feat: Repost item costing (#24183)

* Repost item valuation (#24031)

* feat: Reposting logic for future finished/transferred item

* feat: added fields to identify needs to recalculate rate while reposting

* refactor: Set rate for outgoing and finished items

* refactor: Arranged fields in Stock Entry item table and added fields to identify finished and scrap item

* refactor: Arranged fields in Stock Entry item table and added fields to identify finished and scrap item

* refactor: Get outgoing rate for purchase return

* refactor: Get incoming rate for sales return

* test: Added tests for reposting valuation of transferred/finished/returned items

* feat: added incoming rate field in DN, SI and Packed Item table

* feat: get incoming rate for returned item

* fix: no error while getting valuation rate in stock entry

* fix: update stock ledger for DN and SI

* feat: update item valuation rate in PR and PI based on supplied items cost

* feat: SLE reposting logic for sales return and subcontracted item with test cases

* feat: update qty in future sle

* feat: repost future sle and gle via Repost Item Valuation

* fix: Skip unwanted function calling while reposting

* fix: repost sle for specific item and warehouse

* test: Modified tests for backdated stock reco

* fix: ignore cancelled sle in few methods

* feat: role allowed to do backdated entry

* feat: Show reposting status on stock valuation related reports

* fix: minor fixes

* fix: fixed sider issues

* fix: serial no fix related to immutable ledger

* fix: Test cases fixes related to perpetual inventory

* fix: Test cases fixed

* fix: Fixed reposting on cancel and test cases

* feat: Restart reposting item valuation

* refactor: Code cleanup using small functions and test case fixes

* fix: minor fixes

* fix: Raise on error while reposting item valuation

* fix: minor fix

* fix: Tests fixed

* fix: skip some validation ig gle made from reposting

* fix: test fixes

* fix: debugging stock and account validation

* fix: debugging stock and account validation

* fix: debugging travis for stock and account sync validation

* fix: debugging travis

* fix: debugging travis

* fix: debugging travis

* fix: removed duplicate field from pos profile
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index f9ac254..4ea7e4f 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -63,6 +63,7 @@
 		SELECT item_code, stock_value, name, warehouse
 		FROM `tabStock Ledger Entry` sle
 		WHERE posting_date <= %s {0}
+			and is_cancelled = 0
 		ORDER BY timestamp(posting_date, posting_time) DESC, creation DESC
 	""".format(condition), values, as_dict=1)
 
@@ -211,7 +212,7 @@
 			currency=erpnext.get_company_currency(args.get('company')), company=args.get('company'),
 			raise_error_if_no_rate=raise_error_if_no_rate)
 
-	return in_rate
+	return flt(in_rate)
 
 def get_avg_purchase_rate(serial_nos):
 	"""get average value of serial numbers"""
@@ -375,4 +376,10 @@
 
 	outgoing_rate = outgoing_rate[0][0] if outgoing_rate else 0.0
 
-	return outgoing_rate
\ No newline at end of file
+	return outgoing_rate
+
+def is_reposting_item_valuation_in_progress():
+	reposting_in_progress = frappe.db.exists("Repost Item Valuation",
+		{'docstatus': 1, 'status': ['in', ['Queued','In Progress']]})
+	if reposting_in_progress:
+		frappe.msgprint(_("Item valuation reposting in progress. Report might show incorrect item valuation."), alert=1)
\ No newline at end of file