diff --git a/erpnext/selling/doctype/sales_common/sales_common.js b/erpnext/selling/doctype/sales_common/sales_common.js index ebe2836409..603a7b2114 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.js +++ b/erpnext/selling/doctype/sales_common/sales_common.js @@ -310,34 +310,21 @@ cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname) //enter item_wise_tax_detail i.e. tax rate on each item var item_wise_tax_detail = cur_frm.cscript.get_item_wise_tax_detail(doc, rate, cl, i, tax, t); - - // this is calculation part for all types - if(tax[t].charge_type != "Actual") { - tax[t].item_wise_tax_detail += item_wise_tax_detail; - } - //console.log(tax[t]); - //console.log(tax_amount); - //console.log(total); - - tax[t].total_amount = flt(tax_amount.toFixed(2)); //stores actual tax amount in virtual field + if(tax[t].charge_type != "Actual") tax[t].item_wise_tax_detail += item_wise_tax_detail; + tax[t].total_amount = flt(tax_amount); //stores actual tax amount in virtual field tax[t].total_tax_amount = flt(prev_total); //stores total amount in virtual field tax[t].tax_amount += flt(tax_amount); - - //var total_amount = flt(tax_amount.toFixed(2)); - //total_tax_amount = flt(tax[t].total_tax_amount) + flt(total_amount); - - set_multiple('RV Tax Detail', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':flt(tax[t].total_amount), 'total':flt((flt(total)+flt(tax[t].tax_amount)).toFixed(2))/*_tax_amount)*/}, other_fname); - - //console.log("Total: " + (flt(total)+flt(tax[t].tax_amount))); - + var total_amount = flt(tax[t].tax_amount); + total_tax_amount = flt(tax[t].total_tax_amount) + flt(total_amount); + set_multiple('RV Tax Detail', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':flt(total_amount.toFixed(2)), 'total':(flt(total)+flt(tax[t].tax_amount)).toFixed(2)/*_tax_amount)*/}, other_fname); prev_total += flt(tax[t].total_amount); // for previous row total - total += flt(tax_amount); // for adding total to previous amount + total += flt(tax[t].tax_amount); // for adding total to previous amount if(tax[t].charge_type == 'Actual') $td(otc,i+1,t+1).innerHTML = fmt_money(tax[t].total_amount); else $td(otc,i+1,t+1).innerHTML = '('+fmt_money(rate) + '%) ' +fmt_money(tax[t].total_amount); - + } } } diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py index 47a348372e..b2b0c14148 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.py +++ b/erpnext/selling/doctype/sales_common/sales_common.py @@ -593,7 +593,9 @@ class StatusUpdater: If you want to increase your overflow tolerance, please increase tolerance %% in Global Defaults or Item master. - Or, you must reduce the %(compare_ref_field)s by %(reduce_by)s""" % item, raise_exception=1) + Or, you must reduce the %(compare_ref_field)s by %(reduce_by)s + + Also, please check if the order item has already been billed in the Sales Order""" % item, raise_exception=1) def validate_qty(self, args, no_tolerance=None): """ diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 944fa8aff0..0572592645 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -92,6 +92,17 @@ class DocType(TransactionBase): raise Exception + def validate_challan_no(self): + "Validate if same challan no exists for same supplier in a purchase receipt" + if self.doc.challan_no: + exists = webnotes.conn.sql(""" + SELECT name FROM `tabPurchase Receipt` + WHERE name!=%s AND supplier=%s AND challan_no=%s""", (self.doc.name, self.doc.supplier, self.doc.challan_no)) + if exists: + webnotes.msgprint("Another Purchase Receipt using the same Challan No. already exists.\ + Please enter a valid Challan No.", raise_exception=1) + + # update valuation rate def update_valuation_rate(self): total_b_cost = flt(self.doc.buying_cost_transport) + flt(self.doc.buying_cost_taxes) + flt(self.doc.buying_cost_other) @@ -127,6 +138,7 @@ class DocType(TransactionBase): self.validate_accepted_rejected_qty() self.validate_inspection() # Validate Inspection get_obj('Stock Ledger').validate_serial_no(self, 'purchase_receipt_details') + self.validate_challan_no() pc_obj = get_obj(dt='Purchase Common') pc_obj.validate_for_items(self)