Hi - I have several Purchase Invoices and Sales Invoices where amounts received are slightly different than the amount recorded my the document. One of these is because someone accidently checked the use rounded total checkbox and shouldn’t have.
Regardless of reason, we try to correct by doing a journal entry to clear the amount difference but we get this error:
@smakheads I ran into this in v15 (details: see below).
I looked into the code throwing the error in apps/erpnext/erpnext/accounts/utils.py:
def check_if_advance_entry_modified(args):
"""
check if there is already a voucher reference
check if amount is same
check if jv is submitted
"""
if not args.get("unreconciled_amount"):
args.update({"unreconciled_amount": args.get("unadjusted_amount")})
ret = None
if args.voucher_type == "Journal Entry":
journal_entry = frappe.qb.DocType("Journal Entry")
journal_acc = frappe.qb.DocType("Journal Entry Account")
q = (
frappe.qb.from_(journal_entry)
.inner_join(journal_acc)
.on(journal_entry.name == journal_acc.parent)
.select(journal_acc[args.get("dr_or_cr")])
.where(
(journal_acc.account == args.get("account"))
& ((journal_acc.party_type == args.get("party_type")))
& ((journal_acc.party == args.get("party")))
& (
(journal_acc.reference_type.isnull())
| (journal_acc.reference_type.isin(["", "Sales Order", "Purchase Order"]))
)
& ((journal_entry.name == args.get("voucher_no")))
& ((journal_acc.name == args.get("voucher_detail_no")))
& ((journal_entry.docstatus == 1))
)
)
else:
#### redacted out
ret = q.run(as_dict=True)
if not ret:
throw(_("""Payment Entry has been modified after you pulled it. Please pull it again."""))
So it looked like a requirement having to do with the reference. I then trying messing with that, to no avail. I ended up creating a Sales Order and that led (won’t describe the detailed steps) to being able to submit the invoice. But what’s interesting is that even after cancelling, unlinking, etc. the Sales Order, the Advance Payments done via Journal Entry still work! So it seems more like some bug having to do with the database table containing Sales Orders being initially empty or non-existant. Maybe someone from the developers can have a look…
Anyhow, simple workaround attempt: Try to create a Sales Order and see if that helps.