clean import
parent
bde8db41c2
commit
2e55c41d64
|
@ -20,52 +20,12 @@
|
|||
<tabs>
|
||||
<tab string="Information">
|
||||
<field name="total_row" span="3" readonly="1"/>
|
||||
<!--<field name="remain_row" span="3" readonly="1"/>-->
|
||||
<field name="match_qty" span="3" readonly="1"/>
|
||||
<field name="unmatch_qty" span="3" readonly="1"/>
|
||||
<field name="fail_qty" span="3" readonly="1"/>
|
||||
<newline/>
|
||||
<!--<field name="done_qty" span="3" readonly="1"/>-->
|
||||
<field name="est_time" span="4" readonly="1"/>
|
||||
</tab>
|
||||
<tab string="Match">
|
||||
<field name="match_lines" nolabel="1">
|
||||
<list>
|
||||
<field name="date"/>
|
||||
<field name="invoice_id"/>
|
||||
<field name="ref"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="hd_case_id"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
<form>
|
||||
<field name="date"/>
|
||||
<field name="invoice_id"/>
|
||||
<field name="ref"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="hd_case_id"/>
|
||||
<field name="amount"/>
|
||||
</form>
|
||||
</field>
|
||||
</tab>
|
||||
<tab string="Unmatch">
|
||||
<field name="unmatch_lines" nolabel="1">
|
||||
<list>
|
||||
<field name="date"/>
|
||||
<field name="invoice_id"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="hd_case_id"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
<form>
|
||||
<field name="date"/>
|
||||
<field name="invoice_id"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="hd_case_id"/>
|
||||
<field name="amount"/>
|
||||
</form>
|
||||
</field>
|
||||
</tab>
|
||||
<tab string="Message">
|
||||
<field name="msg" span="6" nolabel="1" width="1000" height="180"/>
|
||||
</tab>
|
||||
|
|
|
@ -48,8 +48,6 @@ class ImportPayment(Model):
|
|||
'match_qty': fields.Integer("Match"),
|
||||
'unmatch_qty': fields.Integer("UnMatch"),
|
||||
'state': fields.Selection([['draft','Draft'],['confirmed','Confirmed'],['approved','Approved'],['fail','Fail'],['success','Success']],'State'),
|
||||
'match_lines': fields.One2Many("import.clinic.payment.line","import_payment_id","Match",domain=[["state","=","match"]]),
|
||||
'unmatch_lines': fields.One2Many("import.clinic.payment.line","import_payment_id","Un Match",domain=[["state","=","unmatch"]]),
|
||||
'payment_id': fields.Many2One("account.payment","Payment"),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
'partner_id': fields.Many2One("partner","Fee Contact",function="_get_partner"),
|
||||
|
@ -149,93 +147,15 @@ class ImportPayment(Model):
|
|||
if not lines:
|
||||
raise Exception("No data to import")
|
||||
msg=""
|
||||
nofound=0
|
||||
blank=0
|
||||
fail_qty=0
|
||||
match_qty=0
|
||||
unmatch_qty=0
|
||||
msg+=""*10; msg+="hcode,hn,name,note\n"
|
||||
|
||||
invoices=self.get_patient_invoice(state='waiting_payment')
|
||||
patients=self.get_all_patient()
|
||||
hd_cases=self.get_hd_case()
|
||||
|
||||
mlines=[]
|
||||
umlines=[]
|
||||
for line in lines:
|
||||
patient_name=line.get("name14")
|
||||
hn=line.get('hn',"")
|
||||
hn_num=self.get_hn_num(hn)
|
||||
inv_date=line.get("dttran")
|
||||
hcode=line.get('hcode18','0')
|
||||
if not hcode:
|
||||
hcode='0'
|
||||
hcode=int(hcode)
|
||||
hcode=str(hcode)
|
||||
if not obj.hcode_id.code==hcode:
|
||||
if hcode:
|
||||
nofound+=1
|
||||
if hcode!='0':
|
||||
msg+="%s, %s, %s, Wrong hospital code \n"%(hcode,hn,patient_name)
|
||||
fail_qty+=1
|
||||
else:
|
||||
blank+=1
|
||||
else:
|
||||
blank+=1
|
||||
continue
|
||||
pass
|
||||
|
||||
if patients.get(hn_num):
|
||||
patient_id=patients[hn_num]['id']
|
||||
key=(inv_date,patient_id)
|
||||
if invoices.get(key):
|
||||
inv=invoices[key]
|
||||
mlines.append(('create',{
|
||||
'date': inv_date,
|
||||
'invoice_id': inv['id'],
|
||||
'hd_case_id': inv['hd_case_id'],
|
||||
'patient_id': patient_id,
|
||||
'amount': inv['amount_due'] or 0.0,
|
||||
'state': 'match',
|
||||
}))
|
||||
match_qty+=1
|
||||
else:
|
||||
hd_case=hd_cases.get(key)
|
||||
vals={
|
||||
'date': inv_date,
|
||||
'patient_id': patient_id,
|
||||
}
|
||||
if hd_case:
|
||||
vals['hd_case_id']=hd_case['id']
|
||||
umlines.append(('create',vals))
|
||||
unmatch_qty+=1
|
||||
else:
|
||||
msg+="%s,%s,%s,Not found invoice on %s\n"%(hcode,hn,patient_name,inv_date)
|
||||
nofound+=1
|
||||
|
||||
unmatch_qty+=nofound #XXX
|
||||
for mline in obj.match_lines:
|
||||
mline.delete()
|
||||
for umline in obj.unmatch_lines:
|
||||
umline.delete()
|
||||
|
||||
stop_time=time.strftime(fmt)
|
||||
est_time=datetime.strptime(stop_time,fmt)-datetime.strptime(start_time,fmt)
|
||||
|
||||
total_row=len(lines)
|
||||
remain_row=total_row-blank-match_qty-unmatch_qty
|
||||
obj.write({
|
||||
'total_row': len(lines),
|
||||
'remain_row': remain_row-match_qty,
|
||||
'msg': msg,
|
||||
'done_qty': match_qty+unmatch_qty,
|
||||
'fail_qty': fail_qty,
|
||||
'match_qty': match_qty,
|
||||
'unmatch_qty': unmatch_qty-fail_qty,
|
||||
'est_time': est_time.seconds/3600,
|
||||
'match_lines': mlines,
|
||||
'unmatch_lines': umlines,
|
||||
})
|
||||
print("Done!")
|
||||
|
||||
return {
|
||||
'next': {
|
||||
'name': 'import_clinic_payment',
|
||||
|
@ -253,24 +173,12 @@ class ImportPayment(Model):
|
|||
if not lines:
|
||||
raise Exception("No Data to import")
|
||||
|
||||
invoices=self.get_patient_invoice(state='waiting_payment')
|
||||
patients=self.get_all_patient()
|
||||
hd_cases=self.get_hd_case()
|
||||
|
||||
for line in lines:
|
||||
date,time=line.get("dttran").split("T")
|
||||
invno=line.get("invno")
|
||||
hdrate=float(line.get("hdrate","0"))
|
||||
hn=line.get('hn',"")
|
||||
hn_num=self.get_hn_num(hn)
|
||||
#if hn+
|
||||
patient=patients.get(hn_num)
|
||||
if patient:
|
||||
key=(date,patient['id'])
|
||||
if patient['id']==16953:
|
||||
print("key ", patient)
|
||||
#paid=float(line.get("paid","0"))
|
||||
#epostat=line.get('epostat')
|
||||
|
||||
obj.write({
|
||||
'match_qty': 0,
|
||||
|
|
Loading…
Reference in New Issue