diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 3606dadc..8c478a1a 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -160,6 +160,10 @@ background-color: #FF8C00 } +.blue{ + background-color: blue +} + .left{ margin-left:1px; } diff --git a/app/controllers/origami/room_invoices_controller.rb b/app/controllers/origami/room_invoices_controller.rb new file mode 100644 index 00000000..8d805771 --- /dev/null +++ b/app/controllers/origami/room_invoices_controller.rb @@ -0,0 +1,40 @@ +class Origami::RoomInvoicesController < BaseOrigamiController + def index + @room = DiningFacility.find(params[:room_id]) + puts "room bookig lenght" + @sale_array = Array.new + @room.bookings.each do |booking| + puts booking.sale_id + + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + end + + def show + @room = DiningFacility.find(params[:room_id]) + @sale_array = Array.new + @room.bookings.each do |booking| + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + + @sale = Sale.find(params[:invoice_id]) + @date = @sale.created_at + @status_sale = 'sale' + @customer = @sale.customer + end + +end diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb new file mode 100644 index 00000000..32e0ef7f --- /dev/null +++ b/app/controllers/origami/table_invoices_controller.rb @@ -0,0 +1,40 @@ +class Origami::TableInvoicesController < BaseOrigamiController + def index + @table = DiningFacility.find(params[:table_id]) + puts "table bookig lenght" + @sale_array = Array.new + @table.bookings.each do |booking| + puts booking.sale_id + + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + end + + def show + @table = DiningFacility.find(params[:table_id]) + @sale_array = Array.new + @table.bookings.each do |booking| + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + + @sale = Sale.find(params[:invoice_id]) + @date = @sale.created_at + @status_sale = 'sale' + @customer = @sale.customer + end + +end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 950334cb..65fc96b0 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -54,7 +54,7 @@ class SalePayment < ApplicationRecord #record an payment in sale-audit remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}" sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by) - + return true, self.save else #record an payment in sale-audit @@ -94,10 +94,15 @@ class SalePayment < ApplicationRecord sale_data = Sale.find_by_sale_id(sale_id) if sale_data + others = 0 + sale_data.sale_payments.each do |sale_payment| + others = others + sale_payment.payment_amount + end + redeem_prices = sale_data.grand_total -others # Control for Paypar Cloud begin response = HTTParty.post(url, - :body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :body => { generic_customer_id:membership_id,total_amount: redeem_prices,total_sale_transaction_amount: sale_data.grand_total,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' @@ -292,7 +297,7 @@ class SalePayment < ApplicationRecord # Control for Paypar Cloud begin - response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, + response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_sale_transaction_amount: sObj.grand_total,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, receipt_no: receipt_no,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 08f53998..5888bb3e 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -38,12 +38,21 @@
<% @tables.each do |table| %> <% if table.status == 'occupied' %> -
-
- Zone <%= table.zone_id %>
- Table <%= table.name %> ( <%= table.seater %> Seat ) -
-
+ <% if table.get_booking.nil? %> +
+
+ Zone <%= table.zone_id %>
+ Table <%= table.name %> ( <%= table.seater %> Seat ) +
+
+ <% else %> +
+
+ Zone <%= table.zone_id %>
+ Table <%= table.name %> ( <%= table.seater %> Seat ) +
+
+ <% end %> <% else %>
@@ -121,7 +130,7 @@ $(function() { var timer; function start() { - timer = setTimeout(function() { console.log("refresh");window.location.reload()}, 30000); //10000 + timer = setTimeout(function() { console.log("refresh");window.location.reload()}, 10000); //10000 }; function stop() { diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 49269d58..dd04fbcc 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -38,16 +38,22 @@
<% @tables.each do |table| %> <% if table.status == 'occupied' %> -
-
- <%= table.name %> - <% if table.get_booking.nil? %> - billed - <% else %> - new - <% end %> -
-
+ <% if table.get_booking.nil? %> +
+
+ <%= table.name %> + billed +
+
+
+ <% else %> +
+
+ <%= table.name %> + new +
+
+ <% end %> <% else %>
@@ -108,9 +114,9 @@
<% if @status_order == 'order' && @status_sale != 'sale' %> -
ORDER DETAILS
+
ORDER DETAILS | Table <%= @dining.name rescue "" %>
<% elsif @status_sale == 'sale' %> -
INVOICE DETAILS
+
INVOICE DETAILS | Table <%= @dining.name rescue "" %>
<% end %>
@@ -126,15 +132,14 @@

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

- +
<%if @customer %> - -

Customer : <%= @customer.name %>

- <%end%> + +

Customer : <%= @customer.name rescue "" %>

+ <%end%>
-
@@ -243,18 +248,18 @@ %>
- <% - end - @sale_array.each do |sale| + <% end %> +

+ Pending Payment + <% @sale_array.each do |sale| if @sale_array.size > 1 unless sale.receipt_no == @sale_array[0].receipt_no %> -

- Pending Payment + - +
Receipt No - <%= sale.receipt_no %>
<% @@ -300,6 +305,11 @@
diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index cbe356b5..a4783010 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -5,7 +5,7 @@
- +

@@ -21,7 +21,7 @@ <% end %>
- +

@@ -98,6 +98,12 @@
diff --git a/app/views/origami/room_invoices/show.html.erb b/app/views/origami/room_invoices/show.html.erb new file mode 100644 index 00000000..7ea799ae --- /dev/null +++ b/app/views/origami/room_invoices/show.html.erb @@ -0,0 +1,147 @@ +
+
+ + <% @sale_array.each do |sale| %> +
+ <% if sale.id == @sale.id %> +
+ <%= sale.receipt_no %> +
+ <% else %> +
+ <%= sale.receipt_no %> +
+ <% end %> +
+ <% end %> +
+ +
+
+
+
INVOICE DETAILS
+
+
+
+
+

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

+
+
+

Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+ + +

Customer : <%= @customer.name rescue "" %>

+ +
+ +
+
+ + + + + + + + + <% + count = 0 + sub_total = 0 + if @status_sale == "sale" + @sale.sale_items.each do |sale_item| + count += 1 + sub_total = sub_total + sale_item.price + %> + + <% + # Can't check for discount + unless sale_item.price == 0 + %> + + + + + + + <% + end + end + end + + if @status_order == 'order' && @status_sale != 'sale' + unless @order_items.nil? + count = 0 + @order_items.each do |order_item | + count += 1 + sub_total = sub_total + order_item.price + + unless order_item.price == 0 %> + + + + + + + <% + end + end + end + end + %> + +
#ItemsQTY + Price +
<%= count %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= count %><%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+
+ +
+
+
+ + +
+ + +
+
+ diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 27064f6c..584410d6 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -38,16 +38,21 @@
<% @tables.each do |table| %> <% if table.status == 'occupied' %> -
-
- <%= table.name %> - <% if table.get_booking.nil? %> - billed - <% else %> - new - <% end %> -
-
+ <% if table.get_booking.nil? %> +
+
+ <%= table.name %> + billed +
+
+ <% else %> +
+
+ <%= table.name %> + new +
+
+ <% end %> <% else %>
@@ -108,9 +113,9 @@
<% if @status == 'order' %> -
ORDER DETAILS
+
ORDER DETAILS | Table <%= @room.name rescue "" %>
<% elsif @status_sale == 'sale' %> -
INVOICE DETAILS
+
INVOICE DETAILS | Table <%= @room.name rescue "" %>
<% end %>
@@ -260,28 +265,28 @@ $(document).ready(function(){ $(".tables").on('click', function(){ var customer_id=$(".customer-id").text(); show_customer_details(customer_id); - + var dining_id = $(this).attr("data-id"); window.location.href = '/origami/table/' + dining_id; }) $(".sales").on('click',function(){ var customer_id=$(".customer-id").text(); show_customer_details(customer_id); - + var sale_id = $(this).attr("data-id"); window.location.href = '/origami/sale/' + sale_id; }) $(".rooms").on('click', function(){ var customer_id=$(".customer-id").text(); show_customer_details(customer_id); - + var dining_id = $(this).attr("data-id"); window.location.href = '/origami/room/' + dining_id; }) $(".orders").on('click',function(){ var customer_id=$(".customer-id").text(); show_customer_details(customer_id); - + var order_id = $(this).attr("data-id"); window.location.href = '/origami/order/' + order_id; }) diff --git a/app/views/origami/table_invoices/index.html.erb b/app/views/origami/table_invoices/index.html.erb new file mode 100644 index 00000000..d5cbe84d --- /dev/null +++ b/app/views/origami/table_invoices/index.html.erb @@ -0,0 +1,82 @@ +
+
+ <% @sale_array.each do |sale| %> +
+
+ <%= sale.receipt_no %> +
+
+ <% end %> +
+ + +
+
+
+
INVOICE DETAILS
+
+
+
+
+

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

+
+
+

Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+

Customer :

+
+ +
+ + +
+
+
+ + +
+ + +
+
+ diff --git a/app/views/origami/table_invoices/show.html.erb b/app/views/origami/table_invoices/show.html.erb new file mode 100644 index 00000000..ee66f9a3 --- /dev/null +++ b/app/views/origami/table_invoices/show.html.erb @@ -0,0 +1,147 @@ +
+
+ + <% @sale_array.each do |sale| %> +
+ <% if sale.id == @sale.id %> +
+ <%= sale.receipt_no %> +
+ <% else %> +
+ <%= sale.receipt_no %> +
+ <% end %> +
+ <% end %> +
+ +
+
+
+
INVOICE DETAILS
+
+
+
+
+

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

+
+
+

Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+ + +

Customer : <%= @customer.name rescue "" %>

+ +
+ +
+
+ + + + + + + + + <% + count = 0 + sub_total = 0 + if @status_sale == "sale" + @sale.sale_items.each do |sale_item| + count += 1 + sub_total = sub_total + sale_item.price + %> + + <% + # Can't check for discount + unless sale_item.price == 0 + %> + + + + + + + <% + end + end + end + + if @status_order == 'order' && @status_sale != 'sale' + unless @order_items.nil? + count = 0 + @order_items.each do |order_item | + count += 1 + sub_total = sub_total + order_item.price + + unless order_item.price == 0 %> + + + + + + + <% + end + end + end + end + %> + +
#ItemsQTY + Price +
<%= count %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= count %><%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+
+ +
+
+
+ + +
+ + +
+
+ diff --git a/app/views/settings/accounts/index.html.erb b/app/views/settings/accounts/index.html.erb index 23cfb7eb..541bc0a1 100644 --- a/app/views/settings/accounts/index.html.erb +++ b/app/views/settings/accounts/index.html.erb @@ -16,9 +16,9 @@ Title Account Type - Can get Discount + Can get Points - Can get Bonus + Can rebate Action @@ -30,9 +30,9 @@ <%= account.title %> <%= account.account_type %> - <%= account.discount %> + <%= account.point %> - <%= account.bonus %> + <%= account.rebate %> <%= link_to 'Edit', edit_settings_account_path(account) %> | diff --git a/app/views/settings/accounts/show.html.erb b/app/views/settings/accounts/show.html.erb index 284bb602..6d28df26 100644 --- a/app/views/settings/accounts/show.html.erb +++ b/app/views/settings/accounts/show.html.erb @@ -1,4 +1,4 @@ - +