labor cost and search patient type

conv_bal
watcha.h 2015-01-30 18:15:13 +07:00
parent 9abb3c8e0e
commit d3a5cb86e2
19 changed files with 193 additions and 26 deletions

View File

@ -0,0 +1,8 @@
<action>
<field name="string">Report Staff</field>
<field name="view_cls">multi_view</field>
<field name="model">clinic.report.staff</field>
<field name="modes">list,form</field>
<field name="menu">account_menu</field>
<field name="limit">25</field>
</action>

View File

@ -22,7 +22,16 @@
<separator string="Doctor"/>
<field name="cost_per_case"/>
</tab>
<tab string="Importing">
<tab string="Products">
<field name="account_products" nolabel="1">
<list>
<field name="product_id"/>
<field name="ar_debit_id"/>
<field name="ar_credit_id"/>
</list>
</field>
</tab>
<tab string="Matching Payment">
<field name="patient_type_id"/>
<field name="imp_patient_type_id"/>
</tab>

View File

@ -3,6 +3,7 @@
<field name="date"/>
<field name="cycle_id"/>
<field name="patient_id"/>
<field name="patient_type_id"/>
<field name="department_id"/>
<field name="branch_id"/>
</search>

View File

@ -24,6 +24,7 @@
<field name="qty" onchange="onchange_line"/>
<field name="rate" onchange="onchange_line"/>
<field name="amount"/>
<field name="report_staff_id"/>
</list>
</field>
<field name="dcost" string="Total" span="3" offset="9"/>
@ -37,6 +38,7 @@
<field name="qty" string="PT" onchange="onchange_line"/>
<field name="rate" onchange="onchange_line"/>
<field name="amount"/>
<field name="report_staff_id"/>
</list>
</field>
<field name="ncost" string="Total" span="3" offset="9"/>

View File

@ -47,8 +47,8 @@
<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="qty" onchange="onchange_cost_line"/>-->
<!--<field name="rate" onchange="onchange_cost_line"/>-->
<field name="amount"/>
</list>
</field>

View File

@ -9,6 +9,7 @@
<item string="HD Case Expenses" action="clinic_hd_case_expense"/>
<divider/>
<header string="REPORTS"/>
<item string="Staff" action="clinic_report_staff"/>
<item string="Staff Fee" action="clinic_report_staff_fee"/>
<item string="Staff Fee Detail" action="clinic_report_staff_fee_detail"/>
<item string="Staff Fee Summary" action="clinic_report_staff_fee_sum"/>

View File

@ -0,0 +1,18 @@
<form model="clinic.report.staff">
<head>
<button string="Print" icon="print"/>
<button string="Options" dropdown="1">
<item string="TODO"/>
</button>
</head>
<group form_layout="stacked">
<field name="date_from" span="3"/>
<field name="date_to" span="3"/>
<field name="staff_id" span="3"/>
</group>
<field name="lines" nolabel="1">
<list>
<field name="hd_case_id"/>
</list>
</field>
</form>

View File

@ -0,0 +1,6 @@
<list model="clinic.report.staff">
<field name="date_from"/>
<field name="date_to"/>
<field name="staff_id"/>
<field name="hdcase_total"/>
</list>

View File

@ -1,6 +1,7 @@
from . import utils
from . import setting
from . import fin_setting
from . import setting_account_product
from . import setting_product
from . import setting_level
from . import setting_policy
@ -62,6 +63,8 @@ from . import report_hd_case_summary
from . import report_medical_summary
from . import report_recent_patient
from . import report_discontinue_patient
from . import report_staff
from . import report_staff_line
from . import report_staff_fee
from . import report_staff_fee_detail
from . import report_staff_fee_sum

View File

@ -78,7 +78,7 @@ class HDCase(Model):
"time_stop": fields.DateTime("Finish Time",required=True),
"date": fields.Date("Date",required=True,search=True),
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True),
"patient_type_id": fields.Many2One("clinic.patient.type", "Type",function="_get_patient_type"),
"patient_type_id": fields.Many2One("clinic.patient.type", "Type"),
"nurse_id": fields.Many2One("clinic.staff","Approve By", domain=[['type','=','nurse']]),
"department_id": fields.Many2One("clinic.department", "Department",search=True),
"wt_start": fields.Float("Start Wt (kg.)"),
@ -983,8 +983,8 @@ class HDCase(Model):
vals['lines']=[]
for st_prod in st.products:
if patient.type_id.id==st_prod.patient_type_id.id:
price=st_prod.price
qty=st_prod.qty
price=st_prod.price or 0
qty=st_prod.qty or 0
amt=st_prod.amount
categ=st_prod.product_categ_id
account_id=st_prod.ar_credit_id.id

View File

@ -394,12 +394,20 @@ class LaborCost(Model):
def update_amt(self,context):
total=0.0
data=context['data']
for line in data['lines']:
for line in data['doctor_lines']:
qty=line['qty'] or 0
rate=line['rate'] or 0.0
amt=qty*rate
total+=amt
data['total_cost']=total
data['total_dcost']=total
for line in data['nurse_lines']:
#qty=line['qty'] or 0
#rate=line['rate'] or 0.0
#amt=qty*rate
amt=line['amount'] or 0.0
total+=amt
data['total_ncost']=total
data['total']=total
return data
def create(self,vals,**kw):

View File

@ -101,18 +101,28 @@ class LaborCostEntry(Model):
amt=line.amount
state=line.state or staff.state
dpt=staff.department_id
citem=line.labor_cost_id.cycle_item_id
if not dpt:
dpt=line.labor_cost_id.cycle_item_id.department_id
dpt=citem.department_id
if not staffs.get(staff.id):
staffs[staff.id]={
'staff_type': staff.type,
'department_id': dpt.id,
'qty': 0,
'amt': 0,
'rate': 0, # XXX for special nurse
'state': state,
'report_staff_id': get_model("clinic.report.staff").create({
'date_from': obj.date_from,
'date_to': obj.date_to,
'staff_id': staff.id,
}),
'items': set(),
}
# create staff report
staffs[staff.id]['qty']+=qty
staffs[staff.id]['amt']+=amt
staffs[staff.id]['items'].update({citem.id})
lines=[]
timenow=time.strftime("%Y-%m-%d")
@ -120,6 +130,29 @@ class LaborCostEntry(Model):
qty=vals['qty'] or 0
amt=vals['amt'] or 0.0
state=vals['state']
report_staff_id=vals['report_staff_id']
report_staff=get_model("clinic.report.staff").browse(report_staff_id)
# find hd case for each staff
hids=set()
for item in get_model("clinic.cycle.item").browse(vals['items']):
if vals['staff_type']=='nurse':
for hd_case in item.hd_cases:
hids.update({hd_case.id})
else:
for hd_case in item.hd_cases:
doctor_id=hd_case.doctor_id.id
if staff_id==doctor_id:
hids.update({hd_case.id})
rlines=[]
for hid in list(hids):
rlines.append(('create',{
'hd_case_id': hid,
}))
report_staff.write({
'lines': rlines,
})
#####
rate=0.0
if qty:
rate=amt/qty # average
@ -131,6 +164,7 @@ class LaborCostEntry(Model):
'rate': rate,
'state': state,
'department_id': vals['department_id'],
'report_staff_id': report_staff.id,
}))
for line in obj.lines:

View File

@ -19,6 +19,7 @@ class LaborCostEntryLine(Model):
'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),
'report_staff_id': fields.Many2One("clinic.report.staff","#"),
}
_order="type"
@ -34,4 +35,11 @@ class LaborCostEntryLine(Model):
new_id=super().create(vals,**kw)
return new_id
def delete(self,ids):
for obj in self.browse(ids):
report=obj.report_staff_id
if report:
report.delete()
super().delete(ids)
LaborCostEntryLine.register()

View File

@ -0,0 +1,43 @@
from netforce.model import Model, fields
class ReportStaff(Model):
_name='clinic.report.staff'
_string="Report Staff"
def _get_store(self,ids,context={}):
res={}
for obj in self.browse(ids):
total=len(obj.lines)
res[obj.id]={
'name': total,
}
return res
def _get_all(self,ids,context={}):
res={}
for obj in self.browse(ids):
total=len(obj.lines)
res[obj.id]={
'hdcase_total': total,
}
return res
_fields={
'staff_id': fields.Many2One("clinic.staff",'Staff'),
'name': fields.Char("Name", function="_get_store",function_multi=True,store=True),
'date_from': fields.Date("From"),
'date_to': fields.Date("To"),
'hdcase_total': fields.Char("Total", function="_get_all",function_multi=True),
'lines': fields.One2Many("clinic.report.staff.line","report_staff_id","Lines"),
}
def create(self,vals,**kw):
id=super().create(vals,**kw)
self.function_store([id])
return id
def write(self,ids,vals,**kw):
super().write(ids,vals,**kw)
self.function_store(ids)
ReportStaff.register()

View File

@ -0,0 +1,11 @@
from netforce.model import Model, fields
class ReportStaffLine(Model):
_name='clinic.report.staff.line'
_string="Report Staff Line"
_fields={
'report_staff_id': fields.Many2One("clinic.report.staff","Report Staff", required=True, on_delete="cascade"),
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case"),
}
ReportStaffLine.register()

View File

@ -12,6 +12,7 @@ class ClinicSetting(Model):
'file': fields.File("File"),
'levels': fields.One2Many("clinic.setting.level","setting_id","Levels"),
'products': fields.One2Many("clinic.setting.product","setting_id","Products"),
'account_products': fields.One2Many("clinic.setting.account.product","setting_id","Account Products"),
'invoice_policies': fields.One2Many("clinic.setting.policy","setting_id","Invoice Policies"),
'cost_per_case': fields.Float("Cost Per Case"),
'company_id': fields.Many2One("company", 'Company'),
@ -101,23 +102,13 @@ class ClinicSetting(Model):
return True
def run_script(self,ids,context={}):
for hdcase in get_model("clinic.hd.case").search_browse([]):
mt=hdcase.membrane_type
for dlz in hdcase.dialyzers:
dlz2=dlz.dialyzer_id
dlz2.write({
'membrane_type': mt,
})
for pt in get_model("clinic.patient").search_browse([]):
count=0
for hdcase in pt.hd_cases:
if count > 1:
break
if hdcase.vascular_acc:
pt.write({
'vascular_acc': hdcase.vascular_acc.id,
})
count+=1
count=1
for hd_case in get_model("clinic.hd.case").search_browse([]):
hd_case.write({
'patient_type_id': hd_case.patient_id.type_id.id,
})
print(count, " update ", hd_case.patient_id.type_id.id)
count+=1
print("Done! ")
def reset_last_import(self,ids,context={}):

View File

@ -0,0 +1,21 @@
from netforce.model import Model, fields
from netforce.access import get_active_company
class SettingAccountProduct(Model):
_name="clinic.setting.account.product"
_string="Setting Account Product"
_multi_company=True
_fields={
"setting_id": fields.Many2One("clinic.setting","Setting",required=True,on_delete="cascade"),
"product_id": fields.Many2One("product","Product"),
"ar_credit_id": fields.Many2One("account.account","AR Credit",multi_company=True),
"ar_debit_id": fields.Many2One("account.account","AR Debit",multi_company=True),
'company_id': fields.Many2One("company","Company"),
}
_defaults={
"company_id": lambda *a: get_active_company(),
}
SettingAccountProduct.register()

View File

@ -161,6 +161,7 @@ class Visit(Model):
hd_case_obj=get_model("clinic.hd.case")
vals={
'patient_id': obj.patient_id.id,
'patient_type_id': obj.patient_id.type_id.id,
'vascular_acc': obj.patient_id.vascular_acc.id,
'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id,

View File

@ -1,5 +1,7 @@
todo:
- accounting
- labor cost
- report ***
- invoice line -> account -> credit
- debit from hd case setting
- if user select product by them self