labor cost

conv_bal
watcha.h@almacom.co.th 2015-01-19 22:40:24 +07:00
parent 54738bce05
commit 32ed942983
5 changed files with 51 additions and 54 deletions

View File

@ -30,7 +30,7 @@
<field name="var_x" span="6" offset="6"/> <field name="var_x" span="6" offset="6"/>
</group> </group>
<group span="6" columns="1"> <group span="6" columns="1">
<field name="total" span="6" offset="6"/> <field name="total" string="Total" span="6" offset="6"/>
</group> </group>
</tab> </tab>
<tab string="Nurses"> <tab string="Nurses">
@ -54,7 +54,7 @@
<field name="amount"/> <field name="amount"/>
</form> </form>
</field> </field>
<field name="total_ncost" span="3" offset="9"/> <field name="total_ncost" string="Total" span="3" offset="9"/>
</tab> </tab>
<tab string="Doctors"> <tab string="Doctors">
<field name="doctor_lines" nolabel="1"> <field name="doctor_lines" nolabel="1">
@ -77,7 +77,7 @@
<field name="amount"/> <field name="amount"/>
</form> </form>
</field> </field>
<field name="total_dcost" span="3" offset="9"/> <field name="total_dcost" string="Total" span="3" offset="9"/>
</tab> </tab>
<tab string="Other Staff"> <tab string="Other Staff">
<field name="staff_lines" nolabel="1"> <field name="staff_lines" nolabel="1">
@ -100,7 +100,7 @@
<field name="amount"/> <field name="amount"/>
</form> </form>
</field> </field>
<field name="total_stcost" span="3" offset="9"/> <field name="total_stcost" string="Total" span="3" offset="9"/>
</tab> </tab>
</tabs> </tabs>
<foot> <foot>

View File

@ -1,4 +1,7 @@
<list model="clinic.labor.cost"> <list model="clinic.labor.cost">
<field name="cycle_item_id"/> <field name="cycle_item_id"/>
<field name="total_dcost"/>
<field name="total_ncost"/>
<field name="total_stcost"/>
<field name="total"/> <field name="total"/>
</list> </list>

View File

@ -38,7 +38,8 @@ class LaborCost(Model):
total_stcost=0.0 total_stcost=0.0
for line in obj.staff_lines: for line in obj.staff_lines:
total_stcost+=line.amount or 0.0 total_stcost+=line.amount or 0.0
#XXX
total=total_ncost+total_dcost+total_stcost
res[obj.id]={ res[obj.id]={
'var_pt': total_case, 'var_pt': total_case,
'var_ptx': total_case*(obj.var_k or 0), 'var_ptx': total_case*(obj.var_k or 0),
@ -63,10 +64,10 @@ class LaborCost(Model):
'var_fml2': fields.Char("Step 2:",function="_get_all",function_multi=True), 'var_fml2': fields.Char("Step 2:",function="_get_all",function_multi=True),
'var_fml3': fields.Char("X:",function="_get_all",function_multi=True), 'var_fml3': fields.Char("X:",function="_get_all",function_multi=True),
'var_x': fields.Char("X:",function="_get_all",function_multi=True), 'var_x': fields.Char("X:",function="_get_all",function_multi=True),
'total': fields.Float("Total",function="_get_all",function_multi=True), 'total': fields.Float("Total (Baht)",function="_get_all",function_multi=True),
'total_ncost': fields.Float("Total",function="_get_all",function_multi=True), 'total_ncost': fields.Float("Nurse Cost",function="_get_all",function_multi=True),
'total_dcost': fields.Float("Total",function="_get_all",function_multi=True), 'total_dcost': fields.Float("Doctor Cost",function="_get_all",function_multi=True),
'total_stcost': fields.Float("Total",function="_get_all",function_multi=True), 'total_stcost': fields.Float("Staff Cost",function="_get_all",function_multi=True),
'manual': fields.Boolean("Manual"), 'manual': fields.Boolean("Manual"),
"formulars": fields.One2Many("clinic.labor.cost.formular", "labor_cost_id", "Formulars"), "formulars": fields.One2Many("clinic.labor.cost.formular", "labor_cost_id", "Formulars"),
"nurse_lines": fields.One2Many("clinic.labor.cost.line", "labor_cost_id", "Nurse Lines",domain=[['type','=','nurse']]), "nurse_lines": fields.One2Many("clinic.labor.cost.line", "labor_cost_id", "Nurse Lines",domain=[['type','=','nurse']]),

View File

@ -67,53 +67,46 @@ class ReportStaffFeeDetail(Model):
dom.append(['date','>=',time_start]) dom.append(['date','>=',time_start])
dom.append(['date','<=',time_stop]) dom.append(['date','<=',time_stop])
if department_id: if department_id:
dom.append(['department_id','=',department_id]) dom.append(['staff_id.department_id','=',department_id])
if branch_id: if branch_id:
dom.append(['branch_id','=',branch_id]) dom.append(['staff_id.branch_id','=',branch_id])
staff_name='' staff_name=''
if staff_id: if staff_id:
staff=get_model("clinic.staff").browse(staff_id) dom.append(['staff_id','=',staff_id])
staff_name=staff.name
dom.append(['staff_id','=',staff.id])
dlines=get_model('clinic.labor.cost.line').search_browse(dom)
# group by date
all_vals={}
for dline in dlines:
date=dline.date
staff=dline.staff_id
if staff_type:
if staff_type!=staff.type:
continue
key=(date,staff.id)
if key not in all_vals.keys():
all_vals[key]={
'qty': 0,
'staff_type': utils.STAFF_TYPE.get(staff.type,''),
'staff_name': staff.name or "",
'amount': 0,
}
all_vals[key]['qty']+=dline.qty or 0
all_vals[key]['amount']+=dline.amount or 0
lines=[] lines=[]
total_amount=0.0 total_qty=0
total_qty=0.0 total_amount=0
for key,vals in all_vals.items(): lines=[]
date,staff_id=key for lcline in get_model('clinic.labor.cost.line').search_browse(dom):
qty=vals['qty'] or 0 lc=lcline.labor_cost_id
amount=vals['amount'] or 0 item=lc.cycle_item_id
_staff_name=vals['staff_name'] or '' date=item.date
staff_type=vals['staff_type'] cycle=item.cycle_id
lines.append({ branch=item.branch_id
'date': date, dpt=item.department_id
'qty': qty, for dt in lc.doctor_lines:
'staff_type': staff_type, staff=dt.staff_id
'staff_name': _staff_name, lines.append({
'amount': amount or 0.0, 'staff_id': staff.id,
}) 'staff_name': staff.name or '',
total_qty+=qty 'staff_type': staff.type or '',
total_amount+=amount 'date': date,
'cycle_id': cycle.id,
'branch_id': branch.id,
'department_id': dpt.id,
})
for nr in lc.nurse_lines:
staff=dt.staff_id
lines.append({
'staff_id': staff.id,
'staff_name': staff.name or '',
'staff_type': staff.type or '',
'date': date,
'cycle_id': cycle.id,
'branch_id': branch.id,
'department_id': dpt.id,
})
month_str=utils.MONTHS['th_TH'][int(month)] month_str=utils.MONTHS['th_TH'][int(month)]
start=int(time_start[8:10]) start=int(time_start[8:10])
stop=int(time_stop[8:10]) stop=int(time_stop[8:10])

View File

@ -1,7 +1,7 @@
todo: todo:
- report - report
- doctor labort cost detail - doctor labort cost detail ***
- matching payment - matching payment ***
- popup messagging - popup messagging
======= =======
generate visit ใหม่ -> ok generate visit ใหม่ -> ok