feat: company wise valuation method

This commit is contained in:
Mihir Kandoi
2025-11-13 11:59:58 +05:30
parent 5dcb766b9f
commit 316b6d6867
12 changed files with 74 additions and 22 deletions

View File

@@ -12,7 +12,6 @@ from frappe.utils import cint, flt, format_datetime, get_datetime
import erpnext
from erpnext.stock.serial_batch_bundle import get_batches_from_bundle
from erpnext.stock.serial_batch_bundle import get_serial_nos as get_serial_nos_from_bundle
from erpnext.stock.utils import get_combine_datetime, get_incoming_rate, get_valuation_method
@@ -145,7 +144,7 @@ def validate_returned_items(doc):
ref.rate
and flt(d.rate) > ref.rate
and doc.doctype in ("Delivery Note", "Sales Invoice")
and get_valuation_method(ref.item_code) != "Moving Average"
and get_valuation_method(ref.item_code, doc.company) != "Moving Average"
):
frappe.throw(
_("Row # {0}: Rate cannot be greater than the rate used in {1} {2}").format(

View File

@@ -524,7 +524,7 @@ class SellingController(StockController):
)
if not self.get("return_against") or (
get_valuation_method(d.item_code) == "Moving Average"
get_valuation_method(d.item_code, self.company) == "Moving Average"
and self.get("is_return")
and not item_details.has_serial_no
and not item_details.has_batch_no
@@ -535,7 +535,10 @@ class SellingController(StockController):
if (
not d.incoming_rate
or self.is_internal_transfer()
or (get_valuation_method(d.item_code) == "Moving Average" and self.get("is_return"))
or (
get_valuation_method(d.item_code, self.company) == "Moving Average"
and self.get("is_return")
)
):
d.incoming_rate = get_incoming_rate(
{
@@ -560,7 +563,7 @@ class SellingController(StockController):
not d.incoming_rate
and self.get("return_against")
and self.get("is_return")
and get_valuation_method(d.item_code) == "Moving Average"
and get_valuation_method(d.item_code, self.company) == "Moving Average"
):
d.incoming_rate = get_rate_for_return(
self.doctype, self.name, d.item_code, self.return_against, item_row=d