| ';
-
- // main table
-
- out +='';
-
- if(!print_hide('net_total')) {
- out += make_row('Net Total', doc.net_total, 1);
- }
-
- // add rows
- if(cl.length){
- for(var i=0;i';
- out += '';
- out += '| In Words | ';
- out += '' + doc.in_words + ' | ';
- }
- out += '
| ';
- }
- return out;
-}
-
-cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')) {
- msgprint(__("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"));
- d.charge_type = '';
- }
- validated = false;
- refresh_field('charge_type', d.name, 'taxes');
- cur_frm.cscript.row_id(doc, cdt, cdn);
- cur_frm.cscript.rate(doc, cdt, cdn);
- cur_frm.cscript.tax_amount(doc, cdt, cdn);
-}
-
-cur_frm.cscript.row_id = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if(!d.charge_type && d.row_id) {
- msgprint(__("Please select Charge Type first"));
- d.row_id = '';
- }
- else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) {
- msgprint(__("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'"));
- d.row_id = '';
- }
- else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id) {
- if(d.row_id >= d.idx){
- msgprint(__("Cannot refer row number greater than or equal to current row number for this Charge type"));
- d.row_id = '';
- }
- }
- validated = false;
- refresh_field('row_id', d.name, 'taxes');
-}
-
-/*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/
-
-cur_frm.fields_dict['taxes'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
- return{
- query: "erpnext.controllers.queries.tax_account_query",
- filters: {
- "account_type": ["Tax", "Chargeable", "Income Account"],
- "company": doc.company
- }
- }
-}
-
-cur_frm.fields_dict['taxes'].grid.get_field("cost_center").get_query = function(doc) {
- return{
- 'company': doc.company,
- 'group_or_ledger': "Ledger"
- }
-}
-
-cur_frm.cscript.rate = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if(!d.charge_type && d.rate) {
- msgprint(__("Please select Charge Type first"));
- d.rate = '';
- }
- validated = false;
- refresh_field('rate', d.name, 'taxes');
-}
-
-cur_frm.cscript.tax_amount = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if(!d.charge_type && d.tax_amount) {
- msgprint(__("Please select Charge Type first"));
- d.tax_amount = '';
- }
- // else if(d.charge_type && d.tax_amount) {
- // msgprint(__("Cannot directly set amount. For 'Actual' charge type, use the rate field"));
- // d.tax_amount = '';
- // }
- validated = false;
- refresh_field('tax_amount', d.name, 'taxes');
-};
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index 6759550e994..f98dab783d9 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -90,20 +90,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
this.price_list_rate(doc, cdt, cdn);
},
- rate: function(doc, cdt, cdn) {
- var item = frappe.get_doc(cdt, cdn);
- frappe.model.round_floats_in(item, ["rate", "discount_percentage"]);
-
- if(item.price_list_rate) {
- item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0,
- precision("discount_percentage", item));
- } else {
- item.discount_percentage = 0.0;
- }
-
- this.calculate_taxes_and_totals();
- },
-
uom: function(doc, cdt, cdn) {
var me = this;
var item = frappe.get_doc(cdt, cdn);
@@ -293,3 +279,8 @@ erpnext.buying.get_default_bom = function(frm) {
}
});
}
+
+
+frappe.ui.form.on("Purchase Taxes and Charges", "rate", function(frm, cdt, cdn) {
+ cur_frm.cscript.calculate_taxes_and_totals();
+})
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 504c446fe9d..7d19fde6e16 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -290,6 +290,8 @@ class calculate_taxes_and_totals(object):
tax.tax_amount = flt(tax.tax_amount, tax.precision("tax_amount"))
tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, tax.precision("tax_amount"))
+ self._set_in_company_currency(tax, ["total", "tax_amount", "tax_amount_after_discount_amount"]);
+
def adjust_discount_amount_loss(self, tax):
discount_amount_loss = self.doc.grand_total - flt(self.doc.discount_amount) - tax.total
tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount +
diff --git a/erpnext/projects/doctype/time_log/time_log.js b/erpnext/projects/doctype/time_log/time_log.js
index 5f7e84615f1..eb2e1a01f73 100644
--- a/erpnext/projects/doctype/time_log/time_log.js
+++ b/erpnext/projects/doctype/time_log/time_log.js
@@ -77,7 +77,6 @@ $.extend(cur_frm.cscript, {
},
callback: function(r) {
if(!r.exc) {
- console.log(r.message)
cur_frm.set_value("workstation", r.message)
}
}
diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js
index 03e1890b8be..4b1581180af 100644
--- a/erpnext/public/js/controllers/accounts.js
+++ b/erpnext/public/js/controllers/accounts.js
@@ -1,3 +1,9 @@
+// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+// License: GNU General Public License v3. See license.txt
+
+frappe.ui.form.on(cur_frm.doctype, "refresh", function(frm) {
+ frm.set_footnote(frappe.markdown(frm.meta.description));
+}
// get tax rate
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
@@ -8,7 +14,7 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) {
} else if(d.account_head && d.charge_type!=="Actual") {
frappe.call({
type:"GET",
- method: "erpnext.controllers.accounts_controller.get_tax_rate",
+ method: "erpnext.controllers.accounts_controller.get_tax_rate",
args: {"account_head":d.account_head},
callback: function(r) {
frappe.model.set_value(cdt, cdn, "rate", r.message || 0);
@@ -16,3 +22,139 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) {
})
}
}
+
+
+var validate_taxes_and_charges = function(cdt, cdn) {
+ var d = locals[cdt][cdn];
+ if(!d.charge_type && (d.row_id || d.rate || d.tax_amount)) {
+ msgprint(__("Please select Charge Type first"));
+ d.row_id = ""
+ d.rate = d.tax_amount = 0.0
+ } else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) {
+ msgprint(__("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'"));
+ d.row_id = "";
+ } else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id) {
+ if (d.idx == 1) {
+ msgprint(__("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"));
+ d.charge_type = '';
+ } else if (d.row_i && d.row_id >= d.idx) {
+ msgprint(__("Cannot refer row number greater than or equal to current row number for this Charge type"));
+ d.row_id = "";
+ }
+ }
+ validated = false;
+ refresh_field('row_id', d.name, 'taxes');
+}
+
+frappe.ui.form.on(cur_frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) {
+ validate_taxes_and_charges(cdt, cdn);
+})
+
+frappe.ui.form.on(cur_frm.cscript.tax_table, "rate", function(frm, cdt, cdn) {
+ validate_taxes_and_charges(cdt, cdn);
+})
+
+frappe.ui.form.on(cur_frm.cscript.tax_table, "tax_amount", function(frm, cdt, cdn) {
+ validate_taxes_and_charges(cdt, cdn);
+})
+
+frappe.ui.form.on(cur_frm.cscript.tax_table, "charge_type", function(frm, cdt, cdn) {
+ validate_taxes_and_charges(cdt, cdn);
+})
+
+
+cur_frm.set_query("account_head", "taxes", function(doc) {
+ if(cur_frm.cscript.tax_table == "Sales Taxes and Charges") {
+ var account_type = ["Tax", "Chargeable", "Expense Account"];
+ } else {
+ var account_type = ["Tax", "Chargeable", "Income Account"];
+ }
+
+ return {
+ query: "erpnext.controllers.queries.tax_account_query",
+ filters: {
+ "account_type": account_type,
+ "company": doc.company
+ }
+ }
+});
+
+cur_frm.set_query("cost_center", "taxes", function(doc) {
+ return {
+ filters: {
+ 'company': doc.company,
+ 'group_or_ledger': "Ledger"
+ }
+ }
+}
+
+// For customizing print
+cur_frm.pformat.print_total = function(doc) { return ''; }
+cur_frm.pformat.discount_amount = function(doc) { return ''; }
+cur_frm.pformat.grand_total = function(doc) { return ''; }
+cur_frm.pformat.rounded_total = function(doc) { return ''; }
+cur_frm.pformat.in_words = function(doc) { return ''; }
+
+cur_frm.pformat.taxes= function(doc){
+ //function to make row of table
+ var make_row = function(title, val, bold){
+ var bstart = ''; var bend = '';
+ return ' |