[SOLVED]Cannot Cancel LCV - Possible bug?

I am unable to cancel LCV for a particular invoice which is throwing the below error.

I can not cancel the purchase invoice as well to amend the Purchase invoice and then repost LCV. It is a redundant issue. This error started after updating to the latest Version

ERPNext: v13.21.0 (version-13)

Frappe Framework: v13.21.0 (version-13)

It is very annoying that every few minutes an error notification pops up.

Traceback (most recent call last):
  File "apps/erpnext/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py", line 103, in repost
    repost_gl_entries(doc)
  File "apps/erpnext/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py", line 153, in repost_gl_entries
    update_gl_entries_after(doc.posting_date, doc.posting_time,
  File "apps/erpnext/erpnext/accounts/utils.py", line 923, in update_gl_entries_after
    repost_gle_for_stock_vouchers(stock_vouchers, posting_date, company, warehouse_account)
  File "apps/erpnext/erpnext/accounts/utils.py", line 944, in repost_gle_for_stock_vouchers
    voucher_obj.make_gl_entries(gl_entries=expected_gle, from_repost=True)
  File "apps/erpnext/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py", line 450, in make_gl_entries
    make_gl_entries(gl_entries, update_outstanding=update_outstanding, merge_entries=False, from_repost=from_repost)
  File "apps/erpnext/erpnext/accounts/general_ledger.py", line 25, in make_gl_entries
    save_entries(gl_map, adv_adj, update_outstanding, from_repost)
  File "apps/erpnext/erpnext/accounts/general_ledger.py", line 152, in save_entries
    round_off_debit_credit(gl_map)
  File "apps/erpnext/erpnext/accounts/general_ledger.py", line 205, in round_off_debit_credit
    frappe.throw(_("Debit and Credit not equal for {0} #{1}. Difference is {2}.")
  File "apps/frappe/frappe/__init__.py", line 444, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)
  File "apps/frappe/frappe/__init__.py", line 423, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 378, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.ValidationError: Debit and Credit not equal for Purchase Invoice #ACC-PINV-2020-00137. Difference is 772.854.

Hi,

Is there additional discount amount in the purchase invoice?

No. There isn’t any discount.

I wonder why isn’t any one acknowledging this issue. One must be able to cancel the LCV irrespective of any links to purchase invoice. If you cannot LCV and cannot cancel purchase invoice the how do we correct the mistake? It has wrong effect on ledger which is not acceptable.

1 Like

@bkm @JayRam

Guys any work around until any Erpnext/Frappe team acknowledges this?

Please raise a GitHub issue.

You can reverse the effect of the Stock and the and Accounting Transactions for now.

Did you manage to figure out why this issue is cropping up? Is it because of different Exchange Rates?

Hope this helps.

Thanks

Jay

@JayRam
I did raise the issue on github but not attended so far.

https://github.com/frappe/erpnext/issues/30010

How can I do so? I cannot cancel or amend either the Invoice or the LCV.

Actually it is very confusing as to figure out what really the issue is. When I try to cancel the invoice it says 772.845 is the difference which is same value of the all three LCVs combined.

But when I try to cancel one of the LCV it says the difference amount is 326.479 which is actually a charge added in the invoice in taxes column.

Look at the General Ledger effect of the LCV and reverse the entry using the same posting date and time (if time is supported): Reversing means move amount for an account from debit to credit or vice versa.

Look at the Stock Ledger effect of the Purchase Invoice and reverse the entry (Stock Entry Material Issue and Charge to the same account that was in the Purchase Invoice. Same rate and quantity)

Now look at the General Ledger impact of the Purchase Invoice and reverse the entry, taking care to leave the items out as you have already reversed it in when you did what I detailed out in the previous paragraph.

I know it’s not elegant, but if you cannot cancel your transaction, something similar to this is your only option.

Hope this helps.

Thanks

Jay

1 Like

@JayRam

Thanks for the clarification. Will try it out and revert .

@NCP

do you have any idea about this? I still couldn’t manage to solve this . One way is to delete the transactions from database which I believe is not the right way. I actually tried this in a test environment and could delete LCV, Purchase Invoice. But there we traces still left as there were links to these documents. This might have wrong effect on ledger and maybe while updating in future.

Hi @Touseef,

can you try this in LCL list to go to action then cancel it.
Please check it.

If not working then i will check your process flow.

Thanks.

I can’t cancel any document as they all are linked. I cannot cancel PO because it has purchase invoice linked. I cannot cancel Purchase invoice as it has Landed Cost voucher linked.
To cancel the purchase invoice one has to cancel the LCV as it is linked to it.
In my case I am unable to cancel the LCV which is very strange.

I’m facing this loop issue with DN, I can’t cancel DN because one item serial number is in transaction when I check that serial number then that shows delivered.

After much of headache the solution was so simple which I stumbled upon while digging the database of LCV. I solved the issue by changing the docstatus to 0 in database which made the LCV back into draft. I could delete all the LCV in draft and make the necessary corrections.

1 Like

Could you tell this procedure in details? I want to cancel a DN so I want access DB like you did. I need support in this: Unable to Cancel DN because of Serial No