improve import
							parent
							
								
									3c4b45e937
								
							
						
					
					
						commit
						35ed3299cc
					
				|  | @ -1,13 +1,20 @@ | ||||||
| <form model="clinic.matching.payment" title="Matching Payment"> | <form model="clinic.matching.payment" title="Matching Payment"> | ||||||
|     <separator string="1. Click Match > 2. Check Items > 3. Import Payment"/> |     <tabs> | ||||||
|     <field name="date" onchange="onchange_date" mode="month" span="3"/> |         <tab string="General"> | ||||||
|     <field name="date_from" span="3"/> |             <separator string="1. Click Match > 2. Check Items > 3. Import Payment"/> | ||||||
|     <field name="date_to" span="3"/> |             <field name="date" onchange="onchange_date" mode="month" span="3"/> | ||||||
|     <newline/> |             <field name="date_from" span="3"/> | ||||||
|     <field name="file" span="3"/> |             <field name="date_to" span="3"/> | ||||||
|     <field name="patient_type_id" onchange="onchange_ptype" span="3"/> |             <newline/> | ||||||
|     <field name="pcode" span="3"/> |             <field name="file" span="3"/> | ||||||
|     <field name="hcode_id" 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"> |     <foot replace="1"> | ||||||
|         <button string="Match" method="match" icon="ok" type="success"/> |         <button string="Match" method="match" icon="ok" type="success"/> | ||||||
|         <button string="Import Payment" method="do_import" icon="arrow-right" type="default"/> |         <button string="Import Payment" method="do_import" icon="arrow-right" type="default"/> | ||||||
|  |  | ||||||
|  | @ -21,6 +21,7 @@ class MatchingPayment(Model): | ||||||
|         'pcode': fields.Char("Code",required=True), |         'pcode': fields.Char("Code",required=True), | ||||||
|         'hcode_id': fields.Many2One("clinic.hospital","HCode"), |         'hcode_id': fields.Many2One("clinic.hospital","HCode"), | ||||||
|         'expenes': fields.Many2Many("clinic.hd.case.expense","Expenses"), |         'expenes': fields.Many2Many("clinic.hd.case.expense","Expenses"), | ||||||
|  |         'note': fields.Text("Note"), | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     def _get_ptype(self,context={}): |     def _get_ptype(self,context={}): | ||||||
|  | @ -162,6 +163,7 @@ class MatchingPayment(Model): | ||||||
|             #if hn=='11712556': |             #if hn=='11712556': | ||||||
|                 #print(key)  |                 #print(key)  | ||||||
|         #print("="*50) |         #print("="*50) | ||||||
|  |         note="" | ||||||
|         exp_ids=[] |         exp_ids=[] | ||||||
|         dom=[] |         dom=[] | ||||||
|         dom.append(['date',">=",obj.date_from]) |         dom.append(['date',">=",obj.date_from]) | ||||||
|  | @ -170,8 +172,8 @@ class MatchingPayment(Model): | ||||||
|         dom.append(['state','!=', 'completed']) |         dom.append(['state','!=', 'completed']) | ||||||
|         for exp in get_model('clinic.hd.case.expense').search_browse(dom): |         for exp in get_model('clinic.hd.case.expense').search_browse(dom): | ||||||
|             exp_ids.append(exp.id) |             exp_ids.append(exp.id) | ||||||
|  |             pt=exp.patient_id | ||||||
|             if obj.pcode=='UC': |             if obj.pcode=='UC': | ||||||
|                 pt=exp.patient_id |  | ||||||
|                 hdcase=exp.hd_case_id |                 hdcase=exp.hd_case_id | ||||||
|                 date=hdcase.date |                 date=hdcase.date | ||||||
|                 fee_amt=0 |                 fee_amt=0 | ||||||
|  | @ -187,8 +189,33 @@ class MatchingPayment(Model): | ||||||
|                    exp.write({ |                    exp.write({ | ||||||
|                        'state': 'match', |                        '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({ |         obj.write({ | ||||||
|             'expenes': [('add',exp_ids)] |             'expenes': [('add',exp_ids)], | ||||||
|  |             'note': note, | ||||||
|         }) |         }) | ||||||
|         print("Done!") |         print("Done!") | ||||||
|         flash='Succesfully' |         flash='Succesfully' | ||||||
|  | @ -239,6 +266,7 @@ class MatchingPayment(Model): | ||||||
|             'date': time.strftime("%Y-%m-%d"), |             'date': time.strftime("%Y-%m-%d"), | ||||||
|             "account_id": st.import_account_id.id, |             "account_id": st.import_account_id.id, | ||||||
|             'invoice_lines': [], |             'invoice_lines': [], | ||||||
|  |             'rd_cust': True, #XXX | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         for exp in obj.expenes: |         for exp in obj.expenes: | ||||||
|  | @ -271,5 +299,4 @@ class MatchingPayment(Model): | ||||||
|             'flash': 'Create Payment successfully', |             'flash': 'Create Payment successfully', | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| MatchingPayment.register() | MatchingPayment.register() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue