fix: identify empty values "" in against_voucher columns
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 1e0d20d..e15aa4a 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 @@
gl = qb.DocType("GL Entry")
account = qb.DocType("Account")
+ ifelse = CustomFunction("IF", ["condition", "then", "else"])
gl_entries = (
qb.from_(gl)
@@ -96,8 +97,12 @@
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)