labor cost
parent
26a874b8bc
commit
4e9025a0fe
|
@ -2,7 +2,6 @@
|
|||
<field name="string">HD Cases</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.hd.case</field>
|
||||
<!--<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Waiting Treatment",[["state","=","waiting_treatment"]]],["In Progress",[["state","=","in_progress"]]],["Waiting Payment",[["state","=","waiting_payment"]]],["Waiting Approval",[["state","=","waiting_approval"]]],["Completed",[["state","=","completed"]]],["Cancelled",[["state","=","cancelled"]]]]</field>-->
|
||||
<field name="tabs">[
|
||||
["All",[]],["Draft",[["state","=","draft"]]],
|
||||
["Waiting Treatment",[["state","=","waiting_treatment"]]],
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<action>
|
||||
<field name="string">Labor Cost Entries</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.labor.cost.entry</field>
|
||||
<field name="menu">account_menu</field>
|
||||
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Approved",[["state","=","approved"]]]]</field>
|
||||
</action>
|
|
@ -0,0 +1,41 @@
|
|||
<form model="clinic.labor.cost.entry" attrs='{"readonly":[["state","=","approved"]]}'>
|
||||
<head>
|
||||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="Create Journal Entry"/>
|
||||
</button>
|
||||
</head>
|
||||
<field name="date" span="3" mode="month"/>
|
||||
<tabs>
|
||||
<tab string="General">
|
||||
<field name="lines" nolabel="1">
|
||||
<list>
|
||||
<field name="staff_id"/>
|
||||
<field name="qty" onchange="onchange_line"/>
|
||||
<field name="rate" onchange="onchange_line"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
<form>
|
||||
<field name="staff_id"/>
|
||||
<field name="qty"/>
|
||||
<field name="rate"/>
|
||||
<field name="amount"/>
|
||||
</form>
|
||||
</field>
|
||||
<field name="total_amt" span="3" offset="9"/>
|
||||
</tab>
|
||||
<tab string="Approval">
|
||||
<group form_layout="stacked">
|
||||
<field name="user_id" span="3"/>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Note">
|
||||
<group form_layout="stacked">
|
||||
<field name="note" nolabel="1" span="3"/>
|
||||
</group>
|
||||
</tab>
|
||||
</tabs>
|
||||
<foot>
|
||||
<button string="Compute" icon="repeat" type="default" method="compute"/>
|
||||
</foot>
|
||||
</form>
|
|
@ -0,0 +1,5 @@
|
|||
<list model="clinic.labor.cost.entry" colors='{"#cfc":[["state","=","approved"]],"#dbdbdb":[["state","=","cancelled"]]}'>
|
||||
<field name="name"/>
|
||||
<field name="note"/>
|
||||
<field name="state"/>
|
||||
</list>
|
|
@ -33,7 +33,7 @@
|
|||
<field name="total" span="6" offset="6"/>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Cost">
|
||||
<tab string="Staff Earning">
|
||||
<field name="lines" nolabel="1">
|
||||
<list>
|
||||
<field name="cycle_id"/>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<list model="clinic.labor.cost">
|
||||
<field name="cycle_item_id"/>
|
||||
<field name="cycle_item_id"/>
|
||||
<field name="total"/>
|
||||
</list>
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
<item string="Cycles">
|
||||
<item string="Cycles" action="clinic_cycle"/>
|
||||
<item string="Cycle Items" action="clinic_cycle_item"/>
|
||||
<!--<item string="Cycle Daily" action="clinic_cycle_daily"/>-->
|
||||
<!--<item string="Cycle Monthly" action="clinic_cycle_monthly"/>-->
|
||||
</item>
|
||||
<item string="Schedules" action="clinic_schedule">
|
||||
<item string="Schedules" action="clinic_schedule"/>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<item string="Ratchawat">
|
||||
<item string="Labor Cost" action="clinic_labor_cost"/>
|
||||
<item string="Labor Cost Items" action="clinic_labor_cost_item"/>
|
||||
<item string="Labor Cost Entries" action="clinic_labor_cost_entry"/>
|
||||
<item string="Import Payment" action="import_clinic_payment"/>
|
||||
<item string="HD Case Expense" action="clinic_hd_case_expense"/>
|
||||
<divider/>
|
||||
|
|
|
@ -76,3 +76,5 @@ from . import labor_cost
|
|||
from . import labor_cost_formular
|
||||
from . import labor_cost_line
|
||||
from . import labor_cost_staff
|
||||
from . import labor_cost_entry
|
||||
from . import labor_cost_entry_line
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
from netforce.utils import get_data_path
|
||||
from netforce.access import get_active_company
|
||||
|
||||
class LaborCost(Model):
|
||||
_name="clinic.labor.cost"
|
||||
_string="Labor Cost"
|
||||
_multi_company=True
|
||||
_name_field="cycle_item_id"
|
||||
_key=['cycle_item_id']
|
||||
|
||||
|
@ -57,8 +59,14 @@ class LaborCost(Model):
|
|||
"formulars": fields.One2Many("clinic.labor.cost.formular", "labor_cost_id", "Formulars"),
|
||||
"staffs": fields.One2Many("clinic.labor.cost.staff", "labor_cost_id", "Staffs"),
|
||||
"lines": fields.One2Many("clinic.labor.cost.line", "labor_cost_id", "Lines"),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'company_id': lambda *a: get_active_company(),
|
||||
}
|
||||
|
||||
|
||||
def compute(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
if not obj.manual:
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
import time
|
||||
|
||||
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
|
||||
|
||||
from . import utils
|
||||
|
||||
class LaborCostEntry(Model):
|
||||
_name="clinic.labor.cost.entry"
|
||||
_string="Labor Cost Entry"
|
||||
_multi_company=True
|
||||
_key=['name']
|
||||
|
||||
def _get_all(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
total_amt=0.0
|
||||
total_qty=0
|
||||
for line in obj.lines:
|
||||
total_qty+=line.qty or 0
|
||||
total_amt+=line.amount or 0.0
|
||||
res[obj.id]={
|
||||
'total_amt':total_amt,
|
||||
'total_qty': total_qty,
|
||||
}
|
||||
return res
|
||||
|
||||
_fields={
|
||||
'name': fields.Char("Name", search=True),
|
||||
'date': fields.Date("Month",required=True),
|
||||
'total_amt': fields.Float("Total", function="_get_all",function_multi=True),
|
||||
'total_qty': fields.Float("Total Qty", function="_get_all",function_multi=True),
|
||||
"lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Lines"),
|
||||
'state': fields.Selection([['draft','Draft'],['approved','Approved']],"State"),
|
||||
'user_id': fields.Many2One("base.user","Approver"),
|
||||
'note': fields.Text("Note"),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'state': 'draft',
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'user_id': lambda *a: get_active_user(),
|
||||
'company_id': lambda *a: get_active_company(),
|
||||
}
|
||||
|
||||
def compute(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
year,month,day=obj.date.split("-")
|
||||
db=get_connection()
|
||||
line_ids=[r['id'] for r in db.query("select id from clinic_labor_cost_line where extract(month from date)=%s",int(month))]
|
||||
staffs={}
|
||||
for line in get_model("clinic.labor.cost.line").browse(line_ids):
|
||||
staff=line.staff_id
|
||||
qty=line.qty
|
||||
amt=line.amount
|
||||
if not staffs.get(staff.id):
|
||||
staffs[staff.id]={
|
||||
'qty': 0,
|
||||
'amt': 0,
|
||||
'rate': 0, # XXX for special nurse
|
||||
}
|
||||
staffs[staff.id]['qty']+=qty
|
||||
staffs[staff.id]['amt']+=amt
|
||||
|
||||
lines=[]
|
||||
timenow=time.strftime("%Y-%m-%d")
|
||||
for staff_id, vals in staffs.items():
|
||||
lines.append(('create',{
|
||||
'staff_id': staff_id,
|
||||
'qty': vals['qty'] or 0,
|
||||
'amount': vals['amt'] or 0.0,
|
||||
'date': timenow,
|
||||
'rate': vals['amt'],
|
||||
}))
|
||||
|
||||
for line in obj.lines:
|
||||
line.delete()
|
||||
|
||||
obj.write({
|
||||
'lines': lines,
|
||||
})
|
||||
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_labor_cost_entry',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash': 'Compute Succesffuly',
|
||||
}
|
||||
|
||||
def create(self,vals,**kw):
|
||||
vals['name']=utils.date2thai(vals['date'],format='%(BY)s/%(m)s')
|
||||
new_id=super().create(vals,**kw)
|
||||
return new_id
|
||||
|
||||
def write(self,ids,vals,**kw):
|
||||
if 'date' in vals.keys():
|
||||
vals['name']=utils.date2thai(vals['date'],format='%(BY)s/%(m)s')
|
||||
else:
|
||||
obj=self.browse(ids)[0]
|
||||
vals['name']=utils.date2thai(obj.date,format='%(BY)s/%(m)s')
|
||||
super().write(ids,vals,**kw)
|
||||
|
||||
def onchange_line(self,context={}):
|
||||
data=context['data']
|
||||
path=context['path']
|
||||
line=get_data_path(data,path,parent=True)
|
||||
line['amount']=(line['qty'] or 0) * (line['rate'] or 0.0)
|
||||
data=self.update_amount(context)
|
||||
return data
|
||||
|
||||
def update_amount(self,context={}):
|
||||
data=context['data']
|
||||
total_amt=0.0
|
||||
for line in data['lines']:
|
||||
total_amt+=line['amount']
|
||||
data['total_amt']=total_amt
|
||||
return data
|
||||
|
||||
LaborCostEntry.register()
|
|
@ -0,0 +1,27 @@
|
|||
import time
|
||||
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.utils import get_data_path
|
||||
from netforce.access import get_active_company
|
||||
|
||||
class LaborCostEntryLine(Model):
|
||||
_name="clinic.labor.cost.entry.line"
|
||||
_string="Labor Cost Entry Line"
|
||||
_multi_company=True
|
||||
|
||||
_fields={
|
||||
'entry_id': fields.Many2One("clinic.labor.cost.entry","Entry",required=True),
|
||||
'date': fields.Date("Date"),
|
||||
'staff_id': fields.Many2One("clinic.staff","Staff"),
|
||||
'qty': fields.Integer("Qty"),
|
||||
'rate': fields.Float("Rate"),
|
||||
'amount': fields.Float("Amount"),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'company_id': lambda *a: get_active_company(),
|
||||
}
|
||||
|
||||
LaborCostEntryLine.register()
|
|
@ -2,7 +2,8 @@
|
|||
urgent
|
||||
- report Matching Payment
|
||||
- special cost
|
||||
-
|
||||
- labor cost in period
|
||||
|
||||
============
|
||||
-- tonight -
|
||||
- matching
|
||||
|
|
Loading…
Reference in New Issue