[minor] removed get_rate

This commit is contained in:
Rushabh Mehta
2013-10-10 16:35:09 +05:30
parent 97e9deb1ff
commit f56d73c9bc
19 changed files with 36 additions and 122 deletions

View File

@@ -88,14 +88,6 @@ class DocType(BuyingController):
super(DocType, self).get_advances(self.doc.credit_to, super(DocType, self).get_advances(self.doc.credit_to,
"Purchase Invoice Advance", "advance_allocation_details", "debit") "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): def check_active_purchase_items(self):
for d in getlist(self.doclist, 'entries'): for d in getlist(self.doclist, 'entries'):
if d.item_code: # extra condn coz item_code is not mandatory in PV if d.item_code: # extra condn coz item_code is not mandatory in PV

View File

@@ -4,6 +4,8 @@
// //
//--------- ONLOAD ------------- //--------- ONLOAD -------------
wn.require("app/js/controllers/accounts.js");
cur_frm.cscript.onload = function(doc, cdt, cdn) { cur_frm.cscript.onload = function(doc, cdt, cdn) {
} }
@@ -134,20 +136,6 @@ cur_frm.fields_dict['purchase_tax_details'].grid.get_field("cost_center").get_qu
} }
} }
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) { cur_frm.cscript.rate = function(doc, cdt, cdn) {
var d = locals[cdt][cdn]; var d = locals[cdt][cdn];
if(!d.charge_type && d.rate) { if(!d.charge_type && d.rate) {

View File

@@ -15,8 +15,3 @@ class DocType:
def __init__(self, doc, doclist=[]): def __init__(self, doc, doclist=[]):
self.doc = doc self.doc = doc
self.doclist = doclist 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)

View File

@@ -266,12 +266,6 @@ class DocType(SellingController):
"""Fetch ref rate from item master as per selected price list""" """Fetch ref rate from item master as per selected price list"""
get_obj('Sales Common').get_adj_percent(self) 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)
def get_comm_rate(self, sales_partner): def get_comm_rate(self, sales_partner):
"""Get Commission rate of Sales Partner""" """Get Commission rate of Sales Partner"""
return get_obj('Sales Common').get_comm_rate(sales_partner, self) return get_obj('Sales Common').get_comm_rate(sales_partner, self)

View File

@@ -2,6 +2,9 @@
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
//--------- ONLOAD ------------- //--------- ONLOAD -------------
wn.require("app/js/controllers/accounts.js");
cur_frm.cscript.onload = function(doc, cdt, cdn) { 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_for_territory(); erpnext.add_for_territory();
@@ -142,21 +145,6 @@ cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = f
} }
} }
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) { cur_frm.cscript.rate = function(doc, cdt, cdn) {
var d = locals[cdt][cdn]; var d = locals[cdt][cdn];
if(!d.charge_type && d.rate) { if(!d.charge_type && d.rate) {

View File

@@ -7,10 +7,6 @@ from webnotes.utils import cint
from webnotes.model.controller import DocListController from webnotes.model.controller import DocListController
class DocType(DocListController): class DocType(DocListController):
def get_rate(self, arg):
from webnotes.model.code import get_obj
return get_obj('Sales Common').get_rate(arg)
def validate(self): def validate(self):
if self.doc.is_default == 1: if self.doc.is_default == 1:
webnotes.conn.sql("""update `tabSales Taxes and Charges Master` set is_default = 0 webnotes.conn.sql("""update `tabSales Taxes and Charges Master` set is_default = 0

View File

@@ -8,6 +8,7 @@
wn.provide("erpnext.buying"); wn.provide("erpnext.buying");
wn.require("app/js/transaction.js"); wn.require("app/js/transaction.js");
wn.require("app/js/controllers/accounts.js");
erpnext.buying.BuyingController = erpnext.TransactionController.extend({ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
onload: function() { onload: function() {

View File

@@ -36,13 +36,6 @@ class DocType(BuyingController):
msgprint("Supplier : %s does not exists" % (name)) msgprint("Supplier : %s does not exists" % (name))
raise Exception 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): def update_last_purchase_rate(self, obj, is_submit):
"""updates last_purchase_rate in item table for each item""" """updates last_purchase_rate in item table for each item"""
@@ -197,14 +190,6 @@ class DocType(BuyingController):
msgprint(cstr(doctype) + ": " + cstr(submitted[0][0]) msgprint(cstr(doctype) + ": " + cstr(submitted[0][0])
+ _(" not submitted"), raise_exception=1) + _(" 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): def get_prevdoc_date(self, obj):
for d in getlist(obj.doclist, obj.fname): for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname: if d.prevdoc_doctype and d.prevdoc_docname:

View File

@@ -65,10 +65,6 @@ class DocType(BuyingController):
} }
}) })
# 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): def get_schedule_dates(self):
for d in getlist(self.doclist, 'po_details'): for d in getlist(self.doclist, 'po_details'):
if d.prevdoc_detail_docname and not d.schedule_date: if d.prevdoc_detail_docname and not d.schedule_date:
@@ -185,9 +181,6 @@ class DocType(BuyingController):
def on_update(self): def on_update(self):
pass pass
def get_rate(self,arg):
return get_obj('Purchase Common').get_rate(arg,self)
@webnotes.whitelist() @webnotes.whitelist()
def make_purchase_receipt(source_name, target_doclist=None): def make_purchase_receipt(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist from webnotes.model.mapper import get_mapped_doclist

View File

@@ -423,3 +423,7 @@ class AccountsController(TransactionBase):
self._abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr") self._abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
return self._abbr return self._abbr
@webnotes.whitelist()
def get_tax_rate(account_head):
return webnotes.conn.get_value("Account", account_head, "tax_rate")

View File

@@ -2,7 +2,7 @@
# 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 webnotes import webnotes, json
from webnotes import _, msgprint from webnotes import _, msgprint
from webnotes.utils import flt, _round from webnotes.utils import flt, _round
@@ -280,3 +280,6 @@ class BuyingController(StockController):
(", ".join((["%s"]*len(item_codes))),), item_codes)] (", ".join((["%s"]*len(item_codes))),), item_codes)]
return self._purchase_items 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 }

View File

@@ -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);
}
})
}
}

View File

@@ -57,12 +57,6 @@ class DocType(SellingController):
def get_adj_percent(self, arg=''): def get_adj_percent(self, arg=''):
get_obj('Sales Common').get_adj_percent(self) 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 # Does not allow same item code to be entered twice
# ------------------------------------------------- # -------------------------------------------------
def validate_for_items(self): def validate_for_items(self):

View File

@@ -10,6 +10,7 @@
wn.provide("erpnext.selling"); wn.provide("erpnext.selling");
wn.require("app/js/transaction.js"); wn.require("app/js/transaction.js");
wn.require("app/js/controllers/accounts.js");
erpnext.selling.SellingController = erpnext.TransactionController.extend({ erpnext.selling.SellingController = erpnext.TransactionController.extend({
onload: function() { onload: function() {

View File

@@ -87,26 +87,6 @@ class DocType(TransactionBase):
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): 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) 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): def get_item_list(self, obj, is_stopped=0):
"""get item list""" """get item list"""
il = [] il = []

View File

@@ -38,9 +38,6 @@ class DocType(SellingController):
def get_available_qty(self,args): def get_available_qty(self,args):
return get_obj('Sales Common').get_available_qty(eval(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): def validate_mandatory(self):
# validate transaction date v/s delivery date # validate transaction date v/s delivery date
if self.doc.delivery_date: if self.doc.delivery_date:

View File

@@ -66,9 +66,6 @@ class DocType(SellingController):
"""Re-calculates Basic Rate & amount based on Price List Selected""" """Re-calculates Basic Rate & amount based on Price List Selected"""
get_obj('Sales Common').get_adj_percent(self) 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): def so_required(self):
"""check in manage account if sales order required or not""" """check in manage account if sales order required or not"""
if webnotes.conn.get_value("Selling Settings", None, 'so_required') == 'Yes': if webnotes.conn.get_value("Selling Settings", None, 'so_required') == 'Yes':

View File

@@ -20,10 +20,6 @@ class DocType(BuyingController):
self.tname = 'Material Request Item' self.tname = 'Material Request Item'
self.fname = 'indent_details' 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): def check_if_already_pulled(self):
pass#if self.[d.sales_order_no for d in getlist(self.doclist, 'indent_details')] pass#if self.[d.sales_order_no for d in getlist(self.doclist, 'indent_details')]

View File

@@ -38,10 +38,6 @@ class DocType(BuyingController):
total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "purchase_receipt_details"}))) 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 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): def validate(self):
super(DocType, self).validate() super(DocType, self).validate()
@@ -290,10 +286,6 @@ class DocType(BuyingController):
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) 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 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): def get_gl_entries_for_stock(self, warehouse_account=None):
against_stock_account = self.get_company_default("stock_received_but_not_billed") against_stock_account = self.get_company_default("stock_received_but_not_billed")