[payment reconciliation] do not allow negative outstanding in case of against_jv
diff --git a/accounts/doctype/gl_entry/gl_entry.py b/accounts/doctype/gl_entry/gl_entry.py
index 429cc10..112e449 100644
--- a/accounts/doctype/gl_entry/gl_entry.py
+++ b/accounts/doctype/gl_entry/gl_entry.py
@@ -42,9 +42,9 @@
self.check_negative_balance(adv_adj)
# Update outstanding amt on against voucher
- if self.doc.against_voucher and self.doc.against_voucher_type not in \
- ('Journal Voucher','POS') and update_outstanding == 'Yes':
- self.update_outstanding_amt()
+ if self.doc.against_voucher and self.doc.against_voucher_type != "POS" \
+ and update_outstanding == 'Yes':
+ self.update_outstanding_amt()
def check_mandatory(self):
mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company']
@@ -164,16 +164,25 @@
and ifnull(is_cancelled,'No') = 'No'""",
(self.doc.against_voucher, self.doc.against_voucher_type))[0][0] or 0.0)
- if self.doc.against_voucher_type=='Purchase Invoice':
- # amount to debit
+ if self.doc.against_voucher_type == 'Purchase Invoice':
bal = -bal
+ elif self.doc.against_voucher_type == "Journal Voucher":
+ against_voucher_amount = flt(webnotes.conn.sql("""select sum(debit) - sum(credit)
+ from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s
+ and account = %s""", (self.doc.against_voucher, self.doc.account))[0][0])
+
+ bal = against_voucher_amount + bal
+ if against_voucher_amount < 0:
+ bal = -bal
+
# Validation : Outstanding can not be negative
if bal < 0 and self.doc.is_cancelled == 'No':
msgprint(_("Outstanding for Voucher ") + self.doc.against_voucher +
- _(" will become ") + fmt_money(bal) + _("Outstanding cannot be less than zero. \
+ _(" will become ") + fmt_money(bal) + _(". Outstanding cannot be less than zero. \
Please match exact outstanding."), raise_exception=1)
# Update outstanding amt on against voucher
- sql("update `tab%s` set outstanding_amount=%s where name='%s'"%
- (self.doc.against_voucher_type, bal, self.doc.against_voucher))
\ No newline at end of file
+ if self.doc.against_voucher_type in ["Sales Invoice", "Purchase Invoice"]:
+ sql("update `tab%s` set outstanding_amount=%s where name='%s'"%
+ (self.doc.against_voucher_type, bal, self.doc.against_voucher))
\ No newline at end of file
diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js
index f187a54..10c0fc0 100644
--- a/accounts/page/accounts_home/accounts_home.js
+++ b/accounts/page/accounts_home/accounts_home.js
@@ -237,6 +237,11 @@
route: "query-report/Customer Account Head",
doctype: "Account"
},
+ {
+ "label":wn._("Item-wise Sales Register"),
+ route: "query-report/Item-wise Sales Register",
+ doctype: "Sales Invoice"
+ },
]
}
]