Why do you need this change?
We need a new event inside the procedure CalculateWithholdingTax in order to be able to assign to all/some of the fields "Withholding Account", "Withholding Tax %", "Non Taxable %", "Taxable Base",... a custom value, exploiting the variable WithholdCodeLine.
This event is necessary, since it is not possible to exploit the already existing OnCalculateWithholdingTaxOnAfterAssignWithholdingTaxAmount event, because the only parameter for this event is Rec, but the variable WithholdCodeLine is not accessible. We need WithholdCodeLine to be given as parameter in order to calculate Withholding Account", "Withholding Tax %", "Non Taxable %", "Taxable Base",... in a different way.
As with any IsHandled event, multiple extensions could set IsHandled := true and provide alternative calculation logic. In such cases, the last subscriber modifying the resulting values may determine the final outcome. However, this risk is acceptable because the event is specifically intended to allow partners to replace the standard withholding tax calculation when required by local legislation or customer-specific requirements.
Describe the request
In procedure CalculateWithholdingTax of table 12113 "Tmp Withholding Contribution" we need an event:
[IntegrationEvent(false, false)]
local procedure OnBeforeCalculateWithholdingTax(var Ishandled: Boolean; WithholdCodeLine: Record "Withhold Code Line"; var TmpWithholdingContribution: Record "Tmp Withholding Contribution")
begin
end;
Changes between **:
procedure CalculateWithholdingTax()
var
**IsHandled: boolean;**
begin
WithholdCode.Get("Withholding Tax Code");
WithholdingSocSec.WithholdLineFilter(WithholdCodeLine, "Withholding Tax Code",
"Payment Date");
**ishandled := false;
OnBeforeCalculateWithholdingTax(ishandled, WithholdCodeLine, Rec);
if not ishandled then begin**
"Withholding Account" := WithholdCode."Withholding Taxes Payable Acc.";
"Withholding Tax %" := WithholdCodeLine."Withholding Tax %";
"Non Taxable %" := 100 - WithholdCodeLine."Taxable Base %";
"Taxable Base" := Round(((
"Total Amount" -
"Base - Excluded Amount" -
"Non Taxable Amount By Treaty") *
WithholdCodeLine."Taxable Base %") / 100);
"Non Taxable Amount" := "Total Amount" -
"Base - Excluded Amount" -
"Non Taxable Amount By Treaty" -
"Taxable Base";
"Withholding Tax Amount" := Round("Taxable Base" * "Withholding Tax %" / 100);
**end;**
OnCalculateWithholdingTaxOnAfterAssignWithholdingTaxAmount(Rec);
if "Taxable Base" < 0 then
Error(NegativeTaxableBaseErr);
end;
Performance considerations
CalculateWithholdingTax() is executed only during the calculation and update of withholding tax contributions, typically during payment processing and withholding tax management scenarios. The procedure is not part of high-frequency operations or tight loops processing large datasets.
The proposed change adds only:
OnBeforeCalculateWithholdingTax(IsHandled, WithholdCodeLine, Rec);
which introduces a single event invocation and a Boolean check. No additional database operations are introduced by the platform change itself.
Therefore, the performance impact is negligible.
Data sensitivity review
The event exposes:
var IsHandled: Boolean
WithholdCodeLine: Record "Withhold Code Line"
var TmpWithholdingContribution: Record "Tmp Withholding Contribution"
These records contain withholding tax configuration and calculation data that are already accessible to extensions implementing withholding tax customizations. The proposed event does not expose any new categories of information, personally identifiable information, credentials, or other sensitive data.
The event simply makes the WithholdCodeLine record available at a point where it is currently inaccessible, enabling partners to customize the calculation logic without duplicating the standard implementation.
Therefore, this change does not introduce any sensitive data exposure concerns.
Why do you need this change?
We need a new event inside the procedure CalculateWithholdingTax in order to be able to assign to all/some of the fields "Withholding Account", "Withholding Tax %", "Non Taxable %", "Taxable Base",... a custom value, exploiting the variable WithholdCodeLine.
This event is necessary, since it is not possible to exploit the already existing OnCalculateWithholdingTaxOnAfterAssignWithholdingTaxAmount event, because the only parameter for this event is Rec, but the variable WithholdCodeLine is not accessible. We need WithholdCodeLine to be given as parameter in order to calculate Withholding Account", "Withholding Tax %", "Non Taxable %", "Taxable Base",... in a different way.
As with any IsHandled event, multiple extensions could set IsHandled := true and provide alternative calculation logic. In such cases, the last subscriber modifying the resulting values may determine the final outcome. However, this risk is acceptable because the event is specifically intended to allow partners to replace the standard withholding tax calculation when required by local legislation or customer-specific requirements.
Describe the request
In procedure CalculateWithholdingTax of table 12113 "Tmp Withholding Contribution" we need an event:
Changes between **:
Performance considerations
CalculateWithholdingTax()is executed only during the calculation and update of withholding tax contributions, typically during payment processing and withholding tax management scenarios. The procedure is not part of high-frequency operations or tight loops processing large datasets.The proposed change adds only:
which introduces a single event invocation and a Boolean check. No additional database operations are introduced by the platform change itself.
Therefore, the performance impact is negligible.
Data sensitivity review
The event exposes:
var IsHandled: BooleanWithholdCodeLine: Record "Withhold Code Line"var TmpWithholdingContribution: Record "Tmp Withholding Contribution"These records contain withholding tax configuration and calculation data that are already accessible to extensions implementing withholding tax customizations. The proposed event does not expose any new categories of information, personally identifiable information, credentials, or other sensitive data.
The event simply makes the
WithholdCodeLinerecord available at a point where it is currently inaccessible, enabling partners to customize the calculation logic without duplicating the standard implementation.Therefore, this change does not introduce any sensitive data exposure concerns.