allow zero payment in POS Invoice, when cash/bank account is not specified

This commit is contained in:
Anand Doshi 2012-05-28 18:08:02 +05:30
parent 2ad2426610
commit 3b091418ec

View File

@ -421,8 +421,8 @@ class DocType(TransactionBase):
raise Exception raise Exception
def validate_pos(self): def validate_pos(self):
if not self.doc.cash_bank_account: if not self.doc.cash_bank_account and flt(self.doc.paid_amount):
msgprint("Cash/Bank Account is mandatory for POS entry") msgprint("Cash/Bank Account is mandatory for POS, for making payment entry")
raise Exception raise Exception
if (flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) - round(flt(self.doc.grand_total), 2))>0.001: 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") msgprint("(Paid amount + Write Off Amount) can not be greater than Grand Total")
@ -677,7 +677,13 @@ class DocType(TransactionBase):
d.warehouse = cstr(w) d.warehouse = cstr(w)
if flt(self.doc.paid_amount) == 0: 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 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: else:
webnotes.conn.set(self.doc,'paid_amount',0) webnotes.conn.set(self.doc,'paid_amount',0)