SQA feedback

This commit is contained in:
phyusin
2018-03-19 19:34:34 +06:30
parent 25b6458450
commit bf84392ef8
13 changed files with 289 additions and 129 deletions

View File

@@ -249,7 +249,7 @@ function setCommPorts(comPortLists) {
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false
}, function () { }, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment"; window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment/others_payment";
}); });
} }
} }
@@ -342,6 +342,8 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun
}else{ }else{
if(payment_type!="master"){ if(payment_type!="master"){
payment_type = payment_type.toUpperCase(); payment_type = payment_type.toUpperCase();
}else{
payment_type = "Master";
} }
swal({ swal({
title: 'Oops', title: 'Oops',

View File

@@ -6,7 +6,7 @@ class Oqs::EditController < BaseOqsController
if params[:type] == 'oqs' if params[:type] == 'oqs'
assigned_item = AssignedOrderItem.find(assigned_item_id) assigned_item = AssignedOrderItem.find(assigned_item_id)
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'") @order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'")
elsif elsif params[:type] == "pending"
assigned_item = OrderItem.find(assigned_item_id) assigned_item = OrderItem.find(assigned_item_id)
@booking = Booking.joins(" JOIN booking_orders as bko on bko.booking_id = bookings.booking_id") @booking = Booking.joins(" JOIN booking_orders as bko on bko.booking_id = bookings.booking_id")
.where("bko.order_id = '#{assigned_item.order_id}'").first() .where("bko.order_id = '#{assigned_item.order_id}'").first()

61
app/controllers/origami/jcb_controller.rb Executable file → Normal file
View File

@@ -5,33 +5,43 @@ class Origami::JcbController < BaseOrigamiController
@cashier_type = params[:type] @cashier_type = params[:type]
# limit jcb_amount # limit jcb_amount
sale_data = Sale.find_by_sale_id(@sale_id) sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total total = 0
@jcbcount = 0 @jcbcount = 0
others = 0 @shop = Shop::ShopDetail
@rounding_adj = 0
@can_jcb = 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
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "jcb"
@jcbcount = @jcbcount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_jcb = total - @jcbcount - others
@payment_method_setting_nav = PaymentMethodSetting.all @member_discount = MembershipSetting.find_by_discount(1)
@shop = Shop::ShopDetail @sub_total = sale_data.total_amount
if @shop.is_rounding_adj @membership_id = sale_data.customer.membership_id
new_total = Sale.get_rounding_adjustment(sale_data.grand_total) #for bank integration
else @receipt_no = sale_data.receipt_no
new_total = sale_data.grand_total
end end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "jcb"
@jcbcount = @jcbcount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_jcb = total - @jcbcount - 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
bank_integration = Lookup.collection_of('bank_integration') bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0 @bank_integration = 0
if !bank_integration[0].nil? if !bank_integration[0].nil?
@@ -59,4 +69,9 @@ class Origami::JcbController < BaseOrigamiController
end end
end end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end end

60
app/controllers/origami/master_controller.rb Executable file → Normal file
View File

@@ -5,32 +5,41 @@ class Origami::MasterController < BaseOrigamiController
@cashier_type = params[:type] @cashier_type = params[:type]
# limit master_amount # limit master_amount
sale_data = Sale.find_by_sale_id(@sale_id) sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total total = 0
@mastercount = 0 @mastercount = 0
others = 0 @shop = Shop::ShopDetail
@rounding_adj = 0
@payment_method_setting_nav = PaymentMethodSetting.all @can_master = 0
@shop = Shop::ShopDetail @member_discount = 0
if @shop.is_rounding_adj @sub_total = 0
new_total = Sale.get_rounding_adjustment(sale_data.grand_total) @membership_id = nil
else @receipt_no = nil
new_total = sale_data.grand_total if !sale_data.nil?
end total = sale_data.grand_total
@rounding_adj = new_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
sale_data.sale_payments.each do |sale_payment| sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "master" if sale_payment.payment_method == "master"
@mastercount = @mastercount + sale_payment.payment_amount @mastercount = @mastercount + sale_payment.payment_amount
else else
others = others + sale_payment.payment_amount others = others + sale_payment.payment_amount
end end
end
@can_master = total - @mastercount - 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 end
@can_master = total - @mastercount - 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
bank_integration = Lookup.collection_of('bank_integration') bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0 @bank_integration = 0
if !bank_integration[0].nil? if !bank_integration[0].nil?
@@ -58,4 +67,9 @@ class Origami::MasterController < BaseOrigamiController
end end
end end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end end

63
app/controllers/origami/mpu_controller.rb Executable file → Normal file
View File

@@ -4,33 +4,43 @@ class Origami::MpuController < BaseOrigamiController
@cashier_type = params[:type] @cashier_type = params[:type]
# limit mpu_amount # limit mpu_amount
sale_data = Sale.find_by_sale_id(@sale_id) sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total total = 0
@mpucount = 0 @mpucount = 0
others = 0
@payment_method_setting_nav = PaymentMethodSetting.all
@shop = Shop::ShopDetail @shop = Shop::ShopDetail
if @shop.is_rounding_adj @rounding_adj = 0
new_total = Sale.get_rounding_adjustment(sale_data.grand_total) @can_mpu = 0
else @member_discount = 0
new_total = sale_data.grand_total @sub_total = 0
end @membership_id = nil
@rounding_adj = new_total-sale_data.grand_total @receipt_no = nil
if !sale_data.nil?
sale_data.sale_payments.each do |sale_payment| total = sale_data.grand_total
if sale_payment.payment_method == "mpu"
@mpucount = @mpucount + sale_payment.payment_amount others = 0
else
others = others + sale_payment.payment_amount if @shop.is_rounding_adj
end new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
end else
@can_mpu = total - @mpucount - others new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "mpu"
@mpucount = @mpucount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_mpu = total - @mpucount - 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
@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
bank_integration = Lookup.collection_of('bank_integration') bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0 @bank_integration = 0
if !bank_integration[0].nil? if !bank_integration[0].nil?
@@ -58,4 +68,9 @@ class Origami::MpuController < BaseOrigamiController
end end
end end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end end

View File

@@ -177,8 +177,11 @@ class Origami::PaymentsController < BaseOrigamiController
end end
booking.booking_orders.each do |order| booking.booking_orders.each do |order|
Order.pay_process_order_queue(order.order_id,table_id) # Order.pay_process_order_queue(order.order_id, table_id)
oqs = OrderQueueStation.new
oqs.pay_process_order_queue(order.order_id, table_id)
end end
end end
#for card sale data #for card sale data

View File

@@ -4,32 +4,40 @@ class Origami::UnionpayController < BaseOrigamiController
@cashier_type = params[:type] @cashier_type = params[:type]
# limit unionpay_amount # limit unionpay_amount
sale_data = Sale.find_by_sale_id(@sale_id) sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total total = 0
@unionpaycount = 0 @unionpaycount = 0
others = 0
@payment_method_setting_nav = PaymentMethodSetting.all
@shop = Shop::ShopDetail @shop = Shop::ShopDetail
if @shop.is_rounding_adj @rounding_adj = 0
new_total = Sale.get_rounding_adjustment(sale_data.grand_total) @can_unionpay = 0
else @member_discount = 0
new_total = sale_data.grand_total @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
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "unionpay"
@unionpaycount = @unionpaycount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_unionpay = total - @unionpaycount - 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 end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "unionpay"
@unionpaycount = @unionpaycount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_unionpay = total - @unionpaycount - 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
bank_integration = Lookup.collection_of('bank_integration') bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0 @bank_integration = 0
if !bank_integration[0].nil? if !bank_integration[0].nil?
@@ -58,4 +66,9 @@ class Origami::UnionpayController < BaseOrigamiController
end end
end end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end end

59
app/controllers/origami/visa_controller.rb Executable file → Normal file
View File

@@ -4,32 +4,40 @@ class Origami::VisaController < BaseOrigamiController
@cashier_type = params[:type] @cashier_type = params[:type]
# limit visa_amount # limit visa_amount
sale_data = Sale.find_by_sale_id(@sale_id) sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total total = 0
@visacount = 0 @visacount = 0
others = 0
@payment_method_setting_nav = PaymentMethodSetting.all
@shop = Shop::ShopDetail @shop = Shop::ShopDetail
if @shop.is_rounding_adj @rounding_adj = 0
new_total = Sale.get_rounding_adjustment(sale_data.grand_total) @can_visa = 0
else @member_discount = 0
new_total = sale_data.grand_total @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
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "visa"
@visacount = @visacount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_visa = total - @visacount - 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 end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "visa"
@visacount = @visacount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_visa = total - @visacount - 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
bank_integration = Lookup.collection_of('bank_integration') bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0 @bank_integration = 0
if !bank_integration[0].nil? if !bank_integration[0].nil?
@@ -58,4 +66,9 @@ class Origami::VisaController < BaseOrigamiController
end end
end end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end end

View File

@@ -71,9 +71,9 @@ class Order < ApplicationRecord
BookingOrder.create({:booking_id => booking.booking_id, :order => self}) BookingOrder.create({:booking_id => booking.booking_id, :order => self})
#Send order to queue one it done! #Send order to queue one it done!
if self.source != "quick_service" # if self.source != "quick_service"
process_order_queue process_order_queue
end # end
#send order to broadcast job #send order to broadcast job
send_order_broadcast(booking) send_order_broadcast(booking)
@@ -297,7 +297,7 @@ class Order < ApplicationRecord
else else
if order if order
oqs = OrderQueueStation.new oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id) oqs.process_order(order, self.table_id, self.source)
end end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
@@ -313,7 +313,7 @@ class Order < ApplicationRecord
else else
if order if order
oqs = OrderQueueStation.new oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id) oqs.process_order(order, self.table_id, self.source)
end end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
@@ -326,7 +326,7 @@ class Order < ApplicationRecord
else else
if order if order
oqs = OrderQueueStation.new oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id) oqs.process_order(order, self.table_id, self.source)
end end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order ActionCable.server.broadcast "order_queue_station_channel",order: assign_order

View File

@@ -101,6 +101,80 @@ class OrderQueueStation < ApplicationRecord
end #end else end #end else
end end
def pay_process_order_queue (order_id, table_id)
oqs_stations = OrderQueueStation.active
order = Order.find(order_id)
order_items = order.order_items
if table_id.to_i > 0
# get dining
dining = DiningFacility.find(table_id)
oqs_by_zones = OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}")
booking = Booking.find_by_dining_facility_id(dining.id)
# ToDo per item per printer
oqs_by_zones.each do |oqpbz|
oqs = OrderQueueStation.find(oqpbz.order_queue_station_id)
is_auto_printed = false
oqs_order_items = []
if oqs.is_active
#Get List of items -
pq_items = JSON.parse(oqs.processing_items)
#Loop through the processing items
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
if (pq_item == order_item.item_code)
if (order_item.qty > 0)
oqs_order_items.push(order_item)
end
end
end
end
if oqs.auto_print
if oqs_order_items.length > 0
print_slip(oqs, order, oqs_order_items)
is_auto_printed = true
end
end
end
end
else
oqs_stations.each do |oqs|
is_auto_printed = false
oqs_order_items = []
if oqs.is_active
#Get List of items -
pq_items = JSON.parse(oqs.processing_items)
#Loop through the processing items
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
if (pq_item == order_item.item_code)
if (order_item.qty > 0)
oqs_order_items.push(order_item)
end
end
end
end
if oqs.auto_print
if oqs_order_items.length > 0
print_slip(oqs, order, oqs_order_items)
is_auto_printed = true
end
end
end
end
end #end else
end
private private
#Print order_items in 1 slip #Print order_items in 1 slip
def print_slip(oqs, order, order_items) def print_slip(oqs, order, order_items)

View File

@@ -325,6 +325,7 @@ class SalePayment < ApplicationRecord
sObj = Sale.find(self.sale_id) sObj = Sale.find(self.sale_id)
is_credit = 0 is_credit = 0
is_foc = 0 is_foc = 0
is_cash = false
sObj.sale_payments.each do |spay| sObj.sale_payments.each do |spay|
all_received_amount += spay.payment_amount.to_f all_received_amount += spay.payment_amount.to_f
if spay.payment_method == "creditnote" if spay.payment_method == "creditnote"
@@ -333,8 +334,12 @@ class SalePayment < ApplicationRecord
if spay.payment_method == "foc" if spay.payment_method == "foc"
is_foc = 1 is_foc = 1
end end
if spay.payment_method.to_s == "cash"
is_cash = true
end
end end
if (self.sale.grand_total <= all_received_amount)
if (self.sale.grand_total <= all_received_amount) && is_cash
if is_credit == 0 if is_credit == 0
self.sale.payment_status = "paid" self.sale.payment_status = "paid"
else else
@@ -374,11 +379,15 @@ class SalePayment < ApplicationRecord
end end
self.sale.save! self.sale.save!
table_update_status(sObj)
if check_foc if check_foc
table_update_status(sObj)
update_shift update_shift
elsif paid_amount.to_f > 0 #|| paid_amount != "0.0" elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
table_update_status(sObj)
update_shift
elsif is_cash && paid_amount.to_f == 0
table_update_status(sObj)
update_shift update_shift
end end
end end

0
app/views/origami/pending_order/index.html.erb Executable file → Normal file
View File

View File

@@ -97,13 +97,15 @@
<% end%> <% end%>
<% else%> <% else%>
<% sub_total = 0 <% sub_total = 0
total = 0
@order_items.each do |order_item| @order_items.each do |order_item|
sub_total = sub_total + order_item.price %> total = order_item.qty * order_item.price
sub_total = sub_total + total %>
<input type="hidden" id="sale_id" value="<%= @bookings.booking_id %>"> <input type="hidden" id="sale_id" value="<%= @bookings.booking_id %>">
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'> <tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<td class='item-name'><%= order_item.item_name %></td> <td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td> <td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.price %></td> <td class='item-attr'><%= total %></td>
</tr> </tr>
<% end%> <% end%>
<% end%> <% end%>
@@ -210,7 +212,7 @@ $(document).ready(function(){
swal("Information!", result.error_message); swal("Information!", result.error_message);
} }
else { else {
location.reload(); window.location.href = '/origami/quick_service/pending_order';
} }
} }
}); });