From 26a874b8bc714278aacb40d20439fdffc70f35a4 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Tue, 9 Dec 2014 09:40:53 +0700 Subject: [PATCH] matching payment! --- .../clinic_report_payment_matching.xml | 8 ++ .../layouts/clinic_menu_inherit.xml | 2 +- .../clinic_report_payment_matching.xml | 5 ++ netforce_clinic/models/__init__.py | 1 + .../models/report_payment_matching.py | 85 ++++++++++++++++++ .../reports/report_payment_matching.xlsx | Bin 0 -> 4994 bytes .../templates/report_payment_matching.hbs | 29 ++++++ 7 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 netforce_clinic/actions/clinic_report_payment_matching.xml create mode 100644 netforce_clinic/layouts/clinic_report_payment_matching.xml create mode 100644 netforce_clinic/models/report_payment_matching.py create mode 100644 netforce_clinic/reports/report_payment_matching.xlsx create mode 100644 netforce_clinic/templates/report_payment_matching.hbs diff --git a/netforce_clinic/actions/clinic_report_payment_matching.xml b/netforce_clinic/actions/clinic_report_payment_matching.xml new file mode 100644 index 0000000..7eacbf6 --- /dev/null +++ b/netforce_clinic/actions/clinic_report_payment_matching.xml @@ -0,0 +1,8 @@ + + Payment Matching + report + clinic.report.payment.matching + report_payment_matching + report_payment_matching + account_menu + diff --git a/netforce_clinic/layouts/clinic_menu_inherit.xml b/netforce_clinic/layouts/clinic_menu_inherit.xml index 9137553..bb71e57 100644 --- a/netforce_clinic/layouts/clinic_menu_inherit.xml +++ b/netforce_clinic/layouts/clinic_menu_inherit.xml @@ -7,7 +7,7 @@
- + diff --git a/netforce_clinic/layouts/clinic_report_payment_matching.xml b/netforce_clinic/layouts/clinic_report_payment_matching.xml new file mode 100644 index 0000000..0e34173 --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_payment_matching.xml @@ -0,0 +1,5 @@ +
+ + + + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index fa3466a..e808f08 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -60,6 +60,7 @@ from . import report_recent_patient from . import report_discontinue_patient from . import report_staff_fee_sum from . import report_staff_fee_detail +from . import report_payment_matching from . import branch from . import period from . import period_line diff --git a/netforce_clinic/models/report_payment_matching.py b/netforce_clinic/models/report_payment_matching.py new file mode 100644 index 0000000..f976022 --- /dev/null +++ b/netforce_clinic/models/report_payment_matching.py @@ -0,0 +1,85 @@ +import time +from calendar import monthrange + +from netforce.model import Model,fields,get_model +from netforce.access import get_active_company +from . import utils + +class ReportPaymentMatching(Model): + _name="clinic.report.payment.matching" + _string="Report Payment Mathching" + _transient=True + + _fields={ + "date": fields.Date("Month", required=True), + "date_from": fields.Date("From", required=True), + "date_to": fields.Date("To", required=True), + } + + 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) + + _defaults={ + 'date': lambda *a: time.strftime("%Y-%m-%d"), + 'date_from': _get_date_from, + 'date_to': _get_date_to, + } + + def get_report_data(self,ids,context={}): + year, month=time.strftime("%Y-%m").split("-") + weekday, total_day=monthrange(int(year), int(month)) + time_start='%s-%s-01'%(year,str(month).zfill(2)) + time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day) + + defaults=context.get('defaults') + if defaults: + year,month,total_day=defaults['date'].split("-") + weekday, total_day=monthrange(int(year), int(month)) + time_start='%s-%s-01'%(year,str(month).zfill(2)) + time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day) + + if ids: + obj=self.browse(ids)[0] + month=obj.date_from.split("-")[1] + time_start=obj.date_from + time_stop=obj.date_to + + dom=[] + dom.append(['time_start','>=','%s 00:00:00'%time_start]) + dom.append(['time_stop','<=','%s 23:59:59'%time_stop]) + + lines=[] + + company_id=get_active_company() + company=get_model('company').browse(company_id) + month_str=utils.MONTHS['th_TH'][int(month)] + + lines=sorted(lines, key=lambda x: x['prod_name']) + year=int(year)+543 + + data={ + 'company_name': company.name or "", + 'parent_company_name': company.parent_id.name or "", + 'lines': lines, + 'month': month_str, + 'year': year, + } + + 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 + +ReportPaymentMatching.register() diff --git a/netforce_clinic/reports/report_payment_matching.xlsx b/netforce_clinic/reports/report_payment_matching.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..68697ad559ae868463acf7a6694457ed0d010464 GIT binary patch literal 4994 zcmaJ_2UL?=v!zOtB2B7DRRjs0fFKu;k|V>VssH$|L6o?uX?6ib~VkBLr*pQAEx#nTg#-0vflUi4IzgV=aa>Q z0(J&uRMMyE9rmI#)T7nlB@m&QxI-4-+$@^?RrY46(E#sTLogq$?VFNOjLYujL>OT; zyXb_OZo9FC+`Lsj$IA%2X*=IgS943^6T9Vak;UI;9A|#U8b<7grc@TMszrD$S`ewp z4$m9qBwXLWss@l~x}ZIH>#o6bHmyb%fY*Vq7Wvh2)2g{h_h&EkYhqGc@5{f8Ks-}q zSPCsaM#{b*SBpPxO4R(?=Q!3je8o|bK<73YxkE{C!yIngH;4#u-~SC5Hry|~T>yV$ z;{``RZQyXIh_|cD-#9(igm#FY562!csqJ@y$ZTVP%`r+9N8bs%bmxaK(uw1BCjlbt zrj+(;LrFvLcUm;|RwQFrA~7oG&z0nmguU+cBySEn+F1X@YB-QHGv~-3U&%#Z+QcyN z@FEBRso4RVh}g6z+%V7U1#1<*?|l`rt_$ef290D84lvzCn-bT;gmfB_?I)GC@2P1l zbA7W!d#EV}5SJcH4C}?)%n1R+$#z{2J}Z1yIlZ~i|b!}2#WcubIv_Vyk~z^{iG9-L0&DcBT{ z&VROoZg;5Ae7X$k+}LAZb3H*oDY3q-Wq7=YhbQV9=!0fUKmq&H`?}Vm-Y|O6D(A#Y~$ex6)%W65Mgc>?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|?X=SeYT4d%zq|@~>?wW2l3oMV%T&1vRlaM1zSi$q!HnWlV)#)Opp1!T`U}r4P zi`4E#?t;(63qx!@Unm!vSDw>vvu5*~`E8V_36~i$xQhQtSANo3b7?9f-y{aiZJ$2;n5fQek-`nURqW#oGU!IqTSW zyZ)O`xv4G0c*M7!7ler6&^E$pN1fY*M2rNdMhJ~as(FX7_+*H--ZC}&j|UI3rk-nm~< z{+}HFJ;K?Nk5_A_7ES)2|M8D@``!60jp9|osaaC~z5IVP!tbtUi3ZQJr>236^gHYR z?tM0y@MLsq)--3l|DmSe-Ot_(e8!zxBMyWAl7Bk4NpW}*5K!P=in#N+{%g_y0WZ&I Ai2wiq literal 0 HcmV?d00001 diff --git a/netforce_clinic/templates/report_payment_matching.hbs b/netforce_clinic/templates/report_payment_matching.hbs new file mode 100644 index 0000000..4930df6 --- /dev/null +++ b/netforce_clinic/templates/report_payment_matching.hbs @@ -0,0 +1,29 @@ +
+

Payment Matching

+

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

+

+ {{#if is_duration}} + ระหว่างวันที่ {{from}} ถึง {{to}} + {{else}} + ประจำเดือน {{month}} {{year}} + {{/if}} +

+
+{{#if lines}} + + + + + {{#each lines}} + + + {{/each}} + + + +
+{{else}} + No items to display. +{{/if}}