fix: incorrect SLE for Moving Average
valuation method
This commit is contained in:
parent
5da3e532c9
commit
8beec58670
@ -194,6 +194,7 @@ def get_columns():
|
|||||||
def get_data(filters=None):
|
def get_data(filters=None):
|
||||||
filters = frappe._dict(filters or {})
|
filters = frappe._dict(filters or {})
|
||||||
item_warehouse_map = get_item_warehouse_combinations(filters)
|
item_warehouse_map = get_item_warehouse_combinations(filters)
|
||||||
|
valuation_method = frappe.db.get_single_value("Stock Settings", "valuation_method")
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
if item_warehouse_map:
|
if item_warehouse_map:
|
||||||
@ -206,7 +207,9 @@ def get_data(filters=None):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
for row in report_data:
|
for row in report_data:
|
||||||
if has_difference(row, precision, filters.difference_in):
|
if has_difference(
|
||||||
|
row, precision, filters.difference_in, item_warehouse.valuation_method or valuation_method
|
||||||
|
):
|
||||||
data.append(add_item_warehouse_details(row, item_warehouse))
|
data.append(add_item_warehouse_details(row, item_warehouse))
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -229,6 +232,7 @@ def get_item_warehouse_combinations(filters: dict = None) -> dict:
|
|||||||
.select(
|
.select(
|
||||||
bin.item_code,
|
bin.item_code,
|
||||||
bin.warehouse,
|
bin.warehouse,
|
||||||
|
item.valuation_method,
|
||||||
)
|
)
|
||||||
.where(
|
.where(
|
||||||
(item.is_stock_item == 1)
|
(item.is_stock_item == 1)
|
||||||
@ -248,36 +252,38 @@ def get_item_warehouse_combinations(filters: dict = None) -> dict:
|
|||||||
return query.run(as_dict=1)
|
return query.run(as_dict=1)
|
||||||
|
|
||||||
|
|
||||||
def has_difference(row, precision, difference_in):
|
def has_difference(row, precision, difference_in, valuation_method):
|
||||||
has_qty_difference = flt(row.difference_in_qty, precision) or flt(row.fifo_qty_diff, precision)
|
if valuation_method == "Moving Average":
|
||||||
has_value_difference = (
|
qty_diff = flt(row.difference_in_qty, precision)
|
||||||
|
value_diff = flt(row.diff_value_diff, precision)
|
||||||
|
valuation_diff = flt(row.valuation_diff, precision)
|
||||||
|
else:
|
||||||
|
qty_diff = flt(row.difference_in_qty, precision) or flt(row.fifo_qty_diff, precision)
|
||||||
|
value_diff = (
|
||||||
flt(row.diff_value_diff, precision)
|
flt(row.diff_value_diff, precision)
|
||||||
or flt(row.fifo_value_diff, precision)
|
or flt(row.fifo_value_diff, precision)
|
||||||
or flt(row.fifo_difference_diff, precision)
|
or flt(row.fifo_difference_diff, precision)
|
||||||
)
|
)
|
||||||
has_valuation_difference = flt(row.valuation_diff, precision) or flt(
|
valuation_diff = flt(row.valuation_diff, precision) or flt(row.fifo_valuation_diff, precision)
|
||||||
row.fifo_valuation_diff, precision
|
|
||||||
)
|
|
||||||
|
|
||||||
if difference_in == "Qty" and has_qty_difference:
|
if difference_in == "Qty" and qty_diff:
|
||||||
return True
|
return True
|
||||||
elif difference_in == "Value" and has_value_difference:
|
elif difference_in == "Value" and value_diff:
|
||||||
return True
|
return True
|
||||||
elif difference_in == "Valuation" and has_valuation_difference:
|
elif difference_in == "Valuation" and valuation_diff:
|
||||||
return True
|
return True
|
||||||
elif difference_in not in ["Qty", "Value", "Valuation"] and (
|
elif difference_in not in ["Qty", "Value", "Valuation"] and (
|
||||||
has_qty_difference or has_value_difference or has_valuation_difference
|
qty_diff or value_diff or valuation_diff
|
||||||
):
|
):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def add_item_warehouse_details(row, item_warehouse):
|
def add_item_warehouse_details(row, item_warehouse):
|
||||||
row.update(
|
row.update(
|
||||||
{
|
{
|
||||||
"item_code": item_warehouse.item_code,
|
"item_code": item_warehouse.item_code,
|
||||||
"warehouse": item_warehouse.warehouse,
|
"warehouse": item_warehouse.warehouse,
|
||||||
|
"valuation_method": item_warehouse.valuation_method,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user