Skip to content

Commit

Permalink
refactor(taxes): change logic of complaince item as it move to item a…
Browse files Browse the repository at this point in the history
…nd minor changes added
  • Loading branch information
vishdha committed Oct 19, 2020
1 parent 5337351 commit 2f64902
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion erpnext/compliance/taxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def set_cultivation_tax(doc):
if isinstance(doc, str):
doc = frappe._dict(json.loads(doc))

compliance_items = frappe.get_all('Compliance Item', fields=['item_code'])
compliance_items = frappe.get_all('Item', filters={'is_compliance_item': True}, fields=['item_code'])
if not compliance_items:
return
cultivation_tax_row = []
Expand Down
18 changes: 6 additions & 12 deletions erpnext/public/js/controllers/taxes_and_totals.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,17 +757,13 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
},
set_and_update_cultivation_tax: function () {
const me = this;
if (["Quotation", "Sales Invoice", "Delivery Note", "Sales Order"].includes(me.frm.doctype)) {
if (!me.frm.doc.license) {
return;
}
if (["Quotation", "Sales Invoice", "Delivery Note", "Sales Order"].includes(me.frm.doctype) && !me.frm.doc.license) {
return;
}

frappe.db.get_value("Compliance Info", { "name": me.frm.doc.license }, "license_for", (r) => {
if (["Sales Order", "Sales Invoice", "Delivery Note", "Stock Entry"].includes(me.frm.doctype)) {
if (!r || r.license_for !== "Distributor") {
return;
}
if (["Sales Order", "Sales Invoice", "Delivery Note", "Stock Entry"].includes(me.frm.doctype) && (!r || r.license_for !== "Distributor")) {
return;
}

frappe.call({
Expand Down Expand Up @@ -797,10 +793,8 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
me.calculate_taxes_and_totals();
}
}
if (me.frm.doc.items.length === 0) {
if (taxes && taxes.length > 0) {
me.frm.doc.taxes.remove_all();
}
if (me.frm.doc.items.length === 0 && (taxes && taxes.length > 0)) {
me.frm.get_field("taxes").grid.remove_all();
}
}
}
Expand Down

0 comments on commit 2f64902

Please sign in to comment.