From 2e55c41d6441777c8752a59283e5396e3a0439da Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Thu, 4 Dec 2014 21:30:52 +0700 Subject: [PATCH] clean import --- .../layouts/import_clinic_payment_form.xml | 40 -------- netforce_clinic/models/import_payment.py | 96 +------------------ 2 files changed, 2 insertions(+), 134 deletions(-) diff --git a/netforce_clinic/layouts/import_clinic_payment_form.xml b/netforce_clinic/layouts/import_clinic_payment_form.xml index daa68e1..533bc1a 100644 --- a/netforce_clinic/layouts/import_clinic_payment_form.xml +++ b/netforce_clinic/layouts/import_clinic_payment_form.xml @@ -20,52 +20,12 @@ - - - - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - -
- - - - - - - -
diff --git a/netforce_clinic/models/import_payment.py b/netforce_clinic/models/import_payment.py index 1532dfa..8c3c09e 100644 --- a/netforce_clinic/models/import_payment.py +++ b/netforce_clinic/models/import_payment.py @@ -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,