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">
<field name="patient_type_id"/>
<field name="categ_id"/>
<field name="patient_type_id" required="1"/>
<field name="categ_id" required="1"/>
<field name="product_id" domain='[["categ_id","=",categ_id]]'/>
<field name="ar_credit_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={}):
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
if not currency_id:
raise Exception("Currency not found in account settings")

View File

@ -120,6 +120,7 @@ class PaymentMatching(Model):
department_id=None
inv_state=defaults.get('inv_state')
view_type=defaults.get('view_type')
pcode=''
if ids:
obj=self.browse(ids)[0]
date_from=obj.date_from
@ -128,8 +129,10 @@ class PaymentMatching(Model):
department_id=obj.department_id.id
inv_state=obj.inv_state
view_type=obj.view_type
pcode=obj.pcode
lines=[]
invoices=[]
total_invoice=0
total_match_invoice=0
total_epo=0
total_srv=0
@ -161,7 +164,7 @@ class PaymentMatching(Model):
vals['patient_name']=patient.name
vals['patient_nospace_name']=patient.name_check
vals['patient_cid']=patient.card_no
vals['patient_hn']=patient.hn
vals['patient_hn']=patient.hn_no
else:
vals[field_name]=inv[field_name]
vals[field_name]=inv[field_name]
@ -169,9 +172,11 @@ class PaymentMatching(Model):
return invoices
if view_type=='invoice':
lines=get_invoices()
total_invoice=len(lines)
else:
if obj:
if obj and obj.pcode=='SSO':
invoices=get_invoices()
total_invoice=len(invoices)
rlines=obj.get_line()
no=1
for rline in rlines:
@ -218,18 +223,77 @@ class PaymentMatching(Model):
break
lines.append(line_vals)
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={
'lines': lines,
'date_from': date_from,
'date_to': date_to,
'total_qty': len(lines),
'total_item': len(lines),
'total_fee': total_fee,
'total_epo': total_epo,
'total_srv': total_srv,
'total_invoice': total_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,
'view_type': view_type,
'pcode': pcode,
}
return data

View File

@ -8,8 +8,8 @@ class SettingAccountProduct(Model):
_fields={
"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),
'categ_id': fields.Many2One("product.categ","Category",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),
"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_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;">
<table class="table table-bordered">
<thead>
<th style="text-align:center">Total Item</th>
<th style="text-align:center">Total Invoice</th>
<th style="text-align:center">Match</th>
<th style="text-align:center">Un Match</th>
</thead>
<tbody>
<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_match_invoice}}</td>
<td style="text-align:center">{{currency total_unmatch_invoice}}</td>
</tr>
</tbody>
</table>
</div>
<div class="row">
<table class="table table-hover">
{{#ifeq view_type 'invoice'}}
<thead class="scroll-header">
@ -32,19 +37,20 @@
<tfoot>
</tfoot>
{{else}}
{{#ifeq pcode "SSO"}}
<thead class="scroll-header">
<th>No.</th>
<th>Date</th>
<th>PID</th>
<th>HN</th>
<th>Patient</th>
<th style="text-align:right">Fee</th>
<th>Inv Fee</th>
<th style="text-align:right">EPO</th>
<th>Inv EPO</th>
<th style="text-align:right">Service</th>
<th>Inv Service</th>
<th style="text-align:right">Amount</th>
<th style="text-align:center">No.</th>
<th style="text-align:center">Date</th>
<th style="text-align:center">PID</th>
<th style="text-align:center">HN</th>
<th style="text-align:center">Patient</th>
<th style="text-align:center">Fee</th>
<th style="text-align:center">Inv Fee</th>
<th style="text-align:center">EPO</th>
<th style="text-align:center">Inv EPO</th>
<th style="text-align:center">Service</th>
<th style="text-align:center">Inv Service</th>
<th style="text-align:center">Amount</th>
</thead>
<tbody>
{{#if lines}}
@ -105,5 +111,51 @@
<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}}
</td>
</tr>
{{/each}}
</tbody>
<tfoot>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>{{currency total_fee}}</th>
<th></th>
</tfoot>
{{else}}
TODO
{{/ifeq}}
{{/ifeq}}
{{/ifeq}}
</table>
</div>