diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 9e886d87..5e361f7e 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -21,8 +21,9 @@ } .cashier_number{ - height:60px; - line-height:60px; + width: 33%; + height:70px; + line-height:70px; text-align:center; background:#54A5AF; // float:left; @@ -34,8 +35,8 @@ .pay{ width: 98%; - height:210px; - line-height:210px; + height:211px; + line-height:211px; text-align:center; font-size:20px; color:white; @@ -46,7 +47,7 @@ } .long{ - width:100%; + width:49%; } .sold { @@ -121,4 +122,4 @@ select.form-control { tr.discount-item-row:hover { background-color: #e3e3e3 !important; -} \ No newline at end of file +} diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index df9b1542..8bd348e2 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -38,9 +38,8 @@ 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 + if !params["booking_id"].nil? + @order.new_booking = false @order.booking_id = params[:booking_id] end diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index 9a4f7a75..a3f8948f 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -9,10 +9,11 @@ class DiningFacility < ApplicationRecord scope :active, -> {where(is_active: true)} def get_current_booking - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='occupied' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) + puts "enter booking" + booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) if booking.count > 0 then - return booking[0] + return booking[0].booking_id else return nil end diff --git a/app/models/order.rb b/app/models/order.rb index 5e123060..9dcd6949 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -28,11 +28,13 @@ class Order < ApplicationRecord booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", :checkin_at => Time.now.utc, :checkin_by => self.employee_name, :booking_status => "assign" }) + table = DiningFacility.find(self.table_id) + table.status = "occupied" + table.save else if (self.booking_id.to_i > 0 ) booking = Booking.find(self.booking_id) end - end booking.save! @@ -226,7 +228,7 @@ class Order < ApplicationRecord bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") - .joins("left join orders on orders.order_id = booking_orders.order_id") + .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") @@ -239,10 +241,10 @@ class Order < ApplicationRecord bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") - .joins("left join orders on orders.order_id = booking_orders.order_id") + .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status='complete'") - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.customer_id") end @@ -252,7 +254,7 @@ class Order < ApplicationRecord bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") - .joins("left join orders on orders.order_id = booking_orders.order_id") + .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") @@ -269,7 +271,7 @@ class Order < ApplicationRecord .joins("left join sale_orders on sale_orders.order_id = orders.order_id") .joins("left join sales on sales.sale_id = sale_orders.sale_id") .where("sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id") end #Origami: Cashier : to view order type Room @@ -298,7 +300,7 @@ class Order < ApplicationRecord left join sale_orders on sale_orders.order_id = orders.order_id left join sales on sales.sale_id = sale_orders.sale_id") .where("sales.sale_status<>'complete' and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) - .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id") + .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id,orders.customer_id") end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 6609a28e..27ddafa6 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -211,18 +211,18 @@ class SalePayment < ApplicationRecord sObj.sale_payments.each do |spay| all_received_amount += spay.payment_amount.to_f end - if (self.sale.grand_total <= all_received_amount) self.sale.payment_status = "paid" self.sale.sale_status = "completed" self.sale.save! + #TODO: table status rebat() end end def rebat - + end private diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index 65b376d8..4f6b7c9a 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -4,7 +4,7 @@
-
@@ -13,10 +13,10 @@

Receipt No: <%=@sale_data.receipt_no rescue ' '%>

-
+

Date: <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

-
+
@@ -75,7 +75,7 @@
- + @@ -88,7 +88,7 @@
-
+
- -
-
+ +
+
-
+

-
+
5%
-
+
1
-
2
-
3
+
2
+
3
-
+
@@ -125,12 +125,12 @@
10%
-
+
4
-
5
-
6
+
5
+
6
-
+
@@ -138,12 +138,12 @@
20%
-
+
7
-
8
-
9
+
8
+
9
-
+
@@ -151,12 +151,12 @@
30%
-
+
0
-
.
-
00
+
.
+
00
-
+
@@ -166,13 +166,13 @@
-
DEL
-
CLR
+
DEL
+
CLR
-
+
- + - + diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 198b9518..e8d35206 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -130,7 +130,7 @@
00
-
+
Nett
Del
Clr
@@ -195,6 +195,10 @@ $(document).on('click', '.cashier_number', function(event){ $('#cash').text("0.0"); update_balance(); break; + case 'nett': + $('#cash').text($('#amount_due').text()); + update_balance(); + break; } event.handled = true; } else { @@ -216,7 +220,6 @@ $( document ).ready(function() { }); $('#pay').click(function() { - if($('#balance').text() > 0){ alert(" Insufficient Amount!") }else{ @@ -230,7 +233,7 @@ $( document ).ready(function() { data: "cash="+ cash + "&sale_id=" + sale_id, success:function(result){ alert("Thank you") - window.location.href = '/origami'; + // window.location.href = '/origami'; } }); }