create contact for staff
parent
8a16157c61
commit
5fdb377c1a
|
@ -3,6 +3,7 @@
|
|||
<tab string="Other">
|
||||
<field name="walkin_cust"/>
|
||||
<field name="is_patient"/>
|
||||
<field name="is_staff"/>
|
||||
</tab>
|
||||
</tab>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<field name="type_id"/>
|
||||
<field name="name"/>
|
||||
<field name="reg_date"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="partner_id" domain='[["is_patient","=","true"]]'/>
|
||||
<field name="categ_id"/>
|
||||
<field name="doctor_id"/>
|
||||
<field name="department_id"/>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<field name="name"/>
|
||||
<field name="name_eng"/>
|
||||
<field name="nick_name"/>
|
||||
<field name="partner_id" domain='[["is_staff","=","true"]]'/>
|
||||
<field name="branch_id" required="1"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' required="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
|
|
|
@ -1,39 +1,40 @@
|
|||
from netforce.model import get_model
|
||||
from netforce import migration
|
||||
from netforce.access import set_active_user, get_active_user
|
||||
|
||||
class Migration(migration.Migration):
|
||||
_name="import.acc"
|
||||
_version="2.11.0"
|
||||
|
||||
def migrate(self):
|
||||
data={}
|
||||
lines=get_model("conv.bal").search_browse([])
|
||||
for conv in lines:
|
||||
if conv.id==24:
|
||||
for invoice in conv.sale_invoices:
|
||||
amount_due=invoice.amount_due or 0
|
||||
number=invoice.number or ""
|
||||
if not data.get(number):
|
||||
data[number]={'amount_due': amount_due}
|
||||
#data={}
|
||||
#lines=get_model("conv.bal").search_browse([])
|
||||
#for conv in lines:
|
||||
#if conv.id==24:
|
||||
#for invoice in conv.sale_invoices:
|
||||
#amount_due=invoice.amount_due or 0
|
||||
#number=invoice.number or ""
|
||||
#if not data.get(number):
|
||||
#data[number]={'amount_due': amount_due}
|
||||
|
||||
f=open("/tmp/ar.csv","r")
|
||||
res=f.read().split("\n")
|
||||
total=0.0
|
||||
del res[0]
|
||||
st=""
|
||||
no=1
|
||||
for r in res:
|
||||
r=r.split(",")
|
||||
number=r[0]
|
||||
if not data.get(number):
|
||||
st+=','.join(r)
|
||||
st+='\n'
|
||||
print(no, 'XXX ', r)
|
||||
no+=1
|
||||
f=open("res.csv","w")
|
||||
f.write(st)
|
||||
f.close()
|
||||
print("diff ", total)
|
||||
#f=open("/tmp/ar.csv","r")
|
||||
#res=f.read().split("\n")
|
||||
#total=0.0
|
||||
#del res[0]
|
||||
#st=""
|
||||
#no=1
|
||||
#for r in res:
|
||||
#r=r.split(",")
|
||||
#number=r[0]
|
||||
#if not data.get(number):
|
||||
#st+=','.join(r)
|
||||
#st+='\n'
|
||||
#print(no, 'XXX ', r)
|
||||
#no+=1
|
||||
#f=open("res.csv","w")
|
||||
#f.write(st)
|
||||
#f.close()
|
||||
#print("diff ", total)
|
||||
|
||||
#cbv_id=24
|
||||
#cbv=get_model("conv.bal").browse(cbv_id)
|
||||
|
@ -46,6 +47,34 @@ class Migration(migration.Migration):
|
|||
#})
|
||||
#print("import sale file (step 2)running ...")
|
||||
#get_model("conv.bal").import_sale_file([cbv.id],context={})
|
||||
#user_id=get_active_user()
|
||||
#print("user_id ", user_id)
|
||||
#set_active_user(1)
|
||||
#cbv_id=24
|
||||
#print("create_open_entry...")
|
||||
#cbv=get_model("conv.bal").browse(cbv_id)
|
||||
#old={}
|
||||
#for purchase in cbv.purch_invoices:
|
||||
#number=purchase.number or ''
|
||||
#print('number ', number)
|
||||
#if not old.get(number):
|
||||
#old.update({
|
||||
#'x': [number],
|
||||
#})
|
||||
#else:
|
||||
#x=old[number]['x']
|
||||
#number='%s.%s'%(number,len(x))
|
||||
#print('!!number ', number)
|
||||
#purchase.write({
|
||||
#'number': number,
|
||||
#})
|
||||
#x.append(number)
|
||||
#cbv.create_open_entry()
|
||||
#print("create_sale_invoices...")
|
||||
#cbv.create_sale_invoices()
|
||||
print("create_purch_invoices...")
|
||||
cbv.create_purch_invoices()
|
||||
print("Done!")
|
||||
return True
|
||||
|
||||
Migration.register()
|
||||
|
|
|
@ -80,6 +80,327 @@ class MatchingPayment(Model):
|
|||
raise Exception("No data to match")
|
||||
return lines
|
||||
|
||||
def match(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
lines=obj.get_line()
|
||||
matches1={}
|
||||
matches2={}
|
||||
matches3={}
|
||||
matches4={}
|
||||
dom=[]
|
||||
dom.append(['date',">=",obj.date_from])
|
||||
dom.append(['date',"<=",obj.date_to])
|
||||
dom.append(['patient_id.type_id',"=",obj.patient_type_id.id])
|
||||
dom.append(['state','!=', 'completed'])
|
||||
for exp in get_model('clinic.hd.case.expense').search_browse(dom):
|
||||
patient=exp.patient_id
|
||||
hn=patient.hn_no
|
||||
pid=patient.card_no
|
||||
pid=pid and pid or ""
|
||||
name=patient.name or ''
|
||||
name_check=name.replace(" ","")
|
||||
date=exp.date or ""
|
||||
lfee_amt=exp.fee_amt or 0
|
||||
lmdc_amt=exp.mdc_amt or 0
|
||||
lsrv_amt=exp.srv_amt or 0
|
||||
#hn
|
||||
key1='%s:%s:%s:%s:%s'%(
|
||||
hn,
|
||||
date,
|
||||
lfee_amt,
|
||||
lsrv_amt,
|
||||
lmdc_amt,
|
||||
)
|
||||
# id card
|
||||
key2='%s:%s:%s:%s:%s'%(
|
||||
pid,
|
||||
date,
|
||||
lfee_amt,
|
||||
lsrv_amt,
|
||||
lmdc_amt,
|
||||
)
|
||||
key3='%s:%s:%s:%s:%s'%(
|
||||
name_check,
|
||||
date,
|
||||
lfee_amt,
|
||||
lsrv_amt,
|
||||
lmdc_amt,
|
||||
)
|
||||
key4='%s:%s'%(name_check,date)
|
||||
vals={
|
||||
'pid': pid,
|
||||
'name': name,
|
||||
'date': date,
|
||||
'fee_amt': lfee_amt,
|
||||
'service_amt': lsrv_amt,
|
||||
'epo_amt': lmdc_amt,
|
||||
'hn': hn,
|
||||
'expense_id': exp.id,
|
||||
}
|
||||
if not matches1.get(key1):
|
||||
matches1[key1]=vals
|
||||
if not matches2.get(key2):
|
||||
matches2[key2]=vals
|
||||
if not matches3.get(key3):
|
||||
matches3[key3]=vals
|
||||
if not matches4.get(key3):
|
||||
matches4[key4]=vals
|
||||
nf_hcode=''
|
||||
if obj.hcode_id:
|
||||
nf_hcode=obj.hcode_id.code
|
||||
records=[]
|
||||
if obj.pcode=='SSO':
|
||||
no=1
|
||||
for line in lines:
|
||||
hcode=line.get('hcode18')
|
||||
if not hcode:
|
||||
hcode='0'
|
||||
hcode=int(hcode)
|
||||
hcode=str(hcode)
|
||||
if nf_hcode==hcode:
|
||||
lsrv_amt=line.get('epoadm29') or 0
|
||||
lfee_amt=line.get('amount23') or 0
|
||||
lmdc_amt=line.get('allow37') or 0
|
||||
dttran=line.get("dttran")
|
||||
name=line.get("name14")
|
||||
name2=name
|
||||
name=name.replace(" ","")
|
||||
pid=line.get('pid')
|
||||
date=dttran[0:10]
|
||||
time=dttran[11:] #XXX
|
||||
if not time:
|
||||
print("wrong format")
|
||||
continue
|
||||
hn=line.get('hn')
|
||||
hn=''.join([x for x in hn if x.isdigit()])
|
||||
key1='%s:%s:%s:%s:%s'%(
|
||||
hn,
|
||||
date,
|
||||
lfee_amt,
|
||||
lsrv_amt,
|
||||
lmdc_amt,
|
||||
)
|
||||
key2='%s:%s:%s:%s:%s'%(
|
||||
pid,
|
||||
date,
|
||||
lfee_amt,
|
||||
lsrv_amt,
|
||||
lmdc_amt,
|
||||
)
|
||||
key3='%s:%s:%s:%s:%s'%(
|
||||
name,
|
||||
date,
|
||||
lfee_amt,
|
||||
lsrv_amt,
|
||||
lmdc_amt,
|
||||
)
|
||||
key4='%s:%s'%(name,date)
|
||||
#vals={
|
||||
#'pid': pid,
|
||||
#'name': name,
|
||||
#'date': date,
|
||||
#'fee_amt': lfee_amt,
|
||||
#'service_amt': lsrv_amt,
|
||||
#'epo_amt': lmdc_amt,
|
||||
#}
|
||||
record={
|
||||
'no': no,
|
||||
'date':date,
|
||||
'patient_name': name2,
|
||||
'hn': hn,
|
||||
'fee_amt': lfee_amt,
|
||||
'srv_amt': lsrv_amt,
|
||||
'mdc_amt': lmdc_amt,
|
||||
'note': '',
|
||||
'nf_patient': '',
|
||||
'nf_pid': '',
|
||||
'nf_hn': '',
|
||||
'nf_fee_amt': 0,
|
||||
'nf_srv_amt': 0,
|
||||
'nf_mdc_amt': 0,
|
||||
'expense_id': None,
|
||||
'expense_number': '',
|
||||
'found': False,
|
||||
}
|
||||
if not matches1.get(key1):
|
||||
if not matches2.get(key2):
|
||||
if not matches4.get(key3):
|
||||
notes=matches4.get(key4)
|
||||
if notes:
|
||||
print("not found")
|
||||
record.update({
|
||||
'nf_date': notes['date'],
|
||||
'nf_hn': notes['hn'],
|
||||
'nf_pid': notes['pid'],
|
||||
'nf_patient_name': notes['name'],
|
||||
'nf_fee_amt': notes['fee_amt'],
|
||||
'nf_srv_amt': notes['srv_amt'],
|
||||
'nf_mdc_amt': notes['mdc_amt'],
|
||||
'expense_id': notes['expense_id'],
|
||||
'expense_number': notes['expense_number'],
|
||||
})
|
||||
else:
|
||||
print(">> ", notes)
|
||||
else:
|
||||
print("found 3.")
|
||||
# found 3.
|
||||
found=matches3[key3]
|
||||
record.update({
|
||||
'expense_id': found['expense_id'],
|
||||
})
|
||||
else:
|
||||
# found 2.
|
||||
print("found 2.")
|
||||
found=matches2[key2]
|
||||
record.update({
|
||||
'expense_id': found['expense_id'],
|
||||
})
|
||||
else:
|
||||
# found 1.
|
||||
found=matches1[key1]
|
||||
print("found 1.")
|
||||
record.update({
|
||||
'expense_id': found['expense_id'],
|
||||
'expense_number': found['expense_number'],
|
||||
'found': True,
|
||||
})
|
||||
records.append(record)
|
||||
no+=1
|
||||
elif obj.pcode=='UC':
|
||||
for line in lines:
|
||||
#{'amount': '1500.0000',
|
||||
#'cstat': None,
|
||||
#'dttran': '2014-09-27T10:00:00',
|
||||
#'epostat': 'E',
|
||||
#'hdflag': 'COU',
|
||||
#'hdrate': '1500.0000',
|
||||
#'hn': '98511252',
|
||||
#'hreg': 'NHSO1',
|
||||
#'invno': '437941480',
|
||||
#'paid': '0.0000',
|
||||
#'paychk': '1',
|
||||
#'reimbpay': '0.0000',
|
||||
#'rid': '2190',
|
||||
#'station': '01'}
|
||||
date,time=(line['dttran'] or "").split("T")
|
||||
amt=line['amount'] or "0"
|
||||
amt=float(amt)
|
||||
if date and time:
|
||||
key1='%s-%s-%s'%(
|
||||
line['hn'],
|
||||
date,
|
||||
amt,
|
||||
)
|
||||
if not matches1.get(key1):
|
||||
matches1[key1]={
|
||||
'invno': line['invno'],
|
||||
}
|
||||
return records
|
||||
|
||||
def onchange_date(self,context={}):
|
||||
data=context['data']
|
||||
date=data['date']
|
||||
year,month,day=date.split("-")
|
||||
weekday, total_day=monthrange(int(year), int(month))
|
||||
data['date_from']="%s-%s-01"%(year,month)
|
||||
data['date_to']="%s-%s-%s"%(year,month,total_day)
|
||||
return data
|
||||
|
||||
def onchange_ptype(self,context={}):
|
||||
data=context['data']
|
||||
type_id=data['patient_type_id']
|
||||
if type_id:
|
||||
t=get_model('clinic.patient.type').browse(type_id)
|
||||
data['pcode']=t.code or ""
|
||||
return data
|
||||
|
||||
def do_import(self,ids,context={}):
|
||||
st=get_model("clinic.setting").browse(1)
|
||||
if not st.import_account_id:
|
||||
raise Exception("Import account not found (Ratchawat Setting -> Accounting)")
|
||||
obj=self.browse(ids)[0]
|
||||
if not obj.expenes:
|
||||
raise Exception("Nothing to import")
|
||||
|
||||
obj=self.browse(ids)[0]
|
||||
partner=obj.patient_type_id.contact_id
|
||||
company_id=get_active_company()
|
||||
vals={
|
||||
"partner_id": partner.id,
|
||||
"company_id": company_id,
|
||||
"type": "in",
|
||||
"pay_type": "invoice",
|
||||
'date': time.strftime("%Y-%m-%d"),
|
||||
"account_id": st.import_account_id.id,
|
||||
'invoice_lines': [],
|
||||
'rd_cust': True, #XXX
|
||||
}
|
||||
|
||||
for exp in obj.expenes:
|
||||
if exp.state=='match':
|
||||
for inv in exp.hd_case_id.invoices:
|
||||
if inv.partner_id.id==partner.id:
|
||||
vals['invoice_lines'].append(('create',{
|
||||
'invoice_id': inv.id,
|
||||
'amount': inv.amount_due or 0,
|
||||
}))
|
||||
#should not match again
|
||||
exp.write({
|
||||
'state': 'completed',
|
||||
})
|
||||
hdcase=exp.hd_case_id
|
||||
if hdcase:
|
||||
hdcase.write({
|
||||
'state': 'paid',
|
||||
})
|
||||
|
||||
if not vals['invoice_lines']:
|
||||
raise Exception("Nothing to import")
|
||||
payment_id=get_model("account.payment").create(vals,context={"type":"in"})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'payment',
|
||||
'mode': 'form',
|
||||
'active_id': payment_id,
|
||||
},
|
||||
'flash': 'Create Payment successfully',
|
||||
}
|
||||
|
||||
def update_id(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
lines=obj.get_line()
|
||||
pts={}
|
||||
for line in lines:
|
||||
pid=line.get("pid")
|
||||
name=line.get("name14")
|
||||
hn=line.get("hn")
|
||||
if not pts.get(name):
|
||||
pts[name]=pid
|
||||
|
||||
for pt in get_model('clinic.patient').search_browse([]):
|
||||
pid=pts.get(pt.name)
|
||||
if pid:
|
||||
if pt.card_no:
|
||||
pid=''.join([str(x) for x in pt.card_no if x.isnumeric()])
|
||||
print(pt.name, 'pid ', pid)
|
||||
else:
|
||||
pid=int(pid)
|
||||
print("pid ", pid)
|
||||
pt.write({
|
||||
'card_no': pid,
|
||||
})
|
||||
print("Done!")
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
lines=[]
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
lines=obj.match()
|
||||
data={
|
||||
'lines': lines,
|
||||
}
|
||||
return data
|
||||
|
||||
def match_old(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
lines=obj.get_line()
|
||||
|
@ -246,293 +567,4 @@ class MatchingPayment(Model):
|
|||
'flash': flash,
|
||||
}
|
||||
|
||||
def match(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
lines=obj.get_line()
|
||||
return lines
|
||||
|
||||
matches1={}
|
||||
matches2={}
|
||||
matches3={}
|
||||
dom=[]
|
||||
dom.append(['date',">=",obj.date_from])
|
||||
dom.append(['date',"<=",obj.date_to])
|
||||
dom.append(['patient_id.type_id',"=",obj.patient_type_id.id])
|
||||
dom.append(['state','!=', 'completed'])
|
||||
for exp in get_model('clinic.hd.case.expense').search_browse(dom):
|
||||
hn=''.join([x for x in hn if x.isdigit()])
|
||||
key1='%s:%s:%s:%s:%s'%(
|
||||
hn,
|
||||
date,
|
||||
lfee_amt,
|
||||
lsrv_amt,
|
||||
lmdc_amt,
|
||||
)
|
||||
key2='%s:%s:%s:%s:%s'%(
|
||||
pid,
|
||||
date,
|
||||
lfee_amt,
|
||||
lsrv_amt,
|
||||
lmdc_amt,
|
||||
)
|
||||
key3='%s:%s:%s:%s:%s'%(
|
||||
name,
|
||||
date,
|
||||
lfee_amt,
|
||||
lsrv_amt,
|
||||
lmdc_amt,
|
||||
)
|
||||
vals={
|
||||
'pid': pid,
|
||||
'name': name,
|
||||
'date': date,
|
||||
'fee_amt': lfee_amt,
|
||||
'service_amt': lsrv_amt,
|
||||
'epo_amt': lmdc_amt,
|
||||
}
|
||||
if not matches1.get(key1):
|
||||
matches1[key1]=vals
|
||||
if not matches2.get(key2):
|
||||
matches2[key2]=vals
|
||||
if not matches3.get(key3):
|
||||
matches2[key2]=vals
|
||||
if obj.pcode=='SSO':
|
||||
for line in lines:
|
||||
hcode=line.get('hcode18')
|
||||
if not hcode:
|
||||
hcode='0'
|
||||
hcode=int(hcode)
|
||||
hcode=str(hcode)
|
||||
if obj.hcode==hcode:
|
||||
lsrv_amt=line.get('epoadm29') or 0
|
||||
lfee_amt=line.get('amount23') or 0
|
||||
lmdc_amt=line.get('allow37') or 0
|
||||
dttran=line.get("dttran")
|
||||
name=line.get("name14")
|
||||
pid=line.get('pid')
|
||||
date=dttran[0:10]
|
||||
time=dttran[11:] #XXX
|
||||
if not time:
|
||||
print("wrong format")
|
||||
continue
|
||||
hn=line.get('hn')
|
||||
hn=''.join([x for x in hn if x.isdigit()])
|
||||
key1='%s:%s:%s:%s:%s'%(
|
||||
hn,
|
||||
date,
|
||||
lfee_amt,
|
||||
lsrv_amt,
|
||||
lmdc_amt,
|
||||
)
|
||||
key2='%s:%s:%s:%s:%s'%(
|
||||
pid,
|
||||
date,
|
||||
lfee_amt,
|
||||
lsrv_amt,
|
||||
lmdc_amt,
|
||||
)
|
||||
key3='%s:%s:%s:%s:%s'%(
|
||||
name,
|
||||
date,
|
||||
lfee_amt,
|
||||
lsrv_amt,
|
||||
lmdc_amt,
|
||||
)
|
||||
vals={
|
||||
'pid': pid,
|
||||
'name': name,
|
||||
'date': date,
|
||||
'fee_amt': lfee_amt,
|
||||
'service_amt': lsrv_amt,
|
||||
'epo_amt': lmdc_amt,
|
||||
}
|
||||
if not matches1.get(key1):
|
||||
matches1[key1]=vals
|
||||
if not matches2.get(key2):
|
||||
matches2[key2]=vals
|
||||
if not matches3.get(key3):
|
||||
matches2[key2]=vals
|
||||
|
||||
elif obj.pcode=='UC':
|
||||
for line in lines:
|
||||
#{'amount': '1500.0000',
|
||||
#'cstat': None,
|
||||
#'dttran': '2014-09-27T10:00:00',
|
||||
#'epostat': 'E',
|
||||
#'hdflag': 'COU',
|
||||
#'hdrate': '1500.0000',
|
||||
#'hn': '98511252',
|
||||
#'hreg': 'NHSO1',
|
||||
#'invno': '437941480',
|
||||
#'paid': '0.0000',
|
||||
#'paychk': '1',
|
||||
#'reimbpay': '0.0000',
|
||||
#'rid': '2190',
|
||||
#'station': '01'}
|
||||
date,time=(line['dttran'] or "").split("T")
|
||||
amt=line['amount'] or "0"
|
||||
amt=float(amt)
|
||||
if date and time:
|
||||
key1='%s-%s-%s'%(
|
||||
line['hn'],
|
||||
date,
|
||||
amt,
|
||||
)
|
||||
if not matches1.get(key1):
|
||||
matches1[key1]={
|
||||
'invno': line['invno'],
|
||||
}
|
||||
|
||||
for exp in get_model('clinic.hd.case.expense').search_browse(dom):
|
||||
pt=exp.patient_id
|
||||
if obj.pcode=='UC':
|
||||
hdcase=exp.hd_case_id
|
||||
date=hdcase.date
|
||||
fee_amt=0
|
||||
for line in hdcase.lines:
|
||||
categ=line.product_categ_id
|
||||
if categ.code=='FEE':
|
||||
fee_amt+=line.amount or 0
|
||||
key='%s-%s-%s'%(pt.hn_no,date,amt)
|
||||
found=matches1.get(key)
|
||||
if found:
|
||||
exp.write({
|
||||
'state': 'match',
|
||||
})
|
||||
elif obj.pcode=='SSO':
|
||||
key1='%s:%s:%s:%s:%s'%(
|
||||
pt.hn_no,
|
||||
exp.date,
|
||||
exp.fee_amt and exp.fee_amt or 0,
|
||||
exp.srv_amt and exp.srv_amt or 0,
|
||||
exp.mdc_amt and exp.mdc_amt or 0,
|
||||
)
|
||||
key2='%s:%s:%s:%s:%s'%(
|
||||
pt.name or "",
|
||||
exp.date,
|
||||
exp.fee_amt and exp.fee_amt or 0,
|
||||
exp.srv_amt and exp.srv_amt or 0,
|
||||
exp.mdc_amt and exp.mdc_amt or 0,
|
||||
)
|
||||
found=matches1.get(key1) or matches2.get(key2)
|
||||
if found:
|
||||
hdcase=exp.hd_case_id
|
||||
exp.write({
|
||||
'state': 'match',
|
||||
})
|
||||
|
||||
flash='Done!'
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_matching_payment',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash': flash,
|
||||
}
|
||||
|
||||
def onchange_date(self,context={}):
|
||||
data=context['data']
|
||||
date=data['date']
|
||||
year,month,day=date.split("-")
|
||||
weekday, total_day=monthrange(int(year), int(month))
|
||||
data['date_from']="%s-%s-01"%(year,month)
|
||||
data['date_to']="%s-%s-%s"%(year,month,total_day)
|
||||
return data
|
||||
|
||||
def onchange_ptype(self,context={}):
|
||||
data=context['data']
|
||||
type_id=data['patient_type_id']
|
||||
if type_id:
|
||||
t=get_model('clinic.patient.type').browse(type_id)
|
||||
data['pcode']=t.code or ""
|
||||
return data
|
||||
|
||||
def do_import(self,ids,context={}):
|
||||
st=get_model("clinic.setting").browse(1)
|
||||
if not st.import_account_id:
|
||||
raise Exception("Import account not found (Ratchawat Setting -> Accounting)")
|
||||
obj=self.browse(ids)[0]
|
||||
if not obj.expenes:
|
||||
raise Exception("Nothing to import")
|
||||
|
||||
obj=self.browse(ids)[0]
|
||||
partner=obj.patient_type_id.contact_id
|
||||
company_id=get_active_company()
|
||||
vals={
|
||||
"partner_id": partner.id,
|
||||
"company_id": company_id,
|
||||
"type": "in",
|
||||
"pay_type": "invoice",
|
||||
'date': time.strftime("%Y-%m-%d"),
|
||||
"account_id": st.import_account_id.id,
|
||||
'invoice_lines': [],
|
||||
'rd_cust': True, #XXX
|
||||
}
|
||||
|
||||
for exp in obj.expenes:
|
||||
if exp.state=='match':
|
||||
for inv in exp.hd_case_id.invoices:
|
||||
if inv.partner_id.id==partner.id:
|
||||
vals['invoice_lines'].append(('create',{
|
||||
'invoice_id': inv.id,
|
||||
'amount': inv.amount_due or 0,
|
||||
}))
|
||||
#should not match again
|
||||
exp.write({
|
||||
'state': 'completed',
|
||||
})
|
||||
hdcase=exp.hd_case_id
|
||||
if hdcase:
|
||||
hdcase.write({
|
||||
'state': 'paid',
|
||||
})
|
||||
|
||||
if not vals['invoice_lines']:
|
||||
raise Exception("Nothing to import")
|
||||
payment_id=get_model("account.payment").create(vals,context={"type":"in"})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'payment',
|
||||
'mode': 'form',
|
||||
'active_id': payment_id,
|
||||
},
|
||||
'flash': 'Create Payment successfully',
|
||||
}
|
||||
|
||||
def update_id(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
lines=obj.get_line()
|
||||
pts={}
|
||||
for line in lines:
|
||||
pid=line.get("pid")
|
||||
name=line.get("name14")
|
||||
hn=line.get("hn")
|
||||
if not pts.get(name):
|
||||
pts[name]=pid
|
||||
|
||||
for pt in get_model('clinic.patient').search_browse([]):
|
||||
pid=pts.get(pt.name)
|
||||
if pid:
|
||||
if pt.card_no:
|
||||
pid=''.join([str(x) for x in pt.card_no if x.isnumeric()])
|
||||
print(pt.name, 'pid ', pid)
|
||||
else:
|
||||
pid=int(pid)
|
||||
print("pid ", pid)
|
||||
pt.write({
|
||||
'card_no': pid,
|
||||
})
|
||||
print("Done!")
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
lines=[]
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
lines=obj.match()
|
||||
data={
|
||||
'lines': lines,
|
||||
}
|
||||
return data
|
||||
|
||||
MatchingPayment.register()
|
||||
|
|
|
@ -6,6 +6,7 @@ class Partner(Model):
|
|||
_fields={
|
||||
'walkin_cust': fields.Boolean("Walkin Customer"),
|
||||
'is_patient': fields.Boolean("Is Patient"),
|
||||
'is_staff': fields.Boolean("Is Staff"),
|
||||
}
|
||||
|
||||
Partner.register()
|
||||
|
|
|
@ -110,11 +110,11 @@ class ClinicSetting(Model):
|
|||
if user_id !=1:
|
||||
print("Only admin!!")
|
||||
return
|
||||
for pt in get_model("clinic.patient").search_browse([]):
|
||||
partner=pt.partner_id
|
||||
if partner:
|
||||
partner.write({
|
||||
'is_patient': True,
|
||||
|
||||
# try to create contact
|
||||
for staff in get_model("clinic.staff").search_browse([]):
|
||||
staff.write({
|
||||
'note': ' ',
|
||||
})
|
||||
print("Done!")
|
||||
|
||||
|
|
|
@ -128,6 +128,7 @@ class Staff(Model):
|
|||
"hd_cases": fields.Many2Many("clinic.hd.case","HD Cases",function="_get_hdcase"), # not need to use (it's slow to load)
|
||||
"cycle_item_nurses": fields.One2Many("clinic.cycle.item.line","nurse_id","Cycle Items"),
|
||||
'branch_id': fields.Many2One("clinic.branch","Branch", search=True),
|
||||
"partner_id": fields.Many2One("partner","Contact"),
|
||||
}
|
||||
|
||||
def _get_number(self,context={}):
|
||||
|
@ -163,9 +164,39 @@ class Staff(Model):
|
|||
|
||||
#_key=["name_check","branch_id"] #not working
|
||||
_sql_constraints=("clinic_staff_key_uniq","unique(name_check,branch_id)","name should be unique"),
|
||||
|
||||
_order="date desc,number desc"
|
||||
|
||||
def create_contact(self,name):
|
||||
partner_id=get_model("partner").create({
|
||||
'name': name,
|
||||
'last_name': name,
|
||||
'type': 'person',
|
||||
'is_staff': True,
|
||||
})
|
||||
address_id=get_model('address').create({
|
||||
'type': 'shipping',
|
||||
'partner_id': partner_id,
|
||||
'address': 'your address',
|
||||
'address2': 'your address2',
|
||||
'city': 'your city',
|
||||
'postal_code': 'your zip',
|
||||
'country_id': 1,
|
||||
|
||||
})
|
||||
return partner_id, address_id
|
||||
|
||||
def check_contact(self,name=""):
|
||||
partner_id=None
|
||||
dom=[
|
||||
['name','=',name],
|
||||
['is_staff','=',True],
|
||||
]
|
||||
for partner in get_model("partner").search_browse(dom):
|
||||
if partner.name==name:
|
||||
partner_id=partner.id
|
||||
break
|
||||
return partner_id
|
||||
|
||||
def check_emp(self,name="", employee_id=None):
|
||||
names=name.split(" ")
|
||||
first_name=names[0]
|
||||
|
@ -194,8 +225,18 @@ class Staff(Model):
|
|||
emp_id=self.check_emp(name,employee_id)
|
||||
if emp_id:
|
||||
vals['employee_id']=emp_id
|
||||
partner_id=get_model("clinic.staff").check_contact(name)
|
||||
address_id=None
|
||||
if not partner_id:
|
||||
vals['partner_id'],address_id=self.create_contact(name)
|
||||
new_id=super().create(vals,**kw)
|
||||
self.function_store([new_id])
|
||||
if address_id:
|
||||
addr=get_model('address').browse(address_id)
|
||||
addr.write({
|
||||
'partner_id': vals['partner_id'],
|
||||
'staff_id': new_id,
|
||||
})
|
||||
return new_id
|
||||
|
||||
def write(self,ids,vals,**kw):
|
||||
|
@ -206,8 +247,18 @@ class Staff(Model):
|
|||
emp_id=self.check_emp(name,obj.employee_id.id)
|
||||
if emp_id:
|
||||
vals['employee_id']=emp_id
|
||||
partner_id=get_model("clinic.staff").check_contact(name)
|
||||
address_id=None
|
||||
if not partner_id:
|
||||
vals['partner_id'],address_id=self.create_contact(name)
|
||||
self.function_store(ids)
|
||||
super().write(ids,vals,**kw)
|
||||
if address_id:
|
||||
addr=get_model('address').browse(address_id)
|
||||
addr.write({
|
||||
'partner_id': vals['partner_id'],
|
||||
'staff_id': ids[0],
|
||||
})
|
||||
|
||||
def name_get(self,ids,context={}):
|
||||
vals=[]
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<p></p>
|
||||
<table class="table table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="9" style="text-align:center;background-color:#f9e37d;">Import File</th>
|
||||
<th colspan="5" style="text-align:center;background-color:#2d6ed2;color:white">Netforce</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Date</th>
|
||||
<th>HN</th>
|
||||
|
@ -7,8 +13,15 @@
|
|||
<th>EPO Amount</th>
|
||||
<th>Service Medical</th>
|
||||
<th>Fee Amount</th>
|
||||
<th>HD Case</th>
|
||||
<th>Note</th>
|
||||
|
||||
<th>Date</th>
|
||||
<th>HN</th>
|
||||
<th>Patient</th>
|
||||
<th>EPO Amount</th>
|
||||
<th>Service Medical</th>
|
||||
<th>Fee Amount</th>
|
||||
<th>Expense</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each lines }}
|
||||
|
@ -16,11 +29,17 @@
|
|||
<td>{{no}}</td>
|
||||
<td>{{date}}</td>
|
||||
<td>{{hn}}</td>
|
||||
<td style="width:15%;">{{view "link" string=patient_name action="clinic_patient" action_options="mode=form" active_id=patient_id}}</td>
|
||||
<td>{{currency epo_amt zero=""}}</td>
|
||||
<td>{{currency service_amt zero=""}}</td>
|
||||
<td>{{patient_name}}
|
||||
<td>{{currency mdc_amt zero=""}}</td>
|
||||
<td>{{currency srv_amt zero=""}}</td>
|
||||
<td>{{currency fee_amt zero=""}}</td>
|
||||
<td>{{note}}</td>
|
||||
<td>{{nf_date}}</td>
|
||||
<td>{{nf_hn}}</td>
|
||||
<td>{{nf_patient_name}}
|
||||
<td>{{currency nf_mdc_amt zero=""}}</td>
|
||||
<td>{{currency nf_srv_amt zero=""}}</td>
|
||||
<td>{{currency nf_fee_amt zero=""}}</td>
|
||||
<td>{{expense_number}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
todo:
|
||||
--------
|
||||
matching payment
|
||||
|
||||
|
||||
-------
|
||||
|
||||
create contact from staff
|
||||
- xxxx
|
||||
script to clear invoice
|
||||
|
|
Loading…
Reference in New Issue