From 83928bbf78f500728c934e3e764ad069a8d55448 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:24:37 +0530 Subject: [PATCH] feat: expiry date column in Available Batch Report (backport #42628) (#42641) * feat: expiry date column in Available Batch Report (#42628) (cherry picked from commit faff84c6e5d65472bc55c8f0f426eb64db58936f) # Conflicts: # erpnext/stock/report/available_batch_report/available_batch_report.py * chore: fix conflicts --------- Co-authored-by: rohitwaghchaure --- .../available_batch_report.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/report/available_batch_report/available_batch_report.py b/erpnext/stock/report/available_batch_report/available_batch_report.py index cb651dd79729..99af98c23bbc 100644 --- a/erpnext/stock/report/available_batch_report/available_batch_report.py +++ b/erpnext/stock/report/available_batch_report/available_batch_report.py @@ -54,6 +54,12 @@ def get_columns(filters): "width": 150, "options": "Batch", }, + { + "label": _("Expiry Date"), + "fieldname": "expiry_date", + "fieldtype": "Date", + "width": 120, + }, {"label": _("Balance Qty"), "fieldname": "balance_qty", "fieldtype": "Float", "width": 150}, ] ) @@ -96,6 +102,7 @@ def get_batchwise_data_from_stock_ledger(filters): table.item_code, table.batch_no, table.warehouse, + batch.expiry_date, Sum(table.actual_qty).as_("balance_qty"), ) .where(table.is_cancelled == 0) @@ -118,10 +125,14 @@ def get_query_based_on_filters(query, batch, table, filters): if filters.batch_no: query = query.where(batch.name == filters.batch_no) - if not filters.include_expired_batches: - query = query.where((batch.expiry_date >= today()) | (batch.expiry_date.isnull())) - if filters.to_date == today(): - query = query.where(batch.batch_qty > 0) + if filters.to_date == today(): + if not filters.include_expired_batches: + query = query.where((batch.expiry_date >= today()) | (batch.expiry_date.isnull())) + + query = query.where(batch.batch_qty > 0) + + else: + query = query.where(table.posting_date <= filters.to_date) if filters.warehouse: lft, rgt = frappe.db.get_value("Warehouse", filters.warehouse, ["lft", "rgt"])