'
+'
'
- +''+data[field]["type"]+'- '
+ +''+data[field]["table_type"]+'- '
+''+ data[field]["zone"] +''
+''+ data[field]["order_id"] +'- '
+'
'
@@ -200,7 +202,8 @@ $(document).ready(function(){
$(document).on('click', '#print_order_item', function(event){
var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text();
var options = $('.selected-item').children('.card-block').find('.item-options').text();
- var params = { 'options':options };
+ var params = { 'options':options };
+
$.ajax({
type: 'GET',
url: '/oqs/print/print/'+assigned_item_id,
diff --git a/app/controllers/oqs/backhome_controller.rb b/app/controllers/oqs/backhome_controller.rb
index b09e4a2d..4ac5f0a2 100644
--- a/app/controllers/oqs/backhome_controller.rb
+++ b/app/controllers/oqs/backhome_controller.rb
@@ -89,7 +89,7 @@ class Oqs::HomeController < BaseOqsController
# Query for OQS with delivery status
def queue_items_query(status)
- AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
+ AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type as type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb
index d25ab0ac..dfe648d0 100644
--- a/app/controllers/oqs/home_controller.rb
+++ b/app/controllers/oqs/home_controller.rb
@@ -95,7 +95,6 @@ class Oqs::HomeController < BaseOqsController
end
-
# Query for OQS with delivery status
def queue_items_query(status,oqs_id=nil)
if oqs_id == nil
@@ -103,7 +102,13 @@ class Oqs::HomeController < BaseOqsController
else
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
end
- AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type as type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
+ AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
+ oqs.id as station_id, oqs.station_name,
+ oqs.is_active, oqpz.zone_id,
+ df.name as zone, df.type as table_type,
+ odt.order_id, odt.item_code, odt.item_name,
+ odt.price, odt.qty, odt.item_order_by, odt.options,
+ cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
@@ -114,7 +119,6 @@ class Oqs::HomeController < BaseOqsController
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs}")
.group("assigned_order_items.assigned_order_item_id")
- .order("assigned_order_items.created_at")
end
diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb
index 2e8aba2c..27822a17 100644
--- a/app/controllers/origami/home_controller.rb
+++ b/app/controllers/origami/home_controller.rb
@@ -7,6 +7,7 @@ class Origami::HomeController < BaseOrigamiController
@complete = Sale.where("sale_status != 'new'")
@orders = Order.all.order('date desc')
@shop = Shop.find_by_id(1)
+
# @shift = ShiftSale.current_open_shift(current_user.id)
end
@@ -39,7 +40,6 @@ class Origami::HomeController < BaseOrigamiController
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void'
- puts "enter"
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'
diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb
index afb28714..e134a594 100644
--- a/app/controllers/origami/shifts_controller.rb
+++ b/app/controllers/origami/shifts_controller.rb
@@ -39,13 +39,13 @@ class Origami::ShiftsController < BaseOrigamiController
# 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)
# get printer info
- print_settings=PrintSetting.find_by_unique_code(unique_code)
+ print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::CashierStationPrinter.new(print_settings)
- printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account)
+ printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
end
@@ -72,6 +72,8 @@ class Origami::ShiftsController < BaseOrigamiController
# 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)
+
end
end
diff --git a/app/models/printer/cashier_station_printer.rb b/app/models/printer/cashier_station_printer.rb
index b7bc34ae..91100145 100644
--- a/app/models/printer/cashier_station_printer.rb
+++ b/app/models/printer/cashier_station_printer.rb
@@ -22,14 +22,14 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# end
#Bill Receipt Print
- def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount)
+ def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
#Use CUPS service
#Generate PDF
#Print
cashier = shift_sale.employee.name
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
- pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount)
+ pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
pdf.render_file filename
self.print(filename)
diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb
index 8a8c1469..168e63ff 100644
--- a/app/models/shift_sale.rb
+++ b/app/models/shift_sale.rb
@@ -125,6 +125,12 @@ class ShiftSale < ApplicationRecord
query = query.where("sales.shift_sale_id =? and sale_status = 'completed'", shift.id)
.group("acc.title").order("acc.id")
end
+ end
+
+ def self.get_total_member_discount(shift)
+ query = Sale.select("SUM(sales.total_discount) as member_discount")
+ .where("shift_sale_id =? and sale_status = 'completed' and discount_type = 'member_discount'", shift.id)
+
end
end
diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb
index 1955bf74..51f905d6 100644
--- a/app/pdf/close_cashier_pdf.rb
+++ b/app/pdf/close_cashier_pdf.rb
@@ -1,6 +1,6 @@
class CloseCashierPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
- def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account)
+ def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
self.page_width = 210
self.page_height = 7000
self.margin = 5
@@ -32,7 +32,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
- shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account)
+ shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
@@ -51,7 +51,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
end
- def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account)
+ def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -277,9 +277,32 @@ class CloseCashierPdf < Prawn::Document
end
#end total amount by Account
+ if total_member_discount[0].member_discount.present?
+ @member_discount = total_member_discount[0].member_discount rescue 0.0
+ @overall = shift_sale.total_discounts - @member_discount
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Total Member Discount :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{@member_discount}", :size => self.item_font_size, :align => :right
+ end
+ else
+ @overall = shift_sale.total_discounts
+ end
+
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "Overall Discount Amount :", :size => self.item_font_size, :align => :right
+ text "Total Overall Discount :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{@overall}", :size => self.item_font_size, :align => :right
+ end
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Total Discount Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.total_discounts}", :size => self.item_font_size, :align => :right
diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb
index c6c35e1c..3ab1cf24 100644
--- a/app/views/oqs/home/index.html.erb
+++ b/app/views/oqs/home/index.html.erb
@@ -17,12 +17,11 @@
<%= qsi.id %>
>
<%= qsi.station_name %>
- <%= qsi.assigned_order_items.count(:delivery_status) %>
+ <%= qsi.assigned_order_items.where("delivery_status=0").count %>
<% if qsi.auto_print %>
(ap)
<% end %>
- <%= qsi.assigned_order_items.where("delivery_status=0").count %>
<% end %>
diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb
index cdb76bd0..e3193a98 100644
--- a/app/views/origami/home/index.html.erb
+++ b/app/views/origami/home/index.html.erb
@@ -108,7 +108,7 @@
- <%if current_login_employee.role == "cashier" %>
+ <%if current_login_employee.role == "cashier" && @shop.quick_sale_summary == true%>
<%end%>
diff --git a/app/views/origami/shifts/sale_summary.html.erb b/app/views/origami/shifts/sale_summary.html.erb
index c552d6b0..94e59924 100644
--- a/app/views/origami/shifts/sale_summary.html.erb
+++ b/app/views/origami/shifts/sale_summary.html.erb
@@ -55,11 +55,29 @@
<%= amount.total_price.round(2) %> |
<%end%>
+
+ <% if !@total_member_discount[0].member_discount.nil?
+ @member_discount = @total_member_discount[0].member_discount rescue 0.0
+ @overall = @shift.total_discounts - @member_discount
+ %>
- |
- Overall Discount Amount |
- <%= @shift.total_discounts %> |
+ |
+ Total Member Discount |
+ <%= @member_discount %> |
+ <%else @overall = @shift.total_discounts %>
+
+ <%end%>
+
+ |
+ Total Overall Discount |
+ <%= @overall %> |
+
+
+ |
+ Total Discount |
+ <%= @shift.total_discounts %> |
+
<% @sale_taxes.each do |tax| %>
@@ -98,6 +116,7 @@
| <%=@shift.credit_sales %> |
<% @total_amount = 0
+
@other_payment.each do |other| %>
|
@@ -107,32 +126,32 @@
|
MPU Payment |
- <%=other.mpu_amount.round(2) %> |
- <% @total_amount = @total_amount+other.mpu_amount %>
+ <%=other.mpu_amount.round(2) rescue 0.0 %> |
+ <% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %>
|
VISA Payment |
- <%=other.visa_amount.round(2) %> |
- <% @total_amount = @total_amount+other.visa_amount %>
+ <%=other.visa_amount.round(2) rescue 0.0 %> |
+ <% @total_amount = @total_amount+other.visa_amount rescue 0.0 %>
|
JCB Payment |
- <%=other.master_amount.round(2) %> |
- <% @total_amount = @total_amount+other.master_amount %>
+ <%=other.master_amount.round(2) rescue 0.0 %> |
+ <% @total_amount = @total_amount+other.master_amount rescue 0.0 %>
|
Master Payment |
- <%=other.jcb_amount.round(2) %> |
- <% @total_amount = @total_amount+other.jcb_amount %>
+ <%=other.jcb_amount.round(2) rescue 0.0 %> |
+ <% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %>
|
Reedem Payment |
- <%=other.paypar_amount.round(2) %> |
- <% @total_amount = @total_amount+other.paypar_amount %>
+ <%=other.paypar_amount.round(2) rescue 0.0 %> |
+ <% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %>
<%end%>