conv_bal
watcha.h 2014-12-03 16:11:41 +07:00
parent 3da5333667
commit 7a384046fe
8 changed files with 68 additions and 9 deletions

View File

@ -5,4 +5,5 @@
<field name="modes">list,form</field> <field name="modes">list,form</field>
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Done",[["state","=","done"]]]]</field> <field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Done",[["state","=","done"]]]]</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>
<field name="limit">25</field>
</action> </action>

View File

@ -5,4 +5,5 @@
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Waiting Treatment",[["state","=","waiting_treatment"]]],["In Progress",[["state","=","in_progress"]]],["Waiting Payment",[["state","=","waiting_payment"]]],["Waiting Approval",[["state","=","waiting_approval"]]],["Completed",[["state","=","completed"]]],["Cancelled",[["state","=","cancelled"]]]]</field> <field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Waiting Treatment",[["state","=","waiting_treatment"]]],["In Progress",[["state","=","in_progress"]]],["Waiting Payment",[["state","=","waiting_payment"]]],["Waiting Approval",[["state","=","waiting_approval"]]],["Completed",[["state","=","completed"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
<field name="modes">list,form</field> <field name="modes">list,form</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>
<field name="limit">25</field>
</action> </action>

View File

@ -5,4 +5,5 @@
<!--<field name="tabs">[["All",[]],["Archived",[["active","=","False"]]],["Social Security",[["type","=","sc"]]],["UC",[["type","=","uc"]]],["Others",[["type","=","others"]]]]</field>--> <!--<field name="tabs">[["All",[]],["Archived",[["active","=","False"]]],["Social Security",[["type","=","sc"]]],["UC",[["type","=","uc"]]],["Others",[["type","=","others"]]]]</field>-->
<field name="tabs">[["All",[]],["Archived",[["active","=","False"]]]]</field> <field name="tabs">[["All",[]],["Archived",[["active","=","False"]]]]</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>
<field name="limit">25</field>
</action> </action>

View File

@ -5,4 +5,5 @@
<field name="tabs">[["All",[]],["Archived",[["active","=",false]]],["Doctor",[["type","=","doctor"]]],["Nurse",[["type","=","nurse"]]]]</field> <field name="tabs">[["All",[]],["Archived",[["active","=",false]]],["Doctor",[["type","=","doctor"]]],["Nurse",[["type","=","nurse"]]]]</field>
<field name="modes">list,page,form</field> <field name="modes">list,page,form</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>
<field name="limit">25</field>
</action> </action>

View File

@ -5,4 +5,5 @@
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]],["Cancelled",[["state","=","cancelled"]]]]</field> <field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
<field name="modes">list,form,calendar</field> <field name="modes">list,form,calendar</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>
<field name="limit">25</field>
</action> </action>

View File

@ -66,6 +66,7 @@
<tab string="Accounting"> <tab string="Accounting">
<group form_layout="stacked"> <group form_layout="stacked">
<field name="payment_id" span="3" readonly="1"/> <field name="payment_id" span="3" readonly="1"/>
<field name="partner_id" span="3"/>
<button string="Approve" method="approve" icon="ok" span="3"/> <button string="Approve" method="approve" icon="ok" span="3"/>
</group> </group>
</tab> </tab>

View File

@ -64,7 +64,6 @@ class ImportHDCase(Model):
msg="" msg=""
max_row=obj.max_row max_row=obj.max_row
count=0 count=0
nofound=0
did=0 did=0
blank=0 blank=0
fail_qty=0 fail_qty=0
@ -80,12 +79,13 @@ class ImportHDCase(Model):
hcode=str(hcode) hcode=str(hcode)
if not obj.hcode_id.code==hcode: if not obj.hcode_id.code==hcode:
if hcode: if hcode:
nofound+=1
if hcode!='0': if hcode!='0':
msg+="not found %s, %s, %s \n"%(hcode,hn,name) msg+="not found %s, %s, %s \n"%(hcode,hn,name)
fail_qty+=1 fail_qty+=1
else: else:
blank+=1 blank+=1
else:
blank+=1
continue continue
dttran=line.get("dttran","") dttran=line.get("dttran","")
date=dttran[0:10] date=dttran[0:10]
@ -147,25 +147,27 @@ class ImportHDCase(Model):
msg+="confirm visit %s\n"%(visit.visit_date) msg+="confirm visit %s\n"%(visit.visit_date)
else: else:
did+=1 did+=1
#print("not found visit for %s on %s"%(name,date))
else: else:
pass pass
remain_row=len(lines)-blank-did-count total_row=len(lines)
remain_row=total_row-blank-did-count
if remain_row <= 0: if remain_row <= 0:
msg="Nothing to import" msg="Nothing to import"
final_msg='' final_msg=''
total_row=len(lines)
if done_qty <=0: if done_qty <=0 and did==0:
final_msg="Please import visit first" final_msg="Please import visit first"
raise Exception(final_msg)
elif done_qty <=0 and did!=0:
final_msg="Nothing to import"
total_row=0 total_row=0
done_qty=0 done_qty=0
fail_qty=0 fail_qty=0
remain_row=0 remain_row=0
else: else: final_msg="Done!"
final_msg="Done!"
obj.write({ obj.write({
'total_row': total_row, 'total_row': total_row,
'remain_row': remain_row, 'remain_row': remain_row+1, # XXX
'msg': msg, 'msg': msg,
'done_qty': done_qty and done_qty-1 or 0, 'done_qty': done_qty and done_qty-1 or 0,
'fail_qty': fail_qty, 'fail_qty': fail_qty,

View File

@ -3,12 +3,14 @@ from datetime import datetime, timedelta
from calendar import monthrange from calendar import monthrange
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.utils import get_file_path from netforce.utils import get_file_path
from . import utils from . import utils
class ImportPayment(Model): class ImportPayment(Model):
_name="import.clinic.payment" _name="import.clinic.payment"
_string="Clinic Payment" _string="Clinic Payment"
_multi_company=True
def _get_name(self,ids,context={}): def _get_name(self,ids,context={}):
res={} res={}
@ -37,6 +39,8 @@ class ImportPayment(Model):
'match_lines': fields.One2Many("import.clinic.payment.line","import_payment_id","Match",domain=[["state","=","match"]]), 'match_lines': fields.One2Many("import.clinic.payment.line","import_payment_id","Match",domain=[["state","=","match"]]),
'unmatch_lines': fields.One2Many("import.clinic.payment.line","import_payment_id","UnMatch",domain=[["state","=","unmatch"]]), 'unmatch_lines': fields.One2Many("import.clinic.payment.line","import_payment_id","UnMatch",domain=[["state","=","unmatch"]]),
'payment_id': fields.Many2One("account.payment","Payment"), 'payment_id': fields.Many2One("account.payment","Payment"),
'company_id': fields.Many2One("company","Company"),
'partner_id': fields.Many2One("partner","Partner"),
} }
def get_hcode_id(self,context={}): def get_hcode_id(self,context={}):
@ -63,6 +67,7 @@ class ImportPayment(Model):
'date_from': _get_date_from, 'date_from': _get_date_from,
'date_to': _get_date_to, 'date_to': _get_date_to,
'hcode_id': get_hcode_id, 'hcode_id': get_hcode_id,
'company_id': lambda *a: get_active_company(),
'max_row': 50, 'max_row': 50,
'state': 'draft', 'state': 'draft',
} }
@ -203,5 +208,51 @@ class ImportPayment(Model):
}) })
print("Done!") print("Done!")
def approve(self,ids,context={}):
obj=self.browse(ids)[0]
partner=obj.patient_id.partner_id
if not partner:
raise Exception("No contact on this patient")
company_id=get_active_company()
account_receivable_id=partner.account_receivable_id
if not account_receivable_id:
st=get_model('settings').browse(1)
account_receivable_id=st.account_receivable_id
if not account_receivable_id:
raise Exception("Not found account recieveable in account setting")
account_id=account_receivable_id.id
if not account_id:
raise Exception("No Account for payment")
vals={
"partner_id": partner.id,
"company_id": company_id,
"type": "in",
"pay_type": "invoice",
'date': time.strftime("%Y-%m-%d"),
"account_id": account_id,
'related_id': "clinic.hd.case,%s"%obj.id,
'invoice_lines': [],
}
vals['invoice_lines'].append(('create',{
'type': 'invoice',
'description': 'Payment; %s'%obj.number,
'account_id': account_id,
'qty': 1,
'unit_price': pay_amount,
'amount': pay_amount,
}))
payment_id=get_model("account.payment").create(vals,context={"type":"in"})
#payment=get_model('account.payment').browse(payment_id)
#payment.post()
return {
'next': {
'name': 'import_clinic_payment',
'mode': 'form',
'active_id': obj.id,
},
'flash': 'Done!',
}
ImportPayment.register() ImportPayment.register()