payment method changed in report
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
class Foodcourt::VoidController < BaseFoodcourtController
|
||||
authorize_resource :class => false
|
||||
def overall_void
|
||||
authorize_resource :class => false
|
||||
|
||||
def overall_void
|
||||
sale_id = params[:sale_id]
|
||||
remark = params[:remark]
|
||||
order_source = params[:type] #tax profile source
|
||||
@@ -33,32 +33,10 @@ class Foodcourt::VoidController < BaseFoodcourtController
|
||||
sale.sale_status = 'void'
|
||||
sale.save
|
||||
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_avaliable = true
|
||||
table_count = 0
|
||||
table = sale.bookings[0].dining_facility
|
||||
table.bookings.each do |booking|
|
||||
if booking.booking_status != 'moved'
|
||||
if booking.sale_id
|
||||
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
else
|
||||
table_avaliable = true
|
||||
end
|
||||
else
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
end
|
||||
end
|
||||
if table = sale.booking.dining_facility
|
||||
unless table.current_bookings.exists?
|
||||
table.update_attributes(status: 'available')
|
||||
end
|
||||
|
||||
if table_avaliable && table_count == 0
|
||||
table.status = 'available'
|
||||
table.save
|
||||
end
|
||||
else
|
||||
table = nil
|
||||
end
|
||||
|
||||
# FOr Sale Audit
|
||||
@@ -100,47 +78,49 @@ class Foodcourt::VoidController < BaseFoodcourtController
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
customer= Customer.find(sale.customer_id)
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
#shop detail
|
||||
shop_details = Shop.current_shop
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
printer = PrintSetting.all
|
||||
printer = PrintSetting.all
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
printer.each do |printer_setting|
|
||||
if printer_setting.unique_code == 'ReceiptBillPdf'
|
||||
unique_code="ReceiptBillPdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
|
||||
unique_code="ReceiptBillA5Pdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
|
||||
unique_code="ReceiptBillStarPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
printer.each do |printer_setting|
|
||||
if printer_setting.unique_code == 'ReceiptBillPdf'
|
||||
unique_code="ReceiptBillPdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
|
||||
unique_code="ReceiptBillA5Pdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
|
||||
unique_code="ReceiptBillStarPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
|
||||
#end print
|
||||
|
||||
@@ -96,22 +96,25 @@ class HomeController < ApplicationController
|
||||
def dashboard
|
||||
@from, @to = get_date_range_from_params
|
||||
|
||||
@shop = Shop.current_shop
|
||||
|
||||
@orders = Sale.receipt_date_between(@from, @to).where("payment_status = 'new' and sale_status = 'bill'")
|
||||
@sales = Sale.receipt_date_between(@from, @to).completed
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
if shift = ShiftSale.current_open_shift(current_user.id)
|
||||
@orders = @orders.where(shift_sale_id: shift.id)
|
||||
@sales = @sales.where(shift_sale_id: shift.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@top_products = Sale.top_bottom_products(current_user,@from,@to,"top",current_shop)
|
||||
@bottom_products = Sale.top_bottom_products(current_user,@from,@to,"bottom",current_shop)
|
||||
@hourly_sales = Sale.hourly_sales(current_user,@from,@to,current_shop)
|
||||
employee_sales = Sale.employee_sales(current_user,@from,@to,current_shop)
|
||||
|
||||
@top_products = Sale.top_bottom_products(current_user,@from,@to,"top")
|
||||
@bottom_products = Sale.top_bottom_products(current_user,@from,@to,"bottom")
|
||||
@hourly_sales = Sale.hourly_sales(current_user,@from,@to)
|
||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
||||
# .sum(:grand_total)
|
||||
employee_sales = Sale.employee_sales(current_user,@from,@to)
|
||||
# .sum("(CASE WHEN sp.payment_method='cash' THEN ((sp.payment_amount) - (sales.amount_changed)) ELSE (sp.payment_amount) END)")
|
||||
@employee_sales = []
|
||||
if !employee_sales.nil?
|
||||
employee_sales.each do |emp|
|
||||
@@ -123,12 +126,11 @@ class HomeController < ApplicationController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@inventories = StockJournal.inventory_balances(@from,@to).sum(:balance)
|
||||
|
||||
@total_trans = Sale.total_trans(current_user,@from,@to)
|
||||
@total_card = Sale.total_card_sale(current_user,@from,@to)
|
||||
@total_credit = Sale.credit_payment(current_user,@from,@to, current_shop)
|
||||
@total_credit = Sale.credit_payment(current_user,@from,@to)
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(current_user,@from,@to)
|
||||
@@ -144,12 +146,11 @@ class HomeController < ApplicationController
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to)
|
||||
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
|
||||
@total_order = Sale.total_order(current_user,@from,@to, current_shop)
|
||||
@total_order = Sale.total_order(current_user,@from,@to)
|
||||
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
|
||||
@account_data = Array.new
|
||||
if !@total_accounts.nil?
|
||||
@total_accounts.each do |account|
|
||||
|
||||
acc = Sale.account_data(account.account_id,current_user,@from,@to)
|
||||
if !acc.nil? && acc.cnt_acc > 0
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
@@ -162,7 +163,7 @@ class HomeController < ApplicationController
|
||||
@total_foc_items = Sale.total_foc_items(current_user,@from,@to)
|
||||
|
||||
# get printer info
|
||||
# @print_settings = get_precision_delimiter
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
@@ -5,7 +5,7 @@ class Origami::OthersPaymentsController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
path = request.fullpath
|
||||
if path.include? ("credit_payment")
|
||||
@payment_method_setting = PaymentMethodSetting.where("LOWER(payment_method) in ('mpu','visa','master','jcb','unionpay','alipay') and is_active='1'")
|
||||
@payment_method_setting = PaymentMethodSetting.where("is_active='1'")
|
||||
else
|
||||
@payment_method_setting = PaymentMethodSetting.all
|
||||
end
|
||||
@@ -39,7 +39,92 @@ class Origami::OthersPaymentsController < BaseOrigamiController
|
||||
# end
|
||||
end
|
||||
|
||||
def new
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
payment_methods = PaymentMethodSetting.pluck(:payment_method)
|
||||
if @payment_method = payment_methods.find { |m| m.parameterize == params[:method] }
|
||||
path = request.fullpath
|
||||
# limit master_amount
|
||||
if path.include? ("credit_payment")
|
||||
sale_data = Sale.get_sale_data_for_other_payment_credit(@sale_id)
|
||||
else
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
end
|
||||
total = 0
|
||||
@shop = Shop.current_shop
|
||||
@paid_amount = 0
|
||||
@can_paid = 0
|
||||
@rounding_adj = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||
else
|
||||
sale_payment_data = sale_data.sale_payments
|
||||
end
|
||||
|
||||
sale_payment_data.each do |sale_payment|
|
||||
if sale_payment.payment_method == @payment_method.parameterize
|
||||
@paid_amount = @paid_amount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_paid = total - @paid_amount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
else
|
||||
if path.include? ("credit_payment")
|
||||
redirect_to "sale/#{@sale_id}/#{@cashier_type}/payment/others_payment"
|
||||
else
|
||||
redirect_to "sale/#{@sale_id}/#{@cashier_type}/credit_payment/others_payment"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
payment_method = params[:method]
|
||||
if PaymentMethodSetting.pluck(:payment_method).map(&:parameterize).include? payment_method
|
||||
if saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.current_shop
|
||||
|
||||
path = request.fullpath
|
||||
payment_for = false
|
||||
if path.include? ("credit_payment")
|
||||
payment_for = true
|
||||
end
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, current_user, cash, payment_method, ref_no, payment_for)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -51,7 +51,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#TODO :: KBZPAY ( QR )
|
||||
# On/Off setting ( show or not qr )
|
||||
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||
kbz_pay_method = PaymentMethodSetting.where(payment_method: KbzPay::KBZ_PAY, gateway_communication_type: ['api', 'Api'], is_active: true)
|
||||
.where.not(gateway_url: [nil, ''], auth_token: [nil, ''], merchant_account_id: [nil, '']).last
|
||||
|
||||
status = false
|
||||
qr = nil
|
||||
@@ -193,7 +194,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#card_balance amount for Paymal payment
|
||||
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
@@ -209,7 +210,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal, sale_items, saleObj, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, current_shop, "Paid", current_balance, card_data, other_amount, latest_order_no, card_balance_amount, nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, printed_status,current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||
|
||||
#end
|
||||
|
||||
@@ -232,15 +233,29 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# end
|
||||
|
||||
def show
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
@shop = Shop.current_shop
|
||||
@customer = @sale.customer
|
||||
@customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
|
||||
if dining_facility = @sale.booking.dining_facility
|
||||
@table_no = dining_facility.type + ' ' + dining_facility.name
|
||||
@checkin_time = @sale.booking.checkin_at
|
||||
@dining = dining_facility
|
||||
end
|
||||
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@display_type = nil
|
||||
end
|
||||
end
|
||||
|
||||
path = request.fullpath
|
||||
sale_id = params[:sale_id]
|
||||
|
||||
@trans_flag = true
|
||||
|
||||
if params[:type] == "transaction"
|
||||
@trans_flag = false
|
||||
@cashier_type = "cashier"
|
||||
@@ -248,201 +263,111 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
end
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
@sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount")
|
||||
if path.include? 'credit_payment'
|
||||
@sale_payment = false
|
||||
@amount_due = @sale.sale_payments.where(payment_method: 'creditnote').pluck('SUM(payment_amount)').first
|
||||
payments = @sale.sale_payments.joins(:sale_audit).group_by(&:payment_method).map { |method, payments| [method == 'paypar' ? 'redeem' : method, payments.sum { |payment| payment.payment_amount }] }
|
||||
else
|
||||
@sale_payment = true
|
||||
@amount_due = @sale.grand_total
|
||||
payments = @sale.sale_payments.left_joins(:sale_audit).where(sale_audits: {sale_audit_id: nil}).group_by(&:payment_method).map { |method, payments| [method == 'paypar' ? 'redeem' : method, payments.sum { |payment| payment.payment_amount }] }
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@membership_rebate_balance=0
|
||||
@payment_methods = PaymentMethodSetting.where(is_active: true).pluck(:payment_method)
|
||||
@cash = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'cash' }
|
||||
@credit = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'creditnote' }
|
||||
@other_payments = payments.select { |payment| !['cash', 'creditnote', 'foc'].include? payment[0] }.map { |method, amount| [ @payment_methods.find { |payment_method| payment_method.parameterize == method }, amount ] }
|
||||
@other_payment = @other_payments.sum { |payment| payment[1] }
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
@cash = 0.0
|
||||
@kbz_pay_amount = 0.0
|
||||
@other = 0.0
|
||||
@ppamount = 0.0
|
||||
@visacount= 0.0
|
||||
@jcbcount= 0.0
|
||||
@mastercount = 0.0
|
||||
@unionpaycount = 0.0
|
||||
@alipaycount = 0.0
|
||||
@junctionpaycount = 0.0
|
||||
@credit = 0.0
|
||||
@paymalcount = 0.0
|
||||
@dingacount = 0.0
|
||||
@giftvouchercount = 0.0
|
||||
@sale_data = Sale.find_by_sale_id(sale_id)
|
||||
@balance = 0
|
||||
@accountable_type = ''
|
||||
@table_no = ''
|
||||
@dining = ''
|
||||
@other_payment = 0.0
|
||||
@pdf_view = nil
|
||||
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
|
||||
if !@lookup_pdf.nil?
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
#total customer with individual total amount
|
||||
@individual_total = Array.new
|
||||
if !@sale.equal_persons.nil?
|
||||
per_person_amount = @sale.grand_total / @sale.equal_persons.to_i
|
||||
@individual_total.push({'total_customer' => @sale.equal_persons.to_i, 'per_person_amount' => per_person_amount })
|
||||
end
|
||||
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||
@kbz_pay_amount += amount.to_f
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
if changable_tax[1] == '0'
|
||||
@changable_tax = false
|
||||
end
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
if changable_tax[1] == '0'
|
||||
@changable_tax = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# @shop = shop_detail #show shop info
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
@customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
|
||||
@pdf_view = nil
|
||||
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
|
||||
if !@lookup_pdf.nil?
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
# amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||
# @kbz_pay_amount += amount.to_f
|
||||
|
||||
#total customer with individual total amount
|
||||
@individual_total = Array.new
|
||||
if !saleObj.equal_persons.nil?
|
||||
per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i
|
||||
@individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
|
||||
# rounding adjustment
|
||||
# if @shop.is_rounding_adj
|
||||
# a = saleObj.grand_total % 25 # Modulus
|
||||
# b = saleObj.grand_total / 25 # Division
|
||||
# #not calculate rounding if modulus is 0 and division is even
|
||||
# #calculate rounding if modulus is zero or not zero and division are not even
|
||||
# if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# @rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj)
|
||||
# @sale_data.grand_total = new_total
|
||||
# @sale_data.old_grand_total = saleObj.grand_total
|
||||
# @sale_data.rounding_adjustment = @rounding_adj
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
#end rounding adjustment
|
||||
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
@tax_arr =[]
|
||||
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc.id)
|
||||
# @account_arr.push(account)
|
||||
@tax_arr.push(account.name)
|
||||
end
|
||||
|
||||
sale_taxes = @sale.sale_taxes
|
||||
if !sale_taxes.empty?
|
||||
sale_taxes.each do |sale_tax|
|
||||
@account_arr.push(sale_tax)
|
||||
end
|
||||
end
|
||||
|
||||
# rounding adjustment
|
||||
# if @shop.is_rounding_adj
|
||||
# a = saleObj.grand_total % 25 # Modulus
|
||||
# b = saleObj.grand_total / 25 # Division
|
||||
# #not calculate rounding if modulus is 0 and division is even
|
||||
# #calculate rounding if modulus is zero or not zero and division are not even
|
||||
# if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# @rounding_adj = new_total-saleObj.grand_total
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
#end rounding adjustment
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
|
||||
# rounding adjustment
|
||||
if current_shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
#calculate rounding if modulus is zero or not zero and division are not even
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
@rounding_adj = new_total-saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj)
|
||||
@sale_data.grand_total = new_total
|
||||
@sale_data.old_grand_total = saleObj.grand_total
|
||||
@sale_data.rounding_adjustment = @rounding_adj
|
||||
else
|
||||
@rounding_adj = @sale_data.rounding_adjustment
|
||||
end
|
||||
else
|
||||
@rounding_adj = @sale_data.rounding_adjustment
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc.id)
|
||||
# @account_arr.push(account)
|
||||
@tax_arr.push(account.name)
|
||||
end
|
||||
sale_taxes = SaleTax.where("sale_id = ?", saleObj.sale_id)
|
||||
if !sale_taxes.empty?
|
||||
sale_taxes.each do |sale_tax|
|
||||
@account_arr.push(sale_tax)
|
||||
end
|
||||
end
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
# get member information
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
if response["status"]==true
|
||||
response["account_data"].each do |res|
|
||||
# get member information
|
||||
@balance = 0
|
||||
@accountable_type = ''
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
if response["status"]==true
|
||||
response["account_data"].each do |res|
|
||||
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||
@balance = @balance.to_f + res["balance"].to_f
|
||||
# @accountable_type = res["accountable_type"]
|
||||
@accountable_type = "Rebate Balance"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#end customer amount
|
||||
|
||||
#paymal payment
|
||||
|
||||
@sale_data.bookings.each do |sbk|
|
||||
if sbk.dining_facility_id.to_i >0
|
||||
df = DiningFacility.find(sbk.dining_facility_id)
|
||||
@table_no = df.type + ' ' + df.name
|
||||
@checkin_time = sbk.checkin_at
|
||||
@dining = df
|
||||
break
|
||||
else
|
||||
@table_no = nil
|
||||
@checkin_time = nil
|
||||
@dining = nil
|
||||
end
|
||||
end
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
@sale_payment_data = SalePayment.get_sale_payment_for_credit(@sale_data)
|
||||
else
|
||||
@sale_payment_data = SalePayment.get_sale_payments(@sale_data)
|
||||
end
|
||||
@sale_payment_data.each do |spay|
|
||||
if spay.payment_method == "cash"
|
||||
@cash += spay.payment_amount
|
||||
end
|
||||
if spay.payment_method !="creditnote"
|
||||
@other_payment += spay.payment_amount
|
||||
end
|
||||
|
||||
if spay.payment_method == "mpu"
|
||||
@other += spay.payment_amount
|
||||
elsif spay.payment_method == "paypar"
|
||||
@ppamount += spay.payment_amount
|
||||
elsif spay.payment_method == "visa"
|
||||
@visacount += spay.payment_amount
|
||||
elsif spay.payment_method == "jcb"
|
||||
@jcbcount += spay.payment_amount
|
||||
elsif spay.payment_method == "master"
|
||||
@mastercount += spay.payment_amount
|
||||
elsif spay.payment_method == "unionpay"
|
||||
@unionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "JunctionPay"
|
||||
@junctionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "creditnote"
|
||||
@credit += spay.payment_amount
|
||||
elsif spay.payment_method == "paymal"
|
||||
@paymalcount += spay.payment_amount
|
||||
elsif spay.payment_method == "alipay"
|
||||
@alipaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "dinga"
|
||||
@dingacount += spay.payment_amount
|
||||
elsif spay.payment_method == "giftvoucher"
|
||||
@giftvouchercount += spay.payment_amount
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
#end customer amount
|
||||
end
|
||||
|
||||
def reprint
|
||||
@@ -465,7 +390,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
@@ -496,7 +421,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
#shop_detail = @shop
|
||||
#shop_detail = Shop.current_shop
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
@@ -519,7 +444,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#card_balance amount for Paymal payment
|
||||
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
@@ -531,7 +456,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount, current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||
|
||||
result = {
|
||||
:status => true,
|
||||
@@ -581,7 +506,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
@@ -603,8 +528,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
|
||||
#shop_detail = @shop
|
||||
#shop_detail = Shop.current_shop
|
||||
printer = PrintSetting.all
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
@@ -629,7 +553,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil)
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
@@ -663,8 +587,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
def rounding_adj
|
||||
|
||||
saleObj = Sale.find(params[:sale_id])
|
||||
@shop = current_shop
|
||||
|
||||
if current_shop.is_rounding_adj
|
||||
if @shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
class Origami::VoidController < BaseOrigamiController
|
||||
authorize_resource :class => false
|
||||
authorize_resource :class => false
|
||||
|
||||
def overall_void
|
||||
sale_id = params[:sale_id]
|
||||
remark = params[:remark]
|
||||
order_source = params[:type] #tax profile source
|
||||
access_code = params[:access_code]
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
if sale.discount_type == "member_discount"
|
||||
@@ -41,32 +43,10 @@ class Origami::VoidController < BaseOrigamiController
|
||||
# end
|
||||
# end
|
||||
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_avaliable = true
|
||||
table_count = 0
|
||||
table = sale.bookings[0].dining_facility
|
||||
table.bookings.each do |booking|
|
||||
if booking.booking_status != 'moved'
|
||||
if booking.sale_id
|
||||
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
else
|
||||
table_avaliable = true
|
||||
end
|
||||
else
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
end
|
||||
end
|
||||
if table = sale.booking.dining_facility
|
||||
unless table.current_bookings.exists?
|
||||
table.update_attributes(status: 'available')
|
||||
end
|
||||
|
||||
if table_avaliable && table_count == 0
|
||||
table.status = 'available'
|
||||
table.save
|
||||
end
|
||||
else
|
||||
table = nil
|
||||
end
|
||||
|
||||
# FOr Sale Audit
|
||||
@@ -112,46 +92,49 @@ class Origami::VoidController < BaseOrigamiController
|
||||
# unique_code = 'ReceiptBillStarPdf'
|
||||
# end
|
||||
|
||||
customer= Customer.find(sale.customer_id)
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
printer = PrintSetting.all
|
||||
#shop detail
|
||||
shop_details = Shop.current_shop
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
printer.each do |printer_setting|
|
||||
if printer_setting.unique_code == 'ReceiptBillPdf'
|
||||
unique_code="ReceiptBillPdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
|
||||
unique_code="ReceiptBillA5Pdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
|
||||
unique_code="ReceiptBillStarPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
printer = PrintSetting.all
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
printer.each do |printer_setting|
|
||||
if printer_setting.unique_code == 'ReceiptBillPdf'
|
||||
unique_code="ReceiptBillPdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
|
||||
unique_code="ReceiptBillA5Pdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
|
||||
unique_code="ReceiptBillStarPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
|
||||
#end print
|
||||
|
||||
@@ -1,66 +1,69 @@
|
||||
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"],
|
||||
["Alipay Payment","alipay"],["Card Payment", "paymal"],["Dinga Payment","dinga"],
|
||||
["JunctionPay","junctionpay"],["Redeem Payment","paypar"],["Gift Voucher","giftvoucher"]]
|
||||
# authorize_resource :class => false
|
||||
def index
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@payments = [["All",''], ["Cash","cash"], ["Card", "card"], ["Credit","creditnote"],
|
||||
["FOC","foc"]] + PaymentMethodSetting.pluck(:payment_method).map { |payment_method| [payment_method, payment_method.parameterize] }
|
||||
|
||||
@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)
|
||||
else
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",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)
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
if @shift.present?
|
||||
@shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_data = sh
|
||||
end
|
||||
end
|
||||
# @payment_methods.each do |m|
|
||||
# @payments.push(["#{m} Payment", m.parameterize])
|
||||
# end
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
|
||||
@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)
|
||||
else
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',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,from,to,@payment_type)
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
if @shift.present?
|
||||
@shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_data = sh
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,72 +1,69 @@
|
||||
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
|
||||
from, to = get_date_range_from_params
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
@payment_methods = [["All", ''], ["Cash", "cash"], ["Card", "card"], ["Credit", "creditnote"], ["FOC", "foc"]] + PaymentMethodSetting.pluck(:payment_method).map { |payment_method| [payment_method, payment_method.parameterize] }
|
||||
|
||||
@shift_sale_range = ''
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
@shift_sale_range = ''
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@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 = 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)
|
||||
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)
|
||||
else
|
||||
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
@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)
|
||||
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)
|
||||
else
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
payment_type = params[:payment_type]
|
||||
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)
|
||||
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
if @shift.present?
|
||||
@shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_data = sh
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
if @shift.present?
|
||||
@shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_data = sh
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -26,7 +26,6 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@@ -50,7 +49,6 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
end
|
||||
|
||||
def print_close_receipt
|
||||
|
||||
shift_id = params[:id]
|
||||
@shift = ShiftSale.find_by_id(shift_id)
|
||||
shift_obj = ShiftSale.where('id =?',shift_id)
|
||||
@@ -82,6 +80,7 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
|
||||
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@@ -97,7 +96,7 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
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, current_shops,@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,@payment_methods)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'}
|
||||
|
||||
@@ -4,14 +4,13 @@ class Transactions::ShiftSalesController < ApplicationController
|
||||
before_action :check_user
|
||||
|
||||
def index
|
||||
|
||||
|
||||
filter = params[:filter]
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
|
||||
if filter.nil? && from.nil? && to.nil?
|
||||
@shift_sales = ShiftSale.order("id desc")
|
||||
@shift_sales = ShiftSale.all.order("id desc")
|
||||
@shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20)
|
||||
else
|
||||
shift_sale = ShiftSale.search(filter,from,to)
|
||||
@@ -33,22 +32,20 @@ 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='')
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift).first
|
||||
@payment_methods = PaymentMethodSetting.where(is_active: true).pluck(:payment_method)
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@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
|
||||
format.json { render json: @shift }
|
||||
|
||||
@@ -35,7 +35,10 @@ class Sale < ApplicationRecord
|
||||
scope :completed, -> { where(sale_status: 'completed') }
|
||||
|
||||
scope :receipt_date_between, -> (from, to) { where(receipt_date: from..to) }
|
||||
scope :along_with_sale_payments_except_void_between, -> (from, to) { joins(sanitize_sql_array(["LEFT JOIN sale_payments ON sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND sale_payments.created_at BETWEEN ? and ?", from, to])) }
|
||||
scope :sale_payments_with_audit_except_void_between, -> (from, to) do
|
||||
joins(sanitize_sql_array(["LEFT JOIN sale_payments ON sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND sale_payments.created_at BETWEEN ? and ?", from, to]))
|
||||
.joins("LEFT JOIN sale_audits ON sale_audits.sale_id = sale_payments.sale_id AND SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id")
|
||||
end
|
||||
|
||||
def qty_of(item_instance_code)
|
||||
order_items.select(:order_items_id, :item_instance_code, 'SUM(qty) as qty').where(item_instance_code: item_instance_code).group(:item_instance_code).first
|
||||
@@ -789,65 +792,40 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.daily_sales_list(from,to)
|
||||
sales = select("
|
||||
sales.*,
|
||||
SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount,
|
||||
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
|
||||
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
|
||||
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
|
||||
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
|
||||
SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
|
||||
SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
|
||||
SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
|
||||
SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
|
||||
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
|
||||
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
||||
CASE WHEN SUM(case when sale_payments.payment_method not in('creditnote')
|
||||
then sale_payments.payment_amount else 0 end) < sales.grand_total
|
||||
THEN sales.grand_total - SUM(case when sale_payments.payment_method not in('creditnote')
|
||||
then sale_payments.payment_amount else 0 end)
|
||||
ELSE 0 END as credit_amount,
|
||||
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_between(from, to)
|
||||
.where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
|
||||
.group("sale_id").to_sql
|
||||
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
|
||||
|
||||
sales = select(Sale.column_names)
|
||||
.select("#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method == 'paypar' ? 'redeem' : method}"}.push('').join(', ')}
|
||||
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) -
|
||||
SUM(case when (sale_payments.payment_method not in('creditnote') and sale_audits.sale_audit_id IS NOT NULL) 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")
|
||||
.sale_payments_with_audit_except_void_between(from, to)
|
||||
.where("(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
|
||||
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
|
||||
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as total_sale,
|
||||
IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
|
||||
IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
|
||||
IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount,
|
||||
IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
|
||||
IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj,
|
||||
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21 as tax,
|
||||
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0))-(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21) as net_sale,
|
||||
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) + (IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0)) as gross_sale,
|
||||
CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
||||
SUM(kbzpay_amount) as kbzpay_amount,
|
||||
SUM(mpu_amount) as mpu_amount,
|
||||
SUM(master_amount) as master_amount,
|
||||
SUM(visa_amount) as visa_amount,
|
||||
SUM(jcb_amount) as jcb_amount,
|
||||
SUM(paypar_amount) as paypar_amount,
|
||||
SUM(unionpay_amount) as unionpay_amount,
|
||||
SUM(alipay_amount) as alipay_amount,
|
||||
SUM(paymal_amount) as paymal_amount,
|
||||
SUM(dinga_amount) as dinga_amount,
|
||||
SUM(junctionpay_amount) as junctionpay_amount,
|
||||
SUM(cash_amount) as cash_amount,
|
||||
SUM(credit_amount) as credit_amount,
|
||||
SUM(giftvoucher_amount) as giftvoucher_amount,
|
||||
SUM(foc_amount) as foc_amount
|
||||
FROM (
|
||||
#{sales}
|
||||
) as s
|
||||
GROUP BY DATE(CONVERT_TZ(receipt_date,'+00:00','+06:30'))").to_hash.map(&:symbolize_keys)
|
||||
|
||||
return daily_total
|
||||
end
|
||||
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
|
||||
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as total_sale,
|
||||
IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
|
||||
IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
|
||||
IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount,
|
||||
IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
|
||||
IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj,
|
||||
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21 as tax,
|
||||
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) - (IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21) as net_sale,
|
||||
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) + (IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0)) as gross_sale,
|
||||
CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
||||
#{payment_methods.map { |method| pm = method == 'paypar' ? 'redeem' : method; "SUM(#{pm}) as #{pm}"}.push('').join(', ')}
|
||||
SUM(cash_amount) as cash_amount,
|
||||
SUM(credit_amount) as credit_amount,
|
||||
SUM(foc_amount) as foc_amount
|
||||
FROM (
|
||||
#{sales}
|
||||
) as s
|
||||
GROUP BY DATE(CONVERT_TZ(receipt_date,'+00:00','+06:30'))").to_hash.map(&:symbolize_keys)
|
||||
return daily_total
|
||||
end
|
||||
|
||||
def self.get_by_range_by_saleitems(from,to,status,report_type)
|
||||
query = Sale.select("
|
||||
@@ -1013,6 +991,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
other_charges = self.get_other_charges()
|
||||
end
|
||||
product = self.get_product_sale()
|
||||
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
|
||||
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
|
||||
@@ -1022,7 +1001,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
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)
|
||||
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,
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -1045,7 +1024,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
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)
|
||||
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,
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -1069,7 +1048,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
|
||||
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)
|
||||
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,
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -1100,6 +1079,8 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
|
||||
customer_id = customer_id.to_s
|
||||
customer_id[0] = ""
|
||||
customer_id = customer_id.chomp("]")
|
||||
else
|
||||
customer_id = "''"
|
||||
end
|
||||
|
||||
query = self.get_staff_meal_query()
|
||||
@@ -1116,16 +1097,17 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
|
||||
# other_charges = self.get_other_charges()
|
||||
# end
|
||||
product = self.get_product_sale()
|
||||
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
|
||||
|
||||
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.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)
|
||||
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,
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -1141,14 +1123,14 @@ 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.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)
|
||||
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,
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -1164,7 +1146,7 @@ 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.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
|
||||
@@ -1172,7 +1154,7 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
|
||||
|
||||
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)
|
||||
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,
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -1383,20 +1365,12 @@ 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,from,to,payment_type)
|
||||
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
|
||||
|
||||
payments_total = SalePayment.select("
|
||||
sales.receipt_date as sale_date,
|
||||
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
|
||||
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
|
||||
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
|
||||
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
|
||||
SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
|
||||
SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
|
||||
SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
|
||||
SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount,
|
||||
SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
|
||||
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
|
||||
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
|
||||
#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method == 'paypar' ? 'redeem' : method}"}.join(', ')},
|
||||
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='cash') then
|
||||
sales.amount_changed else 0 end) as total_change_amount,
|
||||
@@ -1424,13 +1398,14 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
|
||||
if shift.present?
|
||||
payments_total = payments_total.where(sales: {shift_sale_id: shift.to_a})
|
||||
sale_payment = sale_payment.merge(Sale.where(sales: {shift_sale_id: shift.to_a}))
|
||||
elsif shift_sale_range.present?
|
||||
payments_total = payments_total.where(sales: {shift_sale_id: shift_sale_range.to_a})
|
||||
sale_payment = sale_payment.merge(Sale.where(sales: {shift_sale_id: shift_sale_range.to_a}))
|
||||
end
|
||||
|
||||
if payment_type.present?
|
||||
sale_payment = sale_payment.where(payment_method: payment_type)
|
||||
if payment_type == 'card'
|
||||
sale_payment = sale_payment.where(sanitize_sql_array(["payment_method IN (?)", SalePayment::CARD]))
|
||||
else
|
||||
sale_payment = sale_payment.where("payment_method = (?)", payment_type)
|
||||
end
|
||||
end
|
||||
|
||||
return payments_total, sale_payment
|
||||
@@ -1502,7 +1477,7 @@ end
|
||||
end
|
||||
|
||||
|
||||
def self.top_bottom_products(current_user,from,to,type,current_shop)
|
||||
def self.top_bottom_products(current_user,from,to,type)
|
||||
query = Sale.joins("JOIN sale_items ON sale_items.sale_id = sales.sale_id")
|
||||
.completed
|
||||
.where("qty > 0 AND price > 0")
|
||||
@@ -1531,7 +1506,7 @@ end
|
||||
end
|
||||
|
||||
|
||||
def self.hourly_sales(current_user,from,to, current_shop)
|
||||
def self.hourly_sales(current_user,from,to)
|
||||
query = Sale.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '#{Time.zone.formatted_offset}'), '%I %p')")
|
||||
.order('receipt_date').completed
|
||||
|
||||
@@ -1551,19 +1526,18 @@ end
|
||||
end
|
||||
|
||||
|
||||
def self.employee_sales(current_user,from,to, current_shop)
|
||||
|
||||
def self.employee_sales(current_user,from,to)
|
||||
shift = if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
ShiftSale.current_open_shift(current_user)
|
||||
ShiftSale.current_open_shift(current_user.id)
|
||||
end
|
||||
|
||||
payments_for_credits = SalePayment.joins(:sale_audit).to_sql
|
||||
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
|
||||
|
||||
|
||||
query = employee_sale(shift, from, to, current_shop)
|
||||
query = employee_sale(shift, from, to)
|
||||
.joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sales.sale_id")
|
||||
.select("SUM(sale_payments.payment_amount) - CASE WHEN sale_payments.payment_method = 'creditnote' THEN IFNULL(SUM(payments_for_credits.payment_amount), 0) ELSE ABS(SUM(CASE WHEN sale_payments.outstanding_amount < 0 THEN sale_payments.outstanding_amount ELSE 0 END)) END AS payment_amount,
|
||||
CASE WHEN sale_payments.payment_method IN ('mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher') THEN 'card'
|
||||
CASE WHEN sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') }) THEN 'card'
|
||||
ELSE sale_payments.payment_method END AS payment_method, employees.name AS e_name")
|
||||
end
|
||||
|
||||
@@ -1590,18 +1564,18 @@ end
|
||||
|
||||
|
||||
def self.total_card_sale(current_user=nil,from=nil,to=nil)
|
||||
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
|
||||
query = Sale.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.where('sales.sale_status = "completed" 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")')
|
||||
.where("sales.sale_status = 'completed' and (sp.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') }))")
|
||||
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.receipt_date_between(from, to)
|
||||
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user)
|
||||
if shift = ShiftSale.current_open_shift(current_user.id)
|
||||
query = query.where("sales.shift_sale_id = ?", shift.id)
|
||||
end
|
||||
end
|
||||
@@ -1610,7 +1584,7 @@ end
|
||||
end
|
||||
|
||||
|
||||
def self.credit_payment(current_user=nil,from=nil,to=nil, current_shop)
|
||||
def self.credit_payment(current_user=nil,from=nil,to=nil)
|
||||
|
||||
payments_for_credits = SalePayment.joins(:sale_audit).to_sql
|
||||
|
||||
@@ -1831,7 +1805,7 @@ end
|
||||
# end
|
||||
|
||||
|
||||
def self.total_order(current_user=nil,from=nil,to=nil, current_shop)
|
||||
def self.total_order(current_user=nil,from=nil,to=nil)
|
||||
|
||||
query = Sale.select("count(distinct sale_orders.order_id) as total_order")
|
||||
.joins(:sale_orders)
|
||||
@@ -2054,7 +2028,7 @@ def unique_tax_profiles(order_source, customer_id)
|
||||
end
|
||||
|
||||
|
||||
def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil, current_shop)
|
||||
def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
|
||||
query = Sale.joins(:cashier)
|
||||
.joins(:sale_payments)
|
||||
@@ -2114,6 +2088,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
|
||||
other_charges = self.get_other_charges()
|
||||
end
|
||||
product = self.get_product_sale()
|
||||
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
|
||||
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
|
||||
@@ -2123,7 +2098,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
|
||||
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)
|
||||
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,
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -2146,7 +2121,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
|
||||
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)
|
||||
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,
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -2170,7 +2145,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
|
||||
|
||||
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)
|
||||
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,
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) 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")
|
||||
@@ -2329,49 +2304,50 @@ def self.get_daily_sale_data(transaction_date)
|
||||
GROUP BY DATE(s.receipt_date)").to_hash
|
||||
end
|
||||
|
||||
def self.get_check_sale_data(transaction_date)
|
||||
sale_receivables_subquery = "SELECT sale_payments.sale_id,
|
||||
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' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as credit_card_sales,
|
||||
CASE WHEN sale_payments.payment_method = 'giftvoucher' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as voucher_sales
|
||||
FROM sale_payments
|
||||
GROUP BY sale_payments.sale_id, sale_payments.payment_method"
|
||||
|
||||
query = Sale.select("
|
||||
sales.receipt_no as check_num,
|
||||
sales.receipt_date as business_date,
|
||||
sales.requested_at as check_open_time,
|
||||
sales.updated_at as check_close_time,
|
||||
(sales.grand_total + sales.total_discount) as gross_sales,
|
||||
sales.total_discount as discount_amt,
|
||||
sales.grand_total as sales,
|
||||
(sales.grand_total/21) as tax_amt,
|
||||
0 as service_charges,
|
||||
(sales.grand_total - (sales.grand_total/21)) as net_sales,
|
||||
receivables.credit_card_sales as credit_card_sales,
|
||||
receivables.voucher_sales as voucher_sales,
|
||||
0 as staff_meal_amt,
|
||||
sales.rounding_adjustment as rounding_amt,
|
||||
CASE WHEN sales.sale_status='waste' THEN sales.total_amount ELSE 0 END as wastage_amt,
|
||||
CASE WHEN sales.sale_status='spoile' THEN sales.total_amount ELSE 0 END as spoilage_amt,
|
||||
0 as sampling_amt,
|
||||
SUM(i.qty) as qty,
|
||||
0 as no_of_pax,
|
||||
0 as no_of_adult,
|
||||
0 as no_of_child,
|
||||
shift_sales.cashier_terminal_id as pos_id,
|
||||
sales.cashier_id as employee_code,
|
||||
employees.name as employee_name,
|
||||
CASE WHEN sales.sale_status='completed' THEN 1 ELSE 0 END is_valid,
|
||||
0 as overing,
|
||||
0 as cancle,
|
||||
CONCAT( employees.name, ' Cash&Go receipt generated and completed.') as remarks")
|
||||
.joins("LEFT JOIN shift_sales ON shift_sales.id = sales.shift_sale_id")
|
||||
.joins("LEFT JOIN sale_items i ON i.sale_id = sales.sale_id")
|
||||
.joins("LEFT JOIN (" + sale_receivables_subquery + ") as receivables ON receivables.sale_id = sales.sale_id")
|
||||
.joins("LEFT JOIN employees ON employees.id = sales.cashier_id")
|
||||
.where("DATE(sales.receipt_date) = ? AND sales.sale_status != ?", transaction_date, :void)
|
||||
.group("sales.receipt_no,sales.sale_status")
|
||||
end
|
||||
def self.get_check_sale_data(transaction_date)
|
||||
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
|
||||
sale_receivables_subquery = "SELECT sale_payments.sale_id,
|
||||
SUM(case when (sale_payments.payment_method IN (#{payment_methods.empty? ? '""' : payment_methods.map{ |pm| "\"#{pm}\"" }.join(', ') })) then (sale_payments.payment_amount) else 0 end) as credit_card_sales,
|
||||
CASE WHEN sale_payments.payment_method = 'giftvoucher' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as voucher_sales
|
||||
FROM sale_payments
|
||||
GROUP BY sale_payments.sale_id, sale_payments.payment_method"
|
||||
|
||||
query = Sale.select("
|
||||
sales.receipt_no as check_num,
|
||||
sales.receipt_date as business_date,
|
||||
sales.requested_at as check_open_time,
|
||||
sales.updated_at as check_close_time,
|
||||
(sales.grand_total + sales.total_discount) as gross_sales,
|
||||
sales.total_discount as discount_amt,
|
||||
sales.grand_total as sales,
|
||||
(sales.grand_total/21) as tax_amt,
|
||||
0 as service_charges,
|
||||
(sales.grand_total - (sales.grand_total/21)) as net_sales,
|
||||
receivables.credit_card_sales as credit_card_sales,
|
||||
receivables.voucher_sales as voucher_sales,
|
||||
0 as staff_meal_amt,
|
||||
sales.rounding_adjustment as rounding_amt,
|
||||
CASE WHEN sales.sale_status='waste' THEN sales.total_amount ELSE 0 END as wastage_amt,
|
||||
CASE WHEN sales.sale_status='spoile' THEN sales.total_amount ELSE 0 END as spoilage_amt,
|
||||
0 as sampling_amt,
|
||||
SUM(i.qty) as qty,
|
||||
0 as no_of_pax,
|
||||
0 as no_of_adult,
|
||||
0 as no_of_child,
|
||||
shift_sales.cashier_terminal_id as pos_id,
|
||||
sales.cashier_id as employee_code,
|
||||
employees.name as employee_name,
|
||||
CASE WHEN sales.sale_status='completed' THEN 1 ELSE 0 END is_valid,
|
||||
0 as overing,
|
||||
0 as cancle,
|
||||
CONCAT( employees.name, ' Cash&Go receipt generated and completed.') as remarks")
|
||||
.joins("LEFT JOIN shift_sales ON shift_sales.id = sales.shift_sale_id")
|
||||
.joins("LEFT JOIN sale_items i ON i.sale_id = sales.sale_id")
|
||||
.joins("LEFT JOIN (" + sale_receivables_subquery + ") as receivables ON receivables.sale_id = sales.sale_id")
|
||||
.joins("LEFT JOIN employees ON employees.id = sales.cashier_id")
|
||||
.where("DATE(sales.receipt_date) = ? AND sales.sale_status != ?", transaction_date, :void)
|
||||
.group("sales.receipt_no,sales.sale_status")
|
||||
end
|
||||
def paymal_payment_void
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
membership_actions_data = MembershipAction.find_by_membership_type("void")
|
||||
|
||||
@@ -132,13 +132,13 @@ class ShiftSale < ApplicationRecord
|
||||
self.commercial_taxes = self.commercial_taxes.to_f - tax.to_f
|
||||
self.total_rounding = self.total_rounding - saleobj.rounding_adjustment
|
||||
self.total_void = self.total_void + saleobj.grand_total
|
||||
|
||||
if saleobj.customer.customer_type == "Dinein"
|
||||
self.dining_count = self.dining_count - 1
|
||||
else
|
||||
self.takeaway_count = self.takeaway_count - 1
|
||||
end
|
||||
|
||||
|
||||
self.save
|
||||
end
|
||||
end
|
||||
|
||||
@@ -82,7 +82,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
end
|
||||
#end card sale trans data
|
||||
#start card blanace amount
|
||||
if !card_balance_amount.nil? && card_balance_amount >0
|
||||
if !card_balance_amount.nil?
|
||||
card_balance_data(card_balance_amount)
|
||||
card_transaction_ref(transaction_ref)
|
||||
end
|
||||
|
||||
@@ -189,9 +189,8 @@
|
||||
<td align="right"><%= @summ_sale.total_receipt %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<% revenue = @summ_sale.total_amount - @summ_sale.total_discount%>
|
||||
<% revenue = @summ_sale.grand_total - @summ_sale.total_discount - @summ_sale.total_tax %>
|
||||
<td><%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : </td>
|
||||
|
||||
<td align="right"><%= number_format( revenue, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -210,33 +209,36 @@
|
||||
<table class="table">
|
||||
<% if !(@total_payment_methods.nil?) %>
|
||||
<% @total_payment_methods.each do |payment| %>
|
||||
|
||||
<% if payment.payment_method != 'card' %>
|
||||
<tr>
|
||||
<% if !@sale_data[0].empty? %>
|
||||
<% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' %>
|
||||
<tr>
|
||||
<% if payment.payment_method == 'paypar' %>
|
||||
<td>Redeem Sale : </td>
|
||||
<% else %>
|
||||
<td><%= payment.payment_method.to_s.capitalize %> Sale : </td>
|
||||
<% end %>
|
||||
<td align="right">
|
||||
<%= number_format(@sale_data.find {|x| x.key?(payment.payment_method) }[payment.payment_method], precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
</td>
|
||||
</tr>
|
||||
<td align="right">
|
||||
<% @sale_data.each do |data| %>
|
||||
<% pay_mth = payment.payment_method %>
|
||||
<%= data[""+pay_mth+""] %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% total_card = @sale_data.find {|x| x.key?("card") } %>
|
||||
<% if !total_card.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.other_payment") %> : </td>
|
||||
<td align="right">
|
||||
|
||||
<%= number_format(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<% total_card = @sale_data.select { |hash| hash["card"]!=nil } %>
|
||||
<% if !total_card.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.other_payment") %> : </td>
|
||||
<td align="right">
|
||||
<% total_other_amt = 0 %>
|
||||
<% @sale_data.map { |k,v| k.map{|meth,amt| meth != 'cash' && meth != 'foc' && meth != 'creditnote' ? total_other_amt += amt : meth }} %>
|
||||
<%= total_other_amt %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
@@ -347,7 +349,8 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if isMobile.to_s.include? "Mobile" %>
|
||||
<% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
|
||||
<% if isMobile.include? "Mobile" %>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 ">
|
||||
<div class="card">
|
||||
@@ -369,6 +372,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
5
app/views/origami/others_payments/create.json.jbuilder
Normal file
5
app/views/origami/others_payments/create.json.jbuilder
Normal file
@@ -0,0 +1,5 @@
|
||||
if(@status)
|
||||
json.status @status
|
||||
else
|
||||
json.status false
|
||||
end
|
||||
@@ -19,7 +19,7 @@
|
||||
<div class="row clearfix"></div>
|
||||
<% end %>
|
||||
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||
<div class="purple others-payment text-center m-l-10 m-b-10 <%= payment_method.payment_method %>" data-type="<%= payment_method.payment_method %>" id="<%= payment_method.payment_method %>" data-url="<%=payment_method.gateway_url%>" data-sale-id="<%= @sale_id%>"><%= payment_method.payment_method %></div>
|
||||
<div class="purple others-payment text-center m-l-10 m-b-10 <%= payment_method.payment_method %>" data-type="<%= payment_method.payment_method.parameterize %>" id="<%= payment_method.payment_method %>" data-url="<%=payment_method.gateway_url%>" data-sale-id="<%= @sale_id%>"><%= payment_method.payment_method %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -45,7 +45,7 @@
|
||||
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
|
||||
if(payment_type) {
|
||||
$(".others-payment").hide();
|
||||
$(payment_type).each(function(i){
|
||||
$(payment_type).each(function(i){
|
||||
$("."+payment_type[i]).show();
|
||||
});
|
||||
}
|
||||
|
||||
279
app/views/origami/others_payments/new.html.erb
Normal file
279
app/views/origami/others_payments/new.html.erb
Normal file
@@ -0,0 +1,279 @@
|
||||
<div class="container-fluid">
|
||||
<div id="loading_wrapper" style="display:none;">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
<!-- <div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
|
||||
<li class="breadcrumb-item"><a href="/origami/sale/<%=@sale_id %>/payment"><%= t("views.btn.payment") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t("views.btn.mpu") %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to t('.back',:default => t("views.btn.back")),'/origami/sale/'+@sale_id+'/payment/others_payment'%>
|
||||
</span>
|
||||
</ol>
|
||||
</div> -->
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<span class="hidden" id="membership_id"><%= @membership_id%></span>
|
||||
<span class="hidden" id="member_discount"><%= @member_discount%></span>
|
||||
<span class="hidden" id="sub-total"><%= @sub_total%></span>
|
||||
<div class="card" style="margin-top:10px;padding:20px;">
|
||||
<div class="card-block">
|
||||
<div class="rebate-form">
|
||||
<% if @bank_integration == '1' %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label for="com_port_name">Select Device</label>
|
||||
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label>You can pay up to </label>
|
||||
<%@can_paid = @can_paid + @rounding_adj%>
|
||||
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @can_paid %>" data-member-value="">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<% if @paid_amount != 0 %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label><%= "Recent #{@payment_method} paid amount" %></label>
|
||||
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@paid_amount %>" data-member-value="">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label>Reference Number</label>
|
||||
<input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
|
||||
<br><span id="reference_no_Err" style="color:red;"></span>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label>Amount</label>
|
||||
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:;">
|
||||
<div class=" m-t-10 p-l-20">
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="4" data-type="num">4</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="8" data-type="num">8</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="." data-type="num">.</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left green" data-type="nett" >Nett</div>
|
||||
<div class="col-md-4 cashier_number red border-left" data-type="del">Del</div>
|
||||
<div class="col-md-4 cashier_number orange border-left" data-type="clr">Clr</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<div class="row bottom m-l-5">
|
||||
<div class="cashier_number long border-left" data-value="1000" data-type="add">1000</div>
|
||||
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
|
||||
</div>
|
||||
<div class="row bottom m-l-5">
|
||||
<div class="cashier_number long border-left" data-value="5000" data-type="add">5000</div>
|
||||
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
|
||||
</div>
|
||||
<div class="row bottom m-l-5">
|
||||
<div class="pay purple left" id="pay">Pay</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-1 col-lg-1 col-sm-1">
|
||||
<button type="button" class="btn bg-default btn-block" id="back"><i class="material-icons m-t--5">reply</i> Back </button>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="sale_id" value="<%= @sale_id %>">
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
$(document).ready(function() {
|
||||
setHeaderBreadCrumb('/ <%= "#{@payment_method} PAYMENT" %>');
|
||||
var sale_id = "<%= @sale_id %>";
|
||||
var bank_integration = "<%= @bank_integration %>";
|
||||
|
||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||
else {
|
||||
$('#validamount').attr("value",parseFloat("<%= @can_paid %>") - parseFloat(localStorage.getItem("cash")));
|
||||
}
|
||||
|
||||
if(bank_integration == '1'){
|
||||
if(typeof code2lab != 'undefined'){
|
||||
code2lab.getCommPorts(); //get comportlists from jade
|
||||
}else{
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: '<%= "#{@payment_method} is not available in here!" %>',
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
var url_param = "payment";
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
url_param = "credit_payment";
|
||||
}
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/"+url_param+"/others_payment";
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.cashier_number', function(event){
|
||||
console.log("click");
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if(event.handled !== true) {
|
||||
var original_value;
|
||||
original_value = $('#amount').text();
|
||||
|
||||
var input_value = $(this).attr("data-value");
|
||||
|
||||
var input_type = $(this).attr("data-type");
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
if (original_value == "0.0"){
|
||||
$('#amount').text(input_value);
|
||||
}else{
|
||||
$('#amount').append(input_value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value) + parseInt(original_value);
|
||||
$('#amount').html(amount);
|
||||
|
||||
break;
|
||||
case 'clr':
|
||||
$('#amount').html("0.0");
|
||||
break;
|
||||
case 'del' :
|
||||
var cash=$('#amount').text() > 0 ? $('#amount').text() : 0;
|
||||
$('#amount').text((cash > 0 && cash.substr(0,cash.length-1) > 0) ? cash.substr(0,cash.length-1) : 0);
|
||||
break;
|
||||
case 'nett':
|
||||
var remain_amount = $('#validamount').val();
|
||||
$('#amount').text(remain_amount);
|
||||
break;
|
||||
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('#pay').on('click',function(){
|
||||
var amount = $('#amount').text();
|
||||
var reference_no = $('#reference_no').val();
|
||||
var sale_id = "<%= @sale_id %>";
|
||||
var receipt_no = "<%= @receipt_no %>";
|
||||
var bank_integration = "<%= @bank_integration %>";
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
$("#reference_no_Err").html("");
|
||||
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
|
||||
$(this).off("click");
|
||||
//start member discount 5% by pay card
|
||||
// var sub_total = $('#sub-total').text();
|
||||
// var member_id = $('#membership_id').text();
|
||||
// var member_discount = $('#member_discount').text();
|
||||
// if (member_id && member_discount) {
|
||||
// $.ajax({
|
||||
// type: "POST",
|
||||
// url: "/origami/" + sale_id + "/member_discount",
|
||||
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
|
||||
// success:function(result){
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//end member discount
|
||||
if(bank_integration == '1'){
|
||||
pay_withBank("SALE", "<%= @payment_method %>", amount, sale_id, receipt_no,cashier_type);
|
||||
}else{
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
var url = "<%= origami_credit_payment_path(method: @payment_method.parameterize) %>";
|
||||
}else{
|
||||
var url = "<%= origami_payment_path(method: @payment_method.parameterize) %>";
|
||||
}
|
||||
$.ajax({type: "POST",
|
||||
url: url,
|
||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||
success:function(result){
|
||||
if(result){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Payment Successfully",
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
var url_param = "payment";
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
url_param = "credit_payment";
|
||||
}
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/"+url_param;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}else{
|
||||
if (amount>0) {
|
||||
swal ( "Oops" , "Paid Amount is over!" , "error" );
|
||||
}else{
|
||||
swal ( "Oops" , "Enter Amount!" , "error" );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#back').on('click',function(){
|
||||
var url_param = "payment";
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
url_param = "credit_payment";
|
||||
}
|
||||
window.location.href = '/origami/sale/'+'<%= @sale_id %>'+'/<%= @cashier_type %>/'+url_param;
|
||||
// window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
|
||||
});
|
||||
</script>
|
||||
@@ -1,32 +1,32 @@
|
||||
<div class="container-fluid" style= "overflow-y: hidden;">
|
||||
<div class="container-fluid m-top-100">
|
||||
<div id="loading_wrapper" style="display:none;">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
|
||||
<div class="card" style="height: 100%">
|
||||
<div class="card">
|
||||
<div class="card-header m-l-5 m-r-5">
|
||||
<div id="order-title">
|
||||
<div class="row p-l-5 p-r-5">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Receipt No :</strong> <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Receipt Date :</strong> <span id="receipt_date"><%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %></span></div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Receipt No :</strong> <span id="receipt_no"><%=@sale.receipt_no rescue ' '%></span></div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Receipt Date :</strong> <span id="receipt_date"><%=@sale.receipt_date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %></span></div>
|
||||
</div>
|
||||
<div class="row p-l-5 p-r-5">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Table No :</strong> <%=@table_no%></div>
|
||||
<span class="hidden" id="dining"><%if !@dining.nil?%><%= @dining.id%><%end%></span>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Sale ID :</strong> <span id="sale_id"><% if @sale_data %><%=@sale_data.sale_id %><% end %></span></div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Sale ID :</strong> <span id="sale_id"><% if @sale %><%=@sale.sale_id %><% end %></span></div>
|
||||
</div>
|
||||
|
||||
<div class="row p-l-5 p-r-5">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<strong>Customer :</strong>
|
||||
<% if @cashier_type == 'quick_service' || @cashier_type == 'food_court' %>
|
||||
<button type="button" class="btn bg-info waves-effect" id='customer_name'><%= @sale_data.customer.name%></button>
|
||||
<button type="button" class="btn bg-info waves-effect" id='customer_name'><%= @sale.customer.name%></button>
|
||||
<% else %>
|
||||
<span id="customer_name"><%= @sale_data.customer.name%></span>
|
||||
<span id="customer_name"><%= @sale.customer.name%></span>
|
||||
<% end %>
|
||||
<span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span>
|
||||
<span class="hidden" id="membership_id"><%= @sale.customer.membership_id%></span>
|
||||
<span class="hidden" id="member_discount"><%= @member_discount%></span></div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Checkin Time : </strong> <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %>
|
||||
<%end%></div>
|
||||
@@ -49,7 +49,7 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="order-detail-slimscroll" data-height="190">
|
||||
<div id="order-detail-slimscroll" data-height="300">
|
||||
<!-- <div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll"> -->
|
||||
<div id="table-details" class="card-text m-t--10" >
|
||||
<table class="table" id="append-table">
|
||||
@@ -57,7 +57,7 @@
|
||||
<% sub_total = 0
|
||||
count = 0
|
||||
%>
|
||||
<% @sale_data.sale_items.each do |sale_item|
|
||||
<% @sale.sale_items.each do |sale_item|
|
||||
count += 1
|
||||
%>
|
||||
|
||||
@@ -77,17 +77,17 @@
|
||||
<div class="card-footer ">
|
||||
<table class="table m-t--10 ">
|
||||
<tfooter>
|
||||
<tr style="border-top-style: none!important">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total</strong></td>
|
||||
<td class="item-attr"><strong><span id="sub-total"><%=number_format(sub_total, precision: precision.to_i)%></span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<%if @sale_data.discount_type == 'member_discount'%>
|
||||
<%if @sale.discount_type == 'member_discount'%>
|
||||
<td class="charges-name"><strong>Member Discount:</strong></td>
|
||||
<%else%>
|
||||
<td class="charges-name"><strong>(Discount)</strong></td>
|
||||
<%end%>
|
||||
<td class="item-attr"><strong><span>(<%= number_format(@sale_data.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>)</span></strong></td>
|
||||
<td class="item-attr"><strong><span>(<%= number_format(@sale.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>)</span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name">
|
||||
@@ -104,23 +104,23 @@
|
||||
<% else %>
|
||||
No Tax
|
||||
<% end %></strong><br>
|
||||
<%if @sale_payment.nil? && @changable_tax %>
|
||||
<%if @sale_payment && @changable_tax %>
|
||||
<% if @current_user.role == 'cashier' %>
|
||||
<button class="btn btn-link waves-effect bg-info access_modal" data-type="change_tax">Change Tax</button>
|
||||
<button class="btn btn-link waves-effect bg-info access_modal" data-type = 'change_tax' >Change Tax</button>
|
||||
<% else %>
|
||||
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
|
||||
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="item-attr"><strong><span id="total_tax"><%= number_format(@sale_data.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
|
||||
<td class="item-attr"><strong><span id="total_tax"><%= number_format(@sale.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong><%= number_format(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></strong></td>
|
||||
<td class="item-attr"><strong><%= number_format(@sale.rounding_adjustment, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total</strong></td>
|
||||
<td class="item-attr"><strong><span><%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
|
||||
<td class="item-attr"><strong><span><%= number_format(@sale.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
|
||||
</tr>
|
||||
<%if @balance > 0%>
|
||||
<tr>
|
||||
@@ -153,25 +153,17 @@
|
||||
</div>
|
||||
|
||||
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5">
|
||||
<div class="card" style="height: 100%">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row m-l-5 m-r-5">
|
||||
<div class="col-md-8"><strong class='amount_balance'>Amount Due <% if !@sale_payment.nil? %>( Credit )<% end %></strong></div>
|
||||
<div class="col-md-8"><strong class='amount_balance'>Amount Due <% if !@sale_payment %>( Credit )<% end %></strong></div>
|
||||
<div class="col-md-4">
|
||||
<strong>
|
||||
<span id="grand_total" class="hidden">
|
||||
<% if @sale_payment.nil? %>
|
||||
<%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
<% else %>
|
||||
<%= number_format(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
<% end %>
|
||||
<%= number_format(@amount_due, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
</span>
|
||||
<span id="amount_due">
|
||||
<% if @sale_payment.nil? %>
|
||||
<%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
|
||||
<% else %>
|
||||
<%= number_format(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
<% end %>
|
||||
<%= number_format(@amount_due, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
</span>
|
||||
</strong>
|
||||
</div>
|
||||
@@ -183,7 +175,7 @@
|
||||
<%= number_format(@cash, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
|
||||
</div>
|
||||
</div>
|
||||
<% if @sale_payment.nil? && @cashier_type != "food_court" %>
|
||||
<% if @sale_payment && @cashier_type != "food_court" %>
|
||||
<div class="row payment credit-color p-l-5 p-r-5" id="credit_payment" >
|
||||
<div class="col-md-8">Credit</div>
|
||||
<div class="col-md-4" id="credit"><%= number_format(@credit, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
@@ -191,155 +183,25 @@
|
||||
<% else %>
|
||||
<div class="col-md-4 hidden" id="credit">0</div>
|
||||
<% end %>
|
||||
<% if @kbz_pay_amount > 0.0 %>
|
||||
<div class="row payment other-payment-color" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments (KBZ Pay)</div>
|
||||
<div class="col-md-4" id="others">
|
||||
<%= number_format(@kbz_pay_amount, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
|
||||
<div class="row payment other-payment-color p-l-5 p-r-5" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments</div>
|
||||
<div class="col-md-4" id="other_payment_amount">
|
||||
<%= number_format(@other_payment, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
|
||||
</div>
|
||||
</div>
|
||||
<% elsif @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 && @giftvouchercount == 0.0 %>
|
||||
<div class="row payment other-payment-color" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments</div>
|
||||
<div class="col-md-4" id="others">
|
||||
<%= number_format(@other, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="row payment other-payment-color" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments</div>
|
||||
<div class="col-md-4" id="other_payment_amount">
|
||||
<%= number_format(@other_payment, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title m-l-5 m-r-5">
|
||||
<!-- mpu -->
|
||||
<div class="row <%= @other!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">MPU</div>
|
||||
<% if @other != 0.0 %>
|
||||
<div class="col-md-4 mpu is_card" id="others"><%= number_format(@other, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="others"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- paypar -->
|
||||
<div class="row <%= @ppamount!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">Redeem</div>
|
||||
<% if @ppamount != 0.0 %>
|
||||
<div class="col-md-4" id="ppamount"><%= number_format(@ppamount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="ppamount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Visa -->
|
||||
<div class="row <%= @visacount!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">VISA</div>
|
||||
<% if @visacount != 0.0 %>
|
||||
<div class="col-md-4 visa is_card" id="visacount"><%= number_format(@visacount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="visacount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- JCB -->
|
||||
<div class="row <%= @jcbcount!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">JCB</div>
|
||||
<% if @jcbcount != 0.0 %>
|
||||
<div class="col-md-4 jcb is_card" id="jcbcount"><%= number_format(@jcbcount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="jcbcount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Master -->
|
||||
<div class="row <%= @mastercount!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">MASTER</div>
|
||||
<% if @mastercount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="mastercount"><%= number_format(@mastercount, precision: precision.to_i) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="mastercount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<!-- <br> -->
|
||||
|
||||
<!-- UNIONPAY -->
|
||||
<div class="row <%= @unionpaycount!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">UNIONPAY</div>
|
||||
<% if @unionpaycount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="unionpaycount"><%= number_format(@unionpaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="unionpaycount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Alipay -->
|
||||
<div class="row <%= @alipaycount!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">Alipay</div>
|
||||
<% if @alipaycount != 0.0 %>
|
||||
<div class="col-md-4 alipay is_card" id="alipaycount"><%= number_format(@alipaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="alipaycount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- PAYMAL -->
|
||||
<div class="row <%= @paymalcount!=0.0 ? 'payment others-color' : 'hidden'%>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">PAYMAL</div>
|
||||
<% if @paymalcount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="paymalcount"><%= number_format(@paymalcount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="paymalcount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<!-- DINGA -->
|
||||
<div class="row <%= @dingacount!=0.0 ? 'payment others-color' : 'hidden'%>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">DINGA</div>
|
||||
<% if @dingacount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="dingacount"><%= number_format(@dingacount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="dingacount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Junction Pay -->
|
||||
<div class="row <%= @junctionpaycount!=0.0 ? 'payment others-color' : 'hidden'%>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">JUNCTION PAY</div>
|
||||
<% if @junctionpaycount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="junctionpaycount"><%= number_format(@junctionpaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="junctionpaycount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Gift Voucher -->
|
||||
<div class="row <%= @giftvouchercount!=0.0 ? 'payment others-color' : 'hidden'%>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">GIFT VOUCHER</div>
|
||||
<% if @giftvouchercount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="giftvouchercount"><%= number_format(@giftvouchercount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="giftvouchercount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
<div class="card-title">
|
||||
<% @other_payments.each do |payment| %>
|
||||
<div class="row payment others-color p-l-5 p-r-5">
|
||||
<div class="col-md-8"><%= payment[0] %></div>
|
||||
<div class="col-md-4 <%= payment[0].parameterize %> is_card"><%= number_format(payment[1], precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="row m-l-5 m-r-5">
|
||||
<div class="col-md-8"><strong class='amount_balance'>Balance</strong></div>
|
||||
<div class="col-md-4"><strong><span id='balance'><%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></span></strong></div>
|
||||
<div class="col-md-4"><strong><span id='balance'><%= number_format(@sale.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></span></strong></div>
|
||||
</div>
|
||||
<!-- <br> -->
|
||||
</div>
|
||||
@@ -404,30 +266,30 @@
|
||||
</button>
|
||||
<!-- -->
|
||||
<% if current_login_employee.role == "cashier" %>
|
||||
<% if @other_payment <= 0 && @sale_payment.nil? %>
|
||||
<%if @sale_data.total_discount == 0 %>
|
||||
<% if @other_payment <= 0 && @sale_payment %>
|
||||
<%if @sale.total_discount == 0 %>
|
||||
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="foc"> FOC</a>
|
||||
<% end %>
|
||||
<%end %>
|
||||
<% if @sale_payment.nil? %>
|
||||
<% if @sale_payment %>
|
||||
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
|
||||
<% if @other_payment <= 0 %>
|
||||
<%if @sale_data.total_discount == 0 %>
|
||||
<%if @sale.total_discount == 0 %>
|
||||
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="waste"> Waste</a>
|
||||
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="spoile"> Spoile</a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @other_payment <= 0 && @sale_payment.nil?%>
|
||||
<%if @sale_data.total_discount == 0 %>
|
||||
<% if @other_payment <= 0 && @sale_payment%>
|
||||
<%if @sale.total_discount == 0 %>
|
||||
<button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button>
|
||||
<%end %>
|
||||
<%end %>
|
||||
<% if @sale_payment.nil? %>
|
||||
<% if @sale_payment %>
|
||||
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
|
||||
<% if @other_payment <= 0 %>
|
||||
<%if @sale_data.total_discount == 0 %>
|
||||
<%if @sale.total_discount == 0 %>
|
||||
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')">Waste</button>
|
||||
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')">Spoile</button>
|
||||
<% end %>
|
||||
@@ -435,7 +297,7 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if (@cashier_type=="quick_service" || @cashier_type=="food_court") && @sale_payment.nil? %>
|
||||
<% if (@cashier_type=="quick_service" || @cashier_type=="food_court") && @sale_payment %>
|
||||
<hr>
|
||||
|
||||
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
|
||||
@@ -709,10 +571,14 @@ var customer_id = "<%= @customer.id %>";
|
||||
var customer_name = "<%= @customer.name %>";
|
||||
var pdf_view = '<%=@pdf_view%>';
|
||||
var trans_flag = <%= @trans_flag %>;
|
||||
var paymalcount = <%= @paymalcount %>;
|
||||
var other_payments = <%= raw @other_payments %>;
|
||||
var payment_methods = <%= raw @payment_methods %>;
|
||||
|
||||
// console.log(pdf_view)
|
||||
$(document).ready(function(){
|
||||
$("#sxModal").hide();
|
||||
|
||||
var paymalcount = other_payments.some(x => x[0] == 'paymal') ? other_payments.find(x => x[0] == 'paymal')[1] : 0.0;
|
||||
if(cashier_type == "food_court" && paymalcount == 0.0){
|
||||
$("#is_paymemberModal").modal({show : true, backdrop : false, keyboard : false});
|
||||
}
|
||||
@@ -726,45 +592,35 @@ $(document).ready(function(){
|
||||
}
|
||||
/* replace url type*/
|
||||
/* start check first bill or not*/
|
||||
var member_id = $('#membership_id').text();
|
||||
var member_discount = $('#member_discount').text();
|
||||
var receipt_no = "";
|
||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||
receipt_no = ($("#receipt_no").html()).trim();
|
||||
}
|
||||
var member_id = $('#membership_id').text();
|
||||
var member_discount = $('#member_discount').text();
|
||||
var receipt_no = "";
|
||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||
receipt_no = ($("#receipt_no").html()).trim();
|
||||
}
|
||||
|
||||
payment_type = '';
|
||||
// if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
|
||||
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
|
||||
|
||||
// if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
|
||||
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
|
||||
// console.log(payment_type)
|
||||
// console.log(parseInt(jQuery.inArray("MPU", payment_type)))
|
||||
if (member_id && member_discount) {
|
||||
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
|
||||
$("#credit_payment").hide();
|
||||
} else{
|
||||
$("#credit_payment").show();
|
||||
}
|
||||
if(parseInt(jQuery.inArray("MPU", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("VISA", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("JCB", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("Master", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("UNIONPAY", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("Redeem", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("PAYMAL", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("Alipay", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("DINGA", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("GiftVoucher", payment_type)) != -1){
|
||||
$("#card_payment").show();
|
||||
} else{
|
||||
$("#card_payment").hide();
|
||||
}
|
||||
}
|
||||
// }
|
||||
/* end check first bill or not*/
|
||||
console.log(payment_type)
|
||||
// console.log(parseInt(jQuery.inArray("MPU", payment_type)))
|
||||
if (member_id && member_discount) {
|
||||
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
|
||||
$("#credit_payment").hide();
|
||||
} else{
|
||||
$("#credit_payment").show();
|
||||
}
|
||||
|
||||
var dining_id = "<%= @sale_data.bookings[0].dining_facility_id %>";
|
||||
if(payment_type && payment_methods.some(x => payment_type.indexOf(x) >= 0)){
|
||||
$("#card_payment").show();
|
||||
} else{
|
||||
$("#card_payment").hide();
|
||||
}
|
||||
}
|
||||
// }
|
||||
/* end check first bill or not*/
|
||||
|
||||
var dining_id = "<%= @sale.bookings[0].dining_facility_id %>";
|
||||
|
||||
$("#back").on('click', function() {
|
||||
localStorage.removeItem('cash');
|
||||
@@ -787,12 +643,10 @@ $(document).ready(function(){
|
||||
window.location.reload();
|
||||
})
|
||||
|
||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){
|
||||
|
||||
}
|
||||
else {
|
||||
if (localStorage.getItem("cash") && localStorage.getItem("cash") != 'null') {
|
||||
$('#cash').text(localStorage.getItem("cash"));
|
||||
}
|
||||
|
||||
update_balance();
|
||||
//checkChangableTax
|
||||
checkChangableTax();
|
||||
@@ -826,126 +680,96 @@ $(document).ready(function(){
|
||||
$('#pay').click(function() {
|
||||
sub_total = $('#sub-total').text();
|
||||
member = $('#membership_id').text();
|
||||
// console.log(member)
|
||||
if (parseInt(jQuery.inArray("MPU", payment_type)) != -1 && $('.mpu').text() == 0 && sub_total != 0.0 && member) {
|
||||
swal("Oops","Please Pay with MPU Payment","warning");
|
||||
}else if(parseInt(jQuery.inArray("Redeem", payment_type)) != -1 && $('#ppamount').text()==0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Redeem Payment","warning");
|
||||
}else if(parseInt(jQuery.inArray("VISA", payment_type)) != -1 && $('#visacount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Visa Payment","warning");
|
||||
|
||||
}else if(parseInt(jQuery.inArray("JCB", payment_type)) != -1 && $('#jcbcount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with jcb Payment","warning");
|
||||
}
|
||||
else if(parseInt(jQuery.inArray("Master", payment_type)) != -1 && $('#mastercount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Master Payment","warning");
|
||||
}
|
||||
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with UNIONPAY Payment","warning");
|
||||
}
|
||||
else if(parseInt(jQuery.inArray("Alipay", payment_type)) != -1 && $('#alipaycount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Alipay Payment","warning");
|
||||
}
|
||||
else if(parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 && $('#junctionpaycount').text()==0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with JUNCTIONPAY Payment","warning");
|
||||
}
|
||||
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Credit Payment","warning");
|
||||
}else if(parseInt(jQuery.inArray("PAYMAL", payment_type)) != -1 && $('#paymalcount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Paymal Payment","warning");
|
||||
}else if(parseInt(jQuery.inArray("DINGA", payment_type)) != -1 && $('#dingacount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Dinga Payment","warning");
|
||||
}else if(parseInt(jQuery.inArray("GiftVoucher", payment_type)) != -1 && $('#giftvouchercount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Gift Voucher","warning");
|
||||
if (payment_type && payment_type.length > 0 && !other_payments.some(x => payment_type.indexOf(x[0]) >= 0 && x[1] > 0) && sub_total != 0.0 && member) {
|
||||
swal("Oops","Please Pay with " + payment_methods.find(x => payment_type.indexOf(x) >= 0) + " Payment","warning");
|
||||
} else {
|
||||
$( "#loading_wrapper").show();
|
||||
if($('#balance').text() > 0){
|
||||
swal ( "Oops", "Insufficient Amount!" , "error" );
|
||||
$("#loading_wrapper").hide();
|
||||
}else{
|
||||
$(this).off("click");
|
||||
var sale_id = $('#sale_id').text();
|
||||
// var item_row = $('.is_card');
|
||||
|
||||
$( "#loading_wrapper").show();
|
||||
if($('#balance').text() > 0){
|
||||
swal ( "Oops", "Insufficient Amount!" , "error" );
|
||||
$("#loading_wrapper").hide();
|
||||
}else{
|
||||
$(this).off("click");
|
||||
var sale_id = $('#sale_id').text();
|
||||
// var item_row = $('.is_card');
|
||||
// payment
|
||||
var cash = $('#cash').text();
|
||||
var credit = $('#credit').text();
|
||||
var card = $('#card').text();
|
||||
var kbz_amt = "<%= @kbz_pay_amount %>";
|
||||
var is_kbz = false;
|
||||
if (kbz_amt > 0) {
|
||||
is_kbz = true
|
||||
}
|
||||
|
||||
// payment
|
||||
var cash = $('#cash').text();
|
||||
var credit = $('#credit').text();
|
||||
var card = $('#card').text();
|
||||
var kbz_amt = "<%= @kbz_pay_amount %>";
|
||||
var is_kbz = false;
|
||||
if (kbz_amt > 0) {
|
||||
is_kbz = true
|
||||
}
|
||||
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
|
||||
if (credit <= 0 && (!location.pathname.includes("credit_payment"))) {
|
||||
calculate_member_discount(sale_id,tax_type);
|
||||
}
|
||||
|
||||
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
|
||||
if (credit <= 0 && (!location.pathname.includes("credit_payment"))) {
|
||||
calculate_member_discount(sale_id,tax_type);
|
||||
}
|
||||
// $("#pdfModal").on('shown.bs.modal', function () {
|
||||
// $('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
|
||||
/* check credit payment or not*/
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
var url = "<%= origami_credit_payment_cash_path %>";
|
||||
}else{
|
||||
var url = "<%= origami_payment_cash_path %>";
|
||||
}
|
||||
|
||||
// $("#pdfModal").on('shown.bs.modal', function () {
|
||||
// $('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
|
||||
/* check credit payment or not*/
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
var url = "<%= origami_credit_payment_cash_path %>";
|
||||
}else{
|
||||
var url = "<%= origami_payment_cash_path %>";
|
||||
}
|
||||
$.ajax({type: "POST",
|
||||
url: url,
|
||||
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz,
|
||||
success:function(result){
|
||||
/* start delete receipt no in first bill*/
|
||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||
var receipt_no = ($("#receipt_no").html()).trim();
|
||||
deleteReceiptNoInFirstBillData(receipt_no);
|
||||
}
|
||||
/* end delete receipt no in first bill*/
|
||||
|
||||
$.ajax({type: "POST",
|
||||
url: url,
|
||||
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz,
|
||||
success:function(result){
|
||||
/* start delete receipt no in first bill*/
|
||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||
var receipt_no = ($("#receipt_no").html()).trim();
|
||||
deleteReceiptNoInFirstBillData(receipt_no);
|
||||
}
|
||||
/* end delete receipt no in first bill*/
|
||||
localStorage.removeItem("cash");
|
||||
if (result.status) {
|
||||
var msg = result.message;
|
||||
}
|
||||
else{
|
||||
var msg = '';
|
||||
}
|
||||
|
||||
localStorage.removeItem("cash");
|
||||
if (result.status) {
|
||||
var msg = result.message;
|
||||
}
|
||||
else{
|
||||
var msg = '';
|
||||
$("#loading_wrapper" ).hide();
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
payment_success_alert();
|
||||
}else{
|
||||
//PDF lightbox data
|
||||
var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6);
|
||||
$("#sale_receipt_no").val(result.receipt_no);
|
||||
$("#filename").val(result.filename);
|
||||
$("#printer_name").val(result.printer_name);
|
||||
$("#receipt_pdf").attr("src", pdfPath);
|
||||
$("#changed_amount").text("");
|
||||
if($('#balance').text() < 0){
|
||||
<% if precision.to_i > 0 %>
|
||||
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)).toFixed(<%= precision %>));
|
||||
<% else %>
|
||||
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)));
|
||||
<% end %>
|
||||
}
|
||||
|
||||
$("#loading_wrapper" ).hide();
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
payment_success_alert();
|
||||
if (pdf_view == 1) {
|
||||
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
|
||||
$("#pdfModalLabel").text("Sale Completed");
|
||||
}else{
|
||||
//PDF lightbox data
|
||||
var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6);
|
||||
$("#sale_receipt_no").val(result.receipt_no);
|
||||
$("#filename").val(result.filename);
|
||||
$("#printer_name").val(result.printer_name);
|
||||
$("#receipt_pdf").attr("src", pdfPath);
|
||||
$("#changed_amount").text("");
|
||||
if($('#balance').text() < 0){
|
||||
<% if precision.to_i > 0 %>
|
||||
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)).toFixed(<%= precision %>));
|
||||
<% else %>
|
||||
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)));
|
||||
<% end %>
|
||||
}
|
||||
|
||||
if (pdf_view == 1) {
|
||||
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
|
||||
$("#pdfModalLabel").text("Sale Completed");
|
||||
}else{
|
||||
//PDF lightbox data
|
||||
print_receipt();
|
||||
}
|
||||
print_receipt();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
var second_display_lookup = $("#display_type").val();
|
||||
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
|
||||
customer_display_view(null,"reload");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
var second_display_lookup = $("#display_type").val();
|
||||
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
|
||||
customer_display_view(null,"reload");
|
||||
}
|
||||
});
|
||||
|
||||
function customer_display_view(data,status) {
|
||||
@@ -1098,18 +922,8 @@ $(document).ready(function(){
|
||||
break;
|
||||
case 'nett':
|
||||
var credit1 = $('#credit').text();
|
||||
var card1 = $('#others').text();
|
||||
var paypar1 = $('#ppamount').text();
|
||||
var visa1 = $('#visacount').text();
|
||||
var jcb1 = $('#jcbcount').text();
|
||||
var master1 = $('#mastercount').text();
|
||||
var unionpay1 = $('#unionpaycount').text();
|
||||
var paymal1 = $('#paymalcount').text();
|
||||
var alipay1 = $('#alipaycount').text();
|
||||
var junctionpay1 = $('#junctionpaycount').text();
|
||||
var dingapay1 = $('#dingacount').text();
|
||||
var giftvoucherpay1 = $('#giftvouchercount').text();
|
||||
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1) + parseFloat(alipay1) + parseFloat(junctionpay1) + parseFloat(paymal1) + parseFloat(dingapay1) + parseFloat(giftvoucherpay1);
|
||||
var others = other_payments.map(x => x[1]).reduce((acc, v) => acc + v, 0);
|
||||
var othertotal = parseFloat(credit1) + parseFloat(others);
|
||||
var total = $('#amount_due').text();
|
||||
var amt = 0;
|
||||
<% if precision.to_i > 0 %>;
|
||||
@@ -1131,19 +945,10 @@ $(document).ready(function(){
|
||||
function update_balance(){
|
||||
var cash = $('#cash').text();
|
||||
var credit = $('#credit').text();
|
||||
var card = $('#others').text();
|
||||
var paypar = $('#ppamount').text();
|
||||
var visa = $('#visacount').text();
|
||||
var jcb = $('#jcbcount').text();
|
||||
var master = $('#mastercount').text();
|
||||
var unionpay = $('#unionpaycount').text();
|
||||
var paymal = $('#paymalcount').text();
|
||||
var alipay = $('#alipaycount').text();
|
||||
var junctionpay = $('#junctionpaycount').text();
|
||||
var dinga = $('#dingacount').text();
|
||||
var giftvoucher = $('#giftvouchercount').text();
|
||||
var others = other_payments.map(x => x[1]).reduce((acc, v) => acc + v, 0);
|
||||
|
||||
var amount_due = $('#amount_due').text();
|
||||
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay) + parseFloat(alipay) + parseFloat(junctionpay) + parseFloat(paymal) + parseFloat(dinga) + parseFloat(giftvoucher);
|
||||
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(others);
|
||||
|
||||
var result = parseFloat(amount_due) - parseFloat(total);
|
||||
|
||||
@@ -1253,7 +1058,6 @@ $(document).ready(function(){
|
||||
title: "Payment Successful!",
|
||||
text: text,
|
||||
html: true,
|
||||
type: 'success',
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
@@ -1310,6 +1114,7 @@ $(document).ready(function(){
|
||||
$("#sxModal").show();
|
||||
setTimeout(function(){
|
||||
getCardNo();
|
||||
$("#sxModal").hide();
|
||||
customer_mamber_card_no = $("#paypar_account_no").val();
|
||||
|
||||
if(sale_id != 0 && customer_mamber_card_no != 0){
|
||||
@@ -1346,7 +1151,6 @@ $(document).ready(function(){
|
||||
function setCardNo(cardNo){
|
||||
if(cardNo.length == 16){
|
||||
$("#paypar_account_no").val(cardNo);
|
||||
$("#sxModal").hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1477,7 +1281,7 @@ $(document).ready(function(){
|
||||
$('#AccessCodeModal').modal('hide');
|
||||
$('#focModal').modal('show');
|
||||
// overall_foc();
|
||||
}else if(type == "change_tax"){
|
||||
}else if(type == 'change_tax'){
|
||||
$('#AccessCodeModal').modal('hide');
|
||||
$('#change_taxModal').modal('show');
|
||||
}
|
||||
@@ -1715,6 +1519,7 @@ $(document).ready(function(){
|
||||
$("#sxModal").show();
|
||||
setTimeout(function(){
|
||||
getCardNo();
|
||||
$("#sxModal").hide();
|
||||
customer_mamber_card_no = $("#paypar_account_no").val();
|
||||
if (customer_mamber_card_no == 0) {
|
||||
customer_mamber_card_no = $("#membership_id").text() || 0;
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
<% breadcrumb_add t("views.right_panel.detail.daily_sale_report"), "", dashboard_path %>
|
||||
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.daily_sale_report") %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to 'Back', dashboard_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12 col-sm-12 ">
|
||||
<%= render :partial=>'shift_sale_report_filter',
|
||||
@@ -19,99 +27,25 @@
|
||||
<th colspan="<%= column_count = @payment_methods.length + 12 %>"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
|
||||
</tr>
|
||||
<% @count = 1 %>
|
||||
<% @payment_methods.each_slice(10) do |slice| %>
|
||||
<!-- <tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<% alph = "A" %>
|
||||
|
||||
<% slice.each do |payment_method| %>
|
||||
<th style="text-align:center;">
|
||||
<%= alph %>
|
||||
</th>
|
||||
<% alph = alph.ord.next.chr %>
|
||||
<% @count += 1 %>
|
||||
<% end %>
|
||||
<th style="text-align:center;" ><%= alph %></th>
|
||||
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
||||
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
||||
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
||||
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
||||
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
||||
</tr> -->
|
||||
<!-- <tr>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
|
||||
<% slice.each do |payment_method| %>
|
||||
<th style="text-align:center;">
|
||||
<%= payment_method %>
|
||||
</th>
|
||||
<% end %>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.foc_sales") %></th>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
||||
<% end %>
|
||||
<th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th>
|
||||
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> -->
|
||||
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %></th>
|
||||
</tr> -->
|
||||
<% end %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th colspan="<%= @count + 1 %>" style='text-align:center;'>Income</th>
|
||||
<th colspan=4 style='text-align:center;'>Outgoing</th>
|
||||
<th style='text-align:center;' data-toggle="tooltip" data-placement="top" title="Gross Sales = (Income+Discount) - (FOC+Void)"><i class="material-icons md-18">live_help</i></th>
|
||||
<th style='text-align:center;' data-toggle="tooltip" data-placement="top" title="Total Sales = Gross Sales - Discount"><i class="material-icons md-18">live_help</i></th>
|
||||
<th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Gross Sales = (Income+Discount) - Void"><i class="material-icons md-18">live_help</i></th>
|
||||
<th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Total Sales = Gross Sales - Discount"><i class="material-icons md-18">live_help</i></th>
|
||||
<% if @tax.blank? %>
|
||||
<th style='text-align:center;' data-toggle="tooltip" data-placement="top" title="Tax = Total Sales / 21"><i class="material-icons md-18">live_help</i></th>
|
||||
<th style='text-align:center;' data-toggle="tooltip" data-placement="top" title="Net Sales = Total Sales - Tax"><i class="material-icons md-18">live_help</i></th>
|
||||
<th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Tax = Total Sales / 21"><i class="material-icons md-18">live_help</i></th>
|
||||
<th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Net Sales = Total Sales - Tax"><i class="material-icons md-18">live_help</i></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
|
||||
<th style='text-align:center;'><%= t("views.righ_panel.detail.date") %></th>
|
||||
<% @payment_methods.each do |method| %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.#{method}") %></th>
|
||||
<% end %>
|
||||
|
||||
<% if @payment_methods.include? ("MPU") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.mpu_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Master") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.master_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("VISA") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.visa_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JCB") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.jcb_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("UNIONPAY") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.unionpay_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("KBZPay") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.kbzpay_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Alipay") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.alipay_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("PAYMAL") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.paymal_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("DINGA") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.dinga_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JunctionPay") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.junctionpay_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Redeem") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.redeem_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
||||
<% end %>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
|
||||
@@ -132,22 +66,10 @@
|
||||
<% unless @sale_data.blank? %>
|
||||
<tbody>
|
||||
<% void = 0 %>
|
||||
<% mpu = 0 %>
|
||||
<% master = 0 %>
|
||||
<% visa = 0 %>
|
||||
<% jcb = 0 %>
|
||||
<% unionpay = 0 %>
|
||||
<% alipay = 0 %>
|
||||
<% paymal = 0 %>
|
||||
<% dinga = 0 %>
|
||||
<% junctionpay = 0 %>
|
||||
<% giftvoucher = 0 %>
|
||||
<% paypar = 0 %>
|
||||
<% cash = 0 %>
|
||||
<% credit = 0 %>
|
||||
<% foc = 0 %>
|
||||
<% discount = 0 %>
|
||||
<% kbzpay = 0 %>
|
||||
<% total = 0 %>
|
||||
<% grand_total = 0 %>
|
||||
<% old_grand_total = 0 %>
|
||||
@@ -156,24 +78,13 @@
|
||||
<% tax = 0 %>
|
||||
<% net_sale = 0 %>
|
||||
<% count = 1 %> <% rounding_adj = 0 %>
|
||||
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% void += sale[:void_amount] %>
|
||||
<% mpu += sale[:mpu_amount] %>
|
||||
<% master += sale[:master_amount] %>
|
||||
<% visa += sale[:visa_amount] %>
|
||||
<% jcb += sale[:jcb_amount] %>
|
||||
<% unionpay += sale[:unionpay_amount] %>
|
||||
<% alipay += sale[:alipay_amount] %>
|
||||
<% paymal += sale[:paymal_amount] %>
|
||||
<% dinga += sale[:dinga_amount] %>
|
||||
<% junctionpay += sale[:junctionpay_amount] %>
|
||||
<% giftvoucher += sale[:giftvoucher_amount] %>
|
||||
<% paypar += sale[:paypar_amount] %>
|
||||
<% cash += sale[:cash_amount]-sale[:total_change_amount] %>
|
||||
<% credit += sale[:credit_amount] %>
|
||||
<% foc += sale[:foc_amount] %>
|
||||
<% discount += sale[:total_discount] %>
|
||||
<% kbzpay += sale[:kbzpay_amount] %>
|
||||
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
|
||||
<% grand_total += sale[:grand_total].to_f %>
|
||||
<% old_grand_total += sale[:old_grand_total].to_f %>
|
||||
@@ -185,41 +96,8 @@
|
||||
<tr>
|
||||
<td style='text-align:right;'><%= count %></td>
|
||||
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
||||
<% if @payment_methods.include? ("MPU") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:mpu_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Master") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:master_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("VISA") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:visa_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JCB") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:jcb_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("UNIONPAY") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:unionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Alipay") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:alipay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("KBZPay") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("PAYMAL") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:paymal_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("DINGA") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:dinga_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JunctionPay") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:junctionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Redeem") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:paypar_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<td style='text-align:right;'><%= number_format(sale[:giftvoucher_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% @payment_methods.each do |method| %>
|
||||
<td style='text-align:right;'><%= number_format(sale[method.parameterize.to_sym], precision:precision.to_i, delimiter: delimiter) rescue 0 %></td>
|
||||
<% end %>
|
||||
<td style='text-align:right;'><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
@@ -228,7 +106,7 @@
|
||||
|
||||
<td style='text-align:right;'>(<%= number_format(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td>
|
||||
<!-- <td style='text-align:right;'><%= number_format(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> -->
|
||||
<td style='text-align:right;'><%= number_format(sale[:rounding_adj].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(sale[:rounding_adj], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(sale[:gross_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(sale[:total_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% if @tax.blank? %>
|
||||
@@ -242,75 +120,9 @@
|
||||
<% colspan = 7 %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="2" style='text-align:center;'>Total</td>
|
||||
<% if @payment_methods.include? ("MPU") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(mpu , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end%>
|
||||
<% if @payment_methods.include? ("Master") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(master, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end%>
|
||||
<% if @payment_methods.include? ("VISA") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(visa, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end%>
|
||||
<% if @payment_methods.include? ("JCB") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(jcb, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end%>
|
||||
<% if @payment_methods.include? ("UNIONPAY") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(unionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Alipay") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(alipay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("KBZPay") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(kbzpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("PAYMAL") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(paymal, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("DINGA") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(dinga, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JunctionPay") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(junctionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Redeem") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(paypar, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_format(giftvoucher, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% @payment_methods.each do |method| %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_format(@sale_data.inject(0.0.to_d) { |sum, sale| sum + sale[method.parameterize.to_sym] }, precision:precision.to_i,delimiter:delimiter) rescue 0 %></td>
|
||||
<% end %>
|
||||
<td style='text-align:right;'><%= number_format(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
|
||||
@@ -27,41 +27,8 @@
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
|
||||
|
||||
<% if @payment_methods.include? ("MPU") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.mpu_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Master") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.master_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("VISA") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.visa_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JCB") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.jcb_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("UNIONPAY") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.unionpay_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("KBZPay") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.kbzpay_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Alipay") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.alipay_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("PAYMAL") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.paymal_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("DINGA") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.dinga_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JunctionPay") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.junctionpay_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Redeem") %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.redeem_sales") %></th>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
||||
<% @payment_methods.each do |method| %>
|
||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.#{method}") %></th>
|
||||
<% end %>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>
|
||||
@@ -108,22 +75,10 @@
|
||||
<% count = 1 %> <% rounding_adj = 0 %>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% void += sale[:void_amount] %>
|
||||
<% mpu += sale[:mpu_amount] %>
|
||||
<% master += sale[:master_amount] %>
|
||||
<% visa += sale[:visa_amount] %>
|
||||
<% jcb += sale[:jcb_amount] %>
|
||||
<% unionpay += sale[:unionpay_amount] %>
|
||||
<% alipay += sale[:alipay_amount] %>
|
||||
<% paymal += sale[:paymal_amount] %>
|
||||
<% dinga += sale[:dinga_amount] %>
|
||||
<% junctionpay += sale[:junctionpay_amount] %>
|
||||
<% giftvoucher += sale[:giftvoucher_amount] %>
|
||||
<% paypar += sale[:paypar_amount] %>
|
||||
<% cash += sale[:cash_amount]-sale[:total_change_amount] %>
|
||||
<% credit += sale[:credit_amount] %>
|
||||
<% foc += sale[:foc_amount] %>
|
||||
<% discount += sale[:total_discount] %>
|
||||
<% kbzpay += sale[:kbzpay_amount] %>
|
||||
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
|
||||
<% grand_total += sale[:grand_total].to_f %>
|
||||
<% old_grand_total += sale[:old_grand_total].to_f %>
|
||||
@@ -135,41 +90,8 @@
|
||||
<tr>
|
||||
<td style='text-align:right;'><%= count %></td>
|
||||
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
||||
<% if @payment_methods.include? ("MPU") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:mpu_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Master") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:master_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("VISA") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:visa_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JCB") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:jcb_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("UNIONPAY") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:unionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Alipay") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:alipay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("KBZPay") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("PAYMAL") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:paymal_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("DINGA") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:dinga_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JunctionPay") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:junctionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Redeem") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:paypar_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<td style='text-align:right;'><%= number_format(sale[:giftvoucher_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% @payment_methods.each do |method| %>
|
||||
<td style='text-align:right;'><%= number_format(sale[method.parameterize.to_sym], precision:precision.to_i, delimiter: delimiter) rescue 0 %></td>
|
||||
<% end %>
|
||||
<td style='text-align:right;'><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
@@ -192,75 +114,9 @@
|
||||
<% colspan = 7 %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="2" style='text-align:center;'>Total</td>
|
||||
<% if @payment_methods.include? ("MPU") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(mpu , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end%>
|
||||
<% if @payment_methods.include? ("Master") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(master, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end%>
|
||||
<% if @payment_methods.include? ("VISA") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(visa, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end%>
|
||||
<% if @payment_methods.include? ("JCB") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(jcb, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end%>
|
||||
<% if @payment_methods.include? ("UNIONPAY") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(unionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Alipay") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(alipay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("KBZPay") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(kbzpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("PAYMAL") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(paymal, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("DINGA") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(dinga, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JunctionPay") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(junctionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Redeem") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(paypar, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_format(giftvoucher, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% @payment_methods.each do |method| %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_format(@sale_data.inject(0.0.to_d) { |sum, sale| sum + sale[method.parameterize.to_sym] }, precision:precision.to_i,delimiter:delimiter) rescue 0 %></td>
|
||||
<% end %>
|
||||
<td style='text-align:right;'><%= number_format(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
@@ -293,12 +149,12 @@
|
||||
<% net = net - total_tax %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
||||
<td colspan="5" style='text-align:right;'><%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td colspan="2" style='text-align:right;'><%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<% else %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
||||
<td colspan="5" style='text-align:right;'><%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td colspan="2" style='text-align:right;'><%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
<% breadcrumb_add 'Payment Method Report', "", dashboard_path %>
|
||||
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item active">Payment Method Report</li>
|
||||
<span class="float-right">
|
||||
<%= link_to 'Back', dashboard_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
@@ -33,42 +40,25 @@
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.mpu_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.master_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.visa_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.jcb_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.unionpay_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.alipay_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.kbzpay_sales") %></th>
|
||||
<!-- <th><%= t("views.right_panel.detail.paymal_sales") %></th> -->
|
||||
<th><%= t("views.right_panel.detail.dinga_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.junctionpay_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.redeem_sales") %></th>
|
||||
<% @payment_methods.each do |method| %>
|
||||
<th><%= t("views.right_panel.detail.#{method} Sales") %></th>
|
||||
<% end %>
|
||||
<th><%= t("views.right_panel.detail.cash_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.credit_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.foc_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% unless @sale_data.empty? %>
|
||||
<tbody>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<tr>
|
||||
<td><%= number_format(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<!-- <td><%= number_format(sale[:paymal_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> -->
|
||||
<td><%= number_format(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<% @payment_methods.each do |method| %>
|
||||
<td><%= number_format(sale[method.parameterize.to_sym] , precision: precision.to_i ,delimiter: delimiter) rescue 0 %></td>
|
||||
<% end %>
|
||||
<td><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<!-- <td><%= number_format(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> -->
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -27,42 +27,24 @@
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.mpu_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.master_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.visa_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.jcb_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.unionpay_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.alipay_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.kbzpay_sales") %></th>
|
||||
<!-- <th><%= t("views.right_panel.detail.paymal_sales") %></th> -->
|
||||
<th><%= t("views.right_panel.detail.dinga_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.junctionpay_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.redeem_sales") %></th>
|
||||
<% @payment_methods.each do |method| %>
|
||||
<th><%= t("views.right_panel.detail.#{method} Sales") %></th>
|
||||
<% end %>
|
||||
<th><%= t("views.right_panel.detail.cash_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.credit_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.foc_sales") %></th>
|
||||
<th><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% unless @sale_data.empty? %>
|
||||
<tbody>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<tr>
|
||||
<td><%= number_format(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<!-- <td><%= number_format(sale[:paymal_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> -->
|
||||
<td><%= number_format(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<% @payment_methods.each do |method| %>
|
||||
<td><%= number_format(sale[method.parameterize.to_sym] , precision: precision.to_i ,delimiter: delimiter) rescue 0 %></td>
|
||||
<% end %>
|
||||
<td><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -18,17 +18,14 @@
|
||||
<option value="9">Last year</option>
|
||||
</select>
|
||||
</div>
|
||||
<% if defined? payments %>
|
||||
<% if defined? @payment_methods %>
|
||||
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 mbl-style">
|
||||
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.select_payments") %></label>
|
||||
|
||||
<select name="payment_type" id="payment_type" class="form-control">
|
||||
<% @payments.each do |pm| %>
|
||||
<option class="<%=pm[1].downcase%>" value="<%=pm[1].downcase%>"><%=pm[0]%></option>
|
||||
<%end %>
|
||||
<% @payment_method.each do |pm| %>
|
||||
<option value="<%=pm.payment_method%>" class="<%=pm.payment_method%>" > <%=pm.payment_method%></option>
|
||||
<% @payment_methods.each do |pm| %>
|
||||
<option value="<%=pm[1].downcase%>"><%=pm[0]%></option>
|
||||
<%end %>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
<div class="container-fluid">
|
||||
<% breadcrumb_add t("views.right_panel.detail.waste_spoilage_report"), "", dashboard_path %>
|
||||
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.waste_spoilage_report") %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to 'Back', dashboard_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= render :partial=>'shift_sale_report_filter',
|
||||
@@ -48,7 +55,7 @@
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% if !sale.item_instance_code.nil?%>
|
||||
<% waste_and_spoil_item_count += sale.qty.to_i %>
|
||||
<% grand_total += sale.grand_total.to_i %>
|
||||
<% grand_total += sale.price.to_i %>
|
||||
<% end %>
|
||||
<tr>
|
||||
<% if !menu_cat_arr.include?(sale.name) %>
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
<% breadcrumb_add t('shiftsale'), transactions_shift_sales_path, transactions_shift_sales_path, t('details') %>
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item"><a href="<%= transactions_shift_sales_path %>"><%= t :shiftsale %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t :details %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to 'Back', transactions_shift_sales_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="main-box-body clearfix p-l-5 p-r-5">
|
||||
@@ -31,7 +40,7 @@
|
||||
<th><%= @shift.total_receipt %></th>
|
||||
<th><%= @shift.dining_count %></th>
|
||||
<th><%= @shift.takeaway_count %></th>
|
||||
<th>(<%= @shift.total_void.round(2) %>)</th>
|
||||
<th>(<%= @shift.total_void %>)</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@@ -39,31 +48,31 @@
|
||||
<table width="100%">
|
||||
<% @total_amount_by_account.each do |amount| %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<td style="text-align: right;"> Total <%= amount.account_name %> Amount</td>
|
||||
<td><%= amount.total_price.round(2) %></td>
|
||||
<td><%= amount.total_price %></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Net Sales</th>
|
||||
<th><%=@shift.nett_sales %></th>
|
||||
</tr>
|
||||
|
||||
<% @total_discount_by_account.each do |amount| %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<td style="text-align: right;"> Total <%= amount.account_name %> Discount</td>
|
||||
<td><%= amount.total_price.round(2) %></td>
|
||||
<td><%= amount.total_price %></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
|
||||
<% if !@total_member_discount[0].member_discount.nil?
|
||||
@member_discount = @total_member_discount[0].member_discount rescue 0.0
|
||||
@member_discount = @total_member_discount[0].member_discount rescue 0.0
|
||||
@overall = @shift.total_discounts - @member_discount
|
||||
%>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Total Member Discount</th>
|
||||
<th><%= @member_discount %></th>
|
||||
</tr>
|
||||
@@ -71,109 +80,82 @@
|
||||
|
||||
<%end%>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Total Overall Discount</th>
|
||||
<th><%= @overall %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Total Discount</th>
|
||||
<th><%= @shift.total_discounts %></th>
|
||||
</tr>
|
||||
|
||||
<% @sale_taxes.each do |tax| %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<td style="text-align: right;"> <%= tax.tax_name %> </td>
|
||||
<td><%= tax.st_amount.round(2) %></td>
|
||||
<td><%= tax.st_amount %></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Total Tax </th>
|
||||
<th><%=@shift.total_taxes %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Rounding Adj </th>
|
||||
<th><%= @shift.total_rounding.round(2) %></th>
|
||||
<th><%= @shift.total_rounding %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Grand Total </th>
|
||||
<th><%= @shift.grand_total.round(2) %></th>
|
||||
<th><%= @shift.grand_total %></th>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td colspan="6">
|
||||
<table width="100%">
|
||||
<% total_other_amount = 0 %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;">Cash Payment </th>
|
||||
<th><%=@shift.cash_sales %></th>
|
||||
<th><%= @shift.cash_sales %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;">Credit Payment </th>
|
||||
<th><%=@shift.credit_sales %></th>
|
||||
<th><%= @shift.credit_sales %></th>
|
||||
</tr>
|
||||
<% @total_amount = 0
|
||||
|
||||
@other_payment.each do |other| %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;">Other Payment Detail </th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">MPU Payment </td>
|
||||
<td><%=other.mpu_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">VISA Payment </td>
|
||||
<td><%=other.visa_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.visa_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">Master Payment </td>
|
||||
<td><%=other.master_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">JCB Payment </td>
|
||||
<td><%=other.jcb_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.master_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">Reedem Payment </td>
|
||||
<td><%=other.paypar_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<% @payment_methods.each do |method| %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;"><%= method %> Payment</td>
|
||||
<td><%= @other_payment[method.parameterize.to_sym] || 0.0 %></td>
|
||||
<% total_other_amount = total_other_amount + (@other_payment[method.parameterize.to_sym] || 0.0) %>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;"><strong>FOC </strong></td>
|
||||
<td><%=other.foc_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.foc_amount rescue 0.0 %>
|
||||
<td><%= @other_payment.foc_amount rescue 0.0 %></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;">Total Other Payment </th>
|
||||
<th><%=@shift.other_sales %></th>
|
||||
<th><%= total_other_amount %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;">Total Payment </th>
|
||||
<th><%= @total_amount+@shift.cash_sales+@shift.credit_sales %></th>
|
||||
<th><%= total_other_amount + @other_payment.foc_amount + @shift.cash_sales + @shift.credit_sales %></th>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user