Merge branch 'stable'

report_acc_hdcase_summary
watcha.h 2016-08-18 10:38:54 +07:00
commit 1bdffd8194
38 changed files with 849 additions and 71 deletions

View File

@ -0,0 +1,6 @@
<action>
<field name="view_cls">form_view</field>
<field name="model">create.invoice.payment</field>
<field name="view_xml">create_invoice_payment_form</field>
<field name="menu">account_menu</field>
</action>

View File

@ -5,5 +5,6 @@
</field> </field>
<field name="memo" position="after"> <field name="memo" position="after">
<field name="account_id" string="Account Receivable" span="2"/> <field name="account_id" string="Account Receivable" span="2"/>
<field name="patient_type_id" span="2"/>
</field> </field>
</inherit> </inherit>

View File

@ -1,5 +1,6 @@
<inherit model="account.invoice" inherit="cust_invoice_list"> <inherit inherit="cust_invoice_list">
<field name="partner_id" position="after"> <field name="ref" position="after">
<field name="department_id"/> <field name="patient_type_id"/>
</field> </field>
<field name="memo" position="replace"/>
</inherit> </inherit>

View File

@ -3,7 +3,7 @@
<field name="state"/> <field name="state"/>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="Copy" method="copy"/> <item string="Copy" method="copy"/>
<item string="To Draft" method="to_draft" states="active"/> <item string="To Draft" method="to_draft" states="active,drop,cancelled"/>
</button> </button>
</head> </head>
<group span="6" columns="1"> <group span="6" columns="1">

View File

@ -64,7 +64,7 @@
</tab> </tab>
<tab string="Expense"> <tab string="Expense">
<group span="12" form_layout="stacked"> <group span="12" form_layout="stacked">
<field name="lines" count="3" nolabel="1"> <field name="lines" count="3" nolabel="1" attrs='{"readonly":[["state","in",["waiting_payment","completed","paid"]]]}'>
<list> <list>
<field name="product_categ_id" onchange="onchange_line"/> <field name="product_categ_id" onchange="onchange_line"/>
<field name="product_id" domain='[["categ_id.id","=",product_categ_id],["patient_types.id","=",parent.patient_type_id]]' onchange="onchange_product"/> <field name="product_id" domain='[["categ_id.id","=",product_categ_id],["patient_types.id","=",parent.patient_type_id]]' onchange="onchange_product"/>
@ -100,9 +100,8 @@
</group> </group>
</tab> </tab>
<tab string="Doctors"> <tab string="Doctors">
<field name="staffs" nolabel="1"> <field name="staffs" nolabel="1" attrs='{"readonly":[["state","=","completed"]]}'>
<list> <list>
<!--<field name="type" invisible="1"/>-->
<field name="staff_id" onchange="onchange_staff" domain="[['type','=','doctor']]"/> <field name="staff_id" onchange="onchange_staff" domain="[['type','=','doctor']]"/>
<field name="priop"/> <field name="priop"/>
<field name="note"/> <field name="note"/>

View File

@ -0,0 +1,16 @@
<form model="clinic.hd.case.payment">
<field name="hd_case_id" invisible="1"/>
<field name="bill_no"/>
<field name="pay_amount" onchange="onchange_amount"/>
<newline/>
<field name="to_pay" readonly="1"/>
<newline/>
<group attrs='{"invisible":[["pay_amount","=",0]]}'>
<field name="complete" help="Mark as complete"/>
</group>
<foot>
<button attrs='{"invisible":[["pay_amount","=",0]]}' string="Cash" type="success" icon="ok" method="cash" confirm="Are you sure?"/>
<button attrs='{"invisible":[["pay_amount","=",0]]}' string="Credit" type="default" icon="check" method="credit"/>
<button attrs='{"invisible":[["pay_amount","!=",0]]}' string="OK" type="success" icon="ok" method="credit"/>
</foot>
</form>

View File

@ -1,5 +0,0 @@
<inherit model="account.payment" inherit="payment_form">
<item string="Copy" position="after">
<item string="Import Payment (UC)" method="import_payment"/>
</item>
</inherit>

View File

@ -1,16 +1,5 @@
<form model="clinic.hd.case.payment"> <inherit inherit="payment_form">
<field name="hd_case_id" invisible="1"/> <item string="Copy" position="after">
<field name="bill_no"/> <item string="Import Payment (UC)" method="import_payment"/>
<field name="pay_amount" onchange="onchange_amount"/> </item>
<newline/> </inherit>
<field name="to_pay" readonly="1"/>
<newline/>
<group attrs='{"invisible":[["pay_amount","=",0]]}'>
<field name="complete" help="Mark as complete"/>
</group>
<foot>
<button attrs='{"invisible":[["pay_amount","=",0]]}' string="Cash" type="success" icon="ok" method="cash" confirm="Are you sure?"/>
<button attrs='{"invisible":[["pay_amount","=",0]]}' string="Credit" type="default" icon="check" method="credit"/>
<button attrs='{"invisible":[["pay_amount","!=",0]]}' string="OK" type="success" icon="ok" method="credit"/>
</foot>
</form>

View File

@ -14,8 +14,8 @@
<field name="account_products" nolabel="1"> <field name="account_products" nolabel="1">
<list> <list>
<field name="patient_type_id"/> <field name="patient_type_id"/>
<field name="ar_debit_id"/> <field name="ar_debit_id" domain='[["type","!=","view"]]'/>
<field name="ar_credit_id"/> <field name="ar_credit_id" domain='[["type","!=","view"]]'/>
<field name="type"/> <field name="type"/>
</list> </list>
</field> </field>

View File

@ -10,16 +10,18 @@
<separator string="Visit"/> <separator string="Visit"/>
<group form_layout="stacked"> <group form_layout="stacked">
<field name="find_dlz" span="3"/> <field name="find_dlz" span="3"/>
<field name="hdcase_picking_auto" span="3"/>
<field name="dlz_picking_auto" span="3"/> <field name="dlz_picking_auto" span="3"/>
</group> </group>
<separator string="HD Case"/> <separator string="HD Case"/>
<field name="hdcase_picking_auto" span="3"/>
<field name="get_old_expense" span="3"/>
<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" invisible="1" span="3"/> <field name="auto_gen" invisible="1" span="3"/>
<field name="products" nolabel="1"> <field name="products" nolabel="1">
<list> <list>
<field name="sequence"/>
<field name="patient_type_id" onchange="onchange_ptype"/> <field name="patient_type_id" onchange="onchange_ptype"/>
<field name="product_categ_id"/> <field name="product_categ_id"/>
<field name="product_id" domain='[["categ_id.id","=",product_categ_id],["patient_types.id","=",patient_type_id]]' onchange="onchange_product"/> <field name="product_id" domain='[["categ_id.id","=",product_categ_id],["patient_types.id","=",patient_type_id]]' onchange="onchange_product"/>

View File

@ -0,0 +1,18 @@
<form model="create.invoice.payment">
<head>
<field name="state"/>
</head>
<field name="date" mode="month" onchange="onchange_date" span="3"/>
<field name="date_from" span="3"/>
<field name="date_to" span="3"/>
<newline/>
<field name="partner_id" span="3"/>
<field name="account_id" domain='[["type","!=","view"]]' states="ready_payment" span="3"/>
<related>
<field name="invoices"/>
</related>
<foot replace="1">
<button string="Back" states="ready_payment" method="back_step" type="default" icon="arrow-left"/>
<button string="Next" method="do_next" type="primary" icon="arrow-right"/>
</foot>
</form>

View File

@ -0,0 +1,14 @@
<list model="account.payment">
<top>
<button string="Create Invoice Payment" action="create_invoice_payment"/>
</top>
<field name="number"/>
<field name="date"/>
<field name="partner_id"/>
<field name="type"/>
<field name="pay_type"/>
<field name="account_id"/>
<field name="ref"/>
<field name="amount_total"/>
<field name="state"/>
</list>

View File

@ -7,4 +7,8 @@ from . import clinic_setting
#from . import check_seq #from . import check_seq
#from . import del_gi #from . import del_gi
#from . import restore_picking #from . import restore_picking
from . import rename_dbl_hdcase_number #from . import rename_dbl_hdcase_number
#from . import reset_hdcase_number
#from . import remove_dbl_contact
#from . import update_invoice
from . import update_pick_out_number

View File

@ -0,0 +1,53 @@
from netforce.model import get_model
from netforce import migration
from netforce.access import set_active_user, set_active_company
class Migration(migration.Migration):
_name="clinic.remove.dbl.contact"
_version="2.12.3"
def migrate(self):
set_active_company(1)
set_active_user(1)
contacts={}
context={
'active_test': False, #find archive also
}
for partner in get_model("partner").search_browse([],context=context):
contacts.setdefault(partner.name,{'name': partner.name,'lines': []})
contacts[partner.name]['lines'].append(partner.id)
cnames={}
for contact_name, vals in contacts.items():
lines=vals['lines']
if len(lines) > 1:
for contact_id in lines:
contact=get_model('partner').browse(contact_id)
if contact.is_patient:
res=get_model("clinic.patient").search([['partner_id','=',contact_id]])
if not res:
try:
print(contact_name,' not use, will delete')
get_model('partner').delete([contact_id])
except Exception as e:
print("Can not delete contact_id ", contact_id)
print("ERROR ", e)
else:
res=get_model("account.invoice").search_read([['partner_id','=',contact_id]],['number'])
if not res:
print(contact_name,' not use, will delete')
get_model('partner').delete([contact_id])
else:
if contact_name not in cnames.keys():
cnames[contact_name]=contact_id
else:
for r in res:
inv=get_model('account.invoice').browse(r['id'])
inv.write({
'partner_id': cnames[contact_name],
})
get_model('partner').delete([contact_id])
print("del ", contact_name)
print("#"*80)
Migration.register()

View File

@ -0,0 +1,29 @@
import time
from netforce.model import get_model
from netforce import migration
from netforce.access import set_active_user, set_active_company
class Migration(migration.Migration):
_name="clinic.rename.dbl.hdcase.number"
_version="2.12.2"
def migrate(self):
set_active_company(1)
set_active_user(1)
datenow=time.strftime("%Y-%m-%d")
dom=[
['date','>=',datenow],
['date','<=',datenow],
]
for hdcase in get_model("clinic.hd.case").search_browse(dom):
nums=hdcase.number.split("-")
if len(nums)==3 and len(nums[1])==4:
run=nums[1]
number='-'.join([nums[0],run[0:2],run[2:],nums[2]])
print('XXX', hdcase.number, ' --> ', number)
hdcase.write({
'number': number,
})
Migration.register()

View File

@ -0,0 +1,22 @@
from netforce.model import get_model
from netforce import migration
from netforce.access import set_active_user, set_active_company
from netforce.database import get_connection
class Migration(migration.Migration):
_name="clinic.update.invoice"
_version="2.12.4"
def migrate(self):
set_active_company(1)
set_active_user(1)
db=get_connection()
for ptype_id in get_model("clinic.patient.type").search([]):
pids=get_model('clinic.patient').search([['type_id','=',ptype_id]])
if pids:
db.execute("""
update account_invoice set patient_type_id=%s where patient_id in %s
""",ptype_id,tuple(pids))
print("update type %s to invoice -> Done"%(ptype_id))
Migration.register()

View File

@ -0,0 +1,29 @@
from netforce.model import get_model
from netforce import migration
from netforce.access import set_active_user, set_active_company
from netforce.database import get_connection
class Migration(migration.Migration):
_name="clinic.update.pick.out.number"
_version="2.12.5"
def migrate(self):
set_active_company(1)
set_active_user(1)
db=get_connection()
count=0
for pick in get_model('stock.picking').search_browse([]):
journal=pick.journal_id
sequence=journal.sequence_id
branch=sequence.branch_id
prefix=sequence.prefix
if prefix not in pick.number:
new_number=pick.number.replace(pick.number[0:6],prefix)
pick.write({
'number': new_number,
})
count+=1
print("update %s to %s"%(pick.number, new_number))
print("total ", count)
Migration.register()

View File

@ -144,3 +144,5 @@ from . import account_move_line
from . import invoice_payment from . import invoice_payment
from . import document from . import document
from . import payment_matching from . import payment_matching
from . import create_invoice_payment
from . import report_stock_card

View File

@ -13,17 +13,24 @@ class AccountInvoice(Model):
res={} res={}
for obj in self.browse(ids): for obj in self.browse(ids):
pt_id=None pt_id=None
pt_type_id=None
if obj.patient_partner_id: if obj.patient_partner_id:
for pt in get_model('clinic.patient').search_browse([['partner_id','=',obj.patient_partner_id.id]]): for pt in get_model('clinic.patient').search_browse([['partner_id','=',obj.patient_partner_id.id]]):
pt_id=pt.id pt_id=pt.id
res[obj.id]=pt_id pt_type_id=pt.type_id.id
res[obj.id]={
'patient_id': pt_id,
'patient_type_id': pt_type_id,
}
return res return res
_fields={ _fields={
'clinic_expense_id': fields.Many2One("clinic.hd.case.expense","Expense"), 'clinic_expense_id': fields.Many2One("clinic.hd.case.expense","Expense"),
'department_id': fields.Many2One("clinic.department","Department",search=True), 'department_id': fields.Many2One("clinic.department","Department",search=True),
'patient_partner_id': fields.Many2One("partner","Partner Patient",search=True), 'patient_partner_id': fields.Many2One("partner","Partner Patient",search=True),
'patient_id': fields.Many2One("clinic.patient","Patient",function="_get_patient", store=True,search=True), 'patient_id': fields.Many2One("clinic.patient","Patient",function="_get_patient", function_multi=True,store=True,search=True),
'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type",function="_get_patient", function_multi=True,store=True,search=True),
'create_invoice_id': fields.Many2One("create.invoice.payment","Create Invoice Payment"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):

View File

@ -0,0 +1,132 @@
import time
from calendar import monthrange
from netforce.model import Model, fields , get_model
from netforce.database import get_connection
class CreateInvoicePayment(Model):
_name="create.invoice.payment"
_transient=True
_fields={
"date": fields.Date("Month", required=True),
'date_from': fields.Date("From",required=True),
'date_to': fields.Date("To",required=True),
'partner_id': fields.Many2One("partner","Contact",required=True),
'invoices': fields.One2Many("account.invoice","create_invoice_id","Invoices"),
'state': fields.Selection([["find_invoice","Find Invoice"],["ready_payment","Ready Payment"]],'State'),
'account_id': fields.Many2One("account.account","Account"),
}
def _get_date_from(self,context={}):
year,month=time.strftime("%Y-%m").split("-")
return '%s-%s-01'%(year,month)
def _get_date_to(self,context={}):
year,month,day=time.strftime("%Y-%m-%d").split("-")
weekday, total_day=monthrange(int(year), int(month))
return "%s-%s-%s"%(year,month,total_day)
_defaults={
'date': lambda *a: time.strftime("%Y-%m-%d"),
'date_from': _get_date_from,
'date_to': _get_date_to,
'state': 'find_invoice',
}
def onchange_date(self,context={}):
data=context['data']
date=data['date']
year,month,day=date.split("-")
weekday, total_day=monthrange(int(year), int(month))
data['date_from']="%s-%s-01"%(year,month)
data['date_to']="%s-%s-%s"%(year,month,total_day)
return data
def back_step(self,ids,context={}):
obj=self.browse(ids)[0]
state='find_invoice'
if obj.state=='ready_payment':
db=get_connection()
res=db.query("""
select id from account_invoice where create_invoice_id=%s
""",obj.id)
if res:
inv_ids=[r['id'] for r in res]
db.execute("update account_invoice set create_invoice_id=null where id in %s",tuple(inv_ids))
obj.write({
'state': state,
})
def find_invoice(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({
'state': 'ready_payment',
})
db=get_connection()
res=db.query("""
select id from account_invoice where create_invoice_id=%s
""",obj.id)
if res:
inv_ids=[r['id'] for r in res]
db.execute("update account_invoice set create_invoice_id=null where id in %s",tuple(inv_ids))
res=db.query("""
select id from account_invoice where date>=%s and date <=%s and state='waiting_payment'
and partner_id=%s
""",obj.date_from, obj.date_to,obj.partner_id.id)
if res:
inv_ids=[r['id'] for r in res]
db.execute("update account_invoice set create_invoice_id=%s where id in %s",obj.id,tuple(inv_ids))
def create_payment(self,ids,context={}):
obj=self.browse(ids)[0]
if not obj.account_id:
raise Exception("Missing account")
if not obj.invoices:
raise Exception("Nothing to pay!")
partner=obj.partner_id
type="in"
vals={
'type': type, # receivable
'account_id': obj.account_id.id,
'partner_id': partner.id,
'pay_type': 'invoice',
'invoice_lines': [],
}
datenow=time.strftime("%Y-%m-%d")
rate_type="sell" # receivable
settings=get_model("settings").browse(1)
currency=settings.currency_id
if not currency:
raise Exception("Missing setting.currency")
#FIXME process only selected invoice
for inv in obj.invoices:
vals['invoice_lines'].append(('create',{
'invoice_id': inv.id,
"amount": get_model("currency").convert(inv.amount_due,inv.currency_id.id,currency.id,date=datenow,rate_type=rate_type),
}))
ctx={
'type': type,
}
payment_id=get_model("account.payment").create(vals,context=ctx)
return {
'next': {
'name': 'payment',
'mode': 'form',
'active_id': payment_id,
},
'flash': 'Create Payment Successfull',
}
def do_next(self,ids,context={}):
obj=self.browse(ids)[0]
if obj.state=='find_invoice':
obj.find_invoice()
elif obj.state=='ready_payment':
res=obj.create_payment()
return res
CreateInvoicePayment.register()

View File

@ -111,6 +111,7 @@ class HDCase(Model):
dlz_price=0 dlz_price=0
srv=0 srv=0
mdc=0 mdc=0
mdc_items={}
for line in obj.lines: for line in obj.lines:
amt=line.amount or 0 amt=line.amount or 0
prod=line.product_id prod=line.product_id
@ -129,8 +130,12 @@ class HDCase(Model):
else: else:
mdc+=amt mdc+=amt
mdc_names.append(prod_name or "") mdc_names.append(prod_name or "")
mdc_items.setdefault(prod_name,0)
mdc_items[prod_name]=line.qty
if categ.code=='EPO': if categ.code=='EPO':
epo_names.append(prod_name.title()) epo_names.append(prod_name.title())
mdc_items.setdefault(prod_name,0)
mdc_items[prod_name]=line.qty
elif categ.code=='IVR': elif categ.code=='IVR':
iron_names.append(prod_name.title()) iron_names.append(prod_name.title())
elif categ.code=='FEE': elif categ.code=='FEE':
@ -154,6 +159,7 @@ class HDCase(Model):
res[obj.id]={ res[obj.id]={
'epo': ','.join([n for n in epo_names]), 'epo': ','.join([n for n in epo_names]),
'mdc_name': ','.join([n for n in mdc_names]), 'mdc_name': ','.join([n for n in mdc_names]),
'mdc_items': str(mdc_items),
'iron_name': ','.join([n for n in iron_names]), 'iron_name': ','.join([n for n in iron_names]),
'fee': fee, 'fee': fee,
'lab': lab, 'lab': lab,
@ -222,6 +228,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),
"mdc_items": fields.Float("MDC Items",function="_get_expense",function_multi=True),
"iron_name": fields.Float("Iron 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),
@ -520,7 +527,8 @@ class HDCase(Model):
"company_id": company_id, "company_id": company_id,
"type": "in", "type": "in",
"pay_type": "direct", "pay_type": "direct",
'date': time.strftime("%Y-%m-%d"), #'date': time.strftime("%Y-%m-%d"),
'date': obj.date,
"account_id": cash_account_id, "account_id": cash_account_id,
'related_id': "clinic.hd.case,%s"%obj.id, 'related_id': "clinic.hd.case,%s"%obj.id,
'ref': bill_no or obj.number or "", 'ref': bill_no or obj.number or "",
@ -858,7 +866,8 @@ class HDCase(Model):
context={ context={
'pick_type': 'out', 'pick_type': 'out',
'journal_id': pick_vals['journal_id'], 'journal_id': pick_vals['journal_id'],
'date': obj.date 'date': obj.date,
'branch_id': obj.branch_id.id,
} }
pick_id=picking_obj.create(pick_vals,context=context) pick_id=picking_obj.create(pick_vals,context=context)
pick=picking_obj.browse(pick_id) pick=picking_obj.browse(pick_id)
@ -1148,6 +1157,23 @@ class HDCase(Model):
def done(self,ids,context={}): def done(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
if obj.patient_type_id.code=='SSO':
cond1=False
cond2=False
for line in obj.lines:
prod=line.product_id
categ=line.product_categ_id
# force to enter unit price
if not line.price and prod:
raise Exception("Missing unit price for product [%s] %s!"%(prod.code,prod.name))
elif not prod and categ.code=='EPO':
cond2=True
if categ.code=='FEE' and line.price:
cond1=True
# if fee and not enter product then hdcase should not finish
if cond1 and cond2:
raise Exception("%s is missing product"%(categ.name))
count=0 count=0
for sline in obj.staffs: for sline in obj.staffs:
if sline.staff_id: if sline.staff_id:
@ -1430,6 +1456,26 @@ class HDCase(Model):
st=get_model("clinic.setting").browse(1) st=get_model("clinic.setting").browse(1)
if st.auto_gen: if st.auto_gen:
return vals return vals
if st.get_old_expense:
for hdcase in patient.hd_cases:
for line in hdcase.lines:
line_vals={
'product_categ_id': line.product_categ_id.id,
'product_id': line.product_id.id,
'description': line.description,
'reimbursable': line.reimbursable,
'qty': line.qty,
'uom_id': line.uom_id.id,
'price': line.price,
'amount': line.amount,
'account_id': line.account_id.id,
'ar_debit_id': line.ar_debit_id.id,
}
vals['lines'].append(('create',line_vals))
break
if vals['lines']:
return vals
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:
@ -1465,12 +1511,11 @@ class HDCase(Model):
#if not line_vals['account_id']: #if not line_vals['account_id']:
#raise Exception("Please contact accountant: product [%s] %s"%(prod.code, prod.name)) #raise Exception("Please contact accountant: product [%s] %s"%(prod.code, prod.name))
vals['lines'].append(('create',line_vals)) vals['lines'].append(('create',line_vals))
# XXX need to get default
partner=patient.type_id.contact_id partner=patient.type_id.contact_id
if partner: if partner:
vals['fee_partner_id']=partner.id vals['fee_partner_id']=partner.id
if not partner: else:
raise Exception("Not found contact %s at menu: Patiens -> Type"%patient.type_id.name) raise Exception("Missing contact in patiens type %s"%patient.type_id.name)
return vals return vals
def get_invoice_policy(self,vals={},patient_id=None): def get_invoice_policy(self,vals={},patient_id=None):

View File

@ -19,6 +19,7 @@ class Hdcaseline(Model):
"ar_debit_id": fields.Many2One("account.account","Account Debit"), "ar_debit_id": fields.Many2One("account.account","Account Debit"),
} }
def _get_categ(self,context={}): def _get_categ(self,context={}):
categ_ids=get_model("product.categ").search([['code','=','EPO']]) categ_ids=get_model("product.categ").search([['code','=','EPO']])
if categ_ids: if categ_ids:

View File

@ -2,6 +2,8 @@ from netforce.model import Model, fields
class Partner(Model): class Partner(Model):
_inherit="partner" _inherit="partner"
#_key=["code","name"]
_key=["name"]
_fields={ _fields={
'walkin_cust': fields.Boolean("Walkin Customer"), 'walkin_cust': fields.Boolean("Walkin Customer"),
@ -9,6 +11,10 @@ class Partner(Model):
'is_staff': fields.Boolean("Is Staff"), 'is_staff': fields.Boolean("Is Staff"),
} }
_sql_constraints=[
("contact_uniq","unique (name)","The name of contact must be unique!"),
]
def name_get(self,ids,context={}): def name_get(self,ids,context={}):
vals=[] vals=[]
for obj in self.browse(ids): for obj in self.browse(ids):
@ -18,7 +24,7 @@ class Partner(Model):
vals.append((obj.id,name)) vals.append((obj.id,name))
return vals return vals
def name_search(self,name,domain=None,condition=[],context={},**kw): def _name_search(self,name,domain=None,condition=[],context={},**kw):
dom=[["name","ilike","%"+name+"%"]] dom=[["name","ilike","%"+name+"%"]]
if domain: if domain:
dom=[dom,domain] dom=[dom,domain]

View File

@ -314,10 +314,10 @@ class Patient(Model):
'type': 'shipping', 'type': 'shipping',
'partner_id': partner_id, 'partner_id': partner_id,
'patient_id': obj.id, 'patient_id': obj.id,
'address': 'your address', 'address': ' ',
'address2': 'your address2', 'address2': ' ',
'city': 'your city', 'city': ' ',
'postal_code': 'your zip', 'postal_code': ' ',
'country_id': 1, 'country_id': 1,
}) })
@ -415,7 +415,7 @@ class Patient(Model):
update_visit_pending(obj,visit_vals) update_visit_pending(obj,visit_vals)
# create partner if not found # create partner if not found
partner_id=obj.partner_id partner_id=obj.partner_id
if not partner_id: if not partner_id and not vals.get('partner_id'):
partner_name='%s %s'%(obj.first_name or "", obj.last_name or "") # XXX partner_name='%s %s'%(obj.first_name or "", obj.last_name or "") # XXX
for partner in get_model("partner").search_browse([['name', '=', partner_name]]): for partner in get_model("partner").search_browse([['name', '=', partner_name]]):
if partner.name==obj.name: if partner.name==obj.name:

View File

@ -151,6 +151,7 @@ class ReportCycleItem(Model):
total_epo=0 total_epo=0
total_ivr=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:
@ -174,7 +175,8 @@ class ReportCycleItem(Model):
'mdc': hdcase.mdc, 'mdc': hdcase.mdc,
'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 or '', 'mdc_name': hdcase.mdc_name or hdcase.epo,
'mdc_items': hdcase.mdc_items,
'iron_name': hdcase.iron_name or '', 'iron_name': hdcase.iron_name or '',
'fee': abs(hdcase.fee), 'fee': abs(hdcase.fee),
'dlz_name': hdcase.dlz_name, 'dlz_name': hdcase.dlz_name,
@ -229,12 +231,16 @@ class ReportCycleItem(Model):
if x['cseq']==line['cseq'] and x['date']==date: if x['cseq']==line['cseq'] and x['date']==date:
sub_fee+=x['fee'] or 0 sub_fee+=x['fee'] or 0
sub_mdc+=x['mdc'] or 0 sub_mdc+=x['mdc'] or 0
if not epos.get(x['mdc_name']): x_name=x['mdc_name']
epos[x['mdc_name']]=0 epos.setdefault(x_name,0)
if not epos.get(x['iron_name']): epos.setdefault(x['iron_name'],0)
epos[x['iron_name']]=0
epos[x['iron_name']]+=x['total_ivr'] or 0 #XXX epos[x['iron_name']]+=x['total_ivr'] or 0 #XXX
epos[x['mdc_name']]+=x['total_epo'] or 0 if ',' in x_name:
del epos[x_name]
for k,v in eval(x['mdc_items']).items():
epos[k]=v
else:
epos[x_name]+=x['total_epo'] or 0
count+=1 count+=1
line['date_txt']=line['date'] line['date_txt']=line['date']
line['cseq_txt']=line['cseq'] line['cseq_txt']=line['cseq']

View File

@ -1,4 +1,5 @@
from netforce.model import Model, fields, get_model from netforce.model import Model, fields, get_model
from netforce.access import set_active_user, get_active_user
class ReportCycleSetting(Model): class ReportCycleSetting(Model):
_name="clinic.report.cycle.setting" _name="clinic.report.cycle.setting"
@ -61,6 +62,8 @@ class ReportCycleSetting(Model):
if cycle_id: if cycle_id:
dom.append(['cycle_id','=',cycle_id]) dom.append(['cycle_id','=',cycle_id])
pcs=get_model("clinic.patient.cycle").search_browse(dom) pcs=get_model("clinic.patient.cycle").search_browse(dom)
user_id=get_active_user()
set_active_user(1)
if not pcs: if not pcs:
# Create patient cycle with that department # Create patient cycle with that department
for pt in get_model("clinic.patient").search_browse([['department_id','=',department_id]]): for pt in get_model("clinic.patient").search_browse([['department_id','=',department_id]]):
@ -151,6 +154,7 @@ class ReportCycleSetting(Model):
nlines.append(line) nlines.append(line)
no+=1 no+=1
set_active_user(user_id)
data={ data={
'lines': nlines, 'lines': nlines,
'department_id': department_id, 'department_id': department_id,

View File

@ -127,14 +127,12 @@ class ReportLaborCostSummary(Model):
return r return r
return "{0:,.0f}".format(r) return "{0:,.0f}".format(r)
total_hdcase=0 total_hdcase=0
print("----> ", dom)
for line in get_model("clinic.labor.cost.line").search_browse(dom): for line in get_model("clinic.labor.cost.line").search_browse(dom):
lcost=line.labor_cost_id lcost=line.labor_cost_id
citem=lcost.cycle_item_id citem=lcost.cycle_item_id
dpt=citem.department_id dpt=citem.department_id
qty=line.qty or 0 qty=line.qty or 0
total_hdcase+=qty total_hdcase+=qty
print("total_hdcase ", total_hdcase)
amt=line.amount or 0 amt=line.amount or 0
staff=line.staff_id staff=line.staff_id
categ_name='' categ_name=''

View File

@ -30,7 +30,7 @@ class ReportMedicalDetail(Model):
date_from=defaults.get('date_from','%s-%s-01'%(year,month)) date_from=defaults.get('date_from','%s-%s-01'%(year,month))
date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day)) date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day))
categ_id=defaults.get('categ_id',None) categ_id=defaults.get('categ_id',None)
report_type=defaults.get('report_type',"completed") report_type=defaults.get('report_type') or "completed"
if not categ_id: if not categ_id:
categ_ids=get_model("product.categ").search([['code','=','MDC']]) categ_ids=get_model("product.categ").search([['code','=','MDC']])
if categ_ids: if categ_ids:
@ -67,7 +67,6 @@ class ReportMedicalDetail(Model):
'product_id': product_id, 'product_id': product_id,
'report_type': report_type, 'report_type': report_type,
} }
print('report_type ', report_type)
return res return res
def get_report_data(self,ids,context={}): def get_report_data(self,ids,context={}):
@ -76,7 +75,6 @@ class ReportMedicalDetail(Model):
defaults=self.default_get(context=context) defaults=self.default_get(context=context)
time_start=defaults.get("date_from") time_start=defaults.get("date_from")
time_stop=defaults.get("date_to") time_stop=defaults.get("date_to")
prod_categ_id=defaults.get("prod_categ_id")
branch_id=defaults.get("branch_id") branch_id=defaults.get("branch_id")
department_id=defaults.get("department_id") department_id=defaults.get("department_id")
product_id=defaults.get('product_id') product_id=defaults.get('product_id')
@ -84,7 +82,6 @@ class ReportMedicalDetail(Model):
report_type=defaults.get('report_type','completed') report_type=defaults.get('report_type','completed')
if ids: if ids:
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
prod_categ_id=obj.prod_categ_id.id
product_id=obj.product_id.id product_id=obj.product_id.id
types=obj.types types=obj.types
branch_id=obj.branch_id.id branch_id=obj.branch_id.id
@ -97,10 +94,16 @@ class ReportMedicalDetail(Model):
['hd_case_id.date','>=',time_start], ['hd_case_id.date','>=',time_start],
['hd_case_id.date','<=',time_stop], ['hd_case_id.date','<=',time_stop],
] ]
shop_dom=[
['shop_id.date','>=',time_start],
['shop_id.date','<=',time_stop],
]
if branch_id: if branch_id:
dom.append(['hd_case_id.branch_id','=',branch_id]) dom.append(['hd_case_id.branch_id','=',branch_id])
shop_dom.append(['shop_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])
shop_dom.append(['shop_id.department_id','=',department_id])
st=get_model("clinic.setting").browse(1) st=get_model("clinic.setting").browse(1)
ct_ids=[] ct_ids=[]
for categ in st.product_categ_view: for categ in st.product_categ_view:
@ -137,6 +140,26 @@ class ReportMedicalDetail(Model):
'hname': hdcase.number, 'hname': hdcase.number,
}) })
total_qty+=qty total_qty+=qty
for line in get_model("clinic.shop.line").search_browse(shop_dom):
shop=line.shop_id
patient=shop.patient_id
department=shop.department_id
qty=line.qty or 0
lines.append({
'date': shop.date or '',
'tname': patient.type_id.name or '',
'pname': patient.name or '',
'qty': qty,
'cname': 'RD Shop',
'cseq': 999,
'dpt_name': department.name,
'hid': shop.id,
'hname': shop.number,
'is_shop': True,
})
total_qty+=qty
sub_name='' sub_name=''
if department_id: if department_id:
dpt=get_model("clinic.department").browse(department_id) dpt=get_model("clinic.department").browse(department_id)
@ -146,8 +169,9 @@ class ReportMedicalDetail(Model):
sub_name="(%s)" % branch.name or "" sub_name="(%s)" % branch.name or ""
company_id=get_active_company() company_id=get_active_company()
company=get_model("company").browse(company_id) company=get_model("company").browse(company_id)
lines=sorted(lines,key=lambda x: (x['date'],x['cseq']))
no=1 no=1
for line in sorted(lines,key=lambda x: (x['date'],x['cseq'])): for line in lines:
line['no']=no line['no']=no
no+=1 no+=1
data={ data={

View File

@ -79,11 +79,16 @@ class ReportMedicalSummary(Model):
time_start=obj.date_from time_start=obj.date_from
time_stop=obj.date_to time_stop=obj.date_to
report_type=obj.report_type or "completed" report_type=obj.report_type or "completed"
print('report_type ---> ', report_type)
products={} products={}
patient_types={t['id']: t['name'] for t in get_model('clinic.patient.type').search_read([[]],['name'],order="name")} patient_types={t['id']: t['name'] for t in get_model('clinic.patient.type').search_read([[]],['name'],order="name")}
dom=[] dom=[]
shop_dom=[
['date','>=',time_start],
['date','<=',time_stop],
['department_id','=',department_id],
['branch_id','=',branch_id],
]
dom.append(['type','=','stock']) dom.append(['type','=','stock'])
dom.append(['report_visible','=',True]) dom.append(['report_visible','=',True])
st=get_model("clinic.setting").browse(1) st=get_model("clinic.setting").browse(1)
@ -93,6 +98,9 @@ class ReportMedicalSummary(Model):
if ct_ids: if ct_ids:
dom.append(['categ_id.id','in',ct_ids]) dom.append(['categ_id.id','in',ct_ids])
categ_ids=set() categ_ids=set()
themself_id=0
for type_id in get_model("clinic.patient.type").search([['code','=','CASH']]):
themself_id=type_id
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
@ -128,8 +136,20 @@ 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 themself_id and patient_type_id!=themself_id and line.reimbursable=='no':
products[prod_code][themself_id]['qty']+=line.qty
else:
products[prod_code][patient_type_id]['qty']+=line.qty products[prod_code][patient_type_id]['qty']+=line.qty
# add qty from rd shop
for shop in get_model("clinic.shop").search_browse(shop_dom):
for line in shop.lines:
prod=line.product_id
categ=line.categ_id
if categ and categ.id not in list(categ_ids):
continue
products[prod.code][themself_id]['qty']+=line.qty
lines=[] lines=[]
limit_char=25 limit_char=25
titles=[{'name': 'ชื่อยา'}] titles=[{'name': 'ชื่อยา'}]

View File

@ -0,0 +1,85 @@
from netforce.model import Model, get_model
from netforce.access import get_active_company
class ReportStockCard(Model):
_inherit="report.stock.card"
def write(self,ids,vals,**kw):
kw['check_time']=False
super().write(ids,vals,**kw)
def get_report_data(self,ids,context={}):
company=get_model("company").browse(get_active_company())
defaults=self.default_get(context=context)
location_id=defaults.get("location_id")
date_from=defaults.get('date_from')
date_to=defaults.get('date_to')
#product_id=defaults.get('product_id')
if not ids and not location_id:
return {
'date_from': date_from,
'date_to': date_to,
'company_name': company.name,
}
data={
'loc_view': False,
}
if ids:
obj=self.browse(ids)[0]
location=obj.location_id
loc_view_id=location.id
if location.type=='view':
data.update({
'loc_view': True,
'date_from': obj.date_from,
'date_to': obj.date_to,
'company_name': company.name,
})
child_ids=get_model('stock.location').search([['parent_id','=',location.id]])
locs={}
for child_id in child_ids:
obj.write({
'location_id': child_id,
})
groups=super().get_report_data(ids,context)['groups']
for group in groups:
location_id=group['location_id']
locs.setdefault(location_id,{
'total_in_amount': 0,
'total_in_qty': 0,
'total_in_qty2': 0,
'total_out_amount': 0,
'total_out_qty': 0,
'total_out_qty2': 0,
})
locs[location_id]['total_in_amount']+=group['total_in_amount']
locs[location_id]['total_in_qty']+=group['total_in_qty']
locs[location_id]['total_in_qty2']+=group['total_in_qty2']
locs[location_id]['total_out_amount']+=group['total_out_amount']
locs[location_id]['total_out_qty']+=group['total_out_qty']
locs[location_id]['total_out_qty2']+=group['total_out_qty2']
lines=[]
for loc_id,vals in locs.items():
vals['total_bl_qty']=vals['total_in_qty']-vals['total_out_qty']
vals['total_bl_amount']=vals['total_in_amount']-vals['total_out_amount']
vals['total_bl_qty2']=vals['total_in_qty2']-vals['total_out_qty2']
location=get_model('stock.location').browse(loc_id)
vals.update({
'loc_id': loc_id,
'loc_name': location.name,
})
lines.append(vals)
obj.write({
'location_id': loc_view_id,
})
data.update({
'lines': lines,
'show_qty2': True,
})
else:
data.update(super().get_report_data(ids,context))
else:
data.update(super().get_report_data(ids,context))
return data
ReportStockCard.register()

View File

@ -66,6 +66,7 @@ class ClinicSetting(Model):
'product_categ_view': fields.Many2Many("product.categ","Product Category View"), 'product_categ_view': fields.Many2Many("product.categ","Product Category View"),
'hdcase_picking_auto': fields.Boolean("HDCase Auto Picking"), 'hdcase_picking_auto': fields.Boolean("HDCase Auto Picking"),
'dlz_picking_auto': fields.Boolean("DLZ Auto Picking"), 'dlz_picking_auto': fields.Boolean("DLZ Auto Picking"),
'get_old_expense': fields.Boolean("Get old expense"),
} }
_defaults={ _defaults={

View File

@ -22,6 +22,7 @@ class SettingProduct(Model):
"ar_credit_id": fields.Many2One("account.account","AR Credit",multi_company=True), "ar_credit_id": fields.Many2One("account.account","AR Credit",multi_company=True),
"ar_debit_id": fields.Many2One("account.account","AR Debit",multi_company=True), "ar_debit_id": fields.Many2One("account.account","AR Debit",multi_company=True),
'company_id': fields.Many2One("company","Company"), 'company_id': fields.Many2One("company","Company"),
'sequence': fields.Char("Sequence"),
} }
_defaults={ _defaults={
@ -30,7 +31,7 @@ class SettingProduct(Model):
'reimbursable': 'no', 'reimbursable': 'no',
} }
_order="patient_type_id" _order="patient_type_id,sequence"
SettingProduct.register() SettingProduct.register()

View File

@ -161,14 +161,14 @@ def num2word(n,l="th_TH"):
word = sym[l][sign] + sym[l]['sep'] + base + sym[l]['sep'] + currency[l]['name'] + sym[l]['sep'] + currency[l]['end'] word = sym[l][sign] + sym[l]['sep'] + base + sym[l]['sep'] + currency[l]['name'] + sym[l]['sep'] + currency[l]['end']
return word.strip() return word.strip()
def read_excel(fpath=None,show_datetime=False): def read_excel(fpath=None,sheet_name="Sheet1",show_datetime=False):
data={} data={}
if fpath: if fpath:
suffix=fpath.split(".")[-1] suffix=fpath.split(".")[-1]
if suffix not in ('xls', 'xlsx'): if suffix not in ('xls', 'xlsx'):
raise Exception("ERROR : please should file xls or xlsx") raise Exception("ERROR : please should file xls or xlsx")
wb=xlrd.open_workbook(fpath) wb=xlrd.open_workbook(fpath)
sheet=wb.sheet_by_name("Sheet1") sheet=wb.sheet_by_name(sheet_name)
keys = [sheet.cell(0, col_index).value for col_index in range(sheet.ncols)] keys = [sheet.cell(0, col_index).value for col_index in range(sheet.ncols)]
data=[] data=[]
for row_index in range(1, sheet.nrows): for row_index in range(1, sheet.nrows):

View File

@ -7,11 +7,11 @@
<thead> <thead>
<tr> <tr>
<th>#</th> <th>#</th>
<th>HDCase#</th>
<th>Date</th> <th>Date</th>
<th>Cycle</th>
<th>Number</th>
<th>Patient</th> <th>Patient</th>
<th>Type</th> <th>Type</th>
<th>Cycle</th>
<th>Department</th> <th>Department</th>
<th>Qty</th> <th>Qty</th>
</tr> </tr>
@ -20,13 +20,17 @@
{{#each lines}} {{#each lines}}
<tr> <tr>
<td>{{no}}</td> <td>{{no}}</td>
<td>
{{view "link" string=hname action="clinic_hd_case" action_options="mode=form" active_id=hid}}
</td>
<td>{{date}}</td> <td>{{date}}</td>
<td>{{cname}}</td>
<td>
{{#if is_shop}}
{{view "link" string=hname action="clinic_shop" action_options="mode=form" active_id=hid}}
{{else}}
{{view "link" string=hname action="clinic_hd_case" action_options="mode=form" active_id=hid}}
{{/if}}
</td>
<td>{{pname}}</td> <td>{{pname}}</td>
<td>{{tname}}</td> <td>{{tname}}</td>
<td>{{cname}}</td>
<td>{{dpt_name}}</td> <td>{{dpt_name}}</td>
<td>{{qty}}</td> <td>{{qty}}</td>
</tr> </tr>

View File

@ -21,7 +21,7 @@
</td> </td>
{{#each sub_lines}} {{#each sub_lines}}
<td style="text-align:center"> <td style="text-align:center">
<a href="/ui#name=clinic_report_medical_detail&defaults.date_from={{time_start}}&defaults.date_to={{time_stop}}&defaults.types={{types}}&defaults.product_id={{product_id}}&defaults.product_categ_id={{product_categ_id}}">{{qty}} </a> <a href="/ui#name=clinic_report_medical_detail&defaults.report_type={{report_type}}&defaults.date_from={{time_start}}&defaults.date_to={{time_stop}}&defaults.types={{types}}&defaults.product_id={{product_id}}&defaults.product_categ_id={{product_categ_id}}">{{qty}} </a>
</td> </td>
{{/each}} {{/each}}
</tr> </tr>

View File

@ -0,0 +1,264 @@
<center>
<h2>
Stock Card
</h2>
<h3>
{{company_name}}
</h3>
<h4>
From {{date_from}} to {{date_to}}
</h4>
</center>
{{#if loc_view}}
<table class="table table-bordered">
<thead>
<tr>
<th rowspan="2">Location</th>
<th colspan="{{#if show_qty2}}3{{else}}2{{/if}}" style="text-align:center">In</th>
<th colspan="{{#if show_qty2}}3{{else}}2{{/if}}" style="text-align:center">Out</th>
<th colspan="{{#if show_qty2}}3{{else}}2{{/if}}" style="text-align:center">Balance</th>
</tr>
<tr>
<th>
Qty
</th>
<th>
Amount
</th>
{{#if show_qty2}}
<th>
Secondary Qty
</th>
{{/if}}
<th>
Qty
</th>
<th>
Amount
</th>
{{#if show_qty2}}
<th>
Secondary Qty
</th>
{{/if}}
<th>
Qty
</th>
<th>
Amount
</th>
{{#if show_qty2}}
<th>
Secondary Qty
</th>
{{/if}}
</tr>
</thead>
<tbody>
{{#each lines}}
<tr>
<td>
<a href="ui#name=report_stock_card&defaults.location_id={{loc_id}}&defaults.date_from{{../date_from}}&defaults.date_to={{../date_to}}">
{{loc_name}}
</a>
</td>
<td>
{{currency total_in_qty}}
</td>
<td>
{{currency total_in_amount}}
</td>
<td>
{{currency total_in_qty2}}
</td>
<td>
{{currency total_out_qty}}
</td>
<td>
{{currency total_out_amount}}
</td>
<td>
{{currency total_out_qty2}}
</td>
<td>
{{currency total_bl_qty}}
</td>
<td>
{{currency total_bl_amount}}
</td>
<td>
{{currency total_bl_qty2}}
</td>
</tr>
{{/each}}
</tbody>
<tfoot>
</tfoot>
</table>
{{else}}
<table class="table table-bordered">
<thead>
<tr>
<th rowspan="2">Date</th>
<th rowspan="2">Ref</th>
<th rowspan="2">Lot / Serial Number</th>
<th rowspan="2">Invoice</th>
<th colspan="{{#if show_qty2}}4{{else}}3{{/if}}" style="text-align:center">In</th>
<th colspan="{{#if show_qty2}}4{{else}}3{{/if}}" style="text-align:center">Out</th>
<th colspan="{{#if show_qty2}}4{{else}}3{{/if}}" style="text-align:center">Balance</th>
</tr>
<tr>
<th>
Qty
</th>
<th>
Unit Price
</th>
<th>
Amount
</th>
{{#if show_qty2}}
<th>
Secondary Qty
</th>
{{/if}}
<th>
Qty
</th>
<th>
Unit Price
</th>
<th>
Amount
</th>
{{#if show_qty2}}
<th>
Secondary Qty
</th>
{{/if}}
<th>
Qty
</th>
<th>
Cost Price
</th>
<th>
Cost Amount
</th>
{{#if show_qty2}}
<th>
Secondary Qty
</th>
{{/if}}
</tr>
</thead>
<tbody>
{{#each groups context=context}}
<tr>
<th colspan="20">
{{product_name}}
@ {{location_name}}
</th>
</tr>
{{#each lines context=context}}
<tr>
<td>
{{date}}
</td>
<td>
{{view "link" string=ref action="view_stock_transaction" active_id=id context=context}}
</td>
<td>
{{view "link" string=lot_num action="stock_lot" action_options="mode=form" active_id=lot_id context=context}}
</td>
<td>
{{view "link" string=invoice_num action="view_invoice" active_id=invoice_id context=context}}
</td>
<td>
{{currency in_qty}}
</td>
<td>
{{currency in_unit_price}}
</td>
<td>
{{currency in_amount}}
</td>
{{#if ../../show_qty2}}
<td>
{{currency in_qty2}}
</td>
{{/if}}
<td>
{{currency out_qty}}
</td>
<td>
{{currency out_unit_price}}
</td>
<td>
{{currency out_amount}}
</td>
{{#if ../../show_qty2}}
<td>
{{currency out_qty2}}
</td>
{{/if}}
<td>
{{currency bal_qty}}
</td>
<td>
{{currency bal_cost_price}}
</td>
<td>
{{currency bal_cost_amount}}
</td>
{{#if ../../show_qty2}}
<td>
{{currency bal_qty2}}
</td>
{{/if}}
</tr>
{{/each}}
<tr>
<td>
</td>
<th>
Total
</th>
<td>
</td>
<td>
</td>
<th>
{{currency total_in_qty}}
</th>
<td>
</td>
<th>
{{currency total_in_amount}}
</th>
{{#if ../show_qty2}}
<th>
{{currency total_in_qty2}}
</th>
{{/if}}
<th>
{{currency total_out_qty}}
</th>
<td>
</td>
<th>
{{currency total_out_amount}}
</th>
{{#if ../show_qty2}}
<th>
{{currency total_out_qty2}}
</th>
{{/if}}
<th></th>
<th></th>
<th></th>
</tr>
{{/each}}
</tbody>
</table>
{{/if}}