fix_acc
watcha.h 2015-08-23 12:39:02 +07:00
parent 6c9f041771
commit 429dcac788
6 changed files with 56 additions and 15 deletions

View File

@ -12,4 +12,7 @@
<separator string="Document Mathing"/>
<field name="file_id" span="2"/>
<field name="view_type" span="2"/>
<field name="patient_type_id" onchange="onchange_ptype" span="2"/>
<field name="pcode" span="2"/>
<field name="hcode_id" span="2" attrs='{"required":[["pcode","=","SSO"]],"invisible":[["pcode","!=","SSO"]]}'/>
</form>

View File

@ -24,7 +24,6 @@
<field name="bank_name" attrs='{"invisible":[["pay_type","=","credit"]]}' span="2"/>
<field name="bank_branch" attrs='{"invisible":[["pay_type","=","credit"]]}' span="2"/>
<field name="hd_case_call" invisible="1"/>
<field name="shop_categs" invisible="1"/>
<field name="company_id" invisible="1"/>
<tabs>
<tab string="General">

View File

@ -5,8 +5,8 @@
<field name="number"/>
<field name="date"/>
<field name="contact_id"/>
<field name="ref"/>
<field name="branch_id"/>
<!--<field name="ref"/>-->
<!--<field name="branch_id"/>-->
<field name="department_id"/>
<field name="pay_type"/>
<field name="user_id"/>

View File

@ -2,6 +2,9 @@ import time
from calendar import monthrange
from netforce.model import Model, fields, get_model
from netforce.utils import get_file_path
from . import utils
class PaymentMatching(Model):
_name="clinic.payment.matching"
@ -20,6 +23,9 @@ class PaymentMatching(Model):
'branch_id': fields.Many2One("clinic.branch","Branch"),
"inv_state": fields.Selection([("draft","Draft"),("waiting_approval","Waiting Approval"),("waiting_payment","Waiting Payment"),("paid","Paid"),("voided","Voided")],"Status"),
"view_type": fields.Selection([("invoice","Invoice"),("file","File")],"View Type"),
'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type",required=True),
'pcode': fields.Char("Code",required=True),
'hcode_id': fields.Many2One("clinic.hospital","HCode"),
}
def _get_date_from(self,context={}):
@ -43,6 +49,10 @@ class PaymentMatching(Model):
date_from=line.date_start
date_to=line.date_stop
break
tids=get_model('clinic.patient.type').search([['default','=',True]])
patient_type_id=None
if tids:
patient_type_id=tids[0]
res={
'period_id': period_id,
'date': time.strftime("%Y-%m-%d"),
@ -50,6 +60,7 @@ class PaymentMatching(Model):
'date_to': date_to,
'inv_state': 'waiting_payment',
'view_type': 'invoice',
'patient_type_id': patient_type_id,
}
return res
@ -61,6 +72,45 @@ class PaymentMatching(Model):
data['date_to']=period.date_stop
return data
def onchange_ptype(self,context={}):
data=context['data']
type_id=data['patient_type_id']
if type_id:
t=get_model('clinic.patient.type').browse(type_id)
data['pcode']=t.code or ""
return data
def get_line(self,ids,context={}):
obj=self.browse(ids)[0]
if not obj.file_id.file:
raise Exception("File not found!")
fname=obj.file_id.file
if obj.pcode=='SSO':
hcode=obj.hcode_id.code or ""
if not hcode:
raise Exception("Wrong HCode")
try:
n,sf=fname.split(".")
except Exception as e:
print("ERROR: wrong file ", e)
if sf not in ('xls','xlsx'):
raise Exception("File should be xls or xlsx")
fpath=get_file_path(fname)
lines=utils.read_excel(fpath,show_datetime=True)
elif obj.pcode=='UC':
fpath=get_file_path(fname)
node='HDBills'
lines=utils.read_xml(fpath,node=node)
hcode=fname.split("_")[0]
else:
raise Exception("Type %s is not support"%obj.pcode or "")
if not lines:
raise Exception("No data to match")
return lines
def get_report_data(self,ids,context={}):
defaults=self.default_get(context=context)
print('defaults ', defaults)
@ -104,5 +154,4 @@ class PaymentMatching(Model):
}
return data
PaymentMatching.register()

View File

@ -13,8 +13,6 @@ class Shop(Model):
def _get_all(self,ids,context={}):
res={}
st=get_model("clinic.setting").browse(1)
shop_categs=[x.id for x in st.shop_categs]
for obj in self.browse(ids):
sub_total=0
tax_amount=0
@ -30,7 +28,6 @@ class Shop(Model):
'tax_amount': tax_amount,
'total': total,
'due_amount': total,
'shop_categs': shop_categs,
}
return res
@ -54,7 +51,6 @@ class Shop(Model):
"invoices": fields.One2Many("account.invoice","related_id","Invoices"),
"payments": fields.One2Many("account.payment","related_id","Payments"),
'dom_str': fields.Char("Dom Str"),
'shop_categs': fields.Many2Many("product.categ","Categs",function="_get_all",function_multi=True,store=True),
"related_id": fields.Reference([["sale.order","Sales Order"],["purchase.order","Purchase Order"],["project","Project"],["job","Service Order"],["service.contract","Service Contract"]],"Related To"),
'company_id': fields.Many2One("company","Company"),
"pay_type": fields.Selection([("cash","Cash"),("credit","Credit")],"Pay Type"),
@ -70,11 +66,6 @@ class Shop(Model):
_order="date desc"
def _get_shop_categs(self,context={}):
st=get_model("clinic.setting").browse(1)
shop_categs=[x.id for x in st.shop_categs]
return shop_categs
def _get_related(self,context={}):
related_id=None
if context.get('refer_id'):
@ -169,7 +160,6 @@ class Shop(Model):
'branch_id': _get_branch,
'department_id': _get_department,
'state': 'draft',
'shop_categs': _get_shop_categs,
'related_id': _get_related,
'patient_id': _get_patient,
'contact_id': _get_contact,

View File

@ -9,7 +9,7 @@
</div>
<div class="col-sm-6">
<h4>
<span class="pull-right label label-default">TOTAL: {{total_inv}}</span>
<span class="pull-right label label-default">TOTAL: {{currency total_inv}}</span>
</h4>
</div>
</div>