refactor: handle opening round off on purchase invoice

(cherry picked from commit a5d6a25a96)
This commit is contained in:
ruthra kumar
2024-09-02 17:53:02 +05:30
committed by Mergify
parent 7eb4b42280
commit 8bec67cbcf

View File

@@ -1545,6 +1545,21 @@ class PurchaseInvoice(BuyingController):
self.company, "Purchase Invoice", self.name, self.use_company_roundoff_cost_center
)
if self.is_opening == "Yes" and self.rounding_adjustment:
if not round_off_for_opening:
frappe.throw(
_(
"Opening Invoice has rounding adjustment of {0}.<br><br> '{1}' account is required to post these values. Please set it in Company: {2}.<br><br> Or, '{3}' can be enabled to not post any rounding adjustment."
).format(
frappe.bold(self.rounding_adjustment),
frappe.bold("Round Off for Opening"),
get_link_to_form("Company", self.company),
frappe.bold("Disable Rounded Total"),
)
)
else:
round_off_account = round_off_for_opening
gl_entries.append(
self.get_gl_dict(
{