due date is not being calculated on sales order and invoice

ernesternest Member Posts: 162
Hi all

I am using Navision 4.0. I have setup one payment term(DAYS5) where due date calculation formula is 5D.

My problem is as below:

when i create new sales order or sales invoice and i choose this payment term the system it is not calculating the due date of the invoice. I check even in the sales header table and the payment term field is being populated correctly, meanwhile the due date is remaining empty.

Can you please help to solve this problem because it is really important for my client?

Thank you all and best regards
Ernest

Comments

  • aavioaavio Member Posts: 143
    yes, i too noticed it now only.... :)

    you can use tables 12170 and 12171 to get due date.
    aav!o
  • ernesternest Member Posts: 162
    I want the users to be able to see the due date in the system or through reports

    Regards
    Ernest
  • chengalasettyvsraochengalasettyvsrao Member Posts: 711
    Check the coding in the Sales Header Table to Caluclate the Due date.

    Trigger : Payment Terms Code - OnValidate()

    What ever the date is caluclated in the sales order the same is copied to Gen.Journal and post to customer Ledger entry.
  • ernesternest Member Posts: 162
    Hi chengalasettyvsrao

    I checked the coding in sales header table and it is as below:

    PaymentSales."Due Date" := CALCDATE(PaymentTermsLine."Due Date Calculation","Document Date");


    I saw something in forums that something like this should work:

    SalesHeader."Due Date" := CALCDATE(PaymentTermsLine."Due Date Calculation","Document Date");


    I think i tried this but still not working.

    Any other ideas

    Thanks again
    Ernest
  • ernesternest Member Posts: 162
    Please help anybody. :(
  • dkonedkone Member Posts: 59
    Hi,

    What is the code on Payment Terms Code - OnValidate() from Sales Header ?

    you should have something like : "Due Date" := CALCDATE(PaymentTerms."Due Date Calculation","Document Date");

    I don't understand what is the "PaymentSales" record ? What is its subtype ?

    Regards,

    dkone.
  • ernesternest Member Posts: 162
    Hi
    Here is the code of Payment Terms - On Validate():


    PaymentSales.RESET;
    PaymentSales.SETRANGE("Sales/Purchase",PaymentSales."Sales/Purchase"::Sales);

    IF "Document Type" <> "Document Type"::"Blanket Order" THEN
    PaymentSales.SETRANGE(Type,"Document Type")
    ELSE
    PaymentSales.SETRANGE(Type,PaymentSales.Type::"Blanket Order");

    PaymentSales.SETRANGE(Code,"No.");
    PaymentSales.DELETEALL;

    IF ("Payment Terms Code" <> '') AND ("Document Date" <> 0D) THEN BEGIN
    PaymentTermsLine.RESET;
    PaymentTermsLine.SETRANGE("Sales/Purchase",PaymentSales."Sales/Purchase"::" ");
    PaymentTermsLine.SETRANGE(Type,PaymentTermsLine.Type::"Payment Terms");
    PaymentTermsLine.SETRANGE(Code,"Payment Terms Code");

    IF PaymentTermsLine.FIND('-') THEN BEGIN
    PaymentCounter := 0;
    DefDueDates.SETCURRENTKEY("No.","To-Date");
    DefDueDates.SETRANGE("No.","Bill-to Customer No.");

    FixedDueDate.RESET;
    FixedDueDate.SETRANGE(Type,FixedDueDate.Type::Customer);
    FixedDueDate.SETRANGE(Code,"Bill-to Customer No.");

    REPEAT
    PaymentSales.INIT;
    PaymentSales."Sales/Purchase" := PaymentSales."Sales/Purchase"::Sales;
    IF "Document Type" <> "Document Type"::"Blanket Order" THEN
    PaymentSales.Type := "Document Type"
    ELSE
    PaymentSales.Type := PaymentSales.Type::"Blanket Order";
    PaymentSales.Code := "No.";
    PaymentCounter := PaymentCounter + 10000;
    PaymentSales."Line No." := PaymentCounter;
    PaymentSales."Payment %" := PaymentTermsLine."Payment %";
    PaymentSales."Due Date Calculation" := PaymentTermsLine."Due Date Calculation";
    PaymentSales."Discount Date Calculation" := PaymentTermsLine."Discount Date Calculation";
    PaymentSales."Discount %" := PaymentTermsLine."Discount %";
    PaymentSales."Due Date" := CALCDATE(PaymentTermsLine."Due Date Calculation","Document Date");


    IF PaymentSales."Due Date" < "Document Date" THEN
    PaymentSales."Due Date" := "Document Date";

    DefDueDates.SETFILTER("To-Date",'%1..',PaymentSales."Due Date");

    IF (DefDueDates.FIND('-')) AND
    (DefDueDates."From-Date" <= PaymentSales."Due Date")
    THEN BEGIN
    PaymentSales."Due Date Calculation" := DefDueDates."Due Date Calculation";
    PaymentSales."Due Date" := CALCDATE(DefDueDates."Due Date Calculation",DefDueDates."To-Date");
    IF PaymentSales."Due Date" < "Document Date" THEN
    PaymentSales."Due Date" := "Document Date";
    END;

    FixedDueDate.SETRANGE("Payment Days",DATE2DMY(PaymentSales."Due Date",1),99);

    IF FixedDueDate.FIND('-') THEN BEGIN
    Day := FixedDueDate."Payment Days";
    MaximumDay := DATE2DMY(CALCDATE('<CM>',PaymentSales."Due Date"),1);
    IF Day > MaximumDay THEN
    Day := MaximumDay;
    Month := DATE2DMY(PaymentSales."Due Date",2);
    Year := DATE2DMY(PaymentSales."Due Date",3);
    PaymentSales."Due Date" := DMY2DATE(Day,Month,Year);
    END ELSE BEGIN
    FixedDueDate.SETRANGE("Payment Days");
    IF FixedDueDate.FIND('-') THEN BEGIN
    Day := FixedDueDate."Payment Days";
    MaximumDay := DATE2DMY(CALCDATE('<CM + 1M>',PaymentSales."Due Date"),1);
    IF Day > MaximumDay THEN
    Day := MaximumDay;
    Month := DATE2DMY(PaymentSales."Due Date",2)+1;
    Year := DATE2DMY(PaymentSales."Due Date",3);
    IF Month = 13 THEN BEGIN
    Month := 1;
    Year := Year + 1;
    END;
    PaymentSales."Due Date" := DMY2DATE(Day,Month,Year);
    END;
    END;

    PaymentSales."Pmt. Discount Date" := CALCDATE(PaymentTermsLine."Discount Date Calculation","Document Date");

    IF PaymentSales."Pmt. Discount Date" < "Document Date" THEN
    PaymentSales."Pmt. Discount Date" := "Document Date";
    PaymentSales.INSERT;
    UNTIL PaymentTermsLine.NEXT = 0;
    END;
    END;

    CALCFIELDS("Payment %");
  • dkonedkone Member Posts: 59
    Hi,

    In your code, there is nothing that put the Due Date of the Sales Header.

    What is the var PaymentSales?

    Look in a standard database, you will find the right code you should have on the OnValidate trigger for setting due date.

    dkone.
Sign In or Register to comment.