Skip to content

Instantly share code, notes, and snippets.

@barredterra
Last active June 23, 2021 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barredterra/09ff36432d286328dc71cb37ea431fb0 to your computer and use it in GitHub Desktop.
Save barredterra/09ff36432d286328dc71cb37ea431fb0 to your computer and use it in GitHub Desktop.
ERPNext: automatically set Tax Category in Address DocType
// Client Script
frappe.ui.form.on("Address", {
refresh(frm) {
frm.trigger("set_tax_category");
},
country(frm) {
frm.trigger("set_tax_category");
},
links(frm) {
frm.trigger("set_tax_category");
},
set_tax_category (frm) {
if (frm.doc.tax_category || frm.doc.country !== "Germany") return;
const links = frm.doc.links.map(row => row.link_doctype);
if (links.includes("Customer")) {
frm.set_value("tax_category", "Umsatzsteuer");
} else if (links.includes("Supplier")) {
frm.set_value("tax_category", "Vorsteuer");
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment