-
Notifications
You must be signed in to change notification settings - Fork 387
[Shopify] Fix missing shop currency mapping on order transactions #8679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
256e343
d25c0b2
52f3673
aab6915
d5752fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -77,6 +77,9 @@ codeunit 30161 "Shpfy Import Order" | |||||||||||||||||||||||||||||||||
| OrderEvents: Codeunit "Shpfy Order Events"; | ||||||||||||||||||||||||||||||||||
| OrderFulfillments: Codeunit "Shpfy Order Fulfillments"; | ||||||||||||||||||||||||||||||||||
| ProcessedConflictErr: Label 'The order has already been processed in Business Central, but an edition was received from Shopify. Changes were not propagated to the processed order in Business Central. Update the processed documents to match the received data from Shopify.'; | ||||||||||||||||||||||||||||||||||
| DuplicateISOCodeTelemetryLbl: Label 'Multiple currencies found with ISO Code %1. Count: %2.', Locked = true; | ||||||||||||||||||||||||||||||||||
| CurrencyNotFoundTelemetryLbl: Label 'No currency found with ISO Code %1.', Locked = true; | ||||||||||||||||||||||||||||||||||
| CategoryTok: Label 'Shopify Integration', Locked = true; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| local procedure ImportOrderAndCreateOrUpdate(ShopCode: Code[20]; OrderId: BigInteger) | ||||||||||||||||||||||||||||||||||
| var | ||||||||||||||||||||||||||||||||||
|
|
@@ -651,15 +654,31 @@ codeunit 30161 "Shpfy Import Order" | |||||||||||||||||||||||||||||||||
| GeneralLedgerSetup: Record "General Ledger Setup"; | ||||||||||||||||||||||||||||||||||
| CurrencyCode: Code[10]; | ||||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||||
| if ShopifyCurrencyCode = '' then | ||||||||||||||||||||||||||||||||||
| exit(''); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| GeneralLedgerSetup.Get(); | ||||||||||||||||||||||||||||||||||
| if CopyStr(ShopifyCurrencyCode, 1, MaxStrLen(GeneralLedgerSetup."LCY Code")) = GeneralLedgerSetup."LCY Code" then | ||||||||||||||||||||||||||||||||||
| exit(''); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Currency.SetLoadFields(Code); | ||||||||||||||||||||||||||||||||||
| Currency.SetRange("ISO Code", CopyStr(ShopifyCurrencyCode, 1, 3)); | ||||||||||||||||||||||||||||||||||
| if Currency.FindFirst() then | ||||||||||||||||||||||||||||||||||
| if Currency.Count() = 1 then begin | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currency.Count() called three times in one path
Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||||||||||||||||||||
| Currency.FindFirst(); | ||||||||||||||||||||||||||||||||||
| CurrencyCode := Currency.Code; | ||||||||||||||||||||||||||||||||||
| GeneralLedgerSetup.Get(); | ||||||||||||||||||||||||||||||||||
| if CurrencyCode = GeneralLedgerSetup."LCY Code" then | ||||||||||||||||||||||||||||||||||
| exit('') | ||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||
| exit(CurrencyCode); | ||||||||||||||||||||||||||||||||||
| end else begin | ||||||||||||||||||||||||||||||||||
| if Currency.Count() > 1 then begin | ||||||||||||||||||||||||||||||||||
| Session.LogMessage('0000S1A', StrSubstNo(DuplicateISOCodeTelemetryLbl, ShopifyCurrencyCode, Currency.Count()), Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryTok); | ||||||||||||||||||||||||||||||||||
| Currency.FindFirst(); | ||||||||||||||||||||||||||||||||||
| CurrencyCode := Currency.Code; | ||||||||||||||||||||||||||||||||||
| end else | ||||||||||||||||||||||||||||||||||
| if Currency.Get(CopyStr(ShopifyCurrencyCode, 1, MaxStrLen(Currency.Code))) then | ||||||||||||||||||||||||||||||||||
| CurrencyCode := Currency.Code | ||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||
| Session.LogMessage('0000S1B', StrSubstNo(CurrencyNotFoundTelemetryLbl, ShopifyCurrencyCode), Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryTok); | ||||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| exit(CurrencyCode); | ||||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| local procedure ImportCustomAttributtes(ShopifyOrderId: BigInteger; JCustomAttributtes: JsonArray) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currency filter excludes empty ISO code incorrectly
The filter
Currency.SetFilter("ISO Code", '<>%1&%2', '', CopyStr(ShopifyCurrencyCode, 1, 3))uses&(AND) between the two conditions, which will never match any record because no ISO Code can simultaneously be both not-empty AND match the given currency code. The intended logic is likely OR, or a separateSetRangecall.Recommendation:
Currency.SetRange("ISO Code", CopyStr(ShopifyCurrencyCode, 1, 3));👍 useful · ❤️ especially valuable · 👎 wrong - reply with why