[minor] removed get_rate
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py
index c79bfd6..a562c67 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -88,14 +88,6 @@
super(DocType, self).get_advances(self.doc.credit_to,
"Purchase Invoice Advance", "advance_allocation_details", "debit")
- def get_rate(self,arg):
- return get_obj('Purchase Common').get_rate(arg,self)
-
- def get_rate1(self,acc):
- rate = webnotes.conn.sql("select tax_rate from `tabAccount` where name='%s'"%(acc))
- ret={'add_tax_rate' :rate and flt(rate[0][0]) or 0 }
- return ret
-
def check_active_purchase_items(self):
for d in getlist(self.doclist, 'entries'):
if d.item_code: # extra condn coz item_code is not mandatory in PV
diff --git a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
index 423c4e4..3368773 100644
--- a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
+++ b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
@@ -4,6 +4,8 @@
//
//--------- ONLOAD -------------
+wn.require("app/js/controllers/accounts.js");
+
cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
@@ -134,20 +136,6 @@
}
}
-cur_frm.cscript.account_head = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if(!d.charge_type && d.account_head){
- alert("Please select Charge Type first");
- validated = false;
- d.account_head = '';
- }
- else if(d.account_head && d.charge_type) {
- arg = "{'charge_type' : '" + d.charge_type + "', 'account_head' : '" + d.account_head + "'}";
- return get_server_fields('get_rate', arg, 'purchase_tax_details', doc, cdt, cdn, 1);
- }
- refresh_field('account_head',d.name,'purchase_tax_details');
-}
-
cur_frm.cscript.rate = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.rate) {
diff --git a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py
index 0a32fb9..3d003f6 100644
--- a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py
+++ b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py
@@ -14,9 +14,4 @@
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
- self.doclist = doclist
-
- # Get Tax Rate if account type is Tax
- # ===================================================================
- def get_rate(self, arg):
- return get_obj('Purchase Common').get_rate(arg, self)
\ No newline at end of file
+ self.doclist = doclist
\ No newline at end of file
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index 5c7597c..92c1680 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -264,13 +264,7 @@
def get_adj_percent(self, arg=''):
"""Fetch ref rate from item master as per selected price list"""
- get_obj('Sales Common').get_adj_percent(self)
-
-
- def get_rate(self,arg):
- """Get tax rate if account type is tax"""
- get_obj('Sales Common').get_rate(arg)
-
+ get_obj('Sales Common').get_adj_percent(self)
def get_comm_rate(self, sales_partner):
"""Get Commission rate of Sales Partner"""
diff --git a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
index f1a6027..d8f55fd 100644
--- a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
+++ b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
@@ -2,6 +2,9 @@
// License: GNU General Public License v3. See license.txt
//--------- ONLOAD -------------
+
+wn.require("app/js/controllers/accounts.js");
+
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(doc.doctype === "Sales Taxes and Charges Master")
erpnext.add_for_territory();
@@ -142,21 +145,6 @@
}
}
-
-cur_frm.cscript.account_head = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if(!d.charge_type && d.account_head){
- alert("Please select Charge Type first");
- validated = false;
- d.account_head = '';
- }
- else if(d.account_head && d.charge_type) {
- arg = "{'charge_type' : '" + d.charge_type +"', 'account_head' : '" + d.account_head + "'}";
- return get_server_fields('get_rate', arg, 'other_charges', doc, cdt, cdn, 1);
- }
- refresh_field('account_head',d.name,'other_charges');
-}
-
cur_frm.cscript.rate = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.rate) {
diff --git a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py
index 019edcb..67ba9cb 100644
--- a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py
+++ b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py
@@ -6,11 +6,7 @@
from webnotes.utils import cint
from webnotes.model.controller import DocListController
-class DocType(DocListController):
- def get_rate(self, arg):
- from webnotes.model.code import get_obj
- return get_obj('Sales Common').get_rate(arg)
-
+class DocType(DocListController):
def validate(self):
if self.doc.is_default == 1:
webnotes.conn.sql("""update `tabSales Taxes and Charges Master` set is_default = 0
diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js
index 433a76f..023c7f3 100644
--- a/buying/doctype/purchase_common/purchase_common.js
+++ b/buying/doctype/purchase_common/purchase_common.js
@@ -8,6 +8,7 @@
wn.provide("erpnext.buying");
wn.require("app/js/transaction.js");
+wn.require("app/js/controllers/accounts.js");
erpnext.buying.BuyingController = erpnext.TransactionController.extend({
onload: function() {
diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py
index c05aba4..1d57f88 100644
--- a/buying/doctype/purchase_common/purchase_common.py
+++ b/buying/doctype/purchase_common/purchase_common.py
@@ -36,13 +36,6 @@
msgprint("Supplier : %s does not exists" % (name))
raise Exception
- # Get Available Qty at Warehouse
- def get_bin_details( self, arg = ''):
- arg = eval(arg)
- bin = webnotes.conn.sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (arg['item_code'], arg['warehouse']), as_dict=1)
- ret = { 'projected_qty' : bin and flt(bin[0]['projected_qty']) or 0 }
- return ret
-
def update_last_purchase_rate(self, obj, is_submit):
"""updates last_purchase_rate in item table for each item"""
@@ -197,14 +190,6 @@
msgprint(cstr(doctype) + ": " + cstr(submitted[0][0])
+ _(" not submitted"), raise_exception=1)
- def get_rate(self, arg, obj):
- arg = eval(arg)
- rate = webnotes.conn.sql("select account_type, tax_rate from `tabAccount` where name = %s"
- , (arg['account_head']), as_dict=1)
-
- return {'rate': rate and (rate[0]['account_type'] == 'Tax' \
- and not arg['charge_type'] == 'Actual') and flt(rate[0]['tax_rate']) or 0 }
-
def get_prevdoc_date(self, obj):
for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname:
diff --git a/buying/doctype/purchase_order/purchase_order.py b/buying/doctype/purchase_order/purchase_order.py
index 3389f74..dc75466 100644
--- a/buying/doctype/purchase_order/purchase_order.py
+++ b/buying/doctype/purchase_order/purchase_order.py
@@ -65,10 +65,6 @@
}
})
- # get available qty at warehouse
- def get_bin_details(self, arg = ''):
- return get_obj(dt='Purchase Common').get_bin_details(arg)
-
def get_schedule_dates(self):
for d in getlist(self.doclist, 'po_details'):
if d.prevdoc_detail_docname and not d.schedule_date:
@@ -185,9 +181,6 @@
def on_update(self):
pass
- def get_rate(self,arg):
- return get_obj('Purchase Common').get_rate(arg,self)
-
@webnotes.whitelist()
def make_purchase_receipt(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py
index 927b249..f290d4d 100644
--- a/controllers/accounts_controller.py
+++ b/controllers/accounts_controller.py
@@ -423,3 +423,7 @@
self._abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
return self._abbr
+
+@webnotes.whitelist()
+def get_tax_rate(account_head):
+ return webnotes.conn.get_value("Account", account_head, "tax_rate")
diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py
index 25d76aa..3de550c 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import webnotes
+import webnotes, json
from webnotes import _, msgprint
from webnotes.utils import flt, _round
@@ -280,3 +280,6 @@
(", ".join((["%s"]*len(item_codes))),), item_codes)]
return self._purchase_items
+
+ def get_bin_details(self, arg):
+ return {"projected_qty": webnotes.conn.get_value("Bin", json.loads(arg), "projected_qty") or 0 }
diff --git a/public/js/controllers/accounts.js b/public/js/controllers/accounts.js
new file mode 100644
index 0000000..201c47e
--- /dev/null
+++ b/public/js/controllers/accounts.js
@@ -0,0 +1,18 @@
+
+// get tax rate
+cur_frm.cscript.account_head = function(doc, cdt, cdn) {
+ var d = locals[cdt][cdn];
+ if(!d.charge_type && d.account_head){
+ msgprint("Please select Charge Type first");
+ wn.model.set_value(cdt, cdn, "account_head", "");
+ } else if(d.account_head && d.charge_type!=="Actual") {
+ wn.call({
+ type:"GET",
+ method: "controllers.accounts_controller.get_tax_rate",
+ args: {"account_head":d.account_head},
+ callback: function(r) {
+ wn.model.set_value(cdt, cdn, "rate", r.message || 0);
+ }
+ })
+ }
+}
diff --git a/selling/doctype/quotation/quotation.py b/selling/doctype/quotation/quotation.py
index b6bc45d..78afb97 100644
--- a/selling/doctype/quotation/quotation.py
+++ b/selling/doctype/quotation/quotation.py
@@ -56,13 +56,7 @@
# --------------------------------------------------------------
def get_adj_percent(self, arg=''):
get_obj('Sales Common').get_adj_percent(self)
-
- # Get Tax rate if account type is TAX
- # -----------------------------------
- def get_rate(self,arg):
- return get_obj('Sales Common').get_rate(arg)
-
# Does not allow same item code to be entered twice
# -------------------------------------------------
def validate_for_items(self):
diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js
index c87e823..f744faa 100644
--- a/selling/doctype/sales_common/sales_common.js
+++ b/selling/doctype/sales_common/sales_common.js
@@ -10,6 +10,7 @@
wn.provide("erpnext.selling");
wn.require("app/js/transaction.js");
+wn.require("app/js/controllers/accounts.js");
erpnext.selling.SellingController = erpnext.TransactionController.extend({
onload: function() {
diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py
index df7f151..634ea2a 100644
--- a/selling/doctype/sales_common/sales_common.py
+++ b/selling/doctype/sales_common/sales_common.py
@@ -86,26 +86,6 @@
if (obj.doc.price_list_currency == default_currency and flt(obj.doc.plc_conversion_rate) != 1.00) or not obj.doc.plc_conversion_rate or (obj.doc.price_list_currency != default_currency and flt(obj.doc.plc_conversion_rate) == 1.00):
msgprint("Please Enter Appropriate Conversion Rate for Price List Currency to Base Currency (%s --> %s)" % (obj.doc.price_list_currency, default_currency), raise_exception = 1)
-
-
-
- # Get Tax rate if account type is TAX
- # =========================================================================
- def get_rate(self, arg):
- arg = eval(arg)
- rate = webnotes.conn.sql("select account_type, tax_rate from `tabAccount` where name = '%s' and docstatus != 2" %(arg['account_head']), as_dict=1)
- ret = {'rate' : 0}
- if arg['charge_type'] == 'Actual' and rate[0]['account_type'] == 'Tax':
- msgprint("You cannot select ACCOUNT HEAD of type TAX as your CHARGE TYPE is 'ACTUAL'")
- ret = {
- 'account_head' : ''
- }
- elif rate[0]['account_type'] in ['Tax', 'Chargeable'] and not arg['charge_type'] == 'Actual':
- ret = {
- 'rate' : rate and flt(rate[0]['tax_rate']) or 0
- }
- return ret
-
def get_item_list(self, obj, is_stopped=0):
"""get item list"""
diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py
index 0cdca58..1c22c08 100644
--- a/selling/doctype/sales_order/sales_order.py
+++ b/selling/doctype/sales_order/sales_order.py
@@ -38,9 +38,6 @@
def get_available_qty(self,args):
return get_obj('Sales Common').get_available_qty(eval(args))
- def get_rate(self,arg):
- return get_obj('Sales Common').get_rate(arg)
-
def validate_mandatory(self):
# validate transaction date v/s delivery date
if self.doc.delivery_date:
diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py
index b20e790..2819085 100644
--- a/stock/doctype/delivery_note/delivery_note.py
+++ b/stock/doctype/delivery_note/delivery_note.py
@@ -66,9 +66,6 @@
"""Re-calculates Basic Rate & amount based on Price List Selected"""
get_obj('Sales Common').get_adj_percent(self)
- def get_rate(self,arg):
- return get_obj('Sales Common').get_rate(arg)
-
def so_required(self):
"""check in manage account if sales order required or not"""
if webnotes.conn.get_value("Selling Settings", None, 'so_required') == 'Yes':
diff --git a/stock/doctype/material_request/material_request.py b/stock/doctype/material_request/material_request.py
index d1672ba..7aea336 100644
--- a/stock/doctype/material_request/material_request.py
+++ b/stock/doctype/material_request/material_request.py
@@ -20,10 +20,6 @@
self.tname = 'Material Request Item'
self.fname = 'indent_details'
- # get available qty at warehouse
- def get_bin_details(self, arg = ''):
- return get_obj(dt='Purchase Common').get_bin_details(arg)
-
def check_if_already_pulled(self):
pass#if self.[d.sales_order_no for d in getlist(self.doclist, 'indent_details')]
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py
index 6169b1d..1e1f1eaf 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -38,10 +38,6 @@
total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "purchase_receipt_details"})))
self.doc.fields["__billing_complete"] = billed_qty[0][0] == total_qty
- # get available qty at warehouse
- def get_bin_details(self, arg = ''):
- return get_obj(dt='Purchase Common').get_bin_details(arg)
-
def validate(self):
super(DocType, self).validate()
@@ -290,10 +286,6 @@
bin = webnotes.conn.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.rm_item_code, self.doc.supplier_warehouse), as_dict = 1)
d.current_stock = bin and flt(bin[0]['actual_qty']) or 0
-
- def get_rate(self,arg):
- return get_obj('Purchase Common').get_rate(arg,self)
-
def get_gl_entries_for_stock(self, warehouse_account=None):
against_stock_account = self.get_company_default("stock_received_but_not_billed")