From 432b86344ee664ebed22f560f0ce139241cb5858 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 31 Dec 2013 15:07:58 +0530 Subject: [PATCH] Validate account with reference voucher if against voucher mentioned --- .../doctype/journal_voucher/journal_voucher.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py index 4d00dfd472..c9ca0c2e37 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py @@ -42,7 +42,6 @@ class DocType(AccountsController): def on_submit(self): if self.doc.voucher_type in ['Bank Voucher', 'Contra Voucher', 'Journal Entry']: self.check_credit_days() - self.check_account_against_entries() self.make_gl_entries() self.check_credit_limit() @@ -232,14 +231,20 @@ class DocType(AccountsController): for d in self.doclist.get({"parentfield": "entries"}): if d.against_invoice and webnotes.conn.get_value("Sales Invoice", d.against_invoice, "debit_to") != d.account: - webnotes.throw(_("Credited account (Customer) is not matching with Sales Invoice")) + webnotes.throw(_("Row #") + cstr(d.idx) + ": " + + _("Account is not matching with Debit To account of Sales Invoice")) if d.against_voucher and webnotes.conn.get_value("Purchase Invoice", - d.against_voucher, "credit_to") != d.account: - webnotes.throw(_("Debited account (Supplier) is not matching with Purchase Invoice")) + d.against_voucher, "credit_to") != d.account: + webnotes.throw(_("Row #") + cstr(d.idx) + ": " + + _("Account is not matching with Credit To account of Purchase Invoice")) def make_gl_entries(self, cancel=0, adv_adj=0): from erpnext.accounts.general_ledger import make_gl_entries + + if not cancel: + self.check_account_against_entries() + gl_map = [] for d in self.doclist.get({"parentfield": "entries"}): if d.debit or d.credit: