Additional Cost in Stock Entry not distributing when incoming rates are zero

We have a scenario where manufacturing is done from customer provided raw materials.

This means in the stock entry stage, all incoming raw materials will have 0 valuation rates. But there will be work order operation costs added into the additional cost table of stock entry. This cost is not being added to finished good’s valuation. There’s also some weird GL entries being created. Consider the following example.

Stock Entry

  • Raw 1, qty 5, rate 0, allow zero valuation
  • Raw 2, qty 5, rate 0, allow zero valuation
  • Raw 3, qty 5, rate 0, allow zero valuation
  • FG, qty 10, rate 0, not allow zero valuation, expense account: “Stock Adjustment”

Additional Cost - 80,000 with Account “Expenses included in valuation”

When I submit this, it complains that FG line does not allow zero valuation. I was expecting the additional cost to be automatically distributed to FG as 80,000 / 10 = 8,000.

When I did allow zero valuation on FG line though, it can be submitted. However, FG’s valuation will be zero and also the accounting ledger seems strange. It is as follows -
Expenses Included In Valuation: 40,000 credited
Stock Adjustment : 40,000 debited

I’ve checked the code and it seems intentional that if the FG incoming basic rate is 0, additional cost won’t be distributed.

		if self.purpose in ("Repack", "Manufacture"):
			incoming_items_cost = sum(flt(t.basic_amount) for t in self.get("items") if t.is_finished_item)
			incoming_items_cost = sum(flt(t.basic_amount) for t in self.get("items") if t.t_warehouse)

		if not incoming_items_cost:

Is there a reason for this behavior? Also what’s going on with accounting ledger entries?

Thanks for your time!

1 Like

@nay_min Hi!

This needs to be tested!

I’ll try this out and get back to you.

I did make some changes to it based on what I think the behaviour should be.

Here’s my commit

In the get_gl_entries, qty seems to be used as a fall back if the incoming cost is 0, to distribute additional costs. I added that fallback to distribute_additional_cost function as well.

Also GL Entry generation for additional cost seems a bit off, since it’s calculating the incoming item’s amount by all items qty, instead of just incoming item qty. So I changed that as well.

I’ll try submitting a pull request after a few more testing. Would like to have your input on this as well.