update shift only if sales completed
This commit is contained in:
@@ -8,11 +8,11 @@ class Foodcourt::PaymalController < BaseFoodcourtController
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
status, @sale,@membership_data = sale_payment.process_payment(saleObj, current_user, cash, "paymal",account_no)
|
||||
status, @sale, @membership_data = sale_payment.process_payment(saleObj, current_user, cash, "paymal",account_no)
|
||||
if status == true && @membership_data["status"] == true
|
||||
@out = true, "Success!"
|
||||
else
|
||||
@out =false, @membership_data["message"]
|
||||
@out = false, @membership_data["message"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,16 +17,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||
#shop_detail = Shop.first
|
||||
# rounding adjustment
|
||||
if !path.include? ("credit_payment")
|
||||
if current_shop.is_rounding_adj
|
||||
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) if rounding_adj > 0
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
|
||||
if is_kbz == 'false'
|
||||
Rails.logger.info '################ CASH PAYMENT #################'
|
||||
@@ -36,8 +27,6 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user)
|
||||
end
|
||||
|
||||
# end
|
||||
|
||||
if !path.include? ("credit_payment")
|
||||
rebate_amount = nil
|
||||
# For Cashier by Zone
|
||||
@@ -155,7 +144,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
@cash_exist = PaymentMethodSetting.cash_exist
|
||||
@credit_exist = PaymentMethodSetting.credit_exist
|
||||
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
|
||||
|
||||
@@ -6,6 +6,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
|
||||
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)
|
||||
# update count for shift sale
|
||||
@@ -55,21 +56,11 @@ class Foodcourt::VoidController < BaseFoodcourtController
|
||||
Rails.logger.debug membership_response.to_json
|
||||
end
|
||||
|
||||
|
||||
# For Print
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
current_balance = nil
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
if bookings[0].dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
end
|
||||
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
|
||||
@@ -34,15 +34,6 @@ class Origami::VoidController < BaseOrigamiController
|
||||
sale.sale_status = 'void'
|
||||
sale.save
|
||||
|
||||
# No Need
|
||||
# bookings = sale.bookings
|
||||
# bookings.each do |booking|
|
||||
# orders = booking.orders
|
||||
# orders.each do |order|
|
||||
# # order.status = 'void'
|
||||
# end
|
||||
# end
|
||||
|
||||
if table = sale.booking.dining_facility
|
||||
unless table.current_bookings.exists?
|
||||
table.update_attributes(status: 'available')
|
||||
@@ -59,20 +50,10 @@ class Origami::VoidController < BaseOrigamiController
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,"SALEVOID" )
|
||||
|
||||
# For Print
|
||||
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
current_balance = nil
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
if bookings[0].dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
end
|
||||
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
@@ -81,17 +62,6 @@ class Origami::VoidController < BaseOrigamiController
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# get printer info
|
||||
# print_settings = PrintSetting.find_by_unique_code('ReceiptBillPdf') # SaleItemsPdf
|
||||
#
|
||||
# if !print_settings.nil?
|
||||
# unique_code = 'ReceiptBillPdf'
|
||||
# elsif
|
||||
# unique_code = 'ReceiptBillStarPdf'
|
||||
# end
|
||||
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
|
||||
@@ -117,7 +117,7 @@ class SalePayment < ApplicationRecord
|
||||
when "foc"
|
||||
payment_status = foc_payment
|
||||
when "paymal"
|
||||
payment_status,membership_data = paymal_payment
|
||||
payment_status, membership_data = paymal_payment
|
||||
when "JunctionPay"
|
||||
payment_status = junction_pay_payment
|
||||
when "dinga"
|
||||
@@ -544,7 +544,7 @@ class SalePayment < ApplicationRecord
|
||||
remark = "#{membership_data} PayMal Payment- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
|
||||
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
|
||||
|
||||
if membership_data["status"]==true
|
||||
if membership_data["status"] == true
|
||||
self.payment_method = "paymal"
|
||||
self.payment_amount = self.received_amount
|
||||
# self.payment_reference = self.voucher_no
|
||||
@@ -553,7 +553,6 @@ class SalePayment < ApplicationRecord
|
||||
payment_status = self.save!
|
||||
# SalePayment.where(:sale_payment_id => self.sale_payment_id).update_all(:payment_status => 'paid')
|
||||
sale_update_payment_status(self.received_amount.to_f)
|
||||
|
||||
else
|
||||
sale_update_payment_status(0)
|
||||
end
|
||||
@@ -603,7 +602,6 @@ class SalePayment < ApplicationRecord
|
||||
payment_status = self.save!
|
||||
SalePayment.where(:sale_payment_id => self.sale_payment_id).update_all(:payment_status => 'paid')
|
||||
sale_update_payment_status(self.received_amount.to_f)
|
||||
|
||||
else
|
||||
sale_update_payment_status(0)
|
||||
end
|
||||
@@ -677,9 +675,12 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
end
|
||||
sale.save!
|
||||
|
||||
if sale.sale_status == 'completed'
|
||||
table_update_status(sale)
|
||||
update_shift
|
||||
end
|
||||
end
|
||||
|
||||
# update for cashier shift
|
||||
def update_shift
|
||||
|
||||
Reference in New Issue
Block a user