frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
20.38k stars 7.08k forks source link

Debit and Credit not equal for Purchase Invoice in Landed Cost Voucher (LCV) Distribute Manually #37735

Open albertfns opened 10 months ago

albertfns commented 10 months ago

Information about bug

When you have several invoices in the LCV and you manually distribute the charges, it is not possible to validate the document. It gives the error that Debit and Credit are not the same.

If you change that same LCV to distribution by quantity or amount, it is validated without problem.

It seems to be a very old bug, I have tried it in several versions including the recent version 15

image

image

Steps to reproduce the error:

Module

stock

Version

Frappe Framework: v14.53.2 ERPNext: v14.45.3

Frappe Framework: v15.0.0 ERPNext: v15.0.0

Installation method

docker

Relevant log output / Stack trace / Full Error Message.

request.js:457 Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 95, in application
    response = frappe.api.handle()
               ^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 47, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1622, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/form/save.py", line 31, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 309, in save
    return self._save(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 360, in _save
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1095, in run_post_save_methods
    self.run_method("on_submit")
  File "apps/frappe/frappe/model/document.py", line 919, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1281, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1263, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 916, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py", line 161, in on_submit
    "Total Applicable Charges in Purchase Receipt Items table must be same as Total Taxes and Charges"
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py", line 197, in update_landed_cost
    doc.update_stock_ledger(allow_negative_stock=True, via_landed_cost_voucher=True)
    ^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py", line 562, in make_gl_entries
    make_gl_entries(
  File "apps/erpnext/erpnext/accounts/general_ledger.py", line 43, in make_gl_entries
    save_entries(gl_map, adv_adj, update_outstanding, from_repost)
  File "apps/erpnext/erpnext/accounts/general_ledger.py", line 355, in save_entries
    process_debit_credit_difference(gl_map)
  File "apps/erpnext/erpnext/accounts/general_ledger.py", line 426, in process_debit_credit_difference
    raise_debit_credit_not_equal_error(debit_credit_diff, voucher_type, voucher_no)
  File "apps/erpnext/erpnext/accounts/general_ledger.py", line 463, in raise_debit_credit_not_equal_error
    frappe.throw(
  File "apps/frappe/frappe/__init__.py", line 534, in throw
    msgprint(
  File "apps/frappe/frappe/__init__.py", line 502, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 451, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.ValidationError: Debit and Credit not equal for Purchase Invoice #FCP00458. Difference is -2396.58.

(anonymous) @ request.js:457
frappe.request.cleanup @ request.js:455
(anonymous) @ request.js:314
V @ jquery.js:3500
fireWith @ jquery.js:3630
S0 @ jquery.js:9798
(anonymous) @ jquery.js:10057
load (async)
send @ jquery.js:10076
ajax @ jquery.js:9690
frappe.request.call @ request.js:268
frappe.call @ request.js:105
h @ save.js:245
n @ save.js:23
frappe.ui.form.save @ save.js:272
(anonymous) @ form.js:808
Promise.then (async)
(anonymous) @ dom.js:262
frappe.run_serially @ dom.js:260
validate_and_save @ form.js:799
(anonymous) @ form.js:738
save @ form.js:735
(anonymous) @ form.js:830
Promise.then (async)
(anonymous) @ form.js:825
primary_action @ messages.js:34
(anonymous) @ dialog.js:165
dispatch @ jquery.js:5430
et.handle @ jquery.js:5234
c @ rocket-loader.min.js:1
form.js:744 undefined
(anonymous) @ form.js:744
Promise.catch (async)
save @ form.js:743
(anonymous) @ form.js:830
Promise.then (async)
(anonymous) @ form.js:825
primary_action @ messages.js:34
(anonymous) @ dialog.js:165
dispatch @ jquery.js:5430
et.handle @ jquery.js:5234
c @ rocket-loader.min.js:1
albertfns commented 10 months ago

Any idea what's going on with LCV in this case?