xxx
parent
6c9f041771
commit
429dcac788
|
@ -12,4 +12,7 @@
|
||||||
<separator string="Document Mathing"/>
|
<separator string="Document Mathing"/>
|
||||||
<field name="file_id" span="2"/>
|
<field name="file_id" span="2"/>
|
||||||
<field name="view_type" 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>
|
</form>
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
<field name="bank_name" attrs='{"invisible":[["pay_type","=","credit"]]}' span="2"/>
|
<field name="bank_name" attrs='{"invisible":[["pay_type","=","credit"]]}' span="2"/>
|
||||||
<field name="bank_branch" 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="hd_case_call" invisible="1"/>
|
||||||
<field name="shop_categs" invisible="1"/>
|
|
||||||
<field name="company_id" invisible="1"/>
|
<field name="company_id" invisible="1"/>
|
||||||
<tabs>
|
<tabs>
|
||||||
<tab string="General">
|
<tab string="General">
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="contact_id"/>
|
<field name="contact_id"/>
|
||||||
<field name="ref"/>
|
<!--<field name="ref"/>-->
|
||||||
<field name="branch_id"/>
|
<!--<field name="branch_id"/>-->
|
||||||
<field name="department_id"/>
|
<field name="department_id"/>
|
||||||
<field name="pay_type"/>
|
<field name="pay_type"/>
|
||||||
<field name="user_id"/>
|
<field name="user_id"/>
|
||||||
|
|
|
@ -2,6 +2,9 @@ import time
|
||||||
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.utils import get_file_path
|
||||||
|
|
||||||
|
from . import utils
|
||||||
|
|
||||||
class PaymentMatching(Model):
|
class PaymentMatching(Model):
|
||||||
_name="clinic.payment.matching"
|
_name="clinic.payment.matching"
|
||||||
|
@ -20,6 +23,9 @@ class PaymentMatching(Model):
|
||||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
'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"),
|
"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"),
|
"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={}):
|
def _get_date_from(self,context={}):
|
||||||
|
@ -43,6 +49,10 @@ class PaymentMatching(Model):
|
||||||
date_from=line.date_start
|
date_from=line.date_start
|
||||||
date_to=line.date_stop
|
date_to=line.date_stop
|
||||||
break
|
break
|
||||||
|
tids=get_model('clinic.patient.type').search([['default','=',True]])
|
||||||
|
patient_type_id=None
|
||||||
|
if tids:
|
||||||
|
patient_type_id=tids[0]
|
||||||
res={
|
res={
|
||||||
'period_id': period_id,
|
'period_id': period_id,
|
||||||
'date': time.strftime("%Y-%m-%d"),
|
'date': time.strftime("%Y-%m-%d"),
|
||||||
|
@ -50,6 +60,7 @@ class PaymentMatching(Model):
|
||||||
'date_to': date_to,
|
'date_to': date_to,
|
||||||
'inv_state': 'waiting_payment',
|
'inv_state': 'waiting_payment',
|
||||||
'view_type': 'invoice',
|
'view_type': 'invoice',
|
||||||
|
'patient_type_id': patient_type_id,
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -61,6 +72,45 @@ class PaymentMatching(Model):
|
||||||
data['date_to']=period.date_stop
|
data['date_to']=period.date_stop
|
||||||
return data
|
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={}):
|
def get_report_data(self,ids,context={}):
|
||||||
defaults=self.default_get(context=context)
|
defaults=self.default_get(context=context)
|
||||||
print('defaults ', defaults)
|
print('defaults ', defaults)
|
||||||
|
@ -104,5 +154,4 @@ class PaymentMatching(Model):
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
PaymentMatching.register()
|
PaymentMatching.register()
|
||||||
|
|
|
@ -13,8 +13,6 @@ class Shop(Model):
|
||||||
|
|
||||||
def _get_all(self,ids,context={}):
|
def _get_all(self,ids,context={}):
|
||||||
res={}
|
res={}
|
||||||
st=get_model("clinic.setting").browse(1)
|
|
||||||
shop_categs=[x.id for x in st.shop_categs]
|
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
sub_total=0
|
sub_total=0
|
||||||
tax_amount=0
|
tax_amount=0
|
||||||
|
@ -30,7 +28,6 @@ class Shop(Model):
|
||||||
'tax_amount': tax_amount,
|
'tax_amount': tax_amount,
|
||||||
'total': total,
|
'total': total,
|
||||||
'due_amount': total,
|
'due_amount': total,
|
||||||
'shop_categs': shop_categs,
|
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -54,7 +51,6 @@ class Shop(Model):
|
||||||
"invoices": fields.One2Many("account.invoice","related_id","Invoices"),
|
"invoices": fields.One2Many("account.invoice","related_id","Invoices"),
|
||||||
"payments": fields.One2Many("account.payment","related_id","Payments"),
|
"payments": fields.One2Many("account.payment","related_id","Payments"),
|
||||||
'dom_str': fields.Char("Dom Str"),
|
'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"),
|
"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"),
|
'company_id': fields.Many2One("company","Company"),
|
||||||
"pay_type": fields.Selection([("cash","Cash"),("credit","Credit")],"Pay Type"),
|
"pay_type": fields.Selection([("cash","Cash"),("credit","Credit")],"Pay Type"),
|
||||||
|
@ -70,11 +66,6 @@ class Shop(Model):
|
||||||
|
|
||||||
_order="date desc"
|
_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={}):
|
def _get_related(self,context={}):
|
||||||
related_id=None
|
related_id=None
|
||||||
if context.get('refer_id'):
|
if context.get('refer_id'):
|
||||||
|
@ -169,7 +160,6 @@ class Shop(Model):
|
||||||
'branch_id': _get_branch,
|
'branch_id': _get_branch,
|
||||||
'department_id': _get_department,
|
'department_id': _get_department,
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'shop_categs': _get_shop_categs,
|
|
||||||
'related_id': _get_related,
|
'related_id': _get_related,
|
||||||
'patient_id': _get_patient,
|
'patient_id': _get_patient,
|
||||||
'contact_id': _get_contact,
|
'contact_id': _get_contact,
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<h4>
|
<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>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue