diff --git a/src/Layers/IT/BaseApp/Local/Finance/WithholdingTax/WithholdingTax.Table.al b/src/Layers/IT/BaseApp/Local/Finance/WithholdingTax/WithholdingTax.Table.al index b6bd7ffba7..96dfe6ea6e 100644 --- a/src/Layers/IT/BaseApp/Local/Finance/WithholdingTax/WithholdingTax.Table.al +++ b/src/Layers/IT/BaseApp/Local/Finance/WithholdingTax/WithholdingTax.Table.al @@ -246,10 +246,12 @@ table 12116 "Withholding Tax" end; trigger OnModify() + var + PreviousWithholdingTax: Record "Withholding Tax"; begin - if Reported or - Paid - then + if not PreviousWithholdingTax.Get(Rec."Entry No.") then + exit; + if (Reported or Paid) and StandardFieldModified(PreviousWithholdingTax) then Error(Text1033); end; @@ -345,6 +347,28 @@ table 12116 "Withholding Tax" WithholdingTaxLine.DeleteAll(true); end; + local procedure StandardFieldModified(PreviousWithholdingTax: Record "Withholding Tax"): Boolean + var + CurrentRecordRef: RecordRef; + PreviousRecordRef: RecordRef; + CurrentFieldRef: FieldRef; + PreviousFieldRef: FieldRef; + FieldIndex: Integer; + begin + CurrentRecordRef.GetTable(Rec); + PreviousRecordRef.GetTable(PreviousWithholdingTax); + for FieldIndex := 1 to CurrentRecordRef.FieldCount() do begin + CurrentFieldRef := CurrentRecordRef.FieldIndex(FieldIndex); + // Field numbers below 50000 belong to the standard table; 50000 and above are extension fields. + if (CurrentFieldRef.Class = FieldClass::Normal) and (CurrentFieldRef.Number < 50000) then begin + PreviousFieldRef := PreviousRecordRef.Field(CurrentFieldRef.Number); + if CurrentFieldRef.Value <> PreviousFieldRef.Value then + exit(true); + end; + end; + exit(false); + end; + [IntegrationEvent(false, false)] local procedure OnValorizzaRitenuteOnAfterAssignSourceWithholdingTax(var WithholdingTax: Record "Withholding Tax") begin