Skip to content
Merged
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 @@ -59,6 +59,7 @@ codeunit 8064 "Sub. Contract Billing Printout"
TempJobLedgerEntryBuffer."Currency Code" := SalesInvoiceHeader."Currency Code";
TempJobLedgerEntryBuffer."Line Amount" := UsageDataBilling.Amount;
end;
OnBeforeInsertUsageDataBilling(TempJobLedgerEntryBuffer, UsageDataBilling, SalesInvoiceHeader, SalesInvoiceLine);
TempJobLedgerEntryBuffer.Insert(false);
until UsageDataBilling.Next() = 0;
end else begin
Expand Down Expand Up @@ -91,6 +92,7 @@ codeunit 8064 "Sub. Contract Billing Printout"
TempJobLedgerEntryBuffer."Line Discount Amount" := Round(BillingLineArchive.Amount * BillingLineArchive."Discount %" / 100, Currency."Amount Rounding Precision");
TempJobLedgerEntryBuffer."Line Amount" := BillingLineArchive.Amount;
end;
OnBeforeInsertBillingLineArchive(TempJobLedgerEntryBuffer, CustomerContract, BillingLineArchive, SalesInvoiceHeader, SalesInvoiceLine);
TempJobLedgerEntryBuffer.Insert(false);
until BillingLineArchive.Next() = 0;
end;
Expand All @@ -115,6 +117,17 @@ codeunit 8064 "Sub. Contract Billing Printout"
SalesInvoiceLine.Init();
end;

[IntegrationEvent(false, false)]
procedure OnBeforeInsertUsageDataBilling(var TempJobLedgerEntryBuffer: Record "Job Ledger Entry"; UsageDataBilling: Record "Usage Data Billing"; SalesInvoiceHeader: Record "Sales Invoice Header"; SalesInvoiceLine: Record "Sales Invoice Line")
begin
end;

[IntegrationEvent(false, false)]
procedure onBeforeInsertBillingLineArchive(var TempJobLedgerEntryBuffer: Record "Job Ledger Entry"; CustomerContract: Record "Customer Subscription Contract"; BillingLineArchive: Record "Billing Line Archive"; SalesInvoiceHeader: Record "Sales Invoice Header"; SalesInvoiceLine: Record "Sales Invoice Line")
begin
end;


var
DiscountPercentLbl: Label 'Discount %';
DiscountAmountLbl: Label 'Discount';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@ reportextension 8008 "Contract Standard Sales Inv." extends "Standard Sales - In
}
}

var
protected var
TempContractBillingDetailsBuffer: Record "Job Ledger Entry" temporary;
TempContractBillingDetailsGroupingBuffer: Record "Job Ledger Entry" temporary;

var
SalesInvoiceLine: Record "Sales Invoice Line";
Customer2: Record Customer;
ContractBillingPrintout: Codeunit "Sub. Contract Billing Printout";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,31 @@ codeunit 8023 "Create Usage Data Billing"
OnAfterCollectServiceCommitments(TempServiceCommitment, ServiceObjectNo, SubscriptionEndDate);
end;

internal procedure CreateUsageDataBillingFromTempServiceCommitments(
var TempServiceCommitment: Record "Subscription Line"; SupplierNo: Code[20]; UsageDataImportEntryNo: Integer; ServiceObjectNo: Code[20]; ProductID: Text[80]; ProductName: Text[100];
BillingPeriodStartDate: Date; BillingPeriodEndDate: Date; UnitCost: Decimal; NewQuantity: Decimal; CostAmount: Decimal; UnitPrice: Decimal; NewAmount: Decimal; CurrencyCode: Code[10])
internal procedure CreateUsageDataBillingFromTempServiceCommitments(var TempServiceCommitment: Record "Subscription Line"; SupplierNo: Code[20]; UsageDataGenericImportGlobal: Record "Usage Data Generic Import")
begin
repeat
CreateUsageDataBillingFromTempServiceCommitment(TempServiceCommitment, SupplierNo, UsageDataImportEntryNo, ServiceObjectNo, ProductID, ProductName, BillingPeriodStartDate, BillingPeriodEndDate, UnitCost, NewQuantity, CostAmount, UnitPrice, NewAmount, CurrencyCode);
CreateUsageDataBillingFromTempServiceCommitment(TempServiceCommitment, SupplierNo, UsageDataGenericImportGlobal);
until TempServiceCommitment.Next() = 0;
OnAfterCreateUsageDataBillingFromTempSubscriptionLines(TempServiceCommitment);
end;

local procedure CreateUsageDataBillingFromTempServiceCommitment(
var TempServiceCommitment: Record "Subscription Line"; SupplierNo: Code[20]; UsageDataImportEntryNo: Integer; SubscriptionNo: Code[20]; ProductID: Text[80]; ProductName: Text[100];
BillingPeriodStartDate: Date; BillingPeriodEndDate: Date; UnitCost: Decimal; NewQuantity: Decimal; CostAmount: Decimal; UnitPrice: Decimal; NewAmount: Decimal; CurrencyCode: Code[10])
local procedure CreateUsageDataBillingFromTempServiceCommitment(var TempServiceCommitment: Record "Subscription Line"; SupplierNo: Code[20]; UsageDataGenericImportGlobal: Record "Usage Data Generic Import")
var
UsageDataBilling: Record "Usage Data Billing";
UsageDataSupplier: Record "Usage Data Supplier";
CurrencyCode: Code[10];
begin
UsageDataSupplier.Get(SupplierNo);

UsageDataBilling.InitFrom(UsageDataImportEntryNo, SubscriptionNo, ProductID, ProductName, BillingPeriodStartDate, BillingPeriodEndDate, NewQuantity);
CurrencyCode := UsageDataGenericImportGlobal.GetCurrencyCode();

UsageDataBilling.InitFrom(
UsageDataGenericImportGlobal."Usage Data Import Entry No.",
UsageDataGenericImportGlobal."Subscription Header No.",
UsageDataGenericImportGlobal."Product ID",
UsageDataGenericImportGlobal."Product Name",
UsageDataGenericImportGlobal."Billing Period Start Date",
UsageDataGenericImportGlobal."Billing Period End Date",
UsageDataGenericImportGlobal.Quantity);
UsageDataBilling."Supplier No." := SupplierNo;
UsageDataBilling.Partner := TempServiceCommitment.Partner;
UsageDataBilling."Subscription Header No." := TempServiceCommitment."Subscription Header No.";
Expand All @@ -75,15 +80,19 @@ codeunit 8023 "Create Usage Data Billing"
UsageDataBilling."Currency Code" := CurrencyCode
else
UsageDataBilling.AlignContractCurrency(TempServiceCommitment, CurrencyCode);
UsageDataBilling.CalculateAmounts(UsageDataSupplier, CurrencyCode, UnitCost, CostAmount, UnitPrice, NewAmount);
UsageDataBilling.CalculateAmounts(UsageDataSupplier, CurrencyCode, UsageDataGenericImportGlobal.Cost, UsageDataGenericImportGlobal."Cost Amount", UsageDataGenericImportGlobal.Price, UsageDataGenericImportGlobal.Amount);
UsageDataBilling.UpdateRebilling();
UsageDataBilling."Entry No." := 0;

OnBeforInsertUsageDataBilling(UsageDataBilling, UsageDataGenericImportGlobal);

UsageDataBilling.Insert(true);
UsageDataBilling.InsertMetadata();

OnAfterCreateUsageDataBillingFromTempSubscriptionLine(TempServiceCommitment, UsageDataBilling);
end;


local procedure FillTempServiceCommitment(var TempServiceCommitment: Record "Subscription Line" temporary; ServiceObjectNo: Code[20]; SubscriptionEndDate: Date)
var
ServiceCommitment: Record "Subscription Line";
Expand Down Expand Up @@ -137,6 +146,12 @@ codeunit 8023 "Create Usage Data Billing"
begin
end;

[IntegrationEvent(false, false)]
local procedure OnBeforInsertUsageDataBilling(var UsageDataBilling: Record "Usage Data Billing"; UsageDataGenericImportGlobal: Record "Usage Data Generic Import")
begin
end;


var
UsageDataImport: Record "Usage Data Import";
UsageDataLinesProcessingErr: Label 'Errors were detected when processing the usage data lines.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,7 @@ codeunit 8033 "Generic Connector Processing" implements "Usage Data Processing"
SetUsageDataGenericImportError(UsageDataGenericImport, '');
if not CheckServiceCommitments(UsageDataGenericImport, TempServiceCommitment) then
exit;
CreateUsageDataBilling.CreateUsageDataBillingFromTempServiceCommitments(
TempServiceCommitment, UsageDataImport."Supplier No.",
UsageDataGenericImport."Usage Data Import Entry No.",
UsageDataGenericImport."Subscription Header No.",
UsageDataGenericImport."Product ID",
UsageDataGenericImport."Product Name",
UsageDataGenericImport."Billing Period Start Date",
UsageDataGenericImport."Billing Period End Date",
UsageDataGenericImport.Cost, UsageDataGenericImport.Quantity,
UsageDataGenericImport."Cost Amount",
UsageDataGenericImport.Price,
UsageDataGenericImport.Amount,
UsageDataGenericImport.GetCurrencyCode());
CreateUsageDataBilling.CreateUsageDataBillingFromTempServiceCommitments(TempServiceCommitment, UsageDataImport."Supplier No.", UsageDataGenericImport);
until UsageDataGenericImport.Next() = 0
else begin
UsageDataImport.SetErrorReason(StrSubstNo(NoDataFoundErr, UsageDataImport."Processing Step"));
Expand Down
Loading