Skip to content
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

Dev/gga/shopify v2 #4

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ codeunit 30316 "Shpfy Posted Invoice Export"
exit(false);
end;

if not CurrencyCodeMatch(SalesInvoiceHeader) then
exit(false);

if not ShopifyPaymentTermsExists(SalesInvoiceHeader."Payment Terms Code") then
exit(false);

Expand All @@ -111,6 +114,24 @@ codeunit 30316 "Shpfy Posted Invoice Export"
exit(true);
end;

local procedure CurrencyCodeMatch(SalesInvoiceHeader: Record "Sales Invoice Header"): Boolean
var
GeneralLedgerSetup: Record "General Ledger Setup";
ShopifyLocalCurrencyCode: Code[10];
begin
GeneralLedgerSetup.Get();

if ShpfyShop."Currency Code" = '' then
ShopifyLocalCurrencyCode := GeneralLedgerSetup."LCY Code"
else
ShopifyLocalCurrencyCode := ShpfyShop."Currency Code";

if SalesInvoiceHeader."Currency Code" = '' then
exit(ShopifyLocalCurrencyCode = GeneralLedgerSetup."LCY Code")
else
exit(ShopifyLocalCurrencyCode = SalesInvoiceHeader."Currency Code");
end;

local procedure ShopifyPaymentTermsExists(PaymentTermsCode: Code[10]): Boolean
var
ShpfyPaymentTerms: Record "Shpfy Payment Terms";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,22 @@ codeunit 30168 "Shpfy Payment Terms API"
JsonHelper.GetValueIntoField(JTemplate, 'description', PaymentTermRecordRef, ShpfyPaymentTerms.FieldNo(Description));
PaymentTermRecordRef.SetTable(ShpfyPaymentTerms);

if ShpfyPaymentTerms.Type = 'FIXED' then
if ShouldBeMarkedAsPrimary() then
ShpfyPaymentTerms.Validate("Is Primary", true);

if IsNew then
ShpfyPaymentTerms.Insert(true)
else
ShpfyPaymentTerms.Modify(true);
end;

local procedure ShouldBeMarkedAsPrimary(): Boolean
var
ShpfyPaymentTerms: Record "Shpfy Payment Terms";
begin
ShpfyPaymentTerms.SetRange("Shop Code", ShopCode);
ShpfyPaymentTerms.SetRange("Is Primary", true);
exit(ShpfyPaymentTerms.IsEmpty());
end;
}