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 0000000..68697ad Binary files /dev/null and b/netforce_clinic/reports/report_payment_matching.xlsx differ 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}}