Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -1081,7 +1081,8 @@ codeunit 1255 "Match Bank Payments"
DocumentMatching(
BankPmtApplRule, BankAccReconciliationLine,
TempLedgerEntryMatchingBuffer."Document No.",
TempLedgerEntryMatchingBuffer."External Document No.", TempLedgerEntryMatchingBuffer."Payment Reference");
TempLedgerEntryMatchingBuffer."External Document No.",
TempLedgerEntryMatchingBuffer."Payment Reference");
TotalTimeDocumentNoMatching += CurrentDateTime() - StartTime;
end else begin
StartTime := CurrentDateTime();
Expand Down
50 changes: 50 additions & 0 deletions src/Layers/CH/Tests/Bank/BankPmtApplAlgorithm.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,56 @@
BankAccReconciliationLine."Account Type"::Customer, Amount / 2, 0, 0, 1);
end;

[Test]
[HandlerFunctions('MessageHandler,VerifyMatchDetailsOnPaymentApplicationsPage')]
[Scope('OnPrem')]
procedure TestCustPaymentReferenceMatch()
var
BankAccReconciliation: Record "Bank Acc. Reconciliation";
BankAccReconciliationLine: Record "Bank Acc. Reconciliation Line";
Customer: Record Customer;
CustLedgerEntry: Record "Cust. Ledger Entry";
BankPmtApplRule: Record "Bank Pmt. Appl. Rule";
Amount: Decimal;
DocumentNo: Code[20];
ExtDocNo: Code[20];
PaymentReference: Code[50];
begin
Initialize();

// Setup
CreateCustomer(Customer);
Amount := LibraryRandom.RandDecInRange(1, 1000, 2);
ExtDocNo := '';
PaymentReference := 'PMTREF0001';
DocumentNo := CreateAndPostSalesInvoiceWithOneLine(Customer."No.", ExtDocNo, Amount);

// The W1 Sales Header has no Payment Reference field, so set the reference on the open ledger entry
CustLedgerEntry.SetRange("Document Type", CustLedgerEntry."Document Type"::Invoice);
CustLedgerEntry.SetRange("Customer No.", Customer."No.");
CustLedgerEntry.SetRange("Document No.", DocumentNo);
CustLedgerEntry.FindFirst();
CustLedgerEntry."Payment Reference" := PaymentReference;
CustLedgerEntry.Modify();

CreateBankReconciliationAmountTolerance(BankAccReconciliation, 0);
// No document number in the transaction text, so the payment reference is the only possible match
CreateBankReconciliationLine(BankAccReconciliation, BankAccReconciliationLine, Amount / 2, '', '');
BankAccReconciliationLine.Validate("Payment Reference No.", PaymentReference);
BankAccReconciliationLine.Modify(true);

// Exercise
RunMatch(BankAccReconciliation, true);

// Verify
SetRule(BankPmtApplRule, BankPmtApplRule."Related Party Matched"::No,
BankPmtApplRule."Doc. No./Ext. Doc. No. Matched"::Yes, BankPmtApplRule."Amount Incl. Tolerance Matched"::"No Matches");
VerifyReconciliation(BankPmtApplRule, BankAccReconciliationLine."Statement Line No.");
VerifyEntryApplied(BankAccReconciliationLine, false);
VerifyMatchDetailsData(BankAccReconciliation, BankPmtApplRule,
BankAccReconciliationLine."Account Type"::Customer, Amount / 2, 0, 0, 1);
end;

[Test]
[HandlerFunctions('MessageHandler,VerifyMatchDetailsOnPaymentApplicationsPage')]
[Scope('OnPrem')]
Expand Down
50 changes: 50 additions & 0 deletions src/Layers/DK/Tests/Bank/BankPmtApplAlgorithm.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,56 @@
BankAccReconciliationLine."Account Type"::Customer, Amount / 2, 0, 0, 1);
end;

[Test]
[HandlerFunctions('MessageHandler,VerifyMatchDetailsOnPaymentApplicationsPage')]
[Scope('OnPrem')]
procedure TestCustPaymentReferenceMatch()
var
BankAccReconciliation: Record "Bank Acc. Reconciliation";
BankAccReconciliationLine: Record "Bank Acc. Reconciliation Line";
Customer: Record Customer;
CustLedgerEntry: Record "Cust. Ledger Entry";
BankPmtApplRule: Record "Bank Pmt. Appl. Rule";
Amount: Decimal;
DocumentNo: Code[20];
ExtDocNo: Code[20];
PaymentReference: Code[50];
begin
Initialize();

// Setup
CreateCustomer(Customer);
Amount := LibraryRandom.RandDecInRange(1, 1000, 2);
ExtDocNo := '';
PaymentReference := 'PMTREF0001';
DocumentNo := CreateAndPostSalesInvoiceWithOneLine(Customer."No.", ExtDocNo, Amount);

// The W1 Sales Header has no Payment Reference field, so set the reference on the open ledger entry
CustLedgerEntry.SetRange("Document Type", CustLedgerEntry."Document Type"::Invoice);
CustLedgerEntry.SetRange("Customer No.", Customer."No.");
CustLedgerEntry.SetRange("Document No.", DocumentNo);
CustLedgerEntry.FindFirst();
CustLedgerEntry."Payment Reference" := PaymentReference;
CustLedgerEntry.Modify();

CreateBankReconciliationAmountTolerance(BankAccReconciliation, 0);
// No document number in the transaction text, so the payment reference is the only possible match
CreateBankReconciliationLine(BankAccReconciliation, BankAccReconciliationLine, Amount / 2, '', '');
BankAccReconciliationLine.Validate("Payment Reference No.", PaymentReference);
BankAccReconciliationLine.Modify(true);

// Exercise
RunMatch(BankAccReconciliation, true);

// Verify
SetRule(BankPmtApplRule, BankPmtApplRule."Related Party Matched"::No,
BankPmtApplRule."Doc. No./Ext. Doc. No. Matched"::Yes, BankPmtApplRule."Amount Incl. Tolerance Matched"::"No Matches");
VerifyReconciliation(BankPmtApplRule, BankAccReconciliationLine."Statement Line No.");
VerifyEntryApplied(BankAccReconciliationLine, false);
VerifyMatchDetailsData(BankAccReconciliation, BankPmtApplRule,
BankAccReconciliationLine."Account Type"::Customer, Amount / 2, 0, 0, 1);
end;

[Test]
[HandlerFunctions('MessageHandler,VerifyMatchDetailsOnPaymentApplicationsPage')]
[Scope('OnPrem')]
Expand Down
50 changes: 50 additions & 0 deletions src/Layers/IT/Tests/Bank/BankPmtApplAlgorithm.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,56 @@
BankAccReconciliationLine."Account Type"::Customer, Amount / 2, 0, 0, 1);
end;

[Test]
[HandlerFunctions('MessageHandler,VerifyMatchDetailsOnPaymentApplicationsPage')]
[Scope('OnPrem')]
procedure TestCustPaymentReferenceMatch()
var
BankAccReconciliation: Record "Bank Acc. Reconciliation";
BankAccReconciliationLine: Record "Bank Acc. Reconciliation Line";
Customer: Record Customer;
CustLedgerEntry: Record "Cust. Ledger Entry";
BankPmtApplRule: Record "Bank Pmt. Appl. Rule";
Amount: Decimal;
DocumentNo: Code[20];
ExtDocNo: Code[20];
PaymentReference: Code[50];
begin
Initialize();

// Setup
CreateCustomer(Customer);
Amount := LibraryRandom.RandDecInRange(1, 1000, 2);
ExtDocNo := '';
PaymentReference := 'PMTREF0001';
DocumentNo := CreateAndPostSalesInvoiceWithOneLine(Customer."No.", ExtDocNo, Amount);

// The W1 Sales Header has no Payment Reference field, so set the reference on the open ledger entry
CustLedgerEntry.SetRange("Document Type", CustLedgerEntry."Document Type"::Invoice);
CustLedgerEntry.SetRange("Customer No.", Customer."No.");
CustLedgerEntry.SetRange("Document No.", DocumentNo);
CustLedgerEntry.FindFirst();
CustLedgerEntry."Payment Reference" := PaymentReference;
CustLedgerEntry.Modify();

CreateBankReconciliationAmountTolerance(BankAccReconciliation, 0);
// No document number in the transaction text, so the payment reference is the only possible match
CreateBankReconciliationLine(BankAccReconciliation, BankAccReconciliationLine, Amount / 2, '', '');
BankAccReconciliationLine.Validate("Payment Reference No.", PaymentReference);
BankAccReconciliationLine.Modify(true);

// Exercise
RunMatch(BankAccReconciliation, true);

// Verify
SetRule(BankPmtApplRule, BankPmtApplRule."Related Party Matched"::No,
BankPmtApplRule."Doc. No./Ext. Doc. No. Matched"::Yes, BankPmtApplRule."Amount Incl. Tolerance Matched"::"No Matches");
VerifyReconciliation(BankPmtApplRule, BankAccReconciliationLine."Statement Line No.");
VerifyEntryApplied(BankAccReconciliationLine, false);
VerifyMatchDetailsData(BankAccReconciliation, BankPmtApplRule,
BankAccReconciliationLine."Account Type"::Customer, Amount / 2, 0, 0, 1);
end;

[Test]
[HandlerFunctions('MessageHandler,VerifyMatchDetailsOnPaymentApplicationsPage')]
[Scope('OnPrem')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,8 @@ codeunit 1255 "Match Bank Payments"
DocumentMatching(
BankPmtApplRule, BankAccReconciliationLine,
TempLedgerEntryMatchingBuffer."Document No.",
TempLedgerEntryMatchingBuffer."External Document No.", '');
TempLedgerEntryMatchingBuffer."External Document No.",
TempLedgerEntryMatchingBuffer."Payment Reference");
TotalTimeDocumentNoMatching += CurrentDateTime() - StartTime;
end else begin
StartTime := CurrentDateTime();
Expand Down
50 changes: 50 additions & 0 deletions src/Layers/W1/Tests/Bank/BankPmtApplAlgorithm.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,56 @@
BankAccReconciliationLine."Account Type"::Customer, Amount / 2, 0, 0, 1);
end;

[Test]
[HandlerFunctions('MessageHandler,VerifyMatchDetailsOnPaymentApplicationsPage')]
[Scope('OnPrem')]
procedure TestCustPaymentReferenceMatch()
var
BankAccReconciliation: Record "Bank Acc. Reconciliation";
BankAccReconciliationLine: Record "Bank Acc. Reconciliation Line";
Customer: Record Customer;
CustLedgerEntry: Record "Cust. Ledger Entry";
BankPmtApplRule: Record "Bank Pmt. Appl. Rule";
Amount: Decimal;
DocumentNo: Code[20];
ExtDocNo: Code[20];
PaymentReference: Code[50];
begin
Initialize();

// Setup
CreateCustomer(Customer);
Amount := LibraryRandom.RandDecInRange(1, 1000, 2);
ExtDocNo := '';
PaymentReference := 'PMTREF0001';
DocumentNo := CreateAndPostSalesInvoiceWithOneLine(Customer."No.", ExtDocNo, Amount);

// The W1 Sales Header has no Payment Reference field, so set the reference on the open ledger entry
CustLedgerEntry.SetRange("Document Type", CustLedgerEntry."Document Type"::Invoice);
CustLedgerEntry.SetRange("Customer No.", Customer."No.");
CustLedgerEntry.SetRange("Document No.", DocumentNo);
CustLedgerEntry.FindFirst();
CustLedgerEntry."Payment Reference" := PaymentReference;
CustLedgerEntry.Modify();

CreateBankReconciliationAmountTolerance(BankAccReconciliation, 0);
// No document number in the transaction text, so the payment reference is the only possible match
CreateBankReconciliationLine(BankAccReconciliation, BankAccReconciliationLine, Amount / 2, '', '');
BankAccReconciliationLine.Validate("Payment Reference No.", PaymentReference);
BankAccReconciliationLine.Modify(true);

// Exercise
RunMatch(BankAccReconciliation, true);

// Verify
SetRule(BankPmtApplRule, BankPmtApplRule."Related Party Matched"::No,
BankPmtApplRule."Doc. No./Ext. Doc. No. Matched"::Yes, BankPmtApplRule."Amount Incl. Tolerance Matched"::"No Matches");
VerifyReconciliation(BankPmtApplRule, BankAccReconciliationLine."Statement Line No.");
VerifyEntryApplied(BankAccReconciliationLine, false);
VerifyMatchDetailsData(BankAccReconciliation, BankPmtApplRule,
BankAccReconciliationLine."Account Type"::Customer, Amount / 2, 0, 0, 1);
end;

[Test]
[HandlerFunctions('MessageHandler,VerifyMatchDetailsOnPaymentApplicationsPage')]
[Scope('OnPrem')]
Expand Down