From 8bec67cbcfb514dda6ba66f6bf0df07841bb8026 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 2 Sep 2024 17:53:02 +0530 Subject: [PATCH] refactor: handle opening round off on purchase invoice (cherry picked from commit a5d6a25a9654ebe7f91285b9266e9b7cd9797545) --- .../doctype/purchase_invoice/purchase_invoice.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index dc4051eecf4..ebc4efc08a0 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -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}.

'{1}' account is required to post these values. Please set it in Company: {2}.

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( {