diff --git a/netforce_clinic/layouts/clinic_account_menu.xml b/netforce_clinic/layouts/clinic_account_menu.xml index 6bc6bdd..98b1ca2 100644 --- a/netforce_clinic/layouts/clinic_account_menu.xml +++ b/netforce_clinic/layouts/clinic_account_menu.xml @@ -5,7 +5,6 @@ - @@ -20,6 +19,7 @@ + diff --git a/netforce_clinic/layouts/clinic_dialyzer_form.xml b/netforce_clinic/layouts/clinic_dialyzer_form.xml index aea4907..09c0247 100644 --- a/netforce_clinic/layouts/clinic_dialyzer_form.xml +++ b/netforce_clinic/layouts/clinic_dialyzer_form.xml @@ -40,6 +40,7 @@ + diff --git a/netforce_clinic/models/dialyzer.py b/netforce_clinic/models/dialyzer.py index 0ac16be..6dca684 100644 --- a/netforce_clinic/models/dialyzer.py +++ b/netforce_clinic/models/dialyzer.py @@ -29,7 +29,7 @@ class Dialyzer(Model): "visit_id": fields.Many2One("clinic.visit","Visit",search=True), "hd_case_id": fields.Many2One("clinic.hd.case","HD Case",search=True), "hd_cases": fields.One2Many("clinic.hd.case","dlz_id","HD Case"), #TODO funtion to get hd case - "hd_cases_dlz": fields.One2Many("clinic.hd.case.dialyzer","dialyzer_id","Dialyzer History"), + "hd_cases_dlz": fields.One2Many("clinic.hd.case.dialyzer","dialyzer_id","Dialyzer History",domain=[['hd_case_id.state','in','waiting_payment','paid']]), 'department_id': fields.Many2One("clinic.department","Department",search=True), "membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"), } diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 42b2363..0f90687 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -894,9 +894,14 @@ class HDCase(Model): obj=self.browse(ids)[0] # TODO pop to note obj.write({"state":"cancelled"}) - + + #FIXME should use history to get the last time time and it should drop automatical def update_usetime(self,ids,context={}): + datenow=time.strftime("%Y-%m-%d") for obj in self.browse(ids): + # in case to draft + if obj.date < datenow: + continue is_decrease=context.get('is_decrease') for dlz_line in obj.dialyzers: dlz=dlz_line.dialyzer_id @@ -1050,6 +1055,7 @@ class HDCase(Model): def undo(self,ids,context={}): obj=self.browse(ids)[0] context['is_decrease']=True + # in case to draft obj.update_usetime(context=context) for line in obj.lines: line.write({ diff --git a/netforce_clinic/models/hd_case_dialyzer.py b/netforce_clinic/models/hd_case_dialyzer.py index ed7781e..7adfee1 100644 --- a/netforce_clinic/models/hd_case_dialyzer.py +++ b/netforce_clinic/models/hd_case_dialyzer.py @@ -6,9 +6,11 @@ class HDCaseDialyzerLine(Model): def _get_all(self,ids,context={}): res={} for obj in self.browse(ids): - hdcase_date=obj.hd_case_id.date + hdcase=obj.hd_case_id res[obj.id]={ - 'hdcase_date': hdcase_date, + 'hdcase_date': hdcase.date, + 'hdcase_state': hdcase.state, + 'nurse_id': hdcase.nurse_id.id, } return res @@ -21,6 +23,8 @@ class HDCaseDialyzerLine(Model): "max_use_time":fields.Integer("Max use time"), "membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"), 'hdcase_date': fields.Date('Date', function="_get_all",function_multi=True), + "hdcase_state": fields.Selection([("draft","Draft"),('waiting_treatment','Waiting Treatment'),("in_progress","In Progress"),("completed","Finish Treatment"),('paid','Paid'),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("cancelled","Cancelled")],"Status",required=True,function="_get_all",function_multi=True), + 'nurse_id': fields.Many2One('clinic.staff', 'Nurse',function="_get_all",function_multi=True), } _order="hd_case_id.date desc" diff --git a/netforce_clinic/models/payment_matching.py b/netforce_clinic/models/payment_matching.py index 958900d..69d10a1 100644 --- a/netforce_clinic/models/payment_matching.py +++ b/netforce_clinic/models/payment_matching.py @@ -11,7 +11,6 @@ class PaymentMatching(Model): _string="Payment Matching" _transient=True - _fields={ 'name': fields.Char("Name"), "date": fields.Date("Month"), @@ -26,6 +25,7 @@ class PaymentMatching(Model): 'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type",required=True), 'pcode': fields.Char("Code",required=True), 'hcode_id': fields.Many2One("clinic.hospital","HCode"), + 'inv_ids': fields.Text("Invoice ids"), } def _get_date_from(self,context={}): @@ -49,18 +49,25 @@ class PaymentMatching(Model): date_from=line.date_start date_to=line.date_stop break - tids=get_model('clinic.patient.type').search([['default','=',True]]) patient_type_id=None - if tids: - patient_type_id=tids[0] + pcode='SSO' + for ptype in get_model('clinic.patient.type').search_read([['default','=',True]],['code']): + pcode=ptype['code'] + patient_type_id=ptype['id'] + hdcode_id=None + for hid in get_model("clinic.hospital").search([]): + hdcode_id=hid + break res={ 'period_id': period_id, 'date': time.strftime("%Y-%m-%d"), 'date_from': date_from, 'date_to': date_to, - 'inv_state': 'waiting_payment', + #'inv_state': 'waiting_payment', 'view_type': 'invoice', 'patient_type_id': patient_type_id, + 'pcode': pcode, + 'hcode_id': hdcode_id, } return res @@ -121,6 +128,7 @@ class PaymentMatching(Model): inv_state=defaults.get('inv_state') view_type=defaults.get('view_type') pcode='' + obj=None if ids: obj=self.browse(ids)[0] date_from=obj.date_from @@ -143,13 +151,15 @@ class PaymentMatching(Model): dom=[ ['date','>=',date_from], ['date','<=',date_to], - ['state','=',inv_state], ] + if inv_state: + dom.append(['state','=',inv_state]) if branch_id and not department_id: 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'] + print('dom ', dom) + field_names=['date','number','amount_total','amount_due','patient_id','state'] for inv in get_model('account.invoice').search_read(dom,field_names): vals={ 'id': inv['id'], @@ -170,6 +180,7 @@ class PaymentMatching(Model): vals[field_name]=inv[field_name] invoices.append(vals) return invoices + inv_match_ids=[] if view_type=='invoice': lines=get_invoices() total_invoice=len(lines) @@ -214,12 +225,16 @@ class PaymentMatching(Model): if inv['patient_id']: # check card no first then HN finally patient name if pid==inv['patient_cid'] or hn==inv['patient_hn'] or name_nospace==inv['patient_nospace_name']: - inv_amt=inv['amount_due'] + #inv_amt=inv['amount_due'] + inv_amt=inv['amount_total'] inv_date=inv['date'] if inv_date==date and inv_amt==line_vals[item_amt]: line_vals['inv_%s'%(item_amt)]=inv['number'] line_vals['inv_%s_id'%(item_amt)]=inv['id'] - total_match_invoice+=1 + line_vals['inv_%s_state'%(item_amt)]=inv['state'] + if inv['state']=='waiting_payment': + inv_match_ids.append(inv['id']) + total_match_invoice+=1 break lines.append(line_vals) no+=1 @@ -267,6 +282,7 @@ class PaymentMatching(Model): 'epo': 0, 'inv_id': None, 'inv_number': '', + 'inv_state': '', 'no': no, } for inv in invoices: @@ -275,13 +291,20 @@ class PaymentMatching(Model): if date==inv['date'] and fee==inv['amount_due']: vals['inv_id']=inv['id'] vals['inv_number']=inv['number'] - total_match_invoice+=1 + vals['inv_state']=inv['state'] + if inv['state']=='waiting_payment': + inv_match_ids.append(inv['id']) + total_match_invoice+=1 break lines.append(vals) no+=1 pc=0 if total_invoice: pc=(total_match_invoice/total_invoice)*100 + if inv_match_ids and obj: + obj.write({ + 'inv_ids': str(inv_match_ids), + }) data={ 'lines': lines, 'date_from': date_from, @@ -292,7 +315,8 @@ class PaymentMatching(Model): 'total_srv': total_srv, 'total_invoice': total_invoice, 'total_match_invoice': total_match_invoice, - 'total_match_invoice_in_pc': pc, + 'pc_match': pc, + 'pc_unmatch': 100-pc, 'total_unmatch_invoice': total_invoice-total_match_invoice, 'total_amount': total_amount, 'view_type': view_type, diff --git a/netforce_clinic/templates/payment_matching.hbs b/netforce_clinic/templates/payment_matching.hbs index d9f78e7..b78a6ff 100644 --- a/netforce_clinic/templates/payment_matching.hbs +++ b/netforce_clinic/templates/payment_matching.hbs @@ -1,17 +1,31 @@ + + + {{currency pc_match}}% Match (success) + + + {{currency pc_unmatch}}% Un Match (fail) + + + + - Total Item - Total Invoice - Match - Un Match + Total Item Waiting To Matching + Total Invoice + Match + Un Match {{currency total_item}} {{currency total_invoice}} - {{currency total_match_invoice}} - {{currency total_unmatch_invoice}} + + {{currency total_match_invoice}} + + + {{currency total_unmatch_invoice}} + @@ -65,7 +79,11 @@ {{#if inv_fee_id}} - + {{#ifeq inv_fee_state "paid"}} + + {{else}} + + {{/ifeq}} {{inv_fee}} {{/if}}