The "Payment Days Code" field

KlaasFeenstraKlaasFeenstra Member Posts: 35
Hello,

I would like to know the reason for the following code in the OnInsert Trigger of the Customer or Vendor table:


"Payment Days Code" := "No.";
"Non-Paymt. Periods Code" := "No.";

Because of this code, the codeunit 10700 is not working correctly and does not calculate the correct duedate in the case there is a specific Payment date configured in the Company Information table

The code of codeunit 10700 (Version List: NAVES4.00)

PurchAdjustDueDate(VAR Duedate :Date;VendorNo :Code[20]
Vendor.GET(VendorNo);

PaymentDay.RESET;
IF Vendor."Payment Days Code" <> '' THEN BEGIN
PaymentDay.SETRANGE("Table Name",PaymentDay."Table Name"::Vendor);
PaymentDay.SETRANGE(Code,Vendor."Payment Days Code");
PaymentDay."Table Name" := PaymentDay."Table Name"::Vendor;
PaymentDay.Code := Vendor."Payment Days Code";
END ELSE BEGIN
CompanyInfo.GET;
IF CompanyInfo."Payment Days Code" <> '' THEN BEGIN
PaymentDay.SETRANGE("Table Name",PaymentDay."Table Name"::"Company Information");
PaymentDay.SETRANGE(Code,CompanyInfo."Payment Days Code");
PaymentDay."Table Name" := PaymentDay."Table Name"::"Company Information";
PaymentDay.Code := CompanyInfo."Payment Days Code";
END;
END;
NonPaymentPeriod.RESET;
IF Vendor."Non-Paymt. Periods Code" <> '' THEN BEGIN
NonPaymentPeriod.SETRANGE("Table Name",NonPaymentPeriod."Table Name"::Vendor);
NonPaymentPeriod.SETRANGE(Code,Vendor."Non-Paymt. Periods Code");
NonPaymentPeriod."Table Name" := NonPaymentPeriod."Table Name"::Vendor;
NonPaymentPeriod.Code := Vendor."Non-Paymt. Periods Code";
END ELSE BEGIN
CompanyInfo.GET;
IF CompanyInfo."Non-Paymt. Periods Code" <> '' THEN BEGIN
NonPaymentPeriod.SETRANGE("Table Name",NonPaymentPeriod."Table Name"::"Company Information");
NonPaymentPeriod.SETRANGE(Code,CompanyInfo."Non-Paymt. Periods Code");
NonPaymentPeriod."Table Name" := NonPaymentPeriod."Table Name"::"Company Information";
NonPaymentPeriod.Code := CompanyInfo."Non-Paymt. Periods Code";
END;
END;
AdjustDate(DueDate);

Comments

  • nunomaianunomaia Member Posts: 1,153
    This piece of code is specific for Portugal and Spain.
    You can define Nonpayment days for each customer / vendor. When calculating due date will taking in care those day by advancing due date to next payment day.

    Each customer and vendor have their own payment days table, that’s why its creates a code with customer / vendor number.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • KlaasFeenstraKlaasFeenstra Member Posts: 35
    Thanks for your answer, I copied the wrong peace of code in the Post (I modified it, now it is the correct part Adjusting the Vendor duedate instead of the customer duedate).
    The problem is that you can configure in the Company Information, the day that the company is going to pay, for example every month at day 15. You can also configure a special day at Vendor level
    The vendor configuration has a higher priority as the Company configuration, but here is the problem. Because for default it is filling the fields in the vendor table, it will never take into account the configuration at Company level.

    I don´t know if it is usual in Portugal to pay at a specific day at month, but here in Spain it is very usual.
  • nunomaianunomaia Member Posts: 1,153
    Yes you are right. You must clean vendor payment days code, you could comment that code. This feature it’s also in Portugal but isn’t used. Comment code it would the best way.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
Sign In or Register to comment.