Merge branch 'responsive' of github.com:webnotes/erpnext into responsive
diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js
index dfcafed..eee7984 100644
--- a/buying/doctype/purchase_common/purchase_common.js
+++ b/buying/doctype/purchase_common/purchase_common.js
@@ -309,6 +309,12 @@
delete item["rate"];
});
}
+
+ if(!wn.meta.get_docfield(item.doctype, "item_tax_amount", item.parent || item.name)) {
+ $.each(this.frm.item_doclist, function(i, item) {
+ delete item["item_tax_amount"];
+ });
+ }
},
calculate_outstanding_amount: function() {
@@ -326,9 +332,10 @@
// stored for valuation
//
// TODO: rename item_tax_amount to valuation_tax_amount
- if(["Valuation", "Valuation and Total"].indexOf(tax.category) != -1) {
- // accumulate only if tax is for Valuation / Valuation and Total
- item.item_tax_amount += flt(current_tax_amount, precision("item_tax_amount", item));
+ if(["Valuation", "Valuation and Total"].indexOf(tax.category) != -1 &&
+ wn.meta.get_docfield(item.doctype, "item_tax_amount", item.parent || item.name)) {
+ // accumulate only if tax is for Valuation / Valuation and Total
+ item.item_tax_amount += flt(current_tax_amount, precision("item_tax_amount", item));
}
},
diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py
index 312fb8e..f1cfc10 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -167,7 +167,7 @@
for item in self.item_doclist:
item.purchase_rate = item.rate
del item.fields["rate"]
-
+
if not self.meta.get_field("item_tax_amount", parentfield=self.fname):
for item in self.item_doclist:
del item.fields["item_tax_amount"]
@@ -179,8 +179,9 @@
TODO: rename item_tax_amount to valuation_tax_amount
"""
- if tax.category in ["Valuation", "Valuation and Total"]:
- item.item_tax_amount += flt(current_tax_amount, self.precision("item_tax_amount", item))
+ if tax.category in ["Valuation", "Valuation and Total"] and \
+ self.meta.get_field("item_tax_amount", parentfield=self.fname):
+ item.item_tax_amount += flt(current_tax_amount, self.precision("item_tax_amount", item))
# update valuation rate
def update_valuation_rate(self, parentfield):