working state

conv_bal
watcha.h@almacom.co.th 2015-01-23 08:50:44 +07:00
parent 4fd53c26b9
commit 9d41b1db76
7 changed files with 21 additions and 49 deletions

View File

@ -7,20 +7,20 @@
</button>
</head>
<group form_layout="stacked">
<!--<field name="name" span="2"/>-->
<field name="date" onchange="onchange_date" mode="month" span="2"/>
<field name="date_from" span="2"/>
<field name="date_to" span="2"/>
<field name="branch_id" onchange="onchange_branch" span="2"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
<field name="state" span="2"/>
</group>
<tabs>
<tab string="Doctors">
<field name="doctor_lines" nolabel="1">
<list>
<field name="staff_id"/>
<!--<field name="type"/>-->
<field name="department_id"/>
<field name="state"/>
<field name="qty" onchange="onchange_line"/>
<field name="rate" onchange="onchange_line"/>
<field name="amount"/>
@ -32,8 +32,8 @@
<field name="nurse_lines" nolabel="1">
<list>
<field name="staff_id"/>
<!--<field name="type"/>-->
<field name="department_id"/>
<field name="state"/>
<field name="qty" string="PT" onchange="onchange_line"/>
<field name="rate" onchange="onchange_line"/>
<field name="amount"/>

View File

@ -46,19 +46,11 @@
<field name="staff_id" domain="[['type','=','nurse']]"/>
<field name="description"/>
<field name="level_id"/>
<field name="state"/>
<field name="qty" onchange="onchange_cost_line"/>
<field name="rate" onchange="onchange_cost_line"/>
<field name="amount"/>
</list>
<form>
<field name="cycle_id"/>
<field name="staff_id"/>
<field name="description"/>
<field name="level_id"/>
<field name="qty"/>
<field name="rate"/>
<field name="amount"/>
</form>
</field>
<field name="total_ncost" string="Total" span="3" offset="9"/>
</tab>
@ -69,47 +61,14 @@
<field name="staff_id" domain="[['type','=','doctor']]"/>
<field name="description"/>
<field name="level_id"/>
<field name="state"/>
<field name="qty" onchange="onchange_cost_line"/>
<field name="rate" onchange="onchange_cost_line"/>
<field name="amount"/>
</list>
<form>
<field name="cycle_id"/>
<field name="staff_id"/>
<field name="description"/>
<field name="level_id"/>
<field name="qty"/>
<field name="rate"/>
<field name="amount"/>
</form>
</field>
<field name="total_dcost" string="Total" span="3" offset="9"/>
</tab>
<!--
<tab string="Other Staff">
<field name="staff_lines" nolabel="1">
<list>
<field name="cycle_id"/>
<field name="staff_id" domain="[['type','=','staff']]"/>
<field name="description"/>
<field name="level_id"/>
<field name="qty" onchange="onchange_cost_line"/>
<field name="rate" onchange="onchange_cost_line"/>
<field name="amount"/>
</list>
<form>
<field name="cycle_id"/>
<field name="staff_id"/>
<field name="description"/>
<field name="level_id"/>
<field name="qty"/>
<field name="rate"/>
<field name="amount"/>
</form>
</field>
<field name="total_stcost" string="Total" span="3" offset="9"/>
</tab>
-->
</tabs>
<foot>
<button string="Compute" icon="repeat" type="default" method="compute"/>

View File

@ -269,6 +269,7 @@ class LaborCost(Model):
'cycle_id': item.cycle_id.id,
'staff_id': nurse.id,
'level_id': level_id,
'state': nurse.state,
'rate': rate,
'type': 'nurse',
'qty': 1,
@ -291,6 +292,7 @@ class LaborCost(Model):
staff_total[staff.id]={
'base': 0,
'type': staff.type,
'state': staff.state,
'level_id': staff.level_id.id,
'qty': 0,
}
@ -305,10 +307,12 @@ class LaborCost(Model):
type=value['type']
qty=value['qty']
level_id=value['level_id']
state=value['state']
lines.append(('create',{
'cycle_id': item.cycle_id.id,
'staff_id': doctor_id,
'level_id': level_id,
'state': state,
'rate': base,
'qty': qty,
'type': type,
@ -329,6 +333,7 @@ class LaborCost(Model):
staff_id=vals['staff_id']
rate=vals['rate'] or 0
qty=vals['qty'] or 0
state=vals['state']
amount=qty*rate
key=(cycle_id,staff_id)
if not key in glines.keys():
@ -339,6 +344,7 @@ class LaborCost(Model):
'qty': qty,
'type': vals['type'],
'description': vals.get("description",""),
'state': state,
}
continue
glines[key]['amount']+=amount

View File

@ -2,7 +2,6 @@ import time
from calendar import monthrange
from netforce.model import Model, fields, get_model
from netforce.database import get_connection
from netforce.access import get_active_user, get_active_company
from netforce.utils import get_data_path
@ -56,6 +55,7 @@ class LaborCostEntry(Model):
'company_id': fields.Many2One("company","Company"),
'department_id': fields.Many2One("clinic.department","Department",search=True),
'branch_id': fields.Many2One("clinic.branch","Branch",search=True),
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
}
def _get_date_from(self,context={}):
@ -91,7 +91,8 @@ class LaborCostEntry(Model):
dom.append(['labor_cost_id.cycle_item_id.branch_id','=',obj.branch_id.id])
if obj.department_id:
dom.append(['labor_cost_id.cycle_item_id.department_id','=',obj.department_id.id])
if obj.state:
dom.append(['staff_id.state','=',obj.state])
for lc_id in get_model("clinic.labor.cost.line").search(dom):
line_ids.append(lc_id)
staffs={}
@ -99,6 +100,7 @@ class LaborCostEntry(Model):
staff=line.staff_id
qty=line.qty
amt=line.amount
state=line.state or staff.state
dpt=staff.department_id
if not dpt:
dpt=line.labor_cost_id.cycle_item_id.department_id
@ -108,6 +110,7 @@ class LaborCostEntry(Model):
'qty': 0,
'amt': 0,
'rate': 0, # XXX for special nurse
'state': state,
}
staffs[staff.id]['qty']+=qty
staffs[staff.id]['amt']+=amt
@ -117,6 +120,7 @@ class LaborCostEntry(Model):
for staff_id, vals in staffs.items():
qty=vals['qty'] or 0
amt=vals['amt'] or 0.0
state=vals['state']
rate=0.0
if qty:
rate=amt/qty # average
@ -126,6 +130,7 @@ class LaborCostEntry(Model):
'amount': amt,
'date': timenow,
'rate': rate,
'state': state,
'department_id': vals['department_id'],
}))

View File

@ -18,6 +18,7 @@ class LaborCostEntryLine(Model):
'company_id': fields.Many2One("company","Company"),
'department_id': fields.Many2One("clinic.department","Department"),
"type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type"),
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
}
_order="type"

View File

@ -18,6 +18,7 @@ class LaborCostLine(Model):
'date': fields.Date("Date",search=True),
'description': fields.Char("Description"),
'company_id': fields.Many2One('company','Company'),
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
}
_defaults={

View File

@ -4,7 +4,7 @@ todo:
- report
- doctor labort cost detail ***
- how much hd of that doctor in that period
-
- working status
- matching payment ***
- popup messagging -> Ask DJ