Commonified taxes and totals calculation in server side
This commit is contained in:
parent
6f0a3ed8d4
commit
bd00e81ad5
@ -19,7 +19,7 @@ class taxes_and_totals(object):
|
||||
if self.doc.meta.get_field("discount_amount"):
|
||||
self.apply_discount_amount()
|
||||
|
||||
if self.doctype in ["Sales Invoice", "Purchase Invoice"]:
|
||||
if self.doc.doctype in ["Sales Invoice", "Purchase Invoice"]:
|
||||
self.calculate_total_advance()
|
||||
|
||||
def _calculate(self):
|
||||
@ -37,7 +37,7 @@ class taxes_and_totals(object):
|
||||
self.calculate_item_values()
|
||||
self.initialize_taxes()
|
||||
|
||||
if self.doctype in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
|
||||
if self.doc.doctype in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
|
||||
self.determine_exclusive_rate()
|
||||
|
||||
self.calculate_net_total()
|
||||
@ -186,7 +186,7 @@ class taxes_and_totals(object):
|
||||
self.doc.base_net_total += item.base_amount
|
||||
self.doc.net_total += item.amount
|
||||
|
||||
self.round_floats_in(self.doc, ["base_net_total", "net_total"])
|
||||
self.doc.round_floats_in(self.doc, ["base_net_total", "net_total"])
|
||||
|
||||
def calculate_taxes(self):
|
||||
# maintain actual tax rate based on idx
|
||||
@ -296,7 +296,7 @@ class taxes_and_totals(object):
|
||||
self.doc.base_total_taxes_and_charges = flt(self.doc.base_grand_total - self.doc.base_net_total,
|
||||
self.doc.precision("base_total_taxes_and_charges"))
|
||||
|
||||
if self.doctype in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
|
||||
if self.doc.doctype in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
|
||||
self.doc.grand_total = flt(self.doc.base_grand_total / self.doc.conversion_rate) \
|
||||
if (self.doc.base_total_taxes_and_charges or self.doc.discount_amount) else self.doc.net_total
|
||||
|
||||
@ -384,13 +384,13 @@ class taxes_and_totals(object):
|
||||
# write_off_amount is only for POS Invoice
|
||||
# total_advance is only for non POS Invoice
|
||||
|
||||
if self.doctype == "Sales Invoice":
|
||||
self.round_floats_in(self.doc, ["base_grand_total", "total_advance", "write_off_amount", "paid_amount"])
|
||||
if self.doc.doctype == "Sales Invoice":
|
||||
self.doc.round_floats_in(self.doc, ["base_grand_total", "total_advance", "write_off_amount", "paid_amount"])
|
||||
total_amount_to_pay = self.doc.base_grand_total - self.doc.write_off_amount
|
||||
self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance - self.doc.paid_amount,
|
||||
self.doc.precision("outstanding_amount"))
|
||||
else:
|
||||
self.round_floats_in(self.doc, ["total_advance", "write_off_amount"])
|
||||
self.doc.round_floats_in(self.doc, ["total_advance", "write_off_amount"])
|
||||
self.doc.total_amount_to_pay = flt(self.doc.base_grand_total - self.doc.write_off_amount,
|
||||
self.doc.precision("total_amount_to_pay"))
|
||||
self.doc.outstanding_amount = flt(self.doc.total_amount_to_pay - self.doc.total_advance,
|
||||
|
@ -18,7 +18,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
||||
}
|
||||
|
||||
// Sales person's commission
|
||||
if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"])) {
|
||||
if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) {
|
||||
this.calculate_commission();
|
||||
this.calculate_contribution();
|
||||
}
|
||||
@ -316,7 +316,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
||||
this.frm.doc.base_total_taxes_and_charges = flt(this.frm.doc.base_grand_total - this.frm.doc.base_net_total,
|
||||
precision("base_total_taxes_and_charges"));
|
||||
|
||||
if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"])) {
|
||||
if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) {
|
||||
this.frm.doc.grand_total = (this.frm.doc.base_total_taxes_and_charges || this.frm.doc.discount_amount) ?
|
||||
flt(this.frm.doc.base_grand_total / this.frm.doc.conversion_rate) : this.frm.doc.net_total;
|
||||
|
||||
|
@ -8,7 +8,6 @@ frappe.require("assets/erpnext/js/utils.js");
|
||||
erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
onload: function() {
|
||||
var me = this;
|
||||
|
||||
if(this.frm.doc.__islocal) {
|
||||
var today = get_today(),
|
||||
currency = frappe.defaults.get_user_default("currency");
|
||||
|
@ -176,15 +176,6 @@
|
||||
"reqd": 0,
|
||||
"width": "100px"
|
||||
},
|
||||
{
|
||||
"fieldname": "net_amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Net Amount",
|
||||
"options": "currency",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "col_break3",
|
||||
"fieldtype": "Column Break",
|
||||
@ -219,15 +210,6 @@
|
||||
"reqd": 0,
|
||||
"width": "100px"
|
||||
},
|
||||
{
|
||||
"fieldname": "base_net_amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Net Amount (Company Currency)",
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "pricing_rule",
|
||||
"fieldtype": "Link",
|
||||
@ -433,7 +415,7 @@
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"modified": "2015-01-22 13:52:44.959126",
|
||||
"modified": "2015-02-17 12:50:20.121459",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Sales Order Item",
|
||||
|
Loading…
x
Reference in New Issue
Block a user