Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV forum
Answered

Zero Purchase Prices

Posted on by 130

We want to specify some Purchase Prices so that for some of the Vendors POs are entered with Direct Unit Cost of zero.

However there is a piece of code in Codeunit 7010 "Purch. Price Calc. Mgt." that deliberately ignores Purchase Price records with zero Direct Unit Cost.

What is the logic behind it?

If we modify the Codeunit so that the records with zero Direct Unit Cost are included - will there be any negative consequences?

Categories:
  • Verified answer
    BorisK Profile Picture
    BorisK 130 on at
    RE: Zero Purchase Prices

    Just found myself that if the line

    IF "Direct Unit Cost" <> 0 THEN BEGIN               

    is removed then it will not work anyway - further down the line in CalcBestDirectUnitCost() the code assumes that if the "Direct Unit Cost" = 0 in the resulting BestPurchPrice then no suitable Purchase Prices exist, and Unit Cost from Item Card (or SKU) is applied.

    So I guess this is the answer.

  • BorisK Profile Picture
    BorisK 130 on at
    RE: Zero Purchase Prices

    LOCAL FindPurchPrice(VAR ToPurchPrice : Record "Purchase Price";VendorNo : Code[20];ItemNo : Code[20];VariantCode : Code[10];UOM : Code[10];CurrencyCode : Code[10];StartingDate : Date;ShowAll : Boolean)

    WITH FromPurchPrice DO BEGIN

     SETRANGE("Item No.",ItemNo);

     SETRANGE("Purchase Type", "Purchase Type"::Vendor);

     SETRANGE("Purchase Code",VendorNo);

     SETFILTER("Ending Date",'%1|>=%2',0D,StartingDate);

     SETFILTER("Variant Code",'%1|%2',VariantCode,'');

     IF NOT ShowAll THEN BEGIN

       SETRANGE("Starting Date",0D,StartingDate);

       SETFILTER("Currency Code",'%1|%2',CurrencyCode,'');

       SETFILTER("Unit of Measure Code",'%1|%2',UOM,'');

     END;

     ToPurchPrice.RESET;

     ToPurchPrice.DELETEALL;

     IF FIND('-') THEN

       REPEAT

         IF "Direct Unit Cost" <> 0 THEN BEGIN                //this code

           ToPurchPrice := FromPurchPrice;

           ToPurchPrice.INSERT;

         END;

       UNTIL NEXT = 0;

     SETRANGE("Purchase Type", "Purchase Type"::"Vendor Price Group");

     SETRANGE("Purchase Code", Vend."Vendor Price Group Code");

     IF FromPurchPrice.FIND('-') THEN BEGIN

       REPEAT

         IF FromPurchPrice."Direct Unit Cost" <> 0 THEN BEGIN      //this code

           ToPurchPrice := FromPurchPrice;

           ToPurchPrice.INSERT;

         END;

       UNTIL FromPurchPrice.NEXT = 0;

     END;

    END;

  • Hannes Holst Profile Picture
    Hannes Holst 5,767 on at
    RE: Zero Purchase Prices

    Which piece of Code do you mean?

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans