From 5f88d19d746b8d9c1d0db03554c06aa4d097668f Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Tue, 25 Aug 2015 08:36:30 +0700 Subject: [PATCH] match uc --- .../clinic_setting_account_prod_form.xml | 4 +- netforce_clinic/models/hd_case.py | 3 + netforce_clinic/models/payment_matching.py | 74 ++++++- .../models/setting_account_product.py | 4 +- .../templates/payment_matching.hbs | 194 +++++++++++------- 5 files changed, 199 insertions(+), 80 deletions(-) diff --git a/netforce_clinic/layouts/clinic_setting_account_prod_form.xml b/netforce_clinic/layouts/clinic_setting_account_prod_form.xml index 947239d..d6e7ce7 100644 --- a/netforce_clinic/layouts/clinic_setting_account_prod_form.xml +++ b/netforce_clinic/layouts/clinic_setting_account_prod_form.xml @@ -1,6 +1,6 @@
- - + + diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 18f1692..f3abcec 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -593,6 +593,9 @@ class HDCase(Model): def make_invoices(self,ids,context={}): setting=get_model("settings").browse(1,context) + fin_account_receivable_id=setting.account_receivable_id.id + if not fin_account_receivable_id: + raise Exception("Missing Account Receivable") currency_id=setting.currency_id.id if not currency_id: raise Exception("Currency not found in account settings") diff --git a/netforce_clinic/models/payment_matching.py b/netforce_clinic/models/payment_matching.py index 2cef393..52de61d 100644 --- a/netforce_clinic/models/payment_matching.py +++ b/netforce_clinic/models/payment_matching.py @@ -120,6 +120,7 @@ class PaymentMatching(Model): department_id=None inv_state=defaults.get('inv_state') view_type=defaults.get('view_type') + pcode='' if ids: obj=self.browse(ids)[0] date_from=obj.date_from @@ -128,8 +129,10 @@ class PaymentMatching(Model): department_id=obj.department_id.id inv_state=obj.inv_state view_type=obj.view_type + pcode=obj.pcode lines=[] invoices=[] + total_invoice=0 total_match_invoice=0 total_epo=0 total_srv=0 @@ -146,7 +149,7 @@ class PaymentMatching(Model): dom.append(['department_id.branch_id','=',branch_id]) elif department_id: dom.append(['department_id','=',department_id]) - field_names=['date','number','amount_due','patient_id'] + field_names=['date','number','amount_due','patient_id'] for inv in get_model('account.invoice').search_read(dom,field_names): vals={ 'id': inv['id'], @@ -161,7 +164,7 @@ class PaymentMatching(Model): vals['patient_name']=patient.name vals['patient_nospace_name']=patient.name_check vals['patient_cid']=patient.card_no - vals['patient_hn']=patient.hn + vals['patient_hn']=patient.hn_no else: vals[field_name]=inv[field_name] vals[field_name]=inv[field_name] @@ -169,9 +172,11 @@ class PaymentMatching(Model): return invoices if view_type=='invoice': lines=get_invoices() + total_invoice=len(lines) else: - if obj: + if obj and obj.pcode=='SSO': invoices=get_invoices() + total_invoice=len(invoices) rlines=obj.get_line() no=1 for rline in rlines: @@ -218,18 +223,77 @@ class PaymentMatching(Model): break lines.append(line_vals) no+=1 + elif obj and obj.pcode=='UC': + invoices=get_invoices() + total_invoice=len(invoices) + rlines=obj.get_line() + no=1 + for rline in rlines: + #{'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=(rline['dttran'] or "").split("T") + fee=0 + if rline.get('amount'): + fee=float(rline['amount']) + total_fee+=fee + hn=rline['hn'] + hn=hn.replace(" ", "") + pname='' + pname_check='' + pid='' + for pt in get_model("clinic.patient").search_browse([['hn_no','=',hn]]): + pname=pt.name or "" + pname_check=pt.name_check or "" + pid=pt.card_no or "" + vals={ + 'date':date, + 'patient_name': pname, + 'pid': pid, + 'hn': hn, + 'fee': fee, + 'srv': 0, + 'epo': 0, + 'inv_id': None, + 'inv_number': '', + 'no': no, + } + for inv in invoices: + if inv['patient_id']: + if pid==inv['patient_cid'] or hn==inv['patient_hn'] or pname_check==inv['patient_nospace_name']: + if date==inv['date'] and fee==inv['amount_due']: + vals['inv_id']=inv['id'] + vals['inv_number']=inv['number'] + total_match_invoice+=1 + break + lines.append(vals) + no+=1 data={ 'lines': lines, 'date_from': date_from, 'date_to': date_to, - 'total_qty': len(lines), + 'total_item': len(lines), 'total_fee': total_fee, 'total_epo': total_epo, 'total_srv': total_srv, + 'total_invoice': total_invoice, 'total_match_invoice': total_match_invoice, - 'total_invoice': len(invoices), + 'total_match_invoice_in_pc': (total_match_invoice/total_invoice)*100, + 'total_unmatch_invoice': total_invoice-total_match_invoice, 'total_amount': total_amount, 'view_type': view_type, + 'pcode': pcode, } return data diff --git a/netforce_clinic/models/setting_account_product.py b/netforce_clinic/models/setting_account_product.py index 720a173..5ba4eb5 100644 --- a/netforce_clinic/models/setting_account_product.py +++ b/netforce_clinic/models/setting_account_product.py @@ -8,8 +8,8 @@ class SettingAccountProduct(Model): _fields={ "setting_id": fields.Many2One("clinic.setting","Setting",required=True,on_delete="cascade"), - "patient_type_id": fields.Many2One("clinic.patient.type","Patient Type",search=True,required=True), - 'categ_id': fields.Many2One("product.categ","Category",search=True,required=True), + "patient_type_id": fields.Many2One("clinic.patient.type","Patient Type",search=True), + 'categ_id': fields.Many2One("product.categ","Category",search=True), "product_id": fields.Many2One("product","Product",search=True,required=True), "ar_credit_id": fields.Many2One("account.account","Income Credit",multi_company=True,search=True), "ar_debit_id": fields.Many2One("account.account","AR Debit",multi_company=True,search=True), diff --git a/netforce_clinic/templates/payment_matching.hbs b/netforce_clinic/templates/payment_matching.hbs index bb16f31..d9f78e7 100644 --- a/netforce_clinic/templates/payment_matching.hbs +++ b/netforce_clinic/templates/payment_matching.hbs @@ -1,17 +1,22 @@
+ + + +
Total Item Total Invoice MatchUn Match
{{currency total_item}} {{currency total_invoice}} {{currency total_match_invoice}}{{currency total_unmatch_invoice}}
+
{{#ifeq view_type 'invoice'}} @@ -32,78 +37,125 @@ {{else}} - - - - - - - - - - - - - - - - {{#if lines}} - {{#each lines}} - - - - - - - - + + + + + + + + + + + + + + + {{#if lines}} + {{#each lines}} + + + + + + + + + + + + + + + {{/each}} + {{else}} + {{/if}} + + + + + + + + + + + + + + + + {{else}} + {{#ifeq pcode "UC"}} + + + + + + + + + + + {{#each lines}} + + + + + + + + - - - - - - - {{/each}} + + + {{/each}} + + + + + + + + + + {{else}} - {{/if}} - - - - - - - - - - - - - - - + TODO + {{/ifeq}} + {{/ifeq}} {{/ifeq}}
No.DatePIDHNPatientFeeInv FeeEPOInv EPOServiceInv ServiceAmount
{{no}}{{date}}{{pid}}{{hn}}{{patient_name}}{{currency fee}} - - {{#if inv_fee_id}} - - {{inv_fee}} - + {{#ifeq pcode "SSO"}} +
No.DatePIDHNPatientFeeInv FeeEPOInv EPOServiceInv ServiceAmount
{{no}}{{date}}{{pid}}{{hn}}{{patient_name}}{{currency fee}} + + {{#if inv_fee_id}} + + {{inv_fee}} + + {{/if}} + + {{currency epo}} + + {{#if inv_epo_id}} + + {{inv_epo}} + + {{/if}} + + {{currency srv}} + + {{#if inv_srv_id}} + + {{inv_srv}} + + {{/if}} + + {{currency amount}}
{{currency total_fee}}{{currency total_epo}}{{currency total_srv}}{{currency total_amount}}
No.DateHNIDPatientFeeInvoice
{{no}}{{date}}{{hn}}{{pid}}{{patient_name}}{{currency fee}} + {{#if inv_number}} + + + {{inv_number}} + + {{/if}} - - {{currency epo}} - - {{#if inv_epo_id}} - - {{inv_epo}} - - {{/if}} - - {{currency srv}} - - {{#if inv_srv_id}} - - {{inv_srv}} - - {{/if}} - - {{currency amount}}
{{currency total_fee}}
{{currency total_fee}}{{currency total_epo}}{{currency total_srv}}{{currency total_amount}}
+