Default currency for company fixed
This commit is contained in:
parent
2380eabb32
commit
5708da5a9f
@ -15,9 +15,9 @@ in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
|
||||
class DocType:
|
||||
class DocType(TransactionBase):
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
@ -97,5 +97,6 @@ class DocType:
|
||||
for d in getlist(self.doclist,'form_16A_tax_details'):
|
||||
tot=flt(tot)+flt(d.total_tax_deposited)
|
||||
|
||||
self.doc.total_amount = flt(tot)
|
||||
self.doc.in_words = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], self.doc.total_amount)
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
self.doc.total_amount = flt(tot)
|
||||
self.doc.in_words = get_obj('Sales Common').get_total_in_words(dcc, self.doc.total_amount)
|
||||
|
@ -15,7 +15,7 @@ in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
@ -34,9 +34,9 @@ class DocType:
|
||||
# pl[r[0]] = flt(flt(inc) - flt(exp))
|
||||
return {'cl':[r[0] for r in ret]}#, 'pl':pl}
|
||||
|
||||
def get_company_currency(self,arg=''):
|
||||
ret = sql("select default_currency from tabCompany where name=%s and docstatus != 2", arg)
|
||||
return ret[0]
|
||||
def get_company_currency(self,arg=''):
|
||||
dcc = TransactionBase().get_company_currency(arg)
|
||||
return dcc
|
||||
|
||||
# Get current balance
|
||||
# --------------------
|
||||
|
@ -15,7 +15,7 @@ in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
@ -238,7 +238,7 @@ class DocType:
|
||||
if self.doc.total_debit > 0:
|
||||
self.get_tds_category_account()
|
||||
if self.doc.supplier_account and self.doc.tds_category:
|
||||
get_obj('TDS Control').get_tds_amount(self)
|
||||
get_obj('TDS Control').get_tds_amount(self)
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
@ -333,6 +333,7 @@ class DocType:
|
||||
# ------------------------
|
||||
def set_print_format_fields(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
#msgprint(self.doc.company)
|
||||
chk_type = sql("select master_type, account_type from `tabAccount` where name='%s'" % d.account)
|
||||
master_type, acc_type = chk_type and cstr(chk_type[0][0]) or '', chk_type and cstr(chk_type[0][1]) or ''
|
||||
if master_type in ['Supplier', 'Customer']:
|
||||
@ -340,9 +341,10 @@ class DocType:
|
||||
self.doc.pay_to_recd_from = get_value(master_type, ' - '.join(d.account.split(' - ')[:-1]), master_type == 'Customer' and 'customer_name' or 'supplier_name')
|
||||
|
||||
if acc_type == 'Bank or Cash':
|
||||
amt = cint(d.debit) and d.debit or d.credit
|
||||
self.doc.total_amount = get_defaults()['currency']+'. '+ cstr(amt)
|
||||
self.doc.total_amount_in_words = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], cstr(amt))
|
||||
dcc = TransactionBase().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))
|
||||
|
||||
|
||||
# --------------------------------
|
||||
|
@ -311,7 +311,8 @@ class DocType(TransactionBase):
|
||||
# Set totals in words
|
||||
#--------------------
|
||||
def set_in_words(self):
|
||||
self.doc.in_words = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], self.doc.rounded_total)
|
||||
dcc = TransactionBase().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)
|
||||
|
||||
# Clear Advances
|
||||
|
@ -210,7 +210,7 @@ pscript.set_ac_head = function(parent_account, r,type) {
|
||||
}
|
||||
$c_obj('GL Control', 'get_company_currency', pscript.ab_company_sel.value, callback);
|
||||
|
||||
d.balance.innerHTML = (dcc ? dcc : sys_defaults.currency)+ ' ' + (r.balance ? fmt_money(r.balance) :'0.00');
|
||||
d.balance.innerHTML = (dcc)+ ' ' + (r.balance ? fmt_money(r.balance) :'0.00');
|
||||
}
|
||||
//cost center group/ledger area
|
||||
else{
|
||||
|
@ -207,7 +207,8 @@ class DocType(TransactionBase):
|
||||
sales_com_obj.check_conversion_rate(self)
|
||||
|
||||
# Get total in words
|
||||
self.doc.in_words = sales_com_obj.get_total_in_words(get_defaults()['currency'], self.doc.rounded_total)
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
|
||||
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
|
||||
|
||||
def on_update(self):
|
||||
|
@ -305,7 +305,8 @@ class DocType(TransactionBase):
|
||||
sales_com_obj.make_packing_list(self,'sales_order_details')
|
||||
|
||||
# get total in words
|
||||
self.doc.in_words = sales_com_obj.get_total_in_words(get_defaults()['currency'], self.doc.rounded_total)
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
|
||||
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
|
||||
|
||||
# set SO status
|
||||
|
@ -175,7 +175,8 @@ class DocType(TransactionBase):
|
||||
sales_com_obj.get_allocated_sum(self) # this is to verify that the allocated % of sales persons is 100%
|
||||
sales_com_obj.check_conversion_rate(self)
|
||||
# ::::::: Get total in Words ::::::::
|
||||
self.doc.in_words = sales_com_obj.get_total_in_words(get_defaults()['currency'], self.doc.rounded_total)
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
|
||||
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
|
||||
|
||||
# ::::::: Set actual qty for each item in selected warehouse :::::::
|
||||
|
@ -15,9 +15,9 @@ in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
|
||||
class DocType:
|
||||
class DocType(TransactionBase):
|
||||
def __init__(self,doc,doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
@ -118,7 +118,8 @@ class DocType:
|
||||
#=======================================================
|
||||
def validate(self):
|
||||
self.check_existing()
|
||||
self.doc.total_in_words = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], self.doc.rounded_total)
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
self.doc.total_in_words = get_obj('Sales Common').get_total_in_words(dcc, self.doc.rounded_total)
|
||||
|
||||
# ON SUBMIT
|
||||
#=======================================================
|
||||
|
@ -15,9 +15,9 @@ in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
|
||||
class DocType:
|
||||
class DocType(TransactionBase):
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
@ -42,7 +42,8 @@ class DocType:
|
||||
if not has_common(appr_roles, webnotes.user.get_roles()) and not has_common(appr_users, session['user']):
|
||||
msg, add_msg = '',''
|
||||
if max_amount:
|
||||
if based_on == 'Grand Total': msg = "since Grand Total exceeds %s. %s" % (get_defaults()['currency'], flt(max_amount))
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
if based_on == 'Grand Total': msg = "since Grand Total exceeds %s. %s" % (dcc, flt(max_amount))
|
||||
elif based_on == 'Itemwise Discount': msg = "since Discount exceeds %s for Item Code : %s" % (cstr(max_amount)+'%', item)
|
||||
elif based_on == 'Average Discount' or based_on == 'Customerwise Discount': msg = "since Discount exceeds %s" % (cstr(max_amount)+'%')
|
||||
|
||||
|
@ -133,7 +133,8 @@ class DocType(TransactionBase):
|
||||
|
||||
|
||||
# get total in words
|
||||
self.doc.in_words = pc_obj.get_total_in_words(get_defaults().get('currency') and get_defaults()['currency'] or 'INR', self.doc.grand_total)
|
||||
dcc = TransactionBase().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)
|
||||
|
||||
# update bin
|
||||
|
@ -1,5 +1,5 @@
|
||||
import webnotes
|
||||
from webnotes.utils import load_json, cint, cstr, flt
|
||||
from webnotes.utils import load_json, cint, cstr, flt, get_defaults
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes import msgprint
|
||||
@ -202,3 +202,10 @@ class TransactionBase:
|
||||
ch.incentives = d and flt(d[3]) or 0
|
||||
ch.idx = idx
|
||||
idx += 1
|
||||
|
||||
# Get Company Specific Default Currency
|
||||
# -------------------------------------
|
||||
def get_company_currency(self, name):
|
||||
ret = sql("select default_currency from tabCompany where name = '%s'" %(name))
|
||||
dcc = ret and ret[0][0] or get_defaults()['currency']
|
||||
return dcc
|
||||
|
Loading…
x
Reference in New Issue
Block a user