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> <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,25 +43,7 @@
</list> </list>
</field> </field>
</tab> </tab>
<tab string="Other Expenses"> <tab string="Fees">
<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" columns="1">
</group>
<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"> <field name="gm_lines" count="3" nolabel="1">
<list> <list>
<field name="product_id" onchange="onchange_gmproduct"/> <field name="product_id" onchange="onchange_gmproduct"/>
@ -84,6 +66,25 @@
<field name="fee_amount"/> <field name="fee_amount"/>
</group> </group>
</tab> </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" columns="1">
</group>
<group span="4" columns="1">
<field name="total"/>
<field name="amount"/>
<button string="Pay Now" span="2" size="small" action="clinic_payment" icon="arrow-right" type="success"/>
</group>
</tab>
<tab string="Notes"> <tab string="Notes">
<field name="note" nolabel="1"/> <field name="note" nolabel="1"/>
</tab> </tab>

View File

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

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

View File

@ -206,6 +206,10 @@ class HDcase(Model):
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)
currency_id=setting.currency_id.id currency_id=setting.currency_id.id
@ -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={
"product_id": prod.id,
"description": prod.name,
"qty": 1, "qty": 1,
"uom_id": uom[0].id, "uom_id": prod.uom_id.id,
"unit_price": obj.fee, "unit_price": line.price,
"amount": obj.fee, "amount": line.amount,
'account_id': account_id, 'account_id': account_id, # XXX
} }
vals['lines'].append(('create',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={}):

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