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