fix(dunning): include accounting dimension upon gl creation

This commit is contained in:
ravibharathi656
2025-08-22 12:34:39 +05:30
parent 43a723546d
commit 4fccef0636

View File

@@ -55,17 +55,16 @@ class Dunning(AccountsController):
"conversion_rate", "conversion_rate",
"cost_center", "cost_center",
] ]
inv = frappe.db.get_value("Sales Invoice", self.sales_invoice, invoice_fields, as_dict=1)
accounting_dimensions = get_accounting_dimensions() accounting_dimensions = get_accounting_dimensions()
invoice_fields.extend(accounting_dimensions) invoice_fields.extend(accounting_dimensions)
inv = frappe.db.get_value("Sales Invoice", self.sales_invoice, invoice_fields, as_dict=1)
dunning_in_company_currency = flt(self.dunning_amount * inv.conversion_rate) dunning_in_company_currency = flt(self.dunning_amount * inv.conversion_rate)
default_cost_center = frappe.get_cached_value("Company", self.company, "cost_center") default_cost_center = frappe.get_cached_value("Company", self.company, "cost_center")
gl_entries.append( debit = {
self.get_gl_dict(
{
"account": inv.debit_to, "account": inv.debit_to,
"party_type": "Customer", "party_type": "Customer",
"party": self.customer, "party": self.customer,
@@ -77,24 +76,25 @@ class Dunning(AccountsController):
"against_voucher_type": "Dunning", "against_voucher_type": "Dunning",
"cost_center": inv.cost_center or default_cost_center, "cost_center": inv.cost_center or default_cost_center,
"project": inv.project, "project": inv.project,
}, }
inv.party_account_currency,
item=inv, credit = {
)
)
gl_entries.append(
self.get_gl_dict(
{
"account": self.income_account, "account": self.income_account,
"against": self.customer, "against": self.customer,
"credit": dunning_in_company_currency, "credit": dunning_in_company_currency,
"cost_center": inv.cost_center or default_cost_center,
"credit_in_account_currency": self.dunning_amount, "credit_in_account_currency": self.dunning_amount,
"cost_center": inv.cost_center or default_cost_center,
"project": inv.project, "project": inv.project,
}, }
item=inv,
) for dimension in accounting_dimensions:
) if val := inv.get(dimension):
debit[dimension] = credit[dimension] = val
gl_entries = [
self.get_gl_dict(debit, inv.party_account_currency, item=inv),
self.get_gl_dict(credit, item=inv),
]
make_gl_entries( make_gl_entries(
gl_entries, cancel=(self.docstatus == 2), update_outstanding="No", merge_entries=False gl_entries, cancel=(self.docstatus == 2), update_outstanding="No", merge_entries=False
) )