matching payment!

conv_bal
watcha.h 2014-12-09 09:40:53 +07:00
parent bc52ec93fe
commit 26a874b8bc
7 changed files with 129 additions and 1 deletions

View File

@ -0,0 +1,8 @@
<action>
<field name="string">Payment Matching</field>
<field name="view_cls">report</field>
<field name="model">clinic.report.payment.matching</field>
<field name="report_template">report_payment_matching</field>
<field name="report_template_xls">report_payment_matching</field>
<field name="menu">account_menu</field>
</action>

View File

@ -7,7 +7,7 @@
<item string="HD Case Expense" action="clinic_hd_case_expense"/>
<divider/>
<header string="REPORTS"/>
<item string="Payment Matching" action="clinic_payment_matching"/>
<item string="Payment Matching" action="clinic_report_payment_matching"/>
<item string="Staff Fee Summary" action="clinic_report_staff_fee_sum"/>
<item string="Staff Fee Detail" action="clinic_report_staff_fee_detail"/>
</item>

View File

@ -0,0 +1,5 @@
<form model="clinic.report.payment.matching">
<field name="date" span="3" mode="month" onchange="onchange_date"/>
<field name="date_from" span="3"/>
<field name="date_to" span="3"/>
</form>

View File

@ -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

View File

@ -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()

View File

@ -0,0 +1,29 @@
<center>
<h2>Payment Matching</h2>
<h3>
{{parent_company_name}}&nbsp;{{company_name}}<br/>
</h3>
<h4>
{{#if is_duration}}
ระหว่างวันที่ {{from}} ถึง {{to}}
{{else}}
ประจำเดือน {{month}} {{year}}
{{/if}}
</h4>
</center>
{{#if lines}}
<table class="table table-condensed table-striped">
<thead>
</thead>
<tbody>
{{#each lines}}
<tr>
</tr>
{{/each}}
</tbody>
<tfoot>
</tfoot>
</table>
{{else}}
No items to display.
{{/if}}