[buying] [fix] store item tax amount only if field exists

This commit is contained in:
Anand Doshi 2013-06-05 17:46:20 +05:30
parent 12cea9587f
commit b392878f15
2 changed files with 14 additions and 6 deletions

View File

@ -309,6 +309,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
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,7 +332,8 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
// stored for valuation
//
// TODO: rename item_tax_amount to valuation_tax_amount
if(["Valuation", "Valuation and Total"].indexOf(tax.category) != -1) {
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));
}

View File

@ -179,7 +179,8 @@ class BuyingController(StockController):
TODO: rename item_tax_amount to valuation_tax_amount
"""
if tax.category in ["Valuation", "Valuation and Total"]:
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