import payment
parent
5fdb377c1a
commit
4ac1060064
|
@ -1,8 +1,10 @@
|
|||
<action>
|
||||
<field name="string">Payment Matching</field>
|
||||
<field name="view_cls">report</field>
|
||||
<!--<field name="view_cls">report</field> -->
|
||||
<field name="view_cls">form_view</field>
|
||||
<field name="view_xml">clinic_matching_payment</field>
|
||||
<field name="model">clinic.matching.payment</field>
|
||||
<field name="report_template">matching_payment</field>
|
||||
<field name="report_template_xls">matching_payment</field>
|
||||
<!--<field name="report_template">matching_payment</field> -->
|
||||
<!--<field name="report_template_xls">matching_payment</field> -->
|
||||
<field name="menu">account_menu</field>
|
||||
</action>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<!--<item string="Labor Cost Entries" action="clinic_labor_cost_entry"/>-->
|
||||
<item string="Payments Matching" action="clinic_matching_payment"/>
|
||||
<item string="HD Cases Matching" action="clinic_matching_hdcase_acc"/>
|
||||
<!--<item string="HD Case Expenses" action="clinic_hd_case_expense"/>-->
|
||||
<item string="HD Case Expenses" action="clinic_hd_case_expense"/>
|
||||
<divider/>
|
||||
<header string="REPORTS"/>
|
||||
<item string="Labor Cost Summary" action="clinic_report_labor_cost_summary"/>
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
</tab>
|
||||
</tabs>
|
||||
<foot>
|
||||
<button string="Done" type="success" icon="ok" method="complete" states="match"/>
|
||||
<button string="Match" type="success" icon="ok" method="do_match" states="waiting_matching,unmatch,draft"/>
|
||||
<button string="Unmatch" type="danger" icon="remove" method="do_unmatch" states="waiting_matching,match,draft"/>
|
||||
<!--<button string="Done" type="success" icon="ok" method="complete" states="match"/>-->
|
||||
<!--<button string="Match" type="success" icon="ok" method="do_match" states="waiting_matching,unmatch,draft"/>-->
|
||||
<!--<button string="Unmatch" type="danger" icon="remove" method="do_unmatch" states="waiting_matching,match,draft"/>-->
|
||||
</foot>
|
||||
<related>
|
||||
<field name="invoices"/>
|
||||
|
|
|
@ -5,13 +5,29 @@
|
|||
<item string="Import Payment" method="do_import" type="default"/>
|
||||
</button>
|
||||
</head>
|
||||
<field name="date" onchange="onchange_date" mode="month" span="2"/>
|
||||
<field name="date_from" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="file" span="4"/>
|
||||
<field name="date" onchange="onchange_date" mode="month" span="3"/>
|
||||
<field name="date_from" span="3"/>
|
||||
<field name="date_to" span="3"/>
|
||||
<field name="file" span="3"/>
|
||||
<newline/>
|
||||
<field name="patient_type_id" onchange="onchange_ptype" span="2"/>
|
||||
<field name="pcode" span="2"/>
|
||||
<field name="hcode_id" span="2"/>
|
||||
<button string="Import Payment" method="do_import" type="default" icon='arrow-right' size="small"/>
|
||||
<field name="patient_type_id" onchange="onchange_ptype" span="3"/>
|
||||
<field name="pcode" span="3"/>
|
||||
<field name="hcode_id" span="3" attrs='{"required":[["pcode","=","SSO"]],"invisible":[["pcode","!=","SSO"]]}'/>
|
||||
<field name="lines" nolabel="1" count="0">
|
||||
<list>
|
||||
<field name="date"/>
|
||||
<field name="hn"/>
|
||||
<field name="pid"/>
|
||||
<field name="name"/>
|
||||
<field name="epo"/>
|
||||
<field name="service"/>
|
||||
<field name="fee"/>
|
||||
<field name="expense_id" onchange="onchange_line" domain='[["date","=",date],["patient_id.name","=",name]]'/>
|
||||
<field name="state"/>
|
||||
</list>
|
||||
</field>
|
||||
<foot replace="1">
|
||||
<button string="Match" method="do_match" type="success" icon='ok'/>
|
||||
<!--<button string="Import Payment" method="do_import" type="default" icon='arrow-right'/>-->
|
||||
</foot>
|
||||
</form>
|
||||
|
|
|
@ -102,6 +102,7 @@ from . import product_categ
|
|||
from . import make_apt
|
||||
from . import make_apt_line
|
||||
from . import matching_payment
|
||||
from . import matching_payment_line
|
||||
from . import matching_hdcase
|
||||
from . import sale_order
|
||||
from . import shop
|
||||
|
|
|
@ -6,7 +6,6 @@ from netforce.access import get_active_company
|
|||
class HDCaseExpense(Model):
|
||||
_name="clinic.hd.case.expense"
|
||||
_string="Expense"
|
||||
_name_field="date"
|
||||
_multi_company=True
|
||||
|
||||
def _get_patient_conflict(self,ids,context={}):
|
||||
|
@ -20,7 +19,16 @@ class HDCaseExpense(Model):
|
|||
res[obj.id]=conflict
|
||||
return res
|
||||
|
||||
def _get_store(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
pt=obj.patient_id
|
||||
name='%s,%s,%s,%s'%(obj.date, pt.hn_no or '', pt.card_no or '', pt.name)
|
||||
res[obj.id]=name
|
||||
return res
|
||||
|
||||
_fields={
|
||||
'name': fields.Char("Name", function="_get_store",store=True),
|
||||
'date': fields.Date("Date",required=True,search=True),
|
||||
'patient_id': fields.Many2One("clinic.patient","Patient",required=True,search=True),
|
||||
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case",required=True,search=True),
|
||||
|
@ -57,8 +65,13 @@ class HDCaseExpense(Model):
|
|||
inv.write({
|
||||
'clinic_expense_id': new_id,
|
||||
})
|
||||
self.function_store([new_id])
|
||||
return new_id
|
||||
|
||||
def write(self,ids,vals,**kw):
|
||||
self.function_store(ids)
|
||||
super().write(ids,vals,**kw)
|
||||
|
||||
def complete(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({
|
||||
|
|
|
@ -2,7 +2,7 @@ import time
|
|||
from calendar import monthrange
|
||||
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.utils import get_file_path
|
||||
from netforce.utils import get_file_path, get_data_path
|
||||
from netforce.database import get_connection
|
||||
from netforce.access import get_active_company
|
||||
|
||||
|
@ -21,7 +21,9 @@ class MatchingPayment(Model):
|
|||
'pcode': fields.Char("Code",required=True),
|
||||
'hcode_id': fields.Many2One("clinic.hospital","HCode"),
|
||||
'expenes': fields.Many2Many("clinic.hd.case.expense","Expenses"),
|
||||
'lines': fields.One2Many("clinic.matching.payment.line","match_id", "Lines"),
|
||||
'note': fields.Text("Note"),
|
||||
'exp_id': fields.Many2One("clinic.hd.case.expense","Expenses"),
|
||||
}
|
||||
|
||||
def _get_ptype(self,context={}):
|
||||
|
@ -87,6 +89,7 @@ class MatchingPayment(Model):
|
|||
matches2={}
|
||||
matches3={}
|
||||
matches4={}
|
||||
matches_uc={}
|
||||
dom=[]
|
||||
dom.append(['date',">=",obj.date_from])
|
||||
dom.append(['date',"<=",obj.date_to])
|
||||
|
@ -127,6 +130,7 @@ class MatchingPayment(Model):
|
|||
lmdc_amt,
|
||||
)
|
||||
key4='%s:%s'%(name_check,date)
|
||||
key_uc='%s:%s:%s'%(hn,date,lfee_amt)
|
||||
vals={
|
||||
'pid': pid,
|
||||
'name': name,
|
||||
|
@ -145,6 +149,8 @@ class MatchingPayment(Model):
|
|||
matches3[key3]=vals
|
||||
if not matches4.get(key3):
|
||||
matches4[key4]=vals
|
||||
if not matches_uc.get(key_uc):
|
||||
matches4[key_uc]=vals
|
||||
nf_hcode=''
|
||||
if obj.hcode_id:
|
||||
nf_hcode=obj.hcode_id.code
|
||||
|
@ -207,6 +213,7 @@ class MatchingPayment(Model):
|
|||
'no': no,
|
||||
'date':date,
|
||||
'patient_name': name2,
|
||||
'pid': pid,
|
||||
'hn': hn,
|
||||
'fee_amt': lfee_amt,
|
||||
'srv_amt': lsrv_amt,
|
||||
|
@ -267,6 +274,7 @@ class MatchingPayment(Model):
|
|||
records.append(record)
|
||||
no+=1
|
||||
elif obj.pcode=='UC':
|
||||
records=[]
|
||||
for line in lines:
|
||||
#{'amount': '1500.0000',
|
||||
#'cstat': None,
|
||||
|
@ -285,16 +293,47 @@ class MatchingPayment(Model):
|
|||
date,time=(line['dttran'] or "").split("T")
|
||||
amt=line['amount'] or "0"
|
||||
amt=float(amt)
|
||||
hn=line['hn']
|
||||
hn=hn.replace(" ", "")
|
||||
if date and time:
|
||||
key1='%s-%s-%s'%(
|
||||
key1='%s:%s:%s'%(
|
||||
line['hn'],
|
||||
date,
|
||||
amt,
|
||||
)
|
||||
if not matches1.get(key1):
|
||||
matches1[key1]={
|
||||
'invno': line['invno'],
|
||||
}
|
||||
name=''
|
||||
pid=''
|
||||
for pt in get_model("clinic.patient").search_browse([['hn_no','=',hn]]):
|
||||
name=pt.name
|
||||
pid=pt.card_no or ''
|
||||
record={
|
||||
'date':date,
|
||||
'name': name,
|
||||
'pid': pid,
|
||||
'hn': hn,
|
||||
'fee_amt': amt,
|
||||
'srv_amt': 0,
|
||||
'mdc_amt': 0,
|
||||
'note': '',
|
||||
'nf_patient': '',
|
||||
'nf_pid': '',
|
||||
'nf_hn': '',
|
||||
'nf_fee_amt': 0,
|
||||
'nf_srv_amt': 0,
|
||||
'nf_mdc_amt': 0,
|
||||
'expense_id': None,
|
||||
'expense_number': '',
|
||||
'found': False,
|
||||
}
|
||||
if matches_uc.get(key1):
|
||||
vals=matches_uc[key1]
|
||||
record.update({
|
||||
'found': True,
|
||||
'expense_id':vals['expense_id'],
|
||||
'fee_amt': vals['fee'] or 0,
|
||||
})
|
||||
records.append(record)
|
||||
|
||||
return records
|
||||
|
||||
def onchange_date(self,context={}):
|
||||
|
@ -319,10 +358,6 @@ class MatchingPayment(Model):
|
|||
if not st.import_account_id:
|
||||
raise Exception("Import account not found (Ratchawat Setting -> Accounting)")
|
||||
obj=self.browse(ids)[0]
|
||||
if not obj.expenes:
|
||||
raise Exception("Nothing to import")
|
||||
|
||||
obj=self.browse(ids)[0]
|
||||
partner=obj.patient_type_id.contact_id
|
||||
company_id=get_active_company()
|
||||
vals={
|
||||
|
@ -336,7 +371,16 @@ class MatchingPayment(Model):
|
|||
'rd_cust': True, #XXX
|
||||
}
|
||||
|
||||
for exp in obj.expenes:
|
||||
for line in obj.lines:
|
||||
exp=line.expense_id
|
||||
if exp:
|
||||
exp.write({
|
||||
'state': 'match',
|
||||
})
|
||||
line.delete()
|
||||
dom=[]
|
||||
dom.append(['state','=','match'])
|
||||
for exp in get_model("clinic.hd.case.expense").search_browse(dom):
|
||||
if exp.state=='match':
|
||||
for inv in exp.hd_case_id.invoices:
|
||||
if inv.partner_id.id==partner.id:
|
||||
|
@ -366,6 +410,40 @@ class MatchingPayment(Model):
|
|||
'flash': 'Create Payment successfully',
|
||||
}
|
||||
|
||||
def do_match(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
records=obj.match()
|
||||
lines=[]
|
||||
if obj.pcode=='SSO':
|
||||
for record in records:
|
||||
vals={
|
||||
'date': record['date'],
|
||||
'hn': record['hn'],
|
||||
'pid': record['pid'],
|
||||
'name': record['patient_name'],
|
||||
'epo': record['mdc_amt'],
|
||||
'service': record['srv_amt'],
|
||||
'fee': record['fee_amt'],
|
||||
'expense_id': record['expense_id'],
|
||||
}
|
||||
lines.append(('create', vals))
|
||||
elif obj.pcode=='UC':
|
||||
for record in records:
|
||||
vals={
|
||||
'date': record['date'],
|
||||
'hn': record['hn'],
|
||||
'pid': record['pid'],
|
||||
'name': record['name'],
|
||||
'fee': record['fee_amt'],
|
||||
'expense_id': record['expense_id'],
|
||||
}
|
||||
lines.append(('create', vals))
|
||||
for line in obj.lines:
|
||||
line.delete()
|
||||
obj.write({
|
||||
'lines': lines,
|
||||
})
|
||||
|
||||
def update_id(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
lines=obj.get_line()
|
||||
|
@ -567,4 +645,16 @@ class MatchingPayment(Model):
|
|||
'flash': flash,
|
||||
}
|
||||
|
||||
def onchange_line(self,context={}):
|
||||
data=context['data']
|
||||
path=context['path']
|
||||
line=get_data_path(data,path,parent=True)
|
||||
if line.get("expense_id"):
|
||||
line['state']='match'
|
||||
else:
|
||||
print("else ")
|
||||
line['state']=None
|
||||
return data
|
||||
|
||||
|
||||
MatchingPayment.register()
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
|
||||
|
||||
class MatchingPaymentLine(Model):
|
||||
_name="clinic.matching.payment.line"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
'match_id': fields.Many2One("clinic.matching.payment","Match",required=True,on_delete="cascade"),
|
||||
'expense_id': fields.Many2One("clinic.hd.case.expense","Expense"),
|
||||
"date": fields.Date("Date"),
|
||||
"hn": fields.Char("HN"),
|
||||
'pid': fields.Char("PID"),
|
||||
"name": fields.Char("Name"),
|
||||
'epo': fields.Float("EPO"),
|
||||
'service': fields.Float("Service"),
|
||||
"fee": fields.Float("Fee"),
|
||||
'state': fields.Selection([['match','Match'],['not_math','Not Match']],'State'),
|
||||
}
|
||||
|
||||
|
||||
MatchingPaymentLine.register()
|
|
@ -111,6 +111,10 @@ class ClinicSetting(Model):
|
|||
print("Only admin!!")
|
||||
return
|
||||
|
||||
for exp in get_model('clinic.hd.case.expense').search_browse([]):
|
||||
exp.write({
|
||||
'note': ' ',
|
||||
})
|
||||
# try to create contact
|
||||
for staff in get_model("clinic.staff").search_browse([]):
|
||||
staff.write({
|
||||
|
|
|
@ -2,24 +2,25 @@
|
|||
<table class="table table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="9" style="text-align:center;background-color:#f9e37d;">Import File</th>
|
||||
<th colspan="5" style="text-align:center;background-color:#2d6ed2;color:white">Netforce</th>
|
||||
<th colspan="8" style="text-align:center;background-color:#f9e37d;">Import File</th>
|
||||
<th colspan="7" style="text-align:center;background-color:#2d6ed2;color:white">Netforce</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Date</th>
|
||||
<th>HN</th>
|
||||
<th>PID</th>
|
||||
<th>Patient</th>
|
||||
<th>EPO Amount</th>
|
||||
<th>Service Medical</th>
|
||||
<th>Fee Amount</th>
|
||||
<th>EPO</th>
|
||||
<th>Service</th>
|
||||
<th>Fee</th>
|
||||
|
||||
<th>Date</th>
|
||||
<th>HN</th>
|
||||
<th>Patient</th>
|
||||
<th>EPO Amount</th>
|
||||
<th>Service Medical</th>
|
||||
<th>Fee Amount</th>
|
||||
<th>EPO</th>
|
||||
<th>Service</th>
|
||||
<th>Fee</th>
|
||||
<th>Expense</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -29,6 +30,7 @@
|
|||
<td>{{no}}</td>
|
||||
<td>{{date}}</td>
|
||||
<td>{{hn}}</td>
|
||||
<td>{{pid}}</td>
|
||||
<td>{{patient_name}}
|
||||
<td>{{currency mdc_amt zero=""}}</td>
|
||||
<td>{{currency srv_amt zero=""}}</td>
|
||||
|
|
Loading…
Reference in New Issue