improve matching
parent
ccab6a2ba2
commit
030ad8fcd5
|
@ -67,6 +67,9 @@
|
|||
<!--</list>-->
|
||||
<!--</field>-->
|
||||
</tab>
|
||||
<tab string="Matching HD Case">
|
||||
<field name="skip_type_id"/>
|
||||
</tab>
|
||||
<tab string="Accounting">
|
||||
<field name="cash_account_id"/>
|
||||
<field name="income_account_id" string="Account Receivable"/>
|
||||
|
|
|
@ -1,6 +1,30 @@
|
|||
<form model="clinic.matching.hdcase">
|
||||
<tabs>
|
||||
<tab string="General">
|
||||
<field name="date_from" onchange="onchange_date" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="file" span="3"/>
|
||||
<field name="state" span="3"/>
|
||||
<!--<group span="6" columns="1">-->
|
||||
<!--<field name="file_lines" nolabel="1">-->
|
||||
<!--<list>-->
|
||||
<!--<field name="file"/>-->
|
||||
<!--</list>-->
|
||||
<!--</field>-->
|
||||
<!--</group>-->
|
||||
<!--<group span="6" columns="1">-->
|
||||
<!--</group>-->
|
||||
</tab>
|
||||
<tab string="Skip Type">
|
||||
<group span="6" columns="1">
|
||||
<field name="skip_lines" nolabel="1">
|
||||
<list>
|
||||
<field name="type_id"/>
|
||||
</list>
|
||||
</field>
|
||||
</group>
|
||||
<group span="6" columns="1">
|
||||
</group>
|
||||
</tab>
|
||||
</tabs>
|
||||
</form>
|
||||
|
|
|
@ -114,6 +114,8 @@ from . import matching_payment_popup
|
|||
from . import invoice_payment
|
||||
from . import invoice_payment_line
|
||||
from . import matching_hdcase
|
||||
from . import matching_hdcase_line
|
||||
from . import matching_hdcase_file
|
||||
from . import sale_order
|
||||
from . import shop
|
||||
from . import shop_line
|
||||
|
|
|
@ -12,18 +12,25 @@ class MatchingHDCase(Model):
|
|||
"date_to": fields.Date("To", required=True),
|
||||
'file': fields.File("File"),
|
||||
'state': fields.Selection([["match","Math"],["not_match","Not Match"]],"State"),
|
||||
'skip_lines': fields.One2Many("clinic.matching.hdcase.line","matching_hdcase_id","Skip Lines"),
|
||||
'file_lines': fields.One2Many("clinic.matching.hdcase.file","matching_hdcase_id","File Lines"),
|
||||
'msg': fields.Text("Message"),
|
||||
}
|
||||
|
||||
def default_get(self,field_names=None,context={},**kw):
|
||||
defaults=context.get("defaults",{})
|
||||
datenow=time.strftime("%Y-%m-%d")
|
||||
date_from=defaults.get('date_from',datenow)
|
||||
date_to=defaults.get('date_to',datenow)
|
||||
res={
|
||||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
def _get_skip_lines(self,context={}):
|
||||
skip_lines=[]
|
||||
st=get_model('clinic.setting').browse(1)
|
||||
if st.skip_type_id:
|
||||
skip_lines.append({
|
||||
'type_id': st.skip_type_id.id,
|
||||
})
|
||||
return skip_lines
|
||||
|
||||
_defaults={
|
||||
'date_from': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'date_to': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'skip_lines': _get_skip_lines,
|
||||
}
|
||||
return res
|
||||
|
||||
def get_rows(self,fpath=None):
|
||||
if not fpath:
|
||||
|
@ -72,7 +79,11 @@ class MatchingHDCase(Model):
|
|||
state=obj.state
|
||||
date_from=obj.date_from
|
||||
date_to=obj.date_to
|
||||
if obj.file:
|
||||
skip_lines=[skip.type_id.name for skip in obj.skip_lines]
|
||||
print('skip_lines ', skip_lines)
|
||||
if not obj.file:
|
||||
return {}
|
||||
#raise Exception("File Not found")
|
||||
fpath=get_file_path(obj.file)
|
||||
rows=self.get_rows(fpath)
|
||||
if not rows:
|
||||
|
@ -259,7 +270,29 @@ class MatchingHDCase(Model):
|
|||
total=0
|
||||
total_match=0
|
||||
total_unmatch=0
|
||||
mdate=[]
|
||||
for line in sorted(lines,key=lambda x: x['hn']):
|
||||
ldate=line.get('date') or ""
|
||||
if ldate not in mdate:
|
||||
mdate.append(ldate)
|
||||
cont=ldate and (ldate >=date_from and ldate <= date_to)
|
||||
# skip out of range
|
||||
if not cont:
|
||||
continue
|
||||
patient_type=line.get('patient_type')
|
||||
hn=line.get('hn')
|
||||
if patient_type in skip_lines:
|
||||
print('continue ', patient_type)
|
||||
continue
|
||||
elif not patient_type and hn:
|
||||
found=0
|
||||
for pt in get_model("clinic.patient").search_browse([['hn_no','=',hn]]):
|
||||
if pt.type_id.name in skip_lines:
|
||||
found=1
|
||||
break
|
||||
if found:
|
||||
print('continue ', hn)
|
||||
continue
|
||||
is_match=line.get('is_match',False)
|
||||
if is_match:
|
||||
total_match+=1
|
||||
|
@ -288,11 +321,13 @@ class MatchingHDCase(Model):
|
|||
'total_match': total_match,
|
||||
'total_unmatch': total_unmatch,
|
||||
}
|
||||
if no <=1 and ids:
|
||||
raise Exception("File match only %s"%', '.join(sorted(mdate)))
|
||||
return data
|
||||
|
||||
def onchange_date(self,context={}):
|
||||
data=context['data']
|
||||
data['date_to']=data['date_from']
|
||||
#data['date_to']=data['date_from']
|
||||
return data
|
||||
|
||||
MatchingHDCase.register()
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
|
||||
class MatchingHDCaseFile(Model):
|
||||
_name="clinic.matching.hdcase.file"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
"matching_hdcase_id": fields.Many2One("clinic.matching.hdcase","Matching HD Case"),
|
||||
'file': fields.File("File"),
|
||||
}
|
||||
|
||||
MatchingHDCaseFile.register()
|
|
@ -0,0 +1,12 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
|
||||
class MatchingHDCaseLine(Model):
|
||||
_name="clinic.matching.hdcase.line"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
"matching_hdcase_id": fields.Many2One("clinic.matching.hdcase","Matching HD Case"),
|
||||
'type_id': fields.Many2One("clinic.patient.type","Type"),
|
||||
}
|
||||
|
||||
MatchingHDCaseLine.register()
|
|
@ -55,6 +55,7 @@ class ClinicSetting(Model):
|
|||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
'shop_categs': fields.Many2Many("product.categ","Categs"),
|
||||
'shop_type_id': fields.Many2One("clinic.patient.type","Patient Type"),
|
||||
'skip_type_id': fields.Many2One("clinic.patient.type","Skip Type"), # Matching HD Case
|
||||
"cash_account_id": fields.Many2One("account.account","Cash Account",multi_company=True),
|
||||
"income_account_id": fields.Many2One("account.account","Income Account",multi_company=True),
|
||||
"import_account_id": fields.Many2One("account.account","Import Account",multi_company=True),
|
||||
|
|
Loading…
Reference in New Issue