Last active
June 23, 2021 12:11
-
-
Save barredterra/09ff36432d286328dc71cb37ea431fb0 to your computer and use it in GitHub Desktop.
ERPNext: automatically set Tax Category in Address DocType
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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