invoice payment
parent
bd7a8312f1
commit
c1bb614d1e
|
@ -1,7 +1,7 @@
|
||||||
<action>
|
<action>
|
||||||
<field name="string">Matching Payment Group</field>
|
<field name="string">Invoice Payment</field>
|
||||||
<field name="view_cls">multi_view</field>
|
<field name="view_cls">multi_view</field>
|
||||||
<field name="model">clinic.matching.payment.group</field>
|
<field name="model">clinic.invoice.payment</field>
|
||||||
<field name="menu">account_menu</field>
|
<field name="menu">account_menu</field>
|
||||||
<field name="tabs">[
|
<field name="tabs">[
|
||||||
["All",[]],
|
["All",[]],
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<item string="Ratchawat">
|
<item string="Ratchawat">
|
||||||
<item string="Labor Costs" action="clinic_labor_cost"/>
|
<item string="Labor Costs" action="clinic_labor_cost"/>
|
||||||
<item string="Matching Payments" action="clinic_matching_payment"/>
|
<item string="Matching Payments" action="clinic_matching_payment"/>
|
||||||
<item string="Matching Payments (Group)" action="clinic_matching_payment_group"/>
|
<item string="Invoice Payments" action="clinic_invoice_payment"/>
|
||||||
<item string="Mathing HD Cases" action="clinic_matching_hdcase_acc"/>
|
<item string="Mathing HD Cases" action="clinic_matching_hdcase_acc"/>
|
||||||
<divider/>
|
<divider/>
|
||||||
<header string="REPORTS"/>
|
<header string="REPORTS"/>
|
||||||
|
|
|
@ -1,26 +1,34 @@
|
||||||
<form model="clinic.matching.payment.group" attrs='{"readonly":[["state","=","approved"]]}'>
|
<form model="clinic.invoice.payment" attrs='{"readonly":[["state","=","approved"]]}'>
|
||||||
<head>
|
<head>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<button string="Print" action="print" icon="print"/>
|
<!--<button string="Print" action="print" icon="print"/>-->
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="2">
|
||||||
|
<item string="To Draft" method="to_draft" states="approved"/>
|
||||||
</button>
|
</button>
|
||||||
</head>
|
</head>
|
||||||
<field name="name" span="3"/>
|
<field name="name" span="3"/>
|
||||||
<field name="lines" nolabel="1" count="0">
|
<tabs>
|
||||||
<list>
|
<tab string="General">
|
||||||
<field name="matching_id" onchange="onchange_matching"/>
|
<field name="lines" nolabel="1" count="0">
|
||||||
<field name="epo"/>
|
<list>
|
||||||
<field name="srv"/>
|
<field name="matching_id" domain='[["state","=","approved"]]' onchange="onchange_matching"/>
|
||||||
<field name="fee"/>
|
<field name="epo"/>
|
||||||
<field name="amount"/>
|
<field name="srv"/>
|
||||||
</list>
|
<field name="fee"/>
|
||||||
</field>
|
<field name="amount"/>
|
||||||
<group span="8" columns="1">
|
</list>
|
||||||
</group>
|
</field>
|
||||||
<group span="4" columns="1">
|
<group span="8" columns="1">
|
||||||
<field name="total"/>
|
</group>
|
||||||
</group>
|
<group span="4" columns="1">
|
||||||
|
<field name="total"/>
|
||||||
|
</group>
|
||||||
|
</tab>
|
||||||
|
<tab string="Approval">
|
||||||
|
</tab>
|
||||||
|
</tabs>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Post" method="post" type="success"/>
|
<button string="Submit To Approve" method="submit" states="draft" type="default" icon="arrow-right"/>
|
||||||
|
<button string="Approve" method="approve" states="waiting_approve" type="success"/>
|
||||||
</foot>
|
</foot>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<list model="clinic.matching.payment.group" colors='{"#cfc":[["state","=","approved"]],"#dbdbdb":[["state","=","cancelled"]]}'>
|
<list model="clinic.invoice.payment" colors='{"#cfc":[["state","=","approved"]],"#dbdbdb":[["state","=","cancelled"]]}'>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
<form model="clinic.matching.payment" attrs='{"readonly":[["state","=","approved"]]}'>
|
<form model="clinic.matching.payment" attrs='{"readonly":[["state","=","approved"]]}'>
|
||||||
<head>
|
<head>
|
||||||
|
<field name="state"/>
|
||||||
<button string="Print" action="print" icon="print"/>
|
<button string="Print" action="print" icon="print"/>
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="1">
|
||||||
<item string="Update Identification" method="update_id"/>
|
<item string="Update Identification" method="update_id"/>
|
||||||
<item string="Make Payment" method="do_import" confirm="Are you sure?"/>
|
<item string="To Draft" method="to_draft" states="approved"/>
|
||||||
<item string="Clear Lines" method="clear_line" confirm="Are you sure?"/>
|
<item string="Clear" method="clear_line" confirm="Are you sure?"/>
|
||||||
</button>
|
</button>
|
||||||
</head>
|
</head>
|
||||||
<field name="date" onchange="onchange_date" mode="month" span="3"/>
|
<field name="date" onchange="onchange_date" mode="month" span="3"/>
|
||||||
|
@ -16,28 +17,36 @@
|
||||||
<field name="pcode" span="3"/>
|
<field name="pcode" span="3"/>
|
||||||
<field name="hcode_id" span="3" attrs='{"required":[["pcode","=","SSO"]],"invisible":[["pcode","!=","SSO"]]}'/>
|
<field name="hcode_id" span="3" attrs='{"required":[["pcode","=","SSO"]],"invisible":[["pcode","!=","SSO"]]}'/>
|
||||||
<field name="file" span="3"/>
|
<field name="file" span="3"/>
|
||||||
<field name="lines" nolabel="1" count="0">
|
<tabs>
|
||||||
<list>
|
<tab string="General">
|
||||||
<field name="date"/>
|
<field name="lines" nolabel="1" count="0">
|
||||||
<field name="hn"/>
|
<list>
|
||||||
<field name="pid"/>
|
<field name="date"/>
|
||||||
<field name="name"/>
|
<field name="hn"/>
|
||||||
<field name="epo" sum="1"/>
|
<field name="pid"/>
|
||||||
<field name="srv" sum="1"/>
|
<field name="name"/>
|
||||||
<field name="fee" sum="1"/>
|
<field name="epo" sum="1"/>
|
||||||
<field name="amount" sum="1"/>
|
<field name="srv" sum="1"/>
|
||||||
<field name="invoice_id" onchange="onchange_invoice" domain='[["date","=",date],["state","=","waiting_payment"]]'/>
|
<field name="fee" sum="1"/>
|
||||||
<field name="state"/>
|
<field name="amount" sum="1"/>
|
||||||
</list>
|
<field name="invoice_id" onchange="onchange_invoice" domain='[["date","=",date],["state","=","waiting_payment"]]'/>
|
||||||
</field>
|
<field name="state"/>
|
||||||
<group span="8" columns="1">
|
</list>
|
||||||
</group>
|
</field>
|
||||||
<group span="4" columns="1">
|
<group span="8" columns="1">
|
||||||
<field name="total"/>
|
</group>
|
||||||
<field name="total_match"/>
|
<group span="4" columns="1">
|
||||||
<field name="total_unmatch"/>
|
<field name="total"/>
|
||||||
</group>
|
<field name="total_match"/>
|
||||||
<foot replace="1">
|
<field name="total_unmatch"/>
|
||||||
|
</group>
|
||||||
|
</tab>
|
||||||
|
<tab string="Approval">
|
||||||
|
<field name="user_id" span="3"/>
|
||||||
|
<button string="approve" method="approve" icon="ok" size="small"/>
|
||||||
|
</tab>
|
||||||
|
</tabs>
|
||||||
|
<foot>
|
||||||
<button string="Match" method="do_match" type="success" icon='ok'/>
|
<button string="Match" method="do_match" type="success" icon='ok'/>
|
||||||
</foot>
|
</foot>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
<field name="patient_type_id"/>
|
<field name="patient_type_id"/>
|
||||||
<field name="pcode"/>
|
<field name="pcode"/>
|
||||||
<field name="hcode_id"/>
|
<field name="hcode_id"/>
|
||||||
|
<field name="user_id"/>
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
from . import clinic_setting
|
from . import clinic_setting
|
||||||
from . import import_acc
|
from . import import_acc
|
||||||
|
from . import remove_conv_bal
|
||||||
|
|
|
@ -72,9 +72,9 @@ class Migration(migration.Migration):
|
||||||
#cbv.create_open_entry()
|
#cbv.create_open_entry()
|
||||||
#print("create_sale_invoices...")
|
#print("create_sale_invoices...")
|
||||||
#cbv.create_sale_invoices()
|
#cbv.create_sale_invoices()
|
||||||
print("create_purch_invoices...")
|
#print("create_purch_invoices...")
|
||||||
cbv.create_purch_invoices()
|
#cbv.create_purch_invoices()
|
||||||
print("Done!")
|
#print("Done!")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
Migration.register()
|
Migration.register()
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from netforce.model import get_model
|
||||||
|
from netforce import migration
|
||||||
|
from netforce.database import get_connection
|
||||||
|
#from netforce.access import set_active_user, get_active_user
|
||||||
|
|
||||||
|
class Migration(migration.Migration):
|
||||||
|
_name="clinic.remove.conv.bal"
|
||||||
|
_version="2.11.0"
|
||||||
|
|
||||||
|
def migrate(self):
|
||||||
|
db=get_connection()
|
||||||
|
res=db.query("""
|
||||||
|
select id, amount_due, state,date from account_invoice where extract(year from date)=2014;
|
||||||
|
""")
|
||||||
|
inv_ids=[r['id'] for r in res]
|
||||||
|
for inv in get_model("account.invoice").browse(inv_ids):
|
||||||
|
inv.to_draft()
|
||||||
|
print('%s is deleted'%(inv.number))
|
||||||
|
inv.delete()
|
||||||
|
start=datetime.now()
|
||||||
|
stop=datetime.now()
|
||||||
|
finish=stop-start
|
||||||
|
print(finish.seconds/60)
|
||||||
|
return True
|
||||||
|
|
||||||
|
Migration.register()
|
|
@ -103,8 +103,8 @@ from . import make_apt
|
||||||
from . import make_apt_line
|
from . import make_apt_line
|
||||||
from . import matching_payment
|
from . import matching_payment
|
||||||
from . import matching_payment_line
|
from . import matching_payment_line
|
||||||
from . import matching_payment_group
|
from . import invoice_payment
|
||||||
from . import matching_payment_group_line
|
from . import invoice_payment_line
|
||||||
from . import matching_hdcase
|
from . import matching_hdcase
|
||||||
from . import sale_order
|
from . import sale_order
|
||||||
from . import shop
|
from . import shop
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
|
import time
|
||||||
|
|
||||||
from netforce.model import Model, fields, get_model
|
from netforce.model import Model, fields, get_model
|
||||||
from netforce.utils import get_data_path
|
from netforce.utils import get_data_path
|
||||||
|
from netforce.access import get_active_company
|
||||||
|
|
||||||
class MatchingPaymentGroup(Model):
|
class InvoicePayment(Model):
|
||||||
_name="clinic.matching.payment.group"
|
_name="clinic.invoice.payment"
|
||||||
_string="Matching Payment Group"
|
_string="Invoice Payment"
|
||||||
|
|
||||||
def _get_all(self,ids,context={}):
|
def _get_all(self,ids,context={}):
|
||||||
res={}
|
res={}
|
||||||
|
@ -22,27 +25,68 @@ class MatchingPaymentGroup(Model):
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'name': fields.Char("Name",required=True),
|
'name': fields.Char("Name",required=True),
|
||||||
'lines': fields.One2Many("clinic.matching.payment.group.line","group_matching_id", "Lines"),
|
'lines': fields.One2Many("clinic.invoice.payment.line","invoice_payment_id", "Lines"),
|
||||||
'total': fields.Float("Total",function="_get_all",function_multi=True),
|
'total': fields.Float("Total",function="_get_all",function_multi=True),
|
||||||
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
|
'state': fields.Selection([['draft','Draft'],['waiting_approve','Waiting Approve'],['approved','Approved']],'State'),
|
||||||
|
'date': fields.Date("Date"),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
|
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def post(self,ids,context={}):
|
def approve(self,ids,context={}):
|
||||||
|
count=0
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
print("%s posted"%(obj.id))
|
res=obj.make_payment()
|
||||||
|
count+=1
|
||||||
|
if res<=1:
|
||||||
|
return res
|
||||||
|
|
||||||
|
def make_payment(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
lines=[]
|
||||||
|
for line in obj.lines:
|
||||||
|
matches=line.matching_id
|
||||||
|
for match in matches:
|
||||||
|
invoice=match.invoice_id
|
||||||
|
if invoice:
|
||||||
|
vals={
|
||||||
|
'invoice_id': invoice.id,
|
||||||
|
'amount': invoice.amount_due or 0,
|
||||||
|
}
|
||||||
|
lines.append(('create', vals))
|
||||||
|
if not lines:
|
||||||
|
raise Exception("Nothing to approve")
|
||||||
|
st=get_model("clinic.setting").browse(1)
|
||||||
|
if not st.import_account_id:
|
||||||
|
raise Exception("Import account not found (Ratchawat Setting -> Accounting)")
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
partner=obj.patient_type_id.contact_id
|
||||||
|
company_id=get_active_company()
|
||||||
|
datenow=obj.date or time.strftime("%Y-%m-%d")
|
||||||
|
vals={
|
||||||
|
"partner_id": partner.id,
|
||||||
|
"company_id": company_id,
|
||||||
|
"type": "in",
|
||||||
|
"pay_type": "invoice",
|
||||||
|
'date': datenow,
|
||||||
|
"account_id": st.import_account_id.id,
|
||||||
|
'invoice_lines': [],
|
||||||
|
'rd_cust': True, #XXX
|
||||||
|
}
|
||||||
|
payment_id=get_model("account.payment").create(vals,context={"type":"in"})
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
'name': 'clinic_matching_payment_group',
|
'name': 'payment',
|
||||||
'mode': 'form',
|
'mode': 'form',
|
||||||
'active_id': obj.id,
|
'active_id': payment_id,
|
||||||
},
|
},
|
||||||
'flash': 'Posted',
|
'flash': 'Create Payment successfully',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def update_amount(self,context={}):
|
def update_amount(self,context={}):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
data['total']=0
|
data['total']=0
|
||||||
|
@ -63,4 +107,16 @@ class MatchingPaymentGroup(Model):
|
||||||
data=self.update_amount(context=context)
|
data=self.update_amount(context=context)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
MatchingPaymentGroup.register()
|
def to_draft(self,ids,context={}):
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
obj.write({
|
||||||
|
'state': 'draft',
|
||||||
|
})
|
||||||
|
|
||||||
|
def sumbit(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
obj.write({
|
||||||
|
'state': 'waiting_approve',
|
||||||
|
})
|
||||||
|
|
||||||
|
InvoicePayment.register()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from netforce.model import Model, fields
|
from netforce.model import Model, fields
|
||||||
|
|
||||||
class MatchingPaymentGroupLine(Model):
|
class InvoicePaymentLine(Model):
|
||||||
_name="clinic.matching.payment.group.line"
|
_name="clinic.invoice.payment.line"
|
||||||
_string="Matching Payment Group Line"
|
_string="Invoice Payment Line"
|
||||||
|
|
||||||
def _get_all(self,ids,context={}):
|
def _get_all(self,ids,context={}):
|
||||||
res={}
|
res={}
|
||||||
|
@ -17,12 +17,12 @@ class MatchingPaymentGroupLine(Model):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'group_matching_id': fields.Many2One("clinic.matching.payment.group","Group Matching",required=True,on_delete="cascade"),
|
'invoice_payment_id': fields.Many2One("clinic.invoice.payment","Invcoie Payment",required=True,on_delete="cascade"),
|
||||||
'matching_id': fields.Many2One("clinic.matching.payment","Group Matching"),
|
'matching_id': fields.Many2One("clinic.matching.payment","Payment Matching"),
|
||||||
'fee': fields.Float("Fee"),
|
'fee': fields.Float("Fee"),
|
||||||
'srv': fields.Float("Service"),
|
'srv': fields.Float("Service"),
|
||||||
'epo': fields.Float("EPO"),
|
'epo': fields.Float("EPO"),
|
||||||
'amount': fields.Float("Amount", function="_get_all", function_multi=True),
|
'amount': fields.Float("Amount", function="_get_all", function_multi=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
MatchingPaymentGroupLine.register()
|
InvoicePaymentLine.register()
|
||||||
|
|
|
@ -3,8 +3,7 @@ from calendar import monthrange
|
||||||
|
|
||||||
from netforce.model import Model, fields, get_model
|
from netforce.model import Model, fields, get_model
|
||||||
from netforce.utils import get_file_path, get_data_path
|
from netforce.utils import get_file_path, get_data_path
|
||||||
from netforce.database import get_connection
|
from netforce.access import get_active_company, get_active_user
|
||||||
from netforce.access import get_active_company
|
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
|
@ -55,6 +54,7 @@ class MatchingPayment(Model):
|
||||||
'total_srv': fields.Float("Service",function="_get_all",function_multi=True),
|
'total_srv': fields.Float("Service",function="_get_all",function_multi=True),
|
||||||
'total_epo': fields.Float("EPO",function="_get_all",function_multi=True),
|
'total_epo': fields.Float("EPO",function="_get_all",function_multi=True),
|
||||||
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
|
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
|
||||||
|
'user_id': fields.Many2One("base.user","Approver"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_ptype(self,context={}):
|
def _get_ptype(self,context={}):
|
||||||
|
@ -89,6 +89,7 @@ class MatchingPayment(Model):
|
||||||
'patient_type_id': _get_ptype,
|
'patient_type_id': _get_ptype,
|
||||||
'pcode': _get_pcode,
|
'pcode': _get_pcode,
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
|
'user_id': lambda *a: get_active_user(),
|
||||||
}
|
}
|
||||||
_order="date desc"
|
_order="date desc"
|
||||||
|
|
||||||
|
@ -454,172 +455,6 @@ class MatchingPayment(Model):
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def match_old(self,ids,context={}):
|
|
||||||
obj=self.browse(ids)[0]
|
|
||||||
lines=obj.get_line()
|
|
||||||
|
|
||||||
db=get_connection()
|
|
||||||
db.execute("truncate m2m_clinic_hd_case_expense_clinic_matching_payment;")
|
|
||||||
matches1={}
|
|
||||||
matches2={}
|
|
||||||
matches3={}
|
|
||||||
if obj.pcode=='SSO':
|
|
||||||
for line in lines:
|
|
||||||
hcode=line.get('hcode18')
|
|
||||||
if not hcode:
|
|
||||||
hcode='0'
|
|
||||||
hcode=int(hcode)
|
|
||||||
hcode=str(hcode)
|
|
||||||
if obj.hcode==hcode:
|
|
||||||
lsrv_amt=line.get('epoadm29') or 0
|
|
||||||
lfee_amt=line.get('amount23') or 0
|
|
||||||
lmdc_amt=line.get('allow37') or 0
|
|
||||||
dttran=line.get("dttran")
|
|
||||||
name=line.get("name14")
|
|
||||||
pid=line.get('pid')
|
|
||||||
date=dttran[0:10]
|
|
||||||
time=dttran[11:] #XXX
|
|
||||||
if not time:
|
|
||||||
print("wrong format")
|
|
||||||
continue
|
|
||||||
hn=line.get('hn')
|
|
||||||
hn=''.join([x for x in hn if x.isdigit()])
|
|
||||||
key1='%s:%s:%s:%s:%s'%(
|
|
||||||
hn,
|
|
||||||
date,
|
|
||||||
lfee_amt,
|
|
||||||
lsrv_amt,
|
|
||||||
lmdc_amt,
|
|
||||||
)
|
|
||||||
key2='%s:%s:%s:%s:%s'%(
|
|
||||||
pid,
|
|
||||||
date,
|
|
||||||
lfee_amt,
|
|
||||||
lsrv_amt,
|
|
||||||
lmdc_amt,
|
|
||||||
)
|
|
||||||
key3='%s:%s:%s:%s:%s'%(
|
|
||||||
name,
|
|
||||||
date,
|
|
||||||
lfee_amt,
|
|
||||||
lsrv_amt,
|
|
||||||
lmdc_amt,
|
|
||||||
)
|
|
||||||
vals={
|
|
||||||
'pid': pid,
|
|
||||||
'name': name,
|
|
||||||
'date': date,
|
|
||||||
'fee_amt': lfee_amt,
|
|
||||||
'service_amt': lsrv_amt,
|
|
||||||
'epo_amt': lmdc_amt,
|
|
||||||
}
|
|
||||||
if not matches1.get(key1):
|
|
||||||
matches1[key1]=vals
|
|
||||||
if not matches2.get(key2):
|
|
||||||
matches2[key2]=vals
|
|
||||||
if not matches3.get(key3):
|
|
||||||
matches2[key2]=vals
|
|
||||||
|
|
||||||
elif obj.pcode=='UC':
|
|
||||||
for line in lines:
|
|
||||||
#{'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=(line['dttran'] or "").split("T")
|
|
||||||
amt=line['amount'] or "0"
|
|
||||||
amt=float(amt)
|
|
||||||
if date and time:
|
|
||||||
key1='%s-%s-%s'%(
|
|
||||||
line['hn'],
|
|
||||||
date,
|
|
||||||
amt,
|
|
||||||
)
|
|
||||||
if not matches1.get(key1):
|
|
||||||
matches1[key1]={
|
|
||||||
'invno': line['invno'],
|
|
||||||
}
|
|
||||||
note=""
|
|
||||||
exp_ids=[]
|
|
||||||
dom=[]
|
|
||||||
dom.append(['date',">=",obj.date_from])
|
|
||||||
dom.append(['date',"<=",obj.date_to])
|
|
||||||
dom.append(['patient_id.type_id',"=",obj.patient_type_id.id])
|
|
||||||
dom.append(['state','!=', 'completed'])
|
|
||||||
for exp in get_model('clinic.hd.case.expense').search_browse(dom):
|
|
||||||
exp_ids.append(exp.id)
|
|
||||||
pt=exp.patient_id
|
|
||||||
if obj.pcode=='UC':
|
|
||||||
hdcase=exp.hd_case_id
|
|
||||||
date=hdcase.date
|
|
||||||
fee_amt=0
|
|
||||||
for line in hdcase.lines:
|
|
||||||
categ=line.product_categ_id
|
|
||||||
if categ.code=='FEE':
|
|
||||||
fee_amt+=line.amount or 0
|
|
||||||
key='%s-%s-%s'%(pt.hn_no,date,amt)
|
|
||||||
found=matches1.get(key)
|
|
||||||
if found:
|
|
||||||
exp.write({
|
|
||||||
'state': 'match',
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
note+="not found %s\n"%key
|
|
||||||
elif obj.pcode=='SSO':
|
|
||||||
key1='%s:%s:%s:%s:%s'%(
|
|
||||||
pt.hn_no,
|
|
||||||
exp.date,
|
|
||||||
exp.fee_amt and exp.fee_amt or 0,
|
|
||||||
exp.srv_amt and exp.srv_amt or 0,
|
|
||||||
exp.mdc_amt and exp.mdc_amt or 0,
|
|
||||||
)
|
|
||||||
key2='%s:%s:%s:%s:%s'%(
|
|
||||||
pt.name or "",
|
|
||||||
exp.date,
|
|
||||||
exp.fee_amt and exp.fee_amt or 0,
|
|
||||||
exp.srv_amt and exp.srv_amt or 0,
|
|
||||||
exp.mdc_amt and exp.mdc_amt or 0,
|
|
||||||
)
|
|
||||||
found=matches1.get(key1) or matches2.get(key2)
|
|
||||||
if found:
|
|
||||||
hdcase=exp.hd_case_id
|
|
||||||
if hdcase:
|
|
||||||
for inv in hdcase.invoices:
|
|
||||||
pass
|
|
||||||
#if
|
|
||||||
#pass
|
|
||||||
exp.write({
|
|
||||||
'state': 'match',
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
note+="not found %s, %s\n"%(key1,key2)
|
|
||||||
obj.write({
|
|
||||||
'expenes': [('add',exp_ids)],
|
|
||||||
'note': note,
|
|
||||||
})
|
|
||||||
print("Done!")
|
|
||||||
flash='Succesfully'
|
|
||||||
if not exp_ids:
|
|
||||||
flash="No match"
|
|
||||||
return {
|
|
||||||
'next': {
|
|
||||||
'name': 'clinic_matching_payment',
|
|
||||||
'mode': 'form',
|
|
||||||
'active_id': obj.id,
|
|
||||||
},
|
|
||||||
'flash': flash,
|
|
||||||
}
|
|
||||||
|
|
||||||
def onchange_invoice(self,context={}):
|
def onchange_invoice(self,context={}):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
path=context['path']
|
path=context['path']
|
||||||
|
@ -636,4 +471,24 @@ class MatchingPayment(Model):
|
||||||
get_model("clinic.matching.payment.line").delete(line_ids)
|
get_model("clinic.matching.payment.line").delete(line_ids)
|
||||||
print("Cleared %s"%(line_ids))
|
print("Cleared %s"%(line_ids))
|
||||||
|
|
||||||
|
def approve(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
obj.write({
|
||||||
|
'state': 'approved',
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
'next': {
|
||||||
|
'name': 'clinic_matching_payment',
|
||||||
|
'mode': 'form',
|
||||||
|
'active_id': obj.id,
|
||||||
|
},
|
||||||
|
'flash': '%s has been approved'%obj.name,
|
||||||
|
}
|
||||||
|
|
||||||
|
def to_draft(self,ids,context={}):
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
obj.write({
|
||||||
|
'state': 'draft',
|
||||||
|
})
|
||||||
|
|
||||||
MatchingPayment.register()
|
MatchingPayment.register()
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
{{#each titles}}
|
{{#each titles}}
|
||||||
<th>{{name}}</th>
|
<th style="text-align:center">{{name}}</th>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
<a href="/ui#name=product&active_id={{prod_id}}&mode=form"> {{prod_name}} </a>
|
<a href="/ui#name=product&active_id={{prod_id}}&mode=form"> {{prod_name}} </a>
|
||||||
</td>
|
</td>
|
||||||
{{#each sub_lines}}
|
{{#each sub_lines}}
|
||||||
<td>{{qty}}</td>
|
<td style="text-align:center">{{qty}}</td>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
Loading…
Reference in New Issue