Error when posting an Invoice with Quantity 0 in NAV2018

mgnmgn Member Posts: 39
When posting a Sales Invoice (Page43) the function Post() on the Page is called.
Since 2018 the line with the condition "IF ApplicationAreaSetup.IsFoundationEnabled THEN" is removed.

Scenario: When I post invoices to Customers, I like to keep the format (number of lines) the same each invoice. That means that there will be invoices that have lines with Quantity = 0. But now it is not possible to post an Invoice that has 1 or more lines where the Quantity is 0.

Does anyone know what the logic is to remove this option and why this is not made optional with setting?

LOCAL Post(PostingCodeunitID : Integer;Navigate : Option)
IF ApplicationAreaSetup.IsFoundationEnabled THEN
LinesInstructionMgt.SalesCheckAllLinesHaveQuantityAssigned(Rec);

Answers

  • geronimogeronimo Member Posts: 90
    when i check the function SalesCheckAllLinesHaveQuantityAssigned i see the following

    SalesLine.SETRANGE("Document No.",SalesHeader."No.");
    SalesLine.SETRANGE("Document Type",SalesHeader."Document Type");
    SalesLine.SETFILTER(Type,'<>%1',SalesLine.Type::" ");

    can't you add lines with a blank type?
  • mgnmgn Member Posts: 39
    No, I don't want the Type and No. fields to be blank. I want the same lines and description every time I create an Invoice.

    SalesLine.SETRANGE("Document No.",SalesHeader."No.");
    SalesLine.SETRANGE("Document Type",SalesHeader."Document Type");
    SalesLine.SETFILTER(Type,'<>%1',SalesLine.Type::" ");

    IF SalesLine.FINDSET THEN
    REPEAT
    IF (SalesLine."No." <> '') AND (SalesLine.Quantity = 0) THEN
    ERROR(LinesMissingQuantityErr);
    UNTIL SalesLine.NEXT = 0;
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    I don't think it is a bug, more like a bug fix.

    There is a special value of Type field, 0 (Type::" ") which is meant to serve as a free-text/inline comments in sales documents. For other line types if you put something into No. then some Quantity is expected and this is, in my opinion, not an unreasonable requirement.

    This can be seen as a check if someone started to populate the Sales Line (typed some Type and some No.) but has not finished yet, therefore an attempt of posting such 'unfinished' sales order ends up with an error. It is, again in my opinion, better to have this way rather than letting the half-empty line to go through posting.

    If you don't want to post anything from a Sales Line but you do want it in the posted document set both Qty. to Ship and Qty To Invoice to 0 before posting Sales Order
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • mgnmgn Member Posts: 39
    The functionality on the Sales Order Page (42) has not changed between 2017 and 2018. Here I can enter a line with No. <> '' and Quantity = 0. And post for Shipment and Invoice.
    In the Sales Invoice Page (43) the code and functionality behind the Post function has changed; a line with No. <> '' and Quantity = 0 can NOT be posted.
    Fine, if this is the new functionality. But why is it not the same between Order and Invoice?

    Code in page 42
    LOCAL Post(PostingCodeunitID : Integer;Navigate : Option)
    IF ApplicationAreaSetup.IsFoundationEnabled THEN
    LinesInstructionMgt.SalesCheckAllLinesHaveQuantityAssigned(Rec);

    SendToPosting(PostingCodeunitID);


    Code in Page 43
    LOCAL Post(PostingCodeunitID : Integer;Navigate : Option)
    LinesInstructionMgt.SalesCheckAllLinesHaveQuantityAssigned(Rec);
    PreAssignedNo := "No.";

    SendToPosting(PostingCodeunitID);
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    All I am saying is that I can see some logic behind disallowing posting when No. has some value and Quantity not.

    From that point of view it might be seen as that you have exploited an error in the code, an ommision in checking if the line has been fully populated. This error has now been fixed by MS in one place but not in another. Why? Only God and Microsoft know. Well maybe Microsoft only :wink: ...
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.