Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
399865f
draft need an updte for sure
AndersLarsenMicrosoft Aug 14, 2026
5d4ae67
2 round looks - stillneed to run some test
AndersLarsenMicrosoft Aug 14, 2026
bbe96b3
Merge branch 'main' of https://github.com/microsoft/BCApps into bugs/…
AndersLarsenMicrosoft Aug 14, 2026
41b8368
miapp
AndersLarsenMicrosoft Aug 14, 2026
b6a1e81
miapp
AndersLarsenMicrosoft Aug 17, 2026
b7b915e
miapp
AndersLarsenMicrosoft Aug 17, 2026
fc6cb2c
Resolve leftover merge conflict markers in RU ERM Source Currency test
Copilot Aug 18, 2026
12ae49e
Merge branch 'main' of https://github.com/microsoft/BCApps into bugs/…
AndersLarsenMicrosoft Aug 18, 2026
ab9452d
Revert "miapp"
AndersLarsenMicrosoft Aug 19, 2026
826ffa8
Merge branch 'bugs/646791' of https://github.com/microsoft/BCApps int…
AndersLarsenMicrosoft Aug 19, 2026
353beb0
Revert "miapp"
AndersLarsenMicrosoft Aug 19, 2026
f7a9d65
miapp
AndersLarsenMicrosoft Aug 19, 2026
7cfd7e6
Update the fix
AndersLarsenMicrosoft Aug 19, 2026
43c2f36
Merge branch 'main' of https://github.com/microsoft/BCApps into bugs/…
AndersLarsenMicrosoft Aug 20, 2026
62c2910
Update the fix
AndersLarsenMicrosoft Aug 20, 2026
d22158a
Update miapp
AndersLarsenMicrosoft Aug 20, 2026
e65d6d9
Update miapp
AndersLarsenMicrosoft Aug 20, 2026
fc5c865
Update miapp
AndersLarsenMicrosoft Aug 20, 2026
834fb27
Fix source currency regression in CalcSourceCurrVATBaseAmount
Copilot Aug 21, 2026
b60d241
Update miapp
AndersLarsenMicrosoft Aug 21, 2026
caa3bfe
Merge branch 'main' of https://github.com/microsoft/BCApps into bugs/…
AndersLarsenMicrosoft Aug 21, 2026
8a1db52
Revert "Update miapp"
AndersLarsenMicrosoft Aug 24, 2026
b44c8a2
Revert "Fix source currency regression in CalcSourceCurrVATBaseAmount"
AndersLarsenMicrosoft Aug 24, 2026
085831b
Revert "Update miapp"
AndersLarsenMicrosoft Aug 24, 2026
b41ce80
Revert "Update miapp"
AndersLarsenMicrosoft Aug 24, 2026
32d64b2
Revert "Update miapp"
AndersLarsenMicrosoft Aug 24, 2026
cd43bc2
new base line for the fix
AndersLarsenMicrosoft Aug 24, 2026
6acb8c1
new base line for the fix 2
AndersLarsenMicrosoft Aug 24, 2026
bc45fa1
Merge branch 'main' of https://github.com/microsoft/BCApps into bugs/…
AndersLarsenMicrosoft Aug 24, 2026
25580b6
new base line for the fix 3
AndersLarsenMicrosoft Aug 24, 2026
ef3e957
miapp
AndersLarsenMicrosoft Aug 24, 2026
c9c105d
miapp
AndersLarsenMicrosoft Aug 24, 2026
3b4a259
miapp
AndersLarsenMicrosoft Aug 25, 2026
b3eb576
miapp
AndersLarsenMicrosoft Aug 25, 2026
955d047
miapp
AndersLarsenMicrosoft Aug 28, 2026
a882112
feedback
AndersLarsenMicrosoft Aug 31, 2026
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 @@ -11096,9 +11096,12 @@ codeunit 12 "Gen. Jnl.-Post Line"
if GenJnlLine."Source Curr. VAT Base Amount" <> 0 then
exit(GenJnlLine."Source Curr. VAT Base Amount" + CalcAmountSrcCurr(GenJnlLine, WHTAmountLCY))
else
exit(GenJnlLine."Source Currency Amount" + CalcAmountSrcCurr(GenJnlLine, WHTAmountLCY));
exit(GenJnlLine."Source Currency Amount");
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
end else
exit(CalcAmountSrcCurr(GenJnlLine, GenJnlLine."VAT Base Amount (LCY)" + WHTAmountLCY));
if (GenJnlLine."Source Currency amount" <> (GenJnlLine.Amount - WHTAmountLCY)) and (GenJnlLine."Source Currency Amount" <> 0) then
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
exit(GenJnlLine."Source Currency amount")
else
exit(GenJnlLine.Amount - WHTAmountLCY);
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
end;

local procedure GetVendorPayablesAccount2(var DetailedCVLedgEntryBuffer: Record "Detailed CV Ledg. Entry Buffer"; var GenJournalLine: Record "Gen. Journal Line"; VendPostingGr: Record "Vendor Posting Group"): Code[20]
Expand Down Expand Up @@ -13711,4 +13714,4 @@ codeunit 12 "Gen. Jnl.-Post Line"
local procedure OnPostEmployeeAfterTempDtldCVLedgEntryBufInit(var GenJnlLine: Record "Gen. Journal Line"; var TempDtldCVLedgEntryBuf: Record "Detailed CV Ledg. Entry Buffer" temporary; TaxAmount: Decimal; TaxBaseAmount: Decimal)
begin
end;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8686,7 +8686,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
else
exit(GenJnlLine."Source Currency Amount");
end else
exit(CalcAmountSrcCurr(GenJnlLine, GenJnlLine."VAT Base Amount (LCY)"));
if (GenJnlLine."Source Currency amount" <> (GenJnlLine.Amount - GenJnlLine."VAT Amount")) and (GenJnlLine."Source Currency Amount" <> 0) then
exit(GenJnlLine."Source Currency amount")
else
exit(GenJnlLine.Amount - GenJnlLine."VAT Amount");
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
end;

local procedure GetVendorPayablesAccount2(var DetailedCVLedgEntryBuffer: Record "Detailed CV Ledg. Entry Buffer"; var GenJournalLine: Record "Gen. Journal Line"; VendPostingGr: Record "Vendor Posting Group"): Code[20]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8708,7 +8708,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
else
exit(GenJnlLine."Source Currency Amount");
end else
exit(CalcAmountSrcCurr(GenJnlLine, GenJnlLine."VAT Base Amount (LCY)"));
if (GenJnlLine."Source Currency amount" <> (GenJnlLine.Amount - GenJnlLine."VAT Amount")) and (GenJnlLine."Source Currency Amount" <> 0) then
exit(GenJnlLine."Source Currency amount")
else
exit(GenJnlLine.Amount - GenJnlLine."VAT Amount");
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
end;

local procedure GetVendorPayablesAccount2(var DetailedCVLedgEntryBuffer: Record "Detailed CV Ledg. Entry Buffer"; var GenJournalLine: Record "Gen. Journal Line"; VendPostingGr: Record "Vendor Posting Group"): Code[20]
Expand Down
51 changes: 51 additions & 0 deletions src/Layers/CZ/Tests/ERM-Finance/ERMSourceCurrency.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,57 @@ codeunit 134897 "ERM Source Currency"
Assert.AreEqual(0, SourceCurrencyBalance, TotalSCYAmountNotZeroErr);
end;

[Test]
procedure SalesInvoiceLCYWithPaymentMethodBalAccountPosting()
var
Customer: Record Customer;
GeneralLedgerSetup: Record "General Ledger Setup";
ExistingGeneralLedgerSetup: Record "General Ledger Setup";
PaymentMethod: Record "Payment Method";
SalesHeader: Record "Sales Header";
SalesLine: Record "Sales Line";
SalesPost: Codeunit "Sales-Post";
begin
// [SCENARIO] An LCY sales invoice with a payment method balancing account can be previewed when source currency consistency is enabled.
Initialize();

// [FEATURE] [AI test]
// [GIVEN] Source currency consistency and extended posting preview are enabled.
GeneralLedgerSetup.Get();
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
ExistingGeneralLedgerSetup := GeneralLedgerSetup;
GeneralLedgerSetup.Validate("Check Source Curr. Consistency", true);
GeneralLedgerSetup.Modify(true);

// [GIVEN] A payment method with a G/L balancing account and payment terms without a payment discount.
LibraryERM.CreatePaymentMethod(PaymentMethod);
PaymentMethod.Validate("Bal. Account Type", PaymentMethod."Bal. Account Type"::"G/L Account");
PaymentMethod.Validate("Bal. Account No.", LibraryERM.CreateGLAccountNoWithDirectPosting());
PaymentMethod.Modify(true);

// [GIVEN] A customer whose payment method and payment terms flow to a new LCY sales invoice.
LibrarySales.CreateCustomer(Customer);
Customer.Validate("Payment Method Code", PaymentMethod.Code);
Customer.Modify(true);

LibrarySales.CreateSalesHeader(SalesHeader, SalesHeader."Document Type"::Invoice, Customer."No.");
SalesHeader.TestField("Currency Code", '');
SalesHeader.TestField("Payment Method Code", PaymentMethod.Code);

LibrarySales.CreateSalesLine(
SalesLine, SalesHeader, SalesLine.Type::"G/L Account", LibraryERM.CreateGLAccountWithSalesSetup(), 1);
SalesLine.Validate("Unit Price", LibraryRandom.RandDecInRange(100, 200, 2));
SalesLine.Modify(true);

// [WHEN] Posting the salesinvoice.
SalesPost.Run(SalesHeader);
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.

// [THEN] The posting completes without a source currency consistency error.

//reset General Ledger Setup to original values
GeneralLedgerSetup := ExistingGeneralLedgerSetup;
GeneralLedgerSetup.Modify();
end;

[Test]
procedure SalesInvoiceFCYWithExchRateAdjmtAndPayment()
var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10333,7 +10333,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
else
exit(GenJnlLine."Source Currency Amount");
end else
exit(CalcAmountSrcCurr(GenJnlLine, GenJnlLine."VAT Base Amount (LCY)"));
if (GenJnlLine."Source Currency amount" <> (GenJnlLine.Amount - GenJnlLine."VAT Amount")) and (GenJnlLine."Source Currency Amount" <> 0) then
exit(GenJnlLine."Source Currency amount")
else
exit(GenJnlLine.Amount - GenJnlLine."VAT Amount");
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
end;

local procedure GetVendorPayablesAccount2(var DetailedCVLedgEntryBuffer: Record "Detailed CV Ledg. Entry Buffer"; var GenJournalLine: Record "Gen. Journal Line"; VendPostingGr: Record "Vendor Posting Group"): Code[20]
Expand Down
51 changes: 51 additions & 0 deletions src/Layers/ES/Tests/ERM-Finance/ERMSourceCurrency.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,57 @@ codeunit 134897 "ERM Source Currency"
Assert.AreEqual(0, SourceCurrencyBalance, TotalSCYAmountNotZeroErr);
end;

[Test]
procedure SalesInvoiceLCYWithPaymentMethodBalAccountPosting()
var
Customer: Record Customer;
GeneralLedgerSetup: Record "General Ledger Setup";
ExistingGeneralLedgerSetup: Record "General Ledger Setup";
PaymentMethod: Record "Payment Method";
SalesHeader: Record "Sales Header";
SalesLine: Record "Sales Line";
SalesPost: Codeunit "Sales-Post";
begin
// [SCENARIO] An LCY sales invoice with a payment method balancing account can be previewed when source currency consistency is enabled.
Initialize();

// [FEATURE] [AI test]
// [GIVEN] Source currency consistency and extended posting preview are enabled.
GeneralLedgerSetup.Get();
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
ExistingGeneralLedgerSetup := GeneralLedgerSetup;
GeneralLedgerSetup.Validate("Check Source Curr. Consistency", true);
GeneralLedgerSetup.Modify(true);

// [GIVEN] A payment method with a G/L balancing account and payment terms without a payment discount.
LibraryERM.CreatePaymentMethod(PaymentMethod);
PaymentMethod.Validate("Bal. Account Type", PaymentMethod."Bal. Account Type"::"G/L Account");
PaymentMethod.Validate("Bal. Account No.", LibraryERM.CreateGLAccountNoWithDirectPosting());
PaymentMethod.Modify(true);

// [GIVEN] A customer whose payment method and payment terms flow to a new LCY sales invoice.
LibrarySales.CreateCustomer(Customer);
Customer.Validate("Payment Method Code", PaymentMethod.Code);
Customer.Modify(true);

LibrarySales.CreateSalesHeader(SalesHeader, SalesHeader."Document Type"::Invoice, Customer."No.");
SalesHeader.TestField("Currency Code", '');
SalesHeader.TestField("Payment Method Code", PaymentMethod.Code);

LibrarySales.CreateSalesLine(
SalesLine, SalesHeader, SalesLine.Type::"G/L Account", LibraryERM.CreateGLAccountWithSalesSetup(), 1);
SalesLine.Validate("Unit Price", LibraryRandom.RandDecInRange(100, 200, 2));
SalesLine.Modify(true);

// [WHEN] Posting the salesinvoice.
SalesPost.Run(SalesHeader);
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.

// [THEN] The posting completes without a source currency consistency error.

//reset General Ledger Setup to original values
GeneralLedgerSetup := ExistingGeneralLedgerSetup;
GeneralLedgerSetup.Modify();
end;

[Test]
procedure SalesInvoiceFCYWithExchRateAdjmtAndPayment()
var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8709,7 +8709,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
else
exit(GenJnlLine."Source Currency Amount");
end else
exit(CalcAmountSrcCurr(GenJnlLine, GenJnlLine."VAT Base Amount (LCY)"));
if (GenJnlLine."Source Currency amount" <> (GenJnlLine.Amount - GenJnlLine."VAT Amount")) and (GenJnlLine."Source Currency Amount" <> 0) then
exit(GenJnlLine."Source Currency amount")
else
exit(GenJnlLine.Amount - GenJnlLine."VAT Amount");
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
end;

local procedure GetVendorPayablesAccount2(var DetailedCVLedgEntryBuffer: Record "Detailed CV Ledg. Entry Buffer"; var GenJournalLine: Record "Gen. Journal Line"; VendPostingGr: Record "Vendor Posting Group"): Code[20]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9012,7 +9012,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
else
exit(GenJnlLine."Source Currency Amount");
end else
exit(CalcAmountSrcCurr(GenJnlLine, GenJnlLine."VAT Base Amount (LCY)"));
if (GenJnlLine."Source Currency amount" <> (GenJnlLine.Amount - GenJnlLine."VAT Amount")) and (GenJnlLine."Source Currency Amount" <> 0) then
exit(GenJnlLine."Source Currency amount")
else
exit(GenJnlLine.Amount - GenJnlLine."VAT Amount");
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
end;

local procedure GetVendorPayablesAccount2(var DetailedCVLedgEntryBuffer: Record "Detailed CV Ledg. Entry Buffer"; var GenJournalLine: Record "Gen. Journal Line"; VendPostingGr: Record "Vendor Posting Group"): Code[20]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9688,7 +9688,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
else
exit(GenJnlLine."Source Currency Amount");
end else
exit(CalcAmountSrcCurr(GenJnlLine, GenJnlLine."VAT Base Amount (LCY)"));
if (GenJnlLine."Source Currency amount" <> (GenJnlLine.Amount - GenJnlLine."VAT Amount")) and (GenJnlLine."Source Currency Amount" <> 0) then
exit(GenJnlLine."Source Currency amount")
else
exit(GenJnlLine.Amount - GenJnlLine."VAT Amount");
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
end;

local procedure GetVendorPayablesAccount2(var DetailedCVLedgEntryBuffer: Record "Detailed CV Ledg. Entry Buffer"; var GenJournalLine: Record "Gen. Journal Line"; VendPostingGr: Record "Vendor Posting Group"): Code[20]
Expand Down
51 changes: 51 additions & 0 deletions src/Layers/IT/Tests/ERM-Finance/ERMSourceCurrency.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,57 @@ codeunit 134897 "ERM Source Currency"
Assert.AreEqual(0, SourceCurrencyBalance, TotalSCYAmountNotZeroErr);
end;

[Test]
procedure SalesInvoiceLCYWithPaymentMethodBalAccountPosting()
var
Customer: Record Customer;
GeneralLedgerSetup: Record "General Ledger Setup";
ExistingGeneralLedgerSetup: Record "General Ledger Setup";
PaymentMethod: Record "Payment Method";
SalesHeader: Record "Sales Header";
SalesLine: Record "Sales Line";
SalesPost: Codeunit "Sales-Post";
begin
// [SCENARIO] An LCY sales invoice with a payment method balancing account can be previewed when source currency consistency is enabled.
Initialize();

// [FEATURE] [AI test]
// [GIVEN] Source currency consistency and extended posting preview are enabled.
GeneralLedgerSetup.Get();
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
ExistingGeneralLedgerSetup := GeneralLedgerSetup;
GeneralLedgerSetup.Validate("Check Source Curr. Consistency", true);
GeneralLedgerSetup.Modify(true);

// [GIVEN] A payment method with a G/L balancing account and payment terms without a payment discount.
LibraryERM.CreatePaymentMethod(PaymentMethod);
PaymentMethod.Validate("Bal. Account Type", PaymentMethod."Bal. Account Type"::"G/L Account");
PaymentMethod.Validate("Bal. Account No.", LibraryERM.CreateGLAccountNoWithDirectPosting());
PaymentMethod.Modify(true);

// [GIVEN] A customer whose payment method and payment terms flow to a new LCY sales invoice.
LibrarySales.CreateCustomer(Customer);
Customer.Validate("Payment Method Code", PaymentMethod.Code);
Customer.Modify(true);

LibrarySales.CreateSalesHeader(SalesHeader, SalesHeader."Document Type"::Invoice, Customer."No.");
SalesHeader.TestField("Currency Code", '');
SalesHeader.TestField("Payment Method Code", PaymentMethod.Code);

LibrarySales.CreateSalesLine(
SalesLine, SalesHeader, SalesLine.Type::"G/L Account", LibraryERM.CreateGLAccountWithSalesSetup(), 1);
SalesLine.Validate("Unit Price", LibraryRandom.RandDecInRange(100, 200, 2));
SalesLine.Modify(true);

// [WHEN] Posting the salesinvoice.
SalesPost.Run(SalesHeader);
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.

// [THEN] The posting completes without a source currency consistency error.

//reset General Ledger Setup to original values
GeneralLedgerSetup := ExistingGeneralLedgerSetup;
GeneralLedgerSetup.Modify();
end;

[Test]
procedure SalesInvoiceFCYWithExchRateAdjmtAndPayment()
var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9125,7 +9125,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
else
exit(GenJnlLine."Source Currency Amount");
end else
exit(CalcAmountSrcCurr(GenJnlLine, GenJnlLine."VAT Base Amount (LCY)"));
if (GenJnlLine."Source Currency amount" <> (GenJnlLine.Amount - GenJnlLine."VAT Amount")) and (GenJnlLine."Source Currency Amount" <> 0) then
exit(GenJnlLine."Source Currency amount")
else
exit(GenJnlLine.Amount - GenJnlLine."VAT Amount");
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
end;

local procedure GetVendorPayablesAccount2(var DetailedCVLedgEntryBuffer: Record "Detailed CV Ledg. Entry Buffer"; var GenJournalLine: Record "Gen. Journal Line"; VendPostingGr: Record "Vendor Posting Group"): Code[20]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8747,7 +8747,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
else
exit(GenJnlLine."Source Currency Amount");
end else
exit(CalcAmountSrcCurr(GenJnlLine, GenJnlLine."VAT Base Amount (LCY)"));
if (GenJnlLine."Source Currency amount" <> (GenJnlLine.Amount - GenJnlLine."VAT Amount")) and (GenJnlLine."Source Currency Amount" <> 0) then
exit(GenJnlLine."Source Currency amount")
else
exit(GenJnlLine.Amount - GenJnlLine."VAT Amount");
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
end;

local procedure GetVendorPayablesAccount2(var DetailedCVLedgEntryBuffer: Record "Detailed CV Ledg. Entry Buffer"; var GenJournalLine: Record "Gen. Journal Line"; VendPostingGr: Record "Vendor Posting Group"): Code[20]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11175,7 +11175,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
else
exit(GenJnlLine."Source Currency Amount");
end else
exit(CalcAmountSrcCurr(GenJnlLine, GenJnlLine."VAT Base Amount (LCY)"));
if (GenJnlLine."Source Currency amount" <> (GenJnlLine.Amount - GenJnlLine."VAT Amount")) and (GenJnlLine."Source Currency Amount" <> 0) then
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
exit(GenJnlLine."Source Currency amount")
else
exit(GenJnlLine.Amount - GenJnlLine."VAT Amount");
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
end;

local procedure GetVendorPayablesAccount2(var DetailedCVLedgEntryBuffer: Record "Detailed CV Ledg. Entry Buffer"; var GenJournalLine: Record "Gen. Journal Line"; VendPostingGr: Record "Vendor Posting Group"): Code[20]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1802,3 +1802,4 @@ codeunit 134897 "ERM Source Currency"
end;

}

Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -8643,7 +8643,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
else
exit(GenJnlLine."Source Currency Amount");
end else
exit(CalcAmountSrcCurr(GenJnlLine, GenJnlLine."VAT Base Amount (LCY)"));
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
if (GenJnlLine."Source Currency amount" <> (GenJnlLine.Amount - GenJnlLine."VAT Amount")) and (GenJnlLine."Source Currency Amount" <> 0) then
exit(GenJnlLine."Source Currency amount")
else
exit(GenJnlLine.Amount - GenJnlLine."VAT Amount");
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
end;

local procedure GetVendorPayablesAccount2(var DetailedCVLedgEntryBuffer: Record "Detailed CV Ledg. Entry Buffer"; var GenJournalLine: Record "Gen. Journal Line"; VendPostingGr: Record "Vendor Posting Group"): Code[20]
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
Expand Down
51 changes: 51 additions & 0 deletions src/Layers/W1/Tests/ERM-Finance/ERMSourceCurrency.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,57 @@ codeunit 134897 "ERM Source Currency"
Assert.AreEqual(0, SourceCurrencyBalance, TotalSCYAmountNotZeroErr);
end;

[Test]
procedure SalesInvoiceLCYWithPaymentMethodBalAccountPosting()
var
Customer: Record Customer;
GeneralLedgerSetup: Record "General Ledger Setup";
ExistingGeneralLedgerSetup: Record "General Ledger Setup";
PaymentMethod: Record "Payment Method";
SalesHeader: Record "Sales Header";
SalesLine: Record "Sales Line";
SalesPost: Codeunit "Sales-Post";
begin
// [SCENARIO] An LCY sales invoice with a payment method balancing account can be previewed when source currency consistency is enabled.
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
Initialize();

// [FEATURE] [AI test]
// [GIVEN] Source currency consistency and extended posting preview are enabled.
GeneralLedgerSetup.Get();
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
ExistingGeneralLedgerSetup := GeneralLedgerSetup;
GeneralLedgerSetup.Validate("Check Source Curr. Consistency", true);
GeneralLedgerSetup.Modify(true);

// [GIVEN] A payment method with a G/L balancing account and payment terms without a payment discount.
LibraryERM.CreatePaymentMethod(PaymentMethod);
PaymentMethod.Validate("Bal. Account Type", PaymentMethod."Bal. Account Type"::"G/L Account");
PaymentMethod.Validate("Bal. Account No.", LibraryERM.CreateGLAccountNoWithDirectPosting());
PaymentMethod.Modify(true);

// [GIVEN] A customer whose payment method and payment terms flow to a new LCY sales invoice.
LibrarySales.CreateCustomer(Customer);
Customer.Validate("Payment Method Code", PaymentMethod.Code);
Customer.Modify(true);

LibrarySales.CreateSalesHeader(SalesHeader, SalesHeader."Document Type"::Invoice, Customer."No.");
SalesHeader.TestField("Currency Code", '');
SalesHeader.TestField("Payment Method Code", PaymentMethod.Code);

LibrarySales.CreateSalesLine(
SalesLine, SalesHeader, SalesLine.Type::"G/L Account", LibraryERM.CreateGLAccountWithSalesSetup(), 1);
SalesLine.Validate("Unit Price", LibraryRandom.RandDecInRange(100, 200, 2));
SalesLine.Modify(true);

// [WHEN] Posting the salesinvoice.
SalesPost.Run(SalesHeader);
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.

// [THEN] The posting completes without a source currency consistency error.
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.

//reset General Ledger Setup to original values
Comment thread
AndersLarsenMicrosoft marked this conversation as resolved.
GeneralLedgerSetup := ExistingGeneralLedgerSetup;
GeneralLedgerSetup.Modify();
end;

[Test]
procedure SalesInvoiceFCYWithExchRateAdjmtAndPayment()
var
Expand Down
Loading