From 6e03d4503474c85d46e231bc99117014092b688e Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 15 Jan 2026 17:04:49 +0530 Subject: [PATCH] fix: Show non-SLE vouchers with GL entries in Stock vs Account Value Comparison report (cherry picked from commit 1db9ce205f8337c7008d1708bbda8afae641c820) # Conflicts: # erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py --- .../stock_and_account_value_comparison.py | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py b/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py index 67e340d0f70..641275a57c5 100644 --- a/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py +++ b/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py @@ -41,9 +41,37 @@ def get_data(report_filters): gl_data = voucher_wise_gl_data.get(key) or {} d.account_value = gl_data.get("account_value", 0) d.difference_value = d.stock_value - d.account_value + d.ledger_type = "Stock Ledger Entry" if abs(d.difference_value) > 0.1: data.append(d) + if key in voucher_wise_gl_data: + del voucher_wise_gl_data[key] + + if voucher_wise_gl_data: + data += get_gl_ledgers_with_no_stock_ledger_entries(voucher_wise_gl_data) + + return data + + +def get_gl_ledgers_with_no_stock_ledger_entries(voucher_wise_gl_data): + data = [] + + for key in voucher_wise_gl_data: + gl_data = voucher_wise_gl_data.get(key) or {} + data.append( + { + "name": gl_data.get("name"), + "ledger_type": "GL Entry", + "voucher_type": gl_data.get("voucher_type"), + "voucher_no": gl_data.get("voucher_no"), + "posting_date": gl_data.get("posting_date"), + "stock_value": 0, + "account_value": gl_data.get("account_value", 0), + "difference_value": gl_data.get("account_value", 0) * -1, + } + ) + return data @@ -87,7 +115,15 @@ def get_gl_data(report_filters, filters): "name", "voucher_type", "voucher_no", +<<<<<<< HEAD "sum(debit_in_account_currency) - sum(credit_in_account_currency) as account_value", +======= + "posting_date", + { + "SUB": [{"SUM": "debit_in_account_currency"}, {"SUM": "credit_in_account_currency"}], + "as": "account_value", + }, +>>>>>>> 1db9ce205f (fix: Show non-SLE vouchers with GL entries in Stock vs Account Value Comparison report) ], group_by="voucher_type, voucher_no", ) @@ -105,10 +141,15 @@ def get_columns(filters): { "label": _("Stock Ledger ID"), "fieldname": "name", - "fieldtype": "Link", - "options": "Stock Ledger Entry", + "fieldtype": "Dynamic Link", + "options": "ledger_type", "width": "80", }, + { + "label": _("Ledger Type"), + "fieldname": "ledger_type", + "fieldtype": "Data", + }, {"label": _("Posting Date"), "fieldname": "posting_date", "fieldtype": "Date"}, {"label": _("Posting Time"), "fieldname": "posting_time", "fieldtype": "Time"}, {"label": _("Voucher Type"), "fieldname": "voucher_type", "width": "110"},