visit board

conv_bal
watcha.h@almacom.co.th 2015-01-09 14:48:01 +07:00
parent cbde2cc6ff
commit 1e2df5ee65
8 changed files with 35 additions and 20 deletions

View File

@ -39,6 +39,8 @@
</item> </item>
<item string="HD Cases"> <item string="HD Cases">
<item string="HD Cases" action="clinic_hd_case"/> <item string="HD Cases" action="clinic_hd_case"/>
<divider/>
<header string="OTHERS"/>
<item string="Sickbed" action="clinic_sickbed"/> <item string="Sickbed" action="clinic_sickbed"/>
</item> </item>
<item string="Reports"> <item string="Reports">

View File

@ -6,6 +6,7 @@
</head> </head>
<field name="name"/> <field name="name"/>
<field name="available" readonly="1"/> <field name="available" readonly="1"/>
<field name="sequence"/>
<field name="company_id" invisible="1"/> <field name="company_id" invisible="1"/>
<related> <related>
<field name="hd_cases"/> <field name="hd_cases"/>

View File

@ -939,26 +939,29 @@ class HDCase(Model):
def write(self,ids,vals,**kw): def write(self,ids,vals,**kw):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
############ to show pay button ###########
total_amt=0 total_amt=0
due_amt=0 due_amt=0
if 'lines' in vals.keys(): if 'lines' in vals.keys():
for line in vals['lines']: for line in vals['lines']:
mode=line[0] mode=line[0]
amt=0
if mode=='create': if mode=='create':
line_vals=line[1] line_vals=line[1]
amt=line_vals.get("amount",0)
else: else:
line_id=line[1][0]
line_vals=line[2] line_vals=line[2]
amt=line_vals.get("amount",0) line=get_model('clinic.hd.case.line').browse(line_id)
amt=line.amount or 0
total_amt+=amt total_amt+=amt
rmb=line_vals.get("reimbursable","no") rmb=line_vals.get("reimbursable","no")
print('rmb ', rmb)
if rmb=='no': if rmb=='no':
due_amt+=amt due_amt+=amt
else: else:
for line in obj.lines: for line in obj.lines:
amt=line.amount or 0 amt=line.amount or 0
total_amt+=amt total_amt+=amt
print('>> rmb ', line.reimbursable)
if line.reimbursable=='no': if line.reimbursable=='no':
due_amt+=amt due_amt+=amt
pay_amt=0 pay_amt=0
@ -975,19 +978,12 @@ class HDCase(Model):
due_amt-=pay_amt due_amt-=pay_amt
vals['req_fee']=0 vals['req_fee']=0
print('due_amt ', due_amt)
if due_amt<=0: if due_amt<=0:
vals['req_fee']=1 vals['req_fee']=0
elif due_amt>0: elif due_amt>0:
vals['req_fee']=1 vals['req_fee']=1
#if obj.state=='completed': #################################################3
#if pay_amt==0:
#vals['req_fee']=0 # to hide button pay
#elif pay_amt==total_amt:
#vals['req_fee']=1 # to show button pay
#elif pay_amt<total_amt:
#vals['req_fee']=1 # to show button pay
if 'sickbed_id' in vals.keys(): if 'sickbed_id' in vals.keys():
if vals['sickbed_id']!=obj.sickbed_id.id and obj.state!='draft': if vals['sickbed_id']!=obj.sickbed_id.id and obj.state!='draft':

View File

@ -230,7 +230,7 @@ class Patient(Model):
name=obj.name or '' name=obj.name or ''
if obj.hn_no: if obj.hn_no:
name+=" (HN: %s)"%obj.hn_no name+=" (HN: %s)"%obj.hn_no
vals.append((obj.id,name)) vals.append((obj.id,name,obj.image))
return vals return vals
def name_search(self,name,domain=None,context={},**kw): def name_search(self,name,domain=None,context={},**kw):

View File

@ -33,12 +33,16 @@ class SickBed(Model):
'image': fields.File("Image",function="_get_all",function_multi=True), 'image': fields.File("Image",function="_get_all",function_multi=True),
'date': fields.Date("Date",function="_get_all",function_multi=True), 'date': fields.Date("Date",function="_get_all",function_multi=True),
"state": fields.Selection([("available","Available"),("not_available","Not Available")],"Status"), "state": fields.Selection([("available","Available"),("not_available","Not Available")],"Status"),
'sequence': fields.Integer("Sequence"),
} }
_defaults={ _defaults={
'available': True, 'available': True,
"company_id": lambda *a: get_active_company(), "company_id": lambda *a: get_active_company(),
'sequence': 0,
} }
_order="sequence"
def copy(self,ids,context={}): def copy(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]

View File

@ -27,7 +27,7 @@ class Visit(Model):
res[obj.id]={ res[obj.id]={
'cycle_color': color, 'cycle_color': color,
'sequence': '%s-%s'%(obj.time_start[0:10],cycle.sequence), #date-sequence 'sequence': '%s-%s'%(obj.time_start[0:10],cycle.sequence), #date-sequence
'visit_date': obj.time_start[0:10] #'visit_date': obj.time_start[0:10]
} }
return res return res
@ -48,7 +48,7 @@ class Visit(Model):
'print_date': fields.Date('Print Date',function="_get_print_date"), 'print_date': fields.Date('Print Date',function="_get_print_date"),
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), #XXX on_delete="cascade" -> rm visit from cycle item 'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), #XXX on_delete="cascade" -> rm visit from cycle item
'sequence': fields.Char("Sequence",function="_get_all",function_multi=True,store=True), 'sequence': fields.Char("Sequence",function="_get_all",function_multi=True,store=True),
'visit_date': fields.Date('Visit Date',function="_get_all",function_multi=True,store=True), 'visit_date': fields.Date('Visit Date'),
'cycle_color': fields.Char('Color',function="_get_all",function_multi=True,store=True), 'cycle_color': fields.Char('Color',function="_get_all",function_multi=True,store=True),
'note': fields.Text('Note'), 'note': fields.Text('Note'),
} }

View File

@ -138,7 +138,6 @@ class VisitBoard(Model):
number='*(ยกเลิก)' number='*(ยกเลิก)'
else: else:
number+='(ยกเลิก)' number+='(ยกเลิก)'
print('sickbed_id ', sickbed_id)
line={ line={
'number': number, 'number': number,
'hn_name': hn_name, 'hn_name': hn_name,
@ -160,6 +159,9 @@ class VisitBoard(Model):
'title': False, 'title': False,
'footer': False, 'footer': False,
'details':'', 'details':'',
'details1':'',
'details2':'',
'details3':'',
'no': no, 'no': no,
'note': visit.note, 'note': visit.note,
'hd_case_state':HD_STATE.get(hd_case_state,''), 'hd_case_state':HD_STATE.get(hd_case_state,''),
@ -199,10 +201,13 @@ class VisitBoard(Model):
index+=1 index+=1
# footer # footer
line=empty_line.copy() line=empty_line.copy()
patient_str='[%s]'%', '.join('%s: %s'%(patient_types[k],v) for k,v in types[date].items()) patient_str='>> %s'%', '.join('%s: %s'%(patient_types[k],v) for k,v in types[date].items())
cycle_str='[%s]'%', '.join('%s: %s'%(cycle_names[k],v) for k,v in cycles[date].items()) cycle_str='>> %s'%', '.join('%s: %s'%(cycle_names[k],v) for k,v in cycles[date].items())
summary_str='[%s]'%', '.join(['รับไว้: %s'%total_wait,'จำหน่ายแล้ว: %s'%total_done, 'ยกเลิก: %s'%total_cancel]) summary_str='>> %s'%', '.join(['รับไว้: %s'%total_wait,'จำหน่ายแล้ว: %s'%total_done, 'ยกเลิก: %s'%total_cancel])
line['details']='ทั้งหมด %s: %s'%(total_qty,', '.join([summary_str,cycle_str,patient_str])) line['details']='ทั้งหมด %s: %s'%(total_qty,', '.join([summary_str,cycle_str,patient_str]))
line['details1']=summary_str
line['details2']=cycle_str
line['details3']=patient_str
line['footer']=True line['footer']=True
line['title']=False line['title']=False
lines.insert(index,line) lines.insert(index,line)

View File

@ -30,7 +30,14 @@
{{#each lines }} {{#each lines }}
{{#if footer}} {{#if footer}}
<tr> <tr>
<td colspan="10" style="text-align:right; background-color:#dbdbdb"><b>{{details}}</b></td> <td rowspan="3" align="middle" style="vertical-align:middle; background-color:#4183c4;color:white"><span><b>TOTAL</b></span></td>
<td colspan="10" style="text-align:right; background-color:#dbdbdb"><b>{{details1}}</b></td>
</tr>
<tr>
<td colspan="10" style="text-align:right; background-color:#dbdbdb"><b>{{details2}}</b></td>
</tr>
<tr>
<td colspan="10" style="text-align:right; background-color:#dbdbdb"><b>{{details3}}</b></td>
</tr> </tr>
{{else}} {{else}}
<tr style="background-color:{{visit_color}}"> <tr style="background-color:{{visit_color}}">