Hello,
Is it possible to have the unit cost for an item on a sales order automatically copy to the unit cost field on a purchase order? When I create a PO the Unit Cost shows up as $0.00 even though I specified a unit cost on the sales order. Our sales team researches cost ahead of time to determine which distributor has the best cost/availability before the order is sent through to our purchasing team. It would be great if purchasing could create a PO and the cost from the SO would automatically get copied over per item.
Thanks!
In this code, SalesLine is not filtered, so the code is wrong. You need to retrive the SalesLine linked to your Purchase Line (Rec), so here it’s missing something like:
SalesLine.SETRANGE(“Document Type”,SalesLine.”Document Type”::Order);
SalesLine.SETRANGE(“Purchase Order No”,Rec.”Document No.”);
SalesLine.SETRANGE(“Purchase Order Line No”,Rec.”Line No.”);
IF SalesLine.FINDFIRST THEN
Rec."Unit Cost" := SalesLine."Unit Cost";
Note that I’m not sure if the fields that link a Sales Line to a Purchase Line in your system are the two fields mentioned above, but it’s just to give you an idea.
Hi Stefano,
The part I'm having trouble with now is filtering the values down so I'm grabbing the value from the correct line.
Here's what I have written so far. I'm trying to get the system to update the unit cost on the purchase line to match the unit cost of the sale line it was created from.
[EventSubscriber(ObjectType::Table, Database::"Purchase Line", 'OnAfterInsertEvent', '', false, false)] local procedure CopyUnitCostFromSalesOrderAfterInsert(var Rec: Record "Purchase Line") var SalesLine: Record "Sales Line"; begin Rec."Unit Cost" := SalesLine."Unit Cost"; end;
It's not critical, but sure would be great to have to eliminate manual entry. I'm happy to put in the time to learn how to accomplish it, but would need some guidance as to how to pass the values from the sales order to the purchase order via an extension.
Just an idea of a possible solution: create an extension with a codeunit and an eventsubscriber to the OnAfterValidate event of the UNit Cost field in the Sales Line table.
From this event, you can filter the Purchase Line table (I don't know what are your criteria) and update the Unit Cost of that record accordingly.
Just few lines of code :)
[quote][/quote]
Sales price and purchase cost are not the same. Because of our ordering process, we list the item's cost AND sales price on a sales order. This lets our purchasing department know what the cost of the item should be when they send the PO to the vendor. The cost changes frequently due to negotiated pricing and promotions or specials that a particular vendor might be running. Ideally, that cost would flow through to the purchase order from the sales order automatically rather than relying on the cost from the item card or from previous purchases of that item. Please let me know if that makes sense.
For picking the vendor, is it possible to specify this on the sales order line item instead of in the intermediate step?
I now understand what you're saying so thanks for that. As standard, you can't add the vendor no. to the order line using the in-app designer, so you wouldn't be able to do it without specialist configuration. Happy to further the discussion on how we could help you do this. I suppose it just depends how much of an issue it is for you?
Thanks, Stefano! How simple of an extension would this be? Can you provide an example of what this might look like in VS Code?
Sales price and purchase cost are not the same. Because of our ordering process, we list the item's cost AND sales price on a sales order. This lets our purchasing department know what the cost of the item should be when they send the PO to the vendor. The cost changes frequently due to negotiated pricing and promotions or specials that a particular vendor might be running. Ideally, that cost would flow through to the purchase order from the sales order automatically rather than relying on the cost from the item card or from previous purchases of that item. Please let me know if that makes sense.
For picking the vendor, is it possible to specify this on the sales order line item instead of in the intermediate step?
The Unit Cost in a Purchase Order comes from the Purchase Price table (if exists). This is the cost defined by the vendor. For overriding it from a sales order you can create a simple extension that validates the purchase line unit cost starting from the sales line cost (quite simple).
Hi, there's a way that you can easily create a purchase document from a Sales order whilst at the same time choosing the supplier that you want to purchase the goods from. I think we need some clarification though as I don't understand why your sales price and your purchase cost would be the same? If this is the case then you won't be making any profit. I've included some screenshots below on how to create a purchase order from a sales order.
[Note - Cost will automatically be pulled through to the purchase order based on the default cost of the item within the item card. The other option is to create Vendor specific pricing per item so that the cost of the goods will be relevant to that Vendor.
Hope this helps...