diff --git a/netforce_clinic/actions/clinic_cust_print.xml b/netforce_clinic/actions/clinic_cust_print.xml new file mode 100644 index 0000000..75a7d50 --- /dev/null +++ b/netforce_clinic/actions/clinic_cust_print.xml @@ -0,0 +1,6 @@ + + report_odt2 + clinic.shop + get_data + cust_payment + diff --git a/netforce_clinic/actions/clinic_matching_payment.xml b/netforce_clinic/actions/clinic_matching_payment.xml index 7f23370..ec78bbd 100644 --- a/netforce_clinic/actions/clinic_matching_payment.xml +++ b/netforce_clinic/actions/clinic_matching_payment.xml @@ -4,5 +4,5 @@ clinic.matching.payment matching_payment matching_payment - clinic_menu + account_menu diff --git a/netforce_clinic/layouts/clinic_account_menu.xml b/netforce_clinic/layouts/clinic_account_menu.xml index 29a46f4..48fb75d 100644 --- a/netforce_clinic/layouts/clinic_account_menu.xml +++ b/netforce_clinic/layouts/clinic_account_menu.xml @@ -2,17 +2,18 @@ - + - +
- - - - + + + + +
diff --git a/netforce_clinic/layouts/clinic_dialyzer_form.xml b/netforce_clinic/layouts/clinic_dialyzer_form.xml index 2da19eb..3dc7190 100644 --- a/netforce_clinic/layouts/clinic_dialyzer_form.xml +++ b/netforce_clinic/layouts/clinic_dialyzer_form.xml @@ -3,7 +3,7 @@ diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml index 742f0a4..a34f7dd 100644 --- a/netforce_clinic/layouts/clinic_hd_case_form.xml +++ b/netforce_clinic/layouts/clinic_hd_case_form.xml @@ -60,7 +60,6 @@ - diff --git a/netforce_clinic/layouts/clinic_labor_cost_form.xml b/netforce_clinic/layouts/clinic_labor_cost_form.xml index ef561ed..2ac8626 100644 --- a/netforce_clinic/layouts/clinic_labor_cost_form.xml +++ b/netforce_clinic/layouts/clinic_labor_cost_form.xml @@ -33,7 +33,7 @@ - + @@ -46,7 +46,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_matching_payment.xml b/netforce_clinic/layouts/clinic_matching_payment.xml index 0a409d9..cde5ae6 100644 --- a/netforce_clinic/layouts/clinic_matching_payment.xml +++ b/netforce_clinic/layouts/clinic_matching_payment.xml @@ -5,7 +5,6 @@ - diff --git a/netforce_clinic/layouts/clinic_shop_form.xml b/netforce_clinic/layouts/clinic_shop_form.xml index 8af1802..19643e7 100644 --- a/netforce_clinic/layouts/clinic_shop_form.xml +++ b/netforce_clinic/layouts/clinic_shop_form.xml @@ -1,6 +1,7 @@
+ diff --git a/netforce_clinic/migrations/__init__.py b/netforce_clinic/migrations/__init__.py index 454dc53..c72c313 100644 --- a/netforce_clinic/migrations/__init__.py +++ b/netforce_clinic/migrations/__init__.py @@ -1,2 +1,2 @@ from . import clinic_setting -from . import import_ar +from . import import_acc diff --git a/netforce_clinic/migrations/import_ar.py b/netforce_clinic/migrations/import_acc.py similarity index 59% rename from netforce_clinic/migrations/import_ar.py rename to netforce_clinic/migrations/import_acc.py index d4994a2..6191acb 100644 --- a/netforce_clinic/migrations/import_ar.py +++ b/netforce_clinic/migrations/import_acc.py @@ -2,23 +2,21 @@ from netforce.model import get_model from netforce import migration class Migration(migration.Migration): - _name="import.ar" + _name="import.acc" _version="2.10.0" def migrate(self): cbv_id=24 cbv=get_model("conv.bal").browse(cbv_id) cbv.write({ - 'file': '', + 'file': 'tb.csv', }) - print("import acc file running ...") - get_model("conv.bal").import_acc_file([cbv.id],context={}) - print("import sale file running ...") + print("import acc file (step 1) running ...") cbv.write({ - 'file': '', + 'file': 'ar.csv', }) + print("import sale file (step 2)running ...") get_model("conv.bal").import_sale_file([cbv.id],context={}) - print("Done! ", cbv.id, cbv.file) return True Migration.register() diff --git a/netforce_clinic/migrations/import_pks.py b/netforce_clinic/migrations/import_pks.py deleted file mode 100644 index 6eaacb3..0000000 --- a/netforce_clinic/migrations/import_pks.py +++ /dev/null @@ -1,144 +0,0 @@ -from netforce.model import get_model -from netforce import migration -from netforce.utils import get_file_path -from netforce.access import get_active_user, set_active_user, set_active_company, get_active_company -from . import utils - -class Migration(migration.Migration): - _name="import.pks" - _version="2.10" - - def import_visit(self,lines): - visits={} - cycles=[(c['id'],'%s:00'%c['time_start'],'%s:00'%c['time_stop']) for c in get_model("clinic.cycle").search_read([[]],['time_start','time_stop'])] - for line in lines: - hcode=line.get('hcode18') - if not hcode: - hcode='0' - hcode=int(hcode) - hcode=str(hcode) - hcode_impt='23869' - if hcode_impt==hcode: - name=line.get("name14") - patient_ids=get_model("clinic.patient").search([['name','=',name]]) - if patient_ids: - patient_id=patient_ids[0] - patient=get_model("clinic.patient").browse(patient_id) - doctor=patient.doctor_id - department=patient.department_id - vals={ - 'patient_id': patient.id, - 'doctor_id': doctor.id, - 'department_id': department.id, - 'state': 'pending', - } - # find cycle - dttran=line.get("dttran") - date=dttran[0:10] - time=dttran[11:] - if not time: - continue - cycle_id=None - for cycle in cycles: - time_start=cycle[1] - time_stop=cycle[2] - if time >= time_start: - cycle_id=cycle[0] - vals['cycle_id']=cycle_id - vals['time_start']='%s %s'%(date,time_start) - vals['time_stop']='%s %s'%(date,time_stop) - if not cycle_id: - raise Exception("not found cycle on this time %s %s %s"%(dttran, time_start,time_stop)) - visit_ids=get_model("clinic.visit").search([['visit_date','=',date],['patient_id','=',patient_id]]) - visit_id=None - if not visit_ids: - vals['visit_date']=date - visit_id=get_model('clinic.visit').create(vals) - #print('create visit ', visit_id, date) - else: - visit_id=visit_ids[0] - #print('already ', date, ' ', name) - if visit_id: - visits.update({ - visit_id: { - 'hct': line.get('hct'), - 'epoadm29':line.get("epoadm29"), # SRV - 'amount23':line.get("amount23"), # FEE - 'allow37':line.get("allow37"), # EPO - } - }) - else: - print("found ", name) - return visits - - def confirm_visit(self,visits): - st=get_model("clinic.setting").browse(1) - st.write({ - 'auto_gen': True, - }) - hd_case_ids=[] - visit_ids=visits.keys() - for visit in get_model('clinic.visit').browse(visit_ids): - if visit!='confirmed': - hd_case_id=visit.confirm()['next']['active_id'] - hd_case=get_model("clinic.hd.case").browse(hd_case_id) - # lines - vals={ - 'hct': visits[visit.id]['hct'] or 0, - 'lines': [], - } - for st_prod in st.products: - if st_prod.patient_type_id.id==3: - prod=st_prod.product_id - price=st_prod.price - qty=st_prod.qty - categ=st_prod.product_categ_id - if categ.code=='FEE': - amt=visits[visit.id]['amount23'] or 0 - elif categ.code=='SRV': - amt=visits[visit.id]['epoadm29'] or 0 - elif categ.code=='EPO': - amt=visits[visit.id]['allow37'] or 0 - else: - amt=0 - vals['lines'].append(('create',{ - 'product_id': prod.id, - 'uom_id': st_prod.uom_id.id, - 'product_categ_id': categ.id, - 'description': st_prod.description, - 'price': price, - 'qty': qty, - 'reimbursable': st_prod.reimbursable, - 'amount': amt, - })) - hd_case.write(vals) - hd_case_ids.append(hd_case.id) - st.write({ - 'auto_gen': False, - }) - return hd_case_ids - - - def hdc_done(self,hd_case_ids): - done_ids=[] - for hd_case in get_model("clinic.hd.case").browse(hd_case_ids): - if hd_case.state=='waiting_treatment': - hd_case.complete() - done_ids.append(hd_case.id) - return done_ids - - def migrate(self): - fname='pks.xls' - fpath=get_file_path(fname) - lines=utils.read_excel(fpath,show_datetime=True) - set_active_company(1) - visits=self.import_visit(lines) - print("visit ", len(visits)) - hd_case_ids=self.confirm_visit(visits) - print('hd case ', len(hd_case_ids)) - hd_case_ids=self.hdc_done(hd_case_ids) - print('Done ', len(hd_case_ids)) - set_active_company(1) - return True - -Migration.register() diff --git a/netforce_clinic/migrations/import_uc.py b/netforce_clinic/migrations/import_uc.py deleted file mode 100644 index 787a820..0000000 --- a/netforce_clinic/migrations/import_uc.py +++ /dev/null @@ -1,141 +0,0 @@ -from netforce.model import get_model -from netforce import migration -from netforce.utils import get_file_path -from netforce.access import get_active_user, set_active_user, set_active_company, get_active_company -from . import utils - -class Migration(migration.Migration): - _name="import.uc" - _version="2.11" - - def import_visit(self,lines): - visits={} - cycles=[(c['id'],'%s:00'%c['time_start'],'%s:00'%c['time_stop']) for c in get_model("clinic.cycle").search_read([[]],['time_start','time_stop'])] - patients=get_model("clinic.patient").search_browse([]) - for line in lines: - dttran=line.get("dttran") - hn=line.get("hn") - if hn: - hn=''.join(x for x in hn if x.isdigit) - - pid=None - for pt in patients: - if pt['hn_num']==hn: - pid=pt.id - break - if not pid: - print('continue ', pid) - continue - if dttran: - date,time=dttran.split("T") - if not time: - continue - cycle_id=None - patient=get_model("clinic.patient").browse(pid) - doctor=patient.doctor_id - department=patient.department_id - vals={ - 'patient_id': patient.id, - 'doctor_id': doctor.id, - 'department_id': department.id, - 'state': 'pending', - } - for cycle in cycles: - time_start=cycle[1] - time_stop=cycle[2] - if time >= time_start: - cycle_id=cycle[0] - vals['cycle_id']=cycle_id - vals['time_start']='%s %s'%(date,time_start) - vals['time_stop']='%s %s'%(date,time_stop) - if not cycle_id: - raise Exception("not found cycle on this time %s %s %s"%(dttran, time_start,time_stop)) - visit_ids=get_model("clinic.visit").search([['visit_date','=',date],['patient_id','=',pid]]) - visit_id=None - if not visit_ids: - vals['visit_date']=date - visit_id=get_model('clinic.visit').create(vals) - else: - visit_id=visit_ids[0] - if visit_id: - visits.update({ - visit_id: { - 'hct': line.get('hct'), - } - }) - - pass - return visits - - def confirm_visit(self,visits): - st=get_model("clinic.setting").browse(1) - st.write({ - 'auto_gen': True, - }) - hd_case_ids=[] - visit_ids=visits.keys() - for visit in get_model('clinic.visit').browse(visit_ids): - if visit!='confirmed': - hd_case_id=visit.confirm()['next']['active_id'] - hd_case=get_model("clinic.hd.case").browse(hd_case_id) - # lines - vals={ - 'hct': visits[visit.id]['hct'] or 0, - 'lines': [], - } - for st_prod in st.products: - if st_prod.patient_type_id.id==3: - prod=st_prod.product_id - price=st_prod.price - qty=st_prod.qty - categ=st_prod.product_categ_id - if categ.code=='FEE': - amt=visits[visit.id]['amount23'] or 0 - elif categ.code=='SRV': - amt=visits[visit.id]['epoadm29'] or 0 - elif categ.code=='EPO': - amt=visits[visit.id]['allow37'] or 0 - else: - amt=0 - vals['lines'].append(('create',{ - 'product_id': prod.id, - 'uom_id': st_prod.uom_id.id, - 'product_categ_id': categ.id, - 'description': st_prod.description, - 'price': price, - 'qty': qty, - 'reimbursable': st_prod.reimbursable, - 'amount': amt, - })) - hd_case.write(vals) - hd_case_ids.append(hd_case.id) - st.write({ - 'auto_gen': False, - }) - return hd_case_ids - - - def hdc_done(self,hd_case_ids): - done_ids=[] - for hd_case in get_model("clinic.hd.case").browse(hd_case_ids): - if hd_case.state=='waiting_treatment': - hd_case.complete() - done_ids.append(hd_case.id) - return done_ids - - def migrate(self): - #fname='22283_EURSTM_201406.xml' - fname='22283_UOCDSTM_20140902.xml' - fpath=get_file_path(fname) - node='HDBills' - lines=utils.read_xml(fpath,node=node) - set_active_company(1) - visits=self.import_visit(lines) - print("visit ", len(visits)) - #hd_case_ids=self.confirm_visit(visits) - #print('hd case ', len(hd_case_ids)) - #hd_case_ids=self.hdc_done(hd_case_ids) - #print('Done ', len(hd_case_ids)) - return True - -Migration.register() diff --git a/netforce_clinic/models/dialyzer.py b/netforce_clinic/models/dialyzer.py index a02a7b4..7f679bd 100644 --- a/netforce_clinic/models/dialyzer.py +++ b/netforce_clinic/models/dialyzer.py @@ -15,7 +15,7 @@ class Dialyzer(Model): "number": fields.Char("Number",required=True,search=True), 'ref': fields.Char("Ref."), "note": fields.Text("Note",search=True), - "date": fields.Date("Create Date",search=True), + "date": fields.DateTime("Create Date",search=True), "use_time": fields.Integer("Use Time"), "max_use_time": fields.Integer("Max Use Time"), "exp_date": fields.Date("Expiry Date",search=True), @@ -80,7 +80,7 @@ class Dialyzer(Model): _defaults={ "state": "new", - "date": lambda *a: time.strftime("%Y-%m-%d"), + "date": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"), 'number': '/', "max_use_time": 10, "use_time": 0, @@ -132,6 +132,7 @@ class Dialyzer(Model): pick_vals={ "type": "out", 'journal_id': stock_journal.id, + 'date': obj.date, "ref": obj.number, "related_id": "clinic.dialyzer,%s"%obj.id, "partner_id": obj.patient_id.partner_id.id, diff --git a/netforce_clinic/models/labor_cost.py b/netforce_clinic/models/labor_cost.py index 28031f0..8a3c4f9 100644 --- a/netforce_clinic/models/labor_cost.py +++ b/netforce_clinic/models/labor_cost.py @@ -33,7 +33,7 @@ class LaborCost(Model): total_a+=fline.var_a or 0 total_b+=fline.var_b or 0 var_ptx=total_case*(obj.var_k or 0) - var_fml1='PTxK=%sX%s'%(total_a,total_b) + var_fml1='PTxK=%sx%s'%(total_a,total_b) total_bstr=total_b < 0 and "+%s"%(abs(total_b)) or "-%s"%total_b var_x=0.0 if total_a: @@ -56,7 +56,7 @@ class LaborCost(Model): 'var_pt': total_case, 'var_ptx': total_case*(obj.var_k or 0), 'var_fml1': '%s'%(var_fml1), - 'var_fml2': '%s=%sX%s'%(var_ptx,total_a,total_b), + 'var_fml2': '%s=%sx%s'%(var_ptx,total_a,total_b), 'var_fml3': '(%s%s)/%s'%(var_ptx,total_bstr,total_a), 'var_x': round(var_x,2), 'total': total, diff --git a/netforce_clinic/models/matching_payment.py b/netforce_clinic/models/matching_payment.py index 046bf3f..4ecfb8c 100644 --- a/netforce_clinic/models/matching_payment.py +++ b/netforce_clinic/models/matching_payment.py @@ -526,8 +526,10 @@ class MatchingPayment(Model): print("Done!") def get_report_data(self,ids,context={}): - obj=self.browse(ids)[0] - lines=obj.match() + lines=[] + if ids: + obj=self.browse(ids)[0] + lines=obj.match() data={ 'lines': lines, } diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py index d2e3c0e..53a5d09 100644 --- a/netforce_clinic/models/shop.py +++ b/netforce_clinic/models/shop.py @@ -2,7 +2,7 @@ import time from netforce.model import Model, fields, get_model from netforce.access import get_active_user, set_active_user, get_active_company -from netforce.utils import get_data_path +from netforce.utils import get_data_path, get_file_path class Shop(Model): _name="clinic.shop" @@ -460,4 +460,74 @@ class Shop(Model): }, } + def get_bill(self,context={}): + if not context.get('refer_id'): + return {} + shop_id=int(context['refer_id']) + shop=self.browse(shop_id) + comp_id=get_active_company() + comp=get_model('company').browse(comp_id) + st=get_model('settings').browse(1) + addresses=st.addresses + comp_addr='' + if addresses: + comp_addr=addresses[0].address_text + cust=shop.contact_id + cust_name=cust.name or '' + cust_addr='' + if cust.addresses: + cust_addr=cust.addresses[0].address_text + + #if cust_name.lower()=='walk + if cust.walkin_cust: + cust_name=shop.ref or '' + no=1 + sub_total=0 + amount_total=0 + lines=[] + for line in shop.lines: + amt=line.amount or 0 + prod=line.product_id + lines.append({ + 'no': no, + 'product_name': prod.name or '', + 'description': line.description or '', + 'uom_name': line.uom_id.name or '', + 'qty': line.qty or 0, + 'price': line.price or 0, + 'amount': amt, + }) + sub_total+=amt + amount_total+=sub_total #XXX + no+=1 + data={ + 'comp_name': comp.name or '', + 'comp_addr': comp_addr or '', + 'number': shop.number or '', + 'ref': shop.ref, + 'date': shop.date, + 'cust_name': cust_name, + 'cust_addr': cust_addr, + 'lines':lines, + 'sub_total': sub_total, + 'amount_total': amount_total, + } + if comp.logo: + data['logo']=get_file_path(comp.logo) + return data + + def get_data(self,ids,context={}): + settings=get_model('settings').browse(1) + pages=[] + for obj in get_model('clinic.shop').browse(ids): + context['refer_id']=obj.id + data=get_model('clinic.shop').get_bill(context=context) + pages.append(data) + if pages: + pages[-1]["is_last_page"]=True + return { + "pages": pages, + "logo": get_file_path(settings.logo), + } + Shop.register() diff --git a/netforce_clinic/reports/cust_payment.odt b/netforce_clinic/reports/cust_payment.odt new file mode 100644 index 0000000..ee32d8b Binary files /dev/null and b/netforce_clinic/reports/cust_payment.odt differ