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
@@ -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 @@ -82,6 +82,15 @@ page 8051 "Service Contract Setup"
{
ToolTip = 'Specifies which customer information (name) is transferred to collective invoices. This setting is applies for collective invoices only.';
}
group("Usage Data")
{
Caption = 'Usage Data';

field("Invoice Desc. (Surcharge)"; Rec."Invoice Desc. (Surcharge)")
{
ToolTip = 'Specifies the origin of the invoice details'' description for usage data to be charged as Unit Cost Surcharge.';
}
}
group(ArrangeTexts)
{
Caption = 'Arrange Texts';
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 Desc. (Surcharge)"; Enum "Invoice Detail Origin")
{
Caption = 'Invoice Description (Surcharge)';
}
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 @@ -48,7 +48,7 @@ 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";
TempJobLedgerEntryBuffer.Description := UsageDataBilling.GetPrintoutDescription();
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; 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])
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, SubscriptionNo, 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 Expand Up @@ -694,11 +706,41 @@ table 8006 "Usage Data Billing"
exit((Rec."Document Type" <> "Usage Based Billing Doc. Type"::None) and (Rec."Document No." <> ''));
end;

internal procedure GetPrintoutDescription() Description: Text[100]
begin
if ShouldPrintProductName() then
Description := "Product Name"
else
Description := "Subscription Description";
OnAfterGetPrintoutDescription(Rec, Description);
end;

internal procedure ShouldPrintProductName() Result: Boolean
var
ServiceContractSetup: Record "Subscription Contract Setup";
begin
ServiceContractSetup.Get();
Result :=
("Usage Base Pricing" = Enum::"Usage Based Pricing"::"Unit Cost Surcharge") and
(ServiceContractSetup."Invoice Desc. (Surcharge)" = Enum::"Invoice Detail Origin"::"Product Name (default)");
OnAfterShouldPrintProductName(Rec, Result);
end;

[IntegrationEvent(false, false)]
local procedure OnAfterSaveDocumentValues(UsageDateBilling: Record "Usage Data Billing")
begin
end;

[IntegrationEvent(false, false)]
local procedure OnAfterGetPrintoutDescription(Rec: Record "Usage Data Billing"; var Description: Text[100])
begin
end;

[IntegrationEvent(false, false)]
local procedure OnAfterShouldPrintProductName(Rec: Record "Usage Data Billing"; var Result: Boolean)
begin
end;

var
UsageBasedDocTypeConv: Codeunit "Usage Based Doc. Type Conv.";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<DataExchDef Code="USAGE-GENERIC-US" Name="Usage Data Generic (US format)" Type="3" ReadingWritingXMLport="1220" HeaderLines="1" ColumnSeparator="2" FileEncoding="1" FileType="1" LineSeparator="0">
<DataExchLineDef LineType="0" Code="LINES" Name="Usage data" ColumnCount="15">
<DataExchColumnDef ColumnNo="1" Name="Customer ID" Show="false" DataType="0" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="2" Name="Customer Name" Show="false" DataType="0" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="3" Name="Subscription ID" Show="false" DataType="0" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="4" Name="Product ID" Show="false" DataType="0" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="5" Name="Product Name" Show="false" DataType="0" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="6" Name="Subscription Start Date" Show="false" DataType="1" DataFormat="MM-dd-yyyy" DataFormattingCulture="en-US" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="7" Name="Subscription End Date" Show="false" DataType="1" DataFormat="MM-dd-yyyy" DataFormattingCulture="en-US" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="8" Name="Billing Period Start Date" Show="false" DataType="1" DataFormat="MM-dd-yyyy" DataFormattingCulture="en-US" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="9" Name="Billing Period End Date" Show="false" DataType="1" DataFormat="MM-dd-yyyy" DataFormattingCulture="en-US" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="10" Name="Quantity" Show="false" DataType="2" DataFormattingCulture="en-US" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="11" Name="Unit Cost" Show="false" DataType="2" DataFormattingCulture="en-US" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="12" Name="Unit Price" Show="false" DataType="2" DataFormattingCulture="en-US" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="13" Name="Cost Amount" Show="false" DataType="2" DataFormattingCulture="en-US" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="14" Name="Amount" Show="false" DataType="2" DataFormattingCulture="en-US" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchColumnDef ColumnNo="15" Name="Currency" Show="false" DataType="0" TextPaddingRequired="false" Justification="0" UseNodeNameAsValue="false" BlankZero="false" ExportIfNotBlank="false" />
<DataExchMapping TableId="8018" Name="Usage data" MappingCodeunit="8030">
<DataExchFieldMapping ColumnNo="1" FieldID="7" OverwriteValue="true" />
<DataExchFieldMapping ColumnNo="2" FieldID="8" OverwriteValue="true" />
<DataExchFieldMapping ColumnNo="3" FieldID="10" OverwriteValue="true" />
<DataExchFieldMapping ColumnNo="4" FieldID="17" OverwriteValue="true" />
<DataExchFieldMapping ColumnNo="5" FieldID="18" OverwriteValue="true" />
<DataExchFieldMapping ColumnNo="6" FieldID="13" />
<DataExchFieldMapping ColumnNo="7" FieldID="14" />
<DataExchFieldMapping ColumnNo="8" FieldID="15" />
<DataExchFieldMapping ColumnNo="9" FieldID="16" />
<DataExchFieldMapping ColumnNo="10" FieldID="21" />
<DataExchFieldMapping ColumnNo="11" FieldID="19" />
<DataExchFieldMapping ColumnNo="12" FieldID="20" />
<DataExchFieldMapping ColumnNo="13" FieldID="27" />
<DataExchFieldMapping ColumnNo="14" FieldID="24" />
<DataExchFieldMapping ColumnNo="15" FieldID="25" />
</DataExchMapping>
</DataExchLineDef>
</DataExchDef>
</root>
Loading
Loading