not show price 0 fixed

This commit is contained in:
Yan
2017-06-27 11:52:51 +06:30
parent 08e98409a5
commit e38886790c
10 changed files with 61 additions and 37 deletions

View File

@@ -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 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 bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_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") .group("assigned_order_items.assigned_order_item_id")
end end
end end

View File

@@ -82,6 +82,15 @@ class Order < ApplicationRecord
set_order_items set_order_items
end 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], 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, item[:quantity],menu_item[:price], item[:options], set_order_items, self.id,
self.employee_name) self.employee_name)

View File

@@ -37,8 +37,8 @@ class OrderQueueStation < ApplicationRecord
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) # AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# else # else
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) if (order_item.price != 0)
if (order_item.price != 10 || order_item.price != 0) AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
oqs_order_items.push(order_item) oqs_order_items.push(order_item)
end end
# end # end

View File

@@ -9,7 +9,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
filename = "tmp/order_item_#{order_item[0].item_name}" + ".pdf" filename = "tmp/order_item_#{order_item[0].item_name}" + ".pdf"
# check for item not to show # 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 = OrderItemPdf.new(order_item[0], print_status, options)
pdf.render_file filename pdf.render_file filename
@@ -39,7 +39,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
options = odi.options == "[]"? "" : odi.options options = odi.options == "[]"? "" : odi.options
# check for item not to show # 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 = OrderItemPdf.new(odi, print_status, options)
# pdf.render_file "tmp/order_item.pdf" # pdf.render_file "tmp/order_item.pdf"
pdf.render_file filename pdf.render_file filename
@@ -79,7 +79,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
options = odi.options == "[]"? "" : odi.options options = odi.options == "[]"? "" : odi.options
# check for item not to show # 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 = OrderItemPdf.new(odi, print_status, options)
pdf.render_file filename 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 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 dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_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") .group("order_items.item_code")
elsif type == "order_summary" 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") 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 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 dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_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") .group("order_items.order_items_id")
else else
# order summary for booking # 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 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 dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_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
end end

View File

@@ -87,7 +87,7 @@ class OrderSummaryPdf < Prawn::Document
order_item.each do|odi| order_item.each do|odi|
# check for item not to show # check for item not to show
if odi.price == 0 || odi.price == 10 if odi.price != 0
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do bounding_box([0,y_position], :width => self.item_width) do
@@ -105,13 +105,15 @@ class OrderSummaryPdf < Prawn::Document
if options != "" if options != ""
y_position = cursor 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 text "#{options}", :size => self.item_font_size,:align => :left
end end
move_down 5 move_down 5
end end
move_down 5
dash(1, :space => 1, :phase => 1) dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, (self.page_width - self.margin) stroke_horizontal_line 0, (self.page_width - self.margin)
move_down 5 move_down 5

View File

@@ -119,22 +119,25 @@ class ReceiptBillPdf < Prawn::Document
move_down 5 move_down 5
sub_total = 0.0 sub_total = 0.0
sale_items.each do |item| sale_items.each do |item|
sub_total += (item.qty*item.unit_price) # check for item not to show
qty = item.qty if item.price != 0
total_price = item.qty*item.unit_price sub_total += (item.qty*item.unit_price)
price = item.unit_price qty = item.qty
product_name = item.product_name 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) { 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 "#{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 "#{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 "#{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 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 move_down 1
end
end end
stroke_horizontal_rule stroke_horizontal_rule

View File

@@ -35,6 +35,7 @@
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% <%
@queue_completed_item.each do |qid| @queue_completed_item.each do |qid|
if qid.price != 0
%> %>
<div class="card queue_station"> <div class="card queue_station">
<div class="card-block"> <div class="card-block">
@@ -70,6 +71,7 @@
</div> </div>
</div> </div>
<% <%
end
end end
%> %>
</div> </div>
@@ -86,7 +88,8 @@
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% <%
@queue_items_details.each do |qid| @queue_items_details.each do |qid|
if qid.station_name == qsi[:station_name] if qid.price != 0
if qid.station_name == qsi[:station_name]
%> %>
<div class="card queue_station"> <div class="card queue_station">
<div class="card-block"> <div class="card-block">
@@ -122,6 +125,7 @@
</div> </div>
</div> </div>
<% <%
end
end end
end end
%> %>

View File

@@ -29,7 +29,10 @@
<tbody> <tbody>
<% sub_total = 0 %> <% sub_total = 0 %>
<% @sale_data.sale_items.each do |sale_item| %> <% @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
%>
<tr class="item-row" id=<%= sale_item.sale_item_id %> > <tr class="item-row" id=<%= sale_item.sale_item_id %> >
<td style="width:60%; text-align:left"> <td style="width:60%; text-align:left">
<span id="item-account-type" class="hidden"><%=sale_item.account_id%></span> <span id="item-account-type" class="hidden"><%=sale_item.account_id%></span>
@@ -42,7 +45,10 @@
<span id="item-total-price"><%=(sale_item.qty*sale_item.unit_price)%></span> <span id="item-total-price"><%=(sale_item.qty*sale_item.unit_price)%></span>
</td> </td>
</tr> </tr>
<%end %> <%
end
end
%>
</tbody> </tbody>
</table> </table>
</div> </div>
@@ -166,7 +172,7 @@
<div class="col-md-3"> <div class="col-md-3">
<div class="form-group"> <div class="form-group">
<button id="net" class="btn btn-warning fluid action-btn">Net</button> <button id="net" class="btn btn-warning fluid action-btn">Nett</button>
<button id="percentage" class="btn btn-primary fluid action-btn">Percentage</button> <button id="percentage" class="btn btn-primary fluid action-btn">Percentage</button>
<button id="remove-item" class="btn btn-default fluid action-btn">Remove</button> <button id="remove-item" class="btn btn-default fluid action-btn">Remove</button>
</div> </div>

View File

@@ -163,7 +163,7 @@
<input type="hidden" id="sale_id" value="<%= @sale_array[0].sale_id %>"> <input type="hidden" id="sale_id" value="<%= @sale_array[0].sale_id %>">
<% <%
# Can't check for discount # Can't check for discount
unless sale_item.price == 0 || sale_item.price == 10 unless sale_item.price == 0
%> %>
<tr> <tr>
<td><%= count %></td> <td><%= count %></td>
@@ -183,7 +183,7 @@
count += 1 count += 1
sub_total = sub_total + (order_item.price * order_item.qty) sub_total = sub_total + (order_item.price * order_item.qty)
unless order_item.price == 0 || order_item.price == 10 %> unless order_item.price == 0 %>
<tr> <tr>
<td><%= count %></td> <td><%= count %></td>
<td class='item-name'><%= order_item.item_name %></td> <td class='item-name'><%= order_item.item_name %></td>

View File

@@ -158,7 +158,7 @@
sub_total = sub_total + sale_item.price sub_total = sub_total + sale_item.price
%> %>
<input type="hidden" id="sale_id" value="<%= @obj.sale_id %>"> <input type="hidden" id="sale_id" value="<%= @obj.sale_id %>">
<% unless sale_item.price == 0 || sale_item.price == 10 %> <% unless sale_item.price == 0 %>
<tr> <tr>
<td class='item-name'><%= sale_item.product_name %></td> <td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td> <td class='item-attr'><%= sale_item.qty %></td>
@@ -174,7 +174,7 @@
@order_items.each do |order_item | @order_items.each do |order_item |
sub_total = sub_total + (order_item.price * order_item.qty) sub_total = sub_total + (order_item.price * order_item.qty)
unless order_item.price == 0 || order_item.price == 10 %> unless order_item.price == 0 %>
<tr> <tr>
<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>