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 @@ -171,8 +171,12 @@ table 8072 "Vend. Sub. Contract Deferral"
Sign := 1;
end;
end;
if (PurchaseLine.Quantity < 0) and (not PurchaseLine."Discount") 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 %";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Loading