diff --git a/netforce_clinic/actions/clinic_hdcase_invoice_print.xml b/netforce_clinic/actions/clinic_hdcase_invoice_print.xml
new file mode 100644
index 0000000..217d76c
--- /dev/null
+++ b/netforce_clinic/actions/clinic_hdcase_invoice_print.xml
@@ -0,0 +1,6 @@
+
+ report_odt2
+ account.invoice
+ get_invoice_data
+ cust_invoice
+
diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml
index 6a6e71a..3dde598 100644
--- a/netforce_clinic/layouts/clinic_hd_case_form.xml
+++ b/netforce_clinic/layouts/clinic_hd_case_form.xml
@@ -1,9 +1,11 @@
diff --git a/netforce_clinic/models/account_invoice.py b/netforce_clinic/models/account_invoice.py
index ca468b4..0bb711a 100644
--- a/netforce_clinic/models/account_invoice.py
+++ b/netforce_clinic/models/account_invoice.py
@@ -1,6 +1,10 @@
import time
from netforce.model import Model, fields, get_model
+from netforce.utils import get_file_path
+from netforce.access import get_active_company, get_active_user
+
+from . import utils
class AccountInvoice(Model):
_inherit="account.invoice"
@@ -293,4 +297,134 @@ class AccountInvoice(Model):
dt=(t1-t0)*1000
print("invoice.post <<< %d ms"%dt)
+
+
+ def get_invoice_data(self,ids,context={}):
+ settings=get_model('settings').browse(1)
+ pages=[]
+ for obj in self.browse(ids):
+ context['refer_id']=obj.id
+ data=self.get_invoice_page(context=context)
+ limit_item=10
+ if data['state']=='draft':
+ limit_item-=3
+ for i in range(len(data['lines']),limit_item):
+ data['lines'].append({
+ 'no': '',
+ 'product_name': '',
+ 'description': '',
+ 'uom_name': '',
+ 'qty': None,
+ 'price': None,
+ 'amount': None,
+ })
+ pages.append(data)
+ if pages:
+ pages[-1]["is_last_page"]=True
+ return {
+ "pages": pages,
+ "logo": get_file_path(settings.logo),
+ }
+
+ def get_invoice_page(self,context={}):
+ if not context.get('refer_id'):
+ return {}
+ inv_id=int(context['refer_id'])
+ inv=self.browse(inv_id)
+ comp_id=get_active_company()
+ comp=get_model('company').browse(comp_id)
+ cust=inv.partner_id
+ cust_tax_no=cust.tax_no or ''
+ cust_name=cust.name or ''
+ cust_addr=''
+ if cust.addresses:
+ cust_addr=cust.addresses[0].address_text
+ if 'your' in cust_addr:
+ cust_addr=''
+ dpt=inv.department_id
+ branch_id=None
+ if dpt:
+ branch_id=dpt.branch_id.id
+ elif inv.patient_partner_id:
+ for pt in get_model('clinic.patient').search_read([['partner_id','=',inv.patient_partner_id.id]],['branch_id']):
+ if pt.get("branch_id"):
+ branch_id=pt['branch_id'][0]
+ context['branch_id']=branch_id
+ st=get_model('settings').browse(1,context=context)
+ cst=get_model('clinic.setting').browse(1)
+ no=1
+ sub_total=0
+ amount_total=0
+ lines=[]
+ for line in inv.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': prod.uom_id.name or '',
+ 'qty': line.qty or 0,
+ 'price': line.price or 0,
+ 'amount': amt,
+ })
+ sub_total+=amt
+ no+=1
+ amount_total=sub_total
+ is_draft=inv.state=='draft' and True or False
+ is_cheque=False
+ user_id=get_active_user()
+ user=get_model("base.user").browse(user_id)
+ comp_name=comp.name or ""
+ if st.default_address_id.company:
+ comp_name=st.default_address_id.company or ""
+ payment_terms=''
+ currency_code=''
+ due_date=inv.due_date
+ number=inv.number or ""
+ ref=inv.ref or ""
+ payment_terms=inv.payment_terms or ""
+ currency_code=inv.currency_id.code or ""
+ due_date=inv.due_date
+ add=st.default_address_id
+ data={
+ 'partner_name': cust_name,
+ 'partner_address': cust_addr,
+ 'partner_tax_no': cust_tax_no,
+ 'due_date': due_date,
+ 'currency_code': currency_code,
+ 'payment_terms': payment_terms,
+ 'comp_name': comp_name,
+ 'add_address': add.address or '',
+ 'add_address2': add.address2 or '',
+ 'add_province_name': add.province_id.name or '',
+ 'add_district_name': add.district_id.name or '',
+ 'add_subdistrict_name': add.subdistrict_id.name or '',
+ 'add_city': add.city or '',
+ 'add_postal_code': add.postal_code or '',
+ 'add_phone': add.phone or '',
+ 'add_fax': add.fax or '',
+ 'tax_no': st.tax_no or '',
+ 'number': number,
+ 'ref': ref,
+ 'date': inv.date,
+ 'datenow': inv.date or time.strftime("%d/%m/%Y"),
+ 'dateprint': inv.date or time.strftime("%d/%m/%Y %H:%M:%S"),
+ 'note': inv.note or '',
+ 'lines':lines,
+ 'amount_subtotal': sub_total,
+ 'amount_total': amount_total,
+ 'total_text': utils.num2word(amount_total),
+ 'is_cheque': is_cheque,
+ 'is_draft': is_draft,
+ 'user_name': user.name or "",
+ 'state': inv.state or "",
+ }
+ data['pay_type']='Credit'
+ if st.logo:
+ data['logo']=get_file_path(st.logo)
+ if cst.signature:
+ data['signature']=get_file_path(cst.signature)
+ return data
+
AccountInvoice.register()
diff --git a/netforce_clinic/models/account_payment.py b/netforce_clinic/models/account_payment.py
index 6699a04..18e13af 100644
--- a/netforce_clinic/models/account_payment.py
+++ b/netforce_clinic/models/account_payment.py
@@ -47,6 +47,7 @@ class AccountPayment(Model):
'name': 'report_clinic_payment_form',
'refer_id': hd_case_id,
'payment_id': obj.id,
+ 'convert': 'pdf',
},
}
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index f3abcec..42b2363 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -1273,7 +1273,7 @@ class HDCase(Model):
for payment in obj.payments:
context['payment_id']=payment.id
data=self.get_report_payment_data(context=context)
- limit_item=10
+ limit_item=9
if data['state']=='draft':
limit_item=10
for i in range(len(data['lines']),limit_item):
diff --git a/netforce_clinic/models/report_account_hd_case_summary.py b/netforce_clinic/models/report_account_hd_case_summary.py
index 0a2c9e2..5ded9b8 100644
--- a/netforce_clinic/models/report_account_hd_case_summary.py
+++ b/netforce_clinic/models/report_account_hd_case_summary.py
@@ -19,6 +19,7 @@ class ReportAccountHDCaseSummary(Model):
'reimbursable': fields.Selection([['yes','Yes'],['no','No']],'Claim'),
'walkin': fields.Selection([['yes','Yes'],['no','No']],'Walkin'),
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
+ 'pay_type': fields.Selection([['cash','Cash'],['credit','Credit']],'Pay Type'),
'product_id': fields.Many2One("product","Product"),
}
@@ -76,6 +77,7 @@ class ReportAccountHDCaseSummary(Model):
walkin=defaults.get('walkin')
ptype_id=None
cycle_id=None
+ pay_type=''
if ids:
obj=self.browse(ids)[0]
branch_id=obj.branch_id.id
@@ -87,6 +89,7 @@ class ReportAccountHDCaseSummary(Model):
cycle_id=obj.cycle_id.id
reimbursable=obj.reimbursable or ""
product_id=obj.product_id.id
+ pay_type=obj.pay_type
walkin=obj.walkin
dom=[
['hd_case_id.date','>=', date_from],
@@ -214,7 +217,20 @@ class ReportAccountHDCaseSummary(Model):
else:
records[hdcase_id]['misc']+=amt
lines=[]
+
+ # nurse would like to see only receipt
+ del_invoice=False
+ del_receipt=False
+ if pay_type and reimbursable=='no' and pay_type=='cash':
+ del_invoice=True
+ elif pay_type and reimbursable=='no' and pay_type=='credit':
+ del_receipt=True
+
for hdcase_id, vals in records.items():
+ if del_invoice and vals['inv_number']:
+ continue
+ elif del_receipt and vals['pm_number']:
+ continue
lines.append(vals)
company_name=company.name or ""
if department_id:
diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py
index 7fd46c7..afc4a26 100644
--- a/netforce_clinic/models/shop.py
+++ b/netforce_clinic/models/shop.py
@@ -896,6 +896,10 @@ class Shop(Model):
for pick in shop.pickings:
pick_id=pick.id
pick_number=pick.number
+ st=get_model('clinic.setting').browse(1)
+ ct_ids=[]
+ for ct in st.product_categ_view:
+ ct_ids.append(ct.id)
for line in shop.lines:
prod=line.product_id
categ=line.categ_id
@@ -906,8 +910,10 @@ class Shop(Model):
fee=0
dlz=0
mdc_names=[]
- if categ.parent_id:
- if categ.parent_id.code=='MDC':
+ #if categ.parent_id:
+ #if categ.parent_id.code=='MDC': #XXX
+ if categ:
+ if categ.id in ct_ids:
mdc+=amount
name=prod.name or ""
name=name.split("-")
@@ -944,7 +950,7 @@ class Shop(Model):
'fee': fee,
'mdc': mdc,
'mdc_name': ','.join([n for n in mdc_names]),
- 'dlz_name': "", #XXX
+ 'dlz_name': "",
'dlz_id': "",
'dlz': dlz,
'lab': lab,
diff --git a/netforce_clinic/reports/cust_invoice.odt b/netforce_clinic/reports/cust_invoice.odt
index 5bc494e..17429e7 100644
Binary files a/netforce_clinic/reports/cust_invoice.odt and b/netforce_clinic/reports/cust_invoice.odt differ