diff --git a/README.md b/README.md index 97880534..db67696d 100755 --- a/README.md +++ b/README.md @@ -228,6 +228,9 @@ For Price 0 in receipt bill For Aston Request => Gift Voucher 1) settings/payment_method_settings => {payment_method:'GiftVoucher', is_active:true, ...} +For Login expiry time + 1) settings/lookups => {type:expity_time, name:login, value: {minutes}} + * value should be minute only (30 / 60 / 120 / etc.) Menu Image (Import guideline) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index eb532898..09d6671e 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -120,7 +120,8 @@ class HomeController < ApplicationController @inventories = StockJournal.inventory_balances(today,@from,@to,@from_time,@to_time).sum(:balance) @total_trans = Sale.total_trans(today,current_user,@from,@to,@from_time,@to_time) - @total_payment_trans = Sale.total_payment_trans(today,current_user,@from,@to,@from_time,@to_time) + @total_card = Sale.total_card_sale(today,current_user,@from,@to,@from_time,@to_time) + @total_credit = Sale.credit_payment(today,current_user,@from,@to,@from_time,@to_time) @sale_data = Array.new @total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to,@from_time,@to_time) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 537803b1..1ed56cdf 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -102,8 +102,7 @@ class Origami::HomeController < BaseOrigamiController accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC") @tax_arr =[] accounts.each do |acc| - account = TaxProfile.find(acc.id) - @tax_arr.push(account.name) + @tax_arr.push(acc.name) end lookup_spit_bill = Lookup.collection_of('split_bill') diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index f0c69d71..9d40d4a2 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -129,7 +129,6 @@ class Origami::RoomsController < BaseOrigamiController accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC") @tax_arr =[] accounts.each do |acc| - account = TaxProfile.find(acc.id) @tax_arr.push(account.name) end diff --git a/app/models/employee.rb b/app/models/employee.rb index c1f985ea..66f9a7f0 100755 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -21,12 +21,12 @@ class Employee < ApplicationRecord def self.login(emp_id, password) user = Employee.find_by_emp_id(emp_id) + expiry_time = login_expiry_time if (user) #user.authenticate(password) - if (user.authenticate(password)) user.generate_token - user.session_expiry = DateTime.now.utc + 30.minutes + user.session_expiry = DateTime.now.utc + expiry_time.minutes user.session_last_login = DateTime.now.utc user.save return user @@ -41,9 +41,10 @@ class Employee < ApplicationRecord def self.authenticate_by_token(session_token) if (session_token) user = Employee.find_by_token_session(session_token) + expiry_time = login_expiry_time if user && user.session_expiry.utc > DateTime.now.utc #Extend the login time each time authenticatation take place - user.session_expiry = user.session_expiry.utc + 30.minutes + user.session_expiry = user.session_expiry.utc + expiry_time.minutes user.save return true else @@ -72,5 +73,17 @@ class Employee < ApplicationRecord retry end + def self.login_expiry_time + expiry_time = 30 + login_expiry = Lookup.collection_of('expiry_time') + if !login_expiry.empty? + login_expiry.each do |exp_time| + if exp_time[0].downcase == "login" + expiry_time = exp_time[1].to_i + end + end + end + return expiry_time + end end diff --git a/app/models/sale.rb b/app/models/sale.rb index cb4d8a19..0933ad1a 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1538,60 +1538,120 @@ end end end - def self.total_payment_trans(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil) + def self.total_card_sale(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil) if !from.nil? && !to.nil? if current_user.nil? if !from_time.nil? && !to_time.nil? - query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit') - .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to,from_time,to_time) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") + .sum("sp.payment_amount") else - query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit') - .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") + .sum("sp.payment_amount") end else if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' if !from_time.nil? && !to_time.nil? - query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit') - .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to,from_time,to_time) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") + .sum("sp.payment_amount") else - query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit') - .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") + .sum("sp.payment_amount") end else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? if !from_time.nil? && !to_time.nil? - query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit') - .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and shift_sale_id=?',from,to,from_time,to_time,shift.id) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and shift_sale_id=?',from,to,from_time,to_time,shift.id) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") + .sum("sp.payment_amount") else - query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit') - .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',from,to,shift.id) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and shift_sale_id=?',from,to,shift.id) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") + .sum("sp.payment_amount") end end end end else if current_user.nil? - query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit') - .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today,today) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") + .sum("sp.payment_amount") else if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' - query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit') - .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today,today) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") + .sum("sp.payment_amount") else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? - query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit') - .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',today,today,shift.id) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and shift_sale_id=?',today,today,shift.id) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") + .sum("sp.payment_amount") + end + end + end + end + end + + def self.credit_payment(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil) + if !from.nil? && !to.nil? + if current_user.nil? + if !from_time.nil? && !to_time.nil? + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) + .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") + .sum("payment_amount") + else + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to) + .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") + .sum("payment_amount") + end + else + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' + if !from_time.nil? && !to_time.nil? + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) + .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") + .sum("payment_amount") + else + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to) + .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") + .sum("payment_amount") + end + else + shift = ShiftSale.current_open_shift(current_user.id) + if !shift.nil? + if !from_time.nil? && !to_time.nil? + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and s.shift_sale_id=?',from,to,from_time,to_time,shift.id) + .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") + .sum("payment_amount") + else + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and s.shift_sale_id=?',from,to,shift.id) + .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") + .sum("payment_amount") + end + end + end + end + else + if current_user.nil? + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today) + .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") + .sum("payment_amount") + else + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today) + .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") + .sum("payment_amount") + else + shift = ShiftSale.current_open_shift(current_user.id) + if !shift.nil? + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and s.shift_sale_id=?',today,today,shift.id) + .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") + .sum("payment_amount") end end end diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index a4b64cce..47e34f31 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -51,8 +51,8 @@
<%= t :total_credit %>
- <% if !@total_payment_trans[0].nil? %> -
+ <% if !@total_credit.nil? %> +
" data-speed="1000" data-fresh-interval="20">
<% end %>
@@ -64,8 +64,8 @@
<%= t :total_card %>
- <% if !@total_payment_trans[0].nil? %> -
+ <% if !@total_card.nil? %> +
" data-speed="1000" data-fresh-interval="20">
<% end %>
diff --git a/app/views/reports/order_reservation/index.html.erb b/app/views/reports/order_reservation/index.html.erb index ef5feafc..8384702f 100755 --- a/app/views/reports/order_reservation/index.html.erb +++ b/app/views/reports/order_reservation/index.html.erb @@ -95,13 +95,15 @@ discount_amount = order_reservation.discount_amount delivery_fee = order_reservation.delivery_fee ? order_reservation.delivery_fee : 0.0 convenience_charge = order_reservation.convenience_charge - JSON.parse(order_reservation.taxes).each do |tax_data| - if tax_data[0] == "delivery_tax" - delivery_tax = tax_data[1] - elsif tax_data[0] == "convenience_tax" - convenience_tax = tax_data[1] - elsif tax_data[0] == "commercial_tax" - commercial_tax = tax_data[1] + if !JSON.parse(order_reservation.taxes).empty? + JSON.parse(order_reservation.taxes).each do |tax_data| + if tax_data[0] == "delivery_tax" + delivery_tax = tax_data[1] + elsif tax_data[0] == "convenience_tax" + convenience_tax = tax_data[1] + elsif tax_data[0] == "commercial_tax" + commercial_tax = tax_data[1] + end end end total_discount_amount += discount_amount.to_f diff --git a/app/views/reports/order_reservation/index.xls.erb b/app/views/reports/order_reservation/index.xls.erb index 5a3bc4ea..b33757e5 100755 --- a/app/views/reports/order_reservation/index.xls.erb +++ b/app/views/reports/order_reservation/index.xls.erb @@ -68,14 +68,15 @@ discount_amount = order_reservation.discount_amount delivery_fee = order_reservation.delivery_fee ? order_reservation.delivery_fee : 0.0 convenience_charge = order_reservation.convenience_charge - - JSON.parse(order_reservation.taxes).each do |tax_data| - if tax_data[0] == "delivery_tax" - delivery_tax = tax_data[1] - elsif tax_data[0] == "convenience_tax" - convenience_tax = tax_data[1] - elsif tax_data[0] == "commercial_tax" - commercial_tax = tax_data[1] + if !JSON.parse(order_reservation.taxes).empty? + JSON.parse(order_reservation.taxes).each do |tax_data| + if tax_data[0] == "delivery_tax" + delivery_tax = tax_data[1] + elsif tax_data[0] == "convenience_tax" + convenience_tax = tax_data[1] + elsif tax_data[0] == "commercial_tax" + commercial_tax = tax_data[1] + end end end diff --git a/app/views/reports/product_sale/index.html.erb b/app/views/reports/product_sale/index.html.erb index 4670f6b3..5cd38e52 100644 --- a/app/views/reports/product_sale/index.html.erb +++ b/app/views/reports/product_sale/index.html.erb @@ -59,6 +59,7 @@ <% total_data = {} %> <% @sale_data.each do |sale| if !total_item.has_key?(sale.item_code) + grand_total += sale.grand_total total_item[sale.item_code] = sale.total_item total_data[sale.item_code] = sale.grand_total else @@ -67,13 +68,13 @@ end if sale.status_type == "void" || sale.status_type == "Discount" || sale.status_type == "foc" total_data[sale.item_code] += sale.grand_total + grand_total += sale.grand_total end end end %> <% @sale_data.each do |sale| %> - <% grand_total += sale.grand_total %> - <% if sale.status_type != "Discount" && sale.status_type != "foc" + <% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion" total_qty += sale.total_item end %> <% if sale.status_type == "foc" && sale.price > 0 diff --git a/app/views/reports/product_sale/index.xls.erb b/app/views/reports/product_sale/index.xls.erb index 98885861..b15c7270 100644 --- a/app/views/reports/product_sale/index.xls.erb +++ b/app/views/reports/product_sale/index.xls.erb @@ -32,6 +32,7 @@ <% total_data = {} %> <% @sale_data.each do |sale| if !total_item.has_key?(sale.item_code) + grand_total += sale.grand_total total_item[sale.item_code] = sale.total_item total_data[sale.item_code] = sale.grand_total else @@ -40,13 +41,13 @@ end if sale.status_type == "void" || sale.status_type == "Discount" || sale.status_type == "foc" total_data[sale.item_code] += sale.grand_total + grand_total += sale.grand_total end end end %> <% @sale_data.each do |sale| %> - <% grand_total += sale.grand_total %> - <% if sale.status_type != "Discount" && sale.status_type != "foc" + <% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion" total_qty += sale.total_item end %> <% if sale.status_type == "foc" && sale.price > 0 diff --git a/lib/tasks/clear_data.rake b/lib/tasks/clear_data.rake index 989e9f85..e74f4252 100755 --- a/lib/tasks/clear_data.rake +++ b/lib/tasks/clear_data.rake @@ -16,6 +16,7 @@ namespace :clear do PaymentJournal.delete_all Survey.delete_all ProductCommission.delete_all + InDuty.delete_all DiningFacility.update_all(status:'available') CashierTerminal.update_all(is_currently_login: 0) SeedGenerator.where("id > 1").update(:current => 0, :next => 1)