improve import

conv_bal
watcha.h 2015-02-05 08:01:12 +07:00
parent 3c4b45e937
commit 35ed3299cc
2 changed files with 46 additions and 12 deletions

View File

@ -1,13 +1,20 @@
<form model="clinic.matching.payment" title="Matching Payment">
<separator string="1. Click Match > 2. Check Items > 3. Import Payment"/>
<field name="date" onchange="onchange_date" mode="month" span="3"/>
<field name="date_from" span="3"/>
<field name="date_to" span="3"/>
<newline/>
<field name="file" span="3"/>
<field name="patient_type_id" onchange="onchange_ptype" span="3"/>
<field name="pcode" span="3"/>
<field name="hcode_id" span="3"/>
<tabs>
<tab string="General">
<separator string="1. Click Match > 2. Check Items > 3. Import Payment"/>
<field name="date" onchange="onchange_date" mode="month" span="3"/>
<field name="date_from" span="3"/>
<field name="date_to" span="3"/>
<newline/>
<field name="file" span="3"/>
<field name="patient_type_id" onchange="onchange_ptype" span="3"/>
<field name="pcode" span="3"/>
<field name="hcode_id" span="3"/>
</tab>
<tab string="Log">
<field name="note" nolabel="1" width="1000" height="250"/>
</tab>
</tabs>
<foot replace="1">
<button string="Match" method="match" icon="ok" type="success"/>
<button string="Import Payment" method="do_import" icon="arrow-right" type="default"/>

View File

@ -21,6 +21,7 @@ class MatchingPayment(Model):
'pcode': fields.Char("Code",required=True),
'hcode_id': fields.Many2One("clinic.hospital","HCode"),
'expenes': fields.Many2Many("clinic.hd.case.expense","Expenses"),
'note': fields.Text("Note"),
}
def _get_ptype(self,context={}):
@ -162,6 +163,7 @@ class MatchingPayment(Model):
#if hn=='11712556':
#print(key)
#print("="*50)
note=""
exp_ids=[]
dom=[]
dom.append(['date',">=",obj.date_from])
@ -170,8 +172,8 @@ class MatchingPayment(Model):
dom.append(['state','!=', 'completed'])
for exp in get_model('clinic.hd.case.expense').search_browse(dom):
exp_ids.append(exp.id)
pt=exp.patient_id
if obj.pcode=='UC':
pt=exp.patient_id
hdcase=exp.hd_case_id
date=hdcase.date
fee_amt=0
@ -187,8 +189,33 @@ class MatchingPayment(Model):
exp.write({
'state': 'match',
})
else:
note+="not found %s\n"%key
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:
exp.write({
'state': 'match',
})
else:
note+="not found %s, %s\n"%(key1,key2)
obj.write({
'expenes': [('add',exp_ids)]
'expenes': [('add',exp_ids)],
'note': note,
})
print("Done!")
flash='Succesfully'
@ -239,6 +266,7 @@ class MatchingPayment(Model):
'date': time.strftime("%Y-%m-%d"),
"account_id": st.import_account_id.id,
'invoice_lines': [],
'rd_cust': True, #XXX
}
for exp in obj.expenes:
@ -271,5 +299,4 @@ class MatchingPayment(Model):
'flash': 'Create Payment successfully',
}
MatchingPayment.register()