filter matching payment

conv_bal
watcha.h 2015-03-04 14:19:53 +07:00
parent bce643eec6
commit e203358be3
11 changed files with 169 additions and 46 deletions

View File

@ -0,0 +1,6 @@
<action>
<field name="string">Select</field>
<field name="view_cls">form_popup</field>
<field name="model">clinic.matching.payment.popup</field>
<field name="target">_popup</field>
</action>

View File

@ -1,5 +1,6 @@
<inherit model="account.invoice" inherit="cust_invoice_form"> <inherit model="account.invoice" inherit="cust_invoice_form">
<field name="related_id" position="before"> <field name="related_id" position="before">
<field name="department_id"/> <field name="department_id" span="2"/>
<field name="patient_partner_id" span="2"/>
</field> </field>
</inherit> </inherit>

View File

@ -2,14 +2,13 @@
<head> <head>
<field name="state"/> <field name="state"/>
<button string="Print" dropdown="1" icon="print"> <button string="Print" dropdown="1" icon="print">
<item string="Match" method="print_match"/>
<item string="Unmatch" method="print_unmatch"/>
<item string="Invoice Unmatch" action="clinic_matching_payment_unmatch_invoice"/> <item string="Invoice Unmatch" action="clinic_matching_payment_unmatch_invoice"/>
</button> </button>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="Update Identification" method="update_id"/>
<item string="To Draft" method="to_draft" states="approved"/> <item string="To Draft" method="to_draft" states="approved"/>
<item string="Clear" method="clear_line" confirm="Are you sure?"/> <item string="Select Type" action="clinic_matching_payment_popup"/>
<item string="Update ID Card" method="update_id"/>
<item string="Reset Items" 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"/>
@ -21,22 +20,57 @@
<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="type" invisible="1" span="3"/>
<tabs> <tabs>
<tab string="General"> <tab string="General">
<field name="lines" nolabel="1" count="0"> <group attrs='{"invisible":[["type","in",["match","unmatch"]]]}'>
<list> <field name="lines" nolabel="1" count="0">
<field name="date"/> <list>
<field name="hn"/> <field name="date"/>
<field name="pid"/> <field name="hn"/>
<field name="name"/> <field name="pid"/>
<field name="epo" sum="1"/> <field name="name"/>
<field name="srv" sum="1"/> <field name="epo" sum="1"/>
<field name="fee" sum="1"/> <field name="srv" sum="1"/>
<field name="amount" sum="1"/> <field name="fee" sum="1"/>
<field name="invoice_id" onchange="onchange_invoice" domain='[["date","=",date],["state","=","waiting_payment"]]'/> <field name="amount" sum="1"/>
<field name="state"/> <field name="invoice_id" onchange="onchange_invoice" domain='[["date","=",date],["state","=","waiting_payment"]]'/>
</list> <field name="state"/>
</field> </list>
</field>
</group>
<group attrs='{"invisible":[["type","in",["all","match"]]]}'>
<field name="unmatch_lines" nolabel="1" count="0">
<list>
<field name="date"/>
<field name="hn"/>
<field name="pid"/>
<field name="name"/>
<field name="epo" sum="1"/>
<field name="srv" sum="1"/>
<field name="fee" sum="1"/>
<field name="amount" sum="1"/>
<field name="invoice_id" onchange="onchange_invoice" domain='[["date","=",date],["state","=","waiting_payment"]]'/>
<field name="state"/>
</list>
</field>
</group>
<group attrs='{"invisible":[["type","in",["all","unmatch"]]]}'>
<field name="match_lines" nolabel="1" count="0">
<list>
<field name="date"/>
<field name="hn"/>
<field name="pid"/>
<field name="name"/>
<field name="epo" sum="1"/>
<field name="srv" sum="1"/>
<field name="fee" sum="1"/>
<field name="amount" sum="1"/>
<field name="invoice_id" onchange="onchange_invoice" domain='[["date","=",date],["state","=","waiting_payment"]]'/>
<field name="state"/>
</list>
</field>
</group>
<group span="8" columns="1"> <group span="8" columns="1">
<field name="total_srv" offset="1" span="3"/> <field name="total_srv" offset="1" span="3"/>
<newline/> <newline/>

View File

@ -0,0 +1,9 @@
<form model="clinic.matching.payment.popup" title="Select Type">
<group form_layout="stacked">
<field name="type" span="6"/>
<field name="matching_payment_id" invisible="1"/>
</group>
<foot>
<button string="Select" method="do_select" type="primary"/>
</foot>
</form>

View File

@ -104,6 +104,7 @@ 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_popup
from . import invoice_payment from . import invoice_payment
from . import invoice_payment_line from . import invoice_payment_line
from . import matching_hdcase from . import matching_hdcase

View File

@ -7,6 +7,8 @@ class AccountInvoice(Model):
_fields={ _fields={
'clinic_expense_id': fields.Many2One("clinic.hd.case.expense","Expense"), 'clinic_expense_id': fields.Many2One("clinic.hd.case.expense","Expense"),
'department_id': fields.Many2One("clinic.department","Department",search=True), 'department_id': fields.Many2One("clinic.department","Department",search=True),
'patient_partner_id': fields.Many2One("partner","Patient",search=True),
} }
AccountInvoice.register() AccountInvoice.register()

View File

@ -506,6 +506,7 @@ class HDCase(Model):
})) }))
patient=obj.patient_id patient=obj.patient_id
patient_partner=patient.partner_id
if rmb_lines: if rmb_lines:
ptype=patient.type_id ptype=patient.type_id
@ -528,6 +529,8 @@ class HDCase(Model):
} }
vals["partner_id"]=partner.id vals["partner_id"]=partner.id
vals['lines']=rmb_lines vals['lines']=rmb_lines
if patient_partner:
vals['patient_partner_id']=patient_partner.id,
get_model("account.invoice").create(vals,context) get_model("account.invoice").create(vals,context)
if normb_lines and is_credit: if normb_lines and is_credit:
@ -548,6 +551,8 @@ class HDCase(Model):
'partner_id':partner.id, 'partner_id':partner.id,
} }
vals['lines']=normb_lines vals['lines']=normb_lines
if patient_partner:
vals['patient_partner_id']=patient_partner.id,
get_model("account.invoice").create(vals,context) # create alway get_model("account.invoice").create(vals,context) # create alway
obj.make_pickings() obj.make_pickings()

View File

@ -10,7 +10,6 @@ from . import utils
class MatchingPayment(Model): class MatchingPayment(Model):
_name="clinic.matching.payment" _name="clinic.matching.payment"
_string="Payment Matching" _string="Payment Matching"
#_transient=True
def _get_store(self,ids,context={}): def _get_store(self,ids,context={}):
res={} res={}
@ -28,9 +27,13 @@ class MatchingPayment(Model):
total_fee=0 total_fee=0
total_srv=0 total_srv=0
total_epo=0 total_epo=0
for line in obj.lines: otype=obj.type or "all"
if line.state!='match': lines=obj.lines
continue if otype=='match':
lines=obj.match_lines
elif otype=='unmatch':
lines=obj.unmatch_lines
for line in lines:
total_fee+=line.fee or 0 total_fee+=line.fee or 0
total_srv+=line.srv or 0 total_srv+=line.srv or 0
total_epo+=line.epo or 0 total_epo+=line.epo or 0
@ -38,9 +41,9 @@ class MatchingPayment(Model):
if state=='match': if state=='match':
total_match+=1 total_match+=1
res[obj.id]={ res[obj.id]={
'total': len(obj.lines), 'total': len(lines),
'total_match': total_match, 'total_match': total_match,
'total_unmatch': len(obj.lines)-total_match, 'total_unmatch': len(lines)-total_match,
'total_fee': total_fee, 'total_fee': total_fee,
'total_srv': total_srv, 'total_srv': total_srv,
'total_epo': total_epo, 'total_epo': total_epo,
@ -58,6 +61,8 @@ 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"),
'lines': fields.One2Many("clinic.matching.payment.line","match_id", "Lines"), 'lines': fields.One2Many("clinic.matching.payment.line","match_id", "Lines"),
'match_lines': fields.One2Many("clinic.matching.payment.line","match_id", "Lines",domain=[['state','=','match']]),
'unmatch_lines': fields.One2Many("clinic.matching.payment.line","match_id", "Lines",domain=[['state','=','unmatch']]),
'note': fields.Text("Note"), 'note': fields.Text("Note"),
'total': fields.Integer("Total",function="_get_all",function_multi=True), 'total': fields.Integer("Total",function="_get_all",function_multi=True),
'total_match': fields.Integer("Match",function="_get_all",function_multi=True), 'total_match': fields.Integer("Match",function="_get_all",function_multi=True),
@ -66,6 +71,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'),
'type': fields.Selection([['all','All'],['match','Match'],['unmatch','Not Match']],'Type'),
'user_id': fields.Many2One("base.user","Approver"), 'user_id': fields.Many2One("base.user","Approver"),
} }
@ -102,6 +108,7 @@ class MatchingPayment(Model):
'pcode': _get_pcode, 'pcode': _get_pcode,
'state': 'draft', 'state': 'draft',
'user_id': lambda *a: get_active_user(), 'user_id': lambda *a: get_active_user(),
'type': 'all',
} }
_order="date desc" _order="date desc"
@ -517,16 +524,36 @@ class MatchingPayment(Model):
def get_data(self,context={}): def get_data(self,context={}):
ref_id=int(context.get("refer_id","0")) ref_id=int(context.get("refer_id","0"))
obj=self.browse(ref_id) obj=self.browse(ref_id)
dom=[] inv_match_ids=[]
dom.append(['date','>=',obj.date_from])
dom.append(['date','<=',obj.date_to])
for invoice in get_model("account.invoice").search_browse(dom):
pass
match_ids=[]
for line in obj.lines: for line in obj.lines:
pass invoice=line.invoice_id
print("name ", obj.name) if invoice and line.state=='match':
data={} inv_match_ids.append(invoice.id)
dom=[
['partner_id','=',obj.partner_id.id],
['date', '>=', obj.date_from],
['date', '<=', obj.date_to],
['state','=','waiting_payment'],
]
lines=[]
no=1
for invoice in get_model('account.invoice').search_browse(dom):
if invoice.id in inv_match_ids:
continue
vals={
'no': no,
'date': invoice.date,
'number': invoice.number,
'ref': invoice.ref,
'amount_due': invoice.amount_due or 0,
}
lines.append(vals)
no+=1
data={
'lines': lines,
'date_from': obj.date_from,
'date_to': obj.date_to,
}
return data return data
def print_invoice_unmatch(self,ids,context={}): def print_invoice_unmatch(self,ids,context={}):
@ -537,7 +564,7 @@ class MatchingPayment(Model):
'mode': 'form', 'mode': 'form',
'active_id': obj.id, 'active_id': obj.id,
}, },
'flash': 'TODO', #'flash': 'TODO',
} }
MatchingPayment.register() MatchingPayment.register()

View File

@ -0,0 +1,39 @@
from netforce.model import Model, fields, get_model
class MatchingPaymentPopup(Model):
_name="clinic.matching.payment.popup"
_transient=True
_fields={
"matching_payment_id": fields.Many2One("clinic.matching.payment","Matching Payment",required=True,on_delete="cascade"),
'type': fields.Selection([['all','All'],['match','Match'],['unmatch','Not Match']],'Type'),
}
def _get_id(self,context={}):
refer_id=context.get("refer_id")
if not refer_id:
return None
return int(refer_id)
_defaults={
'matching_payment_id': _get_id,
'type': 'all',
}
def do_select(self,ids,context):
obj=self.browse(ids)[0]
matching=obj.matching_payment_id
matching.write({
'type': obj.type,
})
return {
'next': {
'name': 'clinic_matching_payment',
'mode': 'form',
'active_id': matching.id,
},
}
MatchingPaymentPopup.register()

View File

@ -1,16 +1,15 @@
todo: todo:
- report k. boy (sub detail) -> ok
- need to update level of nurse (Chanon)
- staff rotation
- update level for staff
- add script to
- multi department access *** - multi department access ***
- merge staff same name but different department - merge staff same name but different department
- doctor นายแพทย์ ทวีชัย - doctor นายแพทย์ ทวีชัย
- ** udpate server (run click me) - run script
- ** update accounting - update level's nurse
- bug - report k. boy (sub detail) -> ok
- wht (david) - ** update accounting
- link ref -> ok
- bug -> ok
- wht (david) -> p yui test
=============================== ===============================
- compute labor cost - compute labor cost