From fd4bf6912f7063648d461b6adc8d42cff4e5ae3c Mon Sep 17 00:00:00 2001 From: Cherry Date: Wed, 31 May 2017 09:13:01 +0630 Subject: [PATCH 1/6] for checkout new branch --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6916f408..6936e5f1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -48,9 +48,9 @@ GEM sass (>= 3.4.19) builder (3.2.3) byebug (9.0.6) - coffee-rails (4.2.1) + coffee-rails (4.2.2) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.2.x) + railties (>= 4.0.0) coffee-script (2.4.1) coffee-script-source execjs @@ -97,7 +97,7 @@ GEM minitest (5.10.2) multi_json (1.12.1) mysql2 (0.4.6) - nio4r (2.0.0) + nio4r (2.1.0) nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) From b3b2e9bd8d6e4df5680f6cc5d39abd330ae6762c Mon Sep 17 00:00:00 2001 From: Cherry Date: Wed, 31 May 2017 16:24:34 +0630 Subject: [PATCH 2/6] order controller updated --- app/controllers/api/orders_controller.rb | 1 + app/controllers/origami/home_controller.rb | 19 +++ app/views/origami/home/index.html.erb | 187 +++++++-------------- 3 files changed, 80 insertions(+), 127 deletions(-) diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index d0fe2a77..57f2e48c 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -37,6 +37,7 @@ class Api::OrdersController < Api::ApiController #Create Table Booking or Room Booking if !params["booking_id"].nil? && params[:booking_id].to_i > 0 @order.new_booking = false + # @order.new_booking = true @order.booking_id = params[:booking_id] end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 8cbc8e55..fa4cec7c 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -1,6 +1,25 @@ class Origami::HomeController < BaseOrigamiController def index + @order = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price, + order_items.id as order_items_id,dining_facilities.name as table_name") + .joins("left join booking_orders on booking_orders.order_id = orders.id + left join bookings on bookings.id = booking_orders.id + left join dining_facilities on dining_facilities.id = bookings.dining_facility_id + left join order_items on order_items.order_id = orders.id") + .where("orders.order_type=? and dining_facilities.is_active=?","dine_in",true) + .group("orders.id") + end def show + @order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price") + .joins("left join orders on orders.id = order_items.order_id") + .where("order_items.order_id=?",params[:order_id]) + respond_to do |format| + format.html + format.json{ + render :json => @order_details.to_json + } + end + end end diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 051c9a26..156ee076 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -18,16 +18,23 @@
+
-
+ <% @order.each do |order| %> +
+
-

Card title that wraps to a new line

-

This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

+ + +

<%=order.table_name%>

+ +

<%=order.total_price%>

-
+ <%end %> +
@@ -137,27 +144,27 @@
-
+ + -
+
@@ -172,7 +179,7 @@
-
ORDER DETAILS - Table 4
+
ORDER DETAILS <% if @order_details%>- Table 4<%end%>
@@ -186,120 +193,26 @@
-
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + <% sub_total = 0%> + <% if @order_details%> + <% @order_details.each do |order_detail| %> + + + + + + <% end %> + <% end %>
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
+ <%=order_detail.item_name%> @ <%=order_detail.price%> + + <%=order_detail.qty%> + + <%=order_detail.total_price%> + <%sub_total+=order_detail.total_price%> +
@@ -307,8 +220,13 @@ - - + + + +
Sub-Total750.00Total Amount<%=sub_total%>
@@ -349,3 +267,18 @@
+ \ No newline at end of file From 44e7d2452f37dd954ceae94082ba11be360fd5c6 Mon Sep 17 00:00:00 2001 From: Cherry Date: Wed, 31 May 2017 18:19:17 +0630 Subject: [PATCH 3/6] tables origami --- app/controllers/origami/home_controller.rb | 16 ++++---- app/views/origami/home/index.html.erb | 44 +++++++++++++--------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index fa4cec7c..dbd84007 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -8,18 +8,16 @@ class Origami::HomeController < BaseOrigamiController left join order_items on order_items.order_id = orders.id") .where("orders.order_type=? and dining_facilities.is_active=?","dine_in",true) .group("orders.id") - end def show @order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price") .joins("left join orders on orders.id = order_items.order_id") - .where("order_items.order_id=?",params[:order_id]) - respond_to do |format| - format.html - format.json{ - render :json => @order_details.to_json - } - end - + .where("order_items.order_id=?",params[:order_id]) + # render :json => @order_details.to_json + str = [] + @order_details.each do |ord_detail| + str.push(ord_detail) + end + render :json => str.to_json end end diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 156ee076..ec523494 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -196,23 +196,18 @@
- <% sub_total = 0%> - <% if @order_details%> - <% @order_details.each do |order_detail| %> - - <% end %> - <% end %> + +
- <%=order_detail.item_name%> @ <%=order_detail.price%> + - <%=order_detail.qty%> + - <%=order_detail.total_price%> - <%sub_total+=order_detail.total_price%> +
@@ -220,13 +215,13 @@ - - + +
- <% @order.each do |order| %> -
+ + <% @order_table.each do |order_table| %> +
- - -

<%=order.table_name%>

- -

<%=order.total_price%>

+

<%=order_table.table_name%>

+

<%=order_table.total_price%>

<%end %> -
@@ -94,46 +40,16 @@
-
+ <% @order_rooms.each do |order_room| %> +
+
-

Card title that wraps to a new line

-

This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

-
-
-
-
-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

-
- - Someone famous in Source Title - -
-
-
-
-
-

Card title

-

This card has supporting text below as a natural lead-in to additional content.

-

Last updated 3 mins ago

-
-
-
-
-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.

-
- - Someone famous in Source Title - -
-
-
-
-
-

Card title

-

This card has supporting text below as a natural lead-in to additional content.

-

Last updated 3 mins ago

+ <% tablename = order_room.room_name%> +

<%=order_room.room_name%>

+

<%=order_room.total_price%>

+ <%end %>
@@ -144,27 +60,15 @@
- - - - +
+ <%end %>
@@ -179,7 +83,7 @@
-
ORDER DETAILS <% if @order_details%>- Table 4<%end%>
+
ORDER DETAILS
@@ -194,7 +98,7 @@
Total Amount<%=sub_total%>Sub Total
- +
-
@@ -218,27 +122,6 @@ Sub Total
@@ -262,11 +145,21 @@
- \ No newline at end of file + + + \ No newline at end of file From 9afe39b7e280f6d08e426ea8278a4d8e636d3bfd Mon Sep 17 00:00:00 2001 From: Cherry Date: Fri, 2 Jun 2017 17:48:03 +0630 Subject: [PATCH 5/6] commit for sales --- .../javascripts/origami/request_bills.coffee | 3 + .../stylesheets/origami/request_bills.scss | 3 + .../origami/request_bills_controller.rb | 13 ++++ app/helpers/origami/request_bills_helper.rb | 2 + app/models/order.rb | 4 +- app/models/sale.rb | 3 +- app/views/origami/home/index.html.erb | 46 ++++++++----- app/views/origami/request_bills/show.html.erb | 69 +++++++++++++++++++ config/routes.rb | 5 ++ .../request_bills/show.html.erb_spec.rb | 5 ++ 10 files changed, 134 insertions(+), 19 deletions(-) create mode 100644 app/assets/javascripts/origami/request_bills.coffee create mode 100644 app/assets/stylesheets/origami/request_bills.scss create mode 100644 app/controllers/origami/request_bills_controller.rb create mode 100644 app/helpers/origami/request_bills_helper.rb create mode 100644 app/views/origami/request_bills/show.html.erb create mode 100644 spec/views/origami/request_bills/show.html.erb_spec.rb diff --git a/app/assets/javascripts/origami/request_bills.coffee b/app/assets/javascripts/origami/request_bills.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/origami/request_bills.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/origami/request_bills.scss b/app/assets/stylesheets/origami/request_bills.scss new file mode 100644 index 00000000..20719090 --- /dev/null +++ b/app/assets/stylesheets/origami/request_bills.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the origami/RequestBills controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb new file mode 100644 index 00000000..c202d4dc --- /dev/null +++ b/app/controllers/origami/request_bills_controller.rb @@ -0,0 +1,13 @@ +class Origami::RequestBillsController < BaseOrigamiController + def show + @sale = Sale.new + check_order = Order.find_by_id(params[:id]) + if check_order + @order_details = OrderItem.get_order_items_details(check_order.id) + @order_details = OrderItem.get_order_items_details(check_order.id) + @status, @sale_id = @sale.generate_invoice_from_order(check_order.id, nil,current_login_employee.name) + @sale_data = Sale.find_by_id(@sale_id) + @sale_items = SaleItem.where("sale_id=?",@sale_id) + end + end +end diff --git a/app/helpers/origami/request_bills_helper.rb b/app/helpers/origami/request_bills_helper.rb new file mode 100644 index 00000000..a33f7c3e --- /dev/null +++ b/app/helpers/origami/request_bills_helper.rb @@ -0,0 +1,2 @@ +module Origami::RequestBillsHelper +end diff --git a/app/models/order.rb b/app/models/order.rb index 273cd62c..5011276c 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -226,13 +226,15 @@ class Order < ApplicationRecord end #Origami: Cashier : to view orders def self.get_orders + from = Time.now.beginning_of_day.utc + to = Time.now.end_of_day.utc orders = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price, order_items.id as order_items_id,dining_facilities.name as table_or_room_name") .joins("left join booking_orders on booking_orders.order_id = orders.id left join bookings on bookings.id = booking_orders.id left join dining_facilities on dining_facilities.id = bookings.dining_facility_id left join order_items on order_items.order_id = orders.id") - .where("dining_facilities.is_active=?",true) + .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) .group("orders.id") end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 37819c9b..88f0d846 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -188,7 +188,8 @@ class Sale < ApplicationRecord sale_tax.tax_name = tax.name sale_tax.tax_rate = tax.rate #include or execulive - sale_tax.tax_payable_amount = total_taxable * tax.rate + # sale_tax.tax_payable_amount = total_taxable * tax.rate + sale_tax.tax_payable_amount = total_taxable * tax.rate / 100 #new taxable amount total_taxable = total_taxable + sale_tax.tax_payable_amount diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index e79900ab..e0e13ff1 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -1,4 +1,4 @@ -
+
@@ -22,15 +22,15 @@
- - <% @order_table.each do |order_table| %> -
- -
-

<%=order_table.table_name%>

-

<%=order_table.total_price%>

+ <% if @order_table %> + <% @order_table.each do |order_table| %> +
+
+

<%=order_table.table_name%>

+

<%=order_table.total_price%>

+
-
+ <%end %> <%end %>
@@ -136,32 +136,38 @@ - + + + -