From b80fd669e4ee166ad04ec0069a73727926d48551 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Thu, 18 Aug 2016 13:33:09 +0700 Subject: [PATCH] report receipt summary --- .../actions/clinic_report_receipt_summary.xml | 9 + netforce_clinic/layouts/clinic_menu.xml | 2 + .../layouts/clinic_report_receipt_summary.xml | 7 + netforce_clinic/models/__init__.py | 1 + .../models/report_account_hd_case_summary.py | 2 - .../models/report_receipt_summary.py | 175 ++++++++++++++++++ .../reports/report_receipt_summary.xlsx | Bin 0 -> 5513 bytes .../templates/report_receipt_summary.hbs | 60 ++++++ 8 files changed, 254 insertions(+), 2 deletions(-) create mode 100644 netforce_clinic/actions/clinic_report_receipt_summary.xml create mode 100644 netforce_clinic/layouts/clinic_report_receipt_summary.xml create mode 100644 netforce_clinic/models/report_receipt_summary.py create mode 100644 netforce_clinic/reports/report_receipt_summary.xlsx create mode 100644 netforce_clinic/templates/report_receipt_summary.hbs diff --git a/netforce_clinic/actions/clinic_report_receipt_summary.xml b/netforce_clinic/actions/clinic_report_receipt_summary.xml new file mode 100644 index 0000000..f86b8b0 --- /dev/null +++ b/netforce_clinic/actions/clinic_report_receipt_summary.xml @@ -0,0 +1,9 @@ + + Receipt Summary + report + clinic.report.receipt.summary + report_receipt_summary + report_receipt_summary + 1 + clinic_menu + diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index f2c9765..875bc87 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -47,6 +47,8 @@ + + diff --git a/netforce_clinic/layouts/clinic_report_receipt_summary.xml b/netforce_clinic/layouts/clinic_report_receipt_summary.xml new file mode 100644 index 0000000..75af748 --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_receipt_summary.xml @@ -0,0 +1,7 @@ +
+ + + + + + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 59538bf..49b3d66 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -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 diff --git a/netforce_clinic/models/report_account_hd_case_summary.py b/netforce_clinic/models/report_account_hd_case_summary.py index 58203bd..2878059 100644 --- a/netforce_clinic/models/report_account_hd_case_summary.py +++ b/netforce_clinic/models/report_account_hd_case_summary.py @@ -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'] diff --git a/netforce_clinic/models/report_receipt_summary.py b/netforce_clinic/models/report_receipt_summary.py new file mode 100644 index 0000000..f17198e --- /dev/null +++ b/netforce_clinic/models/report_receipt_summary.py @@ -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() diff --git a/netforce_clinic/reports/report_receipt_summary.xlsx b/netforce_clinic/reports/report_receipt_summary.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..d0f2ef14452f5912efaa3bd02a2dd117304d8df5 GIT binary patch literal 5513 zcmaJ_1yoz<*2UeS=s?k;DFK2MmqKxO3Y6kbaW4*Kkl<1%UIuq}ZSerb8=L~g2~zwI zGyi+#b$uL>}+o5!uj<6vn+m0 z9+`_E{J<{~?Bh}Y=($-1v`%n zRl#pf;bu@XpAdUPW8^!tt+R-tvqh`Lt7z@;^N^Ivq8*uVk98v?nP=mxI=NuLIg1P@ zPb;Cy*mDi7Y)a)8J5G-aA7u=dX@jceh&P#ynl(|W9d5!+;m(<2#G4`Iw=T~bF=S$I zTjQ0shpeVL$C<6f5L6Y=F)WIM8kXV57D7URKmQXj1n^&&Ihv|EJ36^=nm9Q<^|ZIk z1gj_@bCL8O_(u|WLr3&&ikRN#Mid6o zbM-b@ls31n!X95dRG$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DMkLIMv6d!di4)_n3bB?iiUVzu?`OVW3u<%x}$Ep^uuL*IUp5 zU+qWE=A9DEvVEGvMn{8b_-X2j+FX#ch;1X$O-Hy#cRc-O<0vi|h7xWOjJr{{-Qe;SI2&m+XVIr67enVbXB^zK-JB69c44oyHGaH{Q-S0EEgf@A)< z`NH3kvTE}jGrR8AXa=FEGv52_busmpc+PuisHtDuM7pxc`o5Fh&)Y%Sf}CqO|9^x0 zZ-qk)FB}6YM+aAP2UlZFFDG*s!+V0;mUu5z5cD0~kSLT_4@?I~?AD`q<&lgDCx5w!V7-($7PDHQMQEn-`6R7-L#+>8-_?JgNY)urT+9U zL6ni9QQK!TL#r16OM*IUQC~2CJHxt#m=y`Ny4gr z4f~zzIhfKQz|7}%j#Rbe%t!E<_{}grBO}L)qwFHTz$CprNTM z{IBCfE#+QS`e_vKzxq{U`qlg4YJab{{4^2xSoyE_f7F*>-5;)z_xt}(+l3d_->Ct= zMtHbx-LIQJtpiR6;1T{|`TRA`LjrNXoc**pv_Iqg?W*=`l!x>5o^1Ry6`a4$^Iz)m ztLwv#x*xbdEe!q$Kgh%V`B&$Mm2uy6Kdl3vmA`30RRvV|u@De2;g=XZQ=mV+{tsuP BPqF|2 literal 0 HcmV?d00001 diff --git a/netforce_clinic/templates/report_receipt_summary.hbs b/netforce_clinic/templates/report_receipt_summary.hbs new file mode 100644 index 0000000..d6365f3 --- /dev/null +++ b/netforce_clinic/templates/report_receipt_summary.hbs @@ -0,0 +1,60 @@ +
+

+ {{title}} +

+

+ {{parent_company_name}} {{company_name}}
+

+

+ From {{date_from}} To {{date_to}} +

+
+ + + + + + + + + + + + + + {{#each lines}} + + + + + + + + + + + {{/each}} + + + + + + + +
วันที่ใบเสร็จผู้ป่วยเลขที่ใบเสร็จอ้างอิง #รายการจำนวนเงินวันที่นำฝาก
{{date}}{{patient_name}} + {{#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}} + + {{#if is_rd_shop}} + + {{else}} + + {{/if}} + {{ref}}{{list_item}}{{currency amount_total}}{{date_send}}
ทั้งหมด{{currency total_amount}}