[Release] Perpetual Inventory and Stock Reconciliation

Dear Users,

There was an issue related to perpetual inventory, which was causing difference between inventory balance and accounting balance for a warehouse. We have fixed that issue and re-posted all affected stock vouchers for frappecloud users.

To fix the issue, we have changed some logic to calculate valuation rate during outgoing stock transactions, if stock balance of an item is negative.

Basically when stock goes into negative, system does not get exact purchase/valuation rate for the outgoing items. Hence system previously did not post any accounting entries to book the expenses for those items. Now system will try to predict the purchase rate from the transaction history for that item. Even if the purchase/valuation rate not found, it will try to pick the rate from Buying Price List. If Buying Price List not available for an item, it will request you to create one.

Stock Reconciliation

As per previous logic, if we make a Stock Reconciliation on a specific date (say 1-8-2014), system used to make Stock Ledger Entry for the difference amount, to fix the stock balance as per Reconciliation input. But after that, if we make another entry for that item before reconciliation date (say 1-7-2014), system used to recalculate all future transactions for that item, which led to change in stock balance on the first reconciliation date (i.e. 1-8-2014).

As per the new logic, Stock Reconciliation on a specific date means stock balance frozen for that item on the reconciliation date, and shall not get affected due to stock entries made before its date.

Dear @nabinhait

I see a problem before we update for this release. The problem is that if we freeze the stock due to stock reconciliations then the valuations would go hay-wire.

Suppose: I have stock of Item A as 20 Nos @100/- per pc. So total value in GL and SL should be 2000/- on 01-Jan.

Now I make a SR on 10-Jan as a change in Valuation Rate to say 1000/- so the GL would be Dr by 18000/- to show the GL balance as 20000/- at the same time Cr entry of 18000/- would happen on Stock Adjustment side.

Now if I make a SR on 05-Jan (after doing SR on 10-Jan) for the same valuation rate change like 1000/- so again the system would be making a Cr 18000/- to Stock Adjustment and Dr 18000/- to WH in GL and since as per the new logic the next entry would not get modified this means that the GL would show the WH amount as DR of 2000/- + 18000/- + 18000/- = 38000/- instead of the expected 20000/-

I hope this small example above is taken care of in the new update. (Fingers Crossed).


Yes, we have considered the scenario. While making 2nd Stock Reconciliation on 05-Jan, system will re-post GL entries for all future stock transactions (including Stock Reconciliations on 10th Jan) for the related items. Following will be the accounting entries for different dates:

10th Jan:

Warehouse - 18000 (Dr)
Stock Adjustment - 18000 (Cr)

5th Jan:

Warehouse - 18000 (Dr)
Stock Adjustment - 18000 (Cr)

No accounting entries as there is no change in stock value. Hence, system will delete existing gl entries.

Awesome work @nabinhait

I must say that this patch has indeed solved our problem

Earlier there was a 13.6% difference in the Stock Value in Stock Ledger and General Ledger but now only 0.004% is the difference which is minuscule and I am saying this after checking my GL with stock valuation for 5 months and every where both the values are consistent.

Once again great work and thanks a ton for this update.

Hi @nabinhait,

I have a scenario which basically fails this thing of locking the stock due to stock reconciliation.


  1. Item A has stock of 100 pcs on 01-Jan-2015.
  2. We make a DN for Item A on 01-Jan-2015 for 100 pcs. Now the stock in Ledger is ZERO.
  3. Now on 03-Jan-2015 we do a reconciliation of Item A and find that there is 30pcs and so we do a SR.
  4. On 05-Jan-2015, for some reason the DN is cancelled for 100pcs. So the expected stock should be 130 pcs
  5. But since we are cancelling a DN dated 01-Jan-2015 on 05-Jan-2015, and we have SR on 03-Jan-2015, the system would show only 30pcs on 05-Jan-2015 even after cancelling the DN.

The above scenario according to me is incorrect and to keep the things in line we should have DN or STE cancellations add stock to the Stock Ledger by making a +ve entry for cancelling a DN on the date when the DN or STE is cancelled.

Now in the above case things would be very difficult to track since cancelling a DN would remove the entry from the Stock Ledger but making a new entry in SL on the date of cancellation would be helpful in tracking the problem.

I hope that this scenario is taken care of as the locking of quantities is good only if we are taking into account cancelling of Stock Entries or Delivery Notes or Purchase Receipts on the day of cancellations.

Any update as to how the system would handle the cancelling of Delivery Notes or Stock Entries after the stock reconciliation.


Ping @nabinhait, Kindly please let me know how could I do the following in our system:

  1. I have a delivery note of 50 items. Date is 01-Jun-2015
  2. I would like to cancel this DN in erpnext on say 22-Jun-2015 (due to any reason)
  3. My expectation is that all the 50 items would get the quantities increased in the WH of the DN.
  4. But if there is a Stock Reconciliation of any 1 item in the period of 1 to 22 june then the quantities would not get added
  5. Now to avoid such scenario, I have check the STOCK ledger of each of the 50 items and see if there is no stock reconciliation.
  6. Now if there is a Stock Reconciliation of any item then I have to manually add the Stock Entry for the items.

Kindly let me know if there is an easier way to do this as the current system is just too cumbersome to cancel a DN or STOCK ENTRY.

1 Like

Follow Up:
I think the system is still WRONG when we cancel a Delivery Note or a Sales Invoice after a reconciliation is done.
My solution:

  1. If a STOCK ENTRY or DELIVERY NOTE or SALES INVOICE is cancelled for an item after stock reconciliation for the item has been submitted, then the system should automatically make the STOCK ENTRY for that item in current date and time so that the users are not in this WRONG notion that on CANCELLING of a DN or STE or SI after the STOCK RECONCILIATION would update the stock properly.

Or a STILL BETTER design would be to SUBMIT and CANCEL stock related entries and post their effect on the Stock LEDGER only at the TIME and DATE of SUBMISSION and CANCEL instead of the POSTING DATE.

Since this release there is a major issue in inventory count due to people cancelling the Delivery Notes after 1 or 2 months since the customer did not take the material and honestly there is no way to find out what really caused the stock to MISMATCH.

is there any update on the situation mentioned by @adityaduggal ?

BTW, I have been evaluating ERPNext for the past week and It has been wonderful and smooth experience so far. Good job team ERPNext. Just keep doing what you are doing guys… will make my contributions too once i get up to speed on ERPNext…