diff --git a/netforce_clinic/layouts/clinic_matching_hdcase.xml b/netforce_clinic/layouts/clinic_matching_hdcase.xml index 2cdf845..a16d9ee 100644 --- a/netforce_clinic/layouts/clinic_matching_hdcase.xml +++ b/netforce_clinic/layouts/clinic_matching_hdcase.xml @@ -9,7 +9,7 @@ diff --git a/netforce_clinic/migrations/__init__.py b/netforce_clinic/migrations/__init__.py index bde9b20..3a2b12b 100644 --- a/netforce_clinic/migrations/__init__.py +++ b/netforce_clinic/migrations/__init__.py @@ -1,4 +1,5 @@ from . import clinic_setting +from . import hdcase #from . import remove_conv_bal #from . import import_acc #from . import update_labor_cost_line diff --git a/netforce_clinic/migrations/hdcase.py b/netforce_clinic/migrations/hdcase.py new file mode 100644 index 0000000..2380680 --- /dev/null +++ b/netforce_clinic/migrations/hdcase.py @@ -0,0 +1,27 @@ +from datetime import datetime + +from netforce.model import get_model +from netforce import migration +from netforce.access import set_active_user, get_active_user, set_active_company, get_active_company + +class Migration(migration.Migration): + _name="clinic.hd.case" + _version="2.11.0" + + def migrate(self): + user_id=get_active_user() + company_id=get_active_company() + set_active_company(1) + set_active_user(1) + for hdcase in get_model("clinic.hd.case").search_browse([]): + note=hdcase.note or '' + note='%s '%note + vals={ + 'note': note, + } + hdcase.write(vals) + set_active_company(company_id) + set_active_user(user_id) + return True + +Migration.register() diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index e44f449..18c942d 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -64,9 +64,16 @@ class HDCase(Model): type_code=obj.patient_id.type_id.code if obj.patient_id.type_id.hct_include: include=True + staff_id=None + for sline in obj.staffs: + staff=sline.staff_id + if staff and sline.priop=='personal': + staff_id=staff.id + break res[obj.id]={ 'hct_include': include, 'type_code': type_code, + 'doctor_id2': staff_id, } return res @@ -235,6 +242,7 @@ class HDCase(Model): "hct_msg" : fields.Char("",function="_get_hct_msg",store=True), 'hct_include': fields.Boolean("HCT Include", function="_get_store", function_multi=True,store=True), 'type_code': fields.Char("Product Code", function="_get_store", function_multi=True,store=True), + 'doctor_id2': fields.Many2One("clinic.staff","Doctor2", function="_get_store", function_multi=True,store=True), "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), "staffs": fields.One2Many("clinic.hd.case.staff","hd_case_id","Staffs"), "comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"), diff --git a/netforce_clinic/models/matching_hdcase.py b/netforce_clinic/models/matching_hdcase.py index 7aa8c4f..b3bc23e 100644 --- a/netforce_clinic/models/matching_hdcase.py +++ b/netforce_clinic/models/matching_hdcase.py @@ -77,7 +77,7 @@ class MatchingHDCase(Model): state="all" if ids: obj=self.browse(ids)[0] - state=obj.state + state=obj.state or "all" date_from=obj.date_from date_to=obj.date_to branch_id=obj.branch_id.id @@ -319,8 +319,15 @@ class MatchingHDCase(Model): date='' if date_from==date_to: date=date_from + nlines=[] + no=1 + for line in sorted(lines,key=lambda x: x.get('date')): + line['no']=no + nlines.append(line) + no+=1 data={ - 'lines': sorted(lines,key=lambda x: x.get('date')), + 'state': state, + 'lines': nlines, 'date_from': date_from, 'date_to': date_to, 'date': date, diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost.py index e7b0c7d..6ed865f 100644 --- a/netforce_clinic/models/report_labor_cost.py +++ b/netforce_clinic/models/report_labor_cost.py @@ -21,13 +21,15 @@ class ReportLaborCost(Model): } def _get_date_from(self,context={}): - year,month=time.strftime("%Y-%m").split("-") - return '%s-%s-01'%(year,month) + year,month,day=time.strftime("%Y-%m-%d").split("-") + #return '%s-%s-01'%(year,month) + return '%s-%s-%s'%(year,month,day) def _get_date_to(self,context={}): year,month,day=time.strftime("%Y-%m-%d").split("-") weekday, total_day=monthrange(int(year), int(month)) - return "%s-%s-%s"%(year,month,total_day) + #return "%s-%s-%s"%(year,month,total_day) + return "%s-%s-%s"%(year,month,day) def default_get(self,field_names=None,context={},**kw): defaults=context.get("defaults",{}) @@ -227,10 +229,22 @@ class ReportLaborCost(Model): brch_id=vals['branch_id'] walkin_qty=vals['walkin_qty'] cost=(walkin_qty+qty)*cost_per_case + dom1=[ + ['department_id','=',dpt_id], + ['branch_id','=',brch_id], + ['date','>=',date_from], + ['date','<=',date_to], + ['state','in',['waiting_payment','paid']], + ] + dom2=dom1+[['doctor_id2.number','=','']] + dom3=dom1+[['doctor_id2.number','!=','']] dlines.append({ 'name': dt_name, - 'qty': qty, - 'qty2': walkin_qty, + 'qty': "{0:.2f}".format(round(qty,2)), + 'qty2': "{0:.2f}".format(round(walkin_qty,2)), + 'walkin_qty': walkin_qty, + 'option_qty': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom3)), + 'option_qty2': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom2)), 'total_qty': walkin_qty+qty, 'cost': cost, 'total': 0, @@ -250,22 +264,39 @@ class ReportLaborCost(Model): 'branch_id':None, 'staff_type': 'doctor', }]+sorted(dlines,key=lambda x: x['name']) + dom4=[ + ['date','>=',date_from], + ['date','<=',date_to], + ['state','in',['waiting_payment','paid']], + ['doctor_id2.number','!=',''], + ] + if department_id: + dom4.append(['department_id','=',department_id]) + if branch_id: + dom4.append(['branch_id','=',branch_id]) + dom5=dom4+[['doctor_id2.number','=','']] dlines.append({ 'name': 'รวม', 'qty': 0, 'qty2': 0, 'total_qty':0, 'cost': 0, + 'walkin_qty': 0, 'staff_type': 'doctor', 'cycle_id': cycle_id, 'branch_id': branch_id, 'department_id': department_id, + 'option_qty': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom4)), + 'option_qty2': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom5)), }) for dline in dlines[1:-1]: - dlines[-1]['qty']+=dline['qty'] or 0 - dlines[-1]['qty2']+=dline['qty2'] or 0 + dlines[-1]['qty']+=float(dline['qty']) or 0 + dlines[-1]['qty2']+=float(dline['qty2']) or 0 dlines[-1]['total_qty']+=dline['total_qty'] or 0 dlines[-1]['cost']+=dline['cost'] or 0 + dlines[-1]['walkin_qty']+=float(dline['qty2']) or 0 + dlines[-1]['qty']="{0:.2f}".format(round(dlines[-1]['qty'],2)) #total + dlines[-1]['qty2']="{0:.2f}".format(round(dlines[-1]['qty2'],2)) #total nlines.append({ 'name': 'พยาบาล', diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index 231451a..8a7cdf2 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -161,20 +161,6 @@ class ClinicSetting(Model): if user_id !=1: print("Only admin!!") return - pts=set() - for vst in get_model("clinic.visit").search_browse([['doctor_id','=',None],['patient_id.dispose','=',False]]): - pt=vst.patient_id - dt=vst.doctor_id - if not dt and pt.doctor_id: - vst.write({ - 'doctor_id': pt.doctor_id.id, - }) - pts.update({pt.name}) - print('-'*50) - for pt in pts: - print(pt) - print('-'*50) - #obj=self.browse(ids)[0] #obj.del_duplicate_staff() #obj.merge_staff() diff --git a/netforce_clinic/templates/matching_hdcase.hbs b/netforce_clinic/templates/matching_hdcase.hbs index 64686cd..b154aed 100644 --- a/netforce_clinic/templates/matching_hdcase.hbs +++ b/netforce_clinic/templates/matching_hdcase.hbs @@ -11,6 +11,27 @@ Not Match: {{total_unmatch}} + Import File Netforce @@ -76,7 +97,7 @@ {{#if message}} - File Math Only: + Day Required: {{message}} diff --git a/netforce_clinic/templates/report_labor_cost.hbs b/netforce_clinic/templates/report_labor_cost.hbs index 493c946..359a2ca 100644 --- a/netforce_clinic/templates/report_labor_cost.hbs +++ b/netforce_clinic/templates/report_labor_cost.hbs @@ -71,7 +71,9 @@ {{#if desc}} {{qty}} {{else}} - {{currency qty}} + + {{view "link" string=qty action="clinic_hd_case" action_options=option_qty}} + {{/if}} {{/each}} @@ -80,7 +82,13 @@ {{#if desc}} {{qty2}} {{else}} - {{currency qty2}} + + {{#if walkin_qty}} + {{view "link" string=qty2 action="clinic_hd_case" action_options=option_qty2}} + {{else}} + 0.00 + {{/if}} + {{/if}} {{/each}}