From 05b4dbac7c70bb7987bf52589a4dce7546fcf61a Mon Sep 17 00:00:00 2001 From: Phyo Date: Fri, 23 Jun 2017 18:45:15 +0630 Subject: [PATCH 1/7] Rebate Redeem add field --- app/models/sale_payment.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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', From ecabed5d5d05cc893238a59aaea2f1c8f90a807c Mon Sep 17 00:00:00 2001 From: Phyo Date: Fri, 23 Jun 2017 18:45:46 +0630 Subject: [PATCH 2/7] Account type change --- db/seeds.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index fc3e1bde..dced96dd 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -73,8 +73,8 @@ booking_status = Lookup.create([{lookup_type:'booking_status', name: 'Available' {lookup_type:'booking_status', name: 'Moved', value: 'moved'}]) #booking_status -account_type = Lookup.create([{lookup_type:'account_type', name: 'Income', value: 'income'}, - {lookup_type:'account_type', name: 'Expense', value: 'expense'}]) +account_type = Lookup.create([{lookup_type:'account_type', name: 'Income', value: '0'}, + {lookup_type:'account_type', name: 'Expense', value: '1'}]) # sale void reason void_reason = Lookup.create([{lookup_type:'void_reason', name: 'Approve By Manager', value: 'Approve By Manager'}, From 6e49f91b89ccb2e3885d27bf484280baeb6e88d3 Mon Sep 17 00:00:00 2001 From: Phyo Date: Mon, 26 Jun 2017 11:10:49 +0630 Subject: [PATCH 3/7] Multiple Invoices Phase 1 --- .../origami/room_invoices_controller.rb | 40 +++++ .../origami/table_invoices_controller.rb | 40 +++++ app/views/origami/home/show.html.erb | 20 ++- .../origami/room_invoices/index.html.erb | 82 ++++++++++ app/views/origami/room_invoices/show.html.erb | 147 ++++++++++++++++++ .../origami/table_invoices/index.html.erb | 82 ++++++++++ .../origami/table_invoices/show.html.erb | 147 ++++++++++++++++++ config/routes.rb | 6 + 8 files changed, 557 insertions(+), 7 deletions(-) create mode 100644 app/controllers/origami/room_invoices_controller.rb create mode 100644 app/controllers/origami/table_invoices_controller.rb create mode 100644 app/views/origami/room_invoices/index.html.erb create mode 100644 app/views/origami/room_invoices/show.html.erb create mode 100644 app/views/origami/table_invoices/index.html.erb create mode 100644 app/views/origami/table_invoices/show.html.erb 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/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 73f298ec..c25c1b2f 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -126,7 +126,7 @@

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

- +
@@ -241,18 +241,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 %>
<% @@ -298,6 +298,11 @@
diff --git a/app/views/origami/room_invoices/index.html.erb b/app/views/origami/room_invoices/index.html.erb new file mode 100644 index 00000000..011aff11 --- /dev/null +++ b/app/views/origami/room_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/room_invoices/show.html.erb b/app/views/origami/room_invoices/show.html.erb new file mode 100644 index 00000000..46e9a892 --- /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 %>

+ +
+ +
+
+ + + + + + + + + <% + 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/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..065c7f8d --- /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 %>

+ +
+ +
+
+ + + + + + + + + <% + 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/config/routes.rb b/config/routes.rb index c93beb92..6466b664 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -109,6 +109,12 @@ Rails.application.routes.draw do get 'sale/:sale_id/payment/others_payment/JCB' => "jcb#index" get 'sale/:sale_id/payment/others_payment/Redeem' => "redeem_payments#index" + #---------Multiple Invoices --------------# + get 'table/:table_id/table_invoices' => "table_invoices#index" , :as => "table_invoice_index" + get 'table/:table_id/table_invoice/:invoice_id' => "table_invoices#show" , :as => "table_invoice_show" + get 'room/:room_id/room_invoices' => "room_invoices#index" , :as => "room_invoice_index" + get 'room/:room_id/room_invoice/:invoice_id' => "room_invoices#show" , :as => "room_invoice_show" + #---------Add Customer --------------# #resources :customers get '/:sale_id/customers', to: "customers#add_customer" From a05fc0f6460a564b4dc179bed817b1058ba2c5dc Mon Sep 17 00:00:00 2001 From: Phyo Date: Mon, 26 Jun 2017 12:55:44 +0630 Subject: [PATCH 4/7] Up to Amount bug fix --- app/views/origami/redeem_payments/index.html.erb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 @@