Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

(Outstanding) Amount of purchase lines and Cash Flow

Posted on by 220

Hey everyone!

We have observed a very strange behaviour with the amount and the outstanding amount of purchase lines. Sadly, this behaviour renders the cash flow planning module useless.

Every time, we reopen a purchase order, NAV resets the outstanding amount to 0 (Code Unit 415, function Reopen()). This wouldn't be a problem on its own, but our version of NAV won't recalculate the amount when we release the order again. Now this has consequences for the cash flow forecast since it only selects the purchase lines with an outstanding amount > 0.

We are using Dynamics NAV 2013 R2 7.1.36310.0.

Is this a bug or do I muss a hidden feature here? Thanks in advance!

Cheers,
Patrik

*This post is locked for comments

  • Patrik Nordsiek Profile Picture
    Patrik Nordsiek 220 on at
    RE: (Outstanding) Amount of purchase lines and Cash Flow

    Hi there,

    our partner assured us, that this is a bug in the standard NAV.

    However... we found the bug ourselves and it was indeed a problem with a customization. I am sorry, that I caused such a buzz, but again, our partner assured us, that this is no problem with their customization.

    Thanks for all the help, though!

    Evan

  • mmv Profile Picture
    mmv 11,465 on at
    RE: (Outstanding) Amount of purchase lines and Cash Flow

    Hi,

    You may check with your partner to verify the issue.

    Best Regards,

    MMV

  • Patrik Nordsiek Profile Picture
    Patrik Nordsiek 220 on at
    RE: (Outstanding) Amount of purchase lines and Cash Flow

    Hi,

    there is a lot of customization, but nothing on the amount field and as far as I can tell, there is no customization, which influences the amount handling. Additionally, our partner has told us, that they could recreate the problem with standard NAV =/.

    Cheers,

    Patrik

  • mmv Profile Picture
    mmv 11,465 on at
    RE: (Outstanding) Amount of purchase lines and Cash Flow

    Hi,

    Did you check whether there is any customization in the Purchase Line table? (basically the coding)

    Best Regards,

    MMV

  • Patrik Nordsiek Profile Picture
    Patrik Nordsiek 220 on at
    RE: (Outstanding) Amount of purchase lines and Cash Flow

    Hi there,

    let me thank you for all the help first :).

    I checked the CodeUnits. At first glance, the standard sets the amount to zero in CodeUnit 415 in function ReOpen(), line 14. (ZeroAmountInLines).

    Releasing the document will trigger CodeUnit 415's OnRun() function, which updates VATOnLines, but there seems to be no appearance of a calcuation of the amount. Our partner only customizes with a comment to signal the modification. There is none. Here is the code of my CU415:

    IF Status = Status::Released THEN
      EXIT;
    
    TESTFIELD("Buy-from Vendor No.");
    
    // S/ihd700.000.000
    ...
    // E/ihd700.000.000
    
    PurchLine.SETRANGE("Document Type","Document Type");
    PurchLine.SETRANGE("Document No.","No.");
    PurchLine.SETFILTER(Type,'>0');
    PurchLine.SETFILTER(Quantity,'<>0');
    IF NOT PurchLine.FIND('-') THEN
      ERROR(Text001,"Document Type","No.");
    InvtSetup.GET;
    IF InvtSetup."Location Mandatory" THEN BEGIN
      PurchLine.SETRANGE(Type,PurchLine.Type::Item);
      IF PurchLine.FIND('-') THEN
        REPEAT
          IF NOT PurchLine.IsServiceItem THEN
            PurchLine.TESTFIELD("Location Code");
        UNTIL PurchLine.NEXT = 0;
      PurchLine.SETFILTER(Type,'>0');
    END;
    PurchLine.SETRANGE("Drop Shipment",FALSE);
    NotOnlyDropShipment := PurchLine.FIND('-');
    PurchLine.RESET;
    
    // S/ihd700.000.000
    ...
    // E/ihd700.000.000
    
    PurchSetup.GET;
    IF PurchSetup."Calc. Inv. Discount" THEN BEGIN
      PostingDate := "Posting Date";
      PrintPostedDocuments := "Print Posted Documents";
      CODEUNIT.RUN(CODEUNIT::"Purch.-Calc.Discount",PurchLine);
      GET("Document Type","No.");
      "Print Posted Documents" := PrintPostedDocuments;
      IF PostingDate <> "Posting Date" THEN
        VALIDATE("Posting Date",PostingDate);
    END;
    
    IF TestPrepayment(Rec) AND ("Document Type" = "Document Type"::Order) THEN BEGIN
      Status := Status::"Pending Prepayment";
      MODIFY(TRUE);
      EXIT;
    END
      ;
    Status := Status::Released;
    
    PurchLine.SetPurchHeader(Rec);
    PurchLine.CalcVATAmountLines(0,Rec,PurchLine,TempVATAmountLine0);
    PurchLine.CalcVATAmountLines(1,Rec,PurchLine,TempVATAmountLine1);
    PurchLine.UpdateVATOnLines(0,Rec,PurchLine,TempVATAmountLine0);
    PurchLine.UpdateVATOnLines(1,Rec,PurchLine,TempVATAmountLine1);
    
    // S/ihd000.700.000
    ...
    // E/ihd000.700.000
    MODIFY(TRUE);
    
    IF NotOnlyDropShipment THEN
      IF "Document Type" IN ["Document Type"::Order,"Document Type"::"Return Order"] THEN
        WhsePurchRelease.Release(Rec);
    
    // S/uBas7.15
    ...
    // E/uBas7.15
    // S/ihd700.000.000
    ...
    // E/ihd700.000.000


    Cheers,
    Evan

  • mmv Profile Picture
    mmv 11,465 on at
    RE: (Outstanding) Amount of purchase lines and Cash Flow

    Hi,

    Oh!! so the O/S amount is calculated to 0.  It seems to be a customization.  Please check.

    Best Regards,

    MMV

  • Patrik Nordsiek Profile Picture
    Patrik Nordsiek 220 on at
    RE: (Outstanding) Amount of purchase lines and Cash Flow

    Hi,

    the line amount changes to zero. Field No 29.

    Cheers,

    Patrik

  • mmv Profile Picture
    mmv 11,465 on at
    RE: (Outstanding) Amount of purchase lines and Cash Flow

    Hi,

    Which Amount is 0 (zero)?  From InitOutstanding, it will InitOutstandingAmount which will update the "Outstanding Amount".

    Best Regards,

    MMV

  • Patrik Nordsiek Profile Picture
    Patrik Nordsiek 220 on at
    RE: (Outstanding) Amount of purchase lines and Cash Flow

    Hey MMV!

    Thanks again. I can trace the code and I think, my problem lies in line 18 of the function PurchLine.UpdateVATOnLines(). It checks the following:

    IF VATAmountLine.Modified THEN BEGIN

    But if I don't modify the line or the amount line, initOutstanding will not be called, if I see that correctly.

    Another thing I noticed is, that the amount itself is 0, so the outstanding-calculation is right and wrong at the same time ;).

    Cheers,
    Patrik

  • mmv Profile Picture
    mmv 11,465 on at
    RE: (Outstanding) Amount of purchase lines and Cash Flow

    Hi,

    It goes through CodeUnit -> Release Purchase Document ->  (Function) -> PurchLine.UpdateVATOnLines(1,Rec,PurchLine,TempVATAmountLine1);

    From the above function, it calls ->           InitOutstanding;

    So, you may either check  either InitOutstanding (In the Purchase Line table) or PurchLine.UpdateVATOnLines(1,Rec,PurchLine,TempVATAmountLine1);

    Best Regards,

    MMV

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans