shop code filter for all reports and transactions
This commit is contained in:
@@ -98,7 +98,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
other_charges = Sale.get_other_charges()
|
||||
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
|
||||
end
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||
#other payment details for mpu or visa like card
|
||||
@@ -143,7 +143,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
if @shift
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
|
||||
@@ -2,21 +2,14 @@ class Reports::CommissionController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
|
||||
def index
|
||||
# from_date = DateTime.now.beginning_of_day.utc.getlocal
|
||||
# to_date = DateTime.now.end_of_day.utc.getlocal
|
||||
# unless params[:daterange].blank?
|
||||
# from_date = Date.parse(params[:daterange].split(' - ')[0]).beginning_of_day.utc.getlocal
|
||||
# to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day.utc.getlocal
|
||||
# @daterange = params[:daterange]
|
||||
# end
|
||||
from_date, to_date = get_date_range_from_params
|
||||
|
||||
commissioner = params[:commissioner].to_i
|
||||
@com_id = commissioner
|
||||
@commissioner = Commissioner.active.all
|
||||
@commissioner = Commissioner.active.where("shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@transaction = ProductCommission.get_transaction(from_date, to_date, commissioner)
|
||||
|
||||
|
||||
@from = from_date
|
||||
@to = to_date
|
||||
# get printer info
|
||||
@@ -30,7 +23,7 @@ class Reports::CommissionController < BaseReportController
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
@@ -49,6 +42,5 @@ class Reports::CommissionController < BaseReportController
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
class Reports::CreditPaymentController < BaseReportController
|
||||
class Reports::CreditPaymentController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
@filter_for_credit = [['All',''],['Paid','paid'],['Unpaid','unpaid']]
|
||||
@sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]]
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
else
|
||||
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
|
||||
@filter = params[:filter_check]
|
||||
@order_source = params[:order_source]
|
||||
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,@order_source)
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,@order_source,@shop.shop_code)
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
@@ -58,10 +58,10 @@ authorize_resource :class => false
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,11 +3,11 @@ class Reports::DailysaleController < BaseReportController
|
||||
|
||||
def index
|
||||
from, to = get_date_range_from_params
|
||||
@sale_data = Sale.daily_sales_list(from,to)
|
||||
@tax = SaleTax.get_tax(from,to)
|
||||
@sale_data = Sale.daily_sales_list(from,to,@shop.shop_code)
|
||||
@tax = SaleTax.get_tax(from,to,@shop.shop_code)
|
||||
@from = from
|
||||
@to = to
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1' and shop_code='#{@shop.shop_code}'").pluck("payment_method")
|
||||
|
||||
|
||||
# get printer info
|
||||
|
||||
@@ -2,7 +2,7 @@ class Reports::HourlySaleitemController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
@account = Account.all
|
||||
@account = Account.where("shop_code='#{@shop.shop_code}'")
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
shift_sale_range = ''
|
||||
@@ -10,25 +10,25 @@ class Reports::HourlySaleitemController < BaseReportController
|
||||
shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
else
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
account_type = params[:account_type]
|
||||
@type = params[:sale_type]
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,@shop.shop_code)
|
||||
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
|
||||
@@ -57,7 +57,7 @@ class Reports::HourlySaleitemController < BaseReportController
|
||||
# @hourly_total_qty = @sale_data.group_by {|s| s.date_format }.collect{|key,qty| {"date" => key , "total_qty" => qty.sum{|d| d.qty.to_i}}}
|
||||
@hourly_total_qty = @sale_data.group_by(&:date_format).map { |k,v|{"date" => k , "total_qty" => v.count }}
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
class Reports::IndutyController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
@commissioners = Commissioner.all #.where("is_active='1'")
|
||||
@commissioners = Commissioner.where("shop_code='#{@shop.shop_code}'") #.where("is_active='1'")
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at)
|
||||
else
|
||||
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
|
||||
@commissioner = params[:commissioner]
|
||||
@induty_data = InDuty.get_induty_by_shift(@shift_sale_range,@shift,from,to,@commissioner)
|
||||
@induty_data = InDuty.get_induty_by_shift(@shift_sale_range,@shift,from,to,@commissioner).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
@@ -43,9 +43,9 @@ class Reports::IndutyController < BaseReportController
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@induty_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@induty_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
@commissioner = params[:commissioner]
|
||||
|
||||
|
||||
date_arr = Array.new
|
||||
@induty_data.each do |induty|
|
||||
local_opening_date = induty.opening_date.nil? ? '-' : induty.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@@ -58,7 +58,7 @@ class Reports::IndutyController < BaseReportController
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Reports::OrderReservationController < BaseReportController
|
||||
class Reports::OrderReservationController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
def index
|
||||
@providers = [["All",''], ["Direct Delivery","direct_delivery"],["Pick-Up","pick_up"],["TURBO","turbo"],["food2u","food2u"], ["ygndoor2door","ygndoor2door"]]
|
||||
@@ -11,23 +11,23 @@ class Reports::OrderReservationController < BaseReportController
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
else
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
else
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
provider = params[:provider]
|
||||
payment_type = params[:payment_type]
|
||||
@order_reservation_data = OrderReservation.get_order_reservation_by_shift(@shift_sale_range,@shift,from,to,provider,payment_type)
|
||||
@order_reservation_data = OrderReservation.get_order_reservation_by_shift(@shift_sale_range,@shift,from,to,provider,payment_type).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
@@ -49,7 +49,7 @@ class Reports::OrderReservationController < BaseReportController
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
@@ -63,10 +63,10 @@ class Reports::OrderReservationController < BaseReportController
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
class Reports::PaymentMethodController < BaseReportController
|
||||
class Reports::PaymentMethodController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
def index
|
||||
|
||||
@payments = [["All Payment",''],["Cash Payment","cash"], ["KBZ Payment", KbzPay::KBZ_PAY], ["Credit Payment","creditnote"],
|
||||
["FOC Payment","foc"], ["MPU Payment","mpu"], ["Visa Payment","visa"],
|
||||
["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"],
|
||||
["FOC Payment","foc"], ["MPU Payment","mpu"], ["Visa Payment","visa"],
|
||||
["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"],
|
||||
["Alipay Payment","alipay"],["Paymal Payment", "paymal"],["Dinga Payment","dinga"],
|
||||
["JunctionPay","junctionpay"],["Redeem Payment","paypar"],["Gift Voucher","giftvoucher"]]
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
else
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
@payment_type = params[:payment_type]
|
||||
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type)
|
||||
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type,@shop.shop_code)
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
@@ -44,7 +44,7 @@ class Reports::PaymentMethodController < BaseReportController
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
@@ -58,10 +58,10 @@ class Reports::PaymentMethodController < BaseReportController
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class Reports::ReceiptNoController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
@payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]]
|
||||
@payment_method = PaymentMethodSetting.all
|
||||
@payment_method = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@shift_sale_range = ''
|
||||
@@ -10,16 +10,16 @@ authorize_resource :class => false
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at)
|
||||
else
|
||||
if @shift_sale.shift_closed_at.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',@shift_sale.shift_started_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at)
|
||||
else
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -30,9 +30,9 @@ authorize_resource :class => false
|
||||
end
|
||||
|
||||
payment_type = params[:payment_type]
|
||||
@sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type)
|
||||
@sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type)
|
||||
@tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2)
|
||||
@sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@tax_profiles = TaxProfile.where("shop_code='#{@shop.shop_code}'").group('name').order('order_by asc') #.limit(2)
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
@@ -55,7 +55,7 @@ authorize_resource :class => false
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class Reports::ReceiptNoDetailController < BaseReportController
|
||||
class Reports::ReceiptNoDetailController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
@payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]]
|
||||
@payment_method = PaymentMethodSetting.all
|
||||
@payment_method = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@shift_sale_range = ''
|
||||
@@ -10,22 +10,22 @@ authorize_resource :class => false
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at)
|
||||
else
|
||||
if @shift_sale.shift_closed_at.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',@shift_sale.shift_started_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at)
|
||||
else
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
payment_type = params[:payment_type]
|
||||
@sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type)
|
||||
@sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
@@ -48,7 +48,7 @@ authorize_resource :class => false
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
@@ -62,10 +62,10 @@ authorize_resource :class => false
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class Reports::SaleitemController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
@account = Account.all
|
||||
@account = Account.where("shop_code='#{@shop.shop_code}'")
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
shift_sale_range = ''
|
||||
@@ -10,26 +10,25 @@ class Reports::SaleitemController < BaseReportController
|
||||
shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at)
|
||||
else
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
account_type = params[:account_type]
|
||||
@type = params[:sale_type]
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
|
||||
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,@shop.shop_code)
|
||||
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
|
||||
|
||||
@@ -62,7 +61,7 @@ class Reports::SaleitemController < BaseReportController
|
||||
|
||||
def show
|
||||
from, to, report_type = get_date_range_from_params
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
@@ -94,16 +93,16 @@ class Reports::SaleitemController < BaseReportController
|
||||
shift_name = 'All Shift'
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
else
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'" ,shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -112,36 +111,30 @@ class Reports::SaleitemController < BaseReportController
|
||||
shift_name = employee.nil? ? sh_name : "#{sh_name} (#{employee.name})"
|
||||
end
|
||||
|
||||
shop_details = shop_detail
|
||||
account_type = params[:account_type]
|
||||
@type = params[:period_type]
|
||||
period_name = get_period_name(params[:period])
|
||||
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,@shop.shop_code)
|
||||
other_charges = Sale.get_other_charges()
|
||||
if shift.present?
|
||||
@total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
@total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed' and sales.shop_code='#{@shop.shop_code}'",shift.to_a)
|
||||
else
|
||||
@total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
@total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed' and sales.shop_code='#{@shop.shop_code}'",from,to)
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code('SaleItemsPdf') # SaleItemsPdf
|
||||
print_settings_star = PrintSetting.find_by_unique_code('SaleItemsStarPdf')
|
||||
|
||||
# if print_settings.nil? && print_settings_star.nil?
|
||||
# @print_setting = PrintSetting.new(name: "SaleItemsPdf", unique_code: "SaleItemsPdf", template: "",font: "Zawgyi-One", header_font_size: "10", item_font_size: "8", printer_name: "", api_settings: "", brand_name: nil, printer_type: nil, page_width: "210", page_height: "1450", print_copies: "1", precision: "0", delimiter: "0", heading_space: "5" )
|
||||
# @print_setting.save
|
||||
# end
|
||||
print_settings = PrintSetting.find_by_unique_code_and_shop_code('SaleItemsPdf',@shop.shop_code) # SaleItemsPdf
|
||||
print_settings_star = PrintSetting.find_by_unique_code_and_shop_code('SaleItemsStarPdf',@shop.shop_code)
|
||||
|
||||
if print_settings.nil?
|
||||
if !print_settings_star.nil?
|
||||
printer = Printer::CashierStationPrinter.new(print_settings_star)
|
||||
printer.print_sale_items_report(print_settings_star, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
|
||||
printer.print_sale_items_report(print_settings_star, @shop, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
|
||||
end
|
||||
else
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
printer.print_sale_items_report(print_settings, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
|
||||
printer.print_sale_items_report(print_settings, @shop, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
@@ -8,7 +8,7 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
if params[:shift_name].to_i != 0
|
||||
@shift = ShiftSale.find(params[:shift_name])
|
||||
end
|
||||
@sale_data = Sale.get_by_shiftsales(from,to,@shift)
|
||||
@sale_data = Sale.get_by_shiftsales(from,to,@shift,@shop.shop_code)
|
||||
@from = from
|
||||
@to = to
|
||||
if @shift.present?
|
||||
@@ -28,7 +28,7 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
@@ -56,7 +56,7 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
|
||||
close_cashier_pdf = Lookup.collection_of("print_settings")
|
||||
close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings")
|
||||
|
||||
unique_code = "CloseCashierPdf"
|
||||
|
||||
@@ -75,7 +75,7 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
|
||||
shop_details = shop_detail
|
||||
cashier_terminal = @shift.cashier_terminal
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||
#other payment details for mpu or visa like card
|
||||
@@ -91,12 +91,12 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
|
||||
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
|
||||
# printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||
|
||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, @shop,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'}
|
||||
format
|
||||
|
||||
@@ -2,7 +2,7 @@ class Reports::StaffMealController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
@account = Account.all
|
||||
@account = Account.where("shop_code='#{@shop.shop_code}'")
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
shift_sale_range = ''
|
||||
@@ -10,16 +10,16 @@ class Reports::StaffMealController < BaseReportController
|
||||
shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
else
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -32,9 +32,9 @@ class Reports::StaffMealController < BaseReportController
|
||||
|
||||
account_type = params[:account_type]
|
||||
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_staff_meal_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,account_type,customer_id)
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_staff_meal_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,account_type,customer_id,@shop.shop_code)
|
||||
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
|
||||
|
||||
@@ -11,9 +11,9 @@ class Reports::StockCheckController < BaseReportController
|
||||
# end
|
||||
from_date, to_date = get_date_range_from_params
|
||||
@item_code = params[:item_code]
|
||||
@inventory_definitions = InventoryDefinition.active.all
|
||||
@inventory_definitions = InventoryDefinition.active.where("shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@transaction = StockCheckItem.get_transaction(from_date, to_date, @item_code)
|
||||
@transaction = StockCheckItem.where("shop_code='#{@shop.shop_code}'").get_transaction(from_date, to_date, @item_code)
|
||||
@from = from_date
|
||||
@to = to_date
|
||||
# get printer info
|
||||
@@ -27,7 +27,7 @@ class Reports::StockCheckController < BaseReportController
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Reports::VoidSaleController < BaseReportController
|
||||
class Reports::VoidSaleController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
@@ -8,16 +8,16 @@ authorize_resource :class => false
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#@shop.shop_code' ",shift_sale.shift_started_at)
|
||||
else
|
||||
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#@shop.shop_code' ",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
|
||||
@sale_data = Sale.get_void_sale(@shift,from,to)
|
||||
|
||||
@sale_data = Sale.get_void_sale(@shift,from,to,@shop.shop_code)
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
@@ -39,7 +39,7 @@ authorize_resource :class => false
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
@@ -53,10 +53,10 @@ authorize_resource :class => false
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class Reports::WasteAndSpoilageController < BaseReportController
|
||||
class Reports::WasteAndSpoilageController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
from, to = get_date_range_from_params
|
||||
@sale_type = params[:sale_type]
|
||||
@sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type)
|
||||
@sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
@@ -15,5 +15,5 @@ authorize_resource :class => false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Transactions::CreditNotesController < ApplicationController
|
||||
|
||||
|
||||
before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy]
|
||||
before_action :check_user
|
||||
|
||||
@@ -17,22 +17,22 @@ class Transactions::CreditNotesController < ApplicationController
|
||||
|
||||
if filter.nil? && from.nil? && to.nil? && customer.nil? && order_source.nil?
|
||||
order_source_query = "(select orders.source FROM orders JOIN sale_orders so ON so.order_id=orders.order_id WHERE so.sale_id=sales.sale_id GROUP BY so.sale_id)"
|
||||
|
||||
|
||||
@credit_notes = Sale.select("sales.*, #{order_source_query} as source")
|
||||
.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
||||
.where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
|
||||
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote')
|
||||
THEN NULL ELSE payment_method='creditnote' END)")
|
||||
THEN NULL ELSE payment_method='creditnote' END) and sales.shop_code='#{@shop.shop_code}'")
|
||||
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
||||
else
|
||||
sale = Sale.search_credit_sales(customer,filter,from,to,order_source)
|
||||
sale = Sale.search_credit_sales(customer,filter,from,to,order_source).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
if !sale.nil?
|
||||
@credit_notes = sale
|
||||
@credit_notes = sale
|
||||
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
||||
else
|
||||
@credit_notes = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @credit_notes }
|
||||
@@ -45,5 +45,5 @@ class Transactions::CreditNotesController < ApplicationController
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -12,17 +12,17 @@ class Transactions::OrderReservationsController < ApplicationController
|
||||
if from.nil? && to.nil?
|
||||
@order_reservations = OrderReservation.select("order_reservations.*, deliveries.provider, deliveries.delivery_fee")
|
||||
.joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id")
|
||||
.where("NOT order_reservation_status='new'")
|
||||
.where("NOT order_reservation_status='new' and order_reservations.shop_code='#{@shop.shop_code}'")
|
||||
.order("order_reservation_id desc")
|
||||
@order_reservations = Kaminari.paginate_array(@order_reservations).page(params[:page]).per(20)
|
||||
else
|
||||
order_reservation = OrderReservation.search(filter,from,to)
|
||||
order_reservation = OrderReservation.search(filter,from,to).where("order_reservations.shop_code='#{@shop.shop_code}'")
|
||||
if order_reservation.length > 0
|
||||
@order_reservations = order_reservation
|
||||
@order_reservations = order_reservation
|
||||
@order_reservations = Kaminari.paginate_array(@order_reservations).page(params[:page]).per(20)
|
||||
else
|
||||
@order_reservations = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
@from = from
|
||||
@to = to
|
||||
@@ -38,7 +38,7 @@ class Transactions::OrderReservationsController < ApplicationController
|
||||
# GET /transactions/order_reservations/1
|
||||
# GET /transactions/order_reservations/1.json
|
||||
def show
|
||||
|
||||
|
||||
@order_reservation = OrderReservation.select("order_reservations.*, deliveries.provider, deliveries.delivery_fee")
|
||||
.joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id")
|
||||
.where("order_reservations.order_reservation_id = ?", params[:id])
|
||||
@@ -73,7 +73,7 @@ class Transactions::OrderReservationsController < ApplicationController
|
||||
period_type = params[:period_type]
|
||||
period = params[:period]
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
to = params[:to]
|
||||
day_ref = Time.now.utc.getlocal
|
||||
|
||||
if from.present? && to.present?
|
||||
@@ -82,8 +82,8 @@ class Transactions::OrderReservationsController < ApplicationController
|
||||
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
|
||||
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
|
||||
from = f_time.beginning_of_day.utc.getlocal
|
||||
to = t_time.end_of_day.utc.getlocal
|
||||
else
|
||||
to = t_time.end_of_day.utc.getlocal
|
||||
else
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
from = day_ref.beginning_of_day.utc
|
||||
@@ -117,10 +117,10 @@ class Transactions::OrderReservationsController < ApplicationController
|
||||
when PERIOD["last_year"]
|
||||
from = (day_ref - 1.year).beginning_of_year.utc
|
||||
to = (day_ref - 1.year).end_of_year.utc
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return from, to
|
||||
return from, to
|
||||
end
|
||||
|
||||
def check_user
|
||||
@@ -128,7 +128,7 @@ class Transactions::OrderReservationsController < ApplicationController
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_transactions_order_reservation
|
||||
|
||||
@@ -9,11 +9,11 @@ class Transactions::OrdersController < ApplicationController
|
||||
to = params[:to]
|
||||
|
||||
if filter.nil? && from.nil? && to.nil?
|
||||
orders = Order.order("order_id desc")
|
||||
orders = Order.where("shop_code='#{@shop.shop_code}'").order("order_id desc")
|
||||
else
|
||||
orders = Order.search(filter,from,to)
|
||||
end
|
||||
|
||||
orders = Order.search(filter,from,to).where("orders.shop_code='#{@shop.shop_code}'")
|
||||
end
|
||||
|
||||
if !orders.nil?
|
||||
@orders = Kaminari.paginate_array(orders).page(params[:page]).per(20)
|
||||
else
|
||||
@@ -23,14 +23,14 @@ class Transactions::OrdersController < ApplicationController
|
||||
@receipt_no = filter
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render json: @orders }
|
||||
# format.csv { send_data OrdersCsvExport.generate }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
|
||||
@order = Order.find(params[:id])
|
||||
|
||||
@@ -18,13 +18,13 @@ class Transactions::SalesController < ApplicationController
|
||||
|
||||
if receipt_no.nil? && from.nil? && to.nil?
|
||||
if @shift.blank?
|
||||
@sales = Sale.where("NOT sale_status='new'").order("sale_id desc")
|
||||
@sales = Sale.where("NOT sale_status='new' and shop_code='#{@shop.shop_code}'").order("sale_id desc")
|
||||
else
|
||||
@sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").order("sale_id desc")
|
||||
@sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}' and shop_code='#{@shop.shop_code}'").order("sale_id desc")
|
||||
end
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||
else
|
||||
sale = Sale.search(receipt_no,from,to,@shift)
|
||||
sale = Sale.search(receipt_no,from,to,@shift).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
if sale.count > 0
|
||||
@sales = sale
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||
|
||||
@@ -10,16 +10,16 @@ class Transactions::ShiftSalesController < ApplicationController
|
||||
to = params[:to]
|
||||
|
||||
if filter.nil? && from.nil? && to.nil?
|
||||
@shift_sales = ShiftSale.all.order("id desc")
|
||||
@shift_sales = ShiftSale.where("shop_code='#{@shop.shop_code}'").order("id desc")
|
||||
@shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20)
|
||||
else
|
||||
shift_sale = ShiftSale.search(filter,from,to)
|
||||
shift_sale = ShiftSale.search(filter,from,to).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
if shift_sale.count > 0
|
||||
@shift_sales = shift_sale
|
||||
@shift_sales = shift_sale
|
||||
@shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20)
|
||||
else
|
||||
@shift_sales = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
@@ -32,12 +32,12 @@ class Transactions::ShiftSalesController < ApplicationController
|
||||
# GET /transactions/shift_sales/1
|
||||
# GET /transactions/shift_sales/1.json
|
||||
def show
|
||||
|
||||
|
||||
@shift = ShiftSale.find(params[:id])
|
||||
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
@@ -46,7 +46,7 @@ class Transactions::ShiftSalesController < ApplicationController
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
@@ -59,7 +59,7 @@ class Transactions::ShiftSalesController < ApplicationController
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_transactions_shift_sale
|
||||
|
||||
@@ -5,15 +5,15 @@ class Transactions::SurveysController < ApplicationController
|
||||
to = params[:to]
|
||||
|
||||
if filter.nil? && from.nil? && to.nil?
|
||||
@surveys = Survey.all
|
||||
@surveys = Survey.where("shop_code='#{@shop.shop_code}'")
|
||||
else
|
||||
@surveys = Survey.search(filter,from,to)
|
||||
end
|
||||
@surveys = Survey.search(filter,from,to).where("shop_code='#{@shop.shop_code}'")
|
||||
end
|
||||
|
||||
@filter = filter
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xls
|
||||
|
||||
@@ -753,7 +753,7 @@ class Sale < ApplicationRecord
|
||||
return num
|
||||
end
|
||||
|
||||
def self.daily_sales_list(from,to)
|
||||
def self.daily_sales_list(from,to,shop_code)
|
||||
sales = select("
|
||||
sales.*,
|
||||
SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount,
|
||||
@@ -774,7 +774,7 @@ def self.daily_sales_list(from,to)
|
||||
SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
||||
.along_with_sale_payments_except_void
|
||||
.where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
|
||||
.where("shop_code='#{shop_code}' and (sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
|
||||
.group("sale_id").to_sql
|
||||
|
||||
daily_total = connection.select_all("SELECT
|
||||
@@ -826,11 +826,11 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
|
||||
query = query.where("(receipt_date between ? and ? and sale_status=?) AND i.unit_price <> 0",from,to,status)
|
||||
end
|
||||
|
||||
def self.get_by_shiftsales(from,to,shift)
|
||||
def self.get_by_shiftsales(from,to,shift,shop_code)
|
||||
if !shift.blank?
|
||||
query = ShiftSale.where("shift_sales.id =?",shift.id)
|
||||
query = ShiftSale.where("shift_sales.id =? and shop_code='#{shop_code}'",shift.id)
|
||||
else
|
||||
query = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
|
||||
query = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? ) and shop_code='#{shop_code}'", from, to, from, to)
|
||||
end
|
||||
|
||||
shift_sale_data = Hash.new
|
||||
@@ -951,7 +951,7 @@ def self.get_other_charges()
|
||||
query = query.group("i.sale_item_id")
|
||||
end
|
||||
|
||||
def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,account_type)
|
||||
def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,account_type,shop_code)
|
||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||
if account_type.blank?
|
||||
account_type = ''
|
||||
@@ -974,19 +974,19 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
product = self.get_product_sale()
|
||||
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
|
||||
query = query.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
other_charges = other_charges.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
||||
product = product.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
|
||||
.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
@@ -997,19 +997,19 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
|
||||
### => get all sales range in shift_sales
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a)
|
||||
query = query.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
other_charges = other_charges.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
||||
product = product.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
|
||||
.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
@@ -1020,20 +1020,20 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
||||
|
||||
else
|
||||
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to)
|
||||
query = query.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
other_charges = other_charges.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
end
|
||||
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
|
||||
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
|
||||
.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
@@ -1047,7 +1047,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
|
||||
end
|
||||
|
||||
def self.get_staff_meal_items(shift_sale_range, shift, from, to, status,account_type,customer_id)
|
||||
def self.get_staff_meal_items(shift_sale_range, shift, from, to, status,account_type,customer_id,shop_code)
|
||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||
if account_type.blank?
|
||||
account_type = ''
|
||||
@@ -1079,19 +1079,19 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status,account_
|
||||
product = self.get_product_sale()
|
||||
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",shift.to_a)
|
||||
query = query.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",shift.to_a)
|
||||
# if type.nil? || type == 'all' || type == "other"
|
||||
# other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
# end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
||||
product = product.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
|
||||
.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
@@ -1102,19 +1102,19 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status,account_
|
||||
|
||||
### => get all sales range in shift_sales
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",shift_sale_range.to_a)
|
||||
query = query.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",shift_sale_range.to_a)
|
||||
# if type.nil? || type == 'all' || type == "other"
|
||||
# other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
# end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
||||
product = product.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
|
||||
.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
@@ -1125,20 +1125,20 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status,account_
|
||||
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
||||
|
||||
else
|
||||
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",from,to)
|
||||
query = query.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",from,to)
|
||||
# if type.nil? || type == 'all' || type == "other"
|
||||
# other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
# end
|
||||
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
product = product.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
|
||||
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
|
||||
.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
@@ -1233,7 +1233,7 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
|
||||
return query
|
||||
end
|
||||
|
||||
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source)
|
||||
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source,shop_code)
|
||||
payments_for_credits = SalePayment.select("
|
||||
sales.sale_id,
|
||||
DATE_FORMAT(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30'),'%d %b %y %h:%i%p') as credit_payment_receipt_date,
|
||||
@@ -1242,7 +1242,8 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,
|
||||
CONCAT(DATE_FORMAT(CONVERT_TZ(shift_sales.shift_started_at,'+00:00','+06:30'),'%d %b %y %h:%i%p'),' - ',DATE_FORMAT(CONVERT_TZ(shift_sales.shift_closed_at,'+00:00','+06:30'),'%d %b %y %h:%i%p')) as credit_payment_shift_name")
|
||||
.joins(:sale_audit)
|
||||
.joins(:sale => :shift_sale)
|
||||
.joins(:sale => :cashier).to_sql
|
||||
.joins(:sale => :cashier)
|
||||
.where("sales.shop_code='#{shop_code}'").to_sql
|
||||
|
||||
credits = SalePayment.select("
|
||||
sale_payments.sale_payment_id,
|
||||
@@ -1289,10 +1290,11 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,
|
||||
credits = credits.group("sale_payments.sale_payment_id, sales_sale_payments.sale_id")
|
||||
end
|
||||
|
||||
def self.get_void_sale(shift,from,to)
|
||||
def self.get_void_sale(shift,from,to,shop_code)
|
||||
sale_arr = Array.new
|
||||
|
||||
query = Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment")
|
||||
.where("sales.shop_code='#{shop_code}'")
|
||||
# .joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id")
|
||||
# .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ?
|
||||
# OR sh.shift_closed_at between ? and ? )", from ,to, from, to)
|
||||
@@ -1342,13 +1344,13 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type)
|
||||
def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type,shop_code)
|
||||
sub_query = "SELECT (CASE WHEN SUM(sale_payments.payment_amount) > 0 THEN SUM(sale_payments.payment_amount) ELSE 0 END)
|
||||
FROM sale_payments
|
||||
INNER JOIN sale_audits sa
|
||||
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id
|
||||
INNER JOIN sales ON sa.sale_id = sales.sale_id
|
||||
WHERE sales.sale_status='completed' "
|
||||
WHERE sales.sale_status='completed' and sales.shop_code='#{shop_code}'"
|
||||
|
||||
if shift.present?
|
||||
shift_ids = shift.map(&:id).join(",")
|
||||
@@ -1374,7 +1376,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
|
||||
sale_payment = SalePayment.select("s.amount_changed as change_amount,s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
|
||||
s.cashier_name as cashier_name")
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.where("(#{sub_query1}) ")
|
||||
.where("(#{sub_query1}) and s.shop_code='#{shop_code}'")
|
||||
.order('s.receipt_no DESC')
|
||||
|
||||
payments_total = SalePayment.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
||||
@@ -1395,6 +1397,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
|
||||
SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
||||
.joins("join sales on sales.sale_id = sale_payments.sale_id")
|
||||
.where("sales.shop_code='#{shop_code}'")
|
||||
|
||||
if shift.present?
|
||||
|
||||
@@ -2170,7 +2173,7 @@ def self.employee_sale(shop,today,shift=nil,from=nil,to=nil,from_time=nil,to_tim
|
||||
end
|
||||
|
||||
# Start hourly sale item report
|
||||
def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,account_type)
|
||||
def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,account_type,shop_code)
|
||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||
if account_type.blank?
|
||||
account_type = ''
|
||||
@@ -2193,19 +2196,19 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
|
||||
product = self.get_product_sale()
|
||||
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
|
||||
query = query.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
other_charges = other_charges.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
||||
product = product.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
|
||||
.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
@@ -2216,19 +2219,19 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
|
||||
|
||||
### => get all sales range in shift_sales
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a)
|
||||
query = query.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
other_charges = other_charges.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
||||
product = product.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
|
||||
.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
@@ -2239,20 +2242,20 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
|
||||
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
||||
|
||||
else
|
||||
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to)
|
||||
query = query.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
other_charges = other_charges.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
end
|
||||
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
product = product.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
|
||||
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
|
||||
.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
|
||||
@@ -27,10 +27,10 @@ class SaleTax < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_tax(from,to)
|
||||
def self.get_tax(from,to,shop_code)
|
||||
query = SaleTax.select("sale_taxes.tax_name,SUM(sale_taxes.tax_payable_amount) as tax_amount")
|
||||
.joins("join sales on sales.sale_id = sale_taxes.sale_id")
|
||||
.where("sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0 AND inclusive = 0", 'completed', from, to)
|
||||
.where("sales.shop_code='#{shop_code}' and sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0 AND inclusive = 0", 'completed', from, to)
|
||||
.group("sale_taxes.tax_name")
|
||||
end
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# application_path="#{File.expand_path("../..", __FILE__)}"
|
||||
# directory application_path
|
||||
# #environment ENV.fetch("RAILS_ENV") { "production" }
|
||||
# environment "production"
|
||||
# pidfile "#{application_path}/tmp/puma/pid"
|
||||
# state_path "#{application_path}/tmp/puma/state"
|
||||
# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
|
||||
# port ENV.fetch("PORT") { 62158 }
|
||||
# workers 2
|
||||
# preload_app!
|
||||
# threads 1,1
|
||||
application_path="#{File.expand_path("../..", __FILE__)}"
|
||||
directory application_path
|
||||
#environment ENV.fetch("RAILS_ENV") { "production" }
|
||||
environment "production"
|
||||
pidfile "#{application_path}/tmp/puma/pid"
|
||||
state_path "#{application_path}/tmp/puma/state"
|
||||
stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
|
||||
port ENV.fetch("PORT") { 62158 }
|
||||
workers 2
|
||||
preload_app!
|
||||
threads 1,1
|
||||
|
||||
33
db/migrate/20191126052921_removeshopid.rb
Normal file
33
db/migrate/20191126052921_removeshopid.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
class Removeshopid < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
remove_column :accounts, :shop_id
|
||||
remove_column :bookings, :shop_id
|
||||
remove_column :cashier_terminals, :shop_id
|
||||
remove_column :commissioners, :shop_id
|
||||
remove_column :commissions, :shop_id
|
||||
remove_column :customers, :shop_id
|
||||
remove_column :dining_facilities, :shop_id
|
||||
remove_column :dining_queues, :shop_id
|
||||
remove_column :employees, :shop_id
|
||||
remove_column :inventory_definitions, :shop_id
|
||||
remove_column :item_sets, :shop_id
|
||||
remove_column :lookups, :shop_id
|
||||
remove_column :membership_settings, :shop_id
|
||||
remove_column :menus, :shop_id
|
||||
remove_column :order_queue_stations, :shop_id
|
||||
remove_column :orders, :shop_id
|
||||
remove_column :payment_journals, :shop_id
|
||||
remove_column :payment_method_settings, :shop_id
|
||||
remove_column :print_settings, :shop_id
|
||||
remove_column :sales, :shop_id
|
||||
remove_column :products, :shop_id
|
||||
remove_column :promotions, :shop_id
|
||||
remove_column :seed_generators, :shop_id
|
||||
remove_column :shift_sales, :shop_id
|
||||
remove_column :stock_checks, :shop_id
|
||||
remove_column :stock_journals, :shop_id
|
||||
remove_column :surveys, :shop_id
|
||||
remove_column :tax_profiles, :shop_id
|
||||
remove_column :zones, :shop_id
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user