From b340e38c69ea378e680f928953da1c0637f9f3e0 Mon Sep 17 00:00:00 2001 From: v-shuklad Date: Thu, 5 Mar 2026 15:59:46 +0530 Subject: [PATCH 1/3] Changes --- .../App/Deferrals/Tables/VendSubContractDeferral.Table.al | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Apps/W1/Subscription Billing/App/Deferrals/Tables/VendSubContractDeferral.Table.al b/src/Apps/W1/Subscription Billing/App/Deferrals/Tables/VendSubContractDeferral.Table.al index 7423680bb5..46ebc4a78b 100644 --- a/src/Apps/W1/Subscription Billing/App/Deferrals/Tables/VendSubContractDeferral.Table.al +++ b/src/Apps/W1/Subscription Billing/App/Deferrals/Tables/VendSubContractDeferral.Table.al @@ -171,7 +171,7 @@ table 8072 "Vend. Sub. Contract Deferral" Sign := 1; end; end; - if (PurchaseLine.Quantity < 0) and (not PurchaseLine."Discount") then + if PurchaseLine.Quantity < 0 then Sign := Sign * -1; Rec."Vendor No." := PurchaseLine."Pay-to Vendor No."; Rec."Dimension Set ID" := PurchaseLine."Dimension Set ID"; From 00beb0ccf64c184098f5b2c00d218f2825e42b96 Mon Sep 17 00:00:00 2001 From: v-shuklad Date: Fri, 6 Mar 2026 12:24:37 +0530 Subject: [PATCH 2/3] Automation --- .../Deferrals/VendorDeferralsTest.Codeunit.al | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/Apps/W1/Subscription Billing/Test/Deferrals/VendorDeferralsTest.Codeunit.al b/src/Apps/W1/Subscription Billing/Test/Deferrals/VendorDeferralsTest.Codeunit.al index ac5df83204..6a46e2a32a 100644 --- a/src/Apps/W1/Subscription Billing/Test/Deferrals/VendorDeferralsTest.Codeunit.al +++ b/src/Apps/W1/Subscription Billing/Test/Deferrals/VendorDeferralsTest.Codeunit.al @@ -60,6 +60,7 @@ codeunit 139913 "Vendor Deferrals Test" TotalNumberOfMonths: Integer; VendorDeferralsCount: Integer; IsInitialized: Boolean; + ReleasedContractDeferralErr: Label 'Released Contract Deferrals were not reversed properly'; #region Tests @@ -707,6 +708,48 @@ codeunit 139913 "Vendor Deferrals Test" until VendorContractDeferral.Next() = 0; end; + [Test] + [HandlerFunctions('CreateVendorBillingDocsContractPageHandler,ContractDeferralsReleaseRequestPageHandler,MessageHandler')] + procedure VerifyVendSubContrDefAccountBalancedForCreditMemoWithDiscount() + var + SubscriptionLine: Record "Subscription Line"; + ContractDeferralsRelease: Report "Contract Deferrals Release"; + ActualAmount: Decimal; + begin + // [SCENARIO 623041] Verify that released vendor contract deferral amounts have correct sign and GL accounts balance. + Initialize(); + SetPostingAllowTo(0D); + + // [GIVEN] Create Vendor Contract with deferral enabled + CreateVendorContractWithDeferrals('<2M-CM>', true, 1); + + // [GIVEN] Set Discount flag to True on subscription lines + SubscriptionLine.SetRange("Subscription Header No.", ServiceObject."No."); + SubscriptionLine.FindSet(); + repeat + SubscriptionLine.Validate(Discount, true); + SubscriptionLine.Modify(false); + until SubscriptionLine.Next() = 0; + + // [GIVEN] Contract has been created and the billing proposal with non posted contract invoice + CreateBillingProposalAndCreateBillingDocuments('<2M-CM>', '<8M+CM>'); + + // [GIVEN] Post credit memo document + PostPurchDocumentAndFetchDeferrals(); + + // [WHEN] Run Subscription Contract Deferral Release for credit memo + repeat + PostingDate := VendorContractDeferral."Posting Date"; + Commit(); // close transaction before report is called + ContractDeferralsRelease.Run(); // ContractDeferralsReleaseRequestPageHandler + until VendorContractDeferral.Next() = 0; + + // [THEN] Verify "Vend. Sub. Contr. Def. Account" should be balanced after credit memo reversal, which means that released deferral amount was reversed properly + GeneralPostingSetup.Get(Vendor."Gen. Bus. Posting Group", Item."Gen. Prod. Posting Group"); + GetGLEntryAmountFromAccountNo(ActualAmount, GeneralPostingSetup."Vend. Sub. Contr. Def. Account"); + Assert.AreEqual(0, ActualAmount, ReleasedContractDeferralErr); + end; + [Test] procedure UT_CheckFunctionCreateContractDeferralsForPurchaseLine() var From 1ec38e1f4110cfa250be49fbe95ddb6a8a1d7f2f Mon Sep 17 00:00:00 2001 From: v-shuklad Date: Mon, 9 Mar 2026 10:14:53 +0530 Subject: [PATCH 3/3] Changes --- .../App/Deferrals/Tables/VendSubContractDeferral.Table.al | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Apps/W1/Subscription Billing/App/Deferrals/Tables/VendSubContractDeferral.Table.al b/src/Apps/W1/Subscription Billing/App/Deferrals/Tables/VendSubContractDeferral.Table.al index 46ebc4a78b..89a6aee4fa 100644 --- a/src/Apps/W1/Subscription Billing/App/Deferrals/Tables/VendSubContractDeferral.Table.al +++ b/src/Apps/W1/Subscription Billing/App/Deferrals/Tables/VendSubContractDeferral.Table.al @@ -171,8 +171,12 @@ table 8072 "Vend. Sub. Contract Deferral" Sign := 1; end; end; - if PurchaseLine.Quantity < 0 then - Sign := Sign * -1; + + if (PurchaseLine."Document Type" = Enum::"Purchase Document Type"::"Credit Memo") and (PurchaseLine.Quantity < 0) then + Sign := Sign * -1 + else + if (PurchaseLine.Quantity < 0) and (not PurchaseLine."Discount") then + Sign := Sign * -1; Rec."Vendor No." := PurchaseLine."Pay-to Vendor No."; Rec."Dimension Set ID" := PurchaseLine."Dimension Set ID"; Rec."Discount %" := PurchaseLine."Line Discount %";