This event allows you to set the initial data for the Purchase Line for the expense item that is about to be processed (each expense item is processed one at a time in a sequential manner).
Publisher
[IntegrationEvent(false, false)]
procedure OnBeforeCreatePurchaseLine(var onBeforeCreatePurchaseLine: Codeunit "Zde OnBefore Create Purch. Ln")
begin
end;
Subscriber
To subscribe to this event, you will need to decorate the subscriber method with the correct EventSubscriber attributes:
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Zetadocs Expenses Customize", 'OnBeforeCreatePurchaseLine', '', true, true)]
If the expense item contains an amount which is not fully taxable, then 2 lines are created for the expense item. The first line contains the taxable amount with standard rate codes set, the second line contains the non-taxable amount with zero rate codes set.
To deal with any issues relating to differences in how Business Central may be set up to handle rounding of values, an additional adjustment line may be created once all the expense items have been processed in the Expense Data Bundle. Creation of this line can be treated in a similar way to a normal Purchase Line, and will trigger the same events.
This codeunit exposes procedures that allow for prepopulation of Purchase Invoice line values before the standard processing occurs on an expense item, as well as giving access to the expenses export data. The following methods are currently available on instances of the OnBeforeCreatePurchaseLine data type.
Method name |
Description |
---|---|
GetExpensesExportData (var exportData: Codeunit "Zde Export Data Integration") |
Returns the Expense Export Data for the expense item that is about to be processed. |
GetPurchaseLine (var purchaseLine: Record "Purchase Line") |
Returns the current Purchase Line. |
UpdatePurchaseLine (purchaseLine: Record "Purchase Line") |
Sets new data into the Purchase Line |
GetPurchaseLineNonTaxable (var purchaseLineNonTaxable: Record "Purchase Line") |
Returns the Purchase Line for the non-taxable adjustment line. |
UpdatePurchaseLineNonTaxable (purchaseLineNonTaxable: Record "Purchase Line") |
Sets new data for the Purchase Line relating to the non-taxable adjustment line. |
SetError (errorMessage: Text) |
Allows setting of a custom error message. |
Init() |
This method is called internally by the publisher, a call to this method will return an error. |
Provides a way to retrieve Expense Data for the current expense item from the Export Bundle.
Syntax
onBeforeCreatePurchaseLine. GetExpensesExportData (var exportData: Codeunit "Zde Export Data Integration");
Parameters
exportData
Type: Codeunit "Zde Export Data Integration"
This codeunit gives you read access to all the values for the current expense.
Provides a way to retrieve the Purchase Line that is currently set.
Syntax
onBeforeCreatePurchaseLine. GetPurchaseLine(var purchaseLine: Record "Purchase Line");
Parameters
purchaseLine
Type: Record "Purchase Line"
Purchase Line before it is processed by the standard logic. Does not contain any data at this stage (Unless it has previously been set by the UpdatePurchaseLine method). For an expense item with part of the amount being taxable it will be the taxable part. For taxable expense it will be taxable amount. For a non-taxable expense item, it will be the non-taxable amount. For a final report adjustment it will be the adjustment’s non-taxable amount.
Provides a way to set the Purchase Line with updated information.
Syntax
onBeforeCreatePurchaseLine. UpdatePurchaseLine(purchaseLine: Record "Purchase Line");
Parameters
purchaseLine
Type: Record "Purchase Line"
Purchase Line used later in export process.
Provides a way to retrieve the Purchase Line that is currently set for the adjustment line.
Syntax
onBeforeCreatePurchaseLine.GetPurchaseLineNonTaxable(var purchaseLineNonTaxable: Record "Purchase Line");
Parameters
purchaseLineNonTaxable
Type: Record "Purchase Line"
Purchase Line for the non-taxable portion of the expense item. Does not contain any data at this stage (Unless it has previously been set by the UpdatePurchaseLine method). This will generally return an empty record unless the expense item has a non-taxable portion.
Provides a way to set the Purchase Line for the non-taxable adjustment line with updated information
Syntax
onBeforeCreatePurchaseLine.UpdatePurchaseLineNonTaxable(purchaseLineNonTaxable: Record "Purchase Line");
Parameters
purchaseLineNonTaxable
Type: Record "Purchase Line"
Purchase Line used later in export process.
Use this method to set custom error messages that will be populated in the Expense Report.
Syntax
onBeforeCreatePurchaseLine.SetError(errorMessage: Text);
Parameters
errorMessage
Type: Text
The error message to display to the user in the Export Report.