[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,
"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

View File

@ -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.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) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.rate) {

View File

@ -14,9 +14,4 @@ from webnotes.model.code import get_obj
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)
self.doclist = doclist

View File

@ -264,13 +264,7 @@ class DocType(SellingController):
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"""

View File

@ -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.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) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.rate) {

View File

@ -6,11 +6,7 @@ import webnotes
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

View File

@ -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() {

View File

@ -36,13 +36,6 @@ class DocType(BuyingController):
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 @@ class DocType(BuyingController):
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:

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):
for d in getlist(self.doclist, 'po_details'):
if d.prevdoc_detail_docname and not d.schedule_date:
@ -185,9 +181,6 @@ class DocType(BuyingController):
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

View File

@ -423,3 +423,7 @@ class AccountsController(TransactionBase):
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")

View File

@ -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 @@ class BuyingController(StockController):
(", ".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 }

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

@ -56,13 +56,7 @@ class DocType(SellingController):
# --------------------------------------------------------------
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):

View File

@ -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() {

View File

@ -86,26 +86,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):
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"""

View File

@ -38,9 +38,6 @@ class DocType(SellingController):
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:

View File

@ -66,9 +66,6 @@ class DocType(SellingController):
"""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':

View File

@ -20,10 +20,6 @@ class DocType(BuyingController):
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')]

View File

@ -38,10 +38,6 @@ class DocType(BuyingController):
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 @@ 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)
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")