From 298a06fc1e936c78fa9bff69eb2fde349d66ba7c Mon Sep 17 00:00:00 2001 From: Phyo Date: Thu, 22 Jun 2017 16:45:58 +0630 Subject: [PATCH 1/8] Show Local Time --- app/views/origami/home/show.html.erb | 6 +- .../origami/moveroom/move_dining.html.erb | 2 +- .../origami/movetable/move_dining.html.erb | 2 +- app/views/origami/orders/show.html.erb | 2 +- app/views/origami/rooms/show.html.erb | 2 +- app/views/origami/sales/show.html.erb | 2 +- app/views/reports/receipt_no/index.xls.erb | 112 +++++++++--------- 7 files changed, 64 insertions(+), 64 deletions(-) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 2719a758..9e315b08 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -113,7 +113,7 @@

-

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

+

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

@@ -304,7 +304,7 @@ $(document).ready(function(){ var sale_id = $('#save_order_id').attr('data-order'); } - window.location.href = '/origami/'+ sale_id + "/customers" + window.location.href = '/origami/'+ sale_id + "/customers" }); // Discount for Payment @@ -315,7 +315,7 @@ $(document).ready(function(){ }else{ var sale_id = $('#save_order_id').attr('data-order'); } - + if(sale_id!=""){ window.location.href = '/origami/' + sale_id + '/discount' } diff --git a/app/views/origami/moveroom/move_dining.html.erb b/app/views/origami/moveroom/move_dining.html.erb index 495e1514..109bc418 100644 --- a/app/views/origami/moveroom/move_dining.html.erb +++ b/app/views/origami/moveroom/move_dining.html.erb @@ -86,7 +86,7 @@

-

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

+

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

diff --git a/app/views/origami/movetable/move_dining.html.erb b/app/views/origami/movetable/move_dining.html.erb index 83419ca0..caa88660 100644 --- a/app/views/origami/movetable/move_dining.html.erb +++ b/app/views/origami/movetable/move_dining.html.erb @@ -86,7 +86,7 @@

-

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

+

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

diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb index a480593a..0763c43f 100644 --- a/app/views/origami/orders/show.html.erb +++ b/app/views/origami/orders/show.html.erb @@ -119,7 +119,7 @@

-

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

+

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

diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index c1797158..d734638b 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -113,7 +113,7 @@

-

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

+

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

diff --git a/app/views/origami/sales/show.html.erb b/app/views/origami/sales/show.html.erb index e896a50a..5f3056fb 100644 --- a/app/views/origami/sales/show.html.erb +++ b/app/views/origami/sales/show.html.erb @@ -107,7 +107,7 @@

-

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

+

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

diff --git a/app/views/reports/receipt_no/index.xls.erb b/app/views/reports/receipt_no/index.xls.erb index 2191d814..8bdee23c 100644 --- a/app/views/reports/receipt_no/index.xls.erb +++ b/app/views/reports/receipt_no/index.xls.erb @@ -2,27 +2,27 @@
<% unless @sale_data.empty? %> -

<%=current_active_location.name%>

-

Sales Summary Report (BreadTalk)

-<% if params[:from]%> -

From Date : <%= params[:from] %> , To Date : <%= params[:to] %>

-<% end %> +

<%=current_active_location.name%>

+

Sales Summary Report (BreadTalk)

+<% if params[:from]%> +

From Date : <%= params[:from] %> , To Date : <%= params[:to] %>

+<% end %> - - + + - + - + - + @@ -35,101 +35,101 @@ <% foc = 0 %> <% discount = 0 %> <% total = 0 %> - <% count = 1 %> + <% count = 1 %> <% discount_rev = 0 %> <% total_rev = 0 %> <% grand_rev = 0 %> <% total_other_charges=0 %> <% total_tax=0 %> <% cash_received = 0 %> - <% total_cash_received = 0 %> + <% total_cash_received = 0 %> <% today_credit_payment_amount = 0 %> - <% old_location_id = 0%> - <% sub_total = 0 %> - <% count_of_void = 0 %> + <% old_location_id = 0%> + <% sub_total = 0 %> + <% count_of_void = 0 %> <% flag = false %> - <% @sale_data.each do |sale| %> + <% @sale_data.each do |sale| %> <% credit_payment += sale[:credit_payment].to_f %> <% card += sale[:card_amount].to_f %> <% cash += sale[:cash_amount].to_f %> - <% credit += sale[:credit_amount].to_f %> + <% credit += sale[:credit_amount].to_f %> <% foc += sale[:foc_amount].to_f %> <% discount += sale[:total_discount].to_f %> - <% total += sale[:grand_total].to_f %> + <% total += sale[:grand_total].to_f %> <% total_other_charges +=sale[:other_charges].to_f %> <% total_tax +=sale[:total_tax].to_f %> <% cash_received = sale[:cash_amount].to_f + sale[:credit_payment].to_f%> <% total_cash_received = cash.to_f + credit_payment.to_f%> <% today_credit_payment_amount += sale[:today_credit_payment].to_f %> - + - - - - + + + + - - + + - - <% total_void_amount = 0 %> + + <% total_void_amount = 0 %> <% if !@daily_void.nil? %> <% @daily_void.each do |d_v|%> - - <% if d_v[:daily_void_amt].to_i > 0 %> - <% if d_v[:location_id] == sale[:location_id] %> - <% if d_v[:date].utc.getlocal.strftime("%Y-%m-%d").to_s == sale[:sale_date].to_s%> - <%count_of_void+=1%> - <%total_void_amount += d_v[:daily_void_amt].to_f%> + <% if d_v[:daily_void_amt].to_i > 0 %> + <% if d_v[:location_id] == sale[:location_id] %> + <% if d_v[:date].utc.getlocal.strftime("%Y-%m-%d").to_s == sale[:sale_date].to_s%> + <%count_of_void+=1%> + + <%total_void_amount += d_v[:daily_void_amt].to_f%> <% flag = true %> - - - - <%end %> - <% end%> - <% end%> - <% end%> - <% end%> + + + + <%end %> + <% end%> + <% end%> + <% end%> + <% end%> <% if flag == true%> <% void += total_void_amount.to_f %> - - <% flag = false %> + + <% flag = false %> <% end%> - <%if count_of_void == 0%> - + <%if count_of_void == 0%> + <%end %> + <%= number_with_delimiter(sprintf("%.2f",((sale[:cash_amount].to_f + sale[:credit_amount].to_f + sale[:card_amount].to_f + sale[:credit_payment].to_f) - sale[:today_credit_payment].to_f) ).to_f, :delimiter => ',') %> + -<%count_of_void= 0%> +<%count_of_void= 0%> <% count = count + 1 %> <% end %> - + - - - - + + + + - - + + <% end %>
Location Name DateCash SalesCash Sales Credit Sales Credit Received Card PaymentCard Payment Total Discount Total Taxes Total Other Charges FOC SalesVoid SalesVoid Sales Grand Total
<%= sale[:location].to_s rescue '-' %><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount].to_f), :delimiter => ',') %><%= sale[:location].to_s rescue '-' %><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount].to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:credit_payment].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:card_amount].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:credit_payment].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:card_amount].to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",sale[:total_discount].to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",sale[:total_tax].to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",sale[:other_charges].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount].to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",total_void_amount.to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",total_void_amount.to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",0.to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",0.to_f), :delimiter => ',') %> - <%= number_with_delimiter(sprintf("%.2f",((sale[:cash_amount].to_f + sale[:credit_amount].to_f + sale[:card_amount].to_f + sale[:credit_payment].to_f) - sale[:today_credit_payment].to_f) ).to_f, :delimiter => ',') %> -
Grand Total <%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",credit ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",credit_payment ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",card ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",discount ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",credit ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",credit_payment ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",card ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",discount ), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",total_tax ), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",total_other_charges ), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",foc ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",void ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f", (cash.to_f + credit.to_f + card.to_f + credit_payment.to_f) - today_credit_payment_amount.to_f ).to_f, :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",void ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f", (cash.to_f + credit.to_f + card.to_f + credit_payment.to_f) - today_credit_payment_amount.to_f ).to_f, :delimiter => ',') %>
-
\ No newline at end of file + From 19528b189f79b5edffc81664a91b039acde603f5 Mon Sep 17 00:00:00 2001 From: Nweni Date: Fri, 23 Jun 2017 09:50:37 +0630 Subject: [PATCH 2/8] Update --- app/views/origami/home/show.html.erb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 1652c675..781f925b 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -142,7 +142,7 @@ sub_total = sub_total + sale_item.price %> - <% + <% # Can't check for discount unless sale_item.price == 0 %> @@ -259,22 +259,22 @@ <% if @dining.bookings.length >= 1 %> - - - <% if @status_order == 'order' && @status_sale != 'sale' %> - - - - - <% else %> + + + + + + + <% else %> + + - - - + + <% end %> @@ -313,7 +313,7 @@ $(document).ready(function(){ var sale_id = $('#save_order_id').attr('data-order'); } - window.location.href = '/origami/'+ sale_id + "/customers" + window.location.href = '/origami/'+ sale_id + "/customers" }); // Discount for Payment @@ -324,7 +324,7 @@ $(document).ready(function(){ }else{ var sale_id = $('#save_order_id').attr('data-order'); } - + if(sale_id!=""){ window.location.href = '/origami/' + sale_id + '/discount' } From 62156e2e3e72ee4813a0b3c027b91cfc749d82c4 Mon Sep 17 00:00:00 2001 From: Phyo Date: Fri, 23 Jun 2017 11:13:29 +0630 Subject: [PATCH 3/8] Employee Show --- app/views/settings/employees/index.html.erb | 2 +- app/views/settings/employees/show.html.erb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/views/settings/employees/index.html.erb b/app/views/settings/employees/index.html.erb index e680eb91..1112f72b 100644 --- a/app/views/settings/employees/index.html.erb +++ b/app/views/settings/employees/index.html.erb @@ -22,7 +22,7 @@ <% @employees.each do |employee| %> - <%= link_to employee.name, employee[:setting] %> + <%= link_to employee.name,settings_employee_path(employee) %> <%= employee.role %> <%= link_to 'Edit', edit_settings_employee_path(employee) %> | <%= link_to 'Destroy', employee[:setting], method: :delete, data: { confirm: 'Are you sure?' } %> diff --git a/app/views/settings/employees/show.html.erb b/app/views/settings/employees/show.html.erb index 084887dc..753298e6 100644 --- a/app/views/settings/employees/show.html.erb +++ b/app/views/settings/employees/show.html.erb @@ -9,3 +9,8 @@ Role: <%= @employee.role %>

+ +

+ Employee ID: + <%= @employee.emp_id %> +

From 68403617a510b1f858e56cf67605d0c0ad629af6 Mon Sep 17 00:00:00 2001 From: Phyo Date: Fri, 23 Jun 2017 11:14:48 +0630 Subject: [PATCH 4/8] Change Font and show status in origami --- app/assets/stylesheets/origami.scss | 4 +++- app/views/origami/home/show.html.erb | 10 ++++++++++ app/views/origami/orders/show.html.erb | 10 ++++++++++ app/views/origami/rooms/show.html.erb | 14 ++++++++++++-- app/views/origami/sales/show.html.erb | 10 ++++++++++ 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 2670dcc4..d6588a94 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -9,6 +9,8 @@ // min-height: 75rem; // padding-top: 4.5rem; // } +.card-columns { + font-size: 18px !important;} .others-payment{ line-height:100px; @@ -186,4 +188,4 @@ tr.discount-item-row:hover { .jconfirm-box-container{ margin-left:-40px !important -} \ No newline at end of file +} diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 50d13fe4..f92fa1c4 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -41,6 +41,11 @@
<%= table.name %> + <% if table.get_booking.nil? %> + billed + <% else %> + new + <% end %>
<% else %> @@ -62,6 +67,11 @@
<%= room.name %> + <% if room.get_booking.nil? %> + billed + <% else %> + new + <% end %>
<% else %> diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb index 0763c43f..92ffc7f1 100644 --- a/app/views/origami/orders/show.html.erb +++ b/app/views/origami/orders/show.html.erb @@ -41,6 +41,11 @@
<%= table.name %> + <% if table.get_booking.nil? %> + billed + <% else %> + new + <% end %>
<% else %> @@ -62,6 +67,11 @@
<%= room.name %> + <% if room.get_booking.nil? %> + billed + <% else %> + new + <% end %>
<% else %> diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 4f15eea5..6430c83c 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -41,6 +41,11 @@
<%= table.name %> + <% if table.get_booking.nil? %> + billed + <% else %> + new + <% end %>
<% else %> @@ -62,6 +67,11 @@
<%= room.name %> + <% if room.get_booking.nil? %> + billed + <% else %> + new + <% end %>
<% else %> @@ -269,7 +279,7 @@ $(document).ready(function(){ var sale_id = $('#save_order_id').attr('data-order'); } - window.location.href = '/origami/'+ sale_id + "/customers" + window.location.href = '/origami/'+ sale_id + "/customers" }); // Discount for Payment @@ -280,7 +290,7 @@ $(document).ready(function(){ }else{ var sale_id = $('#save_order_id').attr('data-order'); } - + if(sale_id!=""){ window.location.href = '/origami/' + sale_id + '/discount' } diff --git a/app/views/origami/sales/show.html.erb b/app/views/origami/sales/show.html.erb index 5f3056fb..cd716052 100644 --- a/app/views/origami/sales/show.html.erb +++ b/app/views/origami/sales/show.html.erb @@ -41,6 +41,11 @@
<%= table.name %> + <% if table.get_booking.nil? %> + billed + <% else %> + new + <% end %>
<% else %> @@ -62,6 +67,11 @@
<%= room.name %> + <% if room.get_booking.nil? %> + billed + <% else %> + new + <% end %>
<% else %> From 55c8ab80dad3c4a09cbe2c70eb05f338d7e7f532 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 23 Jun 2017 11:40:11 +0630 Subject: [PATCH 5/8] discount updated --- app/views/origami/discounts/index.html.erb | 76 +++++++++++++++++++--- app/views/origami/payments/show.html.erb | 1 - app/views/origami/rooms/show.html.erb | 2 +- 3 files changed, 69 insertions(+), 10 deletions(-) diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index 4e4d2b77..e2b86569 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -80,7 +80,7 @@ -
+
@@ -167,14 +167,23 @@
- - + +
+ + +
+ +
+ + +
+
+class CreateDiningQueues < ActiveRecord::Migration[5.1] + def change + create_table :dining_queues do |t| + t.string :name + t.string :contact_no + t.string :queue_no + t.string :status + t.references :dining_facility, foreign_key: true + + t.timestamps + end + end +end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 2719a758..e282f367 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -116,9 +116,11 @@

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

-
+ +
-

Customer :

+ +

Customer : <%= @customer.name %>

@@ -276,23 +278,39 @@ diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index c1797158..b188d086 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -97,11 +97,18 @@
- <% if @status == "order" %> + + + <% if @status == 'order' %> +
ORDER DETAILS
+ <% elsif @status_sale == 'sale' %> +
INVOICE DETAILS
<% end %> +
@@ -118,7 +125,8 @@
-

Customer :

+ +

Customer : <%= @customer.name %>

@@ -244,22 +252,49 @@ diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 04343380..b62289b1 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -110,14 +110,14 @@   - Pay Amount + Total Pay Amount <%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%> <% @sale_receivables.each do |r|%> - Payment <%= r.payment_method rescue ' '%> + <%= r.payment_method.capitalize rescue ' '%> Payment <%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%> diff --git a/config/routes.rb b/config/routes.rb index 3b647fa9..ae3a0022 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -111,7 +111,7 @@ Rails.application.routes.draw do #---------Add Customer --------------# #resources :customers get '/:sale_id/customers', to: "customers#add_customer" - get '/:customer_id/get_customer' => 'home#get_customer' + get '/:customer_id/get_customer' => 'home#get_customer',:as => "show_customer_details" post '/:sale_id/update_sale' , to: "customers#update_sale_by_customer"#update customer id in sale table end diff --git a/db/migrate/20170617163811_create_dining_queues.rb b/db/migrate/20170623101708_create_dining_queues.rb similarity index 86% rename from db/migrate/20170617163811_create_dining_queues.rb rename to db/migrate/20170623101708_create_dining_queues.rb index d4b3eacd..dd2ea134 100644 --- a/db/migrate/20170617163811_create_dining_queues.rb +++ b/db/migrate/20170623101708_create_dining_queues.rb @@ -6,7 +6,8 @@ class CreateDiningQueues < ActiveRecord::Migration[5.1] t.string :queue_no t.string :status t.references :dining_facility, foreign_key: true - + t.integer :seater + t.string :remark t.timestamps end end From 3a0e26b2eaca85985c80e0af28caded2003cef9d Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 23 Jun 2017 17:05:08 +0630 Subject: [PATCH 7/8] accounts and discount updated --- app/controllers/api/bill_controller.rb | 7 ++- app/controllers/oqs/home_controller.rb | 28 ++++++++++- .../origami/discounts_controller.rb | 7 ++- .../origami/payments_controller.rb | 10 ++-- .../origami/request_bills_controller.rb | 8 +-- app/models/order_queue_station.rb | 17 ++++--- app/models/printer/receipt_printer.rb | 4 +- app/models/sale_item.rb | 23 +++++++-- app/models/sale_payment.rb | 2 +- app/pdf/order_item_pdf.rb | 2 +- app/pdf/order_summary_pdf.rb | 2 +- app/pdf/queue_no_pdf.rb | 2 +- app/pdf/receipt_bill_pdf.rb | 50 +++++++++---------- app/views/origami/discounts/index.html.erb | 11 +++- 14 files changed, 114 insertions(+), 59 deletions(-) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 86d50556..09d75f70 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -34,12 +34,11 @@ class Api::BillController < Api::ApiController # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) - # Calculate Food and Beverage Total - - food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items) + # Calculate Price by accounts + item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total) + printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts) end diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 18971247..64fd840d 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -82,7 +82,33 @@ class Oqs::HomeController < BaseOqsController end # Query for OQS with delivery status - def queue_items_query(status) + def queue_items_query(status) + # queue_items = [] + # AssignedOrderItem.all.each do |aoi| + # oqs = OrderQueueStation.find(aoi.order_queue_station_id) + # order = Order.find(aoi.order_id) + # order_items = OrderItem.find_by_order_id(aoi.order_id) + # booking_orders = BookingOrder.find_by_order_id(aoi.order_id) + # booking = Booking.find(booking_orders.booking_id) + # dining = DiningFacility.find(booking.dining_facility_id) + # customer = Customer.find_by_customer_id(order.customer_id) + # queue_item = { + # :assigned_order_item_id => aoi.assigned_order_item_id, + # :station_name => oqs.station_name, + # :is_active => oqs.is_active, + # :zone => dining.name, + # :item_code => aoi.item_code, + # :item_name => order_items.item_name, + # :price => order_items.price, + # :qty => order_items.qty, + # :item_order_by => order_items.item_order_by, + # :options => order_items.options, + # :customer_name => customer.name, + # :created_at => order_items.created_at + # } + # queue_items.push(queue_item) + # end + # return queue_items AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at") .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id left join orders as od ON od.order_id = assigned_order_items.order_id diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 6c0a4c8d..73038556 100644 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -19,6 +19,8 @@ class Origami::DiscountsController < BaseOrigamiController if Sale.exists?(sale_id) sale = Sale.find(sale_id) + table_id = sale.bookings[0].dining_facility_id + table_type = DiningFacility.find(table_id).type sale.total_discount = overall_discount.to_f sale.total_amount = sub_total.to_f sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax; @@ -44,7 +46,10 @@ class Origami::DiscountsController < BaseOrigamiController sale_item.save end end - end + end + + dining = {:table_id => table_id, :table_type => table_type } + render :json => dining.to_json end #discount for selected order diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 38225fae..00abc9aa 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -23,10 +23,10 @@ class Origami::PaymentsController < BaseOrigamiController # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total - food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) + item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount) end end @@ -94,11 +94,11 @@ class Origami::PaymentsController < BaseOrigamiController # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) - # Calculate Food and Beverage Total - food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) + # Calculate price_by_accounts + item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount) end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 93453ffc..95f63e58 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -24,19 +24,19 @@ class Origami::RequestBillsController < BaseOrigamiController customer= Customer.find(@sale_data.customer_id) # get member information - member_info = Customer.get_member_account(customer) + member_info = Customer.get_member_account(customer) # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) # find order id by sale id # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) - # Calculate Food and Beverage Total - food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items) + # Calculate price_by_accounts + item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total,member_info) + printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info) # redirect_to origami_path(@sale_data.sale_id) end diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 2e85ecde..04619379 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -18,14 +18,15 @@ class OrderQueueStation < ApplicationRecord order_items = order.order_items # get dining - booking = Booking.find_by_dining_facility_id(dining.id) + booking = Booking.find_by_dining_facility_id(dining.id) #Assign OQS id to order Items - oqs_stations.each do |oqs| + oqs_stations.each do |oqs| + is_auto_printed = false #Get List of items - pq_items = JSON.parse(oqs.processing_items) - #Loop through the processing items + #Loop through the processing items pq_items.each do |pq_item| #Processing through the looping items order_items.each do |order_item| @@ -36,11 +37,13 @@ class OrderQueueStation < ApplicationRecord # else AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) - # end - - if oqs.auto_print + # end + + # Auto Printing + if oqs.auto_print && is_auto_printed == false print_slip(oqs, order, order_items) - end + is_auto_printed = true + end end end end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 969b9d44..4b7287db 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount=nil) + def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil) #Use CUPS service #Generate PDF #Print - pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info,rebate_amount) + pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount) pdf.render_file "tmp/receipt_bill.pdf" self.print("tmp/receipt_bill.pdf") diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index bec8b5c5..8881efea 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -30,9 +30,24 @@ class SaleItem < ApplicationRecord # end end - # Calculate food total and beverage total - def self.calculate_food_beverage(sale_items) + def self.calculate_price_by_accounts(sale_items) + price_accounts = [] + Account.all.each do |a| + account_price = {:name => a.title, :price => 0} + sale_items.each do |si| + if si.account_id == a.id + account_price[:price] = account_price[:price] + si.price + end + end + price_accounts.push(account_price) + end + + return price_accounts + end + + # Calculate rebate_by_account + def self.calculate_rebate_by_account(sale_items) rebateacc = Account.where("rebate=?",true) puts "Account that can rebate" rebateacc.each do |i| @@ -40,7 +55,7 @@ class SaleItem < ApplicationRecord end prices=0 sale_items.each do |si| - price = self.get_price(si.sale_item_id,rebateacc) + price = self.get_rebate_price(si.sale_item_id,rebateacc) prices = prices + price end @@ -48,7 +63,7 @@ class SaleItem < ApplicationRecord end # get food price or beverage price for item - def self.get_price(sale_item_id,rebateacc) + def self.get_rebate_price(sale_item_id,rebateacc) price=0 item=SaleItem.select("sale_items.price , menu_items.account_id") diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index f988b4e3..950334cb 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -265,7 +265,7 @@ class SalePayment < ApplicationRecord end def rebat(sObj) - rebate_prices = SaleItem.calculate_food_beverage(sObj.sale_items) + rebate_prices = SaleItem.calculate_rebate_by_account(sObj.sale_items) puts "eeeeeeeeeeeeeeeeeeeeeeee" puts rebate_prices generic_customer_id = sObj.customer.membership_id diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 749a8a16..4b7559b1 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -2,7 +2,7 @@ class OrderItemPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(order_item, print_status, options) self.page_width = 210 - self.page_height = 2500 + self.page_height = 1450 self.margin = 5 self.price_width = 40 # No Need for item self.qty_width = 30 diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index b9c1f6fe..176749b8 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -2,7 +2,7 @@ class OrderSummaryPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(order, print_status) self.page_width = 210 - self.page_height = 2500 + self.page_height = 1450 self.margin = 5 self.price_width = 40 # No Need for item self.qty_width = 30 diff --git a/app/pdf/queue_no_pdf.rb b/app/pdf/queue_no_pdf.rb index 704dbfdb..0963f55e 100644 --- a/app/pdf/queue_no_pdf.rb +++ b/app/pdf/queue_no_pdf.rb @@ -2,7 +2,7 @@ class QueueNoPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(printer_settings, queue) self.page_width = 210 - self.page_height = 2500 + self.page_height = 1450 self.margin = 5 self.price_width = 35 self.qty_width = 20 diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index bdeb58a3..96e16cf4 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,6 +1,6 @@ class ReceiptBillPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width - def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount = nil) + def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil) self.page_width = 210 self.page_height = 2500 self.margin = 5 @@ -29,7 +29,8 @@ class ReceiptBillPdf < Prawn::Document stroke_horizontal_rule cashier_info(sale_data, customer_name) - line_items(sale_items, food_total, beverage_total) + line_items(sale_items) + items_account(item_price_by_accounts) all_total(sale_data) @@ -103,26 +104,24 @@ class ReceiptBillPdf < Prawn::Document move_down 5 end - def line_items(sale_items, food_total, beverage_total) + def line_items(sale_items) y_position = cursor pad_top(15) { - # @item_width.to_i + @half_qty.to_i - text_box "Items", :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 "Qty", :at =>[(self.item_width+self.price_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", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - - } + # @item_width.to_i + @half_qty.to_i + text_box "Items", :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 "Qty", :at =>[(self.item_width+self.price_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", :at =>[(self.item_width+self.price_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 5 stroke_horizontal_rule - add_line_item_row(sale_items, food_total, beverage_total) - + add_line_item_row(sale_items) end - def add_line_item_row(sale_items, food_total, beverage_total) + def add_line_item_row(sale_items) item_name_width = (self.item_width+self.price_width) y_position = cursor move_down 5 @@ -155,25 +154,26 @@ class ReceiptBillPdf < Prawn::Document end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{ sub_total }" , :size => self.item_font_size,:align => :right - end - - # Food and Beverage - food_beverage_total = food_total.to_s + "/" + beverage_total.to_s - - move_down 5 + end + move_down 5 + end + def items_account(item_price_by_accounts) y_position = cursor - bounding_box([0,y_position], :width => self.item_description_width, :height => self.item_height) do - text "Food/Beverage Total", :size => self.item_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width => self.label_width) do - text "#{ food_beverage_total }" , :size => self.item_font_size,:align => :right + item_price_by_accounts.each do |ipa| + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ ipa[:price] }" , :size => self.item_font_size,:align => :right + end + move_down 5 end end def all_total(sale_data) item_name_width = self.item_width - move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index e2b86569..45ab4b2b 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -347,9 +347,16 @@ $(document).ready(function(){ type: "POST", url: ajax_url, data: params, - success:function(result){ + success:function(result){ alert("Successfully Discount!"); - window.history.back(); + if(result.table_type == "Table"){ + window.location.href = "/origami/table/" + result.table_id + } + else { + window.location.href = "/origami/room/" + result.table_id + } + + // window.history.back(); } }); }); From 81c50f220a04391eda0a88257526fa01234a573b Mon Sep 17 00:00:00 2001 From: Nweni Date: Fri, 23 Jun 2017 17:37:08 +0630 Subject: [PATCH 8/8] edit invoice --- Gemfile | 2 +- app/assets/stylesheets/origami.scss | 7 +- .../origami/payments_controller.rb | 5 +- .../origami/sale_edit_controller.rb | 8 ++ app/models/dining_facility.rb | 2 - app/views/origami/home/show.html.erb | 14 +- app/views/origami/sale_edit/edit.html.erb | 120 ++++++++++++++++++ config/routes.rb | 2 +- 8 files changed, 150 insertions(+), 10 deletions(-) create mode 100644 app/controllers/origami/sale_edit_controller.rb create mode 100644 app/views/origami/sale_edit/edit.html.erb diff --git a/Gemfile b/Gemfile index 22275707..227cfa72 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -# gem 'pg' +gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 2670dcc4..ae4a3181 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -128,6 +128,11 @@ text-align: right; } +.item-attr-edit{ + width: 10%; + text-align: left; +} + .display-none{ display: none; } @@ -186,4 +191,4 @@ tr.discount-item-row:hover { .jconfirm-box-container{ margin-left:-40px !important -} \ No newline at end of file +} diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 38225fae..c063d935 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -11,7 +11,7 @@ class Origami::PaymentsController < BaseOrigamiController saleObj = Sale.find(sale_id) sale_payment = SalePayment.new sale_payment.process_payment(saleObj, @user, cash, "cash") - + rebate_amount = nil unique_code = "ReceiptBillPdf" @@ -53,7 +53,8 @@ class Origami::PaymentsController < BaseOrigamiController response["data"].each do |res| if res["accountable_type"] == "RebateAccount" @balance = res["balance"] - @accountable_type = res["accountable_type"] + # @accountable_type = res["accountable_type"] + @accountable_type = "Rebate Balance" end end end diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb new file mode 100644 index 00000000..93e98d03 --- /dev/null +++ b/app/controllers/origami/sale_edit_controller.rb @@ -0,0 +1,8 @@ +class Origami::SaleEditController < BaseOrigamiController + + def edit + sale_id = params[:sale_id] + @table_id = params[:table_id] + @saleobj = Sale.find(sale_id) + end +end diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index f8cb639c..0e10307b 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -20,8 +20,6 @@ class DiningFacility < ApplicationRecord def get_booking booking = self.get_current_booking - puts "is bookig?" - puts booking if booking if booking.dining_facility_id.to_i == self.id if booking.booking_status == 'assign' diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index d0b53858..0974e7da 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -260,17 +260,19 @@ <% if @dining.bookings.length >= 1 %> - + <% if @status_order == 'order' && @status_sale != 'sale' %> - + + <% else %> - + + @@ -382,4 +384,10 @@ $('#add_invoice').on('click',function(){ } }); }) + +$('#edit').on('click',function(){ + var dining_id = "<%= @dining.id %>" + var sale_id = "<%= @obj_sale.sale_id rescue "" %>" + window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit"; +}) diff --git a/app/views/origami/sale_edit/edit.html.erb b/app/views/origami/sale_edit/edit.html.erb new file mode 100644 index 00000000..f04561e0 --- /dev/null +++ b/app/views/origami/sale_edit/edit.html.erb @@ -0,0 +1,120 @@ +
+ +
+
+
+
INVOICE DETAILS
+
+
+
+
+

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

+
+
+

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

+
+
+
+
+

Customer :

+
+ +
+
+ + + + + + + + + + <% + count = 0 + sub_total = 0 + @saleobj.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 + %> + +
#ItemsQTY + Price + Action
<%= count %><%= sale_item.product_name %> +
+
+ +
+
+
+ + +
+ + +
+
+ diff --git a/config/routes.rb b/config/routes.rb index 0bf24ce7..20b87fd1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -76,7 +76,7 @@ Rails.application.routes.draw do resources :customers #add customer type end post 'moving' => "movetable#moving" - + get "/table/:table_id/sale/:sale_id/edit" => "sale_edit#edit" get 'table/:dining_id/movetable' => "movetable#move_dining" get 'table/:dining_id/moveroom' => "moveroom#move_dining" get 'sale/:sale_id' => 'sales#show'