Reposting fixes pre release (#24203)
* fix: finished item validation and rate
* fix: Check if stock and account balance in sync after reposting
* fix: validate stock accounts in journal entry
* fix: validate expense against budget
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index dc61870..6edc020 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -241,7 +241,7 @@
if rate > 0:
d.rate = rate
- d.amount = flt(d.consumed_qty) * flt(d.rate)
+ d.amount = flt(flt(d.consumed_qty) * flt(d.rate), d.precision("amount"))
supplied_items_cost += flt(d.amount)
return supplied_items_cost
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 51c063c..4399976 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -6,7 +6,7 @@
from frappe.utils import cint, flt, cstr, get_link_to_form, today, getdate
from frappe import _
import frappe.defaults
-from erpnext.accounts.utils import get_fiscal_year
+from erpnext.accounts.utils import get_fiscal_year, check_if_stock_and_account_balance_synced
from erpnext.accounts.general_ledger import make_gl_entries, make_reverse_gl_entries, process_gl_map
from erpnext.controllers.accounts_controller import AccountsController
from erpnext.stock.stock_ledger import get_valuation_rate
@@ -402,6 +402,14 @@
if check_if_future_sle_exists(args):
create_repost_item_valuation_entry(args)
+ elif not is_reposting_pending():
+ check_if_stock_and_account_balance_synced(self.posting_date,
+ self.company, self.doctype, self.name)
+
+def is_reposting_pending():
+ return frappe.db.exists("Repost Item Valuation",
+ {'docstatus': 1, 'status': ['in', ['Queued','In Progress']]})
+
def check_if_future_sle_exists(args):
sl_entries = frappe.db.get_all("Stock Ledger Entry",