conv_bal
watcha.h 2014-12-16 16:53:36 +07:00
parent ecbb73c7ac
commit 08911331ee
26 changed files with 164 additions and 85 deletions

View File

@ -1,5 +1,5 @@
<action> <action>
<field name="string">Payment Matching</field> <!--<field name="string">Payment Matching</field>-->
<field name="view_cls">report</field> <field name="view_cls">report</field>
<field name="model">clinic.report.payment.matching</field> <field name="model">clinic.report.payment.matching</field>
<field name="report_template">report_payment_matching</field> <field name="report_template">report_payment_matching</field>

View File

@ -0,0 +1,9 @@
<inherit model="partner" inherit="contact_form">
<field name="payment_terms" position="after">
<newline/>
<separator string="Clinic"/>
<field name="account_fee_id" />
<field name="account_mdc_id" />
<field name="account_service_id" />
</field>
</inherit>

View File

@ -5,10 +5,10 @@
<item string="Labor Cost Items" action="clinic_labor_cost_item"/> <item string="Labor Cost Items" action="clinic_labor_cost_item"/>
<item string="Labor Cost Entries" action="clinic_labor_cost_entry"/> <item string="Labor Cost Entries" action="clinic_labor_cost_entry"/>
<item string="Import Payment" action="import_clinic_payment"/> <item string="Import Payment" action="import_clinic_payment"/>
<item string="Matching Invoice" action="clinic_report_payment_matching"/>
<item string="HD Case Expense" action="clinic_hd_case_expense"/> <item string="HD Case Expense" action="clinic_hd_case_expense"/>
<divider/> <divider/>
<header string="REPORTS"/> <header string="REPORTS"/>
<item string="Payment Matching" action="clinic_report_payment_matching"/>
<item string="Staff Fee Summary" action="clinic_report_staff_fee_sum"/> <item string="Staff Fee Summary" action="clinic_report_staff_fee_sum"/>
<item string="Staff Fee Detail" action="clinic_report_staff_fee_detail"/> <item string="Staff Fee Detail" action="clinic_report_staff_fee_detail"/>
</item> </item>

View File

@ -1,14 +1,15 @@
<form model="clinic.period"> <form model="clinic.period">
<head> <head>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="Copy" method="copy"/> <!--<item string="Copy" method="copy"/>-->
</button> </button>
</head> </head>
<group form_layout="stacked"> <group form_layout="stacked">
<field name="name" span="3"/> <field name="name" span="2"/>
<field name="date_start" span="3"/> <field name="date_start" span="2"/>
<field name="date_stop" span="3"/> <field name="date_stop" span="2"/>
<field name="nmonth" span="3"/> <field name="nmonth" span="2"/>
<field name="last_period_id" span="3"/>
<field name="lines" nolabel="1"> <field name="lines" nolabel="1">
<list> <list>
<field name="date_start"/> <field name="date_start"/>

View File

@ -1,3 +1,4 @@
<list model="clinic.period"> <list model="clinic.period">
<field name="name"/> <field name="name"/>
<field name="last_period_id"/>
</list> </list>

View File

@ -1,7 +1,7 @@
<form model="clinic.report.payment.matching"> <form model="clinic.report.payment.matching">
<field name="date" span="2" mode="month" onchange="onchange_date"/> <field name="file" span="3" required="1"/>
<field name="date_from" span="2"/> <field name="type_id" span="3"/>
<field name="date_to" span="2"/> <!--<field name="date" span="3" mode="month" onchange="onchange_date"/>-->
<field name="state" span="2"/> <newline/>
<field name="patient_id" span="2"/> <button string='Match' type="success" size="small" icon="ok" method="match_invoice"/>
</form> </form>

View File

@ -7,6 +7,7 @@
<group form_layout="stacked"> <group form_layout="stacked">
<field name="waiting_approval" span="3"/> <field name="waiting_approval" span="3"/>
<field name="real_time" span="3"/> <field name="real_time" span="3"/>
<field name="auto_gen" span="3"/>
<separator string="Expenes"/> <separator string="Expenes"/>
<field name="products" nolabel="1"> <field name="products" nolabel="1">
<list> <list>

View File

@ -13,15 +13,14 @@
<separator string="Summary"/> <separator string="Summary"/>
<tabs> <tabs>
<tab string="Information"> <tab string="Information">
<field name="total_row" span="3" readonly="1"/> <button string="Match" span="1" icon="ok" size="small" type="success"/>
<field name="match_qty" span="3" readonly="1"/> <field name="match_qty" span="2" nolabel="1" readonly="1"/>
<field name="unmatch_qty" span="3" readonly="1"/> <button string="Un Match" span="1" icon="remove" size="small" type="danger"/>
<field name="fail_qty" span="3" readonly="1"/> <field name="unmatch_qty" span="2" nolabel="1" readonly="1"/>
<newline/>
<field name="est_time" span="4" readonly="1"/> <field name="est_time" span="4" readonly="1"/>
</tab> </tab>
<tab string="Message"> <tab string="Message">
<field name="msg" span="6" nolabel="1" width="1000" height="180"/> <field name="msg" span="6" nolabel="1" width="500" height="120"/>
</tab> </tab>
<tab string="Accounting"> <tab string="Accounting">
<group form_layout="stacked"> <group form_layout="stacked">

View File

@ -1,2 +1,2 @@
from . import clinic_setting from . import clinic_setting
from . import import_clinic_hd_case from . import import_data

View File

@ -6,7 +6,7 @@ from . import utils
class Migration(migration.Migration): class Migration(migration.Migration):
_name="import.clinic.hd.case" _name="import.clinic.hd.case"
_version="2.80" _version="2.10"
def import_visit(self,lines): def import_visit(self,lines):
visits={} visits={}
@ -69,16 +69,24 @@ class Migration(migration.Migration):
return visits return visits
def confirm_visit(self,visits): def confirm_visit(self,visits):
st=get_model("clinic.setting").browse(1)
st.write({
'auto_gen': True,
})
hd_case_ids=[] hd_case_ids=[]
visit_ids=visits.keys() visit_ids=visits.keys()
for visit in get_model('clinic.visit').browse(visit_ids): for visit in get_model('clinic.visit').browse(visit_ids):
if visit!='confirmed': if visit!='confirmed':
visit.confirm() visit.confirm()
hd_case=visit.hd_cases[0] hd_case=visit.hd_cases[0]
# lines
hd_case.write({ hd_case.write({
'hct': visits[visit.id]['hct'] or 0, 'hct': visits[visit.id]['hct'] or 0,
}) })
hd_case_ids.append(hd_case.id) hd_case_ids.append(hd_case.id)
st.write({
'auto_gen': False,
})
return hd_case_ids return hd_case_ids
@ -94,14 +102,12 @@ class Migration(migration.Migration):
fname='pks.xls' fname='pks.xls'
fpath=get_file_path(fname) fpath=get_file_path(fname)
lines=utils.read_excel(fpath,show_datetime=True) lines=utils.read_excel(fpath,show_datetime=True)
company_id=get_active_company()
set_active_company(1) set_active_company(1)
visits=self.import_visit(lines) visits=self.import_visit(lines)
print("visit ", len(visits)) print("visit ", len(visits))
hd_case_ids=self.confirm_visit(visits) hd_case_ids=self.confirm_visit(visits)
print('hd case ', len(hd_case_ids)) print('hd case ', len(hd_case_ids))
hd_case_ids=self.hdc_done(hd_case_ids) hd_case_ids=self.hdc_done(hd_case_ids)
set_active_company(company_id)
print('Done ', len(hd_case_ids)) print('Done ', len(hd_case_ids))
return True return True

View File

@ -11,6 +11,7 @@ from . import graduation
from . import morbidity from . import morbidity
from . import nation from . import nation
from . import address from . import address
from . import partner
from . import patient from . import patient
from . import patient_type from . import patient_type
from . import patient_categ from . import patient_categ

View File

@ -27,7 +27,7 @@ class GenVisit(Model):
'sunday': fields.Boolean("Sunday"), 'sunday': fields.Boolean("Sunday"),
'doctor_id': fields.Many2One("clinic.staff","Doctor",domain=[['type','=','doctor']]), 'doctor_id': fields.Many2One("clinic.staff","Doctor",domain=[['type','=','doctor']]),
'department_id': fields.Many2One("clinic.department","Department"), 'department_id': fields.Many2One("clinic.department","Department"),
"patient_type": fields.Selection([("sc","Social Security"),("uc","UC."),("others","Others")],"Patient Type"), "patient_type": fields.Selection([("s","Social Security"),("u","UC."),("others","Others")],"Patient Type"),
'patient_categ_id': fields.Many2One("clinic.patient.categ", "Patient Category"), 'patient_categ_id': fields.Many2One("clinic.patient.categ", "Patient Category"),
'nurse_categ_id': fields.Many2One("clinic.staff.categ", "Nurse Category", domain=[['type','=','nurse']]), 'nurse_categ_id': fields.Many2One("clinic.staff.categ", "Nurse Category", domain=[['type','=','nurse']]),
} }

View File

@ -887,6 +887,9 @@ class HDCase(Model):
})) }))
# fee # fee
st=get_model("clinic.setting").browse(1) st=get_model("clinic.setting").browse(1)
if not st.auto_gen:
return
if not vals.get('lines'): if not vals.get('lines'):
vals['lines']=[] vals['lines']=[]
for st_prod in st.products: for st_prod in st.products:

View File

@ -36,6 +36,7 @@ class HDCaseExpense(Model):
'note': fields.Text("Note"), 'note': fields.Text("Note"),
'pt_conflict': fields.Boolean("Patient Conclict",function="_get_patient_conflict"), 'pt_conflict': fields.Boolean("Patient Conclict",function="_get_patient_conflict"),
'company_id': fields.Many2One("company","Company"), 'company_id': fields.Many2One("company","Company"),
'match_id': fields.Many2One("clinic.report.payment.matching","Match"),
} }
_defaults={ _defaults={

View File

@ -49,9 +49,9 @@ class ImportPatient(Model):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
ptype=obj.patient_type_id ptype=obj.patient_type_id
res={} res={}
if ptype.code=='PKS': if ptype.code=='S':
res=self.import_patient_pks(ids,context) res=self.import_patient_pks(ids,context)
elif ptype.code=='UC': elif ptype.code=='U':
res=self.import_patient_uc(ids,context) res=self.import_patient_uc(ids,context)
else: else:
raise Exception('No script to import patient with type %s'%ptype.name) raise Exception('No script to import patient with type %s'%ptype.name)

View File

@ -90,6 +90,8 @@ class ImportPayment(Model):
'state': 'draft', 'state': 'draft',
'is_uc': 0, 'is_uc': 0,
'node': 'HDBills', 'node': 'HDBills',
'match_qty': 0,
'unmatch_qty': 0,
} }
def get_patient_invoice(self,state="waiting_payment"): def get_patient_invoice(self,state="waiting_payment"):
@ -253,9 +255,9 @@ class ImportPayment(Model):
raise Exception("File not found") raise Exception("File not found")
patient_type=obj.type_id patient_type=obj.type_id
res={} res={}
if patient_type.code in ('PKS','SC'): if patient_type.code in ('S'):
res=self.import_payment_pks(ids,context) res=self.import_payment_pks(ids,context)
elif patient_type.code in ('UC','uc','UC.','uc.'): elif patient_type.code in ('U'):
res=self.import_payment_uc(ids,context) res=self.import_payment_uc(ids,context)
else: else:
raise Exception("No script to import payment for type %s"%patient_type.name) raise Exception("No script to import payment for type %s"%patient_type.name)
@ -343,7 +345,7 @@ class ImportPayment(Model):
is_uc=0 is_uc=0
type_id=data['type_id'] type_id=data['type_id']
ptype=get_model('clinic.patient.type').browse(type_id) ptype=get_model('clinic.patient.type').browse(type_id)
if ptype.code=='UC': if ptype.code=='U':
is_uc=1 is_uc=1
data['is_uc']=is_uc data['is_uc']=is_uc
return data return data

View File

@ -49,9 +49,9 @@ class ImportVisit(Model):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
ptype=obj.patient_type_id ptype=obj.patient_type_id
res={} res={}
if ptype.code=='PKS': if ptype.code=='S':
res=self.import_visit_pks(ids,context) res=self.import_visit_pks(ids,context)
elif ptype.code=='UC': elif ptype.code=='U':
res=self.import_visit_uc(ids,context) res=self.import_visit_uc(ids,context)
else: else:
raise Exception('No script to import visit with type %s'%ptype.name) raise Exception('No script to import visit with type %s'%ptype.name)

View File

@ -0,0 +1,12 @@
from netforce.model import Model, fields
class Partner(Model):
_inherit="partner"
_fields={
"account_mdc_id": fields.Many2One("account.account","Account Medicine",multi_company=True),
"account_fee_id": fields.Many2One("account.account","Account Fee",multi_company=True),
"account_service_id": fields.Many2One("account.account","Account Service",multi_company=True),
}
Partner.register()

View File

@ -1,5 +1,4 @@
import time import time
from datetime import datetime, timedelta
from calendar import monthrange from calendar import monthrange
from netforce.model import Model, fields from netforce.model import Model, fields
@ -8,13 +7,23 @@ class Period(Model):
_name="clinic.period" _name="clinic.period"
_string="Period" _string="Period"
def _get_last_period(self,ids,context={}):
res={}
for obj in self.browse(ids):
last_id=None
for line in obj.lines:
if line.close:
last_id=line.id
res[obj.id]=last_id
return res
_fields={ _fields={
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
'date_start': fields.Date("From",required=True), 'date_start': fields.Date("From",required=True),
'date_stop': fields.Date("To",required=True), 'date_stop': fields.Date("To",required=True),
#'duration': fields.Integer("Day in Period",required=True), 'nmonth': fields.Integer("Count",required=True),
'nmonth': fields.Integer("Total Copy",required=True),
'lines': fields.One2Many("clinic.period.line","period_id", "Lines"), 'lines': fields.One2Many("clinic.period.line","period_id", "Lines"),
'last_period_id': fields.Many2One("clinic.period.line","Last Period",function="_get_last_period"),
} }
def _get_start(self,context={}): def _get_start(self,context={}):

View File

@ -16,11 +16,18 @@ class PeriodLine(Model):
res[obj.id]=days res[obj.id]=days
return res return res
def _get_name(self,ids,context={}):
res={}
for obj in self.browse(ids):
res[obj.id]='%s - %s'%(obj.date_start, obj.date_stop)
return res
_fields={ _fields={
'name': fields.Char("Name",function="_get_name",store=True),
"period_id": fields.Many2One("clinic.period", "Period"), "period_id": fields.Many2One("clinic.period", "Period"),
'date_start': fields.Date("Date Start"), 'date_start': fields.Date("Date Start"),
'date_stop': fields.Date("Date Stop"), 'date_stop': fields.Date("Date Stop"),
'day_total': fields.Integer("Total Day",function="_get_total"), 'day_total': fields.Integer("Duration (Day)",function="_get_total"),
'state': fields.Selection([['draft','Draft'],['done','Done']],"State"), 'state': fields.Selection([['draft','Draft'],['done','Done']],"State"),
'close': fields.Boolean("Close"), 'close': fields.Boolean("Close"),
} }
@ -30,4 +37,13 @@ class PeriodLine(Model):
'close': False, 'close': False,
} }
def create(self,vals,**kw):
id=super().create(vals,**kw)
self.function_store([id])
return id
def write(self,ids,vals,**kw):
super().write(ids,vals,**kw)
self.function_store(ids)
PeriodLine.register() PeriodLine.register()

View File

@ -16,6 +16,8 @@ class ReportPaymentMatching(Model):
"date_to": fields.Date("To", required=True), "date_to": fields.Date("To", required=True),
'state': fields.Selection([['draft','Draft'],['waiting_matching','Waiting Matching'],['match','Match'],['unmatch','Unmatch'],['approved','Approved']],'State'), 'state': fields.Selection([['draft','Draft'],['waiting_matching','Waiting Matching'],['match','Match'],['unmatch','Unmatch'],['approved','Approved']],'State'),
'patient_id': fields.Many2One("clinic.patient","Patient"), 'patient_id': fields.Many2One("clinic.patient","Patient"),
'file': fields.File("File"),
'type_id': fields.Many2One("clinic.patient.type","Patient Type",required=True),
} }
def _get_date_from(self,context={}): def _get_date_from(self,context={}):
@ -27,53 +29,58 @@ class ReportPaymentMatching(Model):
weekday, total_day=monthrange(int(year), int(month)) weekday, total_day=monthrange(int(year), int(month))
return "%s-%s-%s"%(year,month,total_day) return "%s-%s-%s"%(year,month,total_day)
def _get_type_id(self,context={}):
st=get_model("clinic.setting").browse(1)
return st.patient_type_id.id
_defaults={ _defaults={
'date': lambda *a: time.strftime("%Y-%m-%d"), 'date': lambda *a: time.strftime("%Y-%m-%d"),
'date_from': _get_date_from, 'date_from': _get_date_from,
'date_to': _get_date_to, 'date_to': _get_date_to,
'state': 'match', 'state': 'match',
'type_id': _get_type_id,
} }
def match_invoice(self,ids,context={}):
obj=self.browse(ids)[0]
if not obj.file:
raise Exception("File not found!")
for exp in get_model("clinic.hd.case.expense").search_browse([]):
exp.write({
'match_id': obj.id,
})
return {
'next': {
'name': 'clinic_report_payment_matching',
'mode': 'form',
'active_id': obj.id,
},
'flash': 'Match successfully',
}
def get_report_data(self,ids,context={}): def get_report_data(self,ids,context={}):
year, month=time.strftime("%Y-%m").split("-") year, month=time.strftime("%Y-%m").split("-")
weekday, total_day=monthrange(int(year), int(month)) obj_id=None
time_start='%s-%s-01'%(year,str(month).zfill(2))
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
defaults=context.get('defaults')
if defaults:
year,month,total_day=defaults['date'].split("-")
weekday, total_day=monthrange(int(year), int(month))
time_start='%s-%s-01'%(year,str(month).zfill(2))
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
if ids: if ids:
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
month=obj.date_from.split("-")[1] obj_id=obj.id
time_start=obj.date_from
time_stop=obj.date_to
dom=[]
dom.append(['time_start','>=','%s 00:00:00'%time_start])
dom.append(['time_stop','<=','%s 23:59:59'%time_stop])
lines=[] lines=[]
for exp in get_model("clinic.hd.case.expense").search_browse([]):
company_id=get_active_company() if exp.match_id.id!=obj_id:
company=get_model('company').browse(company_id) continue
month_str=utils.MONTHS['th_TH'][int(month)] patient=exp.patient_id
lines.append({
lines=sorted(lines, key=lambda x: x['prod_name']) 'name': patient.name,
year=int(year)+543 'fee': 'Yes',
'medicine': 'Yes',
'service': 'Yes',
'state': 'Match',
})
data={ data={
'company_name': company.name or "",
'parent_company_name': company.parent_id.name or "",
'lines': lines, 'lines': lines,
'month': month_str,
'year': year,
} }
return data return data
def onchange_date(self,context={}): def onchange_date(self,context={}):

View File

@ -21,6 +21,7 @@ class ClinicSetting(Model):
'patient_type_id': fields.Many2One("clinic.patient.type","Default Type"), # Import payment 'patient_type_id': fields.Many2One("clinic.patient.type","Default Type"), # Import payment
'find_dlz': fields.Boolean("Find Dialyzer After Confirm Visit"), # Visit 'find_dlz': fields.Boolean("Find Dialyzer After Confirm Visit"), # Visit
'stock_journal_id': fields.Many2One("stock.journal","Default Journal"), 'stock_journal_id': fields.Many2One("stock.journal","Default Journal"),
'auto_gen': fields.Boolean("Auto Gen") # HD Case
} }
_defaults={ _defaults={

View File

@ -11,6 +11,8 @@ class SettingPolicy(Model):
"invoice_option": fields.Selection([("fee_mdc_plus","Combine Fee & Medicine"),("fee_mdc_split","Split Fee & Medicine")],"Option"), "invoice_option": fields.Selection([("fee_mdc_plus","Combine Fee & Medicine"),("fee_mdc_split","Split Fee & Medicine")],"Option"),
} }
_order="patient_type_id"
def _write(self,ids,vals,**kw): def _write(self,ids,vals,**kw):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
if obj.invoice_policy=='fee': if obj.invoice_policy=='fee':

View File

@ -6,7 +6,7 @@ class SettingProduct(Model):
_fields={ _fields={
"setting_id": fields.Many2One("clinic.setting","Setting"), "setting_id": fields.Many2One("clinic.setting","Setting"),
"type": fields.Selection([("fee","Fee"),('medicine','Medicine'),("others","Others")],"Type",required=True), "type": fields.Selection([("fee","Fee"),('medicine','Medicine'),('service','Service'),("others","Others")],"Type",required=True),
"patient_type_id": fields.Many2One("clinic.patient.type","Patient Type"), "patient_type_id": fields.Many2One("clinic.patient.type","Patient Type"),
'uom_id': fields.Many2One("uom","UOM", required=True), 'uom_id': fields.Many2One("uom","UOM", required=True),
"product_id": fields.Many2One("product","Product"), "product_id": fields.Many2One("product","Product"),
@ -22,7 +22,7 @@ class SettingProduct(Model):
'qty': 1, 'qty': 1,
} }
_order="patient_type,type" _order="patient_type_id,type"
SettingProduct.register() SettingProduct.register()

View File

@ -1,20 +1,23 @@
<center> <center>
<h2>Payment Matching</h2> <h4>Payment Matching</h4>
<h4>
{{#if is_duration}}
ระหว่างวันที่ {{from}} ถึง {{to}}
{{else}}
ประจำเดือน {{month}} {{year}}
{{/if}}
</h4>
</center> </center>
{{#if lines}} {{#if lines}}
<table class="table table-condensed table-striped"> <table class="table table-condensed table-striped">
<thead> <thead>
<th>Patient</th>
<th>Fee(1,500)</th>
<th>Medicine</th>
<th>Service</th>
<th>Status</th>
</thead> </thead>
<tbody> <tbody>
{{#each lines}} {{#each lines}}
<tr> <tr>
<td>{{name}}</td>
<td>{{fee}}</td>
<td>{{medicine}}</td>
<td>{{service}}</td>
<td>{{state}}</td>
</tr> </tr>
{{/each}} {{/each}}
</tbody> </tbody>
@ -22,5 +25,5 @@
</tfoot> </tfoot>
</table> </table>
{{else}} {{else}}
No items to display. Waiting matching.
{{/if}} {{/if}}

View File

@ -1,3 +1,7 @@
==
if patient not do visit before treatment , how to do?
==
import payment
====== ======
import payment import payment
step: step:
@ -6,4 +10,5 @@
3. import 3. import
- find import - find import
- -
- change day schedue relate
====== ======