report shop
parent
5cb027d9c3
commit
ebb102e602
|
@ -0,0 +1,8 @@
|
||||||
|
<action>
|
||||||
|
<field name="string">Report Shop</field>
|
||||||
|
<field name="view_cls">report</field>
|
||||||
|
<field name="model">clinic.report.shop</field>
|
||||||
|
<field name="report_template">report_shop</field>
|
||||||
|
<field name="report_template_xls">report_shop</field>
|
||||||
|
<field name="menu">account_menu</field>
|
||||||
|
</action>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<action>
|
||||||
|
<field name="string">Report Shop</field>
|
||||||
|
<field name="view_cls">report</field>
|
||||||
|
<field name="model">clinic.report.shop</field>
|
||||||
|
<field name="report_template">report_shop</field>
|
||||||
|
<field name="report_template_xls">report_shop</field>
|
||||||
|
<field name="menu">clinic_menu</field>
|
||||||
|
</action>
|
|
@ -8,6 +8,7 @@
|
||||||
<divider/>
|
<divider/>
|
||||||
<header string="REPORTS"/>
|
<header string="REPORTS"/>
|
||||||
<item string="Report Claim Expense" action="clinic_report_account_hd_case_summary"/>
|
<item string="Report Claim Expense" action="clinic_report_account_hd_case_summary"/>
|
||||||
|
<item string="Report RD Shop" action="clinic_report_account_shop"/>
|
||||||
<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"/>-->
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
</item>
|
</item>
|
||||||
<item string="Reporting" perm="clinic_report">
|
<item string="Reporting" perm="clinic_report">
|
||||||
<item string="Report Claim Expense" action="clinic_report_claim"/>
|
<item string="Report Claim Expense" action="clinic_report_claim"/>
|
||||||
|
<item string="Report RD Shop" action="clinic_report_shop"/>
|
||||||
<item string="Cycle Item Summary" action="clinic_report_cycle_item"/>
|
<item string="Cycle Item Summary" action="clinic_report_cycle_item"/>
|
||||||
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
||||||
<!--<item string="Medical Detail" action="clinic_report_medical_detail"/>-->
|
<!--<item string="Medical Detail" action="clinic_report_medical_detail"/>-->
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<form model="clinic.report.shop">
|
||||||
|
<field name="date" span="2" mode="month" onchange="onchange_date"/>
|
||||||
|
<field name="date_from" onchange="onchange_datefrom" span="2"/>
|
||||||
|
<field name="date_to" span="2"/>
|
||||||
|
<field name="branch_id" onchange="onchange_branch" span="3"/>
|
||||||
|
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
|
||||||
|
<field name="product_id" span="2"/>
|
||||||
|
</form>
|
|
@ -124,3 +124,4 @@ from . import name_title
|
||||||
from . import compute_labor_cost
|
from . import compute_labor_cost
|
||||||
from . import login
|
from . import login
|
||||||
from . import sequence
|
from . import sequence
|
||||||
|
from . import report_shop
|
||||||
|
|
|
@ -0,0 +1,147 @@
|
||||||
|
import time
|
||||||
|
from calendar import monthrange
|
||||||
|
|
||||||
|
from netforce.model import Model, fields, get_model
|
||||||
|
from netforce.access import get_active_company
|
||||||
|
|
||||||
|
class ReportShop(Model):
|
||||||
|
_name="clinic.report.shop"
|
||||||
|
_string="Report Shop"
|
||||||
|
_transient=True
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
"date": fields.Date("Month", required=True),
|
||||||
|
"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","Departments"),
|
||||||
|
'product_id': fields.Many2One("product","Product"),
|
||||||
|
}
|
||||||
|
|
||||||
|
def default_get(self,field_names=None,context={},**kw):
|
||||||
|
defaults=context.get("defaults",{})
|
||||||
|
date=defaults.get('date',time.strftime("%Y-%m-%d"))
|
||||||
|
year,month=time.strftime("%Y-%m").split("-")
|
||||||
|
weekday, total_day=monthrange(int(year), int(month))
|
||||||
|
date_from=defaults.get('date_from','%s-%s-01'%(year,month))
|
||||||
|
date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day))
|
||||||
|
date_from=defaults.get('date',date)
|
||||||
|
date_to=defaults.get('date',date)
|
||||||
|
product_id=defaults.get('product_id')
|
||||||
|
|
||||||
|
branch_id=defaults.get('branch_id',None)
|
||||||
|
print('defaults ', defaults)
|
||||||
|
if branch_id:
|
||||||
|
branch_id=int(branch_id)
|
||||||
|
department_id=defaults.get('department_id',None)
|
||||||
|
if department_id:
|
||||||
|
department_id=int(department_id)
|
||||||
|
select_dpt=get_model('select.company').get_select()
|
||||||
|
print('select_dpt ', select_dpt)
|
||||||
|
if select_dpt:
|
||||||
|
if not branch_id:
|
||||||
|
branch_id=select_dpt['branch_id']
|
||||||
|
if not department_id:
|
||||||
|
if select_dpt.get('department_ids'):
|
||||||
|
department_id=select_dpt['department_ids'][0]
|
||||||
|
else:
|
||||||
|
department_id=select_dpt['department_id']
|
||||||
|
res={
|
||||||
|
'date': date,
|
||||||
|
'date_from': date_from,
|
||||||
|
'date_to': date_to,
|
||||||
|
'branch_id': branch_id,
|
||||||
|
'department_id': department_id,
|
||||||
|
'product_id': product_id,
|
||||||
|
}
|
||||||
|
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.get("date_from")
|
||||||
|
date_to=defaults.get("date_to")
|
||||||
|
date=defaults.get("date")
|
||||||
|
branch_id=defaults.get("branch_id")
|
||||||
|
department_id=defaults.get("department_id")
|
||||||
|
product_id=defaults.get('product_id')
|
||||||
|
if ids:
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
branch_id=obj.branch_id.id
|
||||||
|
department_id=obj.department_id.id
|
||||||
|
date=obj.date
|
||||||
|
date_from=obj.date_from
|
||||||
|
date_to=obj.date_to
|
||||||
|
product_id=obj.product_id.id
|
||||||
|
ctx={
|
||||||
|
'date_from': date_from,
|
||||||
|
'date_to': date_to,
|
||||||
|
'branch_id': branch_id,
|
||||||
|
'department_id': department_id,
|
||||||
|
'product_id': product_id,
|
||||||
|
}
|
||||||
|
lines=get_model('clinic.shop').get_shop_data(context=ctx)['records']
|
||||||
|
company_name=company.name or ""
|
||||||
|
if department_id:
|
||||||
|
company_name+=' (%s)'%get_model('clinic.department').browse(department_id).name or ""
|
||||||
|
elif branch_id:
|
||||||
|
company_name+=' (%s)'%get_model('clinic.branch').browse(branch_id).name or ""
|
||||||
|
total_fee=0
|
||||||
|
total_srv=0
|
||||||
|
total_epo=0
|
||||||
|
total_lab=0
|
||||||
|
total_dlz=0
|
||||||
|
total_misc=0
|
||||||
|
total_mdc=0
|
||||||
|
slines=[]
|
||||||
|
no=1
|
||||||
|
for line in sorted(lines, key=lambda x: (x['date'])):
|
||||||
|
total_fee+=line.get('fee',0)
|
||||||
|
total_srv+=line.get('srv',0)
|
||||||
|
total_epo+=line.get('epo',0)
|
||||||
|
total_mdc+=line.get('mdc',0)
|
||||||
|
total_lab+=line.get('lab',0)
|
||||||
|
total_misc+=line.get('misc',0)
|
||||||
|
total_dlz+=line.get('dlz_price',0)
|
||||||
|
line['no']=no
|
||||||
|
slines.append(line)
|
||||||
|
no+=1
|
||||||
|
data={
|
||||||
|
'company_name': company_name,
|
||||||
|
'branch_id': branch_id,
|
||||||
|
'department_id': department_id,
|
||||||
|
'date': date,
|
||||||
|
'date_from': date_from,
|
||||||
|
'date_to': date_to,
|
||||||
|
'lines': slines,
|
||||||
|
'total_fee': total_fee,
|
||||||
|
'total_srv': total_srv,
|
||||||
|
'total_epo': total_epo,
|
||||||
|
'total_mdc': total_mdc,
|
||||||
|
'total_lab': total_lab,
|
||||||
|
'total_misc': total_misc,
|
||||||
|
'total_dlz': total_dlz,
|
||||||
|
}
|
||||||
|
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
|
||||||
|
|
||||||
|
def onchange_datefrom(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
data['date_to']=data['date_from']
|
||||||
|
return data
|
||||||
|
|
||||||
|
ReportShop.register()
|
|
@ -816,6 +816,11 @@ class Shop(Model):
|
||||||
['date','<=',context['date_to']],
|
['date','<=',context['date_to']],
|
||||||
['state','not in',['draft','cancelled']],
|
['state','not in',['draft','cancelled']],
|
||||||
]
|
]
|
||||||
|
product_id=context.get('product_id')
|
||||||
|
if product_id:
|
||||||
|
dom.append([
|
||||||
|
'product_id','=',product_id,
|
||||||
|
])
|
||||||
branch_id=context.get('branch_id')
|
branch_id=context.get('branch_id')
|
||||||
if branch_id:
|
if branch_id:
|
||||||
dom.append([
|
dom.append([
|
||||||
|
@ -826,7 +831,6 @@ class Shop(Model):
|
||||||
dom.append([
|
dom.append([
|
||||||
'department_id','=',department_id,
|
'department_id','=',department_id,
|
||||||
])
|
])
|
||||||
print('#shop.dom' , dom)
|
|
||||||
for shop in get_model("clinic.shop").search_browse(dom):
|
for shop in get_model("clinic.shop").search_browse(dom):
|
||||||
patient=shop.patient_id
|
patient=shop.patient_id
|
||||||
pm_id=None
|
pm_id=None
|
||||||
|
@ -854,7 +858,7 @@ class Shop(Model):
|
||||||
lab=0
|
lab=0
|
||||||
misc=0
|
misc=0
|
||||||
fee=0
|
fee=0
|
||||||
dlz_price=0
|
dlz=0
|
||||||
mdc_names=[]
|
mdc_names=[]
|
||||||
if categ.parent_id:
|
if categ.parent_id:
|
||||||
if categ.parent_id.code=='MDC':
|
if categ.parent_id.code=='MDC':
|
||||||
|
@ -867,7 +871,7 @@ class Shop(Model):
|
||||||
misc+=amount
|
misc+=amount
|
||||||
continue
|
continue
|
||||||
if categ.code=='DLZ':
|
if categ.code=='DLZ':
|
||||||
dlz_price+=amount
|
dlz+=amount
|
||||||
elif categ.code=='FEE':
|
elif categ.code=='FEE':
|
||||||
fee+=amount
|
fee+=amount
|
||||||
elif categ.code=='LAB':
|
elif categ.code=='LAB':
|
||||||
|
@ -877,36 +881,30 @@ class Shop(Model):
|
||||||
vals={
|
vals={
|
||||||
'is_shop': True,
|
'is_shop': True,
|
||||||
'hdcase_id': None,
|
'hdcase_id': None,
|
||||||
'number': None, #XXX
|
|
||||||
'date': shop.date,
|
'date': shop.date,
|
||||||
'hct': 0,
|
'pay_type': shop.ptype,
|
||||||
'epo_name': "",
|
'epo_name': "",
|
||||||
'ptype': "Shop", #XXX
|
|
||||||
'ptype_color': "warning",
|
'ptype_color': "warning",
|
||||||
'dname': "",
|
'dname': "",
|
||||||
'cycle': "",
|
|
||||||
'cid': 0, #XXX
|
|
||||||
'pname': patient.name or "",
|
'pname': patient.name or "",
|
||||||
'hn': patient.hn or "",
|
'hn': patient.hn or "",
|
||||||
'idcard': patient.card_no or "",
|
'idcard': patient.card_no or "",
|
||||||
'cseq': 0,
|
|
||||||
'cycle_item_id': "",
|
|
||||||
'pm_id': pm_id,
|
'pm_id': pm_id,
|
||||||
'pm_number': pm_number,
|
'pm_number': pm_number,
|
||||||
'inv_number': inv_number,
|
'inv_number': inv_number,
|
||||||
'inv_id': inv_number,
|
'inv_id': inv_number,
|
||||||
'inv_ref': inv_ref,
|
'inv_ref': inv_ref,
|
||||||
|
'inv_id': inv_id,
|
||||||
'fee': fee,
|
'fee': fee,
|
||||||
'mdc': mdc,
|
'mdc': mdc,
|
||||||
'mdc_name': ','.join([n for n in mdc_names]),
|
'mdc_name': ','.join([n for n in mdc_names]),
|
||||||
'dlz_name': "", #XXX
|
'dlz_name': "", #XXX
|
||||||
'dlz_id': "",
|
'dlz_id': "",
|
||||||
'dlz_price': dlz_price,
|
'dlz': dlz,
|
||||||
'lab': lab,
|
'lab': lab,
|
||||||
'misc': misc,
|
'misc': misc,
|
||||||
'pick_ref': pick_number,
|
'pick_ref': pick_number,
|
||||||
'pick_id': pick_id,
|
'pick_id': pick_id,
|
||||||
'reimbursable': 'no',
|
|
||||||
}
|
}
|
||||||
records.append(vals)
|
records.append(vals)
|
||||||
data={
|
data={
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,75 @@
|
||||||
|
<center>
|
||||||
|
<h3>
|
||||||
|
{{company_name}}<br/>
|
||||||
|
</h3>
|
||||||
|
<h4>
|
||||||
|
From {{date_from}} To {{date_to}}
|
||||||
|
</h4>
|
||||||
|
</center>
|
||||||
|
<table class="table">
|
||||||
|
<thead class="scroll-header">
|
||||||
|
<tr>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Receipt#</th>
|
||||||
|
<th>Invoice#</th>
|
||||||
|
<th>ชื่อยา</th>
|
||||||
|
<th>ค่าฟอก</th>
|
||||||
|
<th>ค่ายา</th>
|
||||||
|
<th>Lab</th>
|
||||||
|
<th>Misc.</th>
|
||||||
|
<th>Dlz</th>
|
||||||
|
<th>Ref.Inv#</th>
|
||||||
|
<th>Picking#</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#each lines}}
|
||||||
|
<tr>
|
||||||
|
<td style="width:10%">{{date}}</td>
|
||||||
|
<td style="width:20%">{{pname}}</td>
|
||||||
|
<td>{{pm_number}}</td>
|
||||||
|
{{#ifeq ptype "credit"}}
|
||||||
|
<td>
|
||||||
|
{{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}}
|
||||||
|
</td>
|
||||||
|
{{else}}
|
||||||
|
<td>
|
||||||
|
{{view "link" string=pm_number action="payment" action_options="mode=form" active_id=pm_id}}
|
||||||
|
</td>
|
||||||
|
{{/if}}
|
||||||
|
<td>{{mdc_name}}</td>
|
||||||
|
<td>{{currency fee zero=""}}</td>
|
||||||
|
<td>{{currency mdc zero=""}}</td>
|
||||||
|
<td>{{currency lab zero=""}}</td>
|
||||||
|
<td>{{currency misc zero=""}}</td>
|
||||||
|
<td>{{currency dlz zero=""}}</td>
|
||||||
|
<td>
|
||||||
|
{{view "link" string=inv_ref action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{#if pick_id}}
|
||||||
|
{{view "link" string=pick_ref action="pick_out" action_options="mode=form" active_id=pick_id}}
|
||||||
|
{{else}}
|
||||||
|
-
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th>{{currency total_fee zero=""}}</th>
|
||||||
|
<th>{{currency total_mdc zero=""}}</th>
|
||||||
|
<th>{{currency total_lab zero=""}}</th>
|
||||||
|
<th>{{currency total_misc zero=""}}</th>
|
||||||
|
<th>{{currency total_dlz zero=""}}</th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
|
Loading…
Reference in New Issue