Merge branch 'production' into fix_acc

fix_acc
watcha.h 2015-08-21 13:11:46 +07:00
commit 502020a8d3
10 changed files with 59 additions and 31 deletions

View File

@ -10,11 +10,6 @@
<separator string="Visit"/> <separator string="Visit"/>
<group form_layout="stacked"> <group form_layout="stacked">
<field name="find_dlz"/> <field name="find_dlz"/>
<!--
<newline/>
<field name="auto_gen_visit" string="Next Gen"/>
<field name="next_date" span="3"/>
-->
</group> </group>
<separator string="HD Case"/> <separator string="HD Case"/>
<group form_layout="stacked"> <group form_layout="stacked">
@ -38,4 +33,6 @@
<separator string="RD Shop"/> <separator string="RD Shop"/>
<field name="shop_type_id"/> <field name="shop_type_id"/>
<field name="signature"/> <field name="signature"/>
<separator string="Reporting"/>
<field name="product_categ_view"/>
</form> </form>

View File

@ -128,7 +128,7 @@ class HDCase(Model):
mdc_names.append(prod_name or "") mdc_names.append(prod_name or "")
else: else:
mdc+=amt mdc+=amt
mdc_names.append(name or "") mdc_names.append(prod_name or "")
if categ.code=='EPO': if categ.code=='EPO':
epo_names.append(prod_name.title()) epo_names.append(prod_name.title())
elif categ.code=='IVR': elif categ.code=='IVR':
@ -222,6 +222,7 @@ class HDCase(Model):
"mdc": fields.Float("MDC",function="_get_expense",function_multi=True), "mdc": fields.Float("MDC",function="_get_expense",function_multi=True),
"srv": fields.Float("Service",function="_get_expense",function_multi=True), "srv": fields.Float("Service",function="_get_expense",function_multi=True),
"mdc_name": fields.Float("MDC Name",function="_get_expense",function_multi=True), "mdc_name": fields.Float("MDC Name",function="_get_expense",function_multi=True),
"iron_name": fields.Float("Iron Name",function="_get_expense",function_multi=True),
'sickbed_id': fields.Many2One("clinic.sickbed",'Sickbed'), 'sickbed_id': fields.Many2One("clinic.sickbed",'Sickbed'),
"ref": fields.Char("Ref",search=True), "ref": fields.Char("Ref",search=True),
"time_start": fields.DateTime("Start Time",required=True), "time_start": fields.DateTime("Start Time",required=True),

View File

@ -141,14 +141,14 @@ class ReportCycleItem(Model):
return number return number
total_epo=0 total_epo=0
total_ivr=0
for line in hdcase.lines: for line in hdcase.lines:
prod=line.product_id prod=line.product_id
if prod.categ_id: if prod.categ_id:
if prod.categ_id.code=='EPO': if prod.categ_id.code=='EPO':
total_epo+=line.qty or 0 total_epo+=line.qty or 0
else: if prod.categ_id.code=='IVR':
pass total_ivr+=line.qty or 0
#print('>>> ', hdcase.number, prod.id, prod.name)
lines.append({ lines.append({
'dlz_drop': dlz_drop, 'dlz_drop': dlz_drop,
@ -166,6 +166,7 @@ class ReportCycleItem(Model):
'hdcase_number': reformat_number(hdcase.number), 'hdcase_number': reformat_number(hdcase.number),
'hdcase_id': hdcase.id, 'hdcase_id': hdcase.id,
'mdc_name': hdcase.mdc_name or hdcase.epo, 'mdc_name': hdcase.mdc_name or hdcase.epo,
'iron_name': hdcase.iron_name or '',
'fee': abs(hdcase.fee), 'fee': abs(hdcase.fee),
'dlz_name': hdcase.dlz_name, 'dlz_name': hdcase.dlz_name,
'dlz_use': dlz_use, 'dlz_use': dlz_use,
@ -182,6 +183,7 @@ class ReportCycleItem(Model):
'dpt_id': dpt.id, 'dpt_id': dpt.id,
'dpt_name': dpt.name or "", 'dpt_name': dpt.name or "",
'total_epo': total_epo, 'total_epo': total_epo,
'total_ivr': total_ivr,
}) })
month_str=utils.MONTHS['th_TH'][int(month)] month_str=utils.MONTHS['th_TH'][int(month)]
company_name=company.name or "" company_name=company.name or ""
@ -219,6 +221,10 @@ class ReportCycleItem(Model):
sub_mdc+=x['mdc'] or 0 sub_mdc+=x['mdc'] or 0
if not epos.get(x['mdc_name']): if not epos.get(x['mdc_name']):
epos[x['mdc_name']]=0 epos[x['mdc_name']]=0
#XXX
if not epos.get(x['iron_name']):
epos[x['iron_name']]=0
epos[x['iron_name']]+=x['total_ivr'] or 0 #XXX
epos[x['mdc_name']]+=x['total_epo'] or 0 epos[x['mdc_name']]+=x['total_epo'] or 0
count+=1 count+=1
line['date_txt']=line['date'] line['date_txt']=line['date']
@ -267,6 +273,7 @@ class ReportCycleItem(Model):
'description': v['description'], 'description': v['description'],
'qty': v['qty'], 'qty': v['qty'],
}) })
vscl_lines=sorted(vscl_lines,key=lambda x: x['description'])
ptype_lines=[] ptype_lines=[]
total_pt=0 total_pt=0
pkeys=list(ptypes.keys()) pkeys=list(ptypes.keys())

View File

@ -101,8 +101,12 @@ class ReportMedicalDetail(Model):
dom.append(['hd_case_id.branch_id','=',branch_id]) dom.append(['hd_case_id.branch_id','=',branch_id])
if department_id: if department_id:
dom.append(['hd_case_id.department_id','=',department_id]) dom.append(['hd_case_id.department_id','=',department_id])
if prod_categ_id: st=get_model("clinic.setting").browse(1)
dom.append(['product_categ_id.id','child_of',prod_categ_id]) ct_ids=[]
for categ in st.product_categ_view:
ct_ids.append(categ.id)
if ct_ids:
dom.append(['product_categ_id.id','in',ct_ids])
if product_id: if product_id:
dom.append(['product_id','=',product_id]) dom.append(['product_id','=',product_id])
if types and ids: if types and ids:

View File

@ -86,13 +86,17 @@ class ReportMedicalSummary(Model):
dom=[] dom=[]
dom.append(['type','=','stock']) dom.append(['type','=','stock'])
dom.append(['report_visible','=',True]) dom.append(['report_visible','=',True])
if prod_categ_id: st=get_model("clinic.setting").browse(1)
dom.append(['categ_id.id','child_of',prod_categ_id]) ct_ids=[]
for categ in st.product_categ_view:
ct_ids.append(categ.id)
if ct_ids:
dom.append(['categ_id.id','in',ct_ids])
categ_ids=set() categ_ids=set()
for prod in get_model("product").search_browse(dom): for prod in get_model("product").search_browse(dom):
prod_code=prod.code or "" prod_code=prod.code or ""
categ=prod.categ_id categ=prod.categ_id
if categ and categ.parent_id: if categ:
categ_ids.update({categ.id}) categ_ids.update({categ.id})
products[prod_code]={} products[prod_code]={}
for patient_type_id,type_name in patient_types.items(): for patient_type_id,type_name in patient_types.items():
@ -124,10 +128,6 @@ class ReportMedicalSummary(Model):
continue continue
if categ and categ.id not in list(categ_ids): if categ and categ.id not in list(categ_ids):
continue continue
#if line.type=='fee' or prod.type=='service':
#continue
#if prod_categ_id and prod_categ_id != prod.categ_id.id:
#continue
products[prod_code][patient_type_id]['qty']+=line.qty products[prod_code][patient_type_id]['qty']+=line.qty
lines=[] lines=[]

View File

@ -1,4 +1,3 @@
import time
from datetime import datetime, timedelta from datetime import datetime, timedelta
from calendar import monthrange from calendar import monthrange
@ -54,7 +53,6 @@ class ClinicSetting(Model):
'schd_to': fields.Date("To"), 'schd_to': fields.Date("To"),
'department_id': fields.Many2One("clinic.department","Department"), 'department_id': fields.Many2One("clinic.department","Department"),
'branch_id': fields.Many2One("clinic.branch","Branch"), 'branch_id': fields.Many2One("clinic.branch","Branch"),
'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 '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),
@ -65,6 +63,7 @@ class ClinicSetting(Model):
'next_date': fields.DateTime("Next Gen"), 'next_date': fields.DateTime("Next Gen"),
'staff_from_id': fields.Many2One("clinic.staff","Staff From"), 'staff_from_id': fields.Many2One("clinic.staff","Staff From"),
'staff_to_id': fields.Many2One("clinic.staff","Staff To"), 'staff_to_id': fields.Many2One("clinic.staff","Staff To"),
'product_categ_view': fields.Many2Many("product.categ","Product Category View"),
} }
_defaults={ _defaults={

View File

@ -229,8 +229,17 @@ class VisitBoard(Model):
visit_color='' visit_color=''
sickbed_name='N/A' sickbed_name='N/A'
sickbed_id=None sickbed_id=None
found_hdcase=False
is_paid=False
is_waiting=False
if visit.hd_cases: if visit.hd_cases:
hd_case=visit.hd_cases[0] hd_case=visit.hd_cases[0]
if hd_case.state in ('waiting_payment', 'paid'):
found_hdcase=True
if hd_case.state=='waiting_payment':
is_waiting=True
elif hd_case.state=='paid':
is_paid=True
sickbed_name=hd_case.sickbed_id.name or "N/A" sickbed_name=hd_case.sickbed_id.name or "N/A"
sickbed_id=hd_case.sickbed_id.id sickbed_id=hd_case.sickbed_id.id
hd_case_id=hd_case.id, hd_case_id=hd_case.id,
@ -288,7 +297,7 @@ class VisitBoard(Model):
'patient_type_id': patient.type_id.id or None, 'patient_type_id': patient.type_id.id or None,
'doctor_name': visit.doctor_id.name, 'doctor_name': visit.doctor_id.name,
'doctor_id': visit.doctor_id.id, 'doctor_id': visit.doctor_id.id,
'hd_case_number': hd_case_number, 'hd_case_number': (hd_case_number or '').replace('HDC/',''),
'hd_case_state': hd_case_state, 'hd_case_state': hd_case_state,
'hd_case_state_txt':HD_STATE.get(hd_case_state,''), 'hd_case_state_txt':HD_STATE.get(hd_case_state,''),
'hd_case_id': hd_case_id, 'hd_case_id': hd_case_id,
@ -304,7 +313,12 @@ class VisitBoard(Model):
'details5':'', 'details5':'',
'no': no, 'no': no,
'note': visit.note, 'note': visit.note,
'cost': 0,
'is_paid': is_paid,
'is_waiting': is_waiting,
} }
if found_hdcase:
line['cost']=hd_case.total_amount or 0
lines.append(line) lines.append(line)
no+=1 no+=1
if not types.get(visit_date): if not types.get(visit_date):

View File

@ -8,8 +8,8 @@
<thead class="scroll-header"> <thead class="scroll-header">
<th>วันที่</th> <th>วันที่</th>
<th>รอบ</th> <th>รอบ</th>
<th>No</th> <th>No.</th>
<th>HDC#</th> <th>HDC/</th>
<th>ชื่อ-สกุล</th> <th>ชื่อ-สกุล</th>
<th>แพทย์</th> <th>แพทย์</th>
<th>สิทธ์</th> <th>สิทธ์</th>
@ -32,7 +32,7 @@
{{/ifeq}} {{/ifeq}}
{{#if cseq_txt}} {{#if cseq_txt}}
<th>{{date_txt}}</th> <th>{{date_txt}}</th>
<th>{{cseq_txt}}</th> <th style="width:2%;text-align:center">{{cseq_txt}}</th>
<td style="text-align:center">{{no}}</td> <td style="text-align:center">{{no}}</td>
<td style="width:6%"><a href="/ui#name=clinic_hd_case&active_id={{hdcase_id}}&mode=form">{{hdcase_number}}</a></td> <td style="width:6%"><a href="/ui#name=clinic_hd_case&active_id={{hdcase_id}}&mode=form">{{hdcase_number}}</a></td>
<td><a href="/ui#name=clinic_patient&active_id={{pid}}&mode=form">{{pname}}</a></td> <td><a href="/ui#name=clinic_patient&active_id={{pid}}&mode=form">{{pname}}</a></td>

View File

@ -11,8 +11,8 @@
<th style="text-align:center">สิทธ์</th> <th style="text-align:center">สิทธ์</th>
<th style="text-align:center">แพทย์</th> <th style="text-align:center">แพทย์</th>
<th style="text-align:center">ชั้น</th> <th style="text-align:center">ชั้น</th>
<th style="text-align:center">เตียง</th> <th style="text-align:center">HDC/</th>
<th style="text-align:center">บันทึกการรักษา</th> <!--<th style="text-align:center">ค่าตอบแทน</th>-->
</thead> </thead>
<tbody> <tbody>
{{#each lines }} {{#each lines }}
@ -49,11 +49,6 @@
<td style="background-color:{{visit_color}}">{{patient_type}}</td> <td style="background-color:{{visit_color}}">{{patient_type}}</td>
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_staff&active_id={{doctor_id}}&mode=form">{{doctor_name}}</a></td> <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_staff&active_id={{doctor_id}}&mode=form">{{doctor_name}}</a></td>
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_department&active_id={{department_id}}&mode=form">{{department_name}}</a></td> <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_department&active_id={{department_id}}&mode=form">{{department_name}}</a></td>
{{#if sickbed_id}}
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_sickbed&active_id={{sickbed_id}}&mode=form">{{sickbed_name}}</a></td>
{{else}}
<td style="background-color:{{visit_color}}">{{sickbed_name}}</td>
{{/if}}
<td style="background-color:{{visit_color}}"> <td style="background-color:{{visit_color}}">
<a href="/ui#name=clinic_hd_case&active_id={{hd_case_id}}&mode=form"> <a href="/ui#name=clinic_hd_case&active_id={{hd_case_id}}&mode=form">
{{#ifeq number "Waiting"}} {{#ifeq number "Waiting"}}
@ -83,6 +78,17 @@
</span> </span>
</a> </a>
</td> </td>
<!--
{{#if is_paid}}
<td style="background-color:{{visit_color}};text-align:right;color:green">{{currency cost}}</td>
{{else}}
{{#if is_waiting}}
<td style="background-color:{{visit_color}};text-align:right;color:blue">{{currency cost}}</td>
{{else}}
<td style="background-color:{{visit_color}};text-align:right">{{currency cost}}</td>
{{/if}}
{{/if}}
-->
{{/if}} {{/if}}
</tr> </tr>
{{/if}} {{/if}}