Merge pull request #35091 from ruthra-kumar/cost_center_allocation_splits_roundoff

refactor: button to toggle parent doc cost center preference for rounding adjustment amount
This commit is contained in:
ruthra kumar 2023-05-02 14:07:22 +05:30 committed by GitHub
commit 1d70183d8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 10 deletions

View File

@ -89,6 +89,7 @@
"column_break8", "column_break8",
"grand_total", "grand_total",
"rounding_adjustment", "rounding_adjustment",
"use_company_roundoff_cost_center",
"rounded_total", "rounded_total",
"in_words", "in_words",
"total_advance", "total_advance",
@ -1559,13 +1560,19 @@
"fieldname": "only_include_allocated_payments", "fieldname": "only_include_allocated_payments",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Only Include Allocated Payments" "label": "Only Include Allocated Payments"
},
{
"default": "0",
"fieldname": "use_company_roundoff_cost_center",
"fieldtype": "Check",
"label": "Use Company Default Round Off Cost Center"
} }
], ],
"icon": "fa fa-file-text", "icon": "fa fa-file-text",
"idx": 204, "idx": 204,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2023-04-03 22:57:14.074982", "modified": "2023-04-28 12:57:50.832598",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Purchase Invoice", "name": "Purchase Invoice",

View File

@ -978,7 +978,7 @@ class PurchaseInvoice(BuyingController):
def make_precision_loss_gl_entry(self, gl_entries): def make_precision_loss_gl_entry(self, gl_entries):
round_off_account, round_off_cost_center = get_round_off_account_and_cost_center( round_off_account, round_off_cost_center = get_round_off_account_and_cost_center(
self.company, "Purchase Invoice", self.name self.company, "Purchase Invoice", self.name, self.use_company_roundoff_cost_center
) )
precision_loss = self.get("base_net_total") - flt( precision_loss = self.get("base_net_total") - flt(
@ -992,7 +992,9 @@ class PurchaseInvoice(BuyingController):
"account": round_off_account, "account": round_off_account,
"against": self.supplier, "against": self.supplier,
"credit": precision_loss, "credit": precision_loss,
"cost_center": self.cost_center or round_off_cost_center, "cost_center": round_off_cost_center
if self.use_company_roundoff_cost_center
else self.cost_center or round_off_cost_center,
"remarks": _("Net total calculation precision loss"), "remarks": _("Net total calculation precision loss"),
} }
) )
@ -1386,7 +1388,7 @@ class PurchaseInvoice(BuyingController):
not self.is_internal_transfer() and self.rounding_adjustment and self.base_rounding_adjustment not self.is_internal_transfer() and self.rounding_adjustment and self.base_rounding_adjustment
): ):
round_off_account, round_off_cost_center = get_round_off_account_and_cost_center( round_off_account, round_off_cost_center = get_round_off_account_and_cost_center(
self.company, "Purchase Invoice", self.name self.company, "Purchase Invoice", self.name, self.use_company_roundoff_cost_center
) )
gl_entries.append( gl_entries.append(
@ -1396,7 +1398,9 @@ class PurchaseInvoice(BuyingController):
"against": self.supplier, "against": self.supplier,
"debit_in_account_currency": self.rounding_adjustment, "debit_in_account_currency": self.rounding_adjustment,
"debit": self.base_rounding_adjustment, "debit": self.base_rounding_adjustment,
"cost_center": self.cost_center or round_off_cost_center, "cost_center": round_off_cost_center
if self.use_company_roundoff_cost_center
else (self.cost_center or round_off_cost_center),
}, },
item=self, item=self,
) )

View File

@ -79,6 +79,7 @@
"column_break5", "column_break5",
"grand_total", "grand_total",
"rounding_adjustment", "rounding_adjustment",
"use_company_roundoff_cost_center",
"rounded_total", "rounded_total",
"in_words", "in_words",
"total_advance", "total_advance",
@ -2135,6 +2136,12 @@
"fieldname": "only_include_allocated_payments", "fieldname": "only_include_allocated_payments",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Only Include Allocated Payments" "label": "Only Include Allocated Payments"
},
{
"default": "0",
"fieldname": "use_company_roundoff_cost_center",
"fieldtype": "Check",
"label": "Use Company default Cost Center for Round off"
} }
], ],
"icon": "fa fa-file-text", "icon": "fa fa-file-text",
@ -2147,7 +2154,7 @@
"link_fieldname": "consolidated_invoice" "link_fieldname": "consolidated_invoice"
} }
], ],
"modified": "2023-04-03 22:55:14.206473", "modified": "2023-04-28 14:15:59.901154",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice", "name": "Sales Invoice",

View File

@ -1464,7 +1464,7 @@ class SalesInvoice(SellingController):
and not self.is_internal_transfer() and not self.is_internal_transfer()
): ):
round_off_account, round_off_cost_center = get_round_off_account_and_cost_center( round_off_account, round_off_cost_center = get_round_off_account_and_cost_center(
self.company, "Sales Invoice", self.name self.company, "Sales Invoice", self.name, self.use_company_roundoff_cost_center
) )
gl_entries.append( gl_entries.append(
@ -1476,7 +1476,9 @@ class SalesInvoice(SellingController):
self.rounding_adjustment, self.precision("rounding_adjustment") self.rounding_adjustment, self.precision("rounding_adjustment")
), ),
"credit": flt(self.base_rounding_adjustment, self.precision("base_rounding_adjustment")), "credit": flt(self.base_rounding_adjustment, self.precision("base_rounding_adjustment")),
"cost_center": self.cost_center or round_off_cost_center, "cost_center": round_off_cost_center
if self.use_company_roundoff_cost_center
else (self.cost_center or round_off_cost_center),
}, },
item=self, item=self,
) )

View File

@ -475,7 +475,9 @@ def update_accounting_dimensions(round_off_gle):
round_off_gle[dimension] = dimension_values.get(dimension) round_off_gle[dimension] = dimension_values.get(dimension)
def get_round_off_account_and_cost_center(company, voucher_type, voucher_no): def get_round_off_account_and_cost_center(
company, voucher_type, voucher_no, use_company_default=False
):
round_off_account, round_off_cost_center = frappe.get_cached_value( round_off_account, round_off_cost_center = frappe.get_cached_value(
"Company", company, ["round_off_account", "round_off_cost_center"] "Company", company, ["round_off_account", "round_off_cost_center"]
) or [None, None] ) or [None, None]
@ -483,7 +485,7 @@ def get_round_off_account_and_cost_center(company, voucher_type, voucher_no):
meta = frappe.get_meta(voucher_type) meta = frappe.get_meta(voucher_type)
# Give first preference to parent cost center for round off GLE # Give first preference to parent cost center for round off GLE
if meta.has_field("cost_center"): if not use_company_default and meta.has_field("cost_center"):
parent_cost_center = frappe.db.get_value(voucher_type, voucher_no, "cost_center") parent_cost_center = frappe.db.get_value(voucher_type, voucher_no, "cost_center")
if parent_cost_center: if parent_cost_center:
round_off_cost_center = parent_cost_center round_off_cost_center = parent_cost_center