payment
parent
5cf9be65a1
commit
2dd2b4cfcc
|
@ -2,7 +2,7 @@
|
||||||
<field name="string">Treatments</field>
|
<field name="string">Treatments</field>
|
||||||
<field name="view_cls">multi_view</field>
|
<field name="view_cls">multi_view</field>
|
||||||
<field name="model">clinic.hd.case</field>
|
<field name="model">clinic.hd.case</field>
|
||||||
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["In Progress",[["state","=","in_progress"]]],["Completed",[["state","=","completed"]]],["In Completed",[["state","=","in_completed"]]]]</field>
|
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["In Progress",[["state","=","in_progress"]]],["Waiting Payment",[["state","=","waiting_payment"]]],["Completed",[["state","=","completed"]]],["In Completed",[["state","=","in_completed"]]]]</field>
|
||||||
<field name="modes">list,form</field>
|
<field name="modes">list,form</field>
|
||||||
<field name="menu">clinic_menu</field>
|
<field name="menu">clinic_menu</field>
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -58,11 +58,11 @@
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
<group span="8" form_layout="stacked" attrs='{"invisible":[["amount","=",0]]}'>
|
<group span="8" form_layout="stacked" attrs='{"invisible":[["amount","=",0]]}'>
|
||||||
<separator string="Make a payment"/>
|
<!--<separator string="Make a payment"/>-->
|
||||||
<field name="pay_amount" attrs='{"required":[["amount","!=",0]]}' onchange="onchange_pay" span="3"/>
|
<!--<field name="pay_amount" attrs='{"required":[["amount","!=",0]]}' onchange="onchange_pay" span="3"/>-->
|
||||||
<field name="pay_date" span="3"/>
|
<!--<field name="pay_date" span="3"/>-->
|
||||||
<field name="pay_account_id" span="3"/>
|
<!--<field name="pay_account_id" span="3"/>-->
|
||||||
<button string="Pay" type="success" icon="ok" action="clinic_payment" attrs='{"invisible":[["amount","=",0]]}'/>
|
<!--<button string="Pay" type="success" icon="ok" action="clinic_payment" attrs='{"invisible":[["amount","=",0]]}'/>-->
|
||||||
</group>
|
</group>
|
||||||
<group span="4" columns="1">
|
<group span="4" columns="1">
|
||||||
<field name="total"/>
|
<field name="total"/>
|
||||||
|
@ -96,13 +96,30 @@
|
||||||
</tab>
|
</tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Process" type="success" icon="arrow-right" method="do_treatment" states="draft"/>
|
<button string="Start" type="success" icon="arrow-right" method="do_treatment" states="draft"/>
|
||||||
<button string="Complete" type="success" icon="ok" method="complete" states="in_progress"/>
|
<button string="Done" type="success" icon="ok" method="done" states="in_progress"/>
|
||||||
|
<!--<button string="Complete" type="success" icon="ok" method="complete" states="in_progress"/>-->
|
||||||
<button string="Discontinue" type="danger" icon="remove" action="clinic_hd_case_distcont" states="in_progress"/>
|
<button string="Discontinue" type="danger" icon="remove" action="clinic_hd_case_distcont" states="in_progress"/>
|
||||||
<button string="Undo" type="default" icon="refresh" method="undo" states="completed"/>
|
<button string="Undo" type="default" icon="refresh" method="undo" states="completed"/>
|
||||||
|
<button string="Pay" type="success" icon="ok" action="clinic_payment" states="waiting_payment" />
|
||||||
</foot>
|
</foot>
|
||||||
<related>
|
<related>
|
||||||
<field name="invoices" click_action="view_invoice"/>
|
<field name="invoices" click_action="view_invoice">
|
||||||
|
<list colors='{"#9f9":[["state","=","paid"]]}'>
|
||||||
|
<head>
|
||||||
|
<button string="Pay" type="success" icon="ok"/>
|
||||||
|
</head>
|
||||||
|
<field name="number"/>
|
||||||
|
<field name="ref"/>
|
||||||
|
<field name="inv_type"/>
|
||||||
|
<field name="partner_id"/>
|
||||||
|
<field name="date"/>
|
||||||
|
<field name="due_date"/>
|
||||||
|
<field name="amount_paid_cur"/>
|
||||||
|
<field name="amount_due_cur"/>
|
||||||
|
<field name="state"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
<field name="pickings" click_action="view_picking"/>
|
<field name="pickings" click_action="view_picking"/>
|
||||||
<field name="payments" click_action="clinic_view_payment"/>
|
<field name="payments" click_action="clinic_view_payment"/>
|
||||||
<field name="comments"/>
|
<field name="comments"/>
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
<form model="clinic.hd.case.payment">
|
<form model="clinic.hd.case.payment">
|
||||||
<field name="hd_case_id" invisible="1"/>
|
<field name="hd_case_id" invisible="1"/>
|
||||||
<group form_layout="stacked">
|
<field name="pay_amount" onchange="onchange_amount"/>
|
||||||
<field name="pay_amount" />
|
<newline/>
|
||||||
</group>
|
<field name="fee" readonly="1"/>
|
||||||
|
<newline/>
|
||||||
|
<field name="to_pay" readonly="1"/>
|
||||||
|
<newline/>
|
||||||
|
<field name="complete" help="Mark as complete"/>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Cash" type="success" method="cash" confirm="Are you sure?"/>
|
<button string="Cash" type="success" icon="ok" method="cash" confirm="Are you sure?"/>
|
||||||
<button string="Credit" type="primary" method="credit"/>
|
<button string="Credit" type="default" icon="check" method="credit"/>
|
||||||
</foot>
|
</foot>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
<form model="clinic.report.hd.dialy">
|
|
||||||
<group>
|
|
||||||
<field name="date_from" span="2"/>
|
|
||||||
<field name="date_to" span="2"/>
|
|
||||||
<field name="cycle_id" span="2"/>
|
|
||||||
<field name="patient_id" span="2"/>
|
|
||||||
<field name="nurse_id" span="2"/>
|
|
||||||
<field name="doctor_id" span="2"/>
|
|
||||||
</group>
|
|
||||||
</form>
|
|
|
@ -6,7 +6,7 @@ from netforce.utils import get_data_path
|
||||||
from netforce.access import get_active_user,set_active_user
|
from netforce.access import get_active_user,set_active_user
|
||||||
from netforce.access import get_active_company
|
from netforce.access import get_active_company
|
||||||
|
|
||||||
class HDcase(Model):
|
class HDCase(Model):
|
||||||
_name="clinic.hd.case"
|
_name="clinic.hd.case"
|
||||||
_string="Treatment"
|
_string="Treatment"
|
||||||
_audit_log=True
|
_audit_log=True
|
||||||
|
@ -50,7 +50,7 @@ class HDcase(Model):
|
||||||
"hct_msg" : fields.Char("HCT message"),
|
"hct_msg" : fields.Char("HCT message"),
|
||||||
"check_goverment_pay" : fields.Boolean("The Government Pay"),
|
"check_goverment_pay" : fields.Boolean("The Government Pay"),
|
||||||
"check_personal_pay" : fields.Boolean("Pay yourself"),
|
"check_personal_pay" : fields.Boolean("Pay yourself"),
|
||||||
"state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("discountinued","Discountinued"),("in_completed","In completed")],"Status",required=True),
|
"state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("in_completed","In completed")],"Status",required=True),
|
||||||
"dialyzers": fields.One2Many("clinic.dialyzer.line","hd_case_id","Dialyzers"),
|
"dialyzers": fields.One2Many("clinic.dialyzer.line","hd_case_id","Dialyzers"),
|
||||||
"lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Lines"),
|
"lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Lines"),
|
||||||
"comments": fields.One2Many("message","related_id","Comments"),
|
"comments": fields.One2Many("message","related_id","Comments"),
|
||||||
|
@ -64,9 +64,9 @@ class HDcase(Model):
|
||||||
"payment_lines": fields.One2Many("clinic.payment","hd_case_id","Payment Lines"),
|
"payment_lines": fields.One2Many("clinic.payment","hd_case_id","Payment Lines"),
|
||||||
'visit_id': fields.Many2One("clinic.visit", "Visit"),
|
'visit_id': fields.Many2One("clinic.visit", "Visit"),
|
||||||
'duration': fields.Integer("Duration (hrs)",function="get_hrs"),
|
'duration': fields.Integer("Duration (hrs)",function="get_hrs"),
|
||||||
"fee_type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Fee Type"),
|
|
||||||
'fee_partner_id': fields.Many2One("partner","Contact Fee"),
|
'fee_partner_id': fields.Many2One("partner","Contact Fee"),
|
||||||
"fee_amount": fields.Float("Fee",function="get_total",readonly=True,function_multi=True),
|
"fee_amount": fields.Float("Fee",function="get_total",readonly=True,function_multi=True),
|
||||||
|
'fee_paid': fields.Boolean("Fee Paid"),
|
||||||
'note': fields.Text("Note"),
|
'note': fields.Text("Note"),
|
||||||
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
||||||
'pay_amount': fields.Float("Amount",function="get_pay_amount"),
|
'pay_amount': fields.Float("Amount",function="get_pay_amount"),
|
||||||
|
@ -106,10 +106,10 @@ class HDcase(Model):
|
||||||
"company_id": lambda *a: get_active_company(),
|
"company_id": lambda *a: get_active_company(),
|
||||||
'hct': 0,
|
'hct': 0,
|
||||||
'hct_msg': "Reimbursement of medicines : 1,125/Week",
|
'hct_msg': "Reimbursement of medicines : 1,125/Week",
|
||||||
|
'fee_paid': False,
|
||||||
}
|
}
|
||||||
_order="date desc,number desc"
|
_order="date desc,number desc"
|
||||||
|
|
||||||
|
|
||||||
def onchange_dialyzer(self,context={}):
|
def onchange_dialyzer(self,context={}):
|
||||||
data=context["data"]
|
data=context["data"]
|
||||||
path=context["path"]
|
path=context["path"]
|
||||||
|
@ -175,8 +175,6 @@ class HDcase(Model):
|
||||||
price=line.get('price') or 0
|
price=line.get('price') or 0
|
||||||
qty=line.get('qty') or 0
|
qty=line.get('qty') or 0
|
||||||
amt=qty * price
|
amt=qty * price
|
||||||
#product_id=line.get("product_id")
|
|
||||||
#if product_id:
|
|
||||||
line['amount']=amt
|
line['amount']=amt
|
||||||
if line['type']=='fee':
|
if line['type']=='fee':
|
||||||
fee_amt+=amt
|
fee_amt+=amt
|
||||||
|
@ -188,9 +186,9 @@ class HDcase(Model):
|
||||||
for line in data['payment_lines']:
|
for line in data['payment_lines']:
|
||||||
total-=line['amount'] or 0.0
|
total-=line['amount'] or 0.0
|
||||||
data['amount']=total
|
data['amount']=total
|
||||||
if not data['pay_date']:
|
if not data.get('pay_date'):
|
||||||
data['pay_date']=time.strftime("%Y-%m-%d")
|
data['pay_date']=time.strftime("%Y-%m-%d")
|
||||||
if not data['pay_account_id']:
|
if not data.get('pay_account_id'):
|
||||||
patient_id=data['patient_id']
|
patient_id=data['patient_id']
|
||||||
if patient_id:
|
if patient_id:
|
||||||
patient=get_model("clinic.patient").browse(patient_id)
|
patient=get_model("clinic.patient").browse(patient_id)
|
||||||
|
@ -297,7 +295,8 @@ class HDcase(Model):
|
||||||
raise Exception("Unit not found in uom")
|
raise Exception("Unit not found in uom")
|
||||||
obj=self.browse(ids[0])
|
obj=self.browse(ids[0])
|
||||||
due_date=obj.date[0:10]
|
due_date=obj.date[0:10]
|
||||||
|
# cash, credit
|
||||||
|
make_invoice=context.get('make_invoice',True)
|
||||||
context['type']='out'
|
context['type']='out'
|
||||||
context['inv_type']='invoice'
|
context['inv_type']='invoice'
|
||||||
fee_lines=[]
|
fee_lines=[]
|
||||||
|
@ -337,12 +336,12 @@ class HDcase(Model):
|
||||||
else:
|
else:
|
||||||
vals['lines'].append(('create',inv_line))
|
vals['lines'].append(('create',inv_line))
|
||||||
|
|
||||||
if obj.amount: ## not pay yet
|
if obj.amount and make_invoice: ## not pay yet
|
||||||
inv_id=get_model("account.invoice").create(vals,context)
|
inv_id=get_model("account.invoice").create(vals,context)
|
||||||
# create picking
|
# create picking
|
||||||
obj.make_pickings()
|
obj.make_pickings()
|
||||||
|
|
||||||
if fee_lines:
|
if fee_lines and not obj.fee_paid:
|
||||||
vals={
|
vals={
|
||||||
"type": "out",
|
"type": "out",
|
||||||
"inv_type": "invoice",
|
"inv_type": "invoice",
|
||||||
|
@ -356,8 +355,6 @@ class HDcase(Model):
|
||||||
"company_id": company_id,
|
"company_id": company_id,
|
||||||
}
|
}
|
||||||
vals["partner_id"]=obj.fee_partner_id.id
|
vals["partner_id"]=obj.fee_partner_id.id
|
||||||
#XXX
|
|
||||||
|
|
||||||
account_id=account_receivable_id
|
account_id=account_receivable_id
|
||||||
patient_type=obj.patient_id.type
|
patient_type=obj.patient_id.type
|
||||||
if patient_type=='mg':
|
if patient_type=='mg':
|
||||||
|
@ -371,6 +368,9 @@ class HDcase(Model):
|
||||||
fee_line['account_id']=account_id
|
fee_line['account_id']=account_id
|
||||||
vals['lines'].append(('create',fee_line))
|
vals['lines'].append(('create',fee_line))
|
||||||
inv_id=get_model("account.invoice").create(vals,context)
|
inv_id=get_model("account.invoice").create(vals,context)
|
||||||
|
obj.write({
|
||||||
|
'fee_paid': True,
|
||||||
|
})
|
||||||
|
|
||||||
def make_pickings(self,ids,context={}):
|
def make_pickings(self,ids,context={}):
|
||||||
obj=self.browse(ids[0])
|
obj=self.browse(ids[0])
|
||||||
|
@ -514,16 +514,6 @@ class HDcase(Model):
|
||||||
if obj.state != 'draft':
|
if obj.state != 'draft':
|
||||||
raise Exception("Can not delete HD Case %s because state is not draft"%obj.number)
|
raise Exception("Can not delete HD Case %s because state is not draft"%obj.number)
|
||||||
super().delete(ids)
|
super().delete(ids)
|
||||||
|
|
||||||
def onchange_fee_type(self,context={}):
|
|
||||||
data=context['data']
|
|
||||||
fee_type=data.get("fee_type","")
|
|
||||||
if fee_type in ("mg","sc","nhso"):
|
|
||||||
data['fee']=1500
|
|
||||||
else:
|
|
||||||
data['fee']=0.0
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
def onchange_hct(self,context={}):
|
def onchange_hct(self,context={}):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
|
@ -560,6 +550,7 @@ class HDcase(Model):
|
||||||
|
|
||||||
obj.write({
|
obj.write({
|
||||||
'state': 'in_progress',
|
'state': 'in_progress',
|
||||||
|
'fee_paid': False,
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
|
@ -579,5 +570,11 @@ class HDcase(Model):
|
||||||
'active_id': ids[0],
|
'active_id': ids[0],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def done(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
obj.write({
|
||||||
|
'state': 'waiting_payment',
|
||||||
|
})
|
||||||
|
|
||||||
HDcase.register()
|
HDCase.register()
|
||||||
|
|
|
@ -24,7 +24,7 @@ class HDCaseDiscont(Model):
|
||||||
hd_case=get_model("clinic.hd.case").browse(obj.hd_case_id.id)
|
hd_case=get_model("clinic.hd.case").browse(obj.hd_case_id.id)
|
||||||
hd_case.write({
|
hd_case.write({
|
||||||
'note': obj.note,
|
'note': obj.note,
|
||||||
'state': 'uncompleted',
|
'state': 'in_completed',
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
|
|
|
@ -6,7 +6,10 @@ class HDCasePayment(Model):
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
|
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
|
||||||
"pay_amount": fields.Float("Amount"),
|
"pay_amount": fields.Float("Due Amount"),
|
||||||
|
"fee": fields.Float("Fee"),
|
||||||
|
"to_pay": fields.Float("To Pay"),
|
||||||
|
"complete": fields.Boolean("Complete"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_hd_case_id(self,context={}):
|
def _get_hd_case_id(self,context={}):
|
||||||
|
@ -20,34 +23,71 @@ class HDCasePayment(Model):
|
||||||
hd_case=get_model("clinic.hd.case").browse(hd_case_id)
|
hd_case=get_model("clinic.hd.case").browse(hd_case_id)
|
||||||
return hd_case.amount
|
return hd_case.amount
|
||||||
|
|
||||||
|
def _get_fee(self,context={}):
|
||||||
|
hd_case_id=context.get("refer_id")
|
||||||
|
hd_case=get_model("clinic.hd.case").browse(hd_case_id)
|
||||||
|
return hd_case.fee_amount
|
||||||
|
|
||||||
|
def _get_topay(self,context={}):
|
||||||
|
hd_case_id=context.get("refer_id")
|
||||||
|
hd_case=get_model("clinic.hd.case").browse(hd_case_id)
|
||||||
|
return hd_case.amount
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
'hd_case_id': _get_hd_case_id,
|
'hd_case_id': _get_hd_case_id,
|
||||||
'pay_amount': _get_pay_amount,
|
'pay_amount': _get_pay_amount,
|
||||||
|
'fee': _get_fee,
|
||||||
|
'to_pay': _get_topay,
|
||||||
|
'complete': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
def cash(self,ids,context):
|
def cash(self,ids,context):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
hd_case=get_model("clinic.hd.case").browse(obj.hd_case_id.id)
|
if obj.pay_amount:
|
||||||
context['amount']=obj.pay_amount or 0.0
|
hd_case=get_model("clinic.hd.case").browse(obj.hd_case_id.id)
|
||||||
print(">><< ", obj.pay_amount)
|
context['amount']=obj.pay_amount or 0.0
|
||||||
hd_case.make_payment(context=context)
|
context['make_invoice']=False
|
||||||
obj.write({
|
hd_case.make_invoices(context=context) #XXX
|
||||||
'pay_amount': hd_case.amount,
|
hd_case.make_payment(context=context)
|
||||||
})
|
if obj.complete:
|
||||||
print(":: ", context['amount']-obj.pay_amount)
|
hd_case.write({
|
||||||
if not obj.pay_amount:
|
'state': 'completed',
|
||||||
return {
|
})
|
||||||
'next': {
|
obj.write({
|
||||||
'name': 'clinic_hd_case',
|
'pay_amount': hd_case.amount,
|
||||||
'mode': 'form',
|
})
|
||||||
'active_id': hd_case.id,
|
return {
|
||||||
},
|
'next': {
|
||||||
'flash': 'Paid',
|
'name': 'clinic_hd_case',
|
||||||
}
|
'mode': 'form',
|
||||||
|
'active_id': hd_case.id,
|
||||||
|
},
|
||||||
|
'flash': 'Paid',
|
||||||
|
}
|
||||||
|
|
||||||
def credit(self,ids,context):
|
def credit(self,ids,context):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
hd_case=get_model("clinic.hd.case").browse(obj.hd_case_id.id)
|
hd_case=get_model("clinic.hd.case").browse(obj.hd_case_id.id)
|
||||||
|
hd_case.make_invoices()
|
||||||
|
if obj.complete:
|
||||||
|
hd_case.write({
|
||||||
|
'state': 'completed',
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
'next': {
|
||||||
|
'name': 'clinic_hd_case',
|
||||||
|
'mode': 'form',
|
||||||
|
'active_id': hd_case.id,
|
||||||
|
},
|
||||||
|
'flash': 'Paid',
|
||||||
|
}
|
||||||
|
|
||||||
|
def onchange_amount(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
pay_amount=data['pay_amount'] or 0.0
|
||||||
|
data['pay_amount']=pay_amount
|
||||||
|
data['to_pay']=pay_amount
|
||||||
|
return data
|
||||||
|
|
||||||
HDCasePayment.register()
|
HDCasePayment.register()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue