improve labor cost report
parent
da37172298
commit
4cda6b2cac
|
@ -9,7 +9,7 @@
|
|||
<group span="6" columns="1">
|
||||
<template>
|
||||
<div>
|
||||
<b>Note: </b> For Quick Matching, Please Define Branch.
|
||||
<b>Note: </b> For Quick Matching, Please Enter Branch.
|
||||
</div>
|
||||
</template>
|
||||
</group>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
|
@ -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"),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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': 'พยาบาล',
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -11,6 +11,27 @@
|
|||
<span class="label label-default">Not Match: {{total_unmatch}}</span>
|
||||
</th>
|
||||
</tr>
|
||||
<!--
|
||||
{{#ifeq state "all"}}
|
||||
<tr>
|
||||
<th colspan="15" style="text-align:center">
|
||||
<span class="label label-primary">Total: {{total}}</span>
|
||||
<span class="label label-success">Match: {{total_match}}</span>
|
||||
<span class="label label-default">Not Match: {{total_unmatch}}</span>
|
||||
</th>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr>
|
||||
<th colspan="15" style="text-align:center">
|
||||
{{#ifeq state "not_match"}}
|
||||
<span class="label label-default">Total: {{total_unmatch}}</span>
|
||||
{{else}}
|
||||
<span class="label label-success">Total: {{total_match}}</span>
|
||||
{{/ifeq}}
|
||||
</th>
|
||||
</tr>
|
||||
{{/ifeq}}
|
||||
-->
|
||||
<tr>
|
||||
<th colspan="10" style="text-align:center;background-color:#f9e37d;">Import File</th>
|
||||
<th colspan="5" style="text-align:center;background-color:#2d6ed2;color:white">Netforce</th>
|
||||
|
@ -76,7 +97,7 @@
|
|||
</table>
|
||||
{{#if message}}
|
||||
<strong>
|
||||
File Math Only:
|
||||
Day Required:
|
||||
<span style="color:red">
|
||||
{{message}}
|
||||
</strong>
|
||||
|
|
|
@ -71,7 +71,9 @@
|
|||
{{#if desc}}
|
||||
<th style="text-align:left;width:10%">{{qty}}</th>
|
||||
{{else}}
|
||||
<td style="text-align:right">{{currency qty}}</td>
|
||||
<td style="text-align:right">
|
||||
{{view "link" string=qty action="clinic_hd_case" action_options=option_qty}}
|
||||
</td>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</tr>
|
||||
|
@ -80,7 +82,13 @@
|
|||
{{#if desc}}
|
||||
<th style="text-align:left;width:10%">{{qty2}}</th>
|
||||
{{else}}
|
||||
<td style="text-align:right">{{currency qty2}}</td>
|
||||
<td style="text-align:right">
|
||||
{{#if walkin_qty}}
|
||||
{{view "link" string=qty2 action="clinic_hd_case" action_options=option_qty2}}
|
||||
{{else}}
|
||||
0.00
|
||||
{{/if}}
|
||||
</td>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue