Announcements
Hi, i'm struggling with extension to Purchase/Sales Invoices.
I added to "Payment Method Code", TableRealtion named "Type Payment" witch contain: "Document Date", "Order Date", "Posted Date", and "Sales Date".
The purpose is to automatically recalculate the due date when you select a specific "Payment Method Code".
I tried to add it as an eventsub, but to no avail. It still only retrieves the document date automatically. Please help.
Your code looks a bit strange, so i agree with the question Kim is asking you. Why are you doing this, what are you really trying to achieve?
So your original post says that you added fields to Payment Method table but your code is referring to Payment Terms table. Two very different tables. Also, your code CalcDate(PaymentTerms."Due Data Calculation" should be Due Date not Due Data.
But why are you doing this, Due Date is automatically recalculated if you change the payment terms.....
I still need help, anyone?
[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;
I think you need to share the eventsubscriber code with us if we should be able to detect what can be wrong here.
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156