From 7d885b5a347d3d3f22d7259c0959939c9dcfe7cf Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Mon, 29 Jun 2026 16:46:46 +0000 Subject: [PATCH] feat(certificate): show Taxpayer Full Name (not id) in certificate picker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch the certificate Table MultiSelect dropdown to drop the leading document id from the description, leaving cert_no + taxpayer name / VÖEN. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../public/js/sales_invoice_certificates.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/jey_erp/public/js/sales_invoice_certificates.js b/jey_erp/public/js/sales_invoice_certificates.js index 5adfd07..28092a7 100644 --- a/jey_erp/public/js/sales_invoice_certificates.js +++ b/jey_erp/public/js/sales_invoice_certificates.js @@ -179,6 +179,46 @@ function open_certificate_dialog(frm, cdn) { true ); + // Show "cert_no" then the Taxpayer Full Name (from search_fields) in the + // dropdown — NOT the document id (oid). Frappe forces the doc name into the + // description for title links (build_for_autosuggest), so we strip that + // leading id token from the rendered second line. search_fields on + // "E-Taxes Presented Certificate" supplies taxpayer_full_name + voen. + patch_certificate_dropdown(fld); + d.set_value("certificates", current); d.show(); } + +function patch_certificate_dropdown(fld) { + const apply = () => { + const aw = fld && fld.awesomplete; + if (!aw || aw.__cert_name_patched) return; + const orig_item = aw.item; + aw.item = function (suggestion, input) { + const node = orig_item.call(this, suggestion, input); + try { + const oid = suggestion && suggestion.value; + const small = node && node.querySelector && node.querySelector(".small"); + if (small && oid && small.textContent.indexOf(oid) === 0) { + // drop the leading ", " — keep taxpayer name/voen verbatim + const rest = small.textContent.slice(oid.length).replace(/^\s*,\s*/, ""); + if (rest) { + small.textContent = rest; + } else { + small.remove(); + } + } + } catch (e) { + // fall back to default rendering on any error + } + return node; + }; + aw.__cert_name_patched = true; + }; + apply(); + // Awesomplete may be (re)created lazily; re-apply when the field gets focus. + if (fld && fld.$input) { + fld.$input.on("focus", apply); + } +}