hct improve
parent
71eb85568b
commit
f32fd7dc19
|
@ -1,13 +1,9 @@
|
||||||
<inherit model="partner" inherit="contact_form">
|
<inherit model="partner" inherit="contact_form">
|
||||||
<!--
|
<tab string="Services" position="after">
|
||||||
<field name="payment_terms" position="after">
|
<tab string="Other">
|
||||||
<newline/>
|
<field name="walkin_cust"/>
|
||||||
<separator string="Clinic"/>
|
<field name="is_patient"/>
|
||||||
<field name="account_fee_id" attrs='{"required":[["type","=","org"]]}'/>
|
</tab>
|
||||||
<field name="account_mdc_id" attrs='{"required":[["type","=","org"]]}'/>
|
</tab>
|
||||||
<field name="account_service_id" attrs='{"required":[["type","=","org"]]}'/>
|
|
||||||
<field name="account_payment_id" attrs='{"required":[["type","=","org"]]}'/>
|
|
||||||
<field name="account_income_id" attrs='{"required":[["type","=","org"]]}'/>
|
|
||||||
</field>
|
|
||||||
-->
|
|
||||||
</inherit>
|
</inherit>
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="1">
|
||||||
<item string="New Dialyzer" action="clinic_hd_case_dlz" states="draft,in_progress,waiting_treatment"/>
|
<item string="New Dialyzer" action="clinic_hd_case_dlz" states="draft,in_progress,waiting_treatment"/>
|
||||||
<!--<item string="RD Shop" method="new_shop" states="draft,in_progress,waiting_treatment"/>-->
|
|
||||||
<item string="To Draft" method="to_draft" states="paid,waiting_payment,completed,cancelled"/>
|
<item string="To Draft" method="to_draft" states="paid,waiting_payment,completed,cancelled"/>
|
||||||
</button>
|
</button>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<form model="clinic.shop" attrs='{"readonly":[["state","in",["cancelled","paid","waiting_payment"]]]}' show_company="1">
|
<form model="clinic.shop" attrs='{"readonly":[["state","in",["cancelled","paid","waiting_payment"]]]}' show_company="1">
|
||||||
<head>
|
<head>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<button string="Print" icon="print" action="clinic_cust_print" action_options="convert=pdf"/>
|
<button string="Print" icon="print" method="print_bill" action_options="convert=pdf"/>
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="1">
|
||||||
<item string="To Draft" method="to_draft" states="paid"/>
|
<item string="To Draft" method="to_draft" states="paid"/>
|
||||||
</button>
|
</button>
|
||||||
|
@ -9,11 +9,16 @@
|
||||||
<group form_layout="stacked">
|
<group form_layout="stacked">
|
||||||
<field name="number" span="2"/>
|
<field name="number" span="2"/>
|
||||||
<field name="patient_id" span="2" onchange="onchange_patient"/>
|
<field name="patient_id" span="2" onchange="onchange_patient"/>
|
||||||
<field name="contact_id" required='1' span="2"/>
|
<field name="contact_id" domain='["or",["is_patient","=","true"],["walkin_cust","=","true"]]' onchange="onchange_contact" required='1' span="2"/>
|
||||||
<field name="ref" span="2"/>
|
<field name="ref" span="2"/>
|
||||||
<field name="date" span="2"/>
|
<field name="date" span="2"/>
|
||||||
<field name="branch_id" span="2"/>
|
<field name="branch_id" span="2"/>
|
||||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||||
|
<field name="pay_type" span="2"/>
|
||||||
|
<field name="pay_date" span="2" attrs='{"invisible":[["pay_type","=","credit"]],"readonly":[["state","=","blabla"]]}'/>
|
||||||
|
<field name="cheque_no" span="2" attrs='{"invisible":[["pay_type","=","credit"]],"readonly":[["state","=","blabla"]]}'/>
|
||||||
|
<field name="bank_name" span="2" attrs='{"invisible":[["pay_type","=","credit"]],"readonly":[["state","=","blabla"]]}'/>
|
||||||
|
<field name="bank_branch" span="2" attrs='{"invisible":[["pay_type","=","credit"]],"readonly":[["state","=","blabla"]]}'/>
|
||||||
<field name="hd_case_call" invisible="1"/>
|
<field name="hd_case_call" invisible="1"/>
|
||||||
<field name="shop_categs" invisible="1"/>
|
<field name="shop_categs" invisible="1"/>
|
||||||
<field name="company_id" invisible="1"/>
|
<field name="company_id" invisible="1"/>
|
||||||
|
@ -36,16 +41,19 @@
|
||||||
<field name="total"/>
|
<field name="total"/>
|
||||||
</group>
|
</group>
|
||||||
</tab>
|
</tab>
|
||||||
|
<tab string="Note">
|
||||||
|
<field name="note" nolabel="1"/>
|
||||||
|
</tab>
|
||||||
<tab string="Other">
|
<tab string="Other">
|
||||||
<field name="related_id" span="3"/>
|
<field name="related_id" span="3"/>
|
||||||
<field name="user_id" span="3"/>
|
<field name="user_id" span="3"/>
|
||||||
<field name="pay_type" span="3"/>
|
|
||||||
</tab>
|
</tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
</group>
|
</group>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Cash" method="pay_cash" states="draft" type="success"/>
|
<button string="Pay" method="pay" states="draft" type="success"/>
|
||||||
<button string="Credit" method="pay_credit" states="draft" type="default"/>
|
<!--<button string="Cash" method="pay_cash" states="draft" type="success"/>-->
|
||||||
|
<!--<button string="Credit" method="pay_credit" states="draft" type="default"/>-->
|
||||||
</foot>
|
</foot>
|
||||||
<related>
|
<related>
|
||||||
<field name="invoices"/>
|
<field name="invoices"/>
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<list model="clinic.shop" colors='{"#cfc":[["state","=","paid"]],"#f9e37d":[["state","=","waiting_payment"]],"#bcbbb9":[["state","=","cancelled"]],"#ACD1E9":[["state","=","waiting_payment"]]}'>
|
<list model="clinic.shop" colors='{"#cfc":[["state","=","paid"]],"#f9e37d":[["state","=","waiting_payment"]],"#bcbbb9":[["state","=","cancelled"]],"#ACD1E9":[["state","=","waiting_payment"]]}'>
|
||||||
|
<head>
|
||||||
|
<button string="Print" icon="print" action="clinic_cust_print" action_options="convert=pdf"/>
|
||||||
|
</head>
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="contact_id"/>
|
<field name="contact_id"/>
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
<inherit model="settings" inherit="fin_settings">
|
|
||||||
<!--<field name="rounding_account_id" position="after">-->
|
|
||||||
<!--<separator string="Clinic (Patient pay by them-self)"/>-->
|
|
||||||
<!--<field name="cash_account_id" domain="[['type','!=','view']]"/>-->
|
|
||||||
<!--<field name="income_account_id" domain="[['type','!=','view']]"/>-->
|
|
||||||
<!--<field name="ap_doctor_id"/>-->
|
|
||||||
<!--</field>-->
|
|
||||||
</inherit>
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<inherit model="settings" inherit="org_settings">
|
||||||
|
<field name="website" position="after">
|
||||||
|
<field name="tax_no"/>
|
||||||
|
</field>
|
||||||
|
</inherit>
|
|
@ -838,8 +838,9 @@ class HDCase(Model):
|
||||||
inv.write({
|
inv.write({
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
})
|
})
|
||||||
inv.move_id.to_draft()
|
if inv.move_id:
|
||||||
inv.move_id.delete()
|
inv.move_id.to_draft()
|
||||||
|
inv.move_id.delete()
|
||||||
inv.delete()
|
inv.delete()
|
||||||
for pick in obj.pickings:
|
for pick in obj.pickings:
|
||||||
pick.write({
|
pick.write({
|
||||||
|
@ -1155,7 +1156,17 @@ class HDCase(Model):
|
||||||
vals=self.get_hct(vals,patient_id)
|
vals=self.get_hct(vals,patient_id)
|
||||||
new_id=super().create(vals,**kw)
|
new_id=super().create(vals,**kw)
|
||||||
self.function_store([new_id])
|
self.function_store([new_id])
|
||||||
|
obj=self.browse(new_id)
|
||||||
|
self.check_hct(obj)
|
||||||
return new_id
|
return new_id
|
||||||
|
|
||||||
|
def check_hct(self,obj):
|
||||||
|
if obj.hct_include:
|
||||||
|
if not obj.hct:
|
||||||
|
raise Exception("Please define HCT")
|
||||||
|
else:
|
||||||
|
if len(str(obj.hct))<=1:
|
||||||
|
raise Exception("HCT should be more that 9")
|
||||||
|
|
||||||
def write(self,ids,vals,**kw):
|
def write(self,ids,vals,**kw):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
@ -1236,6 +1247,8 @@ class HDCase(Model):
|
||||||
})
|
})
|
||||||
self.function_store(ids)
|
self.function_store(ids)
|
||||||
super().write(ids,vals,**kw)
|
super().write(ids,vals,**kw)
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
self.check_hct(obj)
|
||||||
|
|
||||||
def approve(self,ids,context={}):
|
def approve(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
|
|
@ -4,11 +4,8 @@ class Partner(Model):
|
||||||
_inherit="partner"
|
_inherit="partner"
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
"account_mdc_id": fields.Many2One("account.account","Account Receiveable Medicine",multi_company=True),
|
'walkin_cust': fields.Boolean("Walkin Customer"),
|
||||||
"account_fee_id": fields.Many2One("account.account","Account Receiveable Fee",multi_company=True),
|
'is_patient': fields.Boolean("Is Patient"),
|
||||||
"account_service_id": fields.Many2One("account.account","Account Receiveable Service",multi_company=True),
|
|
||||||
"account_payment_id": fields.Many2One("account.account","Account Payment",multi_company=True),
|
|
||||||
"account_income_id": fields.Many2One("account.account","Account Income",multi_company=True),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Partner.register()
|
Partner.register()
|
||||||
|
|
|
@ -165,6 +165,7 @@ class Patient(Model):
|
||||||
'name': obj.name,
|
'name': obj.name,
|
||||||
'last_name': obj.name,
|
'last_name': obj.name,
|
||||||
'type': 'person',
|
'type': 'person',
|
||||||
|
'is_patient': True,
|
||||||
})
|
})
|
||||||
address_id=get_model('address').create({
|
address_id=get_model('address').create({
|
||||||
'type': 'shipping',
|
'type': 'shipping',
|
||||||
|
@ -219,6 +220,7 @@ class Patient(Model):
|
||||||
'name': obj.name,
|
'name': obj.name,
|
||||||
'last_name': obj.name,
|
'last_name': obj.name,
|
||||||
'type': 'person',
|
'type': 'person',
|
||||||
|
'is_patient': True,
|
||||||
})
|
})
|
||||||
vals['partner_id']=partner_id
|
vals['partner_id']=partner_id
|
||||||
|
|
||||||
|
|
|
@ -108,16 +108,13 @@ class ClinicSetting(Model):
|
||||||
if user_id !=1:
|
if user_id !=1:
|
||||||
print("Only admin!!")
|
print("Only admin!!")
|
||||||
return
|
return
|
||||||
cbv_id=None
|
for pt in get_model("clinic.patient").search_browse([]):
|
||||||
for cbv in get_model("conv.bal").search_browse([]):
|
partner=pt.partner_id
|
||||||
if cbv.file:
|
if partner:
|
||||||
cbv_id=cbv.id
|
partner.write({
|
||||||
print(get_file_path(cbv.file))
|
'is_patient': True,
|
||||||
cbv=get_model("conv.bal").browse(cbv_id)
|
})
|
||||||
#if cbv:
|
print("Done!")
|
||||||
#print("running ...")
|
|
||||||
#get_model("conv.bal").import_sale_file([cbv.id],context=context)
|
|
||||||
print("Done! ", cbv.id)
|
|
||||||
|
|
||||||
def reset_last_import(self,ids,context={}):
|
def reset_last_import(self,ids,context={}):
|
||||||
res=get_model("clinic.report.payment.matching").search_read([],['date'],order="date desc")
|
res=get_model("clinic.report.payment.matching").search_read([],['date'],order="date desc")
|
||||||
|
|
|
@ -3,6 +3,7 @@ import time
|
||||||
from netforce.model import Model, fields, get_model
|
from netforce.model import Model, fields, get_model
|
||||||
from netforce.access import get_active_user, set_active_user, get_active_company
|
from netforce.access import get_active_user, set_active_user, get_active_company
|
||||||
from netforce.utils import get_data_path, get_file_path
|
from netforce.utils import get_data_path, get_file_path
|
||||||
|
from . import utils
|
||||||
|
|
||||||
class Shop(Model):
|
class Shop(Model):
|
||||||
_name="clinic.shop"
|
_name="clinic.shop"
|
||||||
|
@ -45,7 +46,14 @@ class Shop(Model):
|
||||||
"related_id": fields.Reference([["sale.order","Sales Order"],["purchase.order","Purchase Order"],["project","Project"],["job","Service Order"],["service.contract","Service Contract"]],"Related To"),
|
"related_id": fields.Reference([["sale.order","Sales Order"],["purchase.order","Purchase Order"],["project","Project"],["job","Service Order"],["service.contract","Service Contract"]],"Related To"),
|
||||||
'company_id': fields.Many2One("company","Company"),
|
'company_id': fields.Many2One("company","Company"),
|
||||||
"pay_type": fields.Selection([("cash","Cash"),("credit","Credit")],"Pay Type"),
|
"pay_type": fields.Selection([("cash","Cash"),("credit","Credit")],"Pay Type"),
|
||||||
|
"pay_by": fields.Selection([("cash","Cash"),("cheque","Cheque")],"Pay By"),
|
||||||
|
'pay_date': fields.Date("Pay Date"),
|
||||||
|
'bank_name': fields.Char("Bank"),
|
||||||
|
'bank_branch': fields.Char("Bank Branch"),
|
||||||
|
'cheque_no': fields.Char("Cheque No."),
|
||||||
'hd_case_call': fields.Boolean("HD Case Call"),
|
'hd_case_call': fields.Boolean("HD Case Call"),
|
||||||
|
'note': fields.Text("Note"),
|
||||||
|
'is_cheque': fields.Boolean("Is Cheque"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_branch(self,context={}):
|
def _get_branch(self,context={}):
|
||||||
|
@ -172,6 +180,21 @@ class Shop(Model):
|
||||||
data['contact_id']=contact.id
|
data['contact_id']=contact.id
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def onchange_contact(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
contact_id=data['contact_id']
|
||||||
|
data['patient_id']=None
|
||||||
|
data['department_id']=None
|
||||||
|
data['branch_id']=None
|
||||||
|
print("contact_id ", contact_id)
|
||||||
|
for patient in get_model("clinic.patient").search_browse([['partner_id','=',contact_id]]):
|
||||||
|
dpt=patient.department_id
|
||||||
|
branch=patient.branch_id
|
||||||
|
data['department_id']=dpt.id
|
||||||
|
data['branch_id']=branch.id
|
||||||
|
data['patient_id']=patient.id
|
||||||
|
return data
|
||||||
|
|
||||||
def create(self,vals,**kw):
|
def create(self,vals,**kw):
|
||||||
id=super().create(vals,**kw)
|
id=super().create(vals,**kw)
|
||||||
self.function_store([id])
|
self.function_store([id])
|
||||||
|
@ -478,7 +501,6 @@ class Shop(Model):
|
||||||
if cust.addresses:
|
if cust.addresses:
|
||||||
cust_addr=cust.addresses[0].address_text
|
cust_addr=cust.addresses[0].address_text
|
||||||
|
|
||||||
#if cust_name.lower()=='walk
|
|
||||||
if cust.walkin_cust:
|
if cust.walkin_cust:
|
||||||
cust_name=shop.ref or ''
|
cust_name=shop.ref or ''
|
||||||
no=1
|
no=1
|
||||||
|
@ -498,22 +520,34 @@ class Shop(Model):
|
||||||
'amount': amt,
|
'amount': amt,
|
||||||
})
|
})
|
||||||
sub_total+=amt
|
sub_total+=amt
|
||||||
amount_total+=sub_total #XXX
|
|
||||||
no+=1
|
no+=1
|
||||||
|
amount_total=sub_total #XXX
|
||||||
|
is_cash=''
|
||||||
|
is_cheque=shop.is_cheque and 'x' or ''
|
||||||
|
if shop.pay_type=='cash':
|
||||||
|
is_cash='x'
|
||||||
|
is_draft=shop.state=='draft' and True or False
|
||||||
data={
|
data={
|
||||||
'comp_name': comp.name or '',
|
'comp_name': comp.name or '',
|
||||||
'comp_addr': comp_addr or '',
|
'comp_addr': comp_addr or '',
|
||||||
|
'tax_no': st.tax_no or '',
|
||||||
'number': shop.number or '',
|
'number': shop.number or '',
|
||||||
'ref': shop.ref,
|
'ref': shop.ref,
|
||||||
'date': shop.date,
|
'date': shop.date,
|
||||||
'cust_name': cust_name,
|
'cust_name': cust_name,
|
||||||
'cust_addr': cust_addr,
|
'cust_addr': cust_addr,
|
||||||
|
'note': shop.note or '',
|
||||||
'lines':lines,
|
'lines':lines,
|
||||||
'sub_total': sub_total,
|
'amount_subtotal': sub_total,
|
||||||
'amount_total': amount_total,
|
'amount_total': amount_total,
|
||||||
|
'total_text': utils.num2word(amount_total),
|
||||||
|
'is_cheque': is_cheque,
|
||||||
|
'is_cash': is_cash,
|
||||||
|
'is_draft': is_draft,
|
||||||
}
|
}
|
||||||
if comp.logo:
|
if st.logo:
|
||||||
data['logo']=get_file_path(comp.logo)
|
data['logo']=get_file_path(st.logo)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_data(self,ids,context={}):
|
def get_data(self,ids,context={}):
|
||||||
|
@ -529,5 +563,25 @@ class Shop(Model):
|
||||||
"pages": pages,
|
"pages": pages,
|
||||||
"logo": get_file_path(settings.logo),
|
"logo": get_file_path(settings.logo),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def print_bill(self,ids,context={}):
|
||||||
|
return {
|
||||||
|
'next': {
|
||||||
|
'refer_id': ids[0],
|
||||||
|
'name': 'clinic_cust_print',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def pay(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
if not obj.lines:
|
||||||
|
raise Exception("No item")
|
||||||
|
|
||||||
|
if obj.pay_type=='cash':
|
||||||
|
res=obj.pay_cash()
|
||||||
|
else:
|
||||||
|
res=obj.pay_credit()
|
||||||
|
return res
|
||||||
|
|
||||||
Shop.register()
|
Shop.register()
|
||||||
|
|
|
@ -2,6 +2,39 @@ from datetime import datetime
|
||||||
import xlrd
|
import xlrd
|
||||||
import xmltodict
|
import xmltodict
|
||||||
|
|
||||||
|
currency={ 'th_TH': {'name': 'บาท', 'partial': 'สตางค์', 'end': 'ถ้วน'}
|
||||||
|
, 'en_US': {'name': 'BAHT', 'partial': 'SATANG', 'end': 'ONLY'}
|
||||||
|
}
|
||||||
|
sym={
|
||||||
|
"en_US": {
|
||||||
|
"positive": "",
|
||||||
|
"negative": "MINUS",
|
||||||
|
"sep": " ",
|
||||||
|
"0": "ZERO",
|
||||||
|
"x": ["ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE"],
|
||||||
|
"1x": ["TEN", "ELEVEN", "TWELVE", "THIRTEEN", "FOURTEEN", "FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN", "NINETEEN"],
|
||||||
|
"x0": ["TWENTY", "THIRTY", "FORTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY"],
|
||||||
|
"100": "HUNDRED",
|
||||||
|
"1K": "THOUSAND",
|
||||||
|
"1M": "MILLION",
|
||||||
|
"and": "AND",
|
||||||
|
},
|
||||||
|
"th_TH": {
|
||||||
|
"positive": "",
|
||||||
|
"negative": "ลบ",
|
||||||
|
"sep": "",
|
||||||
|
"0": "ศูนย์",
|
||||||
|
"x": ["หนึ่ง","สอง","สาม","สี่","ห้า","หก","เจ็ด","แปด","เก้า"],
|
||||||
|
"x0": ["สิบ","ยี่สิบ","สามสิบ","สี่สิบ","ห้าสิบ","หกสิบ","เจ็ดสิบ","แปดสิบ","เก้าสิบ"],
|
||||||
|
"x1": "เอ็ด",
|
||||||
|
"100": "ร้อย",
|
||||||
|
"1K": "พัน",
|
||||||
|
"10K": "หมื่น",
|
||||||
|
"100K": "แสน",
|
||||||
|
"1M": "ล้าน",
|
||||||
|
"and": "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DAYS={
|
DAYS={
|
||||||
'th_TH': ['จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์', 'อาทิตย์'],
|
'th_TH': ['จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์', 'อาทิตย์'],
|
||||||
|
@ -38,6 +71,96 @@ TOPICS={
|
||||||
'topic8': {'name': 'จำนวนผู้ป่วยจ่ายเอง', 'unit': 'คน'},
|
'topic8': {'name': 'จำนวนผู้ป่วยจ่ายเอง', 'unit': 'คน'},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _num2word(n,l="en_US"):
|
||||||
|
number=n
|
||||||
|
if number==0:
|
||||||
|
return sym[l]["0"] + ""
|
||||||
|
elif number<10:
|
||||||
|
return sym[l]["x"][number-1]
|
||||||
|
elif number<100:
|
||||||
|
if l=="en_US":
|
||||||
|
if number<20:
|
||||||
|
return sym[l]["1x"][number-10]
|
||||||
|
else:
|
||||||
|
return sym[l]["x0"][int(number/10-2)]+(number%10 and sym[l]["sep"]+_num2word(number%10,l) or "")
|
||||||
|
elif l=="th_TH":
|
||||||
|
return sym[l]["x0"][int(number/10-1)]+(number%10 and (number%10==1 and sym[l]["x1"] or sym[l]["x"][number%10-1]) or "")
|
||||||
|
elif number<1000:
|
||||||
|
return sym[l]["x"][int(number/100-1)]+sym[l]["sep"]+sym[l]["100"]+(number%100 and sym[l]["sep"]+_num2word(number%100,l) or "")
|
||||||
|
|
||||||
|
elif number<1000000:
|
||||||
|
if l=="en_US":
|
||||||
|
return _num2word(int(number/1000),l)+sym[l]["sep"]+sym[l]["1K"]+(number%1000 and sym[l]["sep"]+_num2word(number%1000,l) or "")
|
||||||
|
elif l=="th_TH":
|
||||||
|
if number<10000:
|
||||||
|
return sym[l]["x"][int(number/1000-1)]+sym[l]["1K"]+(number%1000 and _num2word(number%1000,l) or "")
|
||||||
|
elif number<100000:
|
||||||
|
return sym[l]["x"][int(number/10000-1)]+sym[l]["10K"]+(number%10000 and _num2word(number%10000,l) or "")
|
||||||
|
else:
|
||||||
|
return sym[l]["x"][int(number/100000-1)]+sym[l]["100K"]+(number%100000 and _num2word(number%100000,l) or "")
|
||||||
|
elif number<1000000000:
|
||||||
|
return _num2word(int(number/1000000),l)+sym[l]["sep"]+sym[l]["1M"]+sym[l]["sep"]+(number%1000000 and _num2word(number%1000000,l) or "")
|
||||||
|
else:
|
||||||
|
return "N/A"
|
||||||
|
|
||||||
|
def num2word(n,l="th_TH"):
|
||||||
|
'''
|
||||||
|
>>> num2word(-666, 'en_US')
|
||||||
|
'MINUS SIX HUNDRED SIXTY SIX BAHT ONLY'
|
||||||
|
|
||||||
|
>>> print num2word(-1024, 'th_TH')
|
||||||
|
ลบหนึ่งพันยี่สิบสี่บาทถ้วน
|
||||||
|
|
||||||
|
>>> num2word(42.00, 'en_US')
|
||||||
|
'FORTY TWO BAHT ONLY'
|
||||||
|
|
||||||
|
>>> print num2word(42.00, 'th_TH')
|
||||||
|
สี่สิบสองบาทถ้วน
|
||||||
|
|
||||||
|
>>> num2word(29348.23, 'en_US')
|
||||||
|
'TWENTY NINE THOUSAND THREE HUNDRED FORTY EIGHT BAHT AND TWENTY THREE SATANG'
|
||||||
|
|
||||||
|
>>> print num2word(29348.23, 'th_TH')
|
||||||
|
สองหมื่นเก้าพันสามร้อยสี่สิบแปดบาทยี่สิบสามสตางค์
|
||||||
|
|
||||||
|
>>> num2word(293812913.12, 'en_US')
|
||||||
|
'TWO HUNDRED NINETY THREE MILLION EIGHT HUNDRED TWELVE THOUSAND NINE HUNDRED THIRTEEN BAHT AND TWELVE SATANG'
|
||||||
|
|
||||||
|
>>> print num2word(293812913.12, 'th_TH')
|
||||||
|
สองร้อยเก้าสิบสามล้านแปดแสนหนึ่งหมื่นสองพันเก้าร้อยสิบสามบาทสิบสองสตางค์
|
||||||
|
|
||||||
|
>>> print num2word(0.0, 'th_TH')
|
||||||
|
ศูนย์บาทถ้วน
|
||||||
|
|
||||||
|
>>> print num2word(0.75, 'th_TH')
|
||||||
|
เจ็ดสิบห้าสตางค์
|
||||||
|
'''
|
||||||
|
|
||||||
|
base=0
|
||||||
|
end=0
|
||||||
|
number = n
|
||||||
|
print("number", number)
|
||||||
|
if type(n) == type(''):
|
||||||
|
number=float(n)
|
||||||
|
word = ''
|
||||||
|
if type(number) in (int, float):
|
||||||
|
sign = 'positive' if number >= 0 else 'negative'
|
||||||
|
number = abs(number)
|
||||||
|
number = ('%.2f'%number).split('.')
|
||||||
|
base = _num2word(int(number[0]),l=l) if int(number[0]) > 0 else 0
|
||||||
|
if int(number[1])!=0:
|
||||||
|
end = _num2word(int(number[1]),l=l)
|
||||||
|
if base != 0 and end == 0:
|
||||||
|
word = sym[l][sign] + sym[l]['sep'] + base + sym[l]['sep'] + currency[l]['name'] + sym[l]['sep'] + currency[l]['end']
|
||||||
|
if base != 0 and end != 0:
|
||||||
|
word = sym[l][sign] + sym[l]['sep'] + base + sym[l]['sep'] + currency[l]['name'] + sym[l]['sep'] + sym[l]['and'] + sym[l]['sep'] + end+sym[l]['sep'] + currency[l]['partial']
|
||||||
|
if base == 0 and end != 0:
|
||||||
|
word = sym[l][sign] + sym[l]['sep'] + sym[l]['and'] + sym[l]['sep'] + end+sym[l]['sep'] + currency[l]['partial']
|
||||||
|
if base == 0 and end == 0:
|
||||||
|
base = _num2word(0.00,l=l)
|
||||||
|
word = sym[l][sign] + sym[l]['sep'] + base + sym[l]['sep'] + currency[l]['name'] + sym[l]['sep'] + currency[l]['end']
|
||||||
|
return word.strip()
|
||||||
|
|
||||||
def read_excel(fpath=None,show_datetime=False):
|
def read_excel(fpath=None,show_datetime=False):
|
||||||
data={}
|
data={}
|
||||||
if fpath:
|
if fpath:
|
||||||
|
|
Binary file not shown.
|
@ -1,22 +1,20 @@
|
||||||
<table class="table table-condensed table-striped">
|
<table class="table table-condensed table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<th rowspan="2">#</th>
|
<tr>
|
||||||
<th rowspan="2">Name</th>
|
<th></th>
|
||||||
<th colspan="{{comp_span}}">
|
<th></th>
|
||||||
<table class="table" style="margin-bottom:0px">
|
<th style="text-align:center" colspan="{{comp_span}}">{{comp_name}}</th>
|
||||||
<thead>
|
<th></th>
|
||||||
<th style="text-align:center" colspan="{{comp_span}}">{{comp_name}}</th>
|
</tr>
|
||||||
</thead>
|
<tr>
|
||||||
<tbody>
|
<th rowspan="2">#</th>
|
||||||
<tr>
|
<th rowspan="2">Name</th>
|
||||||
{{#each dpts}}
|
{{#each dpts}}
|
||||||
<td style="text-align:right">{{name}}</td>
|
<th style="text-align:right">{{name}}</th>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tr>
|
</th>
|
||||||
</tbody>
|
<th rowspan="2" style="text-align:right;">Total</th>
|
||||||
</table>
|
</tr>
|
||||||
</th>
|
|
||||||
<th rowspan="2" style="text-align:center;">Total</th>
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{#each lines }}
|
{{#each lines }}
|
||||||
|
|
Loading…
Reference in New Issue