Skip to main content

Extensibility

Additional Sales Charges exposes a set of integration events and public procedures that allow you to extend or integrate with the app from your own AL extension.

Public procedures​

DocChargesMgt_ASC_TSL​

This codeunit is the primary entry point for charge line management. The following procedures are publicly accessible.

CreateDocChargesLines​

procedure CreateDocChargesLines(
var SalesHeader: Record "Sales Header";
PreviewMode: Boolean;
TriggerEnabled: Boolean;
SendNotification: Boolean)

Triggers the charge line creation process for a sales document. Use this procedure to apply charge lines from outside the standard release workflow — for example, from a custom posting routine or a workflow action.

ParameterDescription
SalesHeaderThe sales document to apply charges to.
PreviewModeWhen true, charge lines are created but the notification is suppressed and no permanent side effects are expected.
TriggerEnabledWhen false, the procedure exits immediately without creating lines. Pass true to allow creation.
SendNotificationWhen true, a notification is displayed to the user after lines are created.

DeleteChargesLinesOnReOpen​

procedure DeleteChargesLinesOnReOpen(
var SalesHeader: Record "Sales Header";
PreviewMode: Boolean;
DisplayNotification: Boolean)

Deletes unshipped and fully shipped-and-invoiced charge lines from the document. This is the same cleanup logic called when a document is reopened. Charge lines that have been shipped but not fully invoiced are preserved.

ParameterDescription
SalesHeaderThe sales document to delete charge lines from.
PreviewModeWhen true, suppresses side effects such as notifications.
DisplayNotificationWhen true, shows a notification to the user listing the number of lines deleted.

RecalculateChargesForPosting​

procedure RecalculateChargesForPosting(var SalesHeader: Record "Sales Header")

Recalculates the unit price on unshipped Percentage of Invoice Amount charge lines based on the actual quantities being invoiced. This is called automatically before posting for orders and return orders.


EnsureChargesShipAndInvoice​

procedure EnsureChargesShipAndInvoice(var SalesHeader: Record "Sales Header")

Aligns the Qty. to Ship, Return Qty. to Receive, and Qty. to Invoice fields on charge lines to match the current posting action flags on the Sales Header (Ship, Receive, Invoice). Only unshipped lines are updated; already-shipped lines are not modified.


Integration events​

Integration events allow you to hook into the charge line lifecycle from your own extension. Subscribe to these events to suppress default behaviour, modify lines before they are inserted, or react after lines are created or deleted.

DocChargesMgt_ASC_TSL​

OnBeforeCreateSalesLine, OnBeforeSalesLineInsert and OnAfterCreateSalesLine are also raised for comment charge lines (blank Type), which have no quantity or price. Check SalesLine.Type if your subscriber expects a priced line.

OnBeforeCreateChargesLines​

[IntegrationEvent(false, false)]
local procedure OnBeforeCreateChargesLines(
var SalesHeader: Record "Sales Header";
var IsHandled: Boolean)

Raised before the charge line creation loop begins. Set IsHandled := true to suppress all charge line creation for this document and run.


OnBeforeCreateSalesLine​

[IntegrationEvent(false, false)]
local procedure OnBeforeCreateSalesLine(
var SalesHeader: Record "Sales Header";
var SalesLine: Record "Sales Line";
var IsHandled: Boolean)

Raised before each individual charge sales line is initialised and inserted. Set IsHandled := true to skip creation of this specific line and provide your own instead.


OnBeforeSalesLineInsert​

[IntegrationEvent(false, false)]
local procedure OnBeforeSalesLineInsert(
var SalesHeader: Record "Sales Header";
var SalesLine: Record "Sales Line")

Raised immediately before the charge sales line is inserted into the database. Use this to modify fields on the line before it is committed.


OnAfterCreateSalesLine​

[IntegrationEvent(false, false)]
local procedure OnAfterCreateSalesLine(
var SalesHeader: Record "Sales Header";
var SalesLine: Record "Sales Line")

Raised after the charge sales line has been inserted. Use this for post-processing, logging, or triggering downstream logic.


OnBeforeDeleteChargesLines​

[IntegrationEvent(false, false)]
local procedure OnBeforeDeleteChargesLines(
var SalesHeader: Record "Sales Header";
var PreviewMode: Boolean;
var DisplayNotification: Boolean;
var IsHandled: Boolean)

Raised before charge lines are deleted on reopen. Set IsHandled := true to suppress the default deletion logic and handle it yourself.


OnAfterDeleteChargesLines​

[IntegrationEvent(false, false)]
local procedure OnAfterDeleteChargesLines(
var SalesHeader: Record "Sales Header";
var PreviewMode: Boolean;
var DisplayNotification: Boolean;
var LinesDeleted: Boolean)

Raised after charge lines have been deleted. LinesDeleted indicates whether any lines were actually removed.


GeneralHelperFunctions_ASC_TSL​

OnBeforeEnableDocumentChargeConditions​

[IntegrationEvent(false, false)]
local procedure OnBeforeEnableDocumentChargeConditions(
var DocChgCondition: Record DocChgCondition_ASC_TSL;
var IsHandled: Boolean)

Raised before a charge condition is enabled. Set IsHandled := true to suppress the default enable logic.


OnAfterEnableDocumentChargeConditions​

[IntegrationEvent(false, false)]
local procedure OnAfterEnableDocumentChargeConditions(
var DocChgCondition: Record DocChgCondition_ASC_TSL)

Raised after a charge condition has been enabled.


OnBeforeDisableDocumentChargeConditions​

[IntegrationEvent(false, false)]
local procedure OnBeforeDisableDocumentChargeConditions(
var DocChgCondition: Record DocChgCondition_ASC_TSL;
var IsHandled: Boolean)

Raised before a charge condition is disabled. Set IsHandled := true to suppress the default disable logic.


OnAfterDisableDocumentChargeConditions​

[IntegrationEvent(false, false)]
local procedure OnAfterDisableDocumentChargeConditions(
var DocChgCondition: Record DocChgCondition_ASC_TSL)

Raised after a charge condition has been disabled.


Custom fields on Sales Lines​

Charge lines created by the app carry the following custom fields that can be used when subscribing to the events above or when querying sales lines in your own code.

FieldTypeDescription
ConditionLineId_ASC_TSLGuidThe SystemId of the DocChgConditionLine_ASC_TSL record that produced this line. Blank on regular sales lines.
ConditionLevel_ASC_TSLIntegerThe level at which the charge was applied.
CalculationType_ASC_TSLEnum CalculationType_ASC_TSLThe calculation type used: blank (regular line or comment charge line), Fixed Amount, Sales Price, Percentage, or Percentage of Invoice Amount.

To identify a charge line from your code, filter on ConditionLineId_ASC_TSL <> <blank Guid>.