create journal entry for nurse payment
parent
1ca2e62554
commit
eca7ccf320
|
@ -3,6 +3,8 @@
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="1">
|
||||||
<item string="Create Journal" method="create_journal" states="draft"/>
|
<item string="Create Journal" method="create_journal" states="draft"/>
|
||||||
|
<item string="View Journal" method="view_journal" states="done"/>
|
||||||
|
<item string="To Draft" method="to_draft" states="done"/>
|
||||||
</button>
|
</button>
|
||||||
</head>
|
</head>
|
||||||
<field name="cycle_id" required="1"/>
|
<field name="cycle_id" required="1"/>
|
||||||
|
@ -10,13 +12,12 @@
|
||||||
<field name="var_k"/>
|
<field name="var_k"/>
|
||||||
<field name="var_x"/>
|
<field name="var_x"/>
|
||||||
<field name="total_pt"/>
|
<field name="total_pt"/>
|
||||||
<field name="total_amount"/>
|
|
||||||
<field name="lines" nolabel="1">
|
<field name="lines" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="nurse_categ"/>
|
<field name="nurse_categ" readonly="1"/>
|
||||||
<field name="formular"/>
|
<field name="formular" readonly="1"/>
|
||||||
<field name="qty"/>
|
<field name="qty" onchange="onchange_line"/>
|
||||||
<field name="rate"/>
|
<field name="rate" onchange="onchange_line"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
|
@ -24,6 +25,8 @@
|
||||||
</group>
|
</group>
|
||||||
<group span="4" columns="1">
|
<group span="4" columns="1">
|
||||||
<field name="total"/>
|
<field name="total"/>
|
||||||
|
<field name="total_amount"/>
|
||||||
|
<field name="total_balance"/>
|
||||||
</group>
|
</group>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Compute" type="default" icon="refresh" method="compute" states="draft"/>
|
<button string="Compute" type="default" icon="refresh" method="compute" states="draft"/>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<list model="clinic.cycle.item">
|
<list model="clinic.cycle.item" colors='{"#9f9":[["state","=","done"]]}'>
|
||||||
<field name="cycle_id" required="1"/>
|
<field name="name"/>
|
||||||
|
<field name="cycle_id"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="var_k"/>
|
<field name="var_k"/>
|
||||||
<field name="var_x"/>
|
<field name="var_x"/>
|
||||||
|
<field name="state"/>
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -7,5 +7,7 @@
|
||||||
<field name="ap_sc_id"/>
|
<field name="ap_sc_id"/>
|
||||||
<field name="ar_nhso_id"/>
|
<field name="ar_nhso_id"/>
|
||||||
<field name="ap_nhso_id"/>
|
<field name="ap_nhso_id"/>
|
||||||
|
<field name="ap_nurse_id"/>
|
||||||
|
<field name="ap_doctor_id"/>
|
||||||
</field>
|
</field>
|
||||||
</inherit>
|
</inherit>
|
||||||
|
|
|
@ -2,14 +2,17 @@ import time
|
||||||
|
|
||||||
from netforce.model import Model, fields, get_model
|
from netforce.model import Model, fields, get_model
|
||||||
from netforce.access import get_active_company
|
from netforce.access import get_active_company
|
||||||
|
from netforce.utils import get_data_path
|
||||||
|
|
||||||
class CycleItem(Model):
|
class CycleItem(Model):
|
||||||
_name="clinic.cycle.item"
|
_name="clinic.cycle.item"
|
||||||
_string="Cycle Item"
|
_string="Cycle Item"
|
||||||
|
_name_field="name"
|
||||||
|
|
||||||
def _get_all(self,ids,context):
|
def _get_all(self,ids,context):
|
||||||
res={}
|
res={}
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
|
name="%s-%s"%(obj.cycle_id.name,obj.date)
|
||||||
hd_total=len([hd_case for hd_case in obj.hd_cases if hd_case.state=='completed']) # XXX
|
hd_total=len([hd_case for hd_case in obj.hd_cases if hd_case.state=='completed']) # XXX
|
||||||
pt=(hd_total or 0.0)
|
pt=(hd_total or 0.0)
|
||||||
k=(obj.var_k or 0.0)
|
k=(obj.var_k or 0.0)
|
||||||
|
@ -19,14 +22,17 @@ class CycleItem(Model):
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
total+=line.amount
|
total+=line.amount
|
||||||
res[obj.id]={
|
res[obj.id]={
|
||||||
|
'name': name,
|
||||||
'var_x': x,
|
'var_x': x,
|
||||||
'total_pt': hd_total,
|
'total_pt': hd_total,
|
||||||
'total_amount': hd_total*k,
|
'total_amount': hd_total*k,
|
||||||
'total': total,
|
'total': total,
|
||||||
|
'total_balance': (hd_total*k)-total,
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
|
'name': fields.Char("Name", function="_get_all",function_multi=True), # need to field related in journal
|
||||||
'company_id': fields.Many2One("company", "Company"),
|
'company_id': fields.Many2One("company", "Company"),
|
||||||
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
|
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
|
||||||
'date': fields.Date("Date",search=True),
|
'date': fields.Date("Date",search=True),
|
||||||
|
@ -34,6 +40,7 @@ class CycleItem(Model):
|
||||||
'var_x': fields.Float("X", function="_get_all",function_multi=True),
|
'var_x': fields.Float("X", function="_get_all",function_multi=True),
|
||||||
'total_pt': fields.Float("PT", function="_get_all",function_multi=True),
|
'total_pt': fields.Float("PT", function="_get_all",function_multi=True),
|
||||||
'total_amount': fields.Float("PT*K", function="_get_all",function_multi=True),
|
'total_amount': fields.Float("PT*K", function="_get_all",function_multi=True),
|
||||||
|
'total_balance': fields.Float("Total Balance", function="_get_all",function_multi=True),
|
||||||
'total': fields.Float("Total", function="_get_all",function_multi=True),
|
'total': fields.Float("Total", function="_get_all",function_multi=True),
|
||||||
"state": fields.Selection([("draft","Draft"),("done","Done")],"Status",required=True),
|
"state": fields.Selection([("draft","Draft"),("done","Done")],"Status",required=True),
|
||||||
'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"),
|
'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"),
|
||||||
|
@ -92,5 +99,94 @@ class CycleItem(Model):
|
||||||
},
|
},
|
||||||
'flash': 'Compute OK',
|
'flash': 'Compute OK',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def onchange_line(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
path=context["path"]
|
||||||
|
line=get_data_path(data,path,parent=True)
|
||||||
|
#qty=line.get("qty")
|
||||||
|
#rate=line.get("rate")
|
||||||
|
total=0.0
|
||||||
|
for line in data['lines']:
|
||||||
|
line['amount']=(line['qty'] or 0) * (line['rate'] or 0.0)
|
||||||
|
total+=line['amount']
|
||||||
|
print(line)
|
||||||
|
data['total']=total
|
||||||
|
data['total_amount']=data['total_pt']*(data['var_k'] or 0)
|
||||||
|
data['total_balance']=data['total_amount']-data['total']
|
||||||
|
return data
|
||||||
|
|
||||||
|
def create_journal(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
settings=get_model("settings").browse(1)
|
||||||
|
account_id=settings.ap_nurse_id.id
|
||||||
|
if not account_id:
|
||||||
|
raise Exception("No Account payment for nurse")
|
||||||
|
vals={
|
||||||
|
"company_id": obj.company_id.id,
|
||||||
|
"type": "in",
|
||||||
|
"pay_type": "direct",
|
||||||
|
#"date": time.strftime("%Y-%m-%d"),
|
||||||
|
"date": obj.date or time.strftime("%Y-%m-%d"),
|
||||||
|
"account_id": account_id,
|
||||||
|
'related_id': "clinic.cycle.item,%s"%obj.id,
|
||||||
|
'direct_lines': [],
|
||||||
|
}
|
||||||
|
for line in obj.lines:
|
||||||
|
if not line.amount:
|
||||||
|
continue
|
||||||
|
vals['direct_lines'].append(('create',{
|
||||||
|
'description': 'Payment; %s'%line.nurse_categ.name,
|
||||||
|
'account_id': account_id,
|
||||||
|
'qty': 1,
|
||||||
|
'unit_price': line.amount,
|
||||||
|
'amount': line.amount,
|
||||||
|
}))
|
||||||
|
payment_id=get_model("account.payment").create(vals,context={"type":"in"})
|
||||||
|
get_model("account.payment").browse(payment_id).post()
|
||||||
|
obj.write({
|
||||||
|
'state': 'done',
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
'next': {
|
||||||
|
'name': 'payment',
|
||||||
|
'mode': 'form',
|
||||||
|
'active_id': payment_id,
|
||||||
|
},
|
||||||
|
'flash': 'Create journal successfully',
|
||||||
|
}
|
||||||
|
|
||||||
|
def to_draft(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
related_id="clinic.cycle.item,%s"%obj.id
|
||||||
|
for payment in get_model("account.payment").search_browse([['related_id','=',related_id]]):
|
||||||
|
payment.to_draft()
|
||||||
|
payment.delete()
|
||||||
|
obj.write({
|
||||||
|
'state': 'draft',
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
'next': {
|
||||||
|
'name': 'clinic_cycle_item',
|
||||||
|
'mode': 'form',
|
||||||
|
'active_id': obj.id,
|
||||||
|
},
|
||||||
|
'flash': 'Cycle item is set to draft',
|
||||||
|
}
|
||||||
|
|
||||||
|
def view_journal(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
related_id="clinic.cycle.item,%s"%obj.id
|
||||||
|
payment_ids=get_model("account.payment").search([['related_id','=',related_id]])
|
||||||
|
if payment_ids:
|
||||||
|
payment_id=payment_ids[0]
|
||||||
|
return {
|
||||||
|
'next': {
|
||||||
|
'name': 'payment',
|
||||||
|
'mode': 'form',
|
||||||
|
'active_id': payment_id,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CycleItem.register()
|
CycleItem.register()
|
||||||
|
|
|
@ -9,6 +9,8 @@ class Settings(Model):
|
||||||
"ar_mg_id": fields.Many2One("account.account","Account Recieve Medical Government"),
|
"ar_mg_id": fields.Many2One("account.account","Account Recieve Medical Government"),
|
||||||
"ar_nhso_id": fields.Many2One("account.account","Account Recieve NHSO 30B"),
|
"ar_nhso_id": fields.Many2One("account.account","Account Recieve NHSO 30B"),
|
||||||
"ar_sc_id": fields.Many2One("account.account","Account Recieve Social Security"),
|
"ar_sc_id": fields.Many2One("account.account","Account Recieve Social Security"),
|
||||||
|
"ap_nurse_id": fields.Many2One("account.account","Account Payment Nurse"),
|
||||||
|
"ap_doctor_id": fields.Many2One("account.account","Account Doctor Nurse"),
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.register()
|
Settings.register()
|
||||||
|
|
|
@ -28,7 +28,6 @@ class HDCase(Model):
|
||||||
res[obj.id]=obj.amount
|
res[obj.id]=obj.amount
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
"number": fields.Char("Number",required=True,search=True),
|
"number": fields.Char("Number",required=True,search=True),
|
||||||
"time_start": fields.DateTime("Time start",required=True,search=True),
|
"time_start": fields.DateTime("Time start",required=True,search=True),
|
||||||
|
|
Loading…
Reference in New Issue