From 9afe39b7e280f6d08e426ea8278a4d8e636d3bfd Mon Sep 17 00:00:00 2001 From: Cherry Date: Fri, 2 Jun 2017 17:48:03 +0630 Subject: [PATCH 1/4] 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 @@ - + + + -