feat(certificate): show Taxpayer Full Name (not id) in certificate picker
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) <noreply@anthropic.com>
This commit is contained in:
parent
d1353767bf
commit
7d885b5a34
|
|
@ -179,6 +179,46 @@ function open_certificate_dialog(frm, cdn) {
|
||||||
true
|
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.set_value("certificates", current);
|
||||||
d.show();
|
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 "<oid>, " — 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue