So BC 365 v19.5 on-prem here. Due to being on-prem, as well as being a bit behind in version, I am looking to implement a customized AL solution for Tennessee, USA tiered taxes (https://knowledge.avalara.com/bundle/dqa1657870670369_dqa1657870670369/page/ccf1670396346489.html). Looking at Codeunit::"Sales Tax Calculate", there are various events I can listen out for. For example of a use case, if I am creating a Sales Order, then each new line will first pull the matching Tax Area and Tax Jurisdiction details, stuff those into a temporary Sales Tax Amount Line entry, and then push those tax specifics into a new Sales Line. I am looking to subscribe to the event after the new Sales Tax Amount Line entry is created, modify that with the appropriate taxes, and then take those details to push into the new Sales Line.
Any suggestions? Here are the events I see available:
[IntegrationEvent(false, false)] local procedure OnBeforeAddSalesLine(var SalesLine: Record "Sales Line"; var IsHandled: Boolean); begin end; [IntegrationEvent(false, false)] local procedure OnBeforeAddPurchLine(var PurchaseLine: Record "Purchase Line"; var IsHandled: Boolean); begin end; #if not CLEAN17 [Obsolete('Replaced by OnBeforeCalculateTaxProcedure', '17.0')] [IntegrationEvent(false, false)] procedure OnBeforeCalculateTax(TaxAreaCode: Code[20]; TaxGroupCode: Code[20]; TaxLiable: Boolean) begin end; #endif [IntegrationEvent(false, false)] local procedure OnBeforeCalculateTaxProcedure(TaxAreaCode: Code[20]; TaxGroupCode: Code[20]; TaxLiable: Boolean; Date: Date; Amount: Decimal; Quantity: Decimal; ExchangeRate: Decimal; var TaxAmount: Decimal; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeInitSalesTaxLines(var TaxAreaCode: Code[20]; var TaxGroupCode: Code[20]; TaxLiable: Boolean; Amount: Decimal; Quantity: Decimal; Date: Date; DesiredTaxAmount: Decimal; var TMPTaxDetail: Record "Tax Detail"; var IsHandled: Boolean; var Initialised: Boolean; var FirstLine: Boolean; var TotalForAllocation: Decimal) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeDistTaxOverPurchLines(var PurchaseLine: Record "Purchase Line"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeDistTaxOverSalesLines(var SalesLine: Record "Sales Line"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeDistTaxOverServLines(var ServiceLine: Record "Service Line"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeEndSalesTaxCalculationSales(SalesHeader: Record "Sales Header"; var TempSalesTaxAmountLine: Record "Sales Tax Amount Line" temporary; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeEndSalesTaxCalculationPurchase(PurchaseHeader: Record "Purchase Header"; var TempSalesTaxAmountLine: Record "Sales Tax Amount Line" temporary; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeEndSalesTaxCalculationService(ServiceHeader: Record "Service Header"; var TempSalesTaxAmountLine: Record "Sales Tax Amount Line" temporary; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeGetSummarizedSalesTaxTable(var SalesTaxAmountLine: Record "Sales Tax Amount Line"; SourceType: Integer; SourceSubtype: Integer; SourceID: Code[20]; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeGetPostedSummarizedSalesTaxTable(var SalesTaxAmountLine: Record "Sales Tax Amount Line"; var TempSalesTaxAmountDifference: Record "Sales Tax Amount Difference" temporary; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeApplyTaxDifference(var TempSalesTaxAmountLine: Record "Sales Tax Amount Line"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnAfterUpdatePurchaseLineVatPct(var PurchLine: Record "Purchase Line"; PurchHeader: Record "Purchase Header") begin end; [IntegrationEvent(false, false)] local procedure OnDistTaxOverPurchLinesOnPurchLineLoopOnAfterSetPurchLineVATBaseAmount(var PurchLine: Record "Purchase Line"; PurchHeader: Record "Purchase Header") begin end; [IntegrationEvent(false, false)] local procedure OnDistTaxOverPurchLinesOnTempSalesTaxLineLoopOnAfterSetPurchLineVATBaseAmount(var PurchLine: Record "Purchase Line"; PurchHeader: Record "Purchase Header"); begin end; [IntegrationEvent(false, false)] local procedure OnDistTaxOverPurchLinesOnTempSalesTaxLineLoopOnAfterSetTempSalesTaxLineAmount(var TempSalesTaxLine: Record "Sales Tax Amount Line" temporary; PurchLine: Record "Purchase Line"; PurchHeader: Record "Purchase Header"; var Amount: Decimal) begin end; [IntegrationEvent(false, false)] local procedure OnAddPurchInvoiceLinesOnAfterCalcPurchLineSalesTaxAmountLine(var TempSalesTaxLine: Record "Sales Tax Amount Line" temporary; PurchInvLine: Record "Purch. Inv. Line"; PurchInvHeader: Record "Purch. Inv. Header"; ExchangeFactor: Decimal) begin end; [IntegrationEvent(false, false)] local procedure OnAfterAddSalesLine(var TempSalesTaxLine: Record "Sales Tax Amount Line" temporary; SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"; ExchangeFactor: Decimal) begin end; [IntegrationEvent(false, false)] local procedure OnDistTaxOverSalesLinesOnSalesLineLoopOnAfterSetSalesLineVATBaseAmount(var SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"); begin end; [IntegrationEvent(false, false)] local procedure OnDistTaxOverSalesLinesOnTempSalesTaxLineLoopOnAfterSetSalesLineVATBaseAmount(var SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header") begin end; [IntegrationEvent(false, false)] local procedure OnDistTaxOverSalesLinesOnTempSalesTaxLineLoopOnAfterSetTempSalesTaxLineAmount(var TempSalesTaxLine: Record "Sales Tax Amount Line" temporary; SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"; var Amount: Decimal) begin end; [IntegrationEvent(false, false)] local procedure OnEndSalesTaxCalculationOnBeforeSalesTaxAmountLine2Insert(var SalesTaxAmountLine2: Record "Sales Tax Amount Line" temporary; var TempSalesTaxLine: Record "Sales Tax Amount Line" temporary) begin end; [IntegrationEvent(false, false)] local procedure OnEndSalesTaxCalculationOnBeforeTempSalesTaxLineModify(var TempSalesTaxLine: Record "Sales Tax Amount Line" temporary) begin end; [IntegrationEvent(false, false)] local procedure OnEndSalesTaxCalculationOnAfterCalculateMaxAmount(var TempSalesTaxLine: Record "Sales Tax Amount Line" temporary; TaxDetail: Record "Tax Detail"; var MaxAmount: Decimal; var AddedTaxAmount: Decimal; TaxBaseAmt: Decimal); begin end; [IntegrationEvent(false, false)] local procedure OnAfterAddPurchLine(var TempSalesTaxLine: Record "Sales Tax Amount Line" temporary; PurchLine: Record "Purchase Line"; PurchHeader: Record "Purchase Header"; ExchangeFactor: Decimal) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeStartSalestaxCalculation() begin end; [IntegrationEvent(false, false)] local procedure OnAddSalesLineOnAfterTempSalesTaxAmountLineSetFilters(var TempSalesTaxAmountLine: Record "Sales Tax Amount Line" temporary) begin end; [IntegrationEvent(false, false)] local procedure OnAddPurchLineOnAfterTempSalesTaxAmountLineSetFilters(var TempSalesTaxAmountLine: Record "Sales Tax Amount Line" temporary) begin end; [IntegrationEvent(false, false)] local procedure OnAfterGetSalesTaxAmountLineTable(var TempSalesTaxAmountLine: Record "Sales Tax Amount Line" temporary) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeCalculateExpenseTax(TaxAreaCode: Code[20]; TaxGroupCode: Code[20]; TaxLiable: Boolean; Date: Date; Amount: Decimal; Quantity: Decimal; ExchangeRate: Decimal; var TaxAmount: Decimal; var TempTaxDetailMaximums: Record "Tax Detail" temporary; var TaxDetail: Record "Tax Detail"; var TaxAreaLine: Record "Tax Area Line"; var IsHandled: Boolean) begin end;