mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 00:44:45 +00:00
Merge pull request #2842 from nabinhait/foreign_currency_calc
Foreign currency calc
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
frappe.provide("erpnext.accounts");
|
frappe.provide("erpnext.accounts");
|
||||||
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
||||||
{% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %}
|
|
||||||
|
|
||||||
erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
||||||
onload: function() {
|
onload: function() {
|
||||||
|
|||||||
@@ -263,6 +263,16 @@
|
|||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "Will be calculated automatically when you enter the details",
|
"description": "Will be calculated automatically when you enter the details",
|
||||||
"fieldname": "base_net_total",
|
"fieldname": "base_net_total",
|
||||||
@@ -280,6 +290,17 @@
|
|||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Total",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "net_total",
|
"fieldname": "net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -373,35 +394,10 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_grand_total",
|
"fieldname": "column_break_40",
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Grand Total (Company Currency)",
|
|
||||||
"oldfieldname": "grand_total",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "In Words will be visible once you save the Purchase Invoice.",
|
|
||||||
"fieldname": "base_in_words",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "In Words (Company Currency)",
|
|
||||||
"oldfieldname": "in_words",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "column_break8",
|
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"oldfieldtype": "Column Break",
|
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"precision": ""
|
||||||
"read_only": 0,
|
|
||||||
"width": "50%"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "taxes_and_charges_added",
|
"fieldname": "taxes_and_charges_added",
|
||||||
@@ -433,6 +429,84 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": ""
|
"precision": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_44",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Grand Total",
|
||||||
|
"fieldname": "apply_discount_on",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Apply Discount On",
|
||||||
|
"options": "\nGrand Total\nNet Total",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_46",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "discount_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Discount Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_discount_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Discount Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_49",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_grand_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Grand Total (Company Currency)",
|
||||||
|
"oldfieldname": "grand_total",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "In Words will be visible once you save the Purchase Invoice.",
|
||||||
|
"fieldname": "base_in_words",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "In Words (Company Currency)",
|
||||||
|
"oldfieldname": "in_words",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break8",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"oldfieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "grand_total",
|
"fieldname": "grand_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -888,7 +962,7 @@
|
|||||||
"icon": "icon-file-text",
|
"icon": "icon-file-text",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-02-20 05:16:22.693978",
|
"modified": "2015-02-23 15:33:28.554922",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice",
|
"name": "Purchase Invoice",
|
||||||
|
|||||||
@@ -275,36 +275,36 @@ class PurchaseInvoice(BuyingController):
|
|||||||
# tax table gl entries
|
# tax table gl entries
|
||||||
valuation_tax = {}
|
valuation_tax = {}
|
||||||
for tax in self.get("taxes"):
|
for tax in self.get("taxes"):
|
||||||
if tax.category in ("Total", "Valuation and Total") and flt(tax.tax_amount):
|
if tax.category in ("Total", "Valuation and Total") and flt(tax.base_tax_amount_after_discount_amount):
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": tax.account_head,
|
"account": tax.account_head,
|
||||||
"against": self.credit_to,
|
"against": self.credit_to,
|
||||||
"debit": tax.add_deduct_tax == "Add" and tax.tax_amount or 0,
|
"debit": tax.add_deduct_tax == "Add" and tax.base_tax_amount_after_discount_amount or 0,
|
||||||
"credit": tax.add_deduct_tax == "Deduct" and tax.tax_amount or 0,
|
"credit": tax.add_deduct_tax == "Deduct" and tax.base_tax_amount_after_discount_amount or 0,
|
||||||
"remarks": self.remarks,
|
"remarks": self.remarks,
|
||||||
"cost_center": tax.cost_center
|
"cost_center": tax.cost_center
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
# accumulate valuation tax
|
# accumulate valuation tax
|
||||||
if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount):
|
if tax.category in ("Valuation", "Valuation and Total") and flt(tax.base_tax_amount_after_discount_amount):
|
||||||
if auto_accounting_for_stock and not tax.cost_center:
|
if auto_accounting_for_stock and not tax.cost_center:
|
||||||
frappe.throw(_("Cost Center is required in row {0} in Taxes table for type {1}").format(tax.idx, _(tax.category)))
|
frappe.throw(_("Cost Center is required in row {0} in Taxes table for type {1}").format(tax.idx, _(tax.category)))
|
||||||
valuation_tax.setdefault(tax.cost_center, 0)
|
valuation_tax.setdefault(tax.cost_center, 0)
|
||||||
valuation_tax[tax.cost_center] += \
|
valuation_tax[tax.cost_center] += \
|
||||||
(tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount)
|
(tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.base_tax_amount_after_discount_amount)
|
||||||
|
|
||||||
# item gl entries
|
# item gl entries
|
||||||
negative_expense_to_be_booked = 0.0
|
negative_expense_to_be_booked = 0.0
|
||||||
stock_items = self.get_stock_items()
|
stock_items = self.get_stock_items()
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if flt(item.base_amount):
|
if flt(item.base_net_amount):
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": item.expense_account,
|
"account": item.expense_account,
|
||||||
"against": self.credit_to,
|
"against": self.credit_to,
|
||||||
"debit": item.base_amount,
|
"debit": item.base_net_amount,
|
||||||
"remarks": self.remarks,
|
"remarks": self.remarks,
|
||||||
"cost_center": item.cost_center
|
"cost_center": item.cost_center
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -194,6 +194,58 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_22",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_25",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "accounting",
|
"fieldname": "accounting",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
@@ -399,7 +451,7 @@
|
|||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-02-19 01:07:01.060411",
|
"modified": "2015-02-23 15:35:32.895515",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice Item",
|
"name": "Purchase Invoice Item",
|
||||||
|
|||||||
@@ -53,17 +53,13 @@
|
|||||||
"read_only": 0
|
"read_only": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "description",
|
"description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount",
|
||||||
"fieldtype": "Small Text",
|
"fieldname": "included_in_print_rate",
|
||||||
"in_list_view": 1,
|
"fieldtype": "Check",
|
||||||
"label": "Description",
|
"label": "Is this Tax included in Basic Rate?",
|
||||||
"oldfieldname": "description",
|
|
||||||
"oldfieldtype": "Small Text",
|
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_width": "300px",
|
"precision": "",
|
||||||
"read_only": 0,
|
"report_hide": 1
|
||||||
"reqd": 1,
|
|
||||||
"width": "300px"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "col_break1",
|
"fieldname": "col_break1",
|
||||||
@@ -94,6 +90,19 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 0
|
"read_only": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "description",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Description",
|
||||||
|
"oldfieldname": "description",
|
||||||
|
"oldfieldtype": "Small Text",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "300px",
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"width": "300px"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "rate",
|
"fieldname": "rate",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
@@ -105,6 +114,12 @@
|
|||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"reqd": 0
|
"reqd": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_9",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "tax_amount",
|
"fieldname": "tax_amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -112,19 +127,65 @@
|
|||||||
"label": "Amount",
|
"label": "Amount",
|
||||||
"oldfieldname": "tax_amount",
|
"oldfieldname": "tax_amount",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"options": "Company:company:default_currency",
|
"options": "currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"reqd": 0
|
"reqd": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "tax_amount_after_discount_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Tax Amount After Discount Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "total",
|
"fieldname": "total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Total",
|
"label": "Total",
|
||||||
"oldfieldname": "total",
|
"oldfieldname": "total",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_14",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_tax_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Amount (Company Currency)",
|
||||||
"options": "Company:company:default_currency",
|
"options": "Company:company:default_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Total (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_tax_amount_after_discount_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Tax Amount After Discount Amount",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -155,7 +216,7 @@
|
|||||||
"hide_heading": 1,
|
"hide_heading": 1,
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-02-19 01:07:01.581115",
|
"modified": "2015-02-23 15:01:31.895131",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Taxes and Charges",
|
"name": "Purchase Taxes and Charges",
|
||||||
|
|||||||
@@ -3,78 +3,7 @@
|
|||||||
|
|
||||||
{% include "public/js/controllers/accounts.js" %}
|
{% include "public/js/controllers/accounts.js" %}
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
frappe.ui.form.on("Purchase Taxes and Charges", "add_deduct_tax", function(doc, cdt, cdn) {
|
||||||
cur_frm.set_footnote(frappe.markdown(cur_frm.meta.description));
|
|
||||||
}
|
|
||||||
|
|
||||||
// For customizing print
|
|
||||||
cur_frm.pformat.net_total = function(doc) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.pformat.grand_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 = '<b>'; var bend = '</b>';
|
|
||||||
return '<tr><td style="width:50%;">' + (bold?bstart:'') + title + (bold?bend:'') + '</td>'
|
|
||||||
+ '<td style="width:25%;text-align:right;"></td>'
|
|
||||||
+ '<td style="width:25%;text-align:right;">' + format_currency(val, doc.currency) + '</td>'
|
|
||||||
+ '</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function convert_rate(val) {
|
|
||||||
var new_val = flt(val)/flt(doc.conversion_rate);
|
|
||||||
return new_val;
|
|
||||||
}
|
|
||||||
|
|
||||||
function print_hide(fieldname) {
|
|
||||||
var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name);
|
|
||||||
return doc_field.print_hide;
|
|
||||||
}
|
|
||||||
|
|
||||||
var cl = doc.taxes || [];
|
|
||||||
|
|
||||||
// outer table
|
|
||||||
var out='<div><table class="noborder" style="width:100%">\
|
|
||||||
<tr><td style="width: 60%"></td><td>';
|
|
||||||
|
|
||||||
// main table
|
|
||||||
out +='<table class="noborder" style="width:100%">';
|
|
||||||
if(!print_hide('net_total'))
|
|
||||||
out += make_row('Net Total', doc.net_total, 1);
|
|
||||||
|
|
||||||
// add rows
|
|
||||||
if(cl.length){
|
|
||||||
for(var i=0; i<cl.length; i++) {
|
|
||||||
out += make_row(cl[i].description, convert_rate(cl[i].tax_amount), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// grand total
|
|
||||||
if(!print_hide('grand_total'))
|
|
||||||
out += make_row('Grand Total', doc.grand_total, 1);
|
|
||||||
|
|
||||||
if(doc.in_words && !print_hide('in_words')) {
|
|
||||||
out += '</table></td></tr>';
|
|
||||||
out += '<tr><td colspan = "2">';
|
|
||||||
out += '<table><tr><td style="width:25%;"><b>In Words</b></td>';
|
|
||||||
out += '<td style="width:50%;">' + doc.in_words + '</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
out +='</table></td></tr></table></div>';
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.add_deduct_tax = function(doc, cdt, cdn) {
|
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
|
|
||||||
if(!d.category && d.add_deduct_tax) {
|
if(!d.category && d.add_deduct_tax) {
|
||||||
@@ -85,96 +14,5 @@ cur_frm.cscript.add_deduct_tax = function(doc, cdt, cdn) {
|
|||||||
msgprint(__("Cannot deduct when category is for 'Valuation' or 'Valuation and Total'"));
|
msgprint(__("Cannot deduct when category is for 'Valuation' or 'Valuation and Total'"));
|
||||||
d.add_deduct_tax = '';
|
d.add_deduct_tax = '';
|
||||||
}
|
}
|
||||||
}
|
refresh_field('add_deduct_tax', d.name, 'taxes');
|
||||||
|
|
||||||
cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
|
|
||||||
var d = locals[cdt][cdn];
|
|
||||||
|
|
||||||
if(!d.category && d.charge_type) {
|
|
||||||
msgprint(__("Please select Category first"));
|
|
||||||
d.charge_type = '';
|
|
||||||
}
|
|
||||||
else 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 = '';
|
|
||||||
}
|
|
||||||
else if((d.category == 'Valuation' || d.category == 'Valuation and Total') && (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 valuation. You can select only 'Total' option for previous row amount or previous row total"));
|
|
||||||
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');
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.set_query("account_head", "taxes", function(doc) {
|
|
||||||
return {
|
|
||||||
query: "erpnext.controllers.queries.tax_account_query",
|
|
||||||
filters: {
|
|
||||||
"account_type": ["Tax", "Chargeable", "Expense Account"],
|
|
||||||
"company": doc.company
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
cur_frm.fields_dict['taxes'].grid.get_field("cost_center").get_query = function(doc) {
|
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
'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');
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,8 +2,11 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from erpnext.controllers.accounts_controller import validate_taxes_and_charges, validate_inclusive_tax
|
||||||
|
|
||||||
class PurchaseTaxesandChargesMaster(Document):
|
class PurchaseTaxesandChargesMaster(Document):
|
||||||
pass
|
def validate(self):
|
||||||
|
for tax in self.get("taxes"):
|
||||||
|
validate_taxes_and_charges(tax)
|
||||||
|
validate_inclusive_tax(tax, self)
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
cur_frm.pformat.print_heading = 'Invoice';
|
cur_frm.pformat.print_heading = 'Invoice';
|
||||||
|
|
||||||
{% include 'selling/sales_common.js' %};
|
{% include 'selling/sales_common.js' %};
|
||||||
{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %}
|
|
||||||
|
|
||||||
frappe.provide("erpnext.accounts");
|
frappe.provide("erpnext.accounts");
|
||||||
erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({
|
erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({
|
||||||
|
|||||||
@@ -331,6 +331,16 @@
|
|||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_net_total",
|
"fieldname": "base_net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -348,6 +358,16 @@
|
|||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "net_total",
|
"fieldname": "net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -431,6 +451,12 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_47",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_total_taxes_and_charges",
|
"fieldname": "base_total_taxes_and_charges",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -443,7 +469,23 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_45",
|
"fieldname": "section_break_49",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Grand Total",
|
||||||
|
"fieldname": "apply_discount_on",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Apply Discount On",
|
||||||
|
"options": "\nGrand Total\nNet Total",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_51",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
@@ -1202,7 +1244,7 @@
|
|||||||
"icon": "icon-file-text",
|
"icon": "icon-file-text",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-02-20 05:16:19.256361",
|
"modified": "2015-02-23 15:53:37.894033",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice",
|
"name": "Sales Invoice",
|
||||||
|
|||||||
@@ -496,12 +496,12 @@ class SalesInvoice(SellingController):
|
|||||||
|
|
||||||
def make_tax_gl_entries(self, gl_entries):
|
def make_tax_gl_entries(self, gl_entries):
|
||||||
for tax in self.get("taxes"):
|
for tax in self.get("taxes"):
|
||||||
if flt(tax.tax_amount_after_discount_amount):
|
if flt(tax.base_tax_amount_after_discount_amount):
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": tax.account_head,
|
"account": tax.account_head,
|
||||||
"against": self.debit_to,
|
"against": self.debit_to,
|
||||||
"credit": flt(tax.tax_amount_after_discount_amount),
|
"credit": flt(tax.base_tax_amount_after_discount_amount),
|
||||||
"remarks": self.remarks,
|
"remarks": self.remarks,
|
||||||
"cost_center": tax.cost_center
|
"cost_center": tax.cost_center
|
||||||
})
|
})
|
||||||
@@ -510,12 +510,12 @@ class SalesInvoice(SellingController):
|
|||||||
def make_item_gl_entries(self, gl_entries):
|
def make_item_gl_entries(self, gl_entries):
|
||||||
# income account gl entries
|
# income account gl entries
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if flt(item.base_amount):
|
if flt(item.base_net_amount):
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": item.income_account,
|
"account": item.income_account,
|
||||||
"against": self.debit_to,
|
"against": self.debit_to,
|
||||||
"credit": item.base_amount,
|
"credit": item.base_net_amount,
|
||||||
"remarks": self.remarks,
|
"remarks": self.remarks,
|
||||||
"cost_center": item.cost_center
|
"cost_center": item.cost_center
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -201,6 +201,58 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_21",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_24",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "accounting",
|
"fieldname": "accounting",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
@@ -439,7 +491,7 @@
|
|||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-02-19 01:07:01.862525",
|
"modified": "2015-02-23 15:55:23.143072",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice Item",
|
"name": "Sales Invoice Item",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"autoname": "hash",
|
"autoname": "INVTD.######",
|
||||||
"creation": "2013-04-24 11:39:32",
|
"creation": "2013-04-24 11:39:32",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
@@ -25,24 +25,6 @@
|
|||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "description",
|
|
||||||
"fieldtype": "Small Text",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Description",
|
|
||||||
"oldfieldname": "description",
|
|
||||||
"oldfieldtype": "Small Text",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_width": "300px",
|
|
||||||
"reqd": 1,
|
|
||||||
"width": "300px"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "col_break_1",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"permlevel": 0,
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "account_head",
|
"fieldname": "account_head",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@@ -77,26 +59,22 @@
|
|||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "tax_amount",
|
"fieldname": "col_break_1",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Column Break",
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Amount",
|
|
||||||
"oldfieldname": "tax_amount",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1,
|
"width": "50%"
|
||||||
"reqd": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "total",
|
"fieldname": "description",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Small Text",
|
||||||
"label": "Total",
|
"in_list_view": 1,
|
||||||
"oldfieldname": "total",
|
"label": "Description",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldname": "description",
|
||||||
"options": "Company:company:default_currency",
|
"oldfieldtype": "Small Text",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"print_width": "300px",
|
||||||
|
"reqd": 1,
|
||||||
|
"width": "300px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@@ -112,11 +90,72 @@
|
|||||||
"width": "150px"
|
"width": "150px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:parent.discount_amount",
|
"fieldname": "section_break_9",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "tax_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
"fieldname": "tax_amount_after_discount_amount",
|
"fieldname": "tax_amount_after_discount_amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"hidden": 0,
|
|
||||||
"label": "Tax Amount After Discount Amount",
|
"label": "Tax Amount After Discount Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_13",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_tax_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Amount (Company Currency)",
|
||||||
|
"oldfieldname": "tax_amount",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"reqd": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total (Company Currency)",
|
||||||
|
"oldfieldname": "total",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:parent.discount_amount",
|
||||||
|
"fieldname": "base_tax_amount_after_discount_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Tax Amount After Discount Amount (Company Currency)",
|
||||||
"options": "Company:company:default_currency",
|
"options": "Company:company:default_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
@@ -147,7 +186,7 @@
|
|||||||
"hide_heading": 1,
|
"hide_heading": 1,
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-02-19 01:07:02.165094",
|
"modified": "2015-02-23 12:36:02.213508",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Taxes and Charges",
|
"name": "Sales Taxes and Charges",
|
||||||
|
|||||||
@@ -7,168 +7,3 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
|||||||
if(doc.doctype === "Sales Taxes and Charges Master")
|
if(doc.doctype === "Sales Taxes and Charges Master")
|
||||||
erpnext.add_applicable_territory();
|
erpnext.add_applicable_territory();
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|
||||||
cur_frm.set_footnote(frappe.markdown(cur_frm.meta.description));
|
|
||||||
}
|
|
||||||
|
|
||||||
// For customizing print
|
|
||||||
cur_frm.pformat.net_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 = '<b>'; var bend = '</b>';
|
|
||||||
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>'
|
|
||||||
+ '</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function convert_rate(val) {
|
|
||||||
var new_val = flt(val)/flt(doc.conversion_rate);
|
|
||||||
return new_val;
|
|
||||||
}
|
|
||||||
|
|
||||||
function print_hide(fieldname) {
|
|
||||||
var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name);
|
|
||||||
return doc_field.print_hide;
|
|
||||||
}
|
|
||||||
|
|
||||||
out ='';
|
|
||||||
if (!doc.print_without_amount) {
|
|
||||||
var cl = doc.taxes || [];
|
|
||||||
|
|
||||||
// outer table
|
|
||||||
var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>';
|
|
||||||
|
|
||||||
// main table
|
|
||||||
|
|
||||||
out +='<table class="noborder" style="width:100%">';
|
|
||||||
|
|
||||||
if(!print_hide('net_total')) {
|
|
||||||
out += make_row('Net Total', doc.net_total, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add rows
|
|
||||||
if(cl.length){
|
|
||||||
for(var i=0;i<cl.length;i++) {
|
|
||||||
if(convert_rate(cl[i].tax_amount)!=0 && !cl[i].included_in_print_rate)
|
|
||||||
out += make_row(cl[i].description, convert_rate(cl[i].tax_amount), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Discount Amount
|
|
||||||
if(!print_hide('discount_amount') && doc.discount_amount)
|
|
||||||
out += make_row('Discount Amount', doc.discount_amount, 0);
|
|
||||||
|
|
||||||
// grand total
|
|
||||||
if(!print_hide('grand_total'))
|
|
||||||
out += make_row('Grand Total', doc.grand_total, 1);
|
|
||||||
|
|
||||||
if(!print_hide('rounded_total'))
|
|
||||||
out += make_row('Rounded Total', doc.rounded_total, 1);
|
|
||||||
|
|
||||||
if(doc.in_words && !print_hide('in_words')) {
|
|
||||||
out +='</table></td></tr>';
|
|
||||||
out += '<tr><td colspan = "2">';
|
|
||||||
out += '<table><tr><td style="width:25%;"><b>In Words</b></td>';
|
|
||||||
out += '<td style="width:50%;">' + doc.in_words + '</td></tr>';
|
|
||||||
}
|
|
||||||
out += '</table></td></tr></table></div>';
|
|
||||||
}
|
|
||||||
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');
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cint
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from erpnext.controllers.accounts_controller import validate_taxes_and_charges, validate_inclusive_tax
|
||||||
|
|
||||||
class SalesTaxesandChargesMaster(Document):
|
class SalesTaxesandChargesMaster(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@@ -15,3 +15,8 @@ class SalesTaxesandChargesMaster(Document):
|
|||||||
|
|
||||||
# at least one territory
|
# at least one territory
|
||||||
self.validate_table_has_rows("territories")
|
self.validate_table_has_rows("territories")
|
||||||
|
|
||||||
|
for tax in self.get("taxes"):
|
||||||
|
validate_taxes_and_charges(tax)
|
||||||
|
validate_inclusive_tax(tax, self)
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class GrossProfitGenerator(object):
|
|||||||
if self.skip_row(row, self.sales_boms):
|
if self.skip_row(row, self.sales_boms):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
row.selling_amount = flt(row.base_amount)
|
row.selling_amount = flt(row.base_net_amount)
|
||||||
|
|
||||||
sales_boms = self.sales_boms.get(row.parenttype, {}).get(row.name, frappe._dict())
|
sales_boms = self.sales_boms.get(row.parenttype, {}).get(row.name, frappe._dict())
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ class GrossProfitGenerator(object):
|
|||||||
# sorted by posting_date desc, posting_time desc
|
# sorted by posting_date desc, posting_time desc
|
||||||
if item_code in self.non_stock_items:
|
if item_code in self.non_stock_items:
|
||||||
# average purchasing rate for non-stock items
|
# average purchasing rate for non-stock items
|
||||||
item_rate = frappe.db.sql("""select sum(base_amount) / sum(qty)
|
item_rate = frappe.db.sql("""select sum(base_net_amount) / sum(qty)
|
||||||
from `tabPurchase Invoice Item`
|
from `tabPurchase Invoice Item`
|
||||||
where item_code = %s and docstatus=1""", item_code)
|
where item_code = %s and docstatus=1""", item_code)
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ class GrossProfitGenerator(object):
|
|||||||
si.customer, si.customer_group, si.territory,
|
si.customer, si.customer_group, si.territory,
|
||||||
item.item_code, item.item_name, item.description, item.warehouse,
|
item.item_code, item.item_name, item.description, item.warehouse,
|
||||||
item.item_group, item.brand, item.dn_detail, item.delivery_note,
|
item.item_group, item.brand, item.dn_detail, item.delivery_note,
|
||||||
item.qty, item.base_rate, item.base_amount, item.name as "item_row",
|
item.qty, item.base_net_rate, item.base_net_amount, item.name as "item_row",
|
||||||
sales.sales_person, sales.sales_designation, sales.allocated_amount,
|
sales.sales_person, sales.sales_designation, sales.allocated_amount,
|
||||||
sales.incentives
|
sales.incentives
|
||||||
from `tabSales Invoice` si
|
from `tabSales Invoice` si
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ def execute(filters=None):
|
|||||||
expense_account = d.expense_account or aii_account_map.get(d.company)
|
expense_account = d.expense_account or aii_account_map.get(d.company)
|
||||||
row = [d.item_code, d.item_name, d.item_group, d.parent, d.posting_date, d.supplier,
|
row = [d.item_code, d.item_name, d.item_group, d.parent, d.posting_date, d.supplier,
|
||||||
d.supplier_name, d.credit_to, d.project_name, d.company, d.purchase_order,
|
d.supplier_name, d.credit_to, d.project_name, d.company, d.purchase_order,
|
||||||
purchase_receipt, expense_account, d.qty, d.base_rate, d.base_amount]
|
purchase_receipt, expense_account, d.qty, d.base_net_rate, d.base_net_amount]
|
||||||
|
|
||||||
for tax in tax_accounts:
|
for tax in tax_accounts:
|
||||||
row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0))
|
row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0))
|
||||||
|
|
||||||
total_tax = sum(row[last_col:])
|
total_tax = sum(row[last_col:])
|
||||||
row += [total_tax, d.base_amount + total_tax]
|
row += [total_tax, d.base_net_amount + total_tax]
|
||||||
|
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ def get_items(filters):
|
|||||||
return frappe.db.sql("""select pi_item.parent, pi.posting_date, pi.credit_to, pi.company,
|
return frappe.db.sql("""select pi_item.parent, pi.posting_date, pi.credit_to, pi.company,
|
||||||
pi.supplier, pi.remarks, pi.base_net_total, pi_item.item_code, pi_item.item_name, pi_item.item_group,
|
pi.supplier, pi.remarks, pi.base_net_total, pi_item.item_code, pi_item.item_name, pi_item.item_group,
|
||||||
pi_item.project_name, pi_item.purchase_order, pi_item.purchase_receipt, pi_item.po_detail
|
pi_item.project_name, pi_item.purchase_order, pi_item.purchase_receipt, pi_item.po_detail
|
||||||
pi_item.expense_account, pi_item.qty, pi_item.base_rate, pi_item.base_amount, pi.supplier_name
|
pi_item.expense_account, pi_item.qty, pi_item.base_net_rate, pi_item.base_net_amount, pi.supplier_name
|
||||||
from `tabPurchase Invoice` pi, `tabPurchase Invoice Item` pi_item
|
from `tabPurchase Invoice` pi, `tabPurchase Invoice Item` pi_item
|
||||||
where pi.name = pi_item.parent and pi.docstatus = 1 %s %s
|
where pi.name = pi_item.parent and pi.docstatus = 1 %s %s
|
||||||
order by pi.posting_date desc, pi_item.item_code desc""" % (conditions, match_conditions), filters, as_dict=1)
|
order by pi.posting_date desc, pi_item.item_code desc""" % (conditions, match_conditions), filters, as_dict=1)
|
||||||
@@ -86,7 +86,7 @@ def get_tax_accounts(item_list, columns):
|
|||||||
for d in item_list:
|
for d in item_list:
|
||||||
invoice_wise_items.setdefault(d.parent, []).append(d)
|
invoice_wise_items.setdefault(d.parent, []).append(d)
|
||||||
|
|
||||||
tax_details = frappe.db.sql("""select parent, account_head, item_wise_tax_detail, charge_type, tax_amount
|
tax_details = frappe.db.sql("""select parent, account_head, item_wise_tax_detail, charge_type, base_tax_amount_after_discount_amount
|
||||||
from `tabPurchase Taxes and Charges` where parenttype = 'Purchase Invoice'
|
from `tabPurchase Taxes and Charges` where parenttype = 'Purchase Invoice'
|
||||||
and docstatus = 1 and ifnull(account_head, '') != '' and category in ('Total', 'Valuation and Total')
|
and docstatus = 1 and ifnull(account_head, '') != '' and category in ('Total', 'Valuation and Total')
|
||||||
and parent in (%s)""" % ', '.join(['%s']*len(invoice_wise_items)), tuple(invoice_wise_items.keys()))
|
and parent in (%s)""" % ', '.join(['%s']*len(invoice_wise_items)), tuple(invoice_wise_items.keys()))
|
||||||
@@ -107,7 +107,7 @@ def get_tax_accounts(item_list, columns):
|
|||||||
elif charge_type == "Actual" and tax_amount:
|
elif charge_type == "Actual" and tax_amount:
|
||||||
for d in invoice_wise_items.get(parent, []):
|
for d in invoice_wise_items.get(parent, []):
|
||||||
item_tax.setdefault(parent, {}).setdefault(d.item_code, {})[account_head] = \
|
item_tax.setdefault(parent, {}).setdefault(d.item_code, {})[account_head] = \
|
||||||
(tax_amount * d.base_amount) / d.base_net_total
|
(tax_amount * d.base_net_amount) / d.base_net_total
|
||||||
|
|
||||||
tax_accounts.sort()
|
tax_accounts.sort()
|
||||||
columns += [account_head + ":Currency:80" for account_head in tax_accounts]
|
columns += [account_head + ":Currency:80" for account_head in tax_accounts]
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ def execute(filters=None):
|
|||||||
|
|
||||||
row = [d.item_code, d.item_name, d.item_group, d.parent, d.posting_date, d.customer, d.customer_name,
|
row = [d.item_code, d.item_name, d.item_group, d.parent, d.posting_date, d.customer, d.customer_name,
|
||||||
d.customer_group, d.debit_to, d.territory, d.project_name, d.company, d.sales_order,
|
d.customer_group, d.debit_to, d.territory, d.project_name, d.company, d.sales_order,
|
||||||
delivery_note, d.income_account, d.qty, d.base_rate, d.base_amount]
|
delivery_note, d.income_account, d.qty, d.base_net_rate, d.base_net_amount]
|
||||||
|
|
||||||
for tax in tax_accounts:
|
for tax in tax_accounts:
|
||||||
row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0))
|
row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0))
|
||||||
|
|
||||||
total_tax = sum(row[last_col:])
|
total_tax = sum(row[last_col:])
|
||||||
row += [total_tax, d.base_amount + total_tax]
|
row += [total_tax, d.base_net_amount + total_tax]
|
||||||
|
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ def get_items(filters):
|
|||||||
return frappe.db.sql("""select si_item.parent, si.posting_date, si.debit_to, si.project_name,
|
return frappe.db.sql("""select si_item.parent, si.posting_date, si.debit_to, si.project_name,
|
||||||
si.customer, si.remarks, si.territory, si.company, si.base_net_total, si_item.item_code, si_item.item_name,
|
si.customer, si.remarks, si.territory, si.company, si.base_net_total, si_item.item_code, si_item.item_name,
|
||||||
si_item.item_group, si_item.sales_order, si_item.delivery_note, si_item.income_account,
|
si_item.item_group, si_item.sales_order, si_item.delivery_note, si_item.income_account,
|
||||||
si_item.qty, si_item.base_rate, si_item.base_amount, si.customer_name,
|
si_item.qty, si_item.base_net_rate, si_item.base_net_amount, si.customer_name,
|
||||||
si.customer_group, si_item.so_detail
|
si.customer_group, si_item.so_detail
|
||||||
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
|
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
|
||||||
where si.name = si_item.parent and si.docstatus = 1 %s
|
where si.name = si_item.parent and si.docstatus = 1 %s
|
||||||
@@ -83,7 +83,8 @@ def get_tax_accounts(item_list, columns):
|
|||||||
for d in item_list:
|
for d in item_list:
|
||||||
invoice_wise_items.setdefault(d.parent, []).append(d)
|
invoice_wise_items.setdefault(d.parent, []).append(d)
|
||||||
|
|
||||||
tax_details = frappe.db.sql("""select parent, account_head, item_wise_tax_detail, charge_type, tax_amount
|
tax_details = frappe.db.sql("""select parent, account_head, item_wise_tax_detail,
|
||||||
|
charge_type, base_tax_amount_after_discount_amount
|
||||||
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
|
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
|
||||||
and docstatus = 1 and ifnull(account_head, '') != ''
|
and docstatus = 1 and ifnull(account_head, '') != ''
|
||||||
and parent in (%s)""" % ', '.join(['%s']*len(invoice_wise_items)),
|
and parent in (%s)""" % ', '.join(['%s']*len(invoice_wise_items)),
|
||||||
@@ -104,7 +105,7 @@ def get_tax_accounts(item_list, columns):
|
|||||||
elif charge_type == "Actual" and tax_amount:
|
elif charge_type == "Actual" and tax_amount:
|
||||||
for d in invoice_wise_items.get(parent, []):
|
for d in invoice_wise_items.get(parent, []):
|
||||||
item_tax.setdefault(parent, {}).setdefault(d.item_code, {})[account_head] = \
|
item_tax.setdefault(parent, {}).setdefault(d.item_code, {})[account_head] = \
|
||||||
flt((tax_amount * d.base_amount) / d.base_net_total)
|
flt((tax_amount * d.base_net_amount) / d.base_net_total)
|
||||||
|
|
||||||
tax_accounts.sort()
|
tax_accounts.sort()
|
||||||
columns += [account_head + ":Currency:80" for account_head in tax_accounts]
|
columns += [account_head + ":Currency:80" for account_head in tax_accounts]
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ def get_invoices(filters):
|
|||||||
|
|
||||||
|
|
||||||
def get_invoice_expense_map(invoice_list):
|
def get_invoice_expense_map(invoice_list):
|
||||||
expense_details = frappe.db.sql("""select parent, expense_account, sum(base_amount) as amount
|
expense_details = frappe.db.sql("""select parent, expense_account, sum(base_net_amount) as amount
|
||||||
from `tabPurchase Invoice Item` where parent in (%s) group by parent, expense_account""" %
|
from `tabPurchase Invoice Item` where parent in (%s) group by parent, expense_account""" %
|
||||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ def get_invoice_expense_map(invoice_list):
|
|||||||
return invoice_expense_map
|
return invoice_expense_map
|
||||||
|
|
||||||
def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts):
|
def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts):
|
||||||
tax_details = frappe.db.sql("""select parent, account_head, sum(tax_amount) as tax_amount
|
tax_details = frappe.db.sql("""select parent, account_head, sum(base_tax_amount_after_discount_amount) as tax_amount
|
||||||
from `tabPurchase Taxes and Charges` where parent in (%s) group by parent, account_head""" %
|
from `tabPurchase Taxes and Charges` where parent in (%s) group by parent, account_head""" %
|
||||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ def get_columns(invoice_list):
|
|||||||
|
|
||||||
tax_accounts = frappe.db.sql_list("""select distinct account_head
|
tax_accounts = frappe.db.sql_list("""select distinct account_head
|
||||||
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
|
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
|
||||||
and docstatus = 1 and ifnull(tax_amount_after_discount_amount, 0) != 0
|
and docstatus = 1 and ifnull(base_tax_amount_after_discount_amount, 0) != 0
|
||||||
and parent in (%s) order by account_head""" %
|
and parent in (%s) order by account_head""" %
|
||||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ def get_invoices(filters):
|
|||||||
conditions, filters, as_dict=1)
|
conditions, filters, as_dict=1)
|
||||||
|
|
||||||
def get_invoice_income_map(invoice_list):
|
def get_invoice_income_map(invoice_list):
|
||||||
income_details = frappe.db.sql("""select parent, income_account, sum(base_amount) as amount
|
income_details = frappe.db.sql("""select parent, income_account, sum(base_net_amount) as amount
|
||||||
from `tabSales Invoice Item` where parent in (%s) group by parent, income_account""" %
|
from `tabSales Invoice Item` where parent in (%s) group by parent, income_account""" %
|
||||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ def get_invoice_income_map(invoice_list):
|
|||||||
|
|
||||||
def get_invoice_tax_map(invoice_list, invoice_income_map, income_accounts):
|
def get_invoice_tax_map(invoice_list, invoice_income_map, income_accounts):
|
||||||
tax_details = frappe.db.sql("""select parent, account_head,
|
tax_details = frappe.db.sql("""select parent, account_head,
|
||||||
sum(tax_amount_after_discount_amount) as tax_amount
|
sum(base_tax_amount_after_discount_amount) as tax_amount
|
||||||
from `tabSales Taxes and Charges` where parent in (%s) group by parent, account_head""" %
|
from `tabSales Taxes and Charges` where parent in (%s) group by parent, account_head""" %
|
||||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.provide("erpnext.buying");
|
frappe.provide("erpnext.buying");
|
||||||
frappe.require("assets/erpnext/js/controllers/transaction.js");
|
|
||||||
|
|
||||||
{% include "public/js/controllers/accounts.js" %};
|
cur_frm.cscript.tax_table = "Purchase Taxes and Charges";
|
||||||
|
{% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %}
|
||||||
|
|
||||||
|
frappe.require("assets/erpnext/js/controllers/transaction.js");
|
||||||
|
|
||||||
cur_frm.email_field = "contact_email";
|
cur_frm.email_field = "contact_email";
|
||||||
|
|
||||||
@@ -90,20 +92,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
this.price_list_rate(doc, cdt, cdn);
|
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) {
|
uom: function(doc, cdt, cdn) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var item = frappe.get_doc(cdt, cdn);
|
var item = frappe.get_doc(cdt, cdn);
|
||||||
@@ -180,97 +168,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
this.frm.doc.outstanding_amount = flt(this.frm.doc.total_amount_to_pay - this.frm.doc.total_advance,
|
this.frm.doc.outstanding_amount = flt(this.frm.doc.total_amount_to_pay - this.frm.doc.total_advance,
|
||||||
precision("outstanding_amount"));
|
precision("outstanding_amount"));
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
change_form_labels: function(company_currency) {
|
|
||||||
var me = this;
|
|
||||||
var field_label_map = {};
|
|
||||||
|
|
||||||
var setup_field_label_map = function(fields_list, currency) {
|
|
||||||
$.each(fields_list, function(i, fname) {
|
|
||||||
var docfield = frappe.meta.docfield_map[me.frm.doc.doctype][fname];
|
|
||||||
if(docfield) {
|
|
||||||
var label = __(docfield.label || "").replace(/\([^\)]*\)/g, "");
|
|
||||||
field_label_map[fname] = label.trim() + " (" + currency + ")";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
setup_field_label_map(["base_net_total", "base_total_taxes_and_charges", "base_grand_total", "base_in_words",
|
|
||||||
"base_taxes_and_charges_added", "base_taxes_and_charges_deducted",
|
|
||||||
"outstanding_amount", "total_advance", "total_amount_to_pay", "base_rounded_total"],
|
|
||||||
company_currency);
|
|
||||||
|
|
||||||
setup_field_label_map(["net_total", "grand_total", "in_words",
|
|
||||||
"taxes_and_charges_added", "taxes_and_charges_deducted"], this.frm.doc.currency);
|
|
||||||
|
|
||||||
cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency
|
|
||||||
+ " = [?] " + company_currency);
|
|
||||||
|
|
||||||
if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) {
|
|
||||||
cur_frm.set_df_property("plc_conversion_rate", "description", "1 " + this.frm.doc.price_list_currency
|
|
||||||
+ " = [?] " + company_currency);
|
|
||||||
}
|
|
||||||
|
|
||||||
// toggle fields
|
|
||||||
this.frm.toggle_display(["conversion_rate", "base_net_total", "base_grand_total",
|
|
||||||
"base_in_words", "base_taxes_and_charges_added", "base_taxes_and_charges_deducted"],
|
|
||||||
this.frm.doc.currency !== company_currency);
|
|
||||||
|
|
||||||
this.frm.toggle_display(["plc_conversion_rate", "price_list_currency"],
|
|
||||||
this.frm.doc.price_list_currency !== company_currency);
|
|
||||||
|
|
||||||
// set labels
|
|
||||||
$.each(field_label_map, function(fname, label) {
|
|
||||||
me.frm.fields_dict[fname].set_label(label);
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
change_grid_labels: function(company_currency) {
|
|
||||||
var me = this;
|
|
||||||
var field_label_map = {};
|
|
||||||
|
|
||||||
var setup_field_label_map = function(fields_list, currency, parentfield) {
|
|
||||||
var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype;
|
|
||||||
$.each(fields_list, function(i, fname) {
|
|
||||||
var docfield = frappe.meta.docfield_map[grid_doctype][fname];
|
|
||||||
if(docfield) {
|
|
||||||
var label = __(docfield.label || "").replace(/\([^\)]*\)/g, "");
|
|
||||||
field_label_map[grid_doctype + "-" + fname] =
|
|
||||||
label.trim() + " (" + currency + ")";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
setup_field_label_map(["base_rate", "base_price_list_rate", "base_amount", "base_rate"],
|
|
||||||
company_currency, "items");
|
|
||||||
|
|
||||||
setup_field_label_map(["rate", "price_list_rate", "amount"], this.frm.doc.currency, "items");
|
|
||||||
|
|
||||||
if(this.frm.fields_dict["taxes"]) {
|
|
||||||
setup_field_label_map(["tax_amount", "total"], company_currency, "taxes");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.frm.fields_dict["advances"]) {
|
|
||||||
setup_field_label_map(["advance_amount", "allocated_amount"], company_currency,
|
|
||||||
"advances");
|
|
||||||
}
|
|
||||||
|
|
||||||
// toggle columns
|
|
||||||
var item_grid = this.frm.fields_dict["items"].grid;
|
|
||||||
var fieldnames = $.map(["base_rate", "base_price_list_rate", "base_amount", "base_rate"], function(fname) {
|
|
||||||
return frappe.meta.get_docfield(item_grid.doctype, fname, me.frm.docname) ? fname : null;
|
|
||||||
});
|
|
||||||
|
|
||||||
item_grid.set_column_disp(fieldnames, this.frm.doc.currency != company_currency);
|
|
||||||
|
|
||||||
// set labels
|
|
||||||
var $wrapper = $(this.frm.wrapper);
|
|
||||||
$.each(field_label_map, function(fname, label) {
|
|
||||||
$wrapper.find('[data-grid-fieldname="'+fname+'"]').text(label);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cur_frm.add_fetch('project_name', 'cost_center', 'cost_center');
|
cur_frm.add_fetch('project_name', 'cost_center', 'cost_center');
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
frappe.provide("erpnext.buying");
|
frappe.provide("erpnext.buying");
|
||||||
|
|
||||||
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
||||||
{% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %}
|
|
||||||
|
|
||||||
erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({
|
erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({
|
||||||
refresh: function(doc, cdt, cdn) {
|
refresh: function(doc, cdt, cdn) {
|
||||||
|
|||||||
@@ -224,11 +224,29 @@
|
|||||||
"options": "Purchase Order Item",
|
"options": "Purchase Order Item",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "get_last_purchase_rate",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"label": "Get Last Purchase Rate",
|
||||||
|
"oldfieldtype": "Button",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "sb_last_purchase",
|
"fieldname": "sb_last_purchase",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_net_total",
|
"fieldname": "base_net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -247,6 +265,16 @@
|
|||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "net_total",
|
"fieldname": "net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -259,14 +287,6 @@
|
|||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "get_last_purchase_rate",
|
|
||||||
"fieldtype": "Button",
|
|
||||||
"label": "Get Last Purchase Rate",
|
|
||||||
"oldfieldtype": "Button",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "taxes_section",
|
"fieldname": "taxes_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
@@ -351,6 +371,93 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_39",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "taxes_and_charges_added",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Taxes and Charges Added",
|
||||||
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "other_charges_added_import",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1,
|
||||||
|
"report_hide": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "taxes_and_charges_deducted",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Taxes and Charges Deducted",
|
||||||
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "other_charges_deducted_import",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1,
|
||||||
|
"report_hide": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_taxes_and_charges",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total Taxes and Charges",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "discount_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Grand Total",
|
||||||
|
"fieldname": "apply_discount_on",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Apply Discount On",
|
||||||
|
"options": "\nGrand Total\nNet Total",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_45",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "discount_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Discount Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_discount_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Discount Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "totals_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_grand_total",
|
"fieldname": "base_grand_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -400,40 +507,6 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0
|
"print_hide": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "taxes_and_charges_added",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Taxes and Charges Added",
|
|
||||||
"no_copy": 0,
|
|
||||||
"oldfieldname": "other_charges_added_import",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1,
|
|
||||||
"report_hide": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "taxes_and_charges_deducted",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Taxes and Charges Deducted",
|
|
||||||
"no_copy": 0,
|
|
||||||
"oldfieldname": "other_charges_deducted_import",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1,
|
|
||||||
"report_hide": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "total_taxes_and_charges",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Total Taxes and Charges",
|
|
||||||
"options": "currency",
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": ""
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "grand_total",
|
"fieldname": "grand_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -783,7 +856,7 @@
|
|||||||
"icon": "icon-file-text",
|
"icon": "icon-file-text",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-02-20 05:16:19.990723",
|
"modified": "2015-02-23 15:10:05.156787",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order",
|
"name": "Purchase Order",
|
||||||
|
|||||||
@@ -281,6 +281,58 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_29",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_32",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "warehouse_and_reference",
|
"fieldname": "warehouse_and_reference",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
@@ -484,7 +536,7 @@
|
|||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-02-19 01:07:01.224244",
|
"modified": "2015-02-23 12:21:53.399279",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order Item",
|
"name": "Purchase Order Item",
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
// attach required files
|
// attach required files
|
||||||
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
||||||
{% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %}
|
|
||||||
|
|
||||||
erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({
|
erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
|
|||||||
@@ -228,6 +228,16 @@
|
|||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_net_total",
|
"fieldname": "base_net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -246,6 +256,16 @@
|
|||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "net_total",
|
"fieldname": "net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -342,45 +362,10 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_grand_total",
|
"fieldname": "column_break_37",
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Grand Total (Company Currency)",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "grand_total",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "base_rounded_total",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Rounded Total (Company Currency)",
|
|
||||||
"oldfieldname": "rounded_total",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "In Words will be visible once you save the Purchase Order.",
|
|
||||||
"fieldname": "base_in_words",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "In Words (Company Currency)",
|
|
||||||
"oldfieldname": "in_words",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "column_break4",
|
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"oldfieldtype": "Column Break",
|
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0
|
"precision": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "taxes_and_charges_added",
|
"fieldname": "taxes_and_charges_added",
|
||||||
@@ -414,8 +399,97 @@
|
|||||||
"label": "Total Taxes and Charges",
|
"label": "Total Taxes and Charges",
|
||||||
"options": "currency",
|
"options": "currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_41",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
"precision": ""
|
"precision": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"default": "Grand Total",
|
||||||
|
"fieldname": "apply_discount_on",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Apply Discount On",
|
||||||
|
"options": "\nGrand Total\nNet Total",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_43",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "discount_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Discount Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_discount_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Discount Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_46",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_grand_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Grand Total (Company Currency)",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "grand_total",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "In Words will be visible once you save the Purchase Order.",
|
||||||
|
"fieldname": "base_in_words",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "In Words (Company Currency)",
|
||||||
|
"oldfieldname": "in_words",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_rounded_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Rounded Total (Company Currency)",
|
||||||
|
"oldfieldname": "rounded_total",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break4",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"oldfieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "grand_total",
|
"fieldname": "grand_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -583,7 +657,7 @@
|
|||||||
"icon": "icon-shopping-cart",
|
"icon": "icon-shopping-cart",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-02-20 05:16:21.307774",
|
"modified": "2015-02-23 15:24:02.428061",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Supplier Quotation",
|
"name": "Supplier Quotation",
|
||||||
@@ -673,7 +747,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"read_only_onload": 1,
|
"read_only_onload": 1,
|
||||||
"search_fields": "status, transaction_date, supplier,base_grand_total",
|
"search_fields": "status, transaction_date, supplier,grand_total",
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"title_field": "supplier_name"
|
"title_field": "supplier_name"
|
||||||
|
|||||||
@@ -225,6 +225,57 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_24",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_27",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "warehouse_and_reference",
|
"fieldname": "warehouse_and_reference",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
@@ -360,7 +411,7 @@
|
|||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-02-19 01:07:02.403267",
|
"modified": "2015-02-23 15:28:03.712608",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Supplier Quotation Item",
|
"name": "Supplier Quotation Item",
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({
|
|||||||
if (posting_date >= from_date && posting_date <= to_date) {
|
if (posting_date >= from_date && posting_date <= to_date) {
|
||||||
var item = me.item_by_name[tl[me.tree_grid.item_key]] ||
|
var item = me.item_by_name[tl[me.tree_grid.item_key]] ||
|
||||||
me.item_by_name['Not Set'];
|
me.item_by_name['Not Set'];
|
||||||
item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_amount : tl.qty);
|
item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_net_amount : tl.qty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, throw
|
from frappe import _, throw
|
||||||
from frappe.utils import today, flt
|
from frappe.utils import today, flt, cint
|
||||||
from erpnext.setup.utils import get_company_currency, get_exchange_rate
|
from erpnext.setup.utils import get_company_currency, get_exchange_rate
|
||||||
from erpnext.accounts.utils import get_fiscal_year, validate_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year, validate_fiscal_year
|
||||||
from erpnext.utilities.transaction_base import TransactionBase
|
from erpnext.utilities.transaction_base import TransactionBase
|
||||||
@@ -357,3 +357,32 @@ def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, c
|
|||||||
if not conversion_rate:
|
if not conversion_rate:
|
||||||
throw(_("{0} is mandatory. Maybe Currency Exchange record is not created for {1} to {2}.").format(
|
throw(_("{0} is mandatory. Maybe Currency Exchange record is not created for {1} to {2}.").format(
|
||||||
conversion_rate_label, currency, company_currency))
|
conversion_rate_label, currency, company_currency))
|
||||||
|
|
||||||
|
def validate_taxes_and_charges(tax):
|
||||||
|
if tax.charge_type in ['Actual', 'On Net Total'] and tax.row_id:
|
||||||
|
frappe.throw(_("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'"))
|
||||||
|
elif tax.charge_type in ['On Previous Row Amount', 'On Previous Row Total']:
|
||||||
|
if cint(tax.idx) == 1:
|
||||||
|
frappe.throw(_("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"))
|
||||||
|
elif not tax.row_id:
|
||||||
|
frappe.throw(_("Please specify a valid Row ID for row {0} in table {1}".format(tax.idx, _(tax.doctype))))
|
||||||
|
elif tax.row_id and cint(tax.row_id) >= cint(tax.idx):
|
||||||
|
frappe.throw(_("Cannot refer row number greater than or equal to current row number for this Charge type"))
|
||||||
|
|
||||||
|
def validate_inclusive_tax(tax, doc):
|
||||||
|
def _on_previous_row_error(row_range):
|
||||||
|
throw(_("To include tax in row {0} in Item rate, taxes in rows {1} must also be included").format(tax.idx,
|
||||||
|
row_range))
|
||||||
|
|
||||||
|
if cint(getattr(tax, "included_in_print_rate", None)):
|
||||||
|
if tax.charge_type == "Actual":
|
||||||
|
# inclusive tax cannot be of type Actual
|
||||||
|
throw(_("Charge of type 'Actual' in row {0} cannot be included in Item Rate").format(tax.idx))
|
||||||
|
elif tax.charge_type == "On Previous Row Amount" and \
|
||||||
|
not cint(doc.get("taxes")[cint(tax.row_id) - 1].included_in_print_rate):
|
||||||
|
# referred row should also be inclusive
|
||||||
|
_on_previous_row_error(tax.row_id)
|
||||||
|
elif tax.charge_type == "On Previous Row Total" and \
|
||||||
|
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
|
||||||
|
_on_previous_row_error("1 - %d" % (tax.row_id,))
|
||||||
|
|||||||
@@ -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"
|
||||||
}
|
}
|
||||||
@@ -94,16 +94,16 @@ class BuyingController(StockController):
|
|||||||
for d in self.get(parentfield):
|
for d in self.get(parentfield):
|
||||||
if d.item_code and d.item_code in stock_items:
|
if d.item_code and d.item_code in stock_items:
|
||||||
stock_items_qty += flt(d.qty)
|
stock_items_qty += flt(d.qty)
|
||||||
stock_items_amount += flt(d.base_amount)
|
stock_items_amount += flt(d.base_net_amount)
|
||||||
last_stock_item_idx = d.idx
|
last_stock_item_idx = d.idx
|
||||||
|
|
||||||
total_valuation_amount = sum([flt(d.tax_amount) for d in self.get("taxes")
|
total_valuation_amount = sum([flt(d.base_tax_amount_after_discount_amount) for d in self.get("taxes")
|
||||||
if d.category in ["Valuation", "Valuation and Total"]])
|
if d.category in ["Valuation", "Valuation and Total"]])
|
||||||
|
|
||||||
valuation_amount_adjustment = total_valuation_amount
|
valuation_amount_adjustment = total_valuation_amount
|
||||||
for i, item in enumerate(self.get(parentfield)):
|
for i, item in enumerate(self.get(parentfield)):
|
||||||
if item.item_code and item.qty and item.item_code in stock_items:
|
if item.item_code and item.qty and item.item_code in stock_items:
|
||||||
item_proportion = flt(item.base_amount) / stock_items_amount if stock_items_amount \
|
item_proportion = flt(item.base_net_amount) / stock_items_amount if stock_items_amount \
|
||||||
else flt(item.qty) / stock_items_qty
|
else flt(item.qty) / stock_items_qty
|
||||||
|
|
||||||
if i == (last_stock_item_idx - 1):
|
if i == (last_stock_item_idx - 1):
|
||||||
@@ -124,7 +124,7 @@ class BuyingController(StockController):
|
|||||||
landed_cost_voucher_amount = flt(item.landed_cost_voucher_amount) \
|
landed_cost_voucher_amount = flt(item.landed_cost_voucher_amount) \
|
||||||
if self.doctype == "Purchase Receipt" else 0.0
|
if self.doctype == "Purchase Receipt" else 0.0
|
||||||
|
|
||||||
item.valuation_rate = ((item.base_amount + item.item_tax_amount + rm_supp_cost
|
item.valuation_rate = ((item.base_net_amount + item.item_tax_amount + rm_supp_cost
|
||||||
+ landed_cost_voucher_amount) / qty_in_stock_uom)
|
+ landed_cost_voucher_amount) / qty_in_stock_uom)
|
||||||
else:
|
else:
|
||||||
item.valuation_rate = 0.0
|
item.valuation_rate = 0.0
|
||||||
|
|||||||
@@ -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"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,16 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import json
|
import json
|
||||||
from frappe import _, throw
|
import frappe
|
||||||
|
from frappe import _
|
||||||
from frappe.utils import cint, flt, rounded
|
from frappe.utils import cint, flt, rounded
|
||||||
from erpnext.setup.utils import get_company_currency
|
from erpnext.setup.utils import get_company_currency
|
||||||
from erpnext.controllers.accounts_controller import validate_conversion_rate
|
from erpnext.controllers.accounts_controller import validate_conversion_rate, \
|
||||||
|
validate_taxes_and_charges, validate_inclusive_tax
|
||||||
|
|
||||||
class calculate_taxes_and_totals(object):
|
class calculate_taxes_and_totals(object):
|
||||||
def __init__(self, doc):
|
def __init__(self, doc):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
|
|
||||||
self.calculate()
|
self.calculate()
|
||||||
|
|
||||||
def calculate(self):
|
def calculate(self):
|
||||||
@@ -25,6 +26,15 @@ class calculate_taxes_and_totals(object):
|
|||||||
self.calculate_total_advance()
|
self.calculate_total_advance()
|
||||||
|
|
||||||
def _calculate(self):
|
def _calculate(self):
|
||||||
|
self.calculate_item_values()
|
||||||
|
self.initialize_taxes()
|
||||||
|
self.determine_exclusive_rate()
|
||||||
|
self.calculate_net_total()
|
||||||
|
self.calculate_taxes()
|
||||||
|
self.calculate_totals()
|
||||||
|
self._cleanup()
|
||||||
|
|
||||||
|
def validate_conversion_rate(self):
|
||||||
# validate conversion rate
|
# validate conversion rate
|
||||||
company_currency = get_company_currency(self.doc.company)
|
company_currency = get_company_currency(self.doc.company)
|
||||||
if not self.doc.currency or self.doc.currency == company_currency:
|
if not self.doc.currency or self.doc.currency == company_currency:
|
||||||
@@ -36,17 +46,6 @@ class calculate_taxes_and_totals(object):
|
|||||||
|
|
||||||
self.doc.conversion_rate = flt(self.doc.conversion_rate)
|
self.doc.conversion_rate = flt(self.doc.conversion_rate)
|
||||||
|
|
||||||
self.calculate_item_values()
|
|
||||||
self.initialize_taxes()
|
|
||||||
|
|
||||||
if self.doc.doctype in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
|
|
||||||
self.determine_exclusive_rate()
|
|
||||||
|
|
||||||
self.calculate_net_total()
|
|
||||||
self.calculate_taxes()
|
|
||||||
self.calculate_totals()
|
|
||||||
self._cleanup()
|
|
||||||
|
|
||||||
def calculate_item_values(self):
|
def calculate_item_values(self):
|
||||||
if not self.discount_amount_applied:
|
if not self.discount_amount_applied:
|
||||||
for item in self.doc.get("items"):
|
for item in self.doc.get("items"):
|
||||||
@@ -55,69 +54,44 @@ class calculate_taxes_and_totals(object):
|
|||||||
if item.discount_percentage == 100:
|
if item.discount_percentage == 100:
|
||||||
item.rate = 0.0
|
item.rate = 0.0
|
||||||
elif not item.rate:
|
elif not item.rate:
|
||||||
item.rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)),
|
item.rate = flt(item.price_list_rate *
|
||||||
self.doc.precision("rate", item))
|
(1.0 - (item.discount_percentage / 100.0)), item.precision("rate"))
|
||||||
|
|
||||||
item.amount = flt(item.rate * item.qty, self.doc.precision("amount", item))
|
item.net_rate = item.rate
|
||||||
item.item_tax_amount = 0.0;
|
item.amount = flt(item.rate * item.qty, item.precision("amount"))
|
||||||
|
item.net_amount = item.amount
|
||||||
|
|
||||||
self._set_in_company_currency(item, "price_list_rate", "base_price_list_rate")
|
self._set_in_company_currency(item, ["price_list_rate", "rate", "net_rate", "amount", "net_amount"])
|
||||||
self._set_in_company_currency(item, "rate", "base_rate")
|
|
||||||
self._set_in_company_currency(item, "amount", "base_amount")
|
|
||||||
|
|
||||||
def _set_in_company_currency(self, item, print_field, base_field):
|
item.item_tax_amount = 0.0
|
||||||
|
|
||||||
|
def _set_in_company_currency(self, doc, fields):
|
||||||
"""set values in base currency"""
|
"""set values in base currency"""
|
||||||
value_in_company_currency = flt(self.doc.conversion_rate *
|
for f in fields:
|
||||||
flt(item.get(print_field), self.doc.precision(print_field, item)), self.doc.precision(base_field, item))
|
val = flt(flt(doc.get(f), doc.precision(f)) * self.doc.conversion_rate, doc.precision("base_" + f))
|
||||||
item.set(base_field, value_in_company_currency)
|
doc.set("base_" + f, val)
|
||||||
|
|
||||||
def initialize_taxes(self):
|
def initialize_taxes(self):
|
||||||
for tax in self.doc.get("taxes"):
|
for tax in self.doc.get("taxes"):
|
||||||
|
validate_taxes_and_charges(tax)
|
||||||
|
validate_inclusive_tax(tax, self.doc)
|
||||||
|
|
||||||
tax.item_wise_tax_detail = {}
|
tax.item_wise_tax_detail = {}
|
||||||
tax_fields = ["total", "tax_amount_after_discount_amount",
|
tax_fields = ["total", "tax_amount_after_discount_amount",
|
||||||
"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 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)
|
||||||
|
|
||||||
self.validate_on_previous_row(tax)
|
|
||||||
self.validate_inclusive_tax(tax)
|
|
||||||
self.doc.round_floats_in(tax)
|
self.doc.round_floats_in(tax)
|
||||||
|
|
||||||
def validate_on_previous_row(self, tax):
|
|
||||||
"""
|
|
||||||
validate if a valid row id is mentioned in case of
|
|
||||||
On Previous Row Amount and On Previous Row Total
|
|
||||||
"""
|
|
||||||
if tax.charge_type in ["On Previous Row Amount", "On Previous Row Total"] and \
|
|
||||||
(not tax.row_id or cint(tax.row_id) >= tax.idx):
|
|
||||||
throw(_("Please specify a valid Row ID for {0} in row {1}").format(_(tax.doctype), tax.idx))
|
|
||||||
|
|
||||||
def validate_inclusive_tax(self, tax):
|
|
||||||
def _on_previous_row_error(row_range):
|
|
||||||
throw(_("To include tax in row {0} in Item rate, taxes in rows {1} must also be included").format(tax.idx,
|
|
||||||
row_range))
|
|
||||||
|
|
||||||
if cint(getattr(tax, "included_in_print_rate", None)):
|
|
||||||
if tax.charge_type == "Actual":
|
|
||||||
# inclusive tax cannot be of type Actual
|
|
||||||
throw(_("Charge of type 'Actual' in row {0} cannot be included in Item Rate").format(tax.idx))
|
|
||||||
elif tax.charge_type == "On Previous Row Amount" and \
|
|
||||||
not cint(self.doc.get("taxes")[cint(tax.row_id) - 1].included_in_print_rate):
|
|
||||||
# referred row should also be inclusive
|
|
||||||
_on_previous_row_error(tax.row_id)
|
|
||||||
elif tax.charge_type == "On Previous Row Total" and \
|
|
||||||
not all([cint(t.included_in_print_rate) for t in self.doc.get("taxes")[:cint(tax.row_id) - 1]]):
|
|
||||||
# all rows about the reffered tax should be inclusive
|
|
||||||
_on_previous_row_error("1 - %d" % (tax.row_id,))
|
|
||||||
|
|
||||||
def determine_exclusive_rate(self):
|
def determine_exclusive_rate(self):
|
||||||
if not any((cint(tax.included_in_print_rate) for tax in self.doc.get("taxes"))):
|
if not any((cint(tax.included_in_print_rate) for tax in self.doc.get("taxes"))):
|
||||||
# no inclusive tax
|
|
||||||
return
|
return
|
||||||
|
|
||||||
for item in self.doc.get("items"):
|
for item in self.doc.get("items"):
|
||||||
@@ -136,18 +110,24 @@ class calculate_taxes_and_totals(object):
|
|||||||
cumulated_tax_fraction += tax.tax_fraction_for_current_item
|
cumulated_tax_fraction += tax.tax_fraction_for_current_item
|
||||||
|
|
||||||
if cumulated_tax_fraction and not self.discount_amount_applied and item.qty:
|
if cumulated_tax_fraction and not self.discount_amount_applied and item.qty:
|
||||||
item.base_amount = flt((item.amount * self.doc.conversion_rate) /
|
item.net_amount = flt(item.amount / (1 + cumulated_tax_fraction), item.precision("net_amount"))
|
||||||
(1 + cumulated_tax_fraction), self.doc.precision("base_amount", item))
|
item.net_rate = flt(item.net_amount / item.qty, item.precision("net_rate"))
|
||||||
|
item.discount_percentage = flt(item.discount_percentage, item.precision("discount_percentage"))
|
||||||
|
|
||||||
item.base_rate = flt(item.base_amount / item.qty, self.doc.precision("base_rate", item))
|
|
||||||
item.discount_percentage = flt(item.discount_percentage, self.doc.precision("discount_percentage", item))
|
|
||||||
|
|
||||||
if item.discount_percentage == 100:
|
self._set_in_company_currency(item, ["net_rate", "net_amount"])
|
||||||
item.base_price_list_rate = item.base_rate
|
|
||||||
item.base_rate = 0.0
|
# below part need to be fixed???
|
||||||
else:
|
|
||||||
item.base_price_list_rate = flt(item.base_rate / (1 - (item.discount_percentage / 100.0)),
|
# if item.discount_percentage == 100:
|
||||||
self.doc.precision("base_price_list_rate", item))
|
# item.price_list_rate = item.net_rate
|
||||||
|
# item.base_price_list_rate = flt(item.price_list_rate*self.doc.conversion_rate,
|
||||||
|
# self.doc.precision("base_price_list_rate", item))
|
||||||
|
# item.rate = item.base_rate = item.net_rate = item.base_net_rate = 0.0
|
||||||
|
# else:
|
||||||
|
# item.base_price_list_rate = flt(item.net_rate / (1 - (item.discount_percentage / 100.0)),
|
||||||
|
# self.doc.precision("price_list_rate", item))
|
||||||
|
|
||||||
|
|
||||||
def _load_item_tax_rate(self, item_tax_rate):
|
def _load_item_tax_rate(self, item_tax_rate):
|
||||||
return json.loads(item_tax_rate) if item_tax_rate else {}
|
return json.loads(item_tax_rate) if item_tax_rate else {}
|
||||||
@@ -182,17 +162,19 @@ class calculate_taxes_and_totals(object):
|
|||||||
return tax.rate
|
return tax.rate
|
||||||
|
|
||||||
def calculate_net_total(self):
|
def calculate_net_total(self):
|
||||||
self.doc.base_net_total = self.doc.net_total = 0.0
|
self.doc.total = self.doc.base_total = self.doc.net_total = self.doc.base_net_total = 0.0
|
||||||
|
|
||||||
for item in self.doc.get("items"):
|
for item in self.doc.get("items"):
|
||||||
self.doc.base_net_total += item.base_amount
|
self.doc.total += item.amount
|
||||||
self.doc.net_total += item.amount
|
self.doc.base_total += item.base_amount
|
||||||
|
self.doc.net_total += item.net_amount
|
||||||
|
self.doc.base_net_total += item.base_net_amount
|
||||||
|
|
||||||
self.doc.round_floats_in(self.doc, ["base_net_total", "net_total"])
|
self.doc.round_floats_in(self.doc, ["total", "base_total", "net_total", "base_net_total"])
|
||||||
|
|
||||||
def calculate_taxes(self):
|
def calculate_taxes(self):
|
||||||
# maintain actual tax rate based on idx
|
# maintain actual tax rate based on idx
|
||||||
actual_tax_dict = dict([[tax.idx, flt(tax.rate, self.doc.precision("tax_amount", tax))]
|
actual_tax_dict = dict([[tax.idx, flt(tax.tax_amount, tax.precision("tax_amount"))]
|
||||||
for tax in self.doc.get("taxes") if tax.charge_type == "Actual"])
|
for tax in self.doc.get("taxes") if tax.charge_type == "Actual"])
|
||||||
|
|
||||||
for n, item in enumerate(self.doc.get("items")):
|
for n, item in enumerate(self.doc.get("items")):
|
||||||
@@ -208,14 +190,16 @@ class calculate_taxes_and_totals(object):
|
|||||||
if n == len(self.doc.get("items")) - 1:
|
if n == len(self.doc.get("items")) - 1:
|
||||||
current_tax_amount += actual_tax_dict[tax.idx]
|
current_tax_amount += actual_tax_dict[tax.idx]
|
||||||
|
|
||||||
|
# accumulate tax amount into tax.tax_amount
|
||||||
|
if tax.charge_type != "Actual" and \
|
||||||
|
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'
|
||||||
tax.tax_amount_for_current_item = current_tax_amount
|
tax.tax_amount_for_current_item = current_tax_amount
|
||||||
|
|
||||||
# accumulate tax amount into tax.tax_amount
|
# set tax after discount
|
||||||
if not self.discount_amount_applied:
|
|
||||||
tax.tax_amount += current_tax_amount
|
|
||||||
|
|
||||||
tax.tax_amount_after_discount_amount += current_tax_amount
|
tax.tax_amount_after_discount_amount += current_tax_amount
|
||||||
|
|
||||||
if getattr(tax, "category", None):
|
if getattr(tax, "category", None):
|
||||||
@@ -230,12 +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.base_amount + current_tax_amount,
|
tax.grand_total_for_current_item = flt(item.net_amount + current_tax_amount)
|
||||||
self.doc.precision("total", tax))
|
|
||||||
else:
|
else:
|
||||||
tax.grand_total_for_current_item = \
|
tax.grand_total_for_current_item = \
|
||||||
flt(self.doc.get("taxes")[i-1].grand_total_for_current_item +
|
self.doc.get("taxes")[i-1].grand_total_for_current_item + current_tax_amount
|
||||||
current_tax_amount, self.doc.precision("total", tax))
|
|
||||||
|
|
||||||
# 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
|
||||||
@@ -245,8 +227,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)
|
||||||
@@ -254,12 +237,11 @@ class calculate_taxes_and_totals(object):
|
|||||||
|
|
||||||
if tax.charge_type == "Actual":
|
if tax.charge_type == "Actual":
|
||||||
# distribute the tax amount proportionally to each item row
|
# distribute the tax amount proportionally to each item row
|
||||||
actual = flt(tax.rate, self.doc.precision("tax_amount", tax))
|
actual = flt(tax.tax_amount, tax.precision("tax_amount"))
|
||||||
current_tax_amount = (self.doc.base_net_total
|
current_tax_amount = item.net_amount*actual / self.doc.net_total if self.doc.net_total else 0.0
|
||||||
and ((item.base_amount / self.doc.base_net_total) * actual)
|
|
||||||
or 0)
|
|
||||||
elif tax.charge_type == "On Net Total":
|
elif tax.charge_type == "On Net Total":
|
||||||
current_tax_amount = (tax_rate / 100.0) * item.base_amount
|
current_tax_amount = (tax_rate / 100.0) * item.net_amount
|
||||||
elif tax.charge_type == "On Previous Row Amount":
|
elif tax.charge_type == "On Previous Row Amount":
|
||||||
current_tax_amount = (tax_rate / 100.0) * \
|
current_tax_amount = (tax_rate / 100.0) * \
|
||||||
self.doc.get("taxes")[cint(tax.row_id) - 1].tax_amount_for_current_item
|
self.doc.get("taxes")[cint(tax.row_id) - 1].tax_amount_for_current_item
|
||||||
@@ -267,72 +249,68 @@ 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, self.doc.precision("tax_amount", tax))
|
# current_tax_amount = flt(current_tax_amount, tax.precision("tax_amount", tax))
|
||||||
|
|
||||||
# store tax breakup for each item
|
self.set_item_wise_tax(item, tax, tax_rate, current_tax_amount)
|
||||||
key = item.item_code or item.item_name
|
|
||||||
if tax.item_wise_tax_detail.get(key):
|
|
||||||
item_wise_tax_amount = tax.item_wise_tax_detail[key][1] + current_tax_amount
|
|
||||||
tax.item_wise_tax_detail[key] = [tax_rate,item_wise_tax_amount]
|
|
||||||
else:
|
|
||||||
tax.item_wise_tax_detail[key] = [tax_rate,current_tax_amount]
|
|
||||||
|
|
||||||
return current_tax_amount
|
return current_tax_amount
|
||||||
|
|
||||||
|
def set_item_wise_tax(self, item, tax, tax_rate, current_tax_amount):
|
||||||
|
# store tax breakup for each item
|
||||||
|
key = item.item_code or item.item_name
|
||||||
|
item_wise_tax_amount = current_tax_amount*self.doc.conversion_rate
|
||||||
|
if tax.item_wise_tax_detail.get(key):
|
||||||
|
item_wise_tax_amount += tax.item_wise_tax_detail[key][1]
|
||||||
|
|
||||||
|
tax.item_wise_tax_detail[key] = [tax_rate,flt(item_wise_tax_amount, tax.precision("base_tax_amount"))]
|
||||||
|
|
||||||
def round_off_totals(self, tax):
|
def round_off_totals(self, tax):
|
||||||
tax.total = flt(tax.total, self.doc.precision("total", tax))
|
tax.total = flt(tax.total, tax.precision("total"))
|
||||||
tax.tax_amount = flt(tax.tax_amount, self.doc.precision("tax_amount", tax))
|
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.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, tax.precision("tax_amount"))
|
||||||
self.doc.precision("tax_amount", tax))
|
|
||||||
|
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.base_grand_total - flt(self.doc.base_discount_amount) - tax.total
|
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 +
|
tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount +
|
||||||
discount_amount_loss, self.doc.precision("tax_amount", tax))
|
discount_amount_loss, self.doc.precision("tax_amount", tax))
|
||||||
tax.total = flt(tax.total + discount_amount_loss, self.doc.precision("total", tax))
|
tax.total = flt(tax.total + discount_amount_loss, self.doc.precision("total", tax))
|
||||||
|
|
||||||
def calculate_totals(self):
|
def calculate_totals(self):
|
||||||
self.doc.base_grand_total = flt(self.doc.get("taxes")[-1].total
|
self.doc.grand_total = flt(self.doc.get("taxes")[-1].total
|
||||||
if self.doc.get("taxes") else self.doc.base_net_total)
|
if self.doc.get("taxes") else self.doc.net_total)
|
||||||
|
|
||||||
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.doc.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) \
|
self.doc.base_grand_total = flt(self.doc.grand_total * self.doc.conversion_rate) \
|
||||||
if (self.doc.base_total_taxes_and_charges or self.doc.discount_amount) else self.doc.net_total
|
if self.doc.total_taxes_and_charges else self.doc.base_net_total
|
||||||
|
|
||||||
self.doc.total_taxes_and_charges = flt(self.doc.grand_total - self.doc.net_total +
|
|
||||||
flt(self.doc.discount_amount), self.doc.precision("total_taxes_and_charges"))
|
|
||||||
else:
|
else:
|
||||||
self.doc.base_taxes_and_charges_added, self.doc.base_taxes_and_charges_deducted = 0.0, 0.0
|
self.doc.taxes_and_charges_added, self.taxes_and_charges_deducted = 0.0, 0.0
|
||||||
for tax in self.doc.get("taxes"):
|
for tax in self.doc.get("taxes"):
|
||||||
if tax.category in ["Valuation and Total", "Total"]:
|
if tax.category in ["Valuation and Total", "Total"]:
|
||||||
if tax.add_deduct_tax == "Add":
|
if tax.add_deduct_tax == "Add":
|
||||||
self.doc.base_taxes_and_charges_added += flt(tax.tax_amount)
|
self.doc.taxes_and_charges_added += flt(tax.tax_amount)
|
||||||
else:
|
else:
|
||||||
self.doc.base_taxes_and_charges_deducted += flt(tax.tax_amount)
|
self.doc.taxes_and_charges_deducted += flt(tax.tax_amount)
|
||||||
|
|
||||||
self.doc.round_floats_in(self.doc, ["base_taxes_and_charges_added", "base_taxes_and_charges_deducted"])
|
self.doc.round_floats_in(self.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"])
|
||||||
|
|
||||||
self.doc.grand_total = flt(self.doc.base_grand_total / self.doc.conversion_rate) \
|
self.doc.base_grand_total = flt(self.doc.grand_total * self.doc.conversion_rate) \
|
||||||
if (self.doc.base_taxes_and_charges_added or self.doc.base_taxes_and_charges_deducted) else self.doc.net_total
|
if (self.doc.taxes_and_charges_added or self.doc.taxes_and_charges_deducted) \
|
||||||
|
else self.doc.base_net_total
|
||||||
|
|
||||||
self.doc.total_taxes_and_charges = flt(self.doc.grand_total - self.doc.net_total,
|
self._set_in_company_currency(self.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"])
|
||||||
self.doc.precision("total_taxes_and_charges"))
|
|
||||||
|
|
||||||
self.doc.taxes_and_charges_added = flt(self.doc.base_taxes_and_charges_added / self.doc.conversion_rate,
|
self.doc.total_taxes_and_charges = flt(self.doc.grand_total - self.doc.net_total,
|
||||||
self.doc.precision("taxes_and_charges_added"))
|
self.doc.precision("total_taxes_and_charges"))
|
||||||
self.doc.taxes_and_charges_deducted = flt(self.doc.base_taxes_and_charges_deducted / self.doc.conversion_rate,
|
|
||||||
self.doc.precision("taxes_and_charges_deducted"))
|
|
||||||
|
|
||||||
self.doc.base_grand_total = flt(self.doc.base_grand_total, self.doc.precision("base_grand_total"))
|
self._set_in_company_currency(self.doc, ["total_taxes_and_charges"])
|
||||||
self.doc.grand_total = flt(self.doc.grand_total, self.doc.precision("grand_total"))
|
self.doc.round_floats_in(self.doc, ["grand_total", "base_grand_total"])
|
||||||
|
|
||||||
if self.doc.meta.get_field("base_rounded_total"):
|
|
||||||
self.doc.base_rounded_total = rounded(self.doc.base_grand_total)
|
|
||||||
if self.doc.meta.get_field("rounded_total"):
|
if self.doc.meta.get_field("rounded_total"):
|
||||||
self.doc.rounded_total = rounded(self.doc.grand_total)
|
self.doc.rounded_total = rounded(self.doc.grand_total)
|
||||||
|
if self.doc.meta.get_field("base_rounded_total"):
|
||||||
|
self.doc.base_rounded_total = rounded(self.doc.base_grand_total)
|
||||||
|
|
||||||
def _cleanup(self):
|
def _cleanup(self):
|
||||||
for tax in self.doc.get("taxes"):
|
for tax in self.doc.get("taxes"):
|
||||||
@@ -340,43 +318,50 @@ class calculate_taxes_and_totals(object):
|
|||||||
|
|
||||||
def apply_discount_amount(self):
|
def apply_discount_amount(self):
|
||||||
if self.doc.discount_amount:
|
if self.doc.discount_amount:
|
||||||
|
if not self.doc.apply_discount_on:
|
||||||
|
frappe.throw(_("Please select Apply Discount On"))
|
||||||
|
|
||||||
self.doc.base_discount_amount = flt(self.doc.discount_amount * self.doc.conversion_rate,
|
self.doc.base_discount_amount = flt(self.doc.discount_amount * self.doc.conversion_rate,
|
||||||
self.doc.precision("base_discount_amount"))
|
self.doc.precision("base_discount_amount"))
|
||||||
|
|
||||||
grand_total_for_discount_amount = self.get_grand_total_for_discount_amount()
|
total_for_discount_amount = self.get_total_for_discount_amount()
|
||||||
|
|
||||||
if grand_total_for_discount_amount:
|
if total_for_discount_amount:
|
||||||
# calculate item amount after Discount Amount
|
# calculate item amount after Discount Amount
|
||||||
for item in self.doc.get("items"):
|
for item in self.doc.get("items"):
|
||||||
distributed_amount = flt(self.doc.base_discount_amount) * item.base_amount / grand_total_for_discount_amount
|
distributed_amount = flt(self.doc.discount_amount) * item.net_amount / total_for_discount_amount
|
||||||
item.base_amount = flt(item.base_amount - distributed_amount, self.doc.precision("base_amount", item))
|
item.net_amount = flt(item.net_amount - distributed_amount, item.precision("net_amount"))
|
||||||
|
item.net_rate = flt(item.net_amount / item.qty, item.precision("net_rate"))
|
||||||
|
|
||||||
|
self._set_in_company_currency(item, ["net_rate", "net_amount"])
|
||||||
|
|
||||||
self.discount_amount_applied = True
|
self.discount_amount_applied = True
|
||||||
self._calculate()
|
self._calculate()
|
||||||
else:
|
else:
|
||||||
self.doc.base_discount_amount = 0
|
self.doc.base_discount_amount = 0
|
||||||
|
|
||||||
def get_grand_total_for_discount_amount(self):
|
def get_total_for_discount_amount(self):
|
||||||
actual_taxes_dict = {}
|
if self.doc.apply_discount_on == "Net Total":
|
||||||
|
return self.doc.net_total
|
||||||
|
else:
|
||||||
|
actual_taxes_dict = {}
|
||||||
|
|
||||||
for tax in self.doc.get("taxes"):
|
for tax in self.doc.get("taxes"):
|
||||||
if tax.charge_type == "Actual":
|
if tax.charge_type == "Actual":
|
||||||
actual_taxes_dict.setdefault(tax.idx, tax.tax_amount)
|
actual_taxes_dict.setdefault(tax.idx, tax.tax_amount)
|
||||||
elif tax.row_id in actual_taxes_dict:
|
elif tax.row_id in actual_taxes_dict:
|
||||||
actual_tax_amount = flt(actual_taxes_dict.get(tax.row_id, 0)) * flt(tax.rate) / 100
|
actual_tax_amount = flt(actual_taxes_dict.get(tax.row_id, 0)) * flt(tax.rate) / 100
|
||||||
actual_taxes_dict.setdefault(tax.idx, actual_tax_amount)
|
actual_taxes_dict.setdefault(tax.idx, actual_tax_amount)
|
||||||
|
|
||||||
grand_total_for_discount_amount = flt(self.doc.base_grand_total - sum(actual_taxes_dict.values()),
|
return flt(self.doc.grand_total - sum(actual_taxes_dict.values()), self.doc.precision("grand_total"))
|
||||||
self.doc.precision("base_grand_total"))
|
|
||||||
return grand_total_for_discount_amount
|
|
||||||
|
|
||||||
|
|
||||||
def calculate_total_advance(self):
|
def calculate_total_advance(self):
|
||||||
if self.doc.docstatus < 2:
|
if self.doc.docstatus < 2:
|
||||||
sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.doc.precision("allocated_amount", adv))
|
total_allocated_amount = sum([flt(adv.allocated_amount, adv.precision("allocated_amount"))
|
||||||
for adv in self.doc.get("advances")])
|
for adv in self.doc.get("advances")])
|
||||||
|
|
||||||
self.doc.total_advance = flt(sum_of_allocated_amount, self.doc.precision("total_advance"))
|
self.doc.total_advance = flt(total_allocated_amount, self.doc.precision("total_advance"))
|
||||||
|
|
||||||
if self.doc.docstatus == 0:
|
if self.doc.docstatus == 0:
|
||||||
self.calculate_outstanding_amount()
|
self.calculate_outstanding_amount()
|
||||||
|
|||||||
@@ -132,9 +132,9 @@ def period_wise_columns_query(filters, trans):
|
|||||||
else:
|
else:
|
||||||
pwc = [_(filters.get("fiscal_year")) + " ("+_("Qty") + "):Float:120",
|
pwc = [_(filters.get("fiscal_year")) + " ("+_("Qty") + "):Float:120",
|
||||||
_(filters.get("fiscal_year")) + " ("+ _("Amt") + "):Currency:120"]
|
_(filters.get("fiscal_year")) + " ("+ _("Amt") + "):Currency:120"]
|
||||||
query_details = " SUM(t2.qty), SUM(t2.base_amount),"
|
query_details = " SUM(t2.qty), SUM(t2.base_net_amount),"
|
||||||
|
|
||||||
query_details += 'SUM(t2.qty), SUM(t2.base_amount)'
|
query_details += 'SUM(t2.qty), SUM(t2.base_net_amount)'
|
||||||
return pwc, query_details
|
return pwc, query_details
|
||||||
|
|
||||||
def get_period_wise_columns(bet_dates, period, pwc):
|
def get_period_wise_columns(bet_dates, period, pwc):
|
||||||
@@ -147,7 +147,7 @@ def get_period_wise_columns(bet_dates, period, pwc):
|
|||||||
|
|
||||||
def get_period_wise_query(bet_dates, trans_date, query_details):
|
def get_period_wise_query(bet_dates, trans_date, query_details):
|
||||||
query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.qty, NULL)),
|
query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.qty, NULL)),
|
||||||
SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.base_amount, NULL)),
|
SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.base_net_amount, NULL)),
|
||||||
""" % {"trans_date": trans_date, "sd": bet_dates[0],"ed": bet_dates[1]}
|
""" % {"trans_date": trans_date, "sd": bet_dates[0],"ed": bet_dates[1]}
|
||||||
return query_details
|
return query_details
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ erpnext.patches.v5_0.remove_birthday_events
|
|||||||
erpnext.patches.v5_0.update_item_name_in_bom
|
erpnext.patches.v5_0.update_item_name_in_bom
|
||||||
erpnext.patches.v5_0.rename_customer_issue
|
erpnext.patches.v5_0.rename_customer_issue
|
||||||
erpnext.patches.v5_0.rename_total_fields
|
erpnext.patches.v5_0.rename_total_fields
|
||||||
erpnext.patches.v5_0.replace_renamed_fields_in_custom_script_and_print_formats
|
|
||||||
erpnext.patches.v5_0.new_crm_module
|
erpnext.patches.v5_0.new_crm_module
|
||||||
erpnext.patches.v5_0.rename_customer_issue
|
erpnext.patches.v5_0.rename_customer_issue
|
||||||
erpnext.patches.v5_0.update_material_transfer_for_manufacture
|
erpnext.patches.v5_0.update_material_transfer_for_manufacture
|
||||||
@@ -124,3 +123,5 @@ erpnext.patches.v5_0.convert_stock_reconciliation
|
|||||||
erpnext.patches.v5_0.update_projects
|
erpnext.patches.v5_0.update_projects
|
||||||
erpnext.patches.v5_0.item_patches
|
erpnext.patches.v5_0.item_patches
|
||||||
erpnext.patches.v5_0.update_journal_entry_title
|
erpnext.patches.v5_0.update_journal_entry_title
|
||||||
|
erpnext.patches.v5_0.taxes_and_totals_in_party_currency
|
||||||
|
erpnext.patches.v5_0.replace_renamed_fields_in_custom_scripts_and_print_formats
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ doctype_series_map = {
|
|||||||
def execute():
|
def execute():
|
||||||
series_to_set = get_series_to_set()
|
series_to_set = get_series_to_set()
|
||||||
for doctype, opts in series_to_set.items():
|
for doctype, opts in series_to_set.items():
|
||||||
print "Setting naming series", doctype, opts
|
|
||||||
set_series(doctype, opts["options"], opts["default"])
|
set_series(doctype, opts["options"], opts["default"])
|
||||||
|
|
||||||
def set_series(doctype, options, default):
|
def set_series(doctype, options, default):
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ def get_all_renamed_fields():
|
|||||||
from erpnext.patches.v5_0.rename_table_fieldnames import rename_map
|
from erpnext.patches.v5_0.rename_table_fieldnames import rename_map
|
||||||
|
|
||||||
renamed_fields = (
|
renamed_fields = (
|
||||||
|
("base_amount", "base_net_amount"),
|
||||||
("net_total", "base_net_total"),
|
("net_total", "base_net_total"),
|
||||||
("net_total_export", "net_total"),
|
("net_total_export", "total"),
|
||||||
("net_total_import", "net_total"),
|
("net_total_import", "total"),
|
||||||
("other_charges_total", "base_total_taxes_and_charges"),
|
("other_charges_total", "base_total_taxes_and_charges"),
|
||||||
("other_charges_total_export", "total_taxes_and_charges"),
|
("other_charges_total_export", "total_taxes_and_charges"),
|
||||||
("other_charges_added", "base_taxes_and_charges_added"),
|
("other_charges_added", "base_taxes_and_charges_added"),
|
||||||
@@ -39,7 +40,9 @@ def get_all_renamed_fields():
|
|||||||
("rounded_total_import", "rounded_total"),
|
("rounded_total_import", "rounded_total"),
|
||||||
("in_words", "base_in_words"),
|
("in_words", "base_in_words"),
|
||||||
("in_words_export", "in_words"),
|
("in_words_export", "in_words"),
|
||||||
("in_words_import", "in_words")
|
("in_words_import", "in_words"),
|
||||||
|
("tax_amount", "base_tax_amount"),
|
||||||
|
("tax_amount_after_discount_amount", "base_tax_amount_after_discount_amount"),
|
||||||
)
|
)
|
||||||
|
|
||||||
for fields in rename_map.values():
|
for fields in rename_map.values():
|
||||||
66
erpnext/patches/v5_0/taxes_and_totals_in_party_currency.py
Normal file
66
erpnext/patches/v5_0/taxes_and_totals_in_party_currency.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
|
||||||
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
selling_doctypes = ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]
|
||||||
|
buying_doctypes = ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"]
|
||||||
|
|
||||||
|
for dt in selling_doctypes:
|
||||||
|
update_values(dt, "Sales Taxes and Charges")
|
||||||
|
|
||||||
|
for dt in buying_doctypes:
|
||||||
|
update_values(dt, "Purchase Taxes and Charges")
|
||||||
|
|
||||||
|
def update_values(dt, tax_table):
|
||||||
|
frappe.reload_doctype(dt)
|
||||||
|
frappe.reload_doctype(dt + " Item")
|
||||||
|
frappe.reload_doctype(tax_table)
|
||||||
|
|
||||||
|
# update net_total, discount_on
|
||||||
|
frappe.db.sql("""
|
||||||
|
UPDATE
|
||||||
|
`tab{0}`
|
||||||
|
SET
|
||||||
|
total = net_total,
|
||||||
|
base_total = net_total*conversion_rate,
|
||||||
|
net_total = base_net_total / conversion_rate,
|
||||||
|
apply_discount_on = "Grand Total"
|
||||||
|
WHERE
|
||||||
|
docstatus < 2
|
||||||
|
""".format(dt))
|
||||||
|
|
||||||
|
|
||||||
|
# update net_amount
|
||||||
|
frappe.db.sql("""
|
||||||
|
UPDATE
|
||||||
|
`tab{0}` par, `tab{1}` item
|
||||||
|
SET
|
||||||
|
item.base_net_amount = item.base_amount,
|
||||||
|
item.base_net_rate = item.base_rate,
|
||||||
|
item.net_amount = item.base_net_amount / par.conversion_rate,
|
||||||
|
item.net_rate = item.base_net_rate / par.conversion_rate,
|
||||||
|
item.base_amount = item.amount * par.conversion_rate,
|
||||||
|
item.base_rate = item.rate * par.conversion_rate
|
||||||
|
WHERE
|
||||||
|
par.name = item.parent
|
||||||
|
and par.docstatus < 2
|
||||||
|
""".format(dt, dt + " Item"))
|
||||||
|
|
||||||
|
# update tax in party currency
|
||||||
|
frappe.db.sql("""
|
||||||
|
UPDATE
|
||||||
|
`tab{0}` par, `tab{1}` tax
|
||||||
|
SET
|
||||||
|
tax.base_tax_amount = tax.tax_amount,
|
||||||
|
tax.tax_amount = tax.base_tax_amount / par.conversion_rate,
|
||||||
|
tax.base_total = tax.total,
|
||||||
|
tax.total = tax.base_total / conversion_rate,
|
||||||
|
tax.base_tax_amount_after_discount_amount = tax.tax_amount_after_discount_amount,
|
||||||
|
tax.tax_amount_after_discount_amount = tax.base_tax_amount_after_discount_amount / conversion_rate
|
||||||
|
WHERE
|
||||||
|
par.name = tax.parent
|
||||||
|
and par.docstatus < 2
|
||||||
|
""".format(dt, tax_table))
|
||||||
@@ -77,7 +77,6 @@ $.extend(cur_frm.cscript, {
|
|||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(!r.exc) {
|
if(!r.exc) {
|
||||||
console.log(r.message)
|
|
||||||
cur_frm.set_value("workstation", r.message)
|
cur_frm.set_value("workstation", r.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,19 +13,19 @@ def execute(filters=None):
|
|||||||
|
|
||||||
data = []
|
data = []
|
||||||
for project in proj_details:
|
for project in proj_details:
|
||||||
data.append([project.name, pr_item_map.get(project.name, 0),
|
data.append([project.name, pr_item_map.get(project.name, 0),
|
||||||
se_item_map.get(project.name, 0), dn_item_map.get(project.name, 0),
|
se_item_map.get(project.name, 0), dn_item_map.get(project.name, 0),
|
||||||
project.project_name, project.status, project.company,
|
project.project_name, project.status, project.company,
|
||||||
project.customer, project.project_value, project.project_start_date,
|
project.customer, project.project_value, project.project_start_date,
|
||||||
project.completion_date])
|
project.completion_date])
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
def get_columns():
|
def get_columns():
|
||||||
return [_("Project Id") + ":Link/Project:140", _("Cost of Purchased Items") + ":Currency:160",
|
return [_("Project Id") + ":Link/Project:140", _("Cost of Purchased Items") + ":Currency:160",
|
||||||
_("Cost of Issued Items") + ":Currency:160", _("Cost of Delivered Items") + ":Currency:160",
|
_("Cost of Issued Items") + ":Currency:160", _("Cost of Delivered Items") + ":Currency:160",
|
||||||
_("Project Name") + "::120", _("Project Status") + "::120", _("Company") + ":Link/Company:100",
|
_("Project Name") + "::120", _("Project Status") + "::120", _("Company") + ":Link/Company:100",
|
||||||
_("Customer") + ":Link/Customer:140", _("Project Value") + ":Currency:120",
|
_("Customer") + ":Link/Customer:140", _("Project Value") + ":Currency:120",
|
||||||
_("Project Start Date") + ":Date:120", _("Completion Date") + ":Date:120"]
|
_("Project Start Date") + ":Date:120", _("Completion Date") + ":Date:120"]
|
||||||
|
|
||||||
def get_project_details():
|
def get_project_details():
|
||||||
@@ -33,8 +33,8 @@ def get_project_details():
|
|||||||
project_start_date, completion_date from tabProject where docstatus < 2""", as_dict=1)
|
project_start_date, completion_date from tabProject where docstatus < 2""", as_dict=1)
|
||||||
|
|
||||||
def get_purchased_items_cost():
|
def get_purchased_items_cost():
|
||||||
pr_items = frappe.db.sql("""select project_name, sum(base_amount) as amount
|
pr_items = frappe.db.sql("""select project_name, sum(base_net_amount) as amount
|
||||||
from `tabPurchase Receipt Item` where ifnull(project_name, '') != ''
|
from `tabPurchase Receipt Item` where ifnull(project_name, '') != ''
|
||||||
and docstatus = 1 group by project_name""", as_dict=1)
|
and docstatus = 1 group by project_name""", as_dict=1)
|
||||||
|
|
||||||
pr_item_map = {}
|
pr_item_map = {}
|
||||||
@@ -46,7 +46,7 @@ def get_purchased_items_cost():
|
|||||||
def get_issued_items_cost():
|
def get_issued_items_cost():
|
||||||
se_items = frappe.db.sql("""select se.project_name, sum(se_item.amount) as amount
|
se_items = frappe.db.sql("""select se.project_name, sum(se_item.amount) as amount
|
||||||
from `tabStock Entry` se, `tabStock Entry Detail` se_item
|
from `tabStock Entry` se, `tabStock Entry Detail` se_item
|
||||||
where se.name = se_item.parent and se.docstatus = 1 and ifnull(se_item.t_warehouse, '') = ''
|
where se.name = se_item.parent and se.docstatus = 1 and ifnull(se_item.t_warehouse, '') = ''
|
||||||
and ifnull(se.project_name, '') != '' group by se.project_name""", as_dict=1)
|
and ifnull(se.project_name, '') != '' group by se.project_name""", as_dict=1)
|
||||||
|
|
||||||
se_item_map = {}
|
se_item_map = {}
|
||||||
@@ -56,14 +56,14 @@ def get_issued_items_cost():
|
|||||||
return se_item_map
|
return se_item_map
|
||||||
|
|
||||||
def get_delivered_items_cost():
|
def get_delivered_items_cost():
|
||||||
dn_items = frappe.db.sql("""select dn.project_name, sum(dn_item.base_amount) as amount
|
dn_items = frappe.db.sql("""select dn.project_name, sum(dn_item.base_net_amount) as amount
|
||||||
from `tabDelivery Note` dn, `tabDelivery Note Item` dn_item
|
from `tabDelivery Note` dn, `tabDelivery Note Item` dn_item
|
||||||
where dn.name = dn_item.parent and dn.docstatus = 1 and ifnull(dn.project_name, '') != ''
|
where dn.name = dn_item.parent and dn.docstatus = 1 and ifnull(dn.project_name, '') != ''
|
||||||
group by dn.project_name""", as_dict=1)
|
group by dn.project_name""", as_dict=1)
|
||||||
|
|
||||||
si_items = frappe.db.sql("""select si.project_name, sum(si_item.base_amount) as amount
|
si_items = frappe.db.sql("""select si.project_name, sum(si_item.base_net_amount) as amount
|
||||||
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
|
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
|
||||||
where si.name = si_item.parent and si.docstatus = 1 and ifnull(si.update_stock, 0) = 1
|
where si.name = si_item.parent and si.docstatus = 1 and ifnull(si.update_stock, 0) = 1
|
||||||
and ifnull(si.is_pos, 0) = 1 and ifnull(si.project_name, '') != ''
|
and ifnull(si.is_pos, 0) = 1 and ifnull(si.project_name, '') != ''
|
||||||
group by si.project_name""", as_dict=1)
|
group by si.project_name""", as_dict=1)
|
||||||
|
|
||||||
@@ -75,4 +75,4 @@ def get_delivered_items_cost():
|
|||||||
for item in si_items:
|
for item in si_items:
|
||||||
dn_item_map.setdefault(item.project_name, item.amount)
|
dn_item_map.setdefault(item.project_name, item.amount)
|
||||||
|
|
||||||
return dn_item_map
|
return dn_item_map
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
// get tax rate
|
// get tax rate
|
||||||
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
|
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
|
||||||
@@ -8,7 +10,7 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) {
|
|||||||
} else if(d.account_head && d.charge_type!=="Actual") {
|
} else if(d.account_head && d.charge_type!=="Actual") {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
type:"GET",
|
type:"GET",
|
||||||
method: "erpnext.controllers.accounts_controller.get_tax_rate",
|
method: "erpnext.controllers.accounts_controller.get_tax_rate",
|
||||||
args: {"account_head":d.account_head},
|
args: {"account_head":d.account_head},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
frappe.model.set_value(cdt, cdn, "rate", r.message || 0);
|
frappe.model.set_value(cdt, cdn, "rate", r.message || 0);
|
||||||
@@ -16,3 +18,187 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.validate_taxes_and_charges = function(cdt, cdn) {
|
||||||
|
var d = locals[cdt][cdn];
|
||||||
|
var msg = "";
|
||||||
|
if(!d.charge_type && (d.row_id || d.rate || d.tax_amount)) {
|
||||||
|
msg = __("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) {
|
||||||
|
msg = __("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) {
|
||||||
|
msg = __("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row");
|
||||||
|
d.charge_type = '';
|
||||||
|
} else if (!d.row_id) {
|
||||||
|
msg = __("Please specify a valid Row ID for row {0} in table {1}", [d.idx, __(d.doctype)]);
|
||||||
|
d.row_id = "";
|
||||||
|
} else if(d.row_id && d.row_id >= d.idx) {
|
||||||
|
msg = __("Cannot refer row number greater than or equal to current row number for this Charge type");
|
||||||
|
d.row_id = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(msg) {
|
||||||
|
validated = false;
|
||||||
|
refresh_field("taxes");
|
||||||
|
frappe.throw(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.validate_inclusive_tax = function(tax) {
|
||||||
|
var actual_type_error = function() {
|
||||||
|
var msg = __("Actual type tax cannot be included in Item rate in row {0}", [tax.idx])
|
||||||
|
frappe.throw(msg);
|
||||||
|
};
|
||||||
|
|
||||||
|
var on_previous_row_error = function(row_range) {
|
||||||
|
var msg = __("For row {0} in {1}. To include {2} in Item rate, rows {3} must also be included",
|
||||||
|
[tax.idx, __(tax.doctype), tax.charge_type, row_range])
|
||||||
|
frappe.throw(msg);
|
||||||
|
};
|
||||||
|
|
||||||
|
if(cint(tax.included_in_print_rate)) {
|
||||||
|
if(tax.charge_type == "Actual") {
|
||||||
|
// inclusive tax cannot be of type Actual
|
||||||
|
actual_type_error();
|
||||||
|
} else if(tax.charge_type == "On Previous Row Amount" &&
|
||||||
|
!cint(this.frm.doc["taxes"][tax.row_id - 1].included_in_print_rate)) {
|
||||||
|
// referred row should also be an inclusive tax
|
||||||
|
on_previous_row_error(tax.row_id);
|
||||||
|
} else if(tax.charge_type == "On Previous Row Total") {
|
||||||
|
var taxes_not_included = $.map(this.frm.doc["taxes"].slice(0, tax.row_id),
|
||||||
|
function(t) { return cint(t.included_in_print_rate) ? null : t; });
|
||||||
|
if(taxes_not_included.length > 0) {
|
||||||
|
// all rows above this tax should be inclusive
|
||||||
|
on_previous_row_error(tax.row_id == 1 ? "1" : "1 - " + tax.row_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
frappe.ui.form.on(cur_frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) {
|
||||||
|
cur_frm.cscript.validate_taxes_and_charges(cdt, cdn);
|
||||||
|
});
|
||||||
|
|
||||||
|
frappe.ui.form.on(cur_frm.cscript.tax_table, "rate", function(frm, cdt, cdn) {
|
||||||
|
cur_frm.cscript.validate_taxes_and_charges(cdt, cdn);
|
||||||
|
});
|
||||||
|
|
||||||
|
frappe.ui.form.on(cur_frm.cscript.tax_table, "tax_amount", function(frm, cdt, cdn) {
|
||||||
|
cur_frm.cscript.validate_taxes_and_charges(cdt, cdn);
|
||||||
|
});
|
||||||
|
|
||||||
|
frappe.ui.form.on(cur_frm.cscript.tax_table, "charge_type", function(frm, cdt, cdn) {
|
||||||
|
cur_frm.cscript.validate_taxes_and_charges(cdt, cdn);
|
||||||
|
});
|
||||||
|
|
||||||
|
frappe.ui.form.on(cur_frm.cscript.tax_table, "included_in_print_rate", function(frm, cdt, cdn) {
|
||||||
|
var tax = frappe.get_doc(cdt, cdn);
|
||||||
|
try {
|
||||||
|
cur_frm.cscript.validate_taxes_and_charges(cdt, cdn);
|
||||||
|
cur_frm.cscript.validate_inclusive_tax(tax);
|
||||||
|
} catch(e) {
|
||||||
|
tax.included_in_print_rate = 0;
|
||||||
|
refresh_field("included_in_print_rate", tax.name, tax.parentfield);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
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.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, is_negative) {
|
||||||
|
var bstart = '<b>'; var bend = '</b>';
|
||||||
|
return '<tr><td style="width:50%;">' + (bold?bstart:'') + title + (bold?bend:'') + '</td>'
|
||||||
|
+ '<td style="width:50%;text-align:right;">' + (is_negative ? '- ' : '')
|
||||||
|
+ format_currency(val, doc.currency) + '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function print_hide(fieldname) {
|
||||||
|
var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name);
|
||||||
|
return doc_field.print_hide;
|
||||||
|
}
|
||||||
|
|
||||||
|
out ='';
|
||||||
|
if (!doc.print_without_amount) {
|
||||||
|
var cl = doc.taxes || [];
|
||||||
|
|
||||||
|
// outer table
|
||||||
|
var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>';
|
||||||
|
|
||||||
|
// main table
|
||||||
|
|
||||||
|
out +='<table class="noborder" style="width:100%">';
|
||||||
|
|
||||||
|
if(!print_hide('total')) {
|
||||||
|
out += make_row('Total', doc.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
|
||||||
|
if(cl.length){
|
||||||
|
for(var i=0;i<cl.length;i++) {
|
||||||
|
if(cl[i].tax_amount!=0 && !cl[i].included_in_print_rate)
|
||||||
|
out += make_row(cl[i].description, cl[i].tax_amount, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Discount Amount on grand total
|
||||||
|
if(!print_hide('discount_amount') && doc.apply_discount_on == "Grand Total" && doc.discount_amount)
|
||||||
|
out += make_row('Discount Amount', doc.discount_amount, 0, 1);
|
||||||
|
|
||||||
|
// grand total
|
||||||
|
if(!print_hide('grand_total'))
|
||||||
|
out += make_row('Grand Total', doc.grand_total, 1);
|
||||||
|
|
||||||
|
if(!print_hide('rounded_total'))
|
||||||
|
out += make_row('Rounded Total', doc.rounded_total, 1);
|
||||||
|
|
||||||
|
if(doc.in_words && !print_hide('in_words')) {
|
||||||
|
out +='</table></td></tr>';
|
||||||
|
out += '<tr><td colspan = "2">';
|
||||||
|
out += '<table><tr><td style="width:25%;"><b>In Words</b></td>';
|
||||||
|
out += '<td style="width:50%;">' + doc.in_words + '</td></tr>';
|
||||||
|
}
|
||||||
|
out += '</table></td></tr></table></div>';
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|||||||
@@ -38,22 +38,47 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
|||||||
this.show_item_wise_taxes();
|
this.show_item_wise_taxes();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
validate_conversion_rate: function() {
|
||||||
|
this.frm.doc.conversion_rate = flt(this.frm.doc.conversion_rate, precision("conversion_rate"));
|
||||||
|
var conversion_rate_label = frappe.meta.get_label(this.frm.doc.doctype, "conversion_rate",
|
||||||
|
this.frm.doc.name);
|
||||||
|
var company_currency = this.get_company_currency();
|
||||||
|
|
||||||
|
if(!this.frm.doc.conversion_rate) {
|
||||||
|
frappe.throw(repl('%(conversion_rate_label)s' +
|
||||||
|
__(' is mandatory. Maybe Currency Exchange record is not created for ') +
|
||||||
|
'%(from_currency)s' + __(" to ") + '%(to_currency)s',
|
||||||
|
{
|
||||||
|
"conversion_rate_label": conversion_rate_label,
|
||||||
|
"from_currency": this.frm.doc.currency,
|
||||||
|
"to_currency": company_currency
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
calculate_item_values: function() {
|
calculate_item_values: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
if (!this.discount_amount_applied) {
|
if (!this.discount_amount_applied) {
|
||||||
$.each(this.frm.doc["items"] || [], function(i, item) {
|
$.each(this.frm.doc["items"] || [], function(i, item) {
|
||||||
frappe.model.round_floats_in(item);
|
frappe.model.round_floats_in(item);
|
||||||
|
item.net_rate = item.rate;
|
||||||
item.amount = flt(item.rate * item.qty, precision("amount", item));
|
item.amount = flt(item.rate * item.qty, precision("amount", item));
|
||||||
|
item.net_amount = item.amount;
|
||||||
item.item_tax_amount = 0.0;
|
item.item_tax_amount = 0.0;
|
||||||
|
|
||||||
$.each(["price_list_rate", "rate", "amount"], function(i, f) {
|
me.set_in_company_currency(item, ["price_list_rate", "rate", "amount", "net_rate", "net_amount"]);
|
||||||
item["base_" + f] = flt(item[f] * me.frm.doc.conversion_rate, precision("base_" + f, item));
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
set_in_company_currency: function(doc, fields) {
|
||||||
|
var me = this;
|
||||||
|
$.each(fields, function(i, f) {
|
||||||
|
doc["base_"+f] = flt(flt(doc[f], precision(f, doc)) * me.frm.doc.conversion_rate, precision("base_" + f, doc));
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
initialize_taxes: function() {
|
initialize_taxes: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
@@ -63,21 +88,27 @@ 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 (!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 });
|
||||||
|
|
||||||
me.validate_on_previous_row(tax);
|
cur_frm.cscript.validate_taxes_and_charges(tax.doctype, tax.name);
|
||||||
me.validate_inclusive_tax(tax);
|
me.validate_inclusive_tax(tax);
|
||||||
frappe.model.round_floats_in(tax);
|
frappe.model.round_floats_in(tax);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
determine_exclusive_rate: function() {
|
determine_exclusive_rate: function() {
|
||||||
if(!in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) return;
|
|
||||||
|
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
|
var has_inclusive_tax = false;
|
||||||
|
$.each(me.frm.doc["taxes"] || [], function(i, row) {
|
||||||
|
if(cint(row.included_in_print_rate)) has_inclusive_tax = true;
|
||||||
|
})
|
||||||
|
if(has_inclusive_tax==false) return;
|
||||||
|
|
||||||
$.each(me.frm.doc["items"] || [], function(n, item) {
|
$.each(me.frm.doc["items"] || [], function(n, item) {
|
||||||
var item_tax_map = me._load_item_tax_rate(item.item_tax_rate);
|
var item_tax_map = me._load_item_tax_rate(item.item_tax_rate);
|
||||||
var cumulated_tax_fraction = 0.0;
|
var cumulated_tax_fraction = 0.0;
|
||||||
@@ -97,19 +128,18 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(cumulated_tax_fraction && !me.discount_amount_applied) {
|
if(cumulated_tax_fraction && !me.discount_amount_applied) {
|
||||||
item.base_amount = flt(
|
item.net_amount = flt(item.amount / (1 + cumulated_tax_fraction), precision("net_amount", item));
|
||||||
(item.amount * me.frm.doc.conversion_rate) / (1 + cumulated_tax_fraction),
|
item.net_rate = flt(item.net_amount / item.qty, precision("net_rate", item));
|
||||||
precision("base_amount", item));
|
|
||||||
|
|
||||||
item.base_rate = flt(item.base_amount / item.qty, precision("base_rate", item));
|
me.set_in_company_currency(item, ["net_rate", "net_amount"]);
|
||||||
|
|
||||||
if(item.discount_percentage == 100) {
|
// if(item.discount_percentage == 100) {
|
||||||
item.base_price_list_rate = item.base_rate;
|
// item.base_price_list_rate = item.base_rate;
|
||||||
item.base_rate = 0.0;
|
// item.base_rate = 0.0;
|
||||||
} else {
|
// } else {
|
||||||
item.base_price_list_rate = flt(item.base_rate / (1 - item.discount_percentage / 100.0),
|
// item.base_price_list_rate = flt(item.base_rate / (1 - item.discount_percentage / 100.0),
|
||||||
precision("base_price_list_rate", item));
|
// precision("base_price_list_rate", item));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -140,20 +170,21 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
|||||||
|
|
||||||
_get_tax_rate: function(tax, item_tax_map) {
|
_get_tax_rate: function(tax, item_tax_map) {
|
||||||
return (keys(item_tax_map).indexOf(tax.account_head) != -1) ?
|
return (keys(item_tax_map).indexOf(tax.account_head) != -1) ?
|
||||||
flt(item_tax_map[tax.account_head], precision("rate", tax)) :
|
flt(item_tax_map[tax.account_head], precision("rate", tax)) : tax.rate;
|
||||||
tax.rate;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
calculate_net_total: function() {
|
calculate_net_total: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.frm.doc.base_net_total = this.frm.doc.net_total = 0.0;
|
this.frm.doc.total = this.frm.doc.base_total = this.frm.doc.net_total = this.frm.doc.base_net_total = 0.0;
|
||||||
|
|
||||||
$.each(this.frm.doc["items"] || [], function(i, item) {
|
$.each(this.frm.doc["items"] || [], function(i, item) {
|
||||||
me.frm.doc.base_net_total += item.base_amount;
|
me.frm.doc.total += item.amount;
|
||||||
me.frm.doc.net_total += item.amount;
|
me.frm.doc.base_total += item.base_amount;
|
||||||
|
me.frm.doc.net_total += item.net_amount;
|
||||||
|
me.frm.doc.base_net_total += item.base_net_amount;
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.model.round_floats_in(this.frm.doc, ["base_net_total", "net_total"]);
|
frappe.model.round_floats_in(this.frm.doc, ["total", "base_total", "net_total", "base_net_total"]);
|
||||||
},
|
},
|
||||||
|
|
||||||
calculate_taxes: function() {
|
calculate_taxes: function() {
|
||||||
@@ -163,7 +194,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
|||||||
// maintain actual tax rate based on idx
|
// maintain actual tax rate based on idx
|
||||||
$.each(this.frm.doc["taxes"] || [], function(i, tax) {
|
$.each(this.frm.doc["taxes"] || [], function(i, tax) {
|
||||||
if (tax.charge_type == "Actual") {
|
if (tax.charge_type == "Actual") {
|
||||||
actual_tax_dict[tax.idx] = flt(tax.rate, precision("tax_amount", tax));
|
actual_tax_dict[tax.idx] = flt(tax.tax_amount, precision("tax_amount", tax));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -182,14 +213,16 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// accumulate tax amount into tax.tax_amount
|
||||||
|
if (tax.charge_type != "Actual" &&
|
||||||
|
!(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'
|
||||||
tax.tax_amount_for_current_item = current_tax_amount;
|
tax.tax_amount_for_current_item = current_tax_amount;
|
||||||
|
|
||||||
// accumulate tax amount into tax.tax_amount
|
// tax amount after discount amount
|
||||||
if (!me.discount_amount_applied)
|
|
||||||
tax.tax_amount += current_tax_amount;
|
|
||||||
|
|
||||||
tax.tax_amount_after_discount_amount += current_tax_amount;
|
tax.tax_amount_after_discount_amount += current_tax_amount;
|
||||||
|
|
||||||
// for buying
|
// for buying
|
||||||
@@ -205,12 +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.base_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
|
||||||
@@ -221,7 +252,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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -238,12 +269,12 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
|||||||
|
|
||||||
if(tax.charge_type == "Actual") {
|
if(tax.charge_type == "Actual") {
|
||||||
// distribute the tax amount proportionally to each item row
|
// distribute the tax amount proportionally to each item row
|
||||||
var actual = flt(tax.rate, precision("tax_amount", tax));
|
var actual = flt(tax.tax_amount, precision("tax_amount", tax));
|
||||||
current_tax_amount = this.frm.doc.base_net_total ?
|
current_tax_amount = this.frm.doc.net_total ?
|
||||||
((item.base_amount / this.frm.doc.base_net_total) * actual) : 0.0;
|
((item.net_amount / this.frm.doc.net_total) * actual) : 0.0;
|
||||||
|
|
||||||
} else if(tax.charge_type == "On Net Total") {
|
} else if(tax.charge_type == "On Net Total") {
|
||||||
current_tax_amount = (tax_rate / 100.0) * item.base_amount;
|
current_tax_amount = (tax_rate / 100.0) * item.net_amount;
|
||||||
|
|
||||||
} else if(tax.charge_type == "On Previous Row Amount") {
|
} else if(tax.charge_type == "On Previous Row Amount") {
|
||||||
current_tax_amount = (tax_rate / 100.0) *
|
current_tax_amount = (tax_rate / 100.0) *
|
||||||
@@ -254,31 +285,90 @@ 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));
|
||||||
|
|
||||||
// store tax breakup for each item
|
this.set_item_wise_tax(item, tax, tax_rate, current_tax_amount);
|
||||||
tax.item_wise_tax_detail[item.item_code || item.item_name] = [tax_rate, current_tax_amount];
|
|
||||||
|
|
||||||
return current_tax_amount;
|
return current_tax_amount;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
set_item_wise_tax: function(item, tax, tax_rate, current_tax_amount) {
|
||||||
|
// store tax breakup for each item
|
||||||
|
var key = item.item_code || item.item_name;
|
||||||
|
var item_wise_tax_amount = current_tax_amount * this.frm.doc.conversion_rate;
|
||||||
|
if (tax.item_wise_tax_detail && tax.item_wise_tax_detail[key])
|
||||||
|
item_wise_tax_amount += tax.item_wise_tax_detail[key][1]
|
||||||
|
|
||||||
|
tax.item_wise_tax_detail[key] = [tax_rate,flt(item_wise_tax_amount, precision("base_tax_amount", tax))]
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
round_off_totals: function(tax) {
|
round_off_totals: function(tax) {
|
||||||
tax.total = flt(tax.total, precision("total", tax));
|
tax.total = flt(tax.total, precision("total", tax));
|
||||||
tax.tax_amount = flt(tax.tax_amount, precision("tax_amount", tax));
|
tax.tax_amount = flt(tax.tax_amount, precision("tax_amount", tax));
|
||||||
tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount,
|
tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, precision("tax_amount", tax));
|
||||||
precision("tax_amount", tax));
|
|
||||||
|
this.set_in_company_currency(tax, ["total", "tax_amount", "tax_amount_after_discount_amount"]);
|
||||||
},
|
},
|
||||||
|
|
||||||
adjust_discount_amount_loss: function(tax) {
|
adjust_discount_amount_loss: function(tax) {
|
||||||
var discount_amount_loss = this.frm.doc.base_grand_total - flt(this.frm.doc.base_discount_amount) - tax.total;
|
var discount_amount_loss = this.frm.doc.grand_total - flt(this.frm.doc.discount_amount) - tax.total;
|
||||||
tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount +
|
tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount +
|
||||||
discount_amount_loss, precision("tax_amount", tax));
|
discount_amount_loss, precision("tax_amount", tax));
|
||||||
tax.total = flt(tax.total + discount_amount_loss, precision("total", tax));
|
tax.total = flt(tax.total + discount_amount_loss, precision("total", tax));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
calculate_totals: function() {
|
||||||
|
// Changing sequence can cause roundiing issue and on-screen discrepency
|
||||||
|
var me = this;
|
||||||
|
var tax_count = this.frm.doc["taxes"] ? this.frm.doc["taxes"].length : 0;
|
||||||
|
this.frm.doc.grand_total = flt(tax_count ? this.frm.doc["taxes"][tax_count - 1].total : this.frm.doc.net_total);
|
||||||
|
|
||||||
|
if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) {
|
||||||
|
this.frm.doc.base_grand_total = (this.frm.doc.total_taxes_and_charges) ?
|
||||||
|
flt(this.frm.doc.grand_total * this.frm.doc.conversion_rate) : this.frm.doc.base_net_total;
|
||||||
|
} else {
|
||||||
|
// other charges added/deducted
|
||||||
|
this.frm.doc.taxes_and_charges_added = this.frm.doc.taxes_and_charges_deducted = 0.0;
|
||||||
|
if(tax_count) {
|
||||||
|
$.each(this.frm.doc["taxes"] || [], function(i, tax) {
|
||||||
|
if (in_list(["Valuation and Total", "Total"], tax.category)) {
|
||||||
|
if(tax.add_deduct_tax == "Add") {
|
||||||
|
me.frm.doc.taxes_and_charges_added += flt(tax.tax_amount);
|
||||||
|
} else {
|
||||||
|
me.frm.doc.taxes_and_charges_deducted += flt(tax.tax_amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
frappe.model.round_floats_in(this.frm.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.frm.doc.base_grand_total = flt((this.frm.doc.taxes_and_charges_added || this.frm.doc.taxes_and_charges_deducted) ?
|
||||||
|
flt(this.frm.doc.grand_total * this.frm.doc.conversion_rate) : this.frm.doc.base_net_total);
|
||||||
|
|
||||||
|
this.set_in_company_currency(this.frm.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.frm.doc.total_taxes_and_charges = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
|
||||||
|
precision("total_taxes_and_charges"));
|
||||||
|
|
||||||
|
this.set_in_company_currency(this.frm.doc, ["total_taxes_and_charges"]);
|
||||||
|
|
||||||
|
// Round grand total as per precision
|
||||||
|
frappe.model.round_floats_in(this.frm.doc, ["grand_total", "base_grand_total"]);
|
||||||
|
|
||||||
|
// rounded totals
|
||||||
|
if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) {
|
||||||
|
this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total);
|
||||||
|
}
|
||||||
|
if(frappe.meta.get_docfield(this.frm.doc.doctype, "base_rounded_total", this.frm.doc.name)) {
|
||||||
|
this.frm.doc.base_rounded_total = Math.round(this.frm.doc.base_grand_total);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_cleanup: function() {
|
_cleanup: function() {
|
||||||
this.frm.doc.base_in_words = this.frm.doc.in_words = this.frm.doc.in_words = "";
|
this.frm.doc.base_in_words = this.frm.doc.in_words = "";
|
||||||
|
|
||||||
if(this.frm.doc["items"] && this.frm.doc["items"].length) {
|
if(this.frm.doc["items"] && this.frm.doc["items"].length) {
|
||||||
if(!frappe.meta.get_docfield(this.frm.doc["items"][0].doctype, "item_tax_amount", this.frm.doctype)) {
|
if(!frappe.meta.get_docfield(this.frm.doc["items"][0].doctype, "item_tax_amount", this.frm.doctype)) {
|
||||||
@@ -288,7 +378,6 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(this.frm.doc["taxes"] && this.frm.doc["taxes"].length) {
|
if(this.frm.doc["taxes"] && this.frm.doc["taxes"].length) {
|
||||||
var temporary_fields = ["tax_amount_for_current_item", "grand_total_for_current_item",
|
var temporary_fields = ["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"]
|
||||||
@@ -307,79 +396,26 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
calculate_totals: function() {
|
|
||||||
// Changing sequence can cause roundiing issue and on-screen discrepency
|
|
||||||
|
|
||||||
var tax_count = this.frm.doc["taxes"] ? this.frm.doc["taxes"].length : 0;
|
|
||||||
this.frm.doc.base_grand_total = flt(tax_count ? this.frm.doc["taxes"][tax_count - 1].total : this.frm.doc.base_net_total);
|
|
||||||
|
|
||||||
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"], 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;
|
|
||||||
|
|
||||||
this.frm.doc.total_taxes_and_charges = flt(this.frm.doc.grand_total - this.frm.doc.net_total
|
|
||||||
+ flt(this.frm.doc.discount_amount), precision("total_taxes_and_charges"));
|
|
||||||
} else {
|
|
||||||
// other charges added/deducted
|
|
||||||
this.frm.doc.base_taxes_and_charges_added = 0.0
|
|
||||||
this.frm.doc.base_taxes_and_charges_deducted = 0.0
|
|
||||||
if(tax_count) {
|
|
||||||
this.frm.doc.base_taxes_and_charges_added = frappe.utils.sum($.map(this.frm.doc["taxes"],
|
|
||||||
function(tax) { return (tax.add_deduct_tax == "Add"
|
|
||||||
&& in_list(["Valuation and Total", "Total"], tax.category)) ?
|
|
||||||
tax.tax_amount : 0.0; }));
|
|
||||||
|
|
||||||
this.frm.doc.base_taxes_and_charges_deducted = frappe.utils.sum($.map(this.frm.doc["taxes"],
|
|
||||||
function(tax) { return (tax.add_deduct_tax == "Deduct"
|
|
||||||
&& in_list(["Valuation and Total", "Total"], tax.category)) ?
|
|
||||||
tax.tax_amount : 0.0; }));
|
|
||||||
|
|
||||||
frappe.model.round_floats_in(this.frm.doc,
|
|
||||||
["base_taxes_and_charges_added", "base_taxes_and_charges_deducted"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.frm.doc.grand_total = flt((this.frm.doc.base_taxes_and_charges_added || this.frm.doc.base_taxes_and_charges_deducted) ?
|
|
||||||
flt(this.frm.doc.base_grand_total / this.frm.doc.conversion_rate) : this.frm.doc.net_total);
|
|
||||||
|
|
||||||
this.frm.doc.total_taxes_and_charges = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
|
|
||||||
precision("total_taxes_and_charges"));
|
|
||||||
|
|
||||||
this.frm.doc.taxes_and_charges_added = flt(this.frm.doc.base_taxes_and_charges_added /
|
|
||||||
this.frm.doc.conversion_rate, precision("taxes_and_charges_added"));
|
|
||||||
this.frm.doc.taxes_and_charges_deducted = flt(this.frm.doc.base_taxes_and_charges_deducted /
|
|
||||||
this.frm.doc.conversion_rate, precision("taxes_and_charges_deducted"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Round grand total as per precision
|
|
||||||
this.frm.doc.base_grand_total = flt(this.frm.doc.base_grand_total, precision("base_grand_total"));
|
|
||||||
this.frm.doc.grand_total = flt(this.frm.doc.grand_total, precision("grand_total"));
|
|
||||||
|
|
||||||
// rounded totals
|
|
||||||
if(frappe.meta.get_docfield(this.frm.doc.doctype, "base_rounded_total", this.frm.doc.name)) {
|
|
||||||
this.frm.doc.base_rounded_total = Math.round(this.frm.doc.base_grand_total);
|
|
||||||
}
|
|
||||||
if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) {
|
|
||||||
this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
apply_discount_amount: function() {
|
apply_discount_amount: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
var distributed_amount = 0.0;
|
var distributed_amount = 0.0;
|
||||||
|
|
||||||
if (this.frm.doc.discount_amount) {
|
if (this.frm.doc.discount_amount) {
|
||||||
|
if(!this.frm.doc.apply_discount_on)
|
||||||
|
frappe.throw(__("Please select Apply Discount On"));
|
||||||
|
|
||||||
this.frm.set_value("base_discount_amount",
|
this.frm.set_value("base_discount_amount",
|
||||||
flt(this.frm.doc.discount_amount * this.frm.doc.conversion_rate, precision("base_discount_amount")))
|
flt(this.frm.doc.discount_amount * this.frm.doc.conversion_rate, precision("base_discount_amount")))
|
||||||
|
|
||||||
var grand_total_for_discount_amount = this.get_grand_total_for_discount_amount();
|
var total_for_discount_amount = this.get_total_for_discount_amount();
|
||||||
// calculate item amount after Discount Amount
|
// calculate item amount after Discount Amount
|
||||||
if (grand_total_for_discount_amount) {
|
if (total_for_discount_amount) {
|
||||||
$.each(this.frm.doc["items"] || [], function(i, item) {
|
$.each(this.frm.doc["items"] || [], function(i, item) {
|
||||||
distributed_amount = flt(me.frm.doc.base_discount_amount) * item.base_amount / grand_total_for_discount_amount;
|
distributed_amount = flt(me.frm.doc.discount_amount) * item.net_amount / total_for_discount_amount;
|
||||||
item.base_amount = flt(item.base_amount - distributed_amount, precision("base_amount", item));
|
item.net_amount = flt(item.net_amount - distributed_amount, precision("base_amount", item));
|
||||||
|
item.net_rate = flt(item.net_amount / item.qty, precision("net_rate", item));
|
||||||
|
|
||||||
|
me.set_in_company_currency(item, ["net_rate", "net_amount"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.discount_amount_applied = true;
|
this.discount_amount_applied = true;
|
||||||
@@ -390,34 +426,37 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
get_grand_total_for_discount_amount: function() {
|
get_total_for_discount_amount: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
var total_actual_tax = 0.0;
|
|
||||||
var actual_taxes_dict = {};
|
|
||||||
|
|
||||||
$.each(this.frm.doc["taxes"] || [], function(i, tax) {
|
if(this.frm.doc.apply_discount_on == "Net Total") {
|
||||||
if (tax.charge_type == "Actual")
|
return this.frm.doc.net_total
|
||||||
actual_taxes_dict[tax.idx] = tax.tax_amount;
|
} else {
|
||||||
else if (actual_taxes_dict[tax.row_id] !== null) {
|
var total_actual_tax = 0.0;
|
||||||
actual_tax_amount = flt(actual_taxes_dict[tax.row_id]) * flt(tax.rate) / 100;
|
var actual_taxes_dict = {};
|
||||||
actual_taxes_dict[tax.idx] = actual_tax_amount;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$.each(actual_taxes_dict, function(key, value) {
|
$.each(this.frm.doc["taxes"] || [], function(i, tax) {
|
||||||
if (value)
|
if (tax.charge_type == "Actual")
|
||||||
total_actual_tax += value;
|
actual_taxes_dict[tax.idx] = tax.tax_amount;
|
||||||
});
|
else if (actual_taxes_dict[tax.row_id] !== null) {
|
||||||
|
actual_tax_amount = flt(actual_taxes_dict[tax.row_id]) * flt(tax.rate) / 100;
|
||||||
|
actual_taxes_dict[tax.idx] = actual_tax_amount;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
grand_total_for_discount_amount = flt(this.frm.doc.base_grand_total - total_actual_tax,
|
$.each(actual_taxes_dict, function(key, value) {
|
||||||
precision("base_grand_total"));
|
if (value) total_actual_tax += value;
|
||||||
return grand_total_for_discount_amount;
|
});
|
||||||
|
|
||||||
|
return flt(this.frm.doc.grand_total - total_actual_tax, precision("grand_total"));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
calculate_total_advance: function(update_paid_amount) {
|
calculate_total_advance: function(update_paid_amount) {
|
||||||
this.frm.doc.total_advance = flt(frappe.utils.sum(
|
var total_allocated_amount = frappe.utils.sum($.map(this.frm.doc["advances"] || [], function(adv) {
|
||||||
$.map(this.frm.doc["advances"] || [], function(adv) { return adv.allocated_amount })
|
return flt(adv.allocated_amount, precision("allocated_amount", adv))
|
||||||
), precision("total_advance"));
|
}));
|
||||||
|
this.frm.doc.total_advance = flt(total_allocated_amount, precision("total_advance"));
|
||||||
|
|
||||||
this.calculate_outstanding_amount(update_paid_amount);
|
this.calculate_outstanding_amount(update_paid_amount);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,23 +274,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
this.apply_pricing_rule(frappe.get_doc(cdt, cdn), true);
|
this.apply_pricing_rule(frappe.get_doc(cdt, cdn), true);
|
||||||
},
|
},
|
||||||
|
|
||||||
// tax rate
|
|
||||||
rate: function(doc, cdt, cdn) {
|
|
||||||
this.calculate_taxes_and_totals();
|
|
||||||
},
|
|
||||||
|
|
||||||
row_id: function(doc, cdt, cdn) {
|
|
||||||
var tax = frappe.get_doc(cdt, cdn);
|
|
||||||
try {
|
|
||||||
this.validate_on_previous_row(tax);
|
|
||||||
this.calculate_taxes_and_totals();
|
|
||||||
} catch(e) {
|
|
||||||
tax.row_id = null;
|
|
||||||
refresh_field("row_id", tax.name, tax.parentfield);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
set_dynamic_labels: function() {
|
set_dynamic_labels: function() {
|
||||||
// What TODO? should we make price list system non-mandatory?
|
// What TODO? should we make price list system non-mandatory?
|
||||||
this.frm.toggle_reqd("plc_conversion_rate",
|
this.frm.toggle_reqd("plc_conversion_rate",
|
||||||
@@ -302,6 +285,113 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
this.frm.refresh_fields();
|
this.frm.refresh_fields();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
change_form_labels: function(company_currency) {
|
||||||
|
var me = this;
|
||||||
|
var field_label_map = {};
|
||||||
|
|
||||||
|
var setup_field_label_map = function(fields_list, currency) {
|
||||||
|
$.each(fields_list, function(i, fname) {
|
||||||
|
var docfield = frappe.meta.docfield_map[me.frm.doc.doctype][fname];
|
||||||
|
if(docfield) {
|
||||||
|
var label = __(docfield.label || "").replace(/\([^\)]*\)/g, "");
|
||||||
|
field_label_map[fname] = label.trim() + " (" + currency + ")";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
setup_field_label_map(["base_total", "base_net_total", "base_total_taxes_and_charges",
|
||||||
|
"base_discount_amount", "base_grand_total", "base_rounded_total", "base_in_words",
|
||||||
|
"base_taxes_and_charges_added", "base_taxes_and_charges_deducted", "total_amount_to_pay",
|
||||||
|
"outstanding_amount", "total_advance", "paid_amount", "write_off_amount"], company_currency);
|
||||||
|
|
||||||
|
setup_field_label_map(["total", "net_total", "total_taxes_and_charges", "discount_amount",
|
||||||
|
"grand_total", "taxes_and_charges_added", "taxes_and_charges_deducted",
|
||||||
|
"rounded_total", "in_words"], this.frm.doc.currency);
|
||||||
|
|
||||||
|
cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency
|
||||||
|
+ " = [?] " + company_currency)
|
||||||
|
|
||||||
|
if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) {
|
||||||
|
cur_frm.set_df_property("plc_conversion_rate", "description", "1 " + this.frm.doc.price_list_currency
|
||||||
|
+ " = [?] " + company_currency)
|
||||||
|
}
|
||||||
|
|
||||||
|
// toggle fields
|
||||||
|
this.frm.toggle_display(["conversion_rate", "base_total", "base_net_total", "base_total_taxes_and_charges",
|
||||||
|
"base_taxes_and_charges_added", "base_taxes_and_charges_deducted",
|
||||||
|
"base_grand_total", "base_rounded_total", "base_in_words", "base_discount_amount"],
|
||||||
|
this.frm.doc.currency != company_currency);
|
||||||
|
|
||||||
|
this.frm.toggle_display(["plc_conversion_rate", "price_list_currency"],
|
||||||
|
this.frm.doc.price_list_currency != company_currency);
|
||||||
|
|
||||||
|
// set labels
|
||||||
|
$.each(field_label_map, function(fname, label) {
|
||||||
|
me.frm.fields_dict[fname].set_label(label);
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
change_grid_labels: function(company_currency) {
|
||||||
|
var me = this;
|
||||||
|
var field_label_map = {};
|
||||||
|
|
||||||
|
var setup_field_label_map = function(fields_list, currency, parentfield) {
|
||||||
|
var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype;
|
||||||
|
$.each(fields_list, function(i, fname) {
|
||||||
|
var docfield = frappe.meta.docfield_map[grid_doctype][fname];
|
||||||
|
if(docfield) {
|
||||||
|
var label = __(docfield.label || "").replace(/\([^\)]*\)/g, "");
|
||||||
|
field_label_map[grid_doctype + "-" + fname] =
|
||||||
|
label.trim() + " (" + currency + ")";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_field_label_map(["base_rate", "base_net_rate", "base_price_list_rate", "base_amount", "base_net_amount"],
|
||||||
|
company_currency, "items");
|
||||||
|
|
||||||
|
setup_field_label_map(["rate", "net_rate", "price_list_rate", "amount", "net_amount"],
|
||||||
|
this.frm.doc.currency, "items");
|
||||||
|
|
||||||
|
if(this.frm.fields_dict["taxes"]) {
|
||||||
|
setup_field_label_map(["tax_amount", "total", "tax_amount_after_discount"], this.frm.doc.currency, "taxes");
|
||||||
|
|
||||||
|
setup_field_label_map(["base_tax_amount", "base_total", "base_tax_amount_after_discount"], company_currency, "taxes");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.frm.fields_dict["advances"]) {
|
||||||
|
setup_field_label_map(["advance_amount", "allocated_amount"], company_currency, "advances");
|
||||||
|
}
|
||||||
|
|
||||||
|
// toggle columns
|
||||||
|
var item_grid = this.frm.fields_dict["items"].grid;
|
||||||
|
$.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) {
|
||||||
|
if(frappe.meta.get_docfield(item_grid.doctype, fname))
|
||||||
|
item_grid.set_column_disp(fname, me.frm.doc.currency != company_currency);
|
||||||
|
});
|
||||||
|
|
||||||
|
var show = (cint(cur_frm.doc.discount_amount)) ||
|
||||||
|
((cur_frm.doc.taxes || []).filter(function(d) {return d.included_in_print_rate===1}).length);
|
||||||
|
|
||||||
|
$.each(["net_rate", "net_amount"], function(i, fname) {
|
||||||
|
if(frappe.meta.get_docfield(item_grid.doctype, fname))
|
||||||
|
item_grid.set_column_disp(fname, show);
|
||||||
|
});
|
||||||
|
|
||||||
|
$.each(["base_net_rate", "base_net_amount"], function(i, fname) {
|
||||||
|
if(frappe.meta.get_docfield(item_grid.doctype, fname))
|
||||||
|
item_grid.set_column_disp(fname, (show && (me.frm.doc.currency != company_currency)));
|
||||||
|
});
|
||||||
|
|
||||||
|
// set labels
|
||||||
|
var $wrapper = $(this.frm.wrapper);
|
||||||
|
$.each(field_label_map, function(fname, label) {
|
||||||
|
fname = fname.split("-");
|
||||||
|
var df = frappe.meta.get_docfield(fname[0], fname[1], me.frm.doc.name);
|
||||||
|
if(df) df.label = label;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
recalculate: function() {
|
recalculate: function() {
|
||||||
this.calculate_taxes_and_totals();
|
this.calculate_taxes_and_totals();
|
||||||
},
|
},
|
||||||
@@ -409,9 +499,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
apply_price_list: function(item) {
|
apply_price_list: function(item) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var args = this._get_args(item);
|
var args = this._get_args(item);
|
||||||
if(!args.item_list.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return this.frm.call({
|
return this.frm.call({
|
||||||
method: "erpnext.stock.get_item_details.apply_price_list",
|
method: "erpnext.stock.get_item_details.apply_price_list",
|
||||||
args: { args: args },
|
args: { args: args },
|
||||||
@@ -421,66 +509,15 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
me.frm.set_value("price_list_currency", r.message.parent.price_list_currency);
|
me.frm.set_value("price_list_currency", r.message.parent.price_list_currency);
|
||||||
me.frm.set_value("plc_conversion_rate", r.message.parent.plc_conversion_rate);
|
me.frm.set_value("plc_conversion_rate", r.message.parent.plc_conversion_rate);
|
||||||
me.in_apply_price_list = false;
|
me.in_apply_price_list = false;
|
||||||
me._set_values_for_item_list(r.message.children);
|
|
||||||
|
if(args.item_list.length) {
|
||||||
|
me._set_values_for_item_list(r.message.children);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
included_in_print_rate: function(doc, cdt, cdn) {
|
|
||||||
var tax = frappe.get_doc(cdt, cdn);
|
|
||||||
try {
|
|
||||||
this.validate_on_previous_row(tax);
|
|
||||||
this.validate_inclusive_tax(tax);
|
|
||||||
this.calculate_taxes_and_totals();
|
|
||||||
} catch(e) {
|
|
||||||
tax.included_in_print_rate = 0;
|
|
||||||
refresh_field("included_in_print_rate", tax.name, tax.parentfield);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
validate_on_previous_row: function(tax) {
|
|
||||||
// validate if a valid row id is mentioned in case of
|
|
||||||
// On Previous Row Amount and On Previous Row Total
|
|
||||||
if((["On Previous Row Amount", "On Previous Row Total"].indexOf(tax.charge_type) != -1) &&
|
|
||||||
(!tax.row_id || cint(tax.row_id) >= tax.idx)) {
|
|
||||||
var msg = __("Please specify a valid Row ID for row {0} in table {1}", [tax.idx, __(tax.doctype)])
|
|
||||||
frappe.throw(msg);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
validate_inclusive_tax: function(tax) {
|
|
||||||
var actual_type_error = function() {
|
|
||||||
var msg = __("Actual type tax cannot be included in Item rate in row {0}", [tax.idx])
|
|
||||||
frappe.throw(msg);
|
|
||||||
};
|
|
||||||
|
|
||||||
var on_previous_row_error = function(row_range) {
|
|
||||||
var msg = __("For row {0} in {1}. To include {2} in Item rate, rows {3} must also be included",
|
|
||||||
[tax.idx, __(tax.doctype), tax.charge_type, row_range])
|
|
||||||
frappe.throw(msg);
|
|
||||||
};
|
|
||||||
|
|
||||||
if(cint(tax.included_in_print_rate)) {
|
|
||||||
if(tax.charge_type == "Actual") {
|
|
||||||
// inclusive tax cannot be of type Actual
|
|
||||||
actual_type_error();
|
|
||||||
} else if(tax.charge_type == "On Previous Row Amount" &&
|
|
||||||
!cint(this.frm.doc["taxes"][tax.row_id - 1].included_in_print_rate)) {
|
|
||||||
// referred row should also be an inclusive tax
|
|
||||||
on_previous_row_error(tax.row_id);
|
|
||||||
} else if(tax.charge_type == "On Previous Row Total") {
|
|
||||||
var taxes_not_included = $.map(this.frm.doc["taxes"].slice(0, tax.row_id),
|
|
||||||
function(t) { return cint(t.included_in_print_rate) ? null : t; });
|
|
||||||
if(taxes_not_included.length > 0) {
|
|
||||||
// all rows above this tax should be inclusive
|
|
||||||
on_previous_row_error(tax.row_id == 1 ? "1" : "1 - " + tax.row_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
get_item_wise_taxes_html: function() {
|
get_item_wise_taxes_html: function() {
|
||||||
var item_tax = {};
|
var item_tax = {};
|
||||||
var tax_accounts = [];
|
var tax_accounts = [];
|
||||||
@@ -560,24 +597,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
return valid;
|
return valid;
|
||||||
},
|
},
|
||||||
|
|
||||||
validate_conversion_rate: function() {
|
|
||||||
this.frm.doc.conversion_rate = flt(this.frm.doc.conversion_rate, precision("conversion_rate"));
|
|
||||||
var conversion_rate_label = frappe.meta.get_label(this.frm.doc.doctype, "conversion_rate",
|
|
||||||
this.frm.doc.name);
|
|
||||||
var company_currency = this.get_company_currency();
|
|
||||||
|
|
||||||
if(!this.frm.doc.conversion_rate) {
|
|
||||||
frappe.throw(repl('%(conversion_rate_label)s' +
|
|
||||||
__(' is mandatory. Maybe Currency Exchange record is not created for ') +
|
|
||||||
'%(from_currency)s' + __(" to ") + '%(to_currency)s',
|
|
||||||
{
|
|
||||||
"conversion_rate_label": conversion_rate_label,
|
|
||||||
"from_currency": this.frm.doc.currency,
|
|
||||||
"to_currency": company_currency
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
get_terms: function() {
|
get_terms: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
if(this.frm.doc.tc_name) {
|
if(this.frm.doc.tc_name) {
|
||||||
@@ -656,3 +675,40 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frappe.ui.form.on(cur_frm.doctype + "Item", "rate", function(frm, cdt, cdn) {
|
||||||
|
var item = frappe.get_doc(cdt, cdn);
|
||||||
|
frappe.model.round_floats_in(item, ["rate", "price_list_rate"]);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.calculate_taxes_and_totals();
|
||||||
|
})
|
||||||
|
|
||||||
|
frappe.ui.form.on(cur_frm.cscript.tax_table, "rate", function(frm, cdt, cdn) {
|
||||||
|
cur_frm.cscript.calculate_taxes_and_totals();
|
||||||
|
})
|
||||||
|
|
||||||
|
frappe.ui.form.on(cur_frm.cscript.tax_table, "tax_amount", function(frm, cdt, cdn) {
|
||||||
|
cur_frm.cscript.calculate_taxes_and_totals();
|
||||||
|
})
|
||||||
|
|
||||||
|
frappe.ui.form.on(cur_frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) {
|
||||||
|
cur_frm.cscript.calculate_taxes_and_totals();
|
||||||
|
})
|
||||||
|
|
||||||
|
frappe.ui.form.on(cur_frm.cscript.tax_table, "included_in_print_rate", function(frm, cdt, cdn) {
|
||||||
|
cur_frm.cscript.calculate_taxes_and_totals();
|
||||||
|
})
|
||||||
|
|
||||||
|
frappe.ui.form.on(cur_frm.doctype, "apply_discount_on", function(frm) {
|
||||||
|
cur_frm.cscript.calculate_taxes_and_totals();
|
||||||
|
})
|
||||||
|
|
||||||
|
frappe.ui.form.on(cur_frm.doctype, "discount_amount", function(frm) {
|
||||||
|
cur_frm.cscript.calculate_taxes_and_totals();
|
||||||
|
})
|
||||||
|
|||||||
@@ -111,34 +111,54 @@ erpnext.feature_setup.feature_dict = {
|
|||||||
'Sales Order': {'items':['page_break']}
|
'Sales Order': {'items':['page_break']}
|
||||||
},
|
},
|
||||||
'fs_exports': {
|
'fs_exports': {
|
||||||
'Delivery Note': {'fields':['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total'],'items':['base_price_list_rate','base_amount','base_rate']},
|
'Delivery Note': {
|
||||||
|
'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total',
|
||||||
|
'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'],
|
||||||
|
'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
|
||||||
|
},
|
||||||
'POS Setting': {'fields':['conversion_rate','currency']},
|
'POS Setting': {'fields':['conversion_rate','currency']},
|
||||||
'Quotation': {'fields':['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total'],'items':['base_price_list_rate','base_amount','base_rate']},
|
'Quotation': {
|
||||||
'Sales Invoice': {'fields':['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total'],'items':['base_price_list_rate','base_amount','base_rate']},
|
'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total',
|
||||||
|
'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'],
|
||||||
|
'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
|
||||||
|
},
|
||||||
|
'Sales Invoice': {
|
||||||
|
'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total',
|
||||||
|
'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'],
|
||||||
|
'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
|
||||||
|
},
|
||||||
'Sales BOM': {'fields':['currency']},
|
'Sales BOM': {'fields':['currency']},
|
||||||
'Sales Order': {'fields':['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total'],'items':['base_price_list_rate','base_amount','base_rate']}
|
'Sales Order': {
|
||||||
|
'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total',
|
||||||
|
'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'],
|
||||||
|
'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'fs_imports': {
|
'fs_imports': {
|
||||||
'Purchase Invoice': {
|
'Purchase Invoice': {
|
||||||
'fields': ['conversion_rate', 'currency', 'base_grand_total',
|
'fields': ['conversion_rate', 'currency', 'base_grand_total', 'base_discount_amount',
|
||||||
'base_in_words', 'base_net_total', 'base_taxes_and_charges_added',
|
'base_in_words', 'base_total', 'base_net_total', 'base_taxes_and_charges_added',
|
||||||
'base_taxes_and_charges_deducted'],
|
'base_taxes_and_charges_deducted', 'base_total_taxes_and_charges'],
|
||||||
'items': ['base_price_list_rate', 'base_amount','base_rate']
|
'items': ['base_price_list_rate', 'base_amount','base_rate', 'base_net_rate', 'base_net_amount']
|
||||||
},
|
},
|
||||||
'Purchase Order': {
|
'Purchase Order': {
|
||||||
'fields': ['conversion_rate','currency', 'base_grand_total',
|
'fields': ['conversion_rate','currency', 'base_grand_total', 'base_discount_amount',
|
||||||
'base_in_words', 'base_net_total', 'base_taxes_and_charges_added',
|
'base_in_words', 'base_total', 'base_net_total', 'base_taxes_and_charges_added',
|
||||||
'base_taxes_and_charges_deducted'],
|
'base_taxes_and_charges_deducted', 'base_total_taxes_and_charges'],
|
||||||
'items': ['base_price_list_rate', 'base_amount','base_rate']
|
'items': ['base_price_list_rate', 'base_amount','base_rate', 'base_net_rate', 'base_net_amount']
|
||||||
},
|
},
|
||||||
'Purchase Receipt': {
|
'Purchase Receipt': {
|
||||||
'fields': ['conversion_rate', 'currency','base_grand_total', 'base_in_words',
|
'fields': ['conversion_rate', 'currency','base_grand_total', 'base_in_words', 'base_total',
|
||||||
'base_net_total', 'base_taxes_and_charges_added', 'base_taxes_and_charges_deducted'],
|
'base_net_total', 'base_taxes_and_charges_added', 'base_taxes_and_charges_deducted',
|
||||||
'items': ['base_price_list_rate','base_amount','base_rate']
|
'base_total_taxes_and_charges', 'base_discount_amount'],
|
||||||
|
'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
|
||||||
},
|
},
|
||||||
'Supplier Quotation': {
|
'Supplier Quotation': {
|
||||||
'fields':['conversion_rate','currency']
|
'fields': ['conversion_rate', 'currency','base_grand_total', 'base_in_words', 'base_total',
|
||||||
|
'base_net_total', 'base_taxes_and_charges_added', 'base_taxes_and_charges_deducted',
|
||||||
|
'base_total_taxes_and_charges', 'base_discount_amount'],
|
||||||
|
'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
|
|
||||||
{% include 'selling/sales_common.js' %}
|
{% include 'selling/sales_common.js' %}
|
||||||
{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %}
|
|
||||||
|
|
||||||
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||||
onload: function(doc, dt, dn) {
|
onload: function(doc, dt, dn) {
|
||||||
@@ -25,7 +24,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
|||||||
cur_frm.add_custom_button(__('Set as Lost'),
|
cur_frm.add_custom_button(__('Set as Lost'),
|
||||||
cur_frm.cscript['Declare Order Lost'], "icon-exclamation", "btn-default");
|
cur_frm.cscript['Declare Order Lost'], "icon-exclamation", "btn-default");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.frm.doc.docstatus===0) {
|
if (this.frm.doc.docstatus===0) {
|
||||||
@@ -159,4 +158,6 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
|||||||
cur_frm.email_doc(frappe.boot.notification_settings.quotation_message);
|
cur_frm.email_doc(frappe.boot.notification_settings.quotation_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frappe.ui.form.on("Quotation Item", "items_on_form_rendered", function(frm, cdt, cdn) {
|
||||||
|
// enable tax_amount field if Actual
|
||||||
|
})
|
||||||
|
|||||||
@@ -312,9 +312,20 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 0
|
"read_only": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_net_total",
|
"fieldname": "base_net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
|
"hidden": 0,
|
||||||
"label": "Net Total (Company Currency)",
|
"label": "Net Total (Company Currency)",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"oldfieldname": "net_total",
|
"oldfieldname": "net_total",
|
||||||
@@ -331,12 +342,23 @@
|
|||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "net_total",
|
"fieldname": "net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
|
"hidden": 0,
|
||||||
"label": "Net Total",
|
"label": "Net Total",
|
||||||
"options": "currency",
|
"options": "currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -389,6 +411,7 @@
|
|||||||
"oldfieldtype": "Table",
|
"oldfieldtype": "Table",
|
||||||
"options": "Sales Taxes and Charges",
|
"options": "Sales Taxes and Charges",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
|
"print_hide": 0,
|
||||||
"read_only": 0
|
"read_only": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -430,12 +453,23 @@
|
|||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"default": "Grand Total",
|
||||||
|
"fieldname": "apply_discount_on",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Apply Discount On",
|
||||||
|
"options": "\nGrand Total\nNet Total",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "discount_amount",
|
"fieldname": "discount_amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Discount Amount",
|
"label": "Discount Amount",
|
||||||
"options": "currency",
|
"options": "currency",
|
||||||
"permlevel": 0
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_discount_amount",
|
"fieldname": "base_discount_amount",
|
||||||
@@ -810,7 +844,7 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"max_attachments": 1,
|
"max_attachments": 1,
|
||||||
"modified": "2015-02-20 05:16:20.664025",
|
"modified": "2015-02-23 01:18:17.421144",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Quotation",
|
"name": "Quotation",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"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",
|
||||||
@@ -187,6 +187,16 @@
|
|||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Net Rate",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "amount",
|
"fieldname": "amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -204,6 +214,16 @@
|
|||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "col_break3",
|
"fieldname": "col_break3",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
@@ -213,7 +233,7 @@
|
|||||||
"fieldname": "base_rate",
|
"fieldname": "base_rate",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"label": "Basic 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",
|
||||||
@@ -225,6 +245,15 @@
|
|||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate (Company Currency)",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_amount",
|
"fieldname": "base_amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -241,6 +270,16 @@
|
|||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "pricing_rule",
|
"fieldname": "pricing_rule",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@@ -349,7 +388,7 @@
|
|||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-02-19 01:07:01.742936",
|
"modified": "2015-02-23 00:48:08.477241",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Quotation Item",
|
"name": "Quotation Item",
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
{% include 'selling/sales_common.js' %}
|
{% include 'selling/sales_common.js' %}
|
||||||
{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %}
|
|
||||||
|
|
||||||
erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({
|
erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({
|
||||||
refresh: function(doc, dt, dn) {
|
refresh: function(doc, dt, dn) {
|
||||||
|
|||||||
@@ -325,6 +325,16 @@
|
|||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_net_total",
|
"fieldname": "base_net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -343,6 +353,16 @@
|
|||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "net_total",
|
"fieldname": "net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -420,6 +440,12 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_46",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_total_taxes_and_charges",
|
"fieldname": "base_total_taxes_and_charges",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -433,7 +459,23 @@
|
|||||||
"width": "150px"
|
"width": "150px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_46",
|
"fieldname": "section_break_48",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Grand Total",
|
||||||
|
"fieldname": "apply_discount_on",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Apply Discount On",
|
||||||
|
"options": "\nGrand Total\nNet Total",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_50",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
@@ -1034,7 +1076,7 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"modified": "2015-02-20 05:16:18.207123",
|
"modified": "2015-02-23 15:40:17.414233",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Sales Order",
|
"name": "Sales Order",
|
||||||
|
|||||||
@@ -1,455 +1,507 @@
|
|||||||
{
|
{
|
||||||
"autoname": "hash",
|
"autoname": "hash",
|
||||||
"creation": "2013-03-07 11:42:58",
|
"creation": "2013-03-07 11:42:58",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"fieldname": "item_code",
|
"fieldname": "item_code",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"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_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": "col_break1",
|
"fieldname": "col_break1",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "item_name",
|
"fieldname": "item_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"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": "150",
|
"print_width": "150",
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"width": "150"
|
"width": "150"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "section_break_5",
|
"fieldname": "section_break_5",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": ""
|
"precision": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "description",
|
"fieldname": "description",
|
||||||
"fieldtype": "Small Text",
|
"fieldtype": "Small Text",
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
"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_width": "300px",
|
"print_width": "300px",
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 1,
|
"search_index": 1,
|
||||||
"width": "300px"
|
"width": "300px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_7",
|
"fieldname": "column_break_7",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": ""
|
"precision": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"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_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Quantity",
|
"label": "Quantity",
|
||||||
"oldfieldname": "qty",
|
"oldfieldname": "qty",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_width": "100px",
|
"print_width": "100px",
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"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": "70px",
|
"print_width": "70px",
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"width": "70px"
|
"width": "70px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"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": "70px",
|
"print_width": "70px",
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"width": "70px"
|
"width": "70px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"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",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"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_width": "70px",
|
"print_width": "70px",
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"width": "70px"
|
"width": "70px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"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_break_simple1",
|
"fieldname": "section_break_simple1",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "rate",
|
"fieldname": "rate",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"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_width": "100px",
|
"print_width": "100px",
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "amount",
|
"fieldname": "amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Amount",
|
"label": "Amount",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"oldfieldname": "export_amount",
|
"oldfieldname": "export_amount",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"options": "currency",
|
"options": "currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_width": "100px",
|
"print_width": "100px",
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"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",
|
||||||
"label": "Basic Rate (Company Currency)",
|
"label": "Basic 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,
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_amount",
|
"fieldname": "base_amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Amount (Company Currency)",
|
"label": "Amount (Company Currency)",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"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,
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"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": "warehouse_and_reference",
|
"fieldname": "section_break_24",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Warehouse and Reference",
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_27",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "warehouse_and_reference",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Warehouse and Reference",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "warehouse",
|
"fieldname": "warehouse",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Reserved Warehouse",
|
"label": "Reserved Warehouse",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"oldfieldname": "reserved_warehouse",
|
"oldfieldname": "reserved_warehouse",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
"options": "Warehouse",
|
"options": "Warehouse",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"print_width": "150px",
|
"print_width": "150px",
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"width": "150px"
|
"width": "150px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "prevdoc_docname",
|
"fieldname": "prevdoc_docname",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
"label": "Quotation",
|
"label": "Quotation",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "prevdoc_docname",
|
"oldfieldname": "prevdoc_docname",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
"options": "Quotation",
|
"options": "Quotation",
|
||||||
"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 Name",
|
"label": "Brand Name",
|
||||||
"oldfieldname": "brand",
|
"oldfieldname": "brand",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
"options": "Brand",
|
"options": "Brand",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"search_index": 1
|
"search_index": 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
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
"fieldname": "page_break",
|
"fieldname": "page_break",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Page Break",
|
"label": "Page Break",
|
||||||
"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
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"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": "projected_qty",
|
"fieldname": "projected_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"label": "Projected Qty",
|
"label": "Projected Qty",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "projected_qty",
|
"oldfieldname": "projected_qty",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"print_width": "70px",
|
"print_width": "70px",
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"width": "70px"
|
"width": "70px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
"fieldname": "actual_qty",
|
"fieldname": "actual_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "Actual Qty",
|
"label": "Actual Qty",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"print_width": "70px",
|
"print_width": "70px",
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"width": "70px"
|
"width": "70px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "delivered_qty",
|
"fieldname": "delivered_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"label": "Delivered Qty",
|
"label": "Delivered Qty",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "delivered_qty",
|
"oldfieldname": "delivered_qty",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"print_width": "100px",
|
"print_width": "100px",
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "billed_amt",
|
"fieldname": "billed_amt",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Billed Amt",
|
"label": "Billed Amt",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "currency",
|
"options": "currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "For Production",
|
"description": "For Production",
|
||||||
"fieldname": "planned_qty",
|
"fieldname": "planned_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
"label": "Planned Quantity",
|
"label": "Planned Quantity",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "planned_qty",
|
"oldfieldname": "planned_qty",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"print_width": "50px",
|
"print_width": "50px",
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"report_hide": 1,
|
"report_hide": 1,
|
||||||
"width": "50px"
|
"width": "50px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "For Production",
|
"description": "For Production",
|
||||||
"fieldname": "produced_qty",
|
"fieldname": "produced_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
"label": "Produced Quantity",
|
"label": "Produced Quantity",
|
||||||
"oldfieldname": "produced_qty",
|
"oldfieldname": "produced_qty",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"print_width": "50px",
|
"print_width": "50px",
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"report_hide": 1,
|
"report_hide": 1,
|
||||||
"width": "50px"
|
"width": "50px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"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
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Used for Production Plan",
|
"description": "Used for Production Plan",
|
||||||
"fieldname": "transaction_date",
|
"fieldname": "transaction_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"label": "Sales Order Date",
|
"label": "Sales Order Date",
|
||||||
"oldfieldname": "transaction_date",
|
"oldfieldname": "transaction_date",
|
||||||
"oldfieldtype": "Date",
|
"oldfieldtype": "Date",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"report_hide": 1,
|
"report_hide": 1,
|
||||||
"search_index": 0
|
"search_index": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-02-19 01:07:02.025024",
|
"modified": "2015-02-23 15:43:08.156543",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Sales Order Item",
|
"name": "Sales Order Item",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [],
|
"permissions": [],
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC"
|
"sort_order": "DESC"
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ erpnext.SalesAnalytics = frappe.views.TreeGridReport.extend({
|
|||||||
if (posting_date >= from_date && posting_date <= to_date) {
|
if (posting_date >= from_date && posting_date <= to_date) {
|
||||||
var item = me.item_by_name[tl[me.tree_grid.item_key]] ||
|
var item = me.item_by_name[tl[me.tree_grid.item_key]] ||
|
||||||
me.item_by_name['Not Set'];
|
me.item_by_name['Not Set'];
|
||||||
item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_amount : tl.qty);
|
item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_net_amount : tl.qty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ def get_target_distribution_details(filters):
|
|||||||
def get_achieved_details(filters):
|
def get_achieved_details(filters):
|
||||||
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
|
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
|
||||||
|
|
||||||
item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_amount, so.transaction_date,
|
item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_net_amount, so.transaction_date,
|
||||||
st.sales_person, MONTHNAME(so.transaction_date) as month_name
|
st.sales_person, MONTHNAME(so.transaction_date) as month_name
|
||||||
from `tabSales Order Item` soi, `tabSales Order` so, `tabSales Team` st
|
from `tabSales Order Item` soi, `tabSales Order` so, `tabSales Team` st
|
||||||
where soi.parent=so.name and so.docstatus=1 and
|
where soi.parent=so.name and so.docstatus=1 and
|
||||||
@@ -125,7 +125,7 @@ def get_salesperson_item_month_map(filters):
|
|||||||
if (filters["target_on"] == "Amount"):
|
if (filters["target_on"] == "Amount"):
|
||||||
tav_dict.target = flt(sd.target_amount) * month_percentage / 100
|
tav_dict.target = flt(sd.target_amount) * month_percentage / 100
|
||||||
if ad.month_name == month:
|
if ad.month_name == month:
|
||||||
tav_dict.achieved += ad.base_amount
|
tav_dict.achieved += ad.base_net_amount
|
||||||
|
|
||||||
return sim_map
|
return sim_map
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ def execute(filters=None):
|
|||||||
data.append([
|
data.append([
|
||||||
d.name, d.customer, d.territory, d.posting_date, d.item_code,
|
d.name, d.customer, d.territory, d.posting_date, d.item_code,
|
||||||
item_details.get(d.item_code, {}).get("item_group"), item_details.get(d.item_code, {}).get("brand"),
|
item_details.get(d.item_code, {}).get("item_group"), item_details.get(d.item_code, {}).get("brand"),
|
||||||
d.qty, d.base_amount, d.sales_person, d.allocated_percentage, d.contribution_amt
|
d.qty, d.base_net_amount, d.sales_person, d.allocated_percentage, d.contribution_amt
|
||||||
])
|
])
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
@@ -36,8 +36,8 @@ def get_entries(filters):
|
|||||||
date_field = filters["doc_type"] == "Sales Order" and "transaction_date" or "posting_date"
|
date_field = filters["doc_type"] == "Sales Order" and "transaction_date" or "posting_date"
|
||||||
conditions, items = get_conditions(filters, date_field)
|
conditions, items = get_conditions(filters, date_field)
|
||||||
entries = frappe.db.sql("""select dt.name, dt.customer, dt.territory, dt.%s as posting_date,
|
entries = frappe.db.sql("""select dt.name, dt.customer, dt.territory, dt.%s as posting_date,
|
||||||
dt_item.item_code, dt_item.qty, dt_item.base_amount, st.sales_person,
|
dt_item.item_code, dt_item.qty, dt_item.base_net_amount, st.sales_person,
|
||||||
st.allocated_percentage, dt_item.base_amount*st.allocated_percentage/100 as contribution_amt
|
st.allocated_percentage, dt_item.base_net_amount*st.allocated_percentage/100 as contribution_amt
|
||||||
from `tab%s` dt, `tab%s Item` dt_item, `tabSales Team` st
|
from `tab%s` dt, `tab%s Item` dt_item, `tabSales Team` st
|
||||||
where st.parent = dt.name and dt.name = dt_item.parent and st.parenttype = %s
|
where st.parent = dt.name and dt.name = dt_item.parent and st.parenttype = %s
|
||||||
and dt.docstatus = 1 %s order by st.sales_person, dt.name desc""" %
|
and dt.docstatus = 1 %s order by st.sales_person, dt.name desc""" %
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _, msgprint
|
from frappe import _, msgprint
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
import time
|
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
from erpnext.controllers.trends import get_period_date_ranges, get_period_month_ranges
|
from erpnext.controllers.trends import get_period_date_ranges, get_period_month_ranges
|
||||||
|
|
||||||
@@ -81,7 +80,7 @@ def get_target_distribution_details(filters):
|
|||||||
def get_achieved_details(filters):
|
def get_achieved_details(filters):
|
||||||
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
|
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
|
||||||
|
|
||||||
item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_amount, so.transaction_date,
|
item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_net_amount, so.transaction_date,
|
||||||
so.territory, MONTHNAME(so.transaction_date) as month_name
|
so.territory, MONTHNAME(so.transaction_date) as month_name
|
||||||
from `tabSales Order Item` soi, `tabSales Order` so
|
from `tabSales Order Item` soi, `tabSales Order` so
|
||||||
where soi.parent=so.name and so.docstatus=1 and so.transaction_date>=%s and
|
where soi.parent=so.name and so.docstatus=1 and so.transaction_date>=%s and
|
||||||
@@ -125,7 +124,7 @@ def get_territory_item_month_map(filters):
|
|||||||
if (filters["target_on"] == "Amount"):
|
if (filters["target_on"] == "Amount"):
|
||||||
tav_dict.target = flt(td.target_amount) * month_percentage / 100
|
tav_dict.target = flt(td.target_amount) * month_percentage / 100
|
||||||
if ad.month_name == month:
|
if ad.month_name == month:
|
||||||
tav_dict.achieved += ad.base_amount
|
tav_dict.achieved += ad.base_net_amount
|
||||||
|
|
||||||
return tim_map
|
return tim_map
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
|
||||||
|
cur_frm.cscript.tax_table = "Sales Taxes and Charges";
|
||||||
|
{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %}
|
||||||
|
|
||||||
frappe.provide("erpnext.selling");
|
frappe.provide("erpnext.selling");
|
||||||
frappe.require("assets/erpnext/js/controllers/transaction.js");
|
frappe.require("assets/erpnext/js/controllers/transaction.js");
|
||||||
|
|
||||||
{% include "public/js/controllers/accounts.js" %};
|
|
||||||
|
|
||||||
cur_frm.email_field = "contact_email";
|
cur_frm.email_field = "contact_email";
|
||||||
|
|
||||||
erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||||
@@ -16,10 +17,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
this.toggle_editable_price_list_rate();
|
this.toggle_editable_price_list_rate();
|
||||||
},
|
},
|
||||||
|
|
||||||
onload_post_render: function() {
|
|
||||||
cur_frm.get_field("items").grid.set_multiple_add("item_code", "qty");
|
|
||||||
},
|
|
||||||
|
|
||||||
setup_queries: function() {
|
setup_queries: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
@@ -154,24 +151,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
rate: function(doc, cdt, cdn) {
|
|
||||||
var item = frappe.get_doc(cdt, cdn);
|
|
||||||
frappe.model.round_floats_in(item, ["rate", "price_list_rate"]);
|
|
||||||
|
|
||||||
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();
|
|
||||||
},
|
|
||||||
|
|
||||||
discount_amount: function() {
|
|
||||||
this.calculate_taxes_and_totals();
|
|
||||||
},
|
|
||||||
|
|
||||||
commission_rate: function() {
|
commission_rate: function() {
|
||||||
this.calculate_commission();
|
this.calculate_commission();
|
||||||
refresh_field("total_commission");
|
refresh_field("total_commission");
|
||||||
@@ -321,98 +300,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
refresh_field('sales_bom_help');
|
refresh_field('sales_bom_help');
|
||||||
},
|
|
||||||
|
|
||||||
change_form_labels: function(company_currency) {
|
|
||||||
var me = this;
|
|
||||||
var field_label_map = {};
|
|
||||||
|
|
||||||
var setup_field_label_map = function(fields_list, currency) {
|
|
||||||
$.each(fields_list, function(i, fname) {
|
|
||||||
var docfield = frappe.meta.docfield_map[me.frm.doc.doctype][fname];
|
|
||||||
if(docfield) {
|
|
||||||
var label = __(docfield.label || "").replace(/\([^\)]*\)/g, "");
|
|
||||||
field_label_map[fname] = label.trim() + " (" + currency + ")";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
setup_field_label_map(["base_net_total", "base_total_taxes_and_charges", "base_discount_amount", "base_grand_total",
|
|
||||||
"base_rounded_total", "base_in_words",
|
|
||||||
"outstanding_amount", "total_advance", "paid_amount", "write_off_amount"],
|
|
||||||
company_currency);
|
|
||||||
|
|
||||||
setup_field_label_map(["net_total", "total_taxes_and_charges", "discount_amount", "grand_total",
|
|
||||||
"rounded_total", "in_words"], this.frm.doc.currency);
|
|
||||||
|
|
||||||
cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency
|
|
||||||
+ " = [?] " + company_currency)
|
|
||||||
|
|
||||||
if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) {
|
|
||||||
cur_frm.set_df_property("plc_conversion_rate", "description", "1 " + this.frm.doc.price_list_currency
|
|
||||||
+ " = [?] " + company_currency)
|
|
||||||
}
|
|
||||||
|
|
||||||
// toggle fields
|
|
||||||
this.frm.toggle_display(["conversion_rate", "base_net_total", "base_total_taxes_and_charges",
|
|
||||||
"base_grand_total", "base_rounded_total", "base_in_words", "base_discount_amount"],
|
|
||||||
this.frm.doc.currency != company_currency);
|
|
||||||
|
|
||||||
this.frm.toggle_display(["plc_conversion_rate", "price_list_currency"],
|
|
||||||
this.frm.doc.price_list_currency != company_currency);
|
|
||||||
|
|
||||||
// set labels
|
|
||||||
$.each(field_label_map, function(fname, label) {
|
|
||||||
me.frm.fields_dict[fname].set_label(label);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
change_grid_labels: function(company_currency) {
|
|
||||||
var me = this;
|
|
||||||
var field_label_map = {};
|
|
||||||
|
|
||||||
var setup_field_label_map = function(fields_list, currency, parentfield) {
|
|
||||||
var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype;
|
|
||||||
$.each(fields_list, function(i, fname) {
|
|
||||||
var docfield = frappe.meta.docfield_map[grid_doctype][fname];
|
|
||||||
if(docfield) {
|
|
||||||
var label = __(docfield.label || "").replace(/\([^\)]*\)/g, "");
|
|
||||||
field_label_map[grid_doctype + "-" + fname] =
|
|
||||||
label.trim() + " (" + currency + ")";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_field_label_map(["base_rate", "base_price_list_rate", "base_amount"],
|
|
||||||
company_currency, "items");
|
|
||||||
|
|
||||||
setup_field_label_map(["rate", "price_list_rate", "amount"],
|
|
||||||
this.frm.doc.currency, "items");
|
|
||||||
|
|
||||||
setup_field_label_map(["tax_amount", "total"], company_currency, "taxes");
|
|
||||||
|
|
||||||
if(this.frm.fields_dict["advances"]) {
|
|
||||||
setup_field_label_map(["advance_amount", "allocated_amount"], company_currency,
|
|
||||||
"advances");
|
|
||||||
}
|
|
||||||
|
|
||||||
// toggle columns
|
|
||||||
var item_grid = this.frm.fields_dict["items"].grid;
|
|
||||||
var show = (this.frm.doc.currency != company_currency) ||
|
|
||||||
((cur_frm.doc.taxes || []).filter(
|
|
||||||
function(d) { return d.included_in_print_rate===1}).length);
|
|
||||||
|
|
||||||
$.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) {
|
|
||||||
if(frappe.meta.get_docfield(item_grid.doctype, fname))
|
|
||||||
item_grid.set_column_disp(fname, show);
|
|
||||||
});
|
|
||||||
|
|
||||||
// set labels
|
|
||||||
var $wrapper = $(this.frm.wrapper);
|
|
||||||
$.each(field_label_map, function(fname, label) {
|
|
||||||
fname = fname.split("-");
|
|
||||||
var df = frappe.meta.get_docfield(fname[0], fname[1], me.frm.doc.name);
|
|
||||||
if(df) df.label = label;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,8 @@ import unittest
|
|||||||
|
|
||||||
class TestCompany(unittest.TestCase):
|
class TestCompany(unittest.TestCase):
|
||||||
def atest_coa(self):
|
def atest_coa(self):
|
||||||
for country, chart_name in frappe.db.sql("""select country, chart_name
|
for country, chart_name in frappe.db.sql("""select country, chart_name
|
||||||
from `tabChart of Accounts` where name = 'Deutscher Kontenplan SKR03'""", as_list=1):
|
from `tabChart of Accounts` where name = 'Deutscher Kontenplan SKR03'""", as_list=1):
|
||||||
print "Country: ", country
|
|
||||||
print "Chart Name: ", chart_name
|
|
||||||
|
|
||||||
company_doc = frappe.get_doc({
|
company_doc = frappe.get_doc({
|
||||||
"doctype": "Company",
|
"doctype": "Company",
|
||||||
"company_name": "_Test Company 2",
|
"company_name": "_Test Company 2",
|
||||||
@@ -23,10 +20,10 @@ class TestCompany(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
company_doc.insert()
|
company_doc.insert()
|
||||||
self.assertTrue(frappe.db.sql("""select count(*) from tabAccount
|
self.assertTrue(frappe.db.sql("""select count(*) from tabAccount
|
||||||
where company='_Test Company 2'""")[0][0] > 10)
|
where company='_Test Company 2'""")[0][0] > 10)
|
||||||
|
|
||||||
frappe.delete_doc("Company", "_Test Company 2")
|
|
||||||
|
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Company')
|
frappe.delete_doc("Company", "_Test Company 2")
|
||||||
|
|
||||||
|
|
||||||
|
test_records = frappe.get_test_records('Company')
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ def decorate_quotation_doc(quotation_doc):
|
|||||||
d["formatted_amount"] = fmt_money(d.get("amount"), currency=doc.currency)
|
d["formatted_amount"] = fmt_money(d.get("amount"), currency=doc.currency)
|
||||||
|
|
||||||
for d in doc.get("taxes", []):
|
for d in doc.get("taxes", []):
|
||||||
d["formatted_tax_amount"] = fmt_money(flt(d.get("tax_amount")) / doc.conversion_rate,
|
d["formatted_tax_amount"] = fmt_money(flt(d.get("tax_amount_after_discount_amount")),
|
||||||
currency=doc.currency)
|
currency=doc.currency)
|
||||||
|
|
||||||
doc.formatted_grand_total_export = fmt_money(doc.grand_total,
|
doc.formatted_grand_total_export = fmt_money(doc.grand_total,
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ data_map = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Sales Invoice Item": {
|
"Sales Invoice Item": {
|
||||||
"columns": ["name", "parent", "item_code", "qty", "base_amount"],
|
"columns": ["name", "parent", "item_code", "qty", "base_net_amount"],
|
||||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||||
"order_by": "parent",
|
"order_by": "parent",
|
||||||
"links": {
|
"links": {
|
||||||
@@ -192,7 +192,7 @@ data_map = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Sales Order Item[Sales Analytics]": {
|
"Sales Order Item[Sales Analytics]": {
|
||||||
"columns": ["name", "parent", "item_code", "qty", "base_amount"],
|
"columns": ["name", "parent", "item_code", "qty", "base_net_amount"],
|
||||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||||
"order_by": "parent",
|
"order_by": "parent",
|
||||||
"links": {
|
"links": {
|
||||||
@@ -210,7 +210,7 @@ data_map = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Delivery Note Item[Sales Analytics]": {
|
"Delivery Note Item[Sales Analytics]": {
|
||||||
"columns": ["name", "parent", "item_code", "qty", "base_amount"],
|
"columns": ["name", "parent", "item_code", "qty", "base_net_amount"],
|
||||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||||
"order_by": "parent",
|
"order_by": "parent",
|
||||||
"links": {
|
"links": {
|
||||||
@@ -242,7 +242,7 @@ data_map = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Purchase Invoice Item": {
|
"Purchase Invoice Item": {
|
||||||
"columns": ["name", "parent", "item_code", "qty", "base_amount"],
|
"columns": ["name", "parent", "item_code", "qty", "base_net_amount"],
|
||||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||||
"order_by": "parent",
|
"order_by": "parent",
|
||||||
"links": {
|
"links": {
|
||||||
@@ -260,7 +260,7 @@ data_map = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Purchase Order Item[Purchase Analytics]": {
|
"Purchase Order Item[Purchase Analytics]": {
|
||||||
"columns": ["name", "parent", "item_code", "qty", "base_amount"],
|
"columns": ["name", "parent", "item_code", "qty", "base_net_amount"],
|
||||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||||
"order_by": "parent",
|
"order_by": "parent",
|
||||||
"links": {
|
"links": {
|
||||||
@@ -278,7 +278,7 @@ data_map = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Purchase Receipt Item[Purchase Analytics]": {
|
"Purchase Receipt Item[Purchase Analytics]": {
|
||||||
"columns": ["name", "parent", "item_code", "qty", "base_amount"],
|
"columns": ["name", "parent", "item_code", "qty", "base_net_amount"],
|
||||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||||
"order_by": "parent",
|
"order_by": "parent",
|
||||||
"links": {
|
"links": {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
{% include 'selling/sales_common.js' %};
|
{% include 'selling/sales_common.js' %};
|
||||||
{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %}
|
|
||||||
|
|
||||||
frappe.provide("erpnext.stock");
|
frappe.provide("erpnext.stock");
|
||||||
frappe.provide("erpnext.stock.delivery_note");
|
frappe.provide("erpnext.stock.delivery_note");
|
||||||
@@ -25,7 +24,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
|||||||
cur_frm.add_custom_button(__('Make Installation Note'), this.make_installation_note);
|
cur_frm.add_custom_button(__('Make Installation Note'), this.make_installation_note);
|
||||||
|
|
||||||
if (doc.docstatus==1) {
|
if (doc.docstatus==1) {
|
||||||
|
|
||||||
this.show_stock_ledger();
|
this.show_stock_ledger();
|
||||||
this.show_general_ledger();
|
this.show_general_ledger();
|
||||||
}
|
}
|
||||||
@@ -131,6 +130,7 @@ erpnext.stock.delivery_note.set_print_hide = function(doc, cdt, cdn){
|
|||||||
dn_item_fields['discount_percentage'].print_hide = 1;
|
dn_item_fields['discount_percentage'].print_hide = 1;
|
||||||
dn_item_fields['price_list_rate'].print_hide = 1;
|
dn_item_fields['price_list_rate'].print_hide = 1;
|
||||||
dn_item_fields['amount'].print_hide = 1;
|
dn_item_fields['amount'].print_hide = 1;
|
||||||
|
dn_fields['taxes'].print_hide = 1;
|
||||||
} else {
|
} else {
|
||||||
if (dn_fields_copy['currency'].print_hide != 1)
|
if (dn_fields_copy['currency'].print_hide != 1)
|
||||||
dn_fields['currency'].print_hide = 0;
|
dn_fields['currency'].print_hide = 0;
|
||||||
@@ -138,6 +138,8 @@ erpnext.stock.delivery_note.set_print_hide = function(doc, cdt, cdn){
|
|||||||
dn_item_fields['rate'].print_hide = 0;
|
dn_item_fields['rate'].print_hide = 0;
|
||||||
if (dn_item_fields_copy['amount'].print_hide != 1)
|
if (dn_item_fields_copy['amount'].print_hide != 1)
|
||||||
dn_item_fields['amount'].print_hide = 0;
|
dn_item_fields['amount'].print_hide = 0;
|
||||||
|
if (dn_fields_copy['taxes'].print_hide != 1)
|
||||||
|
dn_fields['taxes'].print_hide = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -340,6 +340,16 @@
|
|||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_net_total",
|
"fieldname": "base_net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -360,6 +370,16 @@
|
|||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "net_total",
|
"fieldname": "net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -443,6 +463,12 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_47",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_total_taxes_and_charges",
|
"fieldname": "base_total_taxes_and_charges",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -457,7 +483,22 @@
|
|||||||
"width": "150px"
|
"width": "150px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_47",
|
"fieldname": "section_break_49",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Grand Total",
|
||||||
|
"fieldname": "apply_discount_on",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Apply Discount On",
|
||||||
|
"options": "\nGrand Total\nNet Total",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_51",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
@@ -1024,7 +1065,7 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"in_create": 0,
|
"in_create": 0,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-02-20 05:16:21.997931",
|
"modified": "2015-02-23 15:49:10.972483",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Delivery Note",
|
"name": "Delivery Note",
|
||||||
|
|||||||
@@ -254,6 +254,58 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_25",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_28",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "warehouse_and_reference",
|
"fieldname": "warehouse_and_reference",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
@@ -442,17 +494,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 +508,7 @@
|
|||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-02-19 01:06:59.675246",
|
"modified": "2015-02-23 15:51:20.772564",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Delivery Note Item",
|
"name": "Delivery Note Item",
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
||||||
{% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %}
|
|
||||||
|
|
||||||
frappe.provide("erpnext.stock");
|
frappe.provide("erpnext.stock");
|
||||||
erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({
|
erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({
|
||||||
|
|||||||
@@ -222,12 +222,31 @@
|
|||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"reqd": 0
|
"reqd": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "get_current_stock",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"label": "Get Current Stock",
|
||||||
|
"oldfieldtype": "Button",
|
||||||
|
"options": "get_current_stock",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "section_break0",
|
"fieldname": "section_break0",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_net_total",
|
"fieldname": "base_net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -242,20 +261,22 @@
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"width": "150px"
|
"width": "150px"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "get_current_stock",
|
|
||||||
"fieldtype": "Button",
|
|
||||||
"label": "Get Current Stock",
|
|
||||||
"oldfieldtype": "Button",
|
|
||||||
"options": "get_current_stock",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_27",
|
"fieldname": "column_break_27",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Total",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "net_total",
|
"fieldname": "net_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -346,39 +367,6 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "base_grand_total",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Grand Total (Company Currency)",
|
|
||||||
"oldfieldname": "grand_total",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "base_rounded_total",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Rounded Total (Company Currency)",
|
|
||||||
"oldfieldname": "rounded_total",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "In Words will be visible once you save the Purchase Receipt.",
|
|
||||||
"fieldname": "base_in_words",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "In Words (Company Currency)",
|
|
||||||
"oldfieldname": "in_words",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "column_break3",
|
"fieldname": "column_break3",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
@@ -416,6 +404,92 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": ""
|
"precision": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_42",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Grand Total",
|
||||||
|
"fieldname": "apply_discount_on",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Apply Discount On",
|
||||||
|
"options": "\nGrand Total\nNet Total",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_44",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "discount_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Discount Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_discount_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Discount Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_46",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_grand_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Grand Total (Company Currency)",
|
||||||
|
"oldfieldname": "grand_total",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "In Words will be visible once you save the Purchase Receipt.",
|
||||||
|
"fieldname": "base_in_words",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "In Words (Company Currency)",
|
||||||
|
"oldfieldname": "in_words",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_rounded_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Rounded Total (Company Currency)",
|
||||||
|
"oldfieldname": "rounded_total",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_50",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "grand_total",
|
"fieldname": "grand_total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -775,7 +849,7 @@
|
|||||||
"icon": "icon-truck",
|
"icon": "icon-truck",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-02-20 05:16:24.035630",
|
"modified": "2015-02-23 15:16:36.617354",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Purchase Receipt",
|
"name": "Purchase Receipt",
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
"cost_center": d.cost_center,
|
"cost_center": d.cost_center,
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
"debit": flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor),
|
"debit": flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor),
|
||||||
self.precision("base_amount", d))
|
self.precision("base_net_amount", d))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
# stock received but not billed
|
# stock received but not billed
|
||||||
@@ -304,7 +304,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
"against": warehouse_account[d.warehouse],
|
"against": warehouse_account[d.warehouse],
|
||||||
"cost_center": d.cost_center,
|
"cost_center": d.cost_center,
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
"credit": flt(d.base_amount, self.precision("base_amount", d))
|
"credit": flt(d.base_net_amount, self.precision("base_net_amount", d))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
negative_expense_to_be_booked += flt(d.item_tax_amount)
|
negative_expense_to_be_booked += flt(d.item_tax_amount)
|
||||||
@@ -330,14 +330,14 @@ class PurchaseReceipt(BuyingController):
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
# divisional loss adjustment
|
# divisional loss adjustment
|
||||||
if not self.get("other_charges"):
|
if not self.get("taxes"):
|
||||||
sle_valuation_amount = flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor),
|
sle_valuation_amount = flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor),
|
||||||
self.precision("base_amount", d))
|
self.precision("base_net_amount", d))
|
||||||
|
|
||||||
distributed_amount = flt(flt(d.base_amount, self.precision("base_amount", d))) + \
|
distributed_amount = flt(flt(d.base_net_amount, self.precision("base_net_amount", d))) + \
|
||||||
flt(d.landed_cost_voucher_amount) + flt(d.rm_supp_cost)
|
flt(d.landed_cost_voucher_amount) + flt(d.rm_supp_cost)
|
||||||
|
|
||||||
divisional_loss = flt(distributed_amount - sle_valuation_amount, self.precision("base_amount", d))
|
divisional_loss = flt(distributed_amount - sle_valuation_amount, self.precision("base_net_amount", d))
|
||||||
if divisional_loss:
|
if divisional_loss:
|
||||||
gl_entries.append(self.get_gl_dict({
|
gl_entries.append(self.get_gl_dict({
|
||||||
"account": stock_rbnb,
|
"account": stock_rbnb,
|
||||||
@@ -354,12 +354,12 @@ class PurchaseReceipt(BuyingController):
|
|||||||
# Cost center-wise amount breakup for other charges included for valuation
|
# Cost center-wise amount breakup for other charges included for valuation
|
||||||
valuation_tax = {}
|
valuation_tax = {}
|
||||||
for tax in self.get("taxes"):
|
for tax in self.get("taxes"):
|
||||||
if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount):
|
if tax.category in ("Valuation", "Valuation and Total") and flt(tax.base_tax_amount_after_discount_amount):
|
||||||
if not tax.cost_center:
|
if not tax.cost_center:
|
||||||
frappe.throw(_("Cost Center is required in row {0} in Taxes table for type {1}").format(tax.idx, _(tax.category)))
|
frappe.throw(_("Cost Center is required in row {0} in Taxes table for type {1}").format(tax.idx, _(tax.category)))
|
||||||
valuation_tax.setdefault(tax.cost_center, 0)
|
valuation_tax.setdefault(tax.cost_center, 0)
|
||||||
valuation_tax[tax.cost_center] += \
|
valuation_tax[tax.cost_center] += \
|
||||||
(tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount)
|
(tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.base_tax_amount_after_discount_amount)
|
||||||
|
|
||||||
if negative_expense_to_be_booked and valuation_tax:
|
if negative_expense_to_be_booked and valuation_tax:
|
||||||
# Backward compatibility:
|
# Backward compatibility:
|
||||||
|
|||||||
@@ -283,6 +283,58 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_29",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount",
|
||||||
|
"options": "currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_32",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_rate",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Rate (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "warehouse_and_reference",
|
"fieldname": "warehouse_and_reference",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
@@ -588,7 +640,7 @@
|
|||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-02-19 01:07:01.405923",
|
"modified": "2015-02-23 15:19:26.294450",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Purchase Receipt Item",
|
"name": "Purchase Receipt Item",
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class StockLedgerEntry(Document):
|
|||||||
|
|
||||||
def validate_item(self):
|
def validate_item(self):
|
||||||
item_det = frappe.db.sql("""select name, has_batch_no, docstatus,
|
item_det = frappe.db.sql("""select name, has_batch_no, docstatus,
|
||||||
is_stock_item, has_variants
|
is_stock_item, has_variants, stock_uom
|
||||||
from tabItem where name=%s""", self.item_code, as_dict=True)[0]
|
from tabItem where name=%s""", self.item_code, as_dict=True)[0]
|
||||||
|
|
||||||
if item_det.is_stock_item != 'Yes':
|
if item_det.is_stock_item != 'Yes':
|
||||||
|
|||||||
@@ -170,6 +170,8 @@ def get_basic_details(args, item):
|
|||||||
"base_rate": 0.0,
|
"base_rate": 0.0,
|
||||||
"amount": 0.0,
|
"amount": 0.0,
|
||||||
"base_amount": 0.0,
|
"base_amount": 0.0,
|
||||||
|
"net_rate": 0.0,
|
||||||
|
"net_amount": 0.0,
|
||||||
"discount_percentage": 0.0
|
"discount_percentage": 0.0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user