Added change amount account

This commit is contained in:
Rohit Waghchaure 2016-08-04 15:06:28 +05:30
parent 7127a8f522
commit c41ab8d15b

View File

@ -268,6 +268,7 @@ class SalesInvoice(SellingController):
# fetch charges # fetch charges
if self.taxes_and_charges and not len(self.get("taxes")): if self.taxes_and_charges and not len(self.get("taxes")):
self.set_taxes() self.set_taxes()
self.change_amount_account = pos.change_amount_account
return pos return pos
@ -608,14 +609,13 @@ class SalesInvoice(SellingController):
def make_gle_for_change(self, gl_entries): def make_gle_for_change(self, gl_entries):
if cint(self.is_pos) and self.change_amount: if cint(self.is_pos) and self.change_amount:
cash_account = self.get_cash_account() if self.change_amount_account:
if cash_account:
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({
"account": self.debit_to, "account": self.debit_to,
"party_type": "Customer", "party_type": "Customer",
"party": self.customer, "party": self.customer,
"against": cash_account, "against": self.change_amount_account,
"debit": flt(self.base_change_amount), "debit": flt(self.base_change_amount),
"debit_in_account_currency": flt(self.base_change_amount) \ "debit_in_account_currency": flt(self.base_change_amount) \
if self.party_account_currency==self.company_currency else flt(self.change_amount), if self.party_account_currency==self.company_currency else flt(self.change_amount),
@ -626,22 +626,13 @@ class SalesInvoice(SellingController):
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({
"account": cash_account, "account": self.change_amount_account,
"against": self.customer, "against": self.customer,
"credit": self.base_change_amount "credit": self.base_change_amount
}) })
) )
else:
frappe.throw(_("Select change amount account"), title="Mandatory Field")
def get_cash_account(self):
cash_account = [d.account for d in self.payments if d.type=="Cash"]
if cash_account:
cash_account = cash_account[0]
else:
cash_account = frappe.db.get_value("Account",
filters={"company": self.company, "account_type": "Cash", "is_group": 0})
return cash_account
def make_write_off_gl_entry(self, gl_entries): def make_write_off_gl_entry(self, gl_entries):
# write off entries, applicable if only pos # write off entries, applicable if only pos