conv_bal
watcha.h 2014-10-15 13:36:52 +07:00
parent 04529f2669
commit cf5de9f0a9
9 changed files with 163 additions and 45 deletions

View File

@ -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>

View File

@ -2,7 +2,7 @@
<head>
<field name="state"/>
<button string="Options" dropdown="1">
<item string="TODO" method="todo"/>
<item string="Print Payment" method="print_payment"/>
</button>
</head>
<group span="6" columns="1">
@ -43,6 +43,29 @@
</list>
</field>
</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">
<field name="lines" count="3" nolabel="1">
<list>
@ -59,29 +82,7 @@
<group span="4" columns="1">
<field name="total"/>
<field name="amount"/>
</group>
</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"/>
<button string="Pay Now" span="2" size="small" action="clinic_payment" icon="arrow-right" type="success"/>
</group>
</tab>
<tab string="Notes">

View File

@ -7,9 +7,9 @@
<item string="Patients">
<item string="Patients" action="clinic_patient"/>
<item string="Dialyzers" action="clinic_dialyzer"/>
<item string="Schedules" action="clinic_schedule"/>
<!--<item string="Schedules" action="clinic_schedule"/>-->
<divider/>
<header string="OPTIONS"/>
<header string="OTHERS"/>
<item string="Races" action="clinic_race"/>
<item string="Nationalities" action="clinic_nation"/>
<item string="Graduations" action="clinic_grade"/>
@ -25,11 +25,7 @@
<header string="HD Case"/>
<item string="Treatment Summary" action="clinic_hd_report"/>
</item>
<item string="Imports">
<item string="Import Payments" action="clinic_import_payment"/>
</item>
<item string="Settings">
<!-- <item string="Cycle" action="clinic_cycle"/>-->
<item string="Departments" action="clinic_department"/>
<item string="Cycle" action="clinic_cycle"/>
<item string="Clinic Settings" action="clinic_setting"/>

View File

@ -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>

View File

@ -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>

View File

@ -31,3 +31,5 @@ from . import file_sheet
from . import cycle
from . import gen_visit
from . import gen_visit_line
from . import payment
from . import payment_line

View File

@ -205,6 +205,10 @@ class HDcase(Model):
data['fee_total']=total
data['fee_amount']=total
return data
def make_payment(self,ids,context={}):
pass
def make_invoices(self,ids,context={}):
setting=get_model("settings").browse(1)
@ -217,11 +221,11 @@ class HDcase(Model):
raise Exception("Unit not found in uom")
obj=self.browse(ids[0])
due_date=obj.date[0:10]
# XXX
context['type']='out'
context['inv_type']='invoice'
# TODO payment without invoice
if obj.lines and obj.total:
# XXX need to split function prepare invoice
vals={
"type": "out",
"inv_type": "invoice",
@ -255,7 +259,7 @@ class HDcase(Model):
inv_id=get_model("account.invoice").create(vals,context)
# create picking
obj.make_pickings()
if obj.fee:
if obj.fee_total:
vals={
"type": "out",
"inv_type": "invoice",
@ -270,22 +274,22 @@ class HDcase(Model):
}
vals["partner_id"]=obj.fee_partner_id.id
# 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:
account_id=obj.fee_partner_id.account_receivable_id.id or account_receivable_id
if not account_receivable_id:
raise Exception("%s not found account recievable %s"%obj.fee_partner_id.name)
line={
"product_id": None,
"description": "Fee",
"qty": 1,
"uom_id": uom[0].id,
"unit_price": obj.fee,
"amount": obj.fee,
'account_id': account_id,
}
vals['lines'].append(('create',line))
for line in obj.gm_lines:
prod=line.product_id
inv_line={
"product_id": prod.id,
"description": prod.name,
"qty": 1,
"uom_id": prod.uom_id.id,
"unit_price": line.price,
"amount": line.amount,
'account_id': account_id, # XXX
}
vals['lines'].append(('create',inv_line))
inv_id=get_model("account.invoice").create(vals,context)
def make_pickings(self,ids,context={}):

View File

@ -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()

View File

@ -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()