fix_acc
watcha.h 2015-08-25 08:36:30 +07:00
parent e69cf8a48f
commit 5f88d19d74
5 changed files with 199 additions and 80 deletions

View File

@ -1,6 +1,6 @@
<form model="clinic.setting.account.product" show_company="1"> <form model="clinic.setting.account.product" show_company="1">
<field name="patient_type_id"/> <field name="patient_type_id" required="1"/>
<field name="categ_id"/> <field name="categ_id" required="1"/>
<field name="product_id" domain='[["categ_id","=",categ_id]]'/> <field name="product_id" domain='[["categ_id","=",categ_id]]'/>
<field name="ar_credit_id" domain='[["type","!=","view"]]'/> <field name="ar_credit_id" domain='[["type","!=","view"]]'/>
<field name="ar_debit_id" domain='[["type","!=","view"]]'/> <field name="ar_debit_id" domain='[["type","!=","view"]]'/>

View File

@ -593,6 +593,9 @@ class HDCase(Model):
def make_invoices(self,ids,context={}): def make_invoices(self,ids,context={}):
setting=get_model("settings").browse(1,context) setting=get_model("settings").browse(1,context)
fin_account_receivable_id=setting.account_receivable_id.id
if not fin_account_receivable_id:
raise Exception("Missing Account Receivable")
currency_id=setting.currency_id.id currency_id=setting.currency_id.id
if not currency_id: if not currency_id:
raise Exception("Currency not found in account settings") raise Exception("Currency not found in account settings")

View File

@ -120,6 +120,7 @@ class PaymentMatching(Model):
department_id=None department_id=None
inv_state=defaults.get('inv_state') inv_state=defaults.get('inv_state')
view_type=defaults.get('view_type') view_type=defaults.get('view_type')
pcode=''
if ids: if ids:
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
date_from=obj.date_from date_from=obj.date_from
@ -128,8 +129,10 @@ class PaymentMatching(Model):
department_id=obj.department_id.id department_id=obj.department_id.id
inv_state=obj.inv_state inv_state=obj.inv_state
view_type=obj.view_type view_type=obj.view_type
pcode=obj.pcode
lines=[] lines=[]
invoices=[] invoices=[]
total_invoice=0
total_match_invoice=0 total_match_invoice=0
total_epo=0 total_epo=0
total_srv=0 total_srv=0
@ -146,7 +149,7 @@ class PaymentMatching(Model):
dom.append(['department_id.branch_id','=',branch_id]) dom.append(['department_id.branch_id','=',branch_id])
elif department_id: elif department_id:
dom.append(['department_id','=',department_id]) dom.append(['department_id','=',department_id])
field_names=['date','number','amount_due','patient_id'] field_names=['date','number','amount_due','patient_id']
for inv in get_model('account.invoice').search_read(dom,field_names): for inv in get_model('account.invoice').search_read(dom,field_names):
vals={ vals={
'id': inv['id'], 'id': inv['id'],
@ -161,7 +164,7 @@ class PaymentMatching(Model):
vals['patient_name']=patient.name vals['patient_name']=patient.name
vals['patient_nospace_name']=patient.name_check vals['patient_nospace_name']=patient.name_check
vals['patient_cid']=patient.card_no vals['patient_cid']=patient.card_no
vals['patient_hn']=patient.hn vals['patient_hn']=patient.hn_no
else: else:
vals[field_name]=inv[field_name] vals[field_name]=inv[field_name]
vals[field_name]=inv[field_name] vals[field_name]=inv[field_name]
@ -169,9 +172,11 @@ class PaymentMatching(Model):
return invoices return invoices
if view_type=='invoice': if view_type=='invoice':
lines=get_invoices() lines=get_invoices()
total_invoice=len(lines)
else: else:
if obj: if obj and obj.pcode=='SSO':
invoices=get_invoices() invoices=get_invoices()
total_invoice=len(invoices)
rlines=obj.get_line() rlines=obj.get_line()
no=1 no=1
for rline in rlines: for rline in rlines:
@ -218,18 +223,77 @@ class PaymentMatching(Model):
break break
lines.append(line_vals) lines.append(line_vals)
no+=1 no+=1
elif obj and obj.pcode=='UC':
invoices=get_invoices()
total_invoice=len(invoices)
rlines=obj.get_line()
no=1
for rline in rlines:
#{'amount': '1500.0000',
#'cstat': None,
#'dttran': '2014-09-27T10:00:00',
#'epostat': 'E',
#'hdflag': 'COU',
#'hdrate': '1500.0000',
#'hn': '98511252',
#'hreg': 'NHSO1',
#'invno': '437941480',
#'paid': '0.0000',
#'paychk': '1',
#'reimbpay': '0.0000',
#'rid': '2190',
#'station': '01'}
date,time=(rline['dttran'] or "").split("T")
fee=0
if rline.get('amount'):
fee=float(rline['amount'])
total_fee+=fee
hn=rline['hn']
hn=hn.replace(" ", "")
pname=''
pname_check=''
pid=''
for pt in get_model("clinic.patient").search_browse([['hn_no','=',hn]]):
pname=pt.name or ""
pname_check=pt.name_check or ""
pid=pt.card_no or ""
vals={
'date':date,
'patient_name': pname,
'pid': pid,
'hn': hn,
'fee': fee,
'srv': 0,
'epo': 0,
'inv_id': None,
'inv_number': '',
'no': no,
}
for inv in invoices:
if inv['patient_id']:
if pid==inv['patient_cid'] or hn==inv['patient_hn'] or pname_check==inv['patient_nospace_name']:
if date==inv['date'] and fee==inv['amount_due']:
vals['inv_id']=inv['id']
vals['inv_number']=inv['number']
total_match_invoice+=1
break
lines.append(vals)
no+=1
data={ data={
'lines': lines, 'lines': lines,
'date_from': date_from, 'date_from': date_from,
'date_to': date_to, 'date_to': date_to,
'total_qty': len(lines), 'total_item': len(lines),
'total_fee': total_fee, 'total_fee': total_fee,
'total_epo': total_epo, 'total_epo': total_epo,
'total_srv': total_srv, 'total_srv': total_srv,
'total_invoice': total_invoice,
'total_match_invoice': total_match_invoice, 'total_match_invoice': total_match_invoice,
'total_invoice': len(invoices), 'total_match_invoice_in_pc': (total_match_invoice/total_invoice)*100,
'total_unmatch_invoice': total_invoice-total_match_invoice,
'total_amount': total_amount, 'total_amount': total_amount,
'view_type': view_type, 'view_type': view_type,
'pcode': pcode,
} }
return data return data

View File

@ -8,8 +8,8 @@ class SettingAccountProduct(Model):
_fields={ _fields={
"setting_id": fields.Many2One("clinic.setting","Setting",required=True,on_delete="cascade"), "setting_id": fields.Many2One("clinic.setting","Setting",required=True,on_delete="cascade"),
"patient_type_id": fields.Many2One("clinic.patient.type","Patient Type",search=True,required=True), "patient_type_id": fields.Many2One("clinic.patient.type","Patient Type",search=True),
'categ_id': fields.Many2One("product.categ","Category",search=True,required=True), 'categ_id': fields.Many2One("product.categ","Category",search=True),
"product_id": fields.Many2One("product","Product",search=True,required=True), "product_id": fields.Many2One("product","Product",search=True,required=True),
"ar_credit_id": fields.Many2One("account.account","Income Credit",multi_company=True,search=True), "ar_credit_id": fields.Many2One("account.account","Income Credit",multi_company=True,search=True),
"ar_debit_id": fields.Many2One("account.account","AR Debit",multi_company=True,search=True), "ar_debit_id": fields.Many2One("account.account","AR Debit",multi_company=True,search=True),

View File

@ -1,17 +1,22 @@
<div class="row" style="margin-top:10px;"> <div class="row" style="margin-top:10px;">
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
<th style="text-align:center">Total Item</th>
<th style="text-align:center">Total Invoice</th> <th style="text-align:center">Total Invoice</th>
<th style="text-align:center">Match</th> <th style="text-align:center">Match</th>
<th style="text-align:center">Un Match</th>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td style="text-align:center">{{currency total_item}}</td>
<td style="text-align:center">{{currency total_invoice}}</td> <td style="text-align:center">{{currency total_invoice}}</td>
<td style="text-align:center">{{currency total_match_invoice}}</td> <td style="text-align:center">{{currency total_match_invoice}}</td>
<td style="text-align:center">{{currency total_unmatch_invoice}}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="row">
<table class="table table-hover"> <table class="table table-hover">
{{#ifeq view_type 'invoice'}} {{#ifeq view_type 'invoice'}}
<thead class="scroll-header"> <thead class="scroll-header">
@ -32,78 +37,125 @@
<tfoot> <tfoot>
</tfoot> </tfoot>
{{else}} {{else}}
<thead class="scroll-header"> {{#ifeq pcode "SSO"}}
<th>No.</th> <thead class="scroll-header">
<th>Date</th> <th style="text-align:center">No.</th>
<th>PID</th> <th style="text-align:center">Date</th>
<th>HN</th> <th style="text-align:center">PID</th>
<th>Patient</th> <th style="text-align:center">HN</th>
<th style="text-align:right">Fee</th> <th style="text-align:center">Patient</th>
<th>Inv Fee</th> <th style="text-align:center">Fee</th>
<th style="text-align:right">EPO</th> <th style="text-align:center">Inv Fee</th>
<th>Inv EPO</th> <th style="text-align:center">EPO</th>
<th style="text-align:right">Service</th> <th style="text-align:center">Inv EPO</th>
<th>Inv Service</th> <th style="text-align:center">Service</th>
<th style="text-align:right">Amount</th> <th style="text-align:center">Inv Service</th>
</thead> <th style="text-align:center">Amount</th>
<tbody> </thead>
{{#if lines}} <tbody>
{{#each lines}} {{#if lines}}
<tr> {{#each lines}}
<td>{{no}}</td> <tr>
<td style="width:8%">{{date}}</td> <td>{{no}}</td>
<td>{{pid}}</td> <td style="width:8%">{{date}}</td>
<td>{{hn}}</td> <td>{{pid}}</td>
<td>{{patient_name}}</td> <td>{{hn}}</td>
<td style="text-align:right">{{currency fee}}</td> <td>{{patient_name}}</td>
<td> <td style="text-align:right">{{currency fee}}</td>
<a style="text-decoration:None" href="ui#form_view_xml=cust_invoice_form&active_id={{inv_fee_id}}&name=cust_invoice&mode=form" target="_blank"> <td>
{{#if inv_fee_id}} <a style="text-decoration:None" href="ui#form_view_xml=cust_invoice_form&active_id={{inv_fee_id}}&name=cust_invoice&mode=form" target="_blank">
<span class="label label-info"> {{#if inv_fee_id}}
{{inv_fee}} <span class="label label-info">
</span> {{inv_fee}}
</span>
{{/if}}
</a>
</td>
<td style="text-align:right">{{currency epo}}</td>
<td>
<a style="text-decoration:None" href="ui#form_view_xml=cust_invoice_form&active_id={{inv_epo_id}}&name=cust_invoice&mode=form" target="_blank">
{{#if inv_epo_id}}
<span class="label label-info">
{{inv_epo}}
</span>
{{/if}}
</a>
</td>
<td style="text-align:right">{{currency srv}}</td>
<td>
<a href="ui#form_view_xml=cust_invoice_form&active_id={{inv_srv_id}}&name=cust_invoice&mode=form" target="_blank">
{{#if inv_srv_id}}
<span class="label label-info">
{{inv_srv}}
</span>
{{/if}}
</a>
</td>
<td style="text-align:right">{{currency amount}}</td>
</tr>
{{/each}}
{{else}}
{{/if}}
</tbody>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th style="text-align:right;">{{currency total_fee}}</th>
<th></th>
<th style="text-align:right;">{{currency total_epo}}</th>
<th></th>
<th style="text-align:right">{{currency total_srv}}</th>
<th></th>
<th style="text-align:right">{{currency total_amount}}</th>
<tfoot>
</tfoot>
{{else}}
{{#ifeq pcode "UC"}}
<thead class="scroll-header">
<th>No.</th>
<th>Date</th>
<th>HN</th>
<th>ID</th>
<th>Patient</th>
<th>Fee</th>
<th>Invoice</th>
</thead>
<tbody>
{{#each lines}}
<tr>
<td>{{no}}</td>
<td>{{date}}</td>
<td>{{hn}}</td>
<td>{{pid}}</td>
<td>{{patient_name}}</td>
<td>{{currency fee}}</td>
<td>
{{#if inv_number}}
<a href="ui#form_view_xml=cust_invoice_form&active_id={{inv_id}}&name=cust_invoice&mode=form" target="_blank">
<span class="label label-info">
{{inv_number}}
</span>
</a>
{{/if}} {{/if}}
</a> </td>
</td> </tr>
<td style="text-align:right">{{currency epo}}</td> {{/each}}
<td> </tbody>
<a style="text-decoration:None" href="ui#form_view_xml=cust_invoice_form&active_id={{inv_epo_id}}&name=cust_invoice&mode=form" target="_blank"> <tfoot>
{{#if inv_epo_id}} <th></th>
<span class="label label-info"> <th></th>
{{inv_epo}} <th></th>
</span> <th></th>
{{/if}} <th></th>
</a> <th>{{currency total_fee}}</th>
</td> <th></th>
<td style="text-align:right">{{currency srv}}</td> </tfoot>
<td>
<a href="ui#form_view_xml=cust_invoice_form&active_id={{inv_srv_id}}&name=cust_invoice&mode=form" target="_blank">
{{#if inv_srv_id}}
<span class="label label-info">
{{inv_srv}}
</span>
{{/if}}
</a>
</td>
<td style="text-align:right">{{currency amount}}</td>
</tr>
{{/each}}
{{else}} {{else}}
{{/if}} TODO
</tbody> {{/ifeq}}
<th></th> {{/ifeq}}
<th></th>
<th></th>
<th></th>
<th></th>
<th style="text-align:right;">{{currency total_fee}}</th>
<th></th>
<th style="text-align:right;">{{currency total_epo}}</th>
<th></th>
<th style="text-align:right">{{currency total_srv}}</th>
<th></th>
<th style="text-align:right">{{currency total_amount}}</th>
<tfoot>
</tfoot>
{{/ifeq}} {{/ifeq}}
</table> </table>
</div>