xxxxx
parent
3c4cdfa5ee
commit
dbe2a6d0fd
|
@ -2,8 +2,8 @@
|
||||||
<field name="payment_terms" position="after">
|
<field name="payment_terms" position="after">
|
||||||
<newline/>
|
<newline/>
|
||||||
<separator string="Clinic"/>
|
<separator string="Clinic"/>
|
||||||
<field name="account_fee_id" />
|
<field name="account_fee_id" attrs='{"required":[["type","=","org"]]}'/>
|
||||||
<field name="account_mdc_id" />
|
<field name="account_mdc_id" attrs='{"required":[["type","=","org"]]}'/>
|
||||||
<field name="account_service_id" />
|
<field name="account_service_id" attrs='{"required":[["type","=","org"]]}'/>
|
||||||
</field>
|
</field>
|
||||||
</inherit>
|
</inherit>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="1">
|
||||||
<item string="New Dialyzer" method="new_dialyzer" states="draft,waiting_treatment"/>
|
<item string="New Dialyzer" method="new_dialyzer" states="draft,waiting_treatment"/>
|
||||||
<item string="To Draft" method="to_draft" states="completed,cancelled"/>
|
<item string="To Draft" method="to_draft" states="paid,waiting_payment,completed,cancelled"/>
|
||||||
</button>
|
</button>
|
||||||
</head>
|
</head>
|
||||||
<group form_layout="stacked" attrs='{"readonly":[["state","=","completed"]]}'>
|
<group form_layout="stacked" attrs='{"readonly":[["state","=","completed"]]}'>
|
||||||
|
@ -64,11 +64,13 @@
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
<group span="8" form_layout="stacked">
|
<group span="8" form_layout="stacked">
|
||||||
|
<!--
|
||||||
<field name="invoice_policy" onchange="onchange_policy"/>
|
<field name="invoice_policy" onchange="onchange_policy"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<group attrs='{"invisible":[["invoice_policy","in",["","fee"]]]}'>
|
<group attrs='{"invisible":[["invoice_policy","in",["","fee"]]]}'>
|
||||||
<field name="invoice_option"/>
|
<field name="invoice_option"/>
|
||||||
</group>
|
</group>
|
||||||
|
-->
|
||||||
</group>
|
</group>
|
||||||
<group span="4" columns="1">
|
<group span="4" columns="1">
|
||||||
<field name="total_amount"/>
|
<field name="total_amount"/>
|
||||||
|
@ -115,9 +117,10 @@
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Start" type="success" icon="arrow-right" method="do_treatment" states="draft,waiting_treatment"/>
|
<button string="Start" type="success" icon="arrow-right" method="do_treatment" states="draft,waiting_treatment"/>
|
||||||
<button string="Done" type="success" icon="ok" method="done" states="in_progress"/>
|
<button string="Done" type="success" icon="ok" method="done" states="in_progress"/>
|
||||||
<button string="Discontinue" type="danger" icon="remove" action="clinic_hd_case_distcont" states="in_progress"/>
|
<button string="Discard" type="danger" icon="remove" action="clinic_hd_case_distcont" states="in_progress"/>
|
||||||
<button string="Claim Expenses" type="default" icon="arrow-right" states="completed" method="request_fee" attrs='{"invisible": [["req_fee","=",1]]}'/>
|
<button string="Claim Expense" type="default" icon="arrow-right" states="completed" method="request_fee" attrs='{"invisible":[["req_fee","=",1]]}'/>
|
||||||
<button string="Pay" type="success" icon="ok" method="pay" states="completed" attrs='{"invisible": [["req_fee","=",1]]}'/>
|
<button string="Pay" type="success" icon="ok" method="pay" states="completed" attrs='{"invisible":[["req_fee","=",0]]}'/>
|
||||||
|
|
||||||
</foot>
|
</foot>
|
||||||
<related>
|
<related>
|
||||||
<field name="invoices" click_action="view_invoice">
|
<field name="invoices" click_action="view_invoice">
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
<field name="hd_case_id" invisible="1"/>
|
<field name="hd_case_id" invisible="1"/>
|
||||||
<field name="pay_amount" onchange="onchange_amount"/>
|
<field name="pay_amount" onchange="onchange_amount"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="fee" readonly="1"/>
|
|
||||||
<newline/>
|
|
||||||
<field name="to_pay" readonly="1"/>
|
<field name="to_pay" readonly="1"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<group attrs='{"invisible":[["pay_amount","=",0]]}'>
|
<group attrs='{"invisible":[["pay_amount","=",0]]}'>
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
<field name="file" span="3" required="1"/>
|
<field name="file" span="3" required="1"/>
|
||||||
<field name="type_id" span="3"/>
|
<field name="type_id" span="3"/>
|
||||||
<!--<field name="date" span="3" mode="month" onchange="onchange_date"/>-->
|
<!--<field name="date" span="3" mode="month" onchange="onchange_date"/>-->
|
||||||
<newline/>
|
<group span="6" columns="1">
|
||||||
<button string='Match' type="success" size="small" icon="ok" method="match_invoice"/>
|
<button string='Match' span="2" type="success" size="small" icon="ok" method="match_invoice"/>
|
||||||
|
<button string='Make A Payment' span="2" type="default" size="small" icon="arrow-right" method="match_invoice"/>
|
||||||
|
</group>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
<inherit model="settings" inherit="fin_settings">
|
<inherit model="settings" inherit="fin_settings">
|
||||||
<field name="retained_earnings_account_id" position="after">
|
<field name="rounding_account_id" position="after">
|
||||||
<separator string="Clinic"/>
|
<separator string="Clinic"/>
|
||||||
<field name="ar_sc_id"/>
|
<field name="cash_account_id" domain="[['type','!=','view']]"/>
|
||||||
<field name="ap_sc_id"/>
|
<field name="income_account_id" domain="[['type','!=','view']]"/>
|
||||||
<field name="ar_uc_id"/>
|
<!--<field name="ap_doctor_id"/>-->
|
||||||
<field name="ap_uc_id"/>
|
|
||||||
<field name="ap_nurse_id"/>
|
|
||||||
<field name="ap_doctor_id"/>
|
|
||||||
<field name="hospital_code"/>
|
|
||||||
</field>
|
</field>
|
||||||
</inherit>
|
</inherit>
|
||||||
|
|
|
@ -3,13 +3,10 @@ from netforce.model import Model, fields
|
||||||
class Settings(Model):
|
class Settings(Model):
|
||||||
_inherit="settings"
|
_inherit="settings"
|
||||||
_fields={
|
_fields={
|
||||||
"ap_uc_id": fields.Many2One("account.account","Account Payment UC"),
|
"cash_account_id": fields.Many2One("account.account","Cash Account"),
|
||||||
"ap_sc_id": fields.Many2One("account.account","Account Payment Social Security"),
|
"income_account_id": fields.Many2One("account.account","Income Account"),
|
||||||
"ar_uc_id": fields.Many2One("account.account","Account Recieve UC"),
|
|
||||||
"ar_sc_id": fields.Many2One("account.account","Account Recieve Social Security"),
|
|
||||||
"ap_nurse_id": fields.Many2One("account.account","Account Payment Nurse"),
|
"ap_nurse_id": fields.Many2One("account.account","Account Payment Nurse"),
|
||||||
"ap_doctor_id": fields.Many2One("account.account","Account Payment Doctor"),
|
"ap_doctor_id": fields.Many2One("account.account","Account Payment Doctor"),
|
||||||
'hospital_code': fields.Char("Hospital Code", multi_company=True),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.register()
|
Settings.register()
|
||||||
|
|
|
@ -97,7 +97,6 @@ class HDCase(Model):
|
||||||
"rmb_amount": fields.Float("Reimbursable",function="_get_all",readonly=True,function_multi=True),
|
"rmb_amount": fields.Float("Reimbursable",function="_get_all",readonly=True,function_multi=True),
|
||||||
"due_amount": fields.Float("Due Amount",function="_get_all",readonly=True,function_multi=True),
|
"due_amount": fields.Float("Due Amount",function="_get_all",readonly=True,function_multi=True),
|
||||||
'fee_partner_id': fields.Many2One("partner","Contact Fee"),
|
'fee_partner_id': fields.Many2One("partner","Contact Fee"),
|
||||||
'fee_paid': fields.Boolean("Fee Paid"),
|
|
||||||
'note': fields.Text("Note"),
|
'note': fields.Text("Note"),
|
||||||
'complication': fields.Text("Complication"),
|
'complication': fields.Text("Complication"),
|
||||||
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
||||||
|
@ -149,7 +148,6 @@ class HDCase(Model):
|
||||||
'hd_mode': 'chronic',
|
'hd_mode': 'chronic',
|
||||||
'hct': 0,
|
'hct': 0,
|
||||||
'hct_msg': "สามารถเบิกค่ายาสูงสุดไม่เกิน 1,125บาท ต่อ สัปดาห์",
|
'hct_msg': "สามารถเบิกค่ายาสูงสุดไม่เกิน 1,125บาท ต่อ สัปดาห์",
|
||||||
'fee_paid': False,
|
|
||||||
'invoice_option': 'fee',
|
'invoice_option': 'fee',
|
||||||
'invoice_policy': 'fee',
|
'invoice_policy': 'fee',
|
||||||
'req_fee': 0,
|
'req_fee': 0,
|
||||||
|
@ -226,6 +224,7 @@ class HDCase(Model):
|
||||||
price=line['price'] or 0.0
|
price=line['price'] or 0.0
|
||||||
line['amount']=qty*price
|
line['amount']=qty*price
|
||||||
data=self.update_amount(context)
|
data=self.update_amount(context)
|
||||||
|
#bug show button
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def onchange_product(self,context={}):
|
def onchange_product(self,context={}):
|
||||||
|
@ -265,15 +264,18 @@ class HDCase(Model):
|
||||||
rmb_amt+=amt
|
rmb_amt+=amt
|
||||||
else:
|
else:
|
||||||
due_amt+=amt
|
due_amt+=amt
|
||||||
print("xx ", rmb_amt, due_amt)
|
|
||||||
data['rmb_amount']=rmb_amt
|
data['rmb_amount']=rmb_amt
|
||||||
data['due_amount']=due_amt
|
data['due_amount']=due_amt
|
||||||
data['total_amount']=due_amt+rmb_amt
|
data['total_amount']=due_amt+rmb_amt
|
||||||
|
data['req_fee']=0
|
||||||
|
if due_amt:
|
||||||
|
data['req_fee']=1
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def make_payment(self,ids,context={}):
|
def make_payment(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
if not obj.total:
|
|
||||||
|
if not obj.total_amount:
|
||||||
return
|
return
|
||||||
remaining_amt=0.0
|
remaining_amt=0.0
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
|
@ -282,34 +284,35 @@ class HDCase(Model):
|
||||||
remaining_amt-=line.amount or 0.0
|
remaining_amt-=line.amount or 0.0
|
||||||
partner=obj.patient_id.partner_id
|
partner=obj.patient_id.partner_id
|
||||||
if not partner:
|
if not partner:
|
||||||
raise Exception("No contact on this patient")
|
raise Exception("Not partner")
|
||||||
company_id=get_active_company()
|
|
||||||
account_receivable_id=partner.account_receivable_id
|
|
||||||
if not account_receivable_id:
|
|
||||||
st=get_model('settings').browse(1)
|
st=get_model('settings').browse(1)
|
||||||
account_receivable_id=st.account_receivable_id
|
|
||||||
if not account_receivable_id:
|
cash_account_id=st.cash_account_id.id
|
||||||
raise Exception("Not found account recieveable in account setting")
|
income_account_id=st.income_account_id.id
|
||||||
account_id=account_receivable_id.id
|
if not cash_account_id:
|
||||||
if not account_id:
|
raise Exception("No Cash Account")
|
||||||
raise Exception("No Account for payment")
|
if not income_account_id:
|
||||||
|
raise Exception("No Income Account")
|
||||||
pay_amount=obj.pay_amount
|
pay_amount=obj.pay_amount
|
||||||
|
|
||||||
if context.get("amount",0):
|
if context.get("amount",0):
|
||||||
pay_amount=context['amount'] or 0.0
|
pay_amount=context['amount'] or 0.0
|
||||||
|
|
||||||
|
company_id=get_active_company()
|
||||||
vals={
|
vals={
|
||||||
"partner_id": partner.id,
|
"partner_id": partner.id,
|
||||||
"company_id": company_id,
|
"company_id": company_id,
|
||||||
"type": "in",
|
"type": "in",
|
||||||
"pay_type": "direct",
|
"pay_type": "direct",
|
||||||
'date': time.strftime("%Y-%m-%d"),
|
'date': time.strftime("%Y-%m-%d"),
|
||||||
"account_id": account_id,
|
"account_id": cash_account_id,
|
||||||
'related_id': "clinic.hd.case,%s"%obj.id,
|
'related_id': "clinic.hd.case,%s"%obj.id,
|
||||||
|
'ref': obj.number,
|
||||||
'direct_lines': [],
|
'direct_lines': [],
|
||||||
}
|
}
|
||||||
vals['direct_lines'].append(('create',{
|
vals['direct_lines'].append(('create',{
|
||||||
'description': 'Payment; %s'%obj.number,
|
'description': 'Payment; %s'%obj.number,
|
||||||
'account_id': account_id,
|
'account_id': income_account_id,
|
||||||
'qty': 1,
|
'qty': 1,
|
||||||
'unit_price': pay_amount,
|
'unit_price': pay_amount,
|
||||||
'amount': pay_amount,
|
'amount': pay_amount,
|
||||||
|
@ -351,66 +354,55 @@ class HDCase(Model):
|
||||||
if obj.invoices:
|
if obj.invoices:
|
||||||
for inv in obj.invoices:
|
for inv in obj.invoices:
|
||||||
inv.void()
|
inv.void()
|
||||||
due_date=obj.date[0:10] # XXX
|
due_date=obj.date[1:10] # XXX
|
||||||
# cash, credit
|
# cash, credit
|
||||||
make_invoice=context.get('make_invoice',True)
|
is_credit=context.get('is_credit') or False
|
||||||
context['type']='out'
|
context['type']='out'
|
||||||
context['inv_type']='invoice'
|
context['inv_type']='invoice'
|
||||||
fee_lines=[]
|
lines1=[] #yes
|
||||||
mdc_lines=[]
|
lines2=[] #no
|
||||||
if obj.lines:
|
|
||||||
vals={
|
|
||||||
"type": "out",
|
|
||||||
"inv_type": "invoice",
|
|
||||||
"tax_type": "tax_in",
|
|
||||||
'due_date': due_date,
|
|
||||||
"ref": obj.number,
|
|
||||||
"related_id": "clinic.hd.case,%s"%obj.id,
|
|
||||||
"currency_id": currency_id,
|
|
||||||
"company_id": company_id,
|
|
||||||
"lines": [],
|
|
||||||
"company_id": company_id,
|
|
||||||
}
|
|
||||||
partner=obj.patient_id.partner_id
|
|
||||||
if not partner:
|
|
||||||
raise Exception("No contact for patient %s"%obj.patient_id.name)
|
|
||||||
vals["partner_id"]=partner.id
|
|
||||||
|
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
if line.product_id:
|
if line.state!='draft':
|
||||||
account_id=line.product_id.sale_account_id.id or account_receivable_id
|
continue
|
||||||
else:
|
if line.reimbursable=='yes':
|
||||||
account_id=account_receivable_id
|
lines1.append(('create',{
|
||||||
inv_line={
|
|
||||||
"product_id": line.product_id.id,
|
"product_id": line.product_id.id,
|
||||||
"description": line.description,
|
"description": line.description,
|
||||||
|
'product_categ_code': line.product_categ_id.code,
|
||||||
|
"qty": line.qty,
|
||||||
|
"uom_id": line.uom_id.id,
|
||||||
|
"unit_price": line.price,
|
||||||
|
"amount": line.amount,
|
||||||
|
#'account_id': account_id,
|
||||||
|
}))
|
||||||
|
else:
|
||||||
|
vals={
|
||||||
|
"product_id": line.product_id.id,
|
||||||
|
'product_categ_code': line.product_categ_id.code,
|
||||||
|
"description": line.description,
|
||||||
"qty": line.qty,
|
"qty": line.qty,
|
||||||
"uom_id": line.uom_id.id,
|
"uom_id": line.uom_id.id,
|
||||||
"unit_price": line.price,
|
"unit_price": line.price,
|
||||||
"amount": line.amount,
|
"amount": line.amount,
|
||||||
'account_id': account_id,
|
|
||||||
}
|
}
|
||||||
|
prod=line.product_id
|
||||||
|
sale_account=prod.sale_account_id
|
||||||
|
if not sale_account:
|
||||||
|
raise Exception("Not found sale account in product (%s) %s"%(prod.code,prod.name))
|
||||||
|
|
||||||
if obj.invoice_policy=='fee':
|
vals['account_id']=sale_account.id
|
||||||
if line.type=='fee':
|
lines2.append(('create',vals))
|
||||||
fee_lines.append(inv_line)
|
|
||||||
else:
|
|
||||||
vals['lines'].append(('create',inv_line))
|
|
||||||
elif obj.invoice_policy=='fee_mdc':
|
|
||||||
if line.type=='fee':
|
|
||||||
fee_lines.append(inv_line)
|
|
||||||
elif line.type=='medicine':
|
|
||||||
mdc_lines.append(inv_line)
|
|
||||||
else:
|
|
||||||
vals['lines'].append(('create',inv_line))
|
|
||||||
else:
|
|
||||||
vals['lines'].append(('create',inv_line))
|
|
||||||
|
|
||||||
if obj.amount and make_invoice: ## not pay yet
|
patient=obj.patient_id
|
||||||
get_model("account.invoice").create(vals,context)
|
|
||||||
# check if type of product is stockable then create picking
|
|
||||||
obj.make_pickings()
|
|
||||||
|
|
||||||
|
if lines1:
|
||||||
|
ptype=patient.type_id
|
||||||
|
partner=ptype.contact_id
|
||||||
|
if not partner:
|
||||||
|
raise Exception("No contact for patient type %s"%obj.ptype.name)
|
||||||
|
account_mdc_id=partner.account_mdc_id.id
|
||||||
|
account_fee_id=partner.account_fee_id.id
|
||||||
|
account_service_id=partner.account_service_id.id
|
||||||
vals={
|
vals={
|
||||||
"type": "out",
|
"type": "out",
|
||||||
"inv_type": "invoice",
|
"inv_type": "invoice",
|
||||||
|
@ -423,33 +415,52 @@ class HDCase(Model):
|
||||||
"lines": [],
|
"lines": [],
|
||||||
"company_id": company_id,
|
"company_id": company_id,
|
||||||
}
|
}
|
||||||
|
vals["partner_id"]=partner.id
|
||||||
|
for mode,line1 in lines1:
|
||||||
|
categ_code=line1['product_categ_code']
|
||||||
|
if categ_code=='EPO':
|
||||||
|
line1['account_id']=account_mdc_id
|
||||||
|
elif categ_code=='FEE':
|
||||||
|
line1['account_id']=account_fee_id
|
||||||
|
elif categ_code=='SRV':
|
||||||
|
line1['account_id']=account_service_id
|
||||||
|
else:
|
||||||
|
line1['account_id']=account_receivable_id
|
||||||
|
del line1['product_categ_code']
|
||||||
|
vals['lines']=lines1
|
||||||
|
get_model("account.invoice").create(vals,context)
|
||||||
|
|
||||||
if obj.invoice_option=='fee_mdc_plus':
|
if lines2 and is_credit:
|
||||||
fee_lines+=mdc_lines
|
partner=patient.partner_id
|
||||||
mdc_lines=[]
|
if not partner:
|
||||||
|
raise Exception("No contact for this patient %s"%obj.partner.name)
|
||||||
|
vals={
|
||||||
|
"type": "out",
|
||||||
|
"inv_type": "invoice",
|
||||||
|
"tax_type": "tax_in",
|
||||||
|
'due_date': due_date,
|
||||||
|
"ref": obj.number,
|
||||||
|
"related_id": "clinic.hd.case,%s"%obj.id,
|
||||||
|
"currency_id": currency_id,
|
||||||
|
"company_id": company_id,
|
||||||
|
"lines": [],
|
||||||
|
"company_id": company_id,
|
||||||
|
'partner_id':partner.id,
|
||||||
|
}
|
||||||
|
for mode,line2 in lines2:
|
||||||
|
categ_code=line2['product_categ_code']
|
||||||
|
if not line2.get("account_id"):
|
||||||
|
line2['account_id']=account_receivable_id
|
||||||
|
del line2['product_categ_code'] #XXX
|
||||||
|
vals['lines']=lines2
|
||||||
|
get_model("account.invoice").create(vals,context) # create alway
|
||||||
|
|
||||||
contact=obj.patient_id.type_id.contact_id
|
|
||||||
account_id=contact.account_receivable_id.id or account_receivable_id
|
|
||||||
if not account_id:
|
|
||||||
raise Exception("Not found account receive")
|
|
||||||
|
|
||||||
if mdc_lines:
|
obj.make_pickings()
|
||||||
inv_vals=vals.copy()
|
# prevent douplicate create invoice & picking
|
||||||
inv_vals["partner_id"]=obj.fee_partner_id.id
|
for line in obj.lines:
|
||||||
for mdc_line in mdc_lines:
|
line.write({
|
||||||
mdc_line['account_id']=account_id
|
'state': 'done',
|
||||||
inv_vals['lines'].append(('create',mdc_line))
|
|
||||||
get_model("account.invoice").create(inv_vals,context)
|
|
||||||
|
|
||||||
if fee_lines and not obj.fee_paid:
|
|
||||||
inv_vals=vals.copy()
|
|
||||||
inv_vals["partner_id"]=obj.fee_partner_id.id
|
|
||||||
for fee_line in fee_lines:
|
|
||||||
fee_line['account_id']=account_id
|
|
||||||
inv_vals['lines'].append(('create',fee_line))
|
|
||||||
get_model("account.invoice").create(inv_vals,context)
|
|
||||||
obj.write({
|
|
||||||
'fee_paid': True,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
def make_pickings(self,ids,context={}):
|
def make_pickings(self,ids,context={}):
|
||||||
|
@ -486,6 +497,9 @@ class HDCase(Model):
|
||||||
|
|
||||||
|
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
|
if line.state!='draft':
|
||||||
|
continue
|
||||||
|
|
||||||
prod=line.product_id
|
prod=line.product_id
|
||||||
|
|
||||||
if prod.type != 'stock':
|
if prod.type != 'stock':
|
||||||
|
@ -590,8 +604,6 @@ class HDCase(Model):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def do_expense(self,ids,context={}):
|
def do_expense(self,ids,context={}):
|
||||||
return
|
|
||||||
#TODO
|
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
# clear old expense
|
# clear old expense
|
||||||
for exp in obj.expenes:
|
for exp in obj.expenes:
|
||||||
|
@ -600,17 +612,20 @@ class HDCase(Model):
|
||||||
fee=0.0
|
fee=0.0
|
||||||
mdc=0.0
|
mdc=0.0
|
||||||
srv=0.0
|
srv=0.0
|
||||||
|
other=0.0
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
amt=line.amount or 0.0
|
amt=line.amount or 0.0
|
||||||
ltype=line.type
|
if line.reimbursable=='no':
|
||||||
if ltype=='fee':
|
amt=0
|
||||||
|
categ=line.product_categ_id
|
||||||
|
if categ.code=='FEE':
|
||||||
fee+=amt
|
fee+=amt
|
||||||
elif ltype=='medicine':
|
elif categ.code=='EPO':
|
||||||
mdc+=amt
|
mdc+=amt
|
||||||
elif ltype=='service':
|
elif categ.code=='SRV':
|
||||||
srv+=amt
|
srv+=amt
|
||||||
elif ltype=='others':
|
else:
|
||||||
pass
|
other+=amt
|
||||||
exp_lines.append(('create',{
|
exp_lines.append(('create',{
|
||||||
'date': obj.date,
|
'date': obj.date,
|
||||||
'patient_id': obj.patient_id.id,
|
'patient_id': obj.patient_id.id,
|
||||||
|
@ -676,10 +691,16 @@ class HDCase(Model):
|
||||||
|
|
||||||
def undo(self,ids,context={}):
|
def undo(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
for line in obj.lines:
|
||||||
|
line.write({
|
||||||
|
'state': 'draft',
|
||||||
|
})
|
||||||
for inv in obj.invoices:
|
for inv in obj.invoices:
|
||||||
inv.write({
|
inv.write({
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
})
|
})
|
||||||
|
inv.move_id.to_draft()
|
||||||
|
inv.move_id.delete()
|
||||||
inv.delete()
|
inv.delete()
|
||||||
for pick in obj.pickings:
|
for pick in obj.pickings:
|
||||||
pick.write({
|
pick.write({
|
||||||
|
@ -698,7 +719,6 @@ class HDCase(Model):
|
||||||
state=context.get("state","in_progress") #force state
|
state=context.get("state","in_progress") #force state
|
||||||
obj.write({
|
obj.write({
|
||||||
'state': state,
|
'state': state,
|
||||||
'fee_paid': False,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -924,9 +944,16 @@ class HDCase(Model):
|
||||||
|
|
||||||
def write(self,ids,vals,**kw):
|
def write(self,ids,vals,**kw):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
super().write(ids,vals,**kw)
|
vals['req_fee']=0
|
||||||
if not obj.amount:
|
if 'lines' in vals.keys():
|
||||||
|
for mode, line_ids, line_vals in vals['lines']:
|
||||||
|
if line_vals['reimbursable']=='no':
|
||||||
vals['req_fee']=1 # to show button pay
|
vals['req_fee']=1 # to show button pay
|
||||||
|
else:
|
||||||
|
for line in obj.lines:
|
||||||
|
if line.reimbursable=='no':
|
||||||
|
vals['req_fee']=1
|
||||||
|
super().write(ids,vals,**kw)
|
||||||
|
|
||||||
def approve(self,ids,context={}):
|
def approve(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
|
|
@ -13,11 +13,13 @@ class Hdcaseline(Model):
|
||||||
"type": fields.Selection([("fee","Fee"),('medicine','Medicine'),('service','Service'),("others","Others")],"Type",required=True),
|
"type": fields.Selection([("fee","Fee"),('medicine','Medicine'),('service','Service'),("others","Others")],"Type",required=True),
|
||||||
"product_categ_id": fields.Many2One("product.categ","Category",domain=[['expense','=',True]]),
|
"product_categ_id": fields.Many2One("product.categ","Category",domain=[['expense','=',True]]),
|
||||||
'reimbursable': fields.Selection([['yes','Yes'],['no','No']],"Reimbursable"),
|
'reimbursable': fields.Selection([['yes','Yes'],['no','No']],"Reimbursable"),
|
||||||
|
'state': fields.Selection([['draft','Draft'],['done','Done']],"State"),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
'type': 'others',
|
'type': 'others',
|
||||||
'reimbursable': 'no',
|
'reimbursable': 'no',
|
||||||
|
'state': 'draft',
|
||||||
}
|
}
|
||||||
|
|
||||||
Hdcaseline.register()
|
Hdcaseline.register()
|
||||||
|
|
|
@ -7,7 +7,6 @@ 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("Due Amount"),
|
"pay_amount": fields.Float("Due Amount"),
|
||||||
"fee": fields.Float("Fee"),
|
|
||||||
"to_pay": fields.Float("To Pay"),
|
"to_pay": fields.Float("To Pay"),
|
||||||
"complete": fields.Boolean("Mark as full payment for Cash"),
|
"complete": fields.Boolean("Mark as full payment for Cash"),
|
||||||
}
|
}
|
||||||
|
@ -21,22 +20,16 @@ class HDCasePayment(Model):
|
||||||
def _get_pay_amount(self,context={}):
|
def _get_pay_amount(self,context={}):
|
||||||
hd_case_id=context.get("refer_id")
|
hd_case_id=context.get("refer_id")
|
||||||
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.due_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={}):
|
def _get_topay(self,context={}):
|
||||||
hd_case_id=context.get("refer_id")
|
hd_case_id=context.get("refer_id")
|
||||||
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.due_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,
|
'to_pay': _get_topay,
|
||||||
'complete': True,
|
'complete': True,
|
||||||
}
|
}
|
||||||
|
@ -45,17 +38,21 @@ class HDCasePayment(Model):
|
||||||
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)
|
||||||
context['amount']=obj.pay_amount or 0.0
|
context['amount']=obj.pay_amount or 0.0
|
||||||
context['make_invoice']=False
|
context['is_credit']=False
|
||||||
hd_case.make_invoices(context=context) #XXX
|
hd_case.make_invoices(context=context) #XXX
|
||||||
hd_case.post_invoices()
|
hd_case.post_invoices()
|
||||||
if obj.pay_amount:
|
if obj.pay_amount:
|
||||||
hd_case.make_payment(context=context)
|
hd_case.make_payment(context=context)
|
||||||
if obj.complete:
|
if obj.complete:
|
||||||
hd_case.create_cycle_item()
|
hd_case.create_cycle_item()
|
||||||
if obj.pay_amount==obj.to_pay:
|
if obj.pay_amount==hd_case.total_amount: #XXX
|
||||||
vals={
|
vals={
|
||||||
'state': 'paid',
|
'state': 'paid',
|
||||||
}
|
}
|
||||||
|
else:
|
||||||
|
vals={
|
||||||
|
'state': 'waiting_payment',
|
||||||
|
}
|
||||||
hd_case.write(vals)
|
hd_case.write(vals)
|
||||||
hd_case.do_expense()
|
hd_case.do_expense()
|
||||||
obj.write({
|
obj.write({
|
||||||
|
@ -73,7 +70,8 @@ class HDCasePayment(Model):
|
||||||
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()
|
context['is_credit']=True
|
||||||
|
hd_case.make_invoices(context=context)
|
||||||
hd_case.post_invoices()
|
hd_case.post_invoices()
|
||||||
hd_case.create_cycle_item()
|
hd_case.create_cycle_item()
|
||||||
if obj.pay_amount==obj.to_pay:
|
if obj.pay_amount==obj.to_pay:
|
||||||
|
@ -95,7 +93,6 @@ class HDCasePayment(Model):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
pay_amount=data['pay_amount'] or 0.0
|
pay_amount=data['pay_amount'] or 0.0
|
||||||
data['pay_amount']=pay_amount
|
data['pay_amount']=pay_amount
|
||||||
data['to_pay']=pay_amount
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
HDCasePayment.register()
|
HDCasePayment.register()
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
categ_id
|
create button reset at setting
|
||||||
product_id
|
- backup master data
|
||||||
ca
|
- patient
|
||||||
|
- staff/nurse/doctor
|
||||||
|
- account
|
||||||
|
- journal
|
||||||
|
- product
|
||||||
|
---
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue