diff --git a/netforce_clinic/layouts/clinic_shop_list.xml b/netforce_clinic/layouts/clinic_shop_list.xml
index 32bf677..a57ad49 100644
--- a/netforce_clinic/layouts/clinic_shop_list.xml
+++ b/netforce_clinic/layouts/clinic_shop_list.xml
@@ -9,7 +9,6 @@
-
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index 7ff4157..7771914 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -94,9 +94,15 @@ class HDCase(Model):
fee=0
lab=0
misc=0
+ dlz_price=0
#sign=1
#if obj.state=='waiting_payment':
#sign=-1
+ for dline in obj.dialyzers:
+ dlz=dline.dialyzer_id
+ prod=dlz.product_id
+ dlz_price+=prod.sale_price or 0
+
for line in obj.lines:
amt=line.amount or 0
prod=line.product_id
@@ -108,12 +114,14 @@ class HDCase(Model):
sign=-1
if categ.code=='EPO':
name=prod.name or ""
- name=name.split("-") #XXX
+ name=name.split("-")
if name:
name=name[0].title()
names.append(name)
elif categ.code=='FEE':
fee+=amt*sign
+ elif categ.code=='DLZ':
+ dlz_price+=prod.sale_price or 0
elif categ.code=="LAB":
lab+=amt
else:
@@ -124,6 +132,7 @@ class HDCase(Model):
'lab': lab,
'misc': misc,
'dlz_id': dlz_id,
+ 'dlz_price': dlz_price,
'dlz_name': dlz_name,
'dlz_use': dlz_use,
'dlz_max': dlz_max,
@@ -172,6 +181,7 @@ class HDCase(Model):
"lab": fields.Float("Fee",function="_get_expense",function_multi=True),
"misc": fields.Float("Fee",function="_get_expense",function_multi=True),
"dlz_name": fields.Float("DZ",function="_get_expense",function_multi=True),
+ "dlz_price": fields.Float("DZ",function="_get_expense",function_multi=True),
"dlz_use": fields.Float("DZ Use",function="_get_expense",function_multi=True),
"dlz_max": fields.Float("DZ Max",function="_get_expense",function_multi=True),
"dlz_id": fields.Float("DZ ID",function="_get_expense",function_multi=True),
@@ -518,9 +528,10 @@ class HDCase(Model):
def cancelled(self,ids,context={}):
obj=self.browse(ids)[0]
- obj.sickbed_id.write({
- 'available': True,
- })
+ if obj.sickbed_id:
+ obj.sickbed_id.write({
+ 'available': True,
+ })
obj.write({"state":"cancelled"})
def make_invoices(self,ids,context={}):
diff --git a/netforce_clinic/models/report_account_hd_case_summary.py b/netforce_clinic/models/report_account_hd_case_summary.py
index 70bc398..4ba990a 100644
--- a/netforce_clinic/models/report_account_hd_case_summary.py
+++ b/netforce_clinic/models/report_account_hd_case_summary.py
@@ -122,9 +122,11 @@ class ReportAccountHDCaseSummary(Model):
pm_number=','.join([pm.number for pm in hdcase.payments if pm.number])
inv_number=""
inv_ref=""
+ inv_id=None
for inv in hdcase.invoices:
inv_number+=inv.number or ""
inv_ref+=inv.ref or ""
+ inv_id=inv.id
pick_ref=""
pick_id=None
for pick in hdcase.pickings:
@@ -157,9 +159,11 @@ class ReportAccountHDCaseSummary(Model):
'cycle_item_id': cycle_item.id,
'pm_number': pm_number and pm_number or "-",
'inv_number': inv_number and inv_number or "-",
+ 'inv_id': inv_id,
'mdc_name': mdc_name,
'dlz_name': hdcase.dlz_name,
'dlz_id': hdcase.dlz_id.id,
+ 'dlz_price': hdcase.dlz_price or 0,
'lab': hdcase.lab,
'misc': hdcase.misc,
'inv_ref': inv_ref and inv_ref or "-",
@@ -195,6 +199,7 @@ class ReportAccountHDCaseSummary(Model):
total_srv=0
total_epo=0
total_lab=0
+ total_dlz=0
total_misc=0
slines=[]
no=1
@@ -214,6 +219,7 @@ class ReportAccountHDCaseSummary(Model):
total_epo+=line.get('epo',0)
total_lab+=line.get('lab',0)
total_misc+=line.get('misc',0)
+ total_dlz+=line.get('dlz_price',0)
line['no']=no
cid=line['cid']
@@ -252,6 +258,7 @@ class ReportAccountHDCaseSummary(Model):
'total_epo': total_epo,
'total_lab': total_lab,
'total_misc': total_misc,
+ 'total_dlz': total_dlz,
'total_qty': total_qty,
'types': types,
'reimbursable': reimbursable,
@@ -264,7 +271,6 @@ class ReportAccountHDCaseSummary(Model):
data['title']='Report - Claim'
else:
data['title']='Report - No Claim'
- print('>>', data['reimbursable'])
return data
def onchange_date(self,context={}):
diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py
index 54b6a16..f8b50d1 100644
--- a/netforce_clinic/models/shop.py
+++ b/netforce_clinic/models/shop.py
@@ -30,14 +30,15 @@ class Shop(Model):
"number": fields.Char("Number",required=True,search=True),
"ref": fields.Char("Customer Name",search=True),
'date': fields.Date("Date",search=True),
+ 'due_date': fields.Date("Due Date",search=True),
'patient_id': fields.Many2One('clinic.patient','Patient',search=True,domain=[['state','=','admit']]),
'contact_id': fields.Many2One('partner','Contact',search=True),
'department_id': fields.Many2One("clinic.department","Department",search=True),
'branch_id': fields.Many2One("clinic.branch","Branch",search=True),
'lines': fields.One2Many('clinic.shop.line','shop_id','Lines'),
'total': fields.Float("Total",function="_get_all",function_multi=True),
- 'user_id': fields.Many2One("base.user","Pharmacist"),
- 'state': fields.Selection([['draft','Draft'],['waiting_payment','Waiting Payment'],['paid','Paid']],'State'),
+ 'user_id': fields.Many2One("base.user","Sale Man"),
+ 'state': fields.Selection([['draft','Draft'],['waiting_payment','Waiting Payment'],['paid','Paid'],['cancelled','Cancelled']],'State'),
"pickings": fields.One2Many("stock.picking","related_id","Pickings"),
"invoices": fields.One2Many("account.invoice","related_id","Invoices"),
"payments": fields.One2Many("account.payment","related_id","Payments"),
@@ -121,6 +122,7 @@ class Shop(Model):
_defaults={
'number': '/',
'date': lambda *a: time.strftime("%Y-%m-%d"),
+ 'due_date': lambda *a: time.strftime("%Y-%m-%d"),
'user_id': lambda *a: get_active_user(),
'company_id': lambda *a: get_active_company(),
'branch_id': _get_branch,
@@ -270,7 +272,6 @@ class Shop(Model):
if obj.invoices:
for inv in obj.invoices:
inv.void()
- due_date=obj.date[1:10] # XXX
context['type']='out'
context['inv_type']='invoice'
context['branch_id']=obj.branch_id.id
@@ -281,7 +282,7 @@ class Shop(Model):
"type": "out",
"inv_type": "invoice",
"tax_type": "tax_in",
- 'due_date': due_date,
+ 'due_date': obj.due_date,
"ref": obj.number or "",
'department_id': obj.department_id.id,
"related_id": "clinic.shop,%s"%obj.id,
@@ -316,7 +317,7 @@ class Shop(Model):
inv.post()
obj.make_pickings()
obj.write({
- 'state': 'paid',
+ 'state': 'waiting_payment',
'pay_type': 'credit',
})
@@ -491,7 +492,117 @@ class Shop(Model):
},
}
- def get_page(self,context={}):
+ def get_invoice_page(self,context={}):
+ if not context.get('refer_id'):
+ return {}
+ shop_id=int(context['refer_id'])
+ shop=self.browse(shop_id)
+ comp_id=get_active_company()
+ comp=get_model('company').browse(comp_id)
+ context['branch_id']=shop.branch_id.id
+ st=get_model('settings').browse(1,context=context)
+ cst=get_model('clinic.setting').browse(1)
+ cust=shop.contact_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=''
+
+ if cust.walkin_cust:
+ cust_name=shop.ref or ''
+ no=1
+ sub_total=0
+ amount_total=0
+ lines=[]
+ for line in shop.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': line.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 #XXX
+ is_draft=shop.state=='draft' and True or False
+ is_cheque=False
+ pay_type=shop.pay_type or ''
+ 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 ""
+ number="/"
+ ref=""
+ payment_terms=''
+ currency_code=''
+ due_date=shop.due_date
+ for inv in shop.invoices:
+ number=inv.number or ""
+ ref=shop.number 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': shop.date,
+ 'datenow': shop.date or time.strftime("%d/%m/%Y"),
+ 'dateprint': shop.date or time.strftime("%d/%m/%Y %H:%M:%S"),
+ 'note': shop.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': shop.state or "",
+ }
+ blank_dot=''
+ if pay_type=='cash':
+ data['pay_type']='Cash'
+ if shop.cheque_no:
+ data['is_cheque']=True
+ data['bank_name']=shop.bank_name or blank_dot
+ data['branch_name']=shop.branch_name or blank_dot
+ data['cheque_no']=shop.cheque_no or blank_dot
+ data['cheque_date']=shop.pay_date or blank_dot
+ else:
+ 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
+
+ def get_receipt_page(self,context={}):
if not context.get('refer_id'):
return {}
shop_id=int(context['refer_id'])
@@ -538,17 +649,11 @@ class Shop(Model):
comp_name=comp.name or ""
if st.default_address_id.company:
comp_name=st.default_address_id.company or ""
- number=shop.number or ""
- ref=shop.ref or ""
- if shop.pay_type=="cash":
- for pm in shop.payments:
- number=pm.number or ""
- ref=shop.number or ""
- else:
- for inv in shop.invoices:
- number=inv.number or ""
- ref=shop.number or ""
-
+ number="/"
+ ref=""
+ for pm in shop.payments:
+ number=pm.number or ""
+ ref=shop.number or ""
add=st.default_address_id
data={
'comp_name': comp_name,
@@ -596,15 +701,51 @@ class Shop(Model):
data['signature']=get_file_path(cst.signature)
return data
- def get_data(self,ids,context={}):
+ def is_pay_by_cheque(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ res=obj.pay_type or obj.pay_by or obj.pay_date or obj.bank_name or obj.bank_branch or False
+ return res
+
+ def get_receipt_data(self,ids,context={}):
settings=get_model('settings').browse(1)
pages=[]
for obj in get_model('clinic.shop').browse(ids):
context['refer_id']=obj.id
- data=get_model('clinic.shop').get_page(context=context)
+ data=get_model('clinic.shop').get_receipt_page(context=context)
limit_item=13
+ if obj.is_pay_by_cheque(context=context):
+ limit_item-=1
if data['state']=='draft':
- limit_item=10
+ 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_data(self,ids,context={}):
+ settings=get_model('settings').browse(1)
+ pages=[]
+ for obj in get_model('clinic.shop').browse(ids):
+ context['refer_id']=obj.id
+ data=get_model('clinic.shop').get_invoice_page(context=context)
+ limit_item=13
+ if obj.is_pay_by_cheque(context=context):
+ limit_item-=1
+ if data['state']=='draft':
+ limit_item-=3
for i in range(len(data['lines']),limit_item):
data['lines'].append({
'no': '',
@@ -628,11 +769,15 @@ class Shop(Model):
obj=self.browse(ids)[0]
if not obj.lines:
raise Exception("No item")
+ res=obj.pay_cash()
+ return res
- if obj.pay_type=='cash':
- res=obj.pay_cash()
- else:
- res=obj.pay_credit()
+ def approve(self,ids,context={}):
+ res={}
+ obj=self.browse(ids)[0]
+ if not obj.lines:
+ raise Exception("No item")
+ res=obj.pay_credit()
return res
def onchange_branch(self,context={}):
@@ -640,4 +785,10 @@ class Shop(Model):
data['department_id']=None
return data
+ def void(self,ids,context={}):
+ for obj in self.browse(ids):
+ obj.write({
+ 'state': 'cancelled',
+ })
+
Shop.register()
diff --git a/netforce_clinic/reports/cust_invoice.odt b/netforce_clinic/reports/cust_invoice.odt
new file mode 100644
index 0000000..5bc494e
Binary files /dev/null and b/netforce_clinic/reports/cust_invoice.odt differ
diff --git a/netforce_clinic/reports/report_account_hd_case_summary.xlsx b/netforce_clinic/reports/report_account_hd_case_summary.xlsx
index f8c89cc..931cf90 100644
Binary files a/netforce_clinic/reports/report_account_hd_case_summary.xlsx and b/netforce_clinic/reports/report_account_hd_case_summary.xlsx differ
diff --git a/netforce_clinic/templates/report_account_hd_case_summary.hbs b/netforce_clinic/templates/report_account_hd_case_summary.hbs
index 892710f..3f94c74 100644
--- a/netforce_clinic/templates/report_account_hd_case_summary.hbs
+++ b/netforce_clinic/templates/report_account_hd_case_summary.hbs
@@ -59,6 +59,7 @@
ค่าฟอก |
ค่ายา |
ค่าบริการฉีดยา |
+ Inv# |
Picking# |
แพทย์ |
พยาบาล |
@@ -85,7 +86,7 @@
{{currency epo zero=""}} |
{{currency lab zero=""}} |
{{currency misc zero=""}} |
- {{dlz_name}} |
+ {{currency dlz_price zero=""}} |
{{inv_ref}} |
{{#if pick_id}}
@@ -109,6 +110,9 @@
| {{currency fee zero=""}} |
{{currency epo zero=""}} |
{{currency srv zero=""}} |
+
+ {{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}}
+ |
{{#if pick_id}}
{{view "link" string=pick_ref action="pick_out" action_options="mode=form" active_id=pick_id}}
@@ -140,7 +144,7 @@
| {{currency total_epo zero=""}} |
{{currency total_lab zero=""}} |
{{currency total_misc zero=""}} |
- |
+ {{currency total_dlz zero=""}} |
|
{{else}}
|
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index da6861e..53c3c85 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -1 +1,3 @@
-testing script generate
+> script:
+ merge staff, patient
+> invoice payment on rd shop