mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-22 11:44:11 +00:00
feat: expiry date column in Available Batch Report (#42628)
(cherry picked from commit faff84c6e5)
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -54,6 +54,12 @@ def get_columns(filters):
|
|||||||
"width": 150,
|
"width": 150,
|
||||||
"options": "Batch",
|
"options": "Batch",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": _("Expiry Date"),
|
||||||
|
"fieldname": "expiry_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"width": 120,
|
||||||
|
},
|
||||||
{"label": _("Balance Qty"), "fieldname": "balance_qty", "fieldtype": "Float", "width": 150},
|
{"label": _("Balance Qty"), "fieldname": "balance_qty", "fieldtype": "Float", "width": 150},
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -97,6 +103,7 @@ def get_batchwise_data_from_stock_ledger(filters):
|
|||||||
table.item_code,
|
table.item_code,
|
||||||
table.batch_no,
|
table.batch_no,
|
||||||
table.warehouse,
|
table.warehouse,
|
||||||
|
batch.expiry_date,
|
||||||
Sum(table.actual_qty).as_("balance_qty"),
|
Sum(table.actual_qty).as_("balance_qty"),
|
||||||
)
|
)
|
||||||
.where(table.is_cancelled == 0)
|
.where(table.is_cancelled == 0)
|
||||||
@@ -127,6 +134,7 @@ def get_batchwise_data_from_serial_batch_bundle(batchwise_data, filters):
|
|||||||
table.item_code,
|
table.item_code,
|
||||||
ch_table.batch_no,
|
ch_table.batch_no,
|
||||||
table.warehouse,
|
table.warehouse,
|
||||||
|
batch.expiry_date,
|
||||||
Sum(ch_table.qty).as_("balance_qty"),
|
Sum(ch_table.qty).as_("balance_qty"),
|
||||||
)
|
)
|
||||||
.where((table.is_cancelled == 0) & (table.docstatus == 1))
|
.where((table.is_cancelled == 0) & (table.docstatus == 1))
|
||||||
@@ -152,10 +160,14 @@ def get_query_based_on_filters(query, batch, table, filters):
|
|||||||
if filters.batch_no:
|
if filters.batch_no:
|
||||||
query = query.where(batch.name == filters.batch_no)
|
query = query.where(batch.name == filters.batch_no)
|
||||||
|
|
||||||
if not filters.include_expired_batches:
|
if filters.to_date == today():
|
||||||
query = query.where((batch.expiry_date >= today()) | (batch.expiry_date.isnull()))
|
if not filters.include_expired_batches:
|
||||||
if filters.to_date == today():
|
query = query.where((batch.expiry_date >= today()) | (batch.expiry_date.isnull()))
|
||||||
query = query.where(batch.batch_qty > 0)
|
|
||||||
|
query = query.where(batch.batch_qty > 0)
|
||||||
|
|
||||||
|
else:
|
||||||
|
query = query.where(table.posting_date <= filters.to_date)
|
||||||
|
|
||||||
if filters.warehouse:
|
if filters.warehouse:
|
||||||
lft, rgt = frappe.db.get_value("Warehouse", filters.warehouse, ["lft", "rgt"])
|
lft, rgt = frappe.db.get_value("Warehouse", filters.warehouse, ["lft", "rgt"])
|
||||||
|
|||||||
Reference in New Issue
Block a user