conv_bal
watcha.h@almacom.co.th 2015-04-03 17:07:03 +07:00
parent 75b47a9eb8
commit c568fd9633
8 changed files with 163 additions and 3 deletions

View File

@ -0,0 +1,8 @@
<action>
<field name="string">Report Labor Cost</field>
<field name="view_cls">report</field>
<field name="model">clinic.report.labor.cost</field>
<field name="report_template">report_labor_cost</field>
<field name="report_template_xls">report_labor_cost</field>
<field name="menu">account_menu</field>
</action>

View File

@ -9,6 +9,7 @@
<header string="REPORTS"/> <header string="REPORTS"/>
<item string="HD Case Expense" action="clinic_report_account_hd_case_summary"/> <item string="HD Case Expense" action="clinic_report_account_hd_case_summary"/>
<item string="RD Shop Expense" action="clinic_report_account_shop"/> <item string="RD Shop Expense" action="clinic_report_account_shop"/>
<!--<item string="Labor Cost" action="clinic_report_labor_cost"/>-->
<item string="Labor Cost Summary" action="clinic_report_labor_cost_summary"/> <item string="Labor Cost Summary" action="clinic_report_labor_cost_summary"/>
<!--<item string="Labor Cost Detail" action="clinic_report_labor_cost_detail"/>--> <!--<item string="Labor Cost Detail" action="clinic_report_labor_cost_detail"/>-->
<!--<item string="Labor Cost Sub Detail" action="clinic_report_labor_cost_sub_detail"/>--> <!--<item string="Labor Cost Sub Detail" action="clinic_report_labor_cost_sub_detail"/>-->

View File

@ -0,0 +1,7 @@
<form model="clinic.report.labor.cost">
<field name="date" mode="month" onchange="onchange_date" span="2"/>
<field name="date_from" required="1" span="2"/>
<field name="date_to" required="1" span="2"/>
<field name="branch_id" onchange="onchange_branch" span="2"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
</form>

View File

@ -80,6 +80,7 @@ from . import report_staff_fee
from . import report_staff_fee_detail from . import report_staff_fee_detail
from . import report_staff_fee_sum from . import report_staff_fee_sum
from . import report_payment_matching from . import report_payment_matching
from . import report_labor_cost
from . import report_labor_cost_summary from . import report_labor_cost_summary
from . import report_labor_cost_detail from . import report_labor_cost_detail
from . import report_labor_cost_sub_detail from . import report_labor_cost_sub_detail

View File

@ -100,7 +100,11 @@ class MatchingHDCase(Model):
#20: ' U '} #20: ' U '}
patients={} patients={}
for pt in get_model("clinic.patient").search_read([],['name','hn_no','type_id']): dom=[
['dispose','=',False],
['walkin','=','no'],
]
for pt in get_model("clinic.patient").search_read(dom,['name','hn_no','type_id']):
hn=pt['hn_no'] hn=pt['hn_no']
patients[hn]={ patients[hn]={
'id': pt['id'], 'id': pt['id'],
@ -121,7 +125,8 @@ class MatchingHDCase(Model):
hdcases2={} hdcases2={}
for hdcase in get_model("clinic.hd.case").search_browse(dom): for hdcase in get_model("clinic.hd.case").search_browse(dom):
date=hdcase.date date=hdcase.date
hn=hdcase.patient_id.hn_no or 0 hn=hdcase.patient_id.hn_no or ""
hn=hn[0:7] #XXX K.Ekk explain on 03/04/2015 : 0-7 is main of hn
fee_amt=0 fee_amt=0
hct=hdcase.hct or "0" hct=hdcase.hct or "0"
hct=round(float(hct),2) hct=round(float(hct),2)

View File

@ -171,6 +171,7 @@ class MatchingPayment(Model):
for invoice in invoices: for invoice in invoices:
pname,hn,card_no='', '', '' pname,hn,card_no='', '', ''
pname2=pname pname2=pname
hn=''
if invoice.related_id: if invoice.related_id:
hdcase=invoice.related_id hdcase=invoice.related_id
patient=hdcase.patient_id patient=hdcase.patient_id
@ -181,7 +182,7 @@ class MatchingPayment(Model):
pname=patient_names[pname] pname=patient_names[pname]
pname2='%s %s'%(patient.first_name or "",patient.last_name or "") pname2='%s %s'%(patient.first_name or "",patient.last_name or "")
card_no=patient.card_no or "" card_no=patient.card_no or ""
hn=patient.hn_no hn=patient.hn_no or ""
elif invoice.ref: elif invoice.ref:
pname=invoice.ref or '' pname=invoice.ref or ''
#XXX #XXX
@ -193,6 +194,7 @@ class MatchingPayment(Model):
hn=pt.hn_no or "" hn=pt.hn_no or ""
else: else:
pass pass
hn=hn[0:7] #XXX
fee,epo,srv=0, 0, 0 fee,epo,srv=0, 0, 0
due_amount=0 due_amount=0
for inv_line in invoice.lines: for inv_line in invoice.lines:

View File

@ -0,0 +1,112 @@
import time
from calendar import monthrange
from netforce.model import Model,fields,get_model
from netforce.access import get_active_company
class ReportLaborCost(Model):
_name="clinic.report.labor.cost"
_string="Report Labor Cost"
_transient=True
_fields={
"date": fields.Date("Month"),
"date_from": fields.Date("From", required=True),
"date_to": fields.Date("To", required=True),
"branch_id": fields.Many2One("clinic.branch","Branch"),
"department_id": fields.Many2One("clinic.department","Department"),
}
def _get_date_from(self,context={}):
year,month=time.strftime("%Y-%m").split("-")
return '%s-%s-01'%(year,month)
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)
def default_get(self,field_names=None,context={},**kw):
defaults=context.get("defaults",{})
date_from=defaults.get("date_from", self._get_date_from())
date_to=defaults.get("date_to", self._get_date_to())
print('defaults ', defaults)
res={
'date': time.strftime("%Y-%m-%d"),
'date_from': date_from,
'date_to': date_to,
}
return res
def get_report_data(self,ids,context={}):
company_id=get_active_company()
company=get_model("company").browse(company_id)
defaults=self.default_get(context=context)
date_from=defaults['date_from']
date_to=defaults['date_to']
branch_id=None
department_id=None
dom=[]
if ids:
obj=self.browse(ids)[0]
date_from=obj.date_from
date_to=obj.date_to
branch_id=obj.branch_id.id
department_id=obj.department_id.id
dom.append(['date','>=',date_from])
dom.append(['date','<=',date_to])
if branch_id:
dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id])
if department_id:
dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id])
print('dom ', dom)
lines=[]
citems={}
for line in get_model("clinic.labor.cost.line").search_browse(dom):
#print('xx')
lcost=line.labor_cost_id
citem=lcost.cycle_item_id
dpt=citem.department_id
qty=line.qty or 0 #XXX
print(citem.id)
import pdb; pdb.set_trace()
if not citem.id not in list(citems.keys()):
print("zzz")
citems[citem.id]=citem
total_hdcase=0
for citem_id, citem in citems.items():
for hdcase in citem.hd_cases:
if hdcase.state in ('completed','waitting_payment','paid'):
total_hdcase+=1
sub_name=''
if department_id:
dpt=get_model("clinic.department").browse(department_id)
sub_name="(%s)" % dpt.name or ""
elif branch_id:
branch=get_model("clinic.branch").browse(branch_id)
sub_name="(%s)" % branch.name or ""
data={
'company_name': '%s %s' % (company.name or "", sub_name),
'date_from': date_from,
'date_to': date_to,
'lines': lines,
'total_hdcase': total_hdcase,
}
return data
def onchange_date(self,context={}):
data=context['data']
date=data['date']
year,month,day=date.split("-")
weekday, total_day=monthrange(int(year), int(month))
data['date_from']="%s-%s-01"%(year,month)
data['date_to']="%s-%s-%s"%(year,month,total_day)
return data
def onchange_branch(self,context={}):
data=context['data']
data['department_id']=None
return data
ReportLaborCost.register()

View File

@ -0,0 +1,24 @@
<center>
<h3>
{{company_name}}
</h3>
<h4>
From {{date_from}} To {{date_to}}
</h4>
</center>
<table class="table table-condensed table-striped">
<thead>
</thead>
<tbody>
{{#each lines }}
<tr>
<td></td>
</tr>
{{/each}}
</tbody>
<tfoot>
</tfoot>
</table>
<p>
{{total_hdcase}}
</p>