rounding issue and rate trigger

This commit is contained in:
Nabin Hait 2015-02-24 17:08:34 +05:30
parent b620fed762
commit 93b3a37a3b
5 changed files with 8 additions and 19 deletions

View File

@ -387,5 +387,5 @@ def validate_inclusive_tax(tax, doc):
not all([cint(t.included_in_print_rate) for t in doc.get("taxes")[:cint(tax.row_id) - 1]]): not all([cint(t.included_in_print_rate) for t in doc.get("taxes")[:cint(tax.row_id) - 1]]):
# all rows about the reffered tax should be inclusive # all rows about the reffered tax should be inclusive
_on_previous_row_error("1 - %d" % (tax.row_id,)) _on_previous_row_error("1 - %d" % (tax.row_id,))
elif tax.category == "Valuation": elif tax.get("category") == "Valuation":
frappe.throw(_("Valuation type charges can not marked as Inclusive")) frappe.throw(_("Valuation type charges can not marked as Inclusive"))

View File

@ -214,10 +214,10 @@ class calculate_taxes_and_totals(object):
# note: grand_total_for_current_item contains the contribution of # note: grand_total_for_current_item contains the contribution of
# item's amount, previously applied tax and the current tax on that item # item's amount, previously applied tax and the current tax on that item
if i==0: if i==0:
tax.grand_total_for_current_item = flt(item.net_amount + current_tax_amount) tax.grand_total_for_current_item = flt(item.net_amount + current_tax_amount, tax.precision("total"))
else: else:
tax.grand_total_for_current_item = \ tax.grand_total_for_current_item = \
self.doc.get("taxes")[i-1].grand_total_for_current_item + current_tax_amount flt(self.doc.get("taxes")[i-1].grand_total_for_current_item + current_tax_amount, tax.precision("total_taxes_and_charges"))
# in tax.total, accumulate grand total of each item # in tax.total, accumulate grand total of each item
tax.total += tax.grand_total_for_current_item tax.total += tax.grand_total_for_current_item
@ -249,7 +249,7 @@ class calculate_taxes_and_totals(object):
current_tax_amount = (tax_rate / 100.0) * \ current_tax_amount = (tax_rate / 100.0) * \
self.doc.get("taxes")[cint(tax.row_id) - 1].grand_total_for_current_item self.doc.get("taxes")[cint(tax.row_id) - 1].grand_total_for_current_item
# current_tax_amount = flt(current_tax_amount, tax.precision("tax_amount", tax)) current_tax_amount = flt(current_tax_amount, tax.precision("tax_amount"))
self.set_item_wise_tax(item, tax, tax_rate, current_tax_amount) self.set_item_wise_tax(item, tax, tax_rate, current_tax_amount)

View File

@ -238,10 +238,10 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
// note: grand_total_for_current_item contains the contribution of // note: grand_total_for_current_item contains the contribution of
// item's amount, previously applied tax and the current tax on that item // item's amount, previously applied tax and the current tax on that item
if(i==0) { if(i==0) {
tax.grand_total_for_current_item = flt(item.net_amount + current_tax_amount); tax.grand_total_for_current_item = flt(item.net_amount + current_tax_amount, precision("total", tax));
} else { } else {
tax.grand_total_for_current_item = tax.grand_total_for_current_item =
flt(me.frm.doc["taxes"][i-1].grand_total_for_current_item + current_tax_amount); flt(me.frm.doc["taxes"][i-1].grand_total_for_current_item + current_tax_amount, precision("total", tax));
} }
// in tax.total, accumulate grand total for each item // in tax.total, accumulate grand total for each item
@ -285,7 +285,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
this.frm.doc["taxes"][cint(tax.row_id) - 1].grand_total_for_current_item; this.frm.doc["taxes"][cint(tax.row_id) - 1].grand_total_for_current_item;
} }
// current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax)); current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax));
this.set_item_wise_tax(item, tax, tax_rate, current_tax_amount); this.set_item_wise_tax(item, tax, tax_rate, current_tax_amount);

View File

@ -685,7 +685,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
} }
}); });
frappe.ui.form.on(cur_frm.doctype + "Item", "rate", function(frm, cdt, cdn) { frappe.ui.form.on(cur_frm.doctype + " Item", "rate", function(frm, cdt, cdn) {
var item = frappe.get_doc(cdt, cdn); var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["rate", "price_list_rate"]); frappe.model.round_floats_in(item, ["rate", "price_list_rate"]);

View File

@ -3,7 +3,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import cstr
from frappe.model.mapper import get_mapped_doc from frappe.model.mapper import get_mapped_doc
from frappe import _ from frappe import _
@ -18,21 +17,12 @@ class Quotation(SellingController):
super(Quotation, self).validate() super(Quotation, self).validate()
self.set_status() self.set_status()
self.validate_order_type() self.validate_order_type()
self.validate_for_items()
self.validate_uom_is_integer("stock_uom", "qty") self.validate_uom_is_integer("stock_uom", "qty")
self.validate_quotation_to() self.validate_quotation_to()
def has_sales_order(self): def has_sales_order(self):
return frappe.db.get_value("Sales Order Item", {"prevdoc_docname": self.name, "docstatus": 1}) return frappe.db.get_value("Sales Order Item", {"prevdoc_docname": self.name, "docstatus": 1})
def validate_for_items(self):
chk_dupl_itm = []
for d in self.get('items'):
if [cstr(d.item_code),cstr(d.description)] in chk_dupl_itm:
frappe.throw(_("Item {0} with same description entered twice").format(d.item_code))
else:
chk_dupl_itm.append([cstr(d.item_code),cstr(d.description)])
def validate_order_type(self): def validate_order_type(self):
super(Quotation, self).validate_order_type() super(Quotation, self).validate_order_type()
@ -169,7 +159,6 @@ def _make_customer(source_name, ignore_permissions=False):
else: else:
raise raise
except frappe.MandatoryError: except frappe.MandatoryError:
from frappe.utils import get_url_to_form
frappe.throw(_("Please create Customer from Lead {0}").format(lead_name)) frappe.throw(_("Please create Customer from Lead {0}").format(lead_name))
else: else:
return customer_name return customer_name