report receipt summary
parent
1bdffd8194
commit
b80fd669e4
|
@ -0,0 +1,9 @@
|
|||
<action>
|
||||
<field name="string">Receipt Summary</field>
|
||||
<field name="view_cls">report</field>
|
||||
<field name="model">clinic.report.receipt.summary</field>
|
||||
<field name="report_template">report_receipt_summary</field>
|
||||
<field name="report_template_xls">report_receipt_summary</field>
|
||||
<field name="export_pdf">1</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
|
@ -47,6 +47,8 @@
|
|||
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
||||
<item string="HD Case Expense" action="clinic_report_claim"/>
|
||||
<item string="RD Shop Expense" action="clinic_report_shop"/>
|
||||
<divider/>
|
||||
<item string="Receipt Summary" action="clinic_report_receipt_summary"/>
|
||||
</item>
|
||||
<item string="Settings" perm="clinic_settings">
|
||||
<item string="Clinic Settings" action="clinic_setting"/>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<form model="clinic.report.receipt.summary">
|
||||
<field name="date" span="2" mode="month" onchange="onchange_date"/>
|
||||
<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"/>
|
||||
</form>
|
|
@ -146,3 +146,4 @@ from . import document
|
|||
from . import payment_matching
|
||||
from . import create_invoice_payment
|
||||
from . import report_stock_card
|
||||
from . import report_receipt_summary
|
||||
|
|
|
@ -36,14 +36,12 @@ class ReportAccountHDCaseSummary(Model):
|
|||
reimbursable=defaults.get('reimbursable',"yes")
|
||||
|
||||
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']
|
||||
|
|
|
@ -0,0 +1,175 @@
|
|||
import time
|
||||
from calendar import monthrange
|
||||
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company
|
||||
|
||||
class ReportReceiptSummary(Model):
|
||||
_name='clinic.report.receipt.summary'
|
||||
_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"),
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
########### find branch
|
||||
branch_id=defaults.get('branch_id',None)
|
||||
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()
|
||||
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,
|
||||
}
|
||||
return res
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
company_id=get_active_company()
|
||||
company=get_model("company").browse(company_id)
|
||||
|
||||
################ default values ###############
|
||||
defaults=self.default_get(context=context)
|
||||
date=defaults.get('date',time.strftime("%Y-%m-%d"))
|
||||
year=int(date[0:4])
|
||||
crr_month=int(date[5:7])
|
||||
weekday, crr_total_day=monthrange(year, crr_month)
|
||||
date_from=defaults.get('date_from',date)
|
||||
date_to=defaults.get('date_to',date)
|
||||
branch_id=defaults.get("branch_id",None)
|
||||
department_id=defaults.get("department_id",None)
|
||||
|
||||
################# when click run report #############
|
||||
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
|
||||
|
||||
#################### condition to get shop rd ########
|
||||
dom=[
|
||||
['date', '>=', date_from],
|
||||
['date', '<=', date_to],
|
||||
]
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
branch=get_model("clinic.branch").browse(branch_id)
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
department=get_model("clinic.department").browse(department_id)
|
||||
|
||||
lines=[]
|
||||
total_amount=0
|
||||
############### from HD Case ###################
|
||||
for hdcase in get_model('clinic.hd.case').search_browse(dom):
|
||||
patient=hdcase.patient_id
|
||||
line_vals={
|
||||
'patient_name': patient.name,
|
||||
'patient_id': patient.id,
|
||||
'is_rd_shop': False,
|
||||
'id': hdcase.id,
|
||||
}
|
||||
for payment in hdcase.payments:
|
||||
items=[]
|
||||
for line in payment.lines:
|
||||
items.append(line.description)
|
||||
list_item='\n'.join([item for item in items if item])
|
||||
line_vals.update({
|
||||
'payment_id': payment.id,
|
||||
'date': payment.date,
|
||||
'number': payment.number,
|
||||
'ref': payment.ref,
|
||||
'list_item': list_item,
|
||||
'amount_total': payment.amount_total,
|
||||
'date_send': '', # ??
|
||||
})
|
||||
total_amount+=payment.amount_total
|
||||
lines.append(line_vals)
|
||||
|
||||
############### from RD Shop ###################
|
||||
for shop in get_model('clinic.shop').search_browse(dom):
|
||||
patient=shop.patient_id
|
||||
items=[]
|
||||
for line in shop.lines:
|
||||
prod=line.product_id
|
||||
if prod:
|
||||
items.append(prod.name)
|
||||
else:
|
||||
items.append(line.description)
|
||||
list_item='\n'.join([item for item in items if item])
|
||||
line_vals={
|
||||
'is_rd_shop': True,
|
||||
'patient_name': patient.name,
|
||||
'patient_id': patient.id,
|
||||
'date': shop.date,
|
||||
'number': shop.number,
|
||||
'id': shop.id,
|
||||
'ref': shop.ref,
|
||||
'list_item': list_item,
|
||||
'amount_total': shop.sub_total,
|
||||
'date_send': '', # ??
|
||||
}
|
||||
total_amount+=shop.sub_total
|
||||
lines.append(line_vals)
|
||||
|
||||
data={
|
||||
'title': 'Receipt Summary',
|
||||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
'parent_company_name': company.parent_id and company.parent_id.name or "",
|
||||
'company_name': company.name,
|
||||
'branch_name': branch.name,
|
||||
'department_name': department.name,
|
||||
'lines': sorted(lines, key=lambda line: line['date']),
|
||||
'total_amount': total_amount,
|
||||
}
|
||||
return data
|
||||
|
||||
def onchange_branch(self,context={}):
|
||||
data=context['data']
|
||||
data['department_id']=None
|
||||
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_datefrom(self,context={}):
|
||||
data=context['data']
|
||||
data['date_to']=data['date_from']
|
||||
return data
|
||||
|
||||
ReportReceiptSummary.register()
|
Binary file not shown.
|
@ -0,0 +1,60 @@
|
|||
<center>
|
||||
<h2>
|
||||
{{title}}
|
||||
</h2>
|
||||
<h3>
|
||||
{{parent_company_name}} {{company_name}}<br/>
|
||||
</h3>
|
||||
<h4>
|
||||
From {{date_from}} To {{date_to}}
|
||||
</h4>
|
||||
</center>
|
||||
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<th>วันที่ใบเสร็จ</th>
|
||||
<th>ผู้ป่วย</th>
|
||||
<th>เลขที่ใบเสร็จ</th>
|
||||
<th></th>
|
||||
<th>อ้างอิง #</th>
|
||||
<th>รายการ</th>
|
||||
<th style="text-align:right">จำนวนเงิน</th>
|
||||
<th>วันที่นำฝาก</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each lines}}
|
||||
<tr>
|
||||
<td>{{date}}</td>
|
||||
<td>{{patient_name}}</td>
|
||||
<td>
|
||||
{{#if is_rd_shop}}
|
||||
{{view "link" string=number action="clinic_shop" action_options="mode=form" active_id=id}}
|
||||
{{else}}
|
||||
{{view "link" string=number action="clinic_hd_case" action_options="mode=form" active_id=id}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td>
|
||||
{{#if is_rd_shop}}
|
||||
<button class="btn btn-sm btn-default"
|
||||
onclick="location.href='report?name=clinic_receipt_print&convert=pdf&refer_id={{../id}}'">
|
||||
<i class="glyphicon glyphicon-print"></i> Print</button>
|
||||
{{else}}
|
||||
<button class="btn btn-sm btn-default"
|
||||
onclick="location.href='report?payment_id={{../payment_id}}&convert=pdf&refer_id={{../id}}&name=report_clinic_payment_form'">
|
||||
<i class="glyphicon glyphicon-print"></i> Print</button>
|
||||
{{/if}}
|
||||
</td>
|
||||
<td>{{ref}}</td>
|
||||
<td>{{list_item}}</td>
|
||||
<td style="text-align:right">{{currency amount_total}}</td>
|
||||
<td>{{date_send}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<th colspan="5"></th>
|
||||
<th>ทั้งหมด</th>
|
||||
<th style="text-align:right">{{currency total_amount}}</th>
|
||||
<th></th>
|
||||
</tfoot>
|
||||
</table>
|
Loading…
Reference in New Issue