refactor: make_gle_for_change_amount

This commit is contained in:
barredterra
2024-02-17 20:46:52 +01:00
parent 2ff06af154
commit 0bbf45cd8b

View File

@@ -1492,12 +1492,16 @@ class SalesInvoice(SellingController):
) )
if not skip_change_gl_entries: if not skip_change_gl_entries:
self.make_gle_for_change_amount(gl_entries) gl_entries.extend(self.get_gle_for_change_amount())
def make_gle_for_change_amount(self, gl_entries): def get_gle_for_change_amount(self) -> list[dict]:
if self.change_amount: if not self.change_amount:
if self.account_for_change_amount: return []
gl_entries.append(
if not self.account_for_change_amount:
frappe.throw(_("Please set Account for Change Amount"), title=_("Mandatory Field"))
return [
self.get_gl_dict( self.get_gl_dict(
{ {
"account": self.debit_to, "account": self.debit_to,
@@ -1517,10 +1521,7 @@ class SalesInvoice(SellingController):
}, },
self.party_account_currency, self.party_account_currency,
item=self, item=self,
) ),
)
gl_entries.append(
self.get_gl_dict( self.get_gl_dict(
{ {
"account": self.account_for_change_amount, "account": self.account_for_change_amount,
@@ -1529,10 +1530,8 @@ class SalesInvoice(SellingController):
"cost_center": self.cost_center, "cost_center": self.cost_center,
}, },
item=self, item=self,
) ),
) ]
else:
frappe.throw(_("Select change amount account"), title=_("Mandatory Field"))
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