Shipment cost based on carrier invoice


We update the cost price of product after reception using the landed cost on incoming shipments.
On outgoing shipment, we compute a theoretical shipment cost from which we deduced the cost sold. But we should also allow to update the shipment cost using the actual invoice of the carrier (or any other services). This will give retrospectively more accurate margin reports.


On a new module account_shipment_cost, we add a document account.shipment_cost which is similar to account.landed_cost but for shipment cost. The available shipment to select are the outgoing and the drop shipments. And the invoice lines available for this document are those for product with the shipment_cost flag checked.
On posting the amount of the invoice lines are allocated to each shipment by updating or added the cost field and the set_shipment_cost is called. The field is updated if there are no other account.shipment_cost posted on the shipment otherwise it is added.


I’m wondering if it’s worth to follow the same desing as landed cost.

I had been requested some times to be able to link the carrier invoices with the shipment that are related. The main reason behind this is to be able to check which shipments had been already invoiced by the carrier and check that they do not invoice a service for a shipment that we did not finally sent (or invoice two times the same shipment).

With this in mind I’m wondering if it won’t be better to be able to select the shipments with an add_remove on invoice line and then distribute the line amout to all this shipments.

I do not think we can assume that there will be only 1 invoice per shipment. Just like the landed cost, we could have custom fees, multiple carriers involved etc. So I think it is right to have the same design as the landed cost.

For now we only accept to have a single carrier on shipments.

In this case why having two modules with the same design and usage?
Won’t be better to have a single module which adds the diferent costs depending on a checkbox on the product?

Also if we have two modules we can use the shipment cost to add the carrier cost and then user the landed cost to add any extra cost that is not directly related to the current carrier.

That is not a reason to not prepare.

For the same reason we have the purchase and sale modules with the same design.

They do not perform the same operations neither on the same document neither at the same time.

I do not understand.

I think you are confusing that landed cost is for incoming shipment and that shipment cost is for outgoing shipment. They do not update the same thing. The landed cost update the unit price of the incoming product such that it cost price computation is modified. The shipment cost update only the shipment cost price of the move that is used for margin reporting.

But maybe we could raise a warning when posting a shipment cost from the same carrier to a shipment that already had a shipment of this carrier.

Here is Issue 10454: Update shipment cost from carrier invoice - Tryton issue tracker which does not include drop shipment because stock_shipment_cost does not support them neither. (And I doubt this is a common practice to have to pay the cost of the drop shipment).