shifted get_company_currency from transaction base to setup/utils.py

This commit is contained in:
Anand Doshi
2013-01-17 15:44:57 +05:30
parent 03fa78597d
commit 9d9aec1ed4
15 changed files with 65 additions and 55 deletions

View File

@@ -17,26 +17,17 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt, get_defaults, now, sendmail
from webnotes.model import db_exists
from webnotes.utils import cstr, flt, get_defaults
from webnotes.model.doc import Document, addchild
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
from webnotes.utils.email_lib import sendmail
from utilities.transaction_base import TransactionBase
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d, dl
self.entries = []
def get_company_currency(self,arg=''):
dcc = TransactionBase().get_company_currency(arg)
return dcc
def get_period_difference(self,arg, cost_center =''):
# used in General Ledger Page Report
# used for Budget where cost center passed as extra argument

View File

@@ -18,15 +18,14 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, cstr, flt, fmt_money, formatdate, getdate
from webnotes.model import db_exists
from webnotes.model.doc import addchild, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import form, msgprint
from webnotes import msgprint
from setup.utils import get_company_currency
sql = webnotes.conn.sql
from utilities.transaction_base import TransactionBase
class DocType:
def __init__(self,d,dl):
@@ -238,7 +237,7 @@ class DocType:
self.doc.pay_to_recd_from = webnotes.conn.get_value(master_type, ' - '.join(d.account.split(' - ')[:-1]), master_type == 'Customer' and 'customer_name' or 'supplier_name')
if acc_type == 'Bank or Cash':
dcc = TransactionBase().get_company_currency(self.doc.company)
dcc = get_company_currency(self.doc.company)
amt = cint(d.debit) and d.debit or d.credit
self.doc.total_amount = dcc +' '+ cstr(amt)
self.doc.total_amount_in_words = get_obj('Sales Common').get_total_in_words(dcc, cstr(amt))

View File

@@ -21,6 +21,7 @@ from webnotes.utils import add_days, cint, cstr, flt, formatdate, get_defaults
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
from setup.utils import get_company_currency
sql = webnotes.conn.sql
@@ -159,7 +160,7 @@ class DocType(BuyingController):
# Check Conversion Rate
# ----------------------
def check_conversion_rate(self):
default_currency = super(DocType, self).get_company_currency(self.doc.company)
default_currency = get_company_currency(self.doc.company)
if not default_currency:
msgprint('Message: Please enter default currency in Company Master')
raise Exception
@@ -370,7 +371,7 @@ class DocType(BuyingController):
pc_obj = get_obj(dt='Purchase Common')
# get total in words
dcc = super(DocType, self).get_company_currency(self.doc.company)
dcc = get_company_currency(self.doc.company)
self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency,
self.doc.grand_total_import)

View File

@@ -26,6 +26,7 @@ from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj
from webnotes import session, form, msgprint
from setup.utils import get_company_currency
session = webnotes.session
@@ -412,7 +413,7 @@ class DocType(TransactionBase):
def set_in_words(self):
dcc = TransactionBase().get_company_currency(self.doc.company)
dcc = get_company_currency(self.doc.company)
self.doc.in_words = get_obj('Sales Common').get_total_in_words(dcc, self.doc.rounded_total)
self.doc.in_words_export = get_obj('Sales Common').get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
@@ -503,7 +504,7 @@ class DocType(TransactionBase):
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
for d in getlist(self.doclist, 'packing_details'):
bin = sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
bin = webnotes.conn.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0