discount calculation and in print view

This commit is contained in:
Nabin Hait
2015-02-23 01:06:00 +05:30
parent 2b019ed430
commit de9c8a9028
10 changed files with 1241 additions and 1212 deletions

View File

@@ -14,7 +14,7 @@ from erpnext.controllers.stock_controller import StockController
class BuyingController(StockController): class BuyingController(StockController):
def __setup__(self): def __setup__(self):
if hasattr(self, "items"): if hasattr(self, "taxes"):
self.print_templates = { self.print_templates = {
"taxes": "templates/print_formats/includes/taxes.html" "taxes": "templates/print_formats/includes/taxes.html"
} }

View File

@@ -12,7 +12,7 @@ from erpnext.controllers.stock_controller import StockController
class SellingController(StockController): class SellingController(StockController):
def __setup__(self): def __setup__(self):
if hasattr(self, "items"): if hasattr(self, "taxes"):
self.print_templates = { self.print_templates = {
"taxes": "templates/print_formats/includes/taxes.html" "taxes": "templates/print_formats/includes/taxes.html"
} }

View File

@@ -76,8 +76,9 @@ class calculate_taxes_and_totals(object):
"tax_amount_for_current_item", "grand_total_for_current_item", "tax_amount_for_current_item", "grand_total_for_current_item",
"tax_fraction_for_current_item", "grand_total_fraction_for_current_item"] "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"]
if tax.charge_type != "Actual" and not self.discount_amount_applied: if tax.charge_type != "Actual" and \
tax_fields.append("tax_amount") not (self.discount_amount_applied and self.doc.apply_discount_on=="Grand Total"):
tax_fields.append("tax_amount")
for fieldname in tax_fields: for fieldname in tax_fields:
tax.set(fieldname, 0.0) tax.set(fieldname, 0.0)
@@ -215,8 +216,9 @@ class calculate_taxes_and_totals(object):
current_tax_amount += actual_tax_dict[tax.idx] current_tax_amount += actual_tax_dict[tax.idx]
# accumulate tax amount into tax.tax_amount # accumulate tax amount into tax.tax_amount
if tax.charge_type != "Actual" and not self.discount_amount_applied: if tax.charge_type != "Actual" and \
tax.tax_amount += current_tax_amount not (self.discount_amount_applied and self.doc.apply_discount_on=="Grand Total"):
tax.tax_amount += current_tax_amount
# store tax_amount for current item as it will be used for # store tax_amount for current item as it will be used for
# charge type = 'On Previous Row Amount' # charge type = 'On Previous Row Amount'
@@ -250,8 +252,9 @@ class calculate_taxes_and_totals(object):
self.round_off_totals(tax) self.round_off_totals(tax)
# adjust Discount Amount loss in last tax iteration # adjust Discount Amount loss in last tax iteration
if i == (len(self.doc.get("taxes")) - 1) and self.discount_amount_applied: if i == (len(self.doc.get("taxes")) - 1) and self.discount_amount_applied \
self.adjust_discount_amount_loss(tax) and self.doc.apply_discount_on == "Grand Total":
self.adjust_discount_amount_loss(tax)
def get_current_tax_amount(self, item, tax, item_tax_map): def get_current_tax_amount(self, item, tax, item_tax_map):
tax_rate = self._get_tax_rate(tax, item_tax_map) tax_rate = self._get_tax_rate(tax, item_tax_map)
@@ -291,7 +294,7 @@ class calculate_taxes_and_totals(object):
tax.tax_amount = flt(tax.tax_amount, tax.precision("tax_amount")) 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")) 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"]); self._set_in_company_currency(tax, ["total", "tax_amount", "tax_amount_after_discount_amount"])
def adjust_discount_amount_loss(self, tax): def adjust_discount_amount_loss(self, tax):
discount_amount_loss = self.doc.grand_total - flt(self.doc.discount_amount) - tax.total discount_amount_loss = self.doc.grand_total - flt(self.doc.discount_amount) - tax.total
@@ -360,8 +363,8 @@ class calculate_taxes_and_totals(object):
self.doc.base_discount_amount = 0 self.doc.base_discount_amount = 0
def get_total_for_discount_amount(self): def get_total_for_discount_amount(self):
if self.doc.apply_discount_on == "Print Total": if self.doc.apply_discount_on == "Net Total":
return self.net_total return self.doc.net_total
else: else:
actual_taxes_dict = {} actual_taxes_dict = {}

View File

@@ -93,11 +93,11 @@ cur_frm.pformat.in_words = function(doc) { return ''; }
cur_frm.pformat.taxes= function(doc){ cur_frm.pformat.taxes= function(doc){
//function to make row of table //function to make row of table
var make_row = function(title, val, bold){ var make_row = function(title, val, bold, is_negative) {
var bstart = '<b>'; var bend = '</b>'; var bstart = '<b>'; var bend = '</b>';
return '<tr><td style="width:50%;">' + (bold?bstart:'') + title + (bold?bend:'') + '</td>' return '<tr><td style="width:50%;">' + (bold?bstart:'') + title + (bold?bend:'') + '</td>'
+ '<td style="width:50%;text-align:right;">' + format_currency(val, doc.currency) + '</td>' + '<td style="width:50%;text-align:right;">' + (is_negative ? '- ' : '')
+ '</tr>'; + format_currency(val, doc.currency) + '</td></tr>';
} }
function convert_rate(val) { function convert_rate(val) {
@@ -125,6 +125,10 @@ cur_frm.pformat.taxes= function(doc){
out += make_row('Net Total', doc.print_total, 1); out += make_row('Net Total', doc.print_total, 1);
} }
// Discount Amount on net total
if(!print_hide('discount_amount') && doc.apply_discount_on == "Net Total" && doc.discount_amount)
out += make_row('Discount Amount', doc.discount_amount, 0, 1);
// add rows // add rows
if(cl.length){ if(cl.length){
for(var i=0;i<cl.length;i++) { for(var i=0;i<cl.length;i++) {
@@ -133,9 +137,9 @@ cur_frm.pformat.taxes= function(doc){
} }
} }
// Discount Amount // Discount Amount on grand total
if(!print_hide('discount_amount') && doc.discount_amount) if(!print_hide('discount_amount') && doc.apply_discount_on == "Grand Total" && doc.discount_amount)
out += make_row('Discount Amount', doc.discount_amount, 0); out += make_row('Discount Amount', doc.discount_amount, 0, 1);
// grand total // grand total
if(!print_hide('grand_total')) if(!print_hide('grand_total'))

View File

@@ -88,8 +88,9 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
"tax_amount_for_current_item", "grand_total_for_current_item", "tax_amount_for_current_item", "grand_total_for_current_item",
"tax_fraction_for_current_item", "grand_total_fraction_for_current_item"] "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"]
if (cstr(tax.charge_type) != "Actual" && !me.discount_amount_applied) if (cstr(tax.charge_type) != "Actual" &&
tax_fields.push("tax_amount"); !(me.discount_amount_applied && me.frm.doc.apply_discount_on=="Grand Total"))
tax_fields.push("tax_amount");
$.each(tax_fields, function(i, fieldname) { tax[fieldname] = 0.0 }); $.each(tax_fields, function(i, fieldname) { tax[fieldname] = 0.0 });
@@ -217,8 +218,9 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
} }
// accumulate tax amount into tax.tax_amount // accumulate tax amount into tax.tax_amount
if (tax.charge_type != "Actual" && !me.discount_amount_applied) if (tax.charge_type != "Actual" &&
tax.tax_amount += current_tax_amount; !(me.discount_amount_applied && me.frm.doc.apply_discount_on=="Grand Total"))
tax.tax_amount += current_tax_amount;
// store tax_amount for current item as it will be used for // store tax_amount for current item as it will be used for
// charge type = 'On Previous Row Amount' // charge type = 'On Previous Row Amount'
@@ -254,7 +256,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
me.round_off_totals(tax); me.round_off_totals(tax);
// adjust Discount Amount loss in last tax iteration // adjust Discount Amount loss in last tax iteration
if ((i == me.frm.doc["taxes"].length - 1) && me.discount_amount_applied) if ((i == me.frm.doc["taxes"].length - 1) && me.discount_amount_applied && me.frm.doc.apply_discount_on == "Grand Total")
me.adjust_discount_amount_loss(tax); me.adjust_discount_amount_loss(tax);
} }
}); });
@@ -428,8 +430,8 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
get_total_for_discount_amount: function() { get_total_for_discount_amount: function() {
var me = this; var me = this;
if(this.apply_discount_amount == "Print Total") { if(this.frm.doc.apply_discount_on == "Net Total") {
return this.net_total return this.frm.doc.net_total
} else { } else {
var total_actual_tax = 0.0; var total_actual_tax = 0.0;
var actual_taxes_dict = {}; var actual_taxes_dict = {};

File diff suppressed because it is too large Load Diff

View File

@@ -1,396 +1,399 @@
{ {
"autoname": "hash", "autoname": "QUOD/.#####",
"creation": "2013-03-07 11:42:57", "creation": "2013-03-07 11:42:57",
"docstatus": 0, "docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"fields": [ "fields": [
{ {
"fieldname": "item_code", "fieldname": "item_code",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"in_filter": 1, "in_filter": 1,
"in_list_view": 1, "in_list_view": 1,
"label": "Item Code", "label": "Item Code",
"oldfieldname": "item_code", "oldfieldname": "item_code",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Item", "options": "Item",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"print_width": "150px", "print_width": "150px",
"read_only": 0, "read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1, "search_index": 1,
"width": "150px" "width": "150px"
}, },
{ {
"fieldname": "customer_item_code", "fieldname": "customer_item_code",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
"label": "Customer's Item Code", "label": "Customer's Item Code",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"read_only": 1 "read_only": 1
}, },
{ {
"fieldname": "item_name", "fieldname": "item_name",
"fieldtype": "Data", "fieldtype": "Data",
"in_filter": 1, "in_filter": 1,
"in_list_view": 1, "in_list_view": 1,
"label": "Item Name", "label": "Item Name",
"oldfieldname": "item_name", "oldfieldname": "item_name",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_width": "150px", "print_width": "150px",
"read_only": 0, "read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 1, "search_index": 1,
"width": "150px" "width": "150px"
}, },
{ {
"fieldname": "col_break1", "fieldname": "col_break1",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "description", "fieldname": "description",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"in_list_view": 1, "in_list_view": 1,
"label": "Description", "label": "Description",
"oldfieldname": "description", "oldfieldname": "description",
"oldfieldtype": "Small Text", "oldfieldtype": "Small Text",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"print_width": "300px", "print_width": "300px",
"read_only": 0, "read_only": 0,
"reqd": 1, "reqd": 1,
"width": "300px" "width": "300px"
}, },
{ {
"fieldname": "image", "fieldname": "image",
"fieldtype": "Attach", "fieldtype": "Attach",
"hidden": 1, "hidden": 1,
"label": "Image", "label": "Image",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 1 "print_hide": 1
}, },
{ {
"fieldname": "image_view", "fieldname": "image_view",
"fieldtype": "Image", "fieldtype": "Image",
"label": "Image View", "label": "Image View",
"options": "image", "options": "image",
"permlevel": 0, "permlevel": 0,
"precision": "" "precision": ""
}, },
{ {
"fieldname": "quantity_and_rate", "fieldname": "quantity_and_rate",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Quantity and Rate", "label": "Quantity and Rate",
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "qty", "fieldname": "qty",
"fieldtype": "Float", "fieldtype": "Float",
"in_filter": 0, "in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"label": "Quantity", "label": "Quantity",
"oldfieldname": "qty", "oldfieldname": "qty",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"print_width": "100px", "print_width": "100px",
"read_only": 0, "read_only": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
"width": "100px" "width": "100px"
}, },
{ {
"fieldname": "price_list_rate", "fieldname": "price_list_rate",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Price List Rate", "label": "Price List Rate",
"oldfieldname": "ref_rate", "oldfieldname": "ref_rate",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "currency", "options": "currency",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 1, "read_only": 1,
"reqd": 0, "reqd": 0,
"width": "100px" "width": "100px"
}, },
{ {
"fieldname": "discount_percentage", "fieldname": "discount_percentage",
"fieldtype": "Percent", "fieldtype": "Percent",
"in_list_view": 1, "in_list_view": 1,
"label": "Discount (%)", "label": "Discount (%)",
"oldfieldname": "adj_rate", "oldfieldname": "adj_rate",
"oldfieldtype": "Float", "oldfieldtype": "Float",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 0, "read_only": 0,
"width": "100px" "width": "100px"
}, },
{ {
"fieldname": "col_break2", "fieldname": "col_break2",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "stock_uom", "fieldname": "stock_uom",
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 1, "in_list_view": 1,
"label": "UOM", "label": "UOM",
"oldfieldname": "stock_uom", "oldfieldname": "stock_uom",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"options": "UOM", "options": "UOM",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"print_width": "100px", "print_width": "100px",
"read_only": 1, "read_only": 1,
"reqd": 0, "reqd": 0,
"width": "100px" "width": "100px"
}, },
{ {
"fieldname": "base_price_list_rate", "fieldname": "base_price_list_rate",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Price List Rate (Company Currency)", "label": "Price List Rate (Company Currency)",
"oldfieldname": "base_ref_rate", "oldfieldname": "base_ref_rate",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 1, "read_only": 1,
"width": "100px" "width": "100px"
}, },
{ {
"fieldname": "Section_break1", "fieldname": "Section_break1",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "rate", "fieldname": "rate",
"fieldtype": "Currency", "fieldtype": "Currency",
"in_filter": 0, "in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"label": "Rate", "label": "Rate",
"oldfieldname": "export_rate", "oldfieldname": "export_rate",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "currency", "options": "currency",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"print_width": "100px", "print_width": "100px",
"read_only": 0, "read_only": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"width": "100px" "width": "100px"
}, },
{ {
"fieldname": "net_rate", "fieldname": "net_rate",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Net Rate", "hidden": 0,
"permlevel": 0, "label": "Net Rate",
"precision": "", "permlevel": 0,
"precision": "",
"print_hide": 1,
"read_only": 1 "read_only": 1
}, },
{ {
"fieldname": "amount", "fieldname": "amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"in_filter": 0, "in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"label": "Amount", "label": "Amount",
"oldfieldname": "export_amount", "oldfieldname": "export_amount",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "currency", "options": "currency",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"print_width": "100px", "print_width": "100px",
"read_only": 1, "read_only": 1,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"width": "100px" "width": "100px"
}, },
{ {
"fieldname": "net_amount", "fieldname": "net_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Net Amount", "label": "Net Amount",
"options": "currency", "options": "currency",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 1, "print_hide": 1,
"read_only": 1 "read_only": 1
}, },
{ {
"fieldname": "col_break3", "fieldname": "col_break3",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "base_rate", "fieldname": "base_rate",
"fieldtype": "Currency", "fieldtype": "Currency",
"in_filter": 0, "in_filter": 0,
"label": "Rate (Company Currency)", "label": "Rate (Company Currency)",
"oldfieldname": "basic_rate", "oldfieldname": "basic_rate",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 1, "read_only": 1,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"width": "100px" "width": "100px"
}, },
{ {
"fieldname": "base_net_rate", "fieldname": "base_net_rate",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Net Rate (Company Currency)", "label": "Net Rate (Company Currency)",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 1,
"read_only": 1 "read_only": 1
}, },
{ {
"fieldname": "base_amount", "fieldname": "base_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"in_filter": 0, "in_filter": 0,
"label": "Amount (Company Currency)", "label": "Amount (Company Currency)",
"oldfieldname": "amount", "oldfieldname": "amount",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_width": "100px", "print_width": "100px",
"read_only": 1, "read_only": 1,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"width": "100px" "width": "100px"
}, },
{ {
"fieldname": "base_net_amount", "fieldname": "base_net_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Net Amount (Company Currency)", "label": "Net Amount (Company Currency)",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 1, "print_hide": 1,
"read_only": 1 "read_only": 1
}, },
{ {
"fieldname": "pricing_rule", "fieldname": "pricing_rule",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Pricing Rule", "label": "Pricing Rule",
"options": "Pricing Rule", "options": "Pricing Rule",
"permlevel": 0, "permlevel": 0,
"read_only": 1 "read_only": 1
}, },
{ {
"fieldname": "reference", "fieldname": "reference",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Reference", "label": "Reference",
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "prevdoc_doctype", "fieldname": "prevdoc_doctype",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
"label": "Against Doctype", "label": "Against Doctype",
"no_copy": 1, "no_copy": 1,
"oldfieldname": "prevdoc_doctype", "oldfieldname": "prevdoc_doctype",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_width": "150px", "print_width": "150px",
"read_only": 1, "read_only": 1,
"report_hide": 0, "report_hide": 0,
"width": "150px" "width": "150px"
}, },
{ {
"fieldname": "prevdoc_docname", "fieldname": "prevdoc_docname",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Against Docname", "label": "Against Docname",
"no_copy": 1, "no_copy": 1,
"oldfieldname": "prevdoc_docname", "oldfieldname": "prevdoc_docname",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_width": "150px", "print_width": "150px",
"read_only": 1, "read_only": 1,
"report_hide": 0, "report_hide": 0,
"width": "150px" "width": "150px"
}, },
{ {
"fieldname": "item_tax_rate", "fieldname": "item_tax_rate",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 1, "hidden": 1,
"label": "Item Tax Rate", "label": "Item Tax Rate",
"oldfieldname": "item_tax_rate", "oldfieldname": "item_tax_rate",
"oldfieldtype": "Small Text", "oldfieldtype": "Small Text",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1,
"report_hide": 1 "report_hide": 1
}, },
{ {
"fieldname": "col_break4", "fieldname": "col_break4",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"permlevel": 0 "permlevel": 0
}, },
{ {
"allow_on_submit": 1, "allow_on_submit": 1,
"fieldname": "page_break", "fieldname": "page_break",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
"label": "Page Break", "label": "Page Break",
"no_copy": 1, "no_copy": 1,
"oldfieldname": "page_break", "oldfieldname": "page_break",
"oldfieldtype": "Check", "oldfieldtype": "Check",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"read_only": 0, "read_only": 0,
"report_hide": 1 "report_hide": 1
}, },
{ {
"description": "", "description": "",
"fieldname": "item_group", "fieldname": "item_group",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "Item Group", "label": "Item Group",
"oldfieldname": "item_group", "oldfieldname": "item_group",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Item Group", "options": "Item Group",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1,
"search_index": 1 "search_index": 1
}, },
{ {
"fieldname": "brand", "fieldname": "brand",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1, "hidden": 1,
"in_filter": 1, "in_filter": 1,
"label": "Brand", "label": "Brand",
"oldfieldname": "brand", "oldfieldname": "brand",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Brand", "options": "Brand",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_width": "150px", "print_width": "150px",
"read_only": 1, "read_only": 1,
"search_index": 1, "search_index": 1,
"width": "150px" "width": "150px"
} }
], ],
"idx": 1, "idx": 1,
"istable": 1, "istable": 1,
"modified": "2015-02-19 15:08:25.451407", "modified": "2015-02-23 00:48:08.477241",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Quotation Item", "name": "Quotation Item",
"owner": "Administrator", "owner": "Administrator",
"permissions": [], "permissions": [],
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC" "sort_order": "DESC"
} }

View File

@@ -154,6 +154,10 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
} }
}, },
apply_discount_on: function() {
this.calculate_taxes_and_totals();
},
discount_amount: function() { discount_amount: function() {
this.calculate_taxes_and_totals(); this.calculate_taxes_and_totals();
}, },

View File

@@ -442,17 +442,6 @@
"read_only": 1, "read_only": 1,
"width": "150px" "width": "150px"
}, },
{
"fieldname": "buying_amount",
"fieldtype": "Currency",
"hidden": 1,
"label": "Buying Amount",
"no_copy": 1,
"options": "Company:company:default_currency",
"permlevel": 0,
"print_hide": 1,
"read_only": 1
},
{ {
"allow_on_submit": 1, "allow_on_submit": 1,
"fieldname": "page_break", "fieldname": "page_break",
@@ -467,7 +456,7 @@
], ],
"idx": 1, "idx": 1,
"istable": 1, "istable": 1,
"modified": "2015-02-19 01:06:59.675246", "modified": "2015-02-23 00:06:50.441413",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Delivery Note Item", "name": "Delivery Note Item",

View File

@@ -1,6 +1,21 @@
{%- macro render_discount_amount(doc) -%}
{%- if doc.discount_amount -%}
<div class="row">
<div class="col-xs-5 text-right">
<label>{{ "Discount Amount" }}</label></div>
<div class="col-xs-7 text-right">
- {{ doc.get_formatted("discount_amount", doc) }}
</div>
</div>
{%- endif -%}
{%- endmacro -%}
<div class="row"> <div class="row">
<div class="col-xs-6"></div> <div class="col-xs-6"></div>
<div class="col-xs-6"> <div class="col-xs-6">
{%- if doc.apply_discount_on == "Net Total" -%}
{{ render_discount_amount(doc) }}
{%- endif -%}
{%- for charge in data -%} {%- for charge in data -%}
{%- if not charge.included_in_print_rate -%} {%- if not charge.included_in_print_rate -%}
<div class="row"> <div class="row">
@@ -13,5 +28,8 @@
</div> </div>
{%- endif -%} {%- endif -%}
{%- endfor -%} {%- endfor -%}
{%- if doc.apply_discount_on == "Grand Total" -%}
{{ render_discount_amount(doc) }}
{%- endif -%}
</div> </div>
</div> </div>