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