[EventSubscriber](ObjectType::Table, Database:: "Sales Header", 'OnValidatePaymentTermsCodeOnBeforeValidateDueData', '', false, false)
local procedure PaymentTermsBeforeValidateDueData(CUrrentFieldNo: Integer; var IsHandled; var Sales Header: Record)
begin
SalesHeader.Validate(SalesHeader."Due Data", SalesHeader."Document Date");
SalesHeader.Validate(SalesHeader."Due Data", SalesHeader."ITI Sales Date");
SalesHeader.Validate(SalesHeader."Due Data", SalesHeader."Order Date");
SalesHeader.Validate(SalesHeader."Due Data", SalesHeader."Posting Date);
end;
[EventSubscriber](ObjectType::Table, Database:: "Sales Header", 'OnValidatePaymentTermsCodeOnBeforeValidateCalcDueData', '', false, false)
local procedure PaymentTermsBeforeCalcDueData(CalledByFieldNo: Integer; CallingFieldNo: Integer; var IsHandled: Boolean)
var
PaymentTerms: Record "Payment Terms";
begin
if PaymentTerms."Term Calculation Type Payment" = PaymentTerms."Term Calculation Type Payment::"Document Date" then
SalesHeader."Due Data" := CalcDate(PaymentTerms."Due Data Calculation", SalesHeader."Document Date");
if PaymentTerms."Term Calculation Type Payment" = PaymentTerms."Term Calculation Type Payment::"Order Date" then
SalesHeader."Due Data" := CalcDate(PaymentTerms."Due Data Calculation", SalesHeader."Order Date");
if PaymentTerms."Term Calculation Type Payment" = PaymentTerms."Term Calculation Type Payment::"Posting Date" then
SalesHeader."Due Data" := CalcDate(PaymentTerms."Due Data Calculation", SalesHeader."Posting Date");
if PaymentTerms."Term Calculation Type Payment" = PaymentTerms."Term Calculation Type Payment::"Sales Date" then
SalesHeader."Due Data" := CalcDate(PaymentTerms."Due Data Calculation", SalesHeader."ITI Sales Date");
end;