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