From e38886790c56a4e5713c5677117564c5ad5c1ab8 Mon Sep 17 00:00:00 2001 From: Yan Date: Tue, 27 Jun 2017 11:52:51 +0630 Subject: [PATCH] not show price 0 fixed --- app/controllers/oqs/home_controller.rb | 2 +- app/models/order.rb | 9 +++++++ app/models/order_queue_station.rb | 6 ++--- app/models/printer/order_queue_printer.rb | 12 ++++----- app/pdf/order_summary_pdf.rb | 6 +++-- app/pdf/receipt_bill_pdf.rb | 29 ++++++++++++---------- app/views/oqs/home/index.html.erb | 14 +++++++---- app/views/origami/discounts/index.html.erb | 12 ++++++--- app/views/origami/home/show.html.erb | 4 +-- app/views/origami/rooms/show.html.erb | 4 +-- 10 files changed, 61 insertions(+), 37 deletions(-) diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 692b9c4a..0d4d07dc 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -117,7 +117,7 @@ class Oqs::HomeController < BaseOqsController left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join bookings as bk on bk.booking_id = bo.booking_id left join dining_facilities as df on df.id = bk.dining_facility_id") - .where("assigned_order_items.delivery_status = #{status}") + .where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0") .group("assigned_order_items.assigned_order_item_id") end end diff --git a/app/models/order.rb b/app/models/order.rb index 018013e4..b3a70f37 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -82,6 +82,15 @@ class Order < ApplicationRecord set_order_items end + # not insert with price 0 + # puts item[:price] + # puts item + # if(item[:price] != 0 ) + # OrderItem.processs_item(menu_item[:item_code], menu_item[:name], menu_item[:account_id], + # item[:quantity],menu_item[:price], item[:options], set_order_items, self.id, + # self.employee_name) + # end + OrderItem.processs_item(menu_item[:item_code], menu_item[:name], menu_item[:account_id], item[:quantity],menu_item[:price], item[:options], set_order_items, self.id, self.employee_name) diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 7a220e0f..7e3352d1 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -36,9 +36,9 @@ class OrderQueueStation < ApplicationRecord # #Same Order_items can appear in two location. # AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) # else - - AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) - if (order_item.price != 10 || order_item.price != 0) + + if (order_item.price != 0) + AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) oqs_order_items.push(order_item) end # end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 363d9b38..f80ee72d 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -9,7 +9,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker filename = "tmp/order_item_#{order_item[0].item_name}" + ".pdf" # check for item not to show - if order_item[0].price == 0 || order_item[0].price == 10 + if order_item[0].price != 0 pdf = OrderItemPdf.new(order_item[0], print_status, options) pdf.render_file filename @@ -39,7 +39,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker options = odi.options == "[]"? "" : odi.options # check for item not to show - if odi.price == 0 || odi.price == 10 + if odi.price != 0 || odi.price != 10 pdf = OrderItemPdf.new(odi, print_status, options) # pdf.render_file "tmp/order_item.pdf" pdf.render_file filename @@ -79,7 +79,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker options = odi.options == "[]"? "" : odi.options # check for item not to show - if odi.price == 0 || odi.price == 10 + if odi.price != 0 pdf = OrderItemPdf.new(odi, print_status, options) pdf.render_file filename @@ -120,7 +120,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker left join bookings AS b ON b.booking_id = bo.booking_id left join dining_facilities AS df ON df.id = b.dining_facility_id left join customers as cus ON cus.customer_id = orders.customer_id") - .where("order_items.item_code = '#{ id }'") + .where("order_items.item_code = '#{ id }' AND order_items.price != 0") .group("order_items.item_code") elsif type == "order_summary" OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining") @@ -129,7 +129,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker left join bookings AS b ON b.booking_id = bo.booking_id left join dining_facilities AS df ON df.id = b.dining_facility_id left join customers as cus ON cus.customer_id = orders.customer_id") - .where("orders.order_id = '#{ id }'") + .where("orders.order_id = '#{ id }' AND order_items.price != 0") .group("order_items.order_items_id") else # order summary for booking @@ -139,7 +139,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker left join bookings AS b ON b.booking_id = bo.booking_id left join dining_facilities AS df ON df.id = b.dining_facility_id left join customers as cus ON cus.customer_id = orders.customer_id") - .where("b.booking_id = '#{ id }'") + .where("b.booking_id = '#{ id }' AND order_items.price != 0") end end diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 504bbc51..89eac43c 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -87,7 +87,7 @@ class OrderSummaryPdf < Prawn::Document order_item.each do|odi| # check for item not to show - if odi.price == 0 || odi.price == 10 + if odi.price != 0 y_position = cursor bounding_box([0,y_position], :width => self.item_width) do @@ -105,13 +105,15 @@ class OrderSummaryPdf < Prawn::Document if options != "" y_position = cursor - bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + bounding_box([0,y_position], :width => self.item_width) do text "#{options}", :size => self.item_font_size,:align => :left end move_down 5 end + move_down 5 + dash(1, :space => 1, :phase => 1) stroke_horizontal_line 0, (self.page_width - self.margin) move_down 5 diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index b156e2c2..27c08b80 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -119,22 +119,25 @@ class ReceiptBillPdf < Prawn::Document move_down 5 sub_total = 0.0 sale_items.each do |item| - sub_total += (item.qty*item.unit_price) - qty = item.qty - total_price = item.qty*item.unit_price - price = item.unit_price - product_name = item.product_name + # check for item not to show + if item.price != 0 + sub_total += (item.qty*item.unit_price) + qty = item.qty + total_price = item.qty*item.unit_price + price = item.unit_price + product_name = item.product_name - y_position = cursor + y_position = cursor - pad_top(15) { - text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix - text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{total_price}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - } - move_down 1 + pad_top(15) { + text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix + text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{total_price}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + } + move_down 1 + end end stroke_horizontal_rule diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index ed704dcb..0f387dad 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -34,7 +34,8 @@
<% - @queue_completed_item.each do |qid| + @queue_completed_item.each do |qid| + if qid.price != 0 %>
@@ -69,7 +70,8 @@
- <% + <% + end end %>
@@ -85,8 +87,9 @@
<% - @queue_items_details.each do |qid| - if qid.station_name == qsi[:station_name] + @queue_items_details.each do |qid| + if qid.price != 0 + if qid.station_name == qsi[:station_name] %>
@@ -121,7 +124,8 @@
- <% + <% + end end end %> diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index e3cca128..9979c32f 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -29,7 +29,10 @@ <% sub_total = 0 %> <% @sale_data.sale_items.each do |sale_item| %> - <% sub_total += sale_item.qty*sale_item.unit_price%> + <% + sub_total += sale_item.qty*sale_item.unit_price + unless sale_item.price == 0 + %> > @@ -42,7 +45,10 @@ <%=(sale_item.qty*sale_item.unit_price)%> - <%end %> + <% + end + end + %>
@@ -166,7 +172,7 @@
- +
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index efbb3e10..2e852b7c 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -163,7 +163,7 @@ <% # Can't check for discount - unless sale_item.price == 0 || sale_item.price == 10 + unless sale_item.price == 0 %> <%= count %> @@ -183,7 +183,7 @@ count += 1 sub_total = sub_total + (order_item.price * order_item.qty) - unless order_item.price == 0 || order_item.price == 10 %> + unless order_item.price == 0 %> <%= count %> <%= order_item.item_name %> diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 0ddaff7a..584410d6 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -158,7 +158,7 @@ sub_total = sub_total + sale_item.price %> - <% unless sale_item.price == 0 || sale_item.price == 10 %> + <% unless sale_item.price == 0 %> <%= sale_item.product_name %> <%= sale_item.qty %> @@ -174,7 +174,7 @@ @order_items.each do |order_item | sub_total = sub_total + (order_item.price * order_item.qty) - unless order_item.price == 0 || order_item.price == 10 %> + unless order_item.price == 0 %> <%= order_item.item_name %> <%= order_item.qty %>