conv_bal
watcha.h 2014-10-22 15:55:57 +07:00
parent 4d5f770d89
commit e6dbec5eef
14 changed files with 313 additions and 120 deletions

View File

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

View File

@ -0,0 +1,5 @@
<action>
<field name="type">method</field>
<field name="model">clinic.hd.case</field>
<field name="method">view_payment</field>
</action>

View File

@ -2,6 +2,7 @@
<head> <head>
<field name="state"/> <field name="state"/>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="Get Dialyzer" action="clinic_get_dlz"/>
<!--<item string="Print Payment" method="print_payment"/>--> <!--<item string="Print Payment" method="print_payment"/>-->
</button> </button>
</head> </head>
@ -44,32 +45,10 @@
</list> </list>
</field> </field>
</tab> </tab>
<tab string="Fees"> <tab string="Expenses">
<field name="gm_lines" count="3" nolabel="1">
<list>
<field name="product_id" onchange="onchange_gmproduct"/>
<field name="description"/>
<field name="qty" onchange="onchange_gmline"/>
<field name="uom_id"/>
<field name="price" onchange="onchange_gmline"/>
<field name="amount"/>
</list>
</field>
<group span="8" columns="1">
<group span="6" columns="1">
<field name="fee_partner_id" domain="[['type','=','org']]" attrs='{"required":[["fee_amount","!=",0]]}'/>
</group>
<group span="2" columns="1">
</group>
</group>
<group span="4" columns="1">
<field name="fee_total"/>
<field name="fee_amount"/>
</group>
</tab>
<tab string="Other Expenses">
<field name="lines" count="3" nolabel="1"> <field name="lines" count="3" nolabel="1">
<list> <list>
<field name="type" onchange="onchange_line"/>
<field name="product_id" onchange="onchange_product"/> <field name="product_id" onchange="onchange_product"/>
<field name="description"/> <field name="description"/>
<field name="qty" onchange="onchange_line"/> <field name="qty" onchange="onchange_line"/>
@ -83,10 +62,11 @@
<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="Add Payment" method="make_payment" icon="ok" size="small" type="success"/> <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"/>
<field name="fee_amount"/>
<field name="payment_lines" nolabel="1"> <field name="payment_lines" nolabel="1">
<template> <template>
{{#each context.data}} {{#each context.data}}
@ -104,12 +84,19 @@
<field name="amount"/> <field name="amount"/>
</group> </group>
</tab> </tab>
<tab string="Notes"> <tab string="Other Info">
<field name="note" nolabel="1"/> <group span="6" columns="1">
<separator string="Fees"/>
<field name="fee_partner_id" domain="[['type','=','org']]"/>
</group>
<group span="6" columns="1">
<separator string="Note"/>
<field name="note" nolabel="1"/>
</group>
</tab> </tab>
</tabs> </tabs>
<foot> <foot>
<button string="Do Treatment" type="success" icon="arrow-right" method="do_treatment" states="draft"/> <button string="Process" type="success" icon="arrow-right" method="do_treatment" states="draft"/>
<button string="Complete" type="success" icon="ok" method="complete" 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"/>
@ -117,7 +104,7 @@
<related> <related>
<field name="invoices" click_action="view_invoice"/> <field name="invoices" click_action="view_invoice"/>
<field name="pickings" click_action="view_picking"/> <field name="pickings" click_action="view_picking"/>
<field name="payments" click_action="view_payment"/> <field name="payments" click_action="clinic_view_payment"/>
<field name="comments"/> <field name="comments"/>
</related> </related>
</form> </form>

View File

@ -0,0 +1,132 @@
<form model="clinic.hd.case" attrs='{"readonly":[["state","in",["uncompleted","completed"]]]}' show_company="1">
<head>
<field name="state"/>
<button string="Options" dropdown="1">
<!--<item string="Print Payment" method="print_payment"/>-->
</button>
</head>
<group span="6" columns="1">
<field name="number"/>
<field name="time_start"/>
<field name="cycle_id" required="1"/>
<field name="department_id"/>
<field name="visit_id" readonly="1"/>
</group>
<group span="6" columns="1">
<field name="patient_id" onchange="onchange_patient"/>
<field name="time_stop"/>
<field name="duration"/>
<field name="doctor_id"/>
<field name="nurse_id"/>
</group>
<tabs>
<tab string="General">
<field name="wh_start"/>
<field name="wh_stop"/>
<field name="bp_start"/>
<field name="per_bp_start"/>
<field name="bp_stop"/>
<field name="per_bp_stop"/>
<field name="hct" onchange="onchange_hct"/>
<newline/>
<field offset="2" name="hct_msg" nolabel="1" readonly="1"/>
<field name="dialyzers" nolabel="1">
<list>
<field name="dialyzer_id" domain="[['patient_id','=',parent.patient_id],['state','=','active']]" onchange="onchange_dialyzer"/>
<field name="description"/>
<field name="use_time"/>
<field name="max_use_time"/>
<field name="member_type"/>
<field name="dialyzer_type"/>
<field name="bid_flow_rate"/>
<field name="ultrafittration"/>
<field name="state"/>
</list>
</field>
</tab>
<tab string="Expenes">
<field name="gm_lines" count="3" nolabel="1">
<list>
<field name="product_id" onchange="onchange_gmproduct"/>
<field name="description"/>
<field name="qty" onchange="onchange_gmline"/>
<field name="uom_id"/>
<field name="price" onchange="onchange_gmline"/>
<field name="amount"/>
</list>
</field>
<group span="8" columns="1">
<group span="6" columns="1">
<!--<field name="fee_partner_id" domain="[['type','=','org']]" attrs='{"required":[["fee_amount","!=",0]]}'/>-->
</group>
<group span="2" columns="1">
</group>
</group>
<group span="4" columns="1">
<field name="fee_total"/>
<field name="fee_amount"/>
</group>
</tab>
<tab string="Other Expenses">
<field name="lines" count="3" nolabel="1">
<list>
<field name="product_id" onchange="onchange_product"/>
<field name="description"/>
<field name="qty" onchange="onchange_line"/>
<field name="uom_id"/>
<field name="price" onchange="onchange_line"/>
<field name="amount"/>
</list>
</field>
<group span="8" form_layout="stacked" attrs='{"invisible":[["amount","=",0]]}'>
<separator string="Make a payment"/>
<field name="pay_amount" attrs='{"required":[["amount","!=",0]]}' onchange="onchange_pay" span="3"/>
<field name="pay_date" span="3"/>
<field name="pay_account_id" span="3"/>
<!--<button string="Add Payment" method="make_payment" icon="ok" size="small" type="success"/>-->
<button string="Pay" type="success" icon="ok" action="clinic_payment" states="in_progress"/>
</group>
<group span="4" columns="1">
<field name="total"/>
<field name="payment_lines" nolabel="1">
<template>
{{#each context.data}}
<div class="form-group nf-field">
<label class="control-label col-md-4">Less
<a href="#name=payment&amp;mode=form&amp;active_id={{payment_id.0.}}">Payment</a>
</label>
<div class="col-md-8" style="text-align:right">
{{currency amount}}
</div>
</div>
{{/each}}
</template>
</field>
<field name="amount"/>
</group>
</tab>
<tab string="Other Info">
<group span="6" columns="1">
<separator string="Fees"/>
<!--<field name="fee_partner_id" domain="[['type','=','org']]" attrs='{"required":[["fee_amount","!=",0]]}'/>-->
<field name="fee_partner_id" domain="[['type','=','org']]"/>
</group>
<group span="6" columns="1">
<separator string="Note"/>
<field name="note" nolabel="1"/>
</group>
</tab>
</tabs>
<foot>
<button string="Process" type="success" icon="arrow-right" method="do_treatment" states="draft"/>
<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="Undo" type="default" icon="refresh" method="undo" states="completed"/>
</foot>
<related>
<field name="invoices" click_action="view_invoice"/>
<field name="pickings" click_action="view_picking"/>
<field name="payments" click_action="view_payment"/>
<field name="comments"/>
</related>
</form>

View File

@ -3,6 +3,7 @@
<field name="type"/> <field name="type"/>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="Generate Visit" action="clinic_gen_visit"/> <item string="Generate Visit" action="clinic_gen_visit"/>
<item string="Generate Dialyzer" action="clinic_gen_dialyzer"/>
</button> </button>
</head> </head>
<field name="number"/> <field name="number"/>

View File

@ -0,0 +1,10 @@
<form model="clinic.hd.case.payment">
<field name="hd_case_id" invisible="1"/>
<group form_layout="stacked">
<field name="pay_amount" />
</group>
<foot>
<button string="Cash" type="success" method="cash" confirm="Are you sure?"/>
<button string="Credit" type="primary" method="credit"/>
</foot>
</form>

View File

@ -1,8 +1,11 @@
<inherit model="settings" inherit="fin_settings"> <inherit model="settings" inherit="fin_settings">
<field name="retained_earnings_account_id" position="after"> <field name="retained_earnings_account_id" position="after">
<separator string="Clinic"/> <separator string="Clinic"/>
<field name="mg_account_id"/> <field name="ar_mg_id"/>
<field name="sc_account_id"/> <field name="ap_mg_id"/>
<field name="nhso_account_id"/> <field name="ar_sc_id"/>
<field name="ap_sc_id"/>
<field name="ar_nhso_id"/>
<field name="ap_nhso_id"/>
</field> </field>
</inherit> </inherit>

View File

@ -20,6 +20,7 @@ from . import hd_case
from . import hd_case_line from . import hd_case_line
from . import hd_case_gmline from . import hd_case_gmline
from . import hd_case_discont from . import hd_case_discont
from . import hd_case_payment
from . import dialyzer from . import dialyzer
from . import dialyzer_line from . import dialyzer_line
from . import import_payment from . import import_payment
@ -30,10 +31,10 @@ from . import gen_visit_line
from . import report_hd_detail from . import report_hd_detail
from . import report_hd_summary from . import report_hd_summary
from . import report_hd_madical from . import report_hd_madical
from . import payment
from . import input_data from . import input_data
from . import fin_setting from . import fin_setting
from . import import_data_mg from . import import_data_mg
from . import import_data_nhso from . import import_data_nhso
from . import import_data_sc from . import import_data_sc
from . import translate from . import translate
from . import payment

View File

@ -3,9 +3,12 @@ from netforce.model import Model, fields
class Settings(Model): class Settings(Model):
_inherit="settings" _inherit="settings"
_fields={ _fields={
"mg_account_id": fields.Many2One("account.account","Account Payment Medical Government"), "ap_mg_id": fields.Many2One("account.account","Account Payment Medical Government"),
"nhso_account_id": fields.Many2One("account.account","Account Payment NHSO 30B"), "ap_nhso_id": fields.Many2One("account.account","Account Payment NHSO 30B"),
"sc_account_id": fields.Many2One("account.account","Account Payment Social Security"), "ap_sc_id": fields.Many2One("account.account","Account Payment Social Security"),
"ar_mg_id": fields.Many2One("account.account","Account Recieve Medical Government"),
"ar_nhso_id": fields.Many2One("account.account","Account Recieve NHSO 30B"),
"ar_sc_id": fields.Many2One("account.account","Account Recieve Social Security"),
} }
Settings.register() Settings.register()

View File

@ -22,6 +22,12 @@ class HDcase(Model):
res[obj.id]=total_time res[obj.id]=total_time
return res return res
def get_pay_amount(self,ids,context={}):
res={}
for obj in self.browse(ids):
res[obj.id]=obj.amount
return res
_fields={ _fields={
"number": fields.Char("Number",required=True,search=True), "number": fields.Char("Number",required=True,search=True),
@ -47,7 +53,6 @@ class HDcase(Model):
"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"),("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"),
"gm_lines": fields.One2Many("clinic.hd.case.gm.line","hd_case_id","GM Lines"),
"comments": fields.One2Many("message","related_id","Comments"), "comments": fields.One2Many("message","related_id","Comments"),
"company_id": fields.Many2One("company","Company"), "company_id": fields.Many2One("company","Company"),
"amount": fields.Float("Due Amount",function="get_total",readonly=True,function_multi=True), "amount": fields.Float("Due Amount",function="get_total",readonly=True,function_multi=True),
@ -61,11 +66,10 @@ class HDcase(Model):
'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_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("Due Amount",function="get_gmtotal",readonly=True,function_multi=True), "fee_amount": fields.Float("Fee",function="get_total",readonly=True,function_multi=True),
"fee_total": fields.Float("Total",function="get_gmtotal",readonly=True,function_multi=True),
'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"), 'pay_amount': fields.Float("Amount",function="get_pay_amount"),
'pay_date': fields.Date("Pay Date"), 'pay_date': fields.Date("Pay Date"),
'pay_account_id': fields.Many2One("account.account","Account"), 'pay_account_id': fields.Many2One("account.account","Account"),
} }
@ -166,15 +170,21 @@ class HDcase(Model):
def onchange_line(self,context={}): def onchange_line(self,context={}):
data=context['data'] data=context['data']
total=0.0 total=0.0
fee_amt=0.0
for line in data['lines']: for line in data['lines']:
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") #product_id=line.get("product_id")
if product_id: #if product_id:
line['amount']=amt line['amount']=amt
total+=amt if line['type']=='fee':
fee_amt+=amt
else:
total+=amt
data['total']=total data['total']=total
data['fee_amount']=fee_amt
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
@ -191,8 +201,6 @@ class HDcase(Model):
settings=get_model("settings").browse(1) settings=get_model("settings").browse(1)
account_id=settings.account_receivable_id account_id=settings.account_receivable_id
data['pay_account_id']=account_id.id data['pay_account_id']=account_id.id
#pay_amount=total
#data['pay_amount']=pay_amount
return data return data
def onchange_pay(self,context={}): def onchange_pay(self,context={}):
@ -219,6 +227,10 @@ class HDcase(Model):
account_id=obj.pay_account_id.id account_id=obj.pay_account_id.id
if not account_id: if not account_id:
raise Exception("No Account for payment") raise Exception("No Account for payment")
pay_amount=obj.pay_amount
# XXX get from popup
if context.get("amount",0):
pay_amount=context['amount'] or 0.0
vals={ vals={
"partner_id": partner_id, "partner_id": partner_id,
"company_id": company_id, "company_id": company_id,
@ -233,17 +245,17 @@ class HDcase(Model):
'description': 'Payment; %s'%obj.number, 'description': 'Payment; %s'%obj.number,
'account_id': account_id, 'account_id': account_id,
'qty': 1, 'qty': 1,
'unit_price': obj.pay_amount, 'unit_price': pay_amount,
'amount': obj.pay_amount, 'amount': pay_amount,
})) }))
payment_id=get_model("account.payment").create(vals,context={"type":"in"}) payment_id=get_model("account.payment").create(vals,context={"type":"in"})
obj.write({ obj.write({
#'pay_amount': remaining_amt-obj.pay_amount, #'pay_amount': remaining_amt-obj.pay_amount,
'pay_amount': 0, # reset #'pay_amount': 0, # reset
'payment_lines': [('create',{ 'payment_lines': [('create',{
'payment_id': payment_id, 'payment_id': payment_id,
'amount': obj.pay_amount, 'amount': pay_amount,
})], })],
}) })
return { return {
@ -275,21 +287,6 @@ class HDcase(Model):
data=self.onchange_gmline(context) data=self.onchange_gmline(context)
return data return data
def onchange_gmline(self,context={}):
data=context['data']
total=0.0
for line in data['gm_lines']:
price=line.get('price') or 0
qty=line.get('qty') or 0
amt=qty * price
product_id=line.get("product_id")
if product_id:
line['amount']=amt
total+=amt
data['fee_total']=total
data['fee_amount']=total
return data
def make_invoices(self,ids,context={}): def make_invoices(self,ids,context={}):
setting=get_model("settings").browse(1) setting=get_model("settings").browse(1)
currency_id=setting.currency_id.id currency_id=setting.currency_id.id
@ -303,8 +300,7 @@ class HDcase(Model):
context['type']='out' context['type']='out'
context['inv_type']='invoice' context['inv_type']='invoice'
# TODO payment without invoice if obj.lines and obj.amount:
if obj.lines and obj.total:
vals={ vals={
"type": "out", "type": "out",
"inv_type": "invoice", "inv_type": "invoice",
@ -321,11 +317,13 @@ class HDcase(Model):
if not partner: if not partner:
raise Exception("No contact for patient %s"%obj.patient_id.name) raise Exception("No contact for patient %s"%obj.patient_id.name)
vals["partner_id"]=partner.id vals["partner_id"]=partner.id
fee_lines=[]
for line in obj.lines: for line in obj.lines:
account_id=line.product_id.sale_account_id.id or account_receivable_id if line.product_id:
if not account_id: account_id=line.product_id.sale_account_id.id or account_receivable_id
raise Exception("%s not found account recievable %s"%partner.name) else:
line={ account_id=account_receivable_id
inv_line={
"product_id": line.product_id.id, "product_id": line.product_id.id,
"description": line.description, "description": line.description,
"qty": line.qty, "qty": line.qty,
@ -334,11 +332,16 @@ class HDcase(Model):
"amount": line.amount, "amount": line.amount,
'account_id': account_id, 'account_id': account_id,
} }
vals['lines'].append(('create',line)) if line.type=='fee':
fee_lines.append(inv_line)
else:
vals['lines'].append(('create',inv_line))
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 obj.fee_total:
if fee_lines:
vals={ vals={
"type": "out", "type": "out",
"inv_type": "invoice", "inv_type": "invoice",
@ -352,22 +355,20 @@ 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
if not obj.fee_partner_id.account_receivable_id: #XXX
account_id=obj.fee_partner_id.account_receivable_id.id or account_receivable_id
if not account_id: account_id=account_receivable_id
raise Exception("%s not found account recievable %s"%obj.fee_partner_id.name) patient_type=obj.patient_id.type
for line in obj.gm_lines: if patient_type=='mg':
prod=line.product_id account_id=setting.ar_mg_id.id
inv_line={ elif patient_type=='sc':
"product_id": prod.id, account_id=setting.ar_sc_id.id
"description": prod.name, elif patient_type=='nhso':
"qty": 1, account_id=setting.ar_nhso_id.id
"uom_id": prod.uom_id.id,
"unit_price": line.price, for fee_line in fee_lines:
"amount": line.amount, fee_line['account_id']=account_id
'account_id': account_id, # XXX vals['lines'].append(('create',fee_line))
}
vals['lines'].append(('create',inv_line))
inv_id=get_model("account.invoice").create(vals,context) inv_id=get_model("account.invoice").create(vals,context)
def make_pickings(self,ids,context={}): def make_pickings(self,ids,context={}):
@ -490,34 +491,23 @@ class HDcase(Model):
vals={} vals={}
for obj in self.browse(ids): for obj in self.browse(ids):
total=0 total=0
amt=0 due_amt=0
fee_amt=0
for line in obj.lines: for line in obj.lines:
if line.type=='fee':
fee_amt+=line.amount or 0.0
total+=line.amount or 0.0 total+=line.amount or 0.0
amt=total
due_amt=total-fee_amt
for line in obj.payment_lines: for line in obj.payment_lines:
amt-=line.amount or 0.0 due_amt-=line.amount or 0.0
vals[obj.id]={ vals[obj.id]={
"total": total, "total": total,
"amount": amt, "amount": due_amt,
'fee_amount': fee_amt,
} }
return vals return vals
def get_gmtotal(self,ids,context={}):
vals={}
for obj in self.browse(ids):
total=0
amt=0
fee=obj.fee or 0
for line in obj.gm_lines:
total+=line.amount or 0
fee=0 # XXX
amt=total+fee
vals[obj.id]={
"fee_total": total,
"fee_amount": amt,
}
return vals
def delete(self,ids,context={}): def delete(self,ids,context={}):
for obj in self.browse(ids): for obj in self.browse(ids):
if obj.state != 'draft': if obj.state != 'draft':
@ -568,7 +558,7 @@ class HDcase(Model):
pm_line.delete() pm_line.delete()
obj.write({ obj.write({
'state': 'draft', 'state': 'in_progress',
}) })
return { return {
'next': { 'next': {
@ -578,5 +568,9 @@ class HDcase(Model):
}, },
'flash': '%s has been undo'%obj.number, 'flash': '%s has been undo'%obj.number,
} }
def view_payment(self,ids,context={}):
print("clinic_view_payment")
pass
HDcase.register() HDcase.register()

View File

@ -10,6 +10,11 @@ class Hdcaseline(Model):
"uom_id": fields.Many2One("uom","UOM",required=True,search=True), "uom_id": fields.Many2One("uom","UOM",required=True,search=True),
"price":fields.Float("Price"), "price":fields.Float("Price"),
"amount":fields.Float("Amount"), "amount":fields.Float("Amount"),
"type": fields.Selection([("fee","Fee"),("other","Other")],"Type",required=True),
}
_defaults={
'type': 'other',
} }
Hdcaseline.register() Hdcaseline.register()

View File

@ -0,0 +1,53 @@
from netforce.model import Model, fields, get_model
class HDCasePayment(Model):
_name="clinic.hd.case.payment"
_transient=True
_fields={
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
"pay_amount": fields.Float("Amount"),
}
def _get_hd_case_id(self,context={}):
hd_case_id=context.get("refer_id")
if not hd_case_id:
return None
return int(hd_case_id)
def _get_pay_amount(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={
'hd_case_id': _get_hd_case_id,
'pay_amount': _get_pay_amount,
}
def cash(self,ids,context):
obj=self.browse(ids)[0]
hd_case=get_model("clinic.hd.case").browse(obj.hd_case_id.id)
context['amount']=obj.pay_amount or 0.0
print(">><< ", obj.pay_amount)
hd_case.make_payment(context=context)
obj.write({
'pay_amount': hd_case.amount,
})
print(":: ", context['amount']-obj.pay_amount)
if not obj.pay_amount:
return {
'next': {
'name': 'clinic_hd_case',
'mode': 'form',
'active_id': hd_case.id,
},
'flash': 'Paid',
}
def credit(self,ids,context):
obj=self.browse(ids)[0]
hd_case=get_model("clinic.hd.case").browse(obj.hd_case_id.id)
HDCasePayment.register()

View File

@ -31,7 +31,7 @@ class ImportPayment(Model):
curr_row=-1 curr_row=-1
while curr_row < num_rows: while curr_row < num_rows:
curr_row +=1 curr_row +=1
worksheet.cell_value(curr_row,1) worksheet.cell_value(curr_row,2)
return data return data
def read_xml(self,fpath=None): def read_xml(self,fpath=None):

View File

@ -104,14 +104,7 @@ class Visit(Model):
} }
obj.write(vals) obj.write(vals)
hd_case_obj=get_model("clinic.hd.case") hd_case_obj=get_model("clinic.hd.case")
#dt=datetime
#datenow=dt.now().strftime("%Y-%m-%d")
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
#date_visit=obj.time_start[0:10]
# cannot treatment if current date is not same visit date
#if date_visit!=datenow:
#raise Exception("Today is not treament date!")
vals={ vals={
'patient_id': obj.patient_id.id, 'patient_id': obj.patient_id.id,
'doctor_id': obj.doctor_id.id, 'doctor_id': obj.doctor_id.id,
@ -124,14 +117,14 @@ class Visit(Model):
'cycle_id': obj.cycle_id.id, 'cycle_id': obj.cycle_id.id,
'fee_type': obj.patient_id.type, 'fee_type': obj.patient_id.type,
'lines':[], 'lines':[],
'gm_lines':[],
'dialyzers': [], 'dialyzers': [],
'state': 'draft', 'state': 'draft',
} }
products=get_model("product").search_browse([['code','=','FEE']]) products=get_model("product").search_browse([['code','=','FEE']])
for product in products: for product in products:
vals['gm_lines'].append(('create',{ vals['lines'].append(('create',{
'type': 'fee',
'product_id': product.id, 'product_id': product.id,
'description': product.name or "", 'description': product.name or "",
'qty': 1, 'qty': 1,