payment
parent
04529f2669
commit
cf5de9f0a9
|
@ -0,0 +1,6 @@
|
||||||
|
<action>
|
||||||
|
<field name="string">Payment</field>
|
||||||
|
<field name="view_cls">form_popup</field>
|
||||||
|
<field name="model">clinic.payment</field>
|
||||||
|
<field name="target">_popup</field>
|
||||||
|
</action>
|
|
@ -2,7 +2,7 @@
|
||||||
<head>
|
<head>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="1">
|
||||||
<item string="TODO" method="todo"/>
|
<item string="Print Payment" method="print_payment"/>
|
||||||
</button>
|
</button>
|
||||||
</head>
|
</head>
|
||||||
<group span="6" columns="1">
|
<group span="6" columns="1">
|
||||||
|
@ -43,6 +43,29 @@
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</tab>
|
</tab>
|
||||||
|
<tab string="Fees">
|
||||||
|
<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">
|
<tab string="Other Expenses">
|
||||||
<field name="lines" count="3" nolabel="1">
|
<field name="lines" count="3" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
|
@ -59,29 +82,7 @@
|
||||||
<group span="4" columns="1">
|
<group span="4" columns="1">
|
||||||
<field name="total"/>
|
<field name="total"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
</group>
|
<button string="Pay Now" span="2" size="small" action="clinic_payment" icon="arrow-right" type="success"/>
|
||||||
</tab>
|
|
||||||
<tab string="Government Pays">
|
|
||||||
<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>
|
</group>
|
||||||
</tab>
|
</tab>
|
||||||
<tab string="Notes">
|
<tab string="Notes">
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
<item string="Patients">
|
<item string="Patients">
|
||||||
<item string="Patients" action="clinic_patient"/>
|
<item string="Patients" action="clinic_patient"/>
|
||||||
<item string="Dialyzers" action="clinic_dialyzer"/>
|
<item string="Dialyzers" action="clinic_dialyzer"/>
|
||||||
<item string="Schedules" action="clinic_schedule"/>
|
<!--<item string="Schedules" action="clinic_schedule"/>-->
|
||||||
<divider/>
|
<divider/>
|
||||||
<header string="OPTIONS"/>
|
<header string="OTHERS"/>
|
||||||
<item string="Races" action="clinic_race"/>
|
<item string="Races" action="clinic_race"/>
|
||||||
<item string="Nationalities" action="clinic_nation"/>
|
<item string="Nationalities" action="clinic_nation"/>
|
||||||
<item string="Graduations" action="clinic_grade"/>
|
<item string="Graduations" action="clinic_grade"/>
|
||||||
|
@ -25,11 +25,7 @@
|
||||||
<header string="HD Case"/>
|
<header string="HD Case"/>
|
||||||
<item string="Treatment Summary" action="clinic_hd_report"/>
|
<item string="Treatment Summary" action="clinic_hd_report"/>
|
||||||
</item>
|
</item>
|
||||||
<item string="Imports">
|
|
||||||
<item string="Import Payments" action="clinic_import_payment"/>
|
|
||||||
</item>
|
|
||||||
<item string="Settings">
|
<item string="Settings">
|
||||||
<!-- <item string="Cycle" action="clinic_cycle"/>-->
|
|
||||||
<item string="Departments" action="clinic_department"/>
|
<item string="Departments" action="clinic_department"/>
|
||||||
<item string="Cycle" action="clinic_cycle"/>
|
<item string="Cycle" action="clinic_cycle"/>
|
||||||
<item string="Clinic Settings" action="clinic_setting"/>
|
<item string="Clinic Settings" action="clinic_setting"/>
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<inherit inherit="account_menu">
|
||||||
|
<item string="Settings" position="before">
|
||||||
|
<item string="Ratchawat">
|
||||||
|
<item string="Import Payments" action="clinic_import_payment"/>
|
||||||
|
</item>
|
||||||
|
</item>
|
||||||
|
</inherit>
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<form model="clinic.payment">
|
||||||
|
<field name="partner_id" />
|
||||||
|
<field name="lines" nolabel="1">
|
||||||
|
<list>
|
||||||
|
<field name="description"/>
|
||||||
|
<field name="qty"/>
|
||||||
|
<field name="price"/>
|
||||||
|
<field name="amount"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
<group span="4">
|
||||||
|
</group>
|
||||||
|
<group span="8">
|
||||||
|
<field offset="6" name="total"/>
|
||||||
|
</group>
|
||||||
|
<foot>
|
||||||
|
<button string="POST" type="success" method="post"/>
|
||||||
|
</foot>
|
||||||
|
</form>
|
|
@ -31,3 +31,5 @@ from . import file_sheet
|
||||||
from . import cycle
|
from . import cycle
|
||||||
from . import gen_visit
|
from . import gen_visit
|
||||||
from . import gen_visit_line
|
from . import gen_visit_line
|
||||||
|
from . import payment
|
||||||
|
from . import payment_line
|
||||||
|
|
|
@ -205,6 +205,10 @@ class HDcase(Model):
|
||||||
data['fee_total']=total
|
data['fee_total']=total
|
||||||
data['fee_amount']=total
|
data['fee_amount']=total
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def make_payment(self,ids,context={}):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def make_invoices(self,ids,context={}):
|
def make_invoices(self,ids,context={}):
|
||||||
setting=get_model("settings").browse(1)
|
setting=get_model("settings").browse(1)
|
||||||
|
@ -217,11 +221,11 @@ 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]
|
||||||
# XXX
|
|
||||||
context['type']='out'
|
context['type']='out'
|
||||||
context['inv_type']='invoice'
|
context['inv_type']='invoice'
|
||||||
|
# TODO payment without invoice
|
||||||
if obj.lines and obj.total:
|
if obj.lines and obj.total:
|
||||||
# XXX need to split function prepare invoice
|
|
||||||
vals={
|
vals={
|
||||||
"type": "out",
|
"type": "out",
|
||||||
"inv_type": "invoice",
|
"inv_type": "invoice",
|
||||||
|
@ -255,7 +259,7 @@ class HDcase(Model):
|
||||||
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:
|
if obj.fee_total:
|
||||||
vals={
|
vals={
|
||||||
"type": "out",
|
"type": "out",
|
||||||
"inv_type": "invoice",
|
"inv_type": "invoice",
|
||||||
|
@ -270,22 +274,22 @@ class HDcase(Model):
|
||||||
}
|
}
|
||||||
vals["partner_id"]=obj.fee_partner_id.id
|
vals["partner_id"]=obj.fee_partner_id.id
|
||||||
# XXX
|
# XXX
|
||||||
#if obj.fee_partner_id.account_payable_id:
|
|
||||||
#account_receivable_id=obj.fee_partner_id.account_payable_id.id
|
|
||||||
if obj.fee_partner_id.account_receivable_id:
|
if obj.fee_partner_id.account_receivable_id:
|
||||||
account_id=obj.fee_partner_id.account_receivable_id.id or account_receivable_id
|
account_id=obj.fee_partner_id.account_receivable_id.id or account_receivable_id
|
||||||
if not account_receivable_id:
|
if not account_receivable_id:
|
||||||
raise Exception("%s not found account recievable %s"%obj.fee_partner_id.name)
|
raise Exception("%s not found account recievable %s"%obj.fee_partner_id.name)
|
||||||
line={
|
for line in obj.gm_lines:
|
||||||
"product_id": None,
|
prod=line.product_id
|
||||||
"description": "Fee",
|
inv_line={
|
||||||
"qty": 1,
|
"product_id": prod.id,
|
||||||
"uom_id": uom[0].id,
|
"description": prod.name,
|
||||||
"unit_price": obj.fee,
|
"qty": 1,
|
||||||
"amount": obj.fee,
|
"uom_id": prod.uom_id.id,
|
||||||
'account_id': account_id,
|
"unit_price": line.price,
|
||||||
}
|
"amount": line.amount,
|
||||||
vals['lines'].append(('create',line))
|
'account_id': account_id, # XXX
|
||||||
|
}
|
||||||
|
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={}):
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
#from netforce.access import get_active_user
|
||||||
|
from netforce.model import Model, fields, get_model
|
||||||
|
|
||||||
|
class Payment(Model):
|
||||||
|
_name="clinic.payment"
|
||||||
|
_transient=True
|
||||||
|
|
||||||
|
def _get_all(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
total=0.0
|
||||||
|
for line in obj.lines:
|
||||||
|
total+=line.amount or 0.0
|
||||||
|
res[obj.id]={
|
||||||
|
'total': total
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
'partner_id': fields.Many2One("partner","Partner"),
|
||||||
|
'lines': fields.One2Many("clinic.payment.line","payment_id", "Lines"),
|
||||||
|
'total': fields.Float("Total", function="_get_all",function_multi=True),
|
||||||
|
"state": fields.Selection([["draft","Draft"],['paid','Paid'],["cancelled","Cancelled"]],"Status",required=True),
|
||||||
|
}
|
||||||
|
|
||||||
|
def _get_partner_id(self,context={}):
|
||||||
|
refer_id=context.get("refer_id") # hd_case_id
|
||||||
|
hd_case=get_model('clinic.hd.case').browse(refer_id)
|
||||||
|
partner_id=hd_case.patient_id.partner_id.id or None
|
||||||
|
return partner_id
|
||||||
|
|
||||||
|
def _get_lines(self,context={}):
|
||||||
|
refer_id=context.get("refer_id") # hd_case_id
|
||||||
|
hd_case=get_model('clinic.hd.case').browse(refer_id)
|
||||||
|
lines=[]
|
||||||
|
for line in hd_case.lines:
|
||||||
|
vals={
|
||||||
|
'description': line.description or '',
|
||||||
|
'qty': line.qty or 0,
|
||||||
|
'price': line.price,
|
||||||
|
'amount': line.amount,
|
||||||
|
}
|
||||||
|
lines.append(vals)
|
||||||
|
return lines
|
||||||
|
|
||||||
|
def _get_total(self,context={}):
|
||||||
|
refer_id=context.get("refer_id")
|
||||||
|
hd_case=get_model('clinic.hd.case').browse(refer_id)
|
||||||
|
total=0.0
|
||||||
|
for line in hd_case.lines:
|
||||||
|
total+=line.amount
|
||||||
|
print("total ", total)
|
||||||
|
return total
|
||||||
|
|
||||||
|
_defaults={
|
||||||
|
'partner_id': _get_partner_id,
|
||||||
|
'lines': _get_lines,
|
||||||
|
'total': _get_total,
|
||||||
|
}
|
||||||
|
|
||||||
|
def paid(self,context={}):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
Payment.register()
|
|
@ -0,0 +1,17 @@
|
||||||
|
from netforce.model import Model, fields, get_model
|
||||||
|
|
||||||
|
class PaymentLine(Model):
|
||||||
|
_name="clinic.payment.line"
|
||||||
|
_transient=True
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
'payment_id': fields.Many2One("clinic.payment","Payment"),
|
||||||
|
'description': fields.Char("Description"),
|
||||||
|
'qty': fields.Integer("Qty"),
|
||||||
|
'price': fields.Float("Unit Price"),
|
||||||
|
'account_id': fields.Many2One("account.account","Account"),
|
||||||
|
'amount': fields.Float("Amount"),
|
||||||
|
}
|
||||||
|
|
||||||
|
PaymentLine.register()
|
||||||
|
|
Loading…
Reference in New Issue