From 3b091418ec877341744e5c9601b497cc0bd5d1bb Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 28 May 2012 18:08:02 +0530 Subject: [PATCH] allow zero payment in POS Invoice, when cash/bank account is not specified --- .../doctype/sales_invoice/sales_invoice.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index c4ed73c65e..af9de92bcd 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -421,8 +421,8 @@ class DocType(TransactionBase): raise Exception def validate_pos(self): - if not self.doc.cash_bank_account: - msgprint("Cash/Bank Account is mandatory for POS entry") + if not self.doc.cash_bank_account and flt(self.doc.paid_amount): + msgprint("Cash/Bank Account is mandatory for POS, for making payment entry") raise Exception if (flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) - round(flt(self.doc.grand_total), 2))>0.001: msgprint("(Paid amount + Write Off Amount) can not be greater than Grand Total") @@ -676,8 +676,14 @@ class DocType(TransactionBase): if not d.warehouse: d.warehouse = cstr(w) - if flt(self.doc.paid_amount) == 0: - webnotes.conn.set(self.doc,'paid_amount',(flt(self.doc.grand_total) - flt(self.doc.write_off_amount))) + if flt(self.doc.paid_amount) == 0: + if self.doc.cash_bank_account: + webnotes.conn.set(self.doc, 'paid_amount', + (flt(self.doc.grand_total) - flt(self.doc.write_off_amount))) + else: + # show message that the amount is not paid + webnotes.conn.set(self.doc,'paid_amount',0) + webnotes.msgprint("Note: Payment Entry not created since 'Cash/Bank Account' was not specified.") else: webnotes.conn.set(self.doc,'paid_amount',0)