From 5826b7b0718a1838746eb9755bb001308ed9a642 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 21 Jun 2022 19:50:50 +0530 Subject: [PATCH] fix: identify empty values "" in against_voucher columns --- erpnext/patches/v14_0/migrate_gl_to_payment_ledger.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v14_0/migrate_gl_to_payment_ledger.py b/erpnext/patches/v14_0/migrate_gl_to_payment_ledger.py index 1e0d20d059..e15aa4a1f4 100644 --- a/erpnext/patches/v14_0/migrate_gl_to_payment_ledger.py +++ b/erpnext/patches/v14_0/migrate_gl_to_payment_ledger.py @@ -1,6 +1,6 @@ import frappe from frappe import qb -from frappe.query_builder import Case +from frappe.query_builder import Case, CustomFunction from frappe.query_builder.custom import ConstantColumn from frappe.query_builder.functions import IfNull @@ -87,6 +87,7 @@ def execute(): gl = qb.DocType("GL Entry") account = qb.DocType("Account") + ifelse = CustomFunction("IF", ["condition", "then", "else"]) gl_entries = ( qb.from_(gl) @@ -96,8 +97,12 @@ def execute(): gl.star, ConstantColumn(1).as_("docstatus"), account.account_type.as_("account_type"), - IfNull(gl.against_voucher_type, gl.voucher_type).as_("against_voucher_type"), - IfNull(gl.against_voucher, gl.voucher_no).as_("against_voucher_no"), + IfNull( + ifelse(gl.against_voucher_type == "", None, gl.against_voucher_type), gl.voucher_type + ).as_("against_voucher_type"), + IfNull(ifelse(gl.against_voucher == "", None, gl.against_voucher), gl.voucher_no).as_( + "against_voucher_no" + ), # convert debit/credit to amount Case() .when(account.account_type == "Receivable", gl.debit - gl.credit)