fix: ignore cancelled SLEs (#29303)
This commit is contained in:
parent
b0cf6195e9
commit
82ea958730
@ -292,6 +292,7 @@ def get_batches(item_code, warehouse, qty=1, throw=False, serial_no=None):
|
|||||||
join `tabStock Ledger Entry` ignore index (item_code, warehouse)
|
join `tabStock Ledger Entry` ignore index (item_code, warehouse)
|
||||||
on (`tabBatch`.batch_id = `tabStock Ledger Entry`.batch_no )
|
on (`tabBatch`.batch_id = `tabStock Ledger Entry`.batch_no )
|
||||||
where `tabStock Ledger Entry`.item_code = %s and `tabStock Ledger Entry`.warehouse = %s
|
where `tabStock Ledger Entry`.item_code = %s and `tabStock Ledger Entry`.warehouse = %s
|
||||||
|
and `tabStock Ledger Entry`.is_cancelled = 0
|
||||||
and (`tabBatch`.expiry_date >= CURDATE() or `tabBatch`.expiry_date IS NULL) {0}
|
and (`tabBatch`.expiry_date >= CURDATE() or `tabBatch`.expiry_date IS NULL) {0}
|
||||||
group by batch_id
|
group by batch_id
|
||||||
order by `tabBatch`.expiry_date ASC, `tabBatch`.creation ASC
|
order by `tabBatch`.expiry_date ASC, `tabBatch`.creation ASC
|
||||||
|
@ -55,7 +55,8 @@ def get_stock_ledger_entries(filters):
|
|||||||
return frappe.db.sql("""select item_code, batch_no, warehouse,
|
return frappe.db.sql("""select item_code, batch_no, warehouse,
|
||||||
posting_date, actual_qty
|
posting_date, actual_qty
|
||||||
from `tabStock Ledger Entry`
|
from `tabStock Ledger Entry`
|
||||||
where docstatus < 2 and ifnull(batch_no, '') != '' %s order by item_code, warehouse""" %
|
where is_cancelled = 0
|
||||||
|
and docstatus < 2 and ifnull(batch_no, '') != '' %s order by item_code, warehouse""" %
|
||||||
conditions, as_dict=1)
|
conditions, as_dict=1)
|
||||||
|
|
||||||
def get_item_warehouse_batch_map(filters, float_precision):
|
def get_item_warehouse_batch_map(filters, float_precision):
|
||||||
|
@ -91,7 +91,7 @@ def get_stock_value_difference_list(filtered_entries: FilteredEntries) -> SVDLis
|
|||||||
voucher_nos = [fe.get('voucher_no') for fe in filtered_entries]
|
voucher_nos = [fe.get('voucher_no') for fe in filtered_entries]
|
||||||
svd_list = frappe.get_list(
|
svd_list = frappe.get_list(
|
||||||
'Stock Ledger Entry', fields=['item_code','stock_value_difference'],
|
'Stock Ledger Entry', fields=['item_code','stock_value_difference'],
|
||||||
filters=[('voucher_no', 'in', voucher_nos)]
|
filters=[('voucher_no', 'in', voucher_nos), ("is_cancelled", "=", 0)]
|
||||||
)
|
)
|
||||||
assign_item_groups_to_svd_list(svd_list)
|
assign_item_groups_to_svd_list(svd_list)
|
||||||
return svd_list
|
return svd_list
|
||||||
|
@ -76,6 +76,7 @@ def get_consumed_items(condition):
|
|||||||
on sle.voucher_no = se.name
|
on sle.voucher_no = se.name
|
||||||
where
|
where
|
||||||
actual_qty < 0
|
actual_qty < 0
|
||||||
|
and is_cancelled = 0
|
||||||
and voucher_type not in ('Delivery Note', 'Sales Invoice')
|
and voucher_type not in ('Delivery Note', 'Sales Invoice')
|
||||||
%s
|
%s
|
||||||
group by item_code""" % condition, as_dict=1)
|
group by item_code""" % condition, as_dict=1)
|
||||||
|
@ -647,6 +647,7 @@ class update_entries_after(object):
|
|||||||
where
|
where
|
||||||
company = %s
|
company = %s
|
||||||
and actual_qty > 0
|
and actual_qty > 0
|
||||||
|
and is_cancelled = 0
|
||||||
and (serial_no = %s
|
and (serial_no = %s
|
||||||
or serial_no like %s
|
or serial_no like %s
|
||||||
or serial_no like %s
|
or serial_no like %s
|
||||||
@ -902,6 +903,7 @@ def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
|
|||||||
item_code = %s
|
item_code = %s
|
||||||
AND warehouse = %s
|
AND warehouse = %s
|
||||||
AND valuation_rate >= 0
|
AND valuation_rate >= 0
|
||||||
|
AND is_cancelled = 0
|
||||||
AND NOT (voucher_no = %s AND voucher_type = %s)
|
AND NOT (voucher_no = %s AND voucher_type = %s)
|
||||||
order by posting_date desc, posting_time desc, name desc limit 1""", (item_code, warehouse, voucher_no, voucher_type))
|
order by posting_date desc, posting_time desc, name desc limit 1""", (item_code, warehouse, voucher_no, voucher_type))
|
||||||
|
|
||||||
@ -912,6 +914,7 @@ def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
|
|||||||
where
|
where
|
||||||
item_code = %s
|
item_code = %s
|
||||||
AND valuation_rate > 0
|
AND valuation_rate > 0
|
||||||
|
AND is_cancelled = 0
|
||||||
AND NOT(voucher_no = %s AND voucher_type = %s)
|
AND NOT(voucher_no = %s AND voucher_type = %s)
|
||||||
order by posting_date desc, posting_time desc, name desc limit 1""", (item_code, voucher_no, voucher_type))
|
order by posting_date desc, posting_time desc, name desc limit 1""", (item_code, voucher_no, voucher_type))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user