Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Microsoft.SubscriptionBilling;

enum 8021 "Invoice Detail Origin"
{
Extensible = true;

value(0; "Product Name (default)")
{
Caption = 'Product Name (default)';
}
value(1; "Subscription Line")
{
Caption = 'Subscription Line';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ page 8051 "Service Contract Setup"
}
}
}
group("Usage Data")
{
Caption = 'Usage Data';

field("Invoice Detail Origin"; Rec."Invoice Detail Origin")
{
ToolTip = 'Specifies the origin of the invoice details'' description for usage data to be charged as Unit Cost Surcharge.';
}
}
group("Gen. Journal Templates")
{
Caption = 'Journal Templates';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ table 8051 "Subscription Contract Setup"
Caption = 'Dimension Code for Customer Subscription Contract';
TableRelation = Dimension;
}
field(30; "Invoice Detail Origin"; Enum "Invoice Detail Origin")
{
Caption = 'Invoice Detail Origin';
}
field(59; "Default Period Calculation"; enum "Period Calculation")
{
Caption = 'Default Period Calculation';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ codeunit 8064 "Sub. Contract Billing Printout"
{
procedure FillContractBillingDetailsBufferFromSalesInvoice(SalesInvoiceHeader: Record "Sales Invoice Header"; var TempJobLedgerEntryBuffer: Record "Job Ledger Entry"; var ColumnHeaders: array[5] of Text)
var
ServiceContractSetup: Record "Subscription Contract Setup";
BillingLineArchive: Record "Billing Line Archive";
SalesInvoiceLine: Record "Sales Invoice Line";
CustomerContract: Record "Customer Subscription Contract";
Expand All @@ -23,6 +24,8 @@ codeunit 8064 "Sub. Contract Billing Printout"
if SalesInvoiceHeader."Sub. Contract Detail Overview" = Enum::"Contract Detail Overview"::None then
exit;

ServiceContractSetup.Get();

SalesDocuments.MoveBillingLineToBillingLineArchiveForPostingPreview(SalesInvoiceHeader);

SalesInvoiceLine.SetRange("Document No.", SalesInvoiceHeader."No.");
Expand All @@ -48,7 +51,12 @@ codeunit 8064 "Sub. Contract Billing Printout"
TempJobLedgerEntryBuffer."Document Date" := UsageDataBilling."Charge Start Date";
TempJobLedgerEntryBuffer."Posting Date" := UsageDataBilling."Charge End Date";
TempJobLedgerEntryBuffer.Quantity := UsageDataBilling.Quantity;
TempJobLedgerEntryBuffer.Description := UsageDataBilling."Subscription Description";
if (UsageDataBilling."Usage Base Pricing" = Enum::"Usage Based Pricing"::"Unit Cost Surcharge") and
(ServiceContractSetup."Invoice Detail Origin" = Enum::"Invoice Detail Origin"::"Product Name (default)")
then
TempJobLedgerEntryBuffer.Description := UsageDataBilling."Product Name"
else
TempJobLedgerEntryBuffer.Description := UsageDataBilling."Subscription Description";
TempJobLedgerEntryBuffer."External Document No." := UsageDataBilling."Subscription Contract No.";
TempJobLedgerEntryBuffer."Resource Group No." := SalesInvoiceHeader."Sell-to Customer No.";
if SalesInvoiceHeader."Sub. Contract Detail Overview" = Enum::"Contract Detail Overview"::Complete then begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,26 @@ 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]; 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]; 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])
begin
repeat
CreateUsageDataBillingFromTempServiceCommitment(TempServiceCommitment, SupplierNo, UsageDataImportEntryNo, ServiceObjectNo, BillingPeriodStartDate, BillingPeriodEndDate, UnitCost, NewQuantity, CostAmount, UnitPrice, NewAmount, CurrencyCode);
CreateUsageDataBillingFromTempServiceCommitment(TempServiceCommitment, SupplierNo, UsageDataImportEntryNo, ServiceObjectNo, ProductID, ProductName, BillingPeriodStartDate, BillingPeriodEndDate, UnitCost, NewQuantity, CostAmount, UnitPrice, NewAmount, CurrencyCode);
until TempServiceCommitment.Next() = 0;
OnAfterCreateUsageDataBillingFromTempSubscriptionLines(TempServiceCommitment);
end;

local procedure CreateUsageDataBillingFromTempServiceCommitment(var TempServiceCommitment: Record "Subscription Line"; SupplierNo: Code[20]; UsageDataImportEntryNo: Integer; ServiceObjectNo: Code[20]; 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]; 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])
var
UsageDataBilling: Record "Usage Data Billing";
UsageDataSupplier: Record "Usage Data Supplier";
begin
UsageDataSupplier.Get(SupplierNo);

UsageDataBilling.InitFrom(UsageDataImportEntryNo, ServiceObjectNo, BillingPeriodStartDate, BillingPeriodEndDate, UnitCost, NewQuantity, CostAmount, UnitPrice, NewAmount, CurrencyCode);
UsageDataBilling.InitFrom(UsageDataImportEntryNo, ServiceObjectNo, ProductID, ProductName, BillingPeriodStartDate, BillingPeriodEndDate, UnitCost, NewQuantity, CostAmount, UnitPrice, NewAmount, CurrencyCode);
UsageDataBilling."Supplier No." := SupplierNo;
UsageDataBilling."Subscription Header No." := TempServiceCommitment."Subscription Header No.";
UsageDataBilling.Partner := TempServiceCommitment.Partner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,19 @@ codeunit 8033 "Generic Connector Processing" implements "Usage Data Processing"
SetUsageDataGenericImportError('');
if not CheckServiceCommitments(TempServiceCommitment) then
exit;
CreateUsageDataBilling.CreateUsageDataBillingFromTempServiceCommitments(TempServiceCommitment, UsageDataImport."Supplier No.", UsageDataGenericImportGlobal."Usage Data Import Entry No.", UsageDataGenericImportGlobal."Subscription Header No.", UsageDataGenericImportGlobal."Billing Period Start Date",
UsageDataGenericImportGlobal."Billing Period End Date", UsageDataGenericImportGlobal.Cost, UsageDataGenericImportGlobal.Quantity,
UsageDataGenericImportGlobal."Cost Amount", UsageDataGenericImportGlobal.Price, UsageDataGenericImportGlobal.Amount, UsageDataGenericImportGlobal.GetCurrencyCode());
CreateUsageDataBilling.CreateUsageDataBillingFromTempServiceCommitments(
TempServiceCommitment, UsageDataImport."Supplier No.",
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.Cost, UsageDataGenericImportGlobal.Quantity,
UsageDataGenericImportGlobal."Cost Amount",
UsageDataGenericImportGlobal.Price,
UsageDataGenericImportGlobal.Amount,
UsageDataGenericImportGlobal.GetCurrencyCode());
until UsageDataGenericImportGlobal.Next() = 0
else begin
UsageDataImport.SetErrorReason(StrSubstNo(NoDataFoundErr, UsageDataImport."Processing Step"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ page 8035 "Usage Data Billings"
{
ToolTip = 'Specifies the Subscription Line for which the usage data is billed.';
}
field("Product ID"; Rec."Product ID") { }
field("Product Name"; Rec."Product Name") { }
field("Processing Date"; Rec."Processing Date")
{
ToolTip = 'Specifies the date of processing.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,16 @@ table 8006 "Usage Data Billing"
{
Caption = 'Rebilling';
}
field(35; "Product ID"; Text[80])
{
Caption = 'Product Id';
ToolTip = 'Specifies the unique ID of the product for this subscription with the supplier.';
}
field(36; "Product Name"; Text[100])
{
Caption = 'Product Name';
ToolTip = 'Specifies the vendor''s product name for this subscription.';
}
}
keys
{
Expand Down Expand Up @@ -347,20 +357,22 @@ table 8006 "Usage Data Billing"
end;
end;

internal procedure InitFrom(UsageDataImportEntryNo: Integer; ServiceObjectNo: Code[20]; BillingPeriodStartDate: Date;
BillingPeriodEndDate: Date; UnitCost: Decimal; NewQuantity: Decimal; CostAmount: Decimal; UnitPrice: Decimal;
NewAmount: Decimal; CurrencyCode: Code[10])
internal procedure InitFrom(UsageDataImportEntryNo: Integer; SubscriptionHeaderNo: 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])
begin
Rec.Init();
Rec."Entry No." := 0;
Rec."Usage Data Import Entry No." := UsageDataImportEntryNo;
Rec."Subscription Header No." := ServiceObjectNo;
Rec."Subscription Header No." := SubscriptionHeaderNo;
Rec."Product ID" := ProductID;
Rec."Product Name" := ProductName;
Rec."Charge Start Date" := BillingPeriodStartDate;
Rec."Charge End Date" := BillingPeriodEndDate;
Rec."Unit Cost" := UnitCost;
Rec.Quantity := NewQuantity;
if CostAmount = 0 then
Rec."Cost Amount" := NewQuantity * unitCost
Rec."Cost Amount" := NewQuantity * UnitCost
else
Rec."Cost Amount" := CostAmount;
Rec."Unit Price" := UnitPrice;
Expand Down
Loading
Loading