diff --git a/.idea/.generators b/.idea/.generators new file mode 100644 index 00000000..16189766 --- /dev/null +++ b/.idea/.generators @@ -0,0 +1,8 @@ + + diff --git a/.idea/.rakeTasks b/.idea/.rakeTasks new file mode 100644 index 00000000..3577d8ad --- /dev/null +++ b/.idea/.rakeTasks @@ -0,0 +1,7 @@ + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..157739d4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..21ecc838 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/sxrestaurant.iml b/.idea/sxrestaurant.iml new file mode 100644 index 00000000..586fd380 --- /dev/null +++ b/.idea/sxrestaurant.iml @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..4d3242d5 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,817 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + origami + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + project + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1498458293643 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gemfile b/Gemfile index 8f16e924..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/Gemfile.lock b/Gemfile.lock index e4b905ea..7e27774a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -122,7 +122,7 @@ GEM nokogiri (1.8.0) mini_portile2 (~> 2.2.0) pdf-core (0.7.0) - pg (0.21.0) + pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb index a348951e..ff9ae413 100644 --- a/app/controllers/origami/credit_payments_controller.rb +++ b/app/controllers/origami/credit_payments_controller.rb @@ -2,9 +2,31 @@ class Origami::CreditPaymentsController < BaseOrigamiController def index + @sale_id = params[:sale_id] + + # limit visa_amount + sale_data = Sale.find_by_sale_id(@sale_id) + total = sale_data.grand_total + @creditcount = 0 + others = 0 + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "visa" + @creditcount = @creditcount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + @can_credit = total - @creditcount - others end def create + cash = params[:amount] + sale_id = params[:sale_id] + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + sale_payment = SalePayment.new + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "creditnote") + end end end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 3f70ad01..1b0aa491 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -35,7 +35,7 @@ class Origami::HomeController < BaseOrigamiController @status_order = 'order' else sale = Sale.find(booking.sale_id) - if sale.sale_status != "completed" + if sale.sale_status != "completed" && sale.sale_status != 'void' puts "enter" @sale_array.push(sale) if @status_order == 'order' diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index b98ccb6e..f5a0023e 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -41,6 +41,7 @@ class Origami::PaymentsController < BaseOrigamiController @visacount= 0.0 @jcbcount= 0.0 @mastercount = 0.0 + @credit = 0.0 @sale_data = Sale.find_by_sale_id(sale_id) #get customer amount @@ -77,6 +78,8 @@ class Origami::PaymentsController < BaseOrigamiController @jcbcount += spay.payment_amount elsif spay.payment_method == "master" @mastercount += spay.payment_amount + elsif spay.payment_method == "creditnote" + @credit += spay.payment_amount end end end diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb new file mode 100644 index 00000000..bea37a21 --- /dev/null +++ b/app/controllers/origami/void_controller.rb @@ -0,0 +1,28 @@ +class Origami::VoidController < BaseOrigamiController + + def overall_void + + sale_id = params[:sale_id] + if Sale.exists?(sale_id) + sale = Sale.find_by_sale_id(sale_id) + sale.payment_status = 'void' + sale.sale_status = 'void' + sale.save + + table_avaliable = true + table = sale.bookings[0].dining_facility + table.bookings.each do |booking| + if booking.sale.sale_status == 'new' + table_avaliable = false + end + end + + if table_avaliable == true + table.status = 'available' + table.save + end + + end + end + +end \ No newline at end of file diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 65fc96b0..e4ad5364 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -9,7 +9,6 @@ class SalePayment < ApplicationRecord attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status def process_payment(invoice, action_by, cash_amount, payment_method) - self.sale = invoice self.received_amount = cash_amount amount_due = invoice.grand_total @@ -28,7 +27,7 @@ class SalePayment < ApplicationRecord when "cash" payment_status = cash_payment when "creditnote" - if !self.customer_id.nil? + if !self.sale.customer_id.nil? payment_status = creditnote_payment(self.customer_id) end when "visa" @@ -142,7 +141,7 @@ class SalePayment < ApplicationRecord self.payment_method = "creditnote" self.payment_amount = self.received_amount self.customer_id = self.customer_id - self.outstanding_amount = 0 - self.received_amount + self.outstanding_amount = 0 - self.received_amount.to_f self.payment_status = "outstanding" payment_method = self.save! @@ -207,10 +206,7 @@ class SalePayment < ApplicationRecord customer_data = Customer.find_by_customer_id(self.sale.customer_id) membership_setting = MembershipSetting.find_by_membership_type("paypar_url") membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id) - puts 'mmmmmmmmmmmmmmmmmmmmmmmmmmm' - puts membership_data.to_json - puts "amountttttttttttttttttttttt" - puts self.received_amount + if membership_data["status"]==true self.payment_method = "paypar" self.payment_amount = self.received_amount @@ -271,8 +267,7 @@ class SalePayment < ApplicationRecord def rebat(sObj) rebate_prices = SaleItem.calculate_rebate_by_account(sObj.sale_items) - puts "eeeeeeeeeeeeeeeeeeeeeeee" - puts rebate_prices + generic_customer_id = sObj.customer.membership_id if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0 paypar = sObj.sale_payments diff --git a/app/views/origami/credit_payments/create.json.jbuilder b/app/views/origami/credit_payments/create.json.jbuilder new file mode 100644 index 00000000..08bf292c --- /dev/null +++ b/app/views/origami/credit_payments/create.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/origami/credit_payments/index.html.erb b/app/views/origami/credit_payments/index.html.erb index e4f97119..dc2b5b85 100644 --- a/app/views/origami/credit_payments/index.html.erb +++ b/app/views/origami/credit_payments/index.html.erb @@ -1 +1,166 @@ -hello Credit + +
+ +
+
+
+

CREDIT PAYMENT

+
+
+
+
+
+
+ + +
+
+
+ <% if @creditcount != 0 %> +
+
+ + +
+
+
+ <% end %> +
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
+
+
+ +
+ +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+
+ +
+ +
+ +
+
+ + diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index dd04fbcc..2e852b7c 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -295,7 +295,7 @@ - + <% end %> @@ -473,6 +473,24 @@ $('#edit').on('click',function(){ var sale_id = "<%= @obj_sale.sale_id rescue "" %>" window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit"; }) + + $('#void').on('click',function () { + var sure = confirm("Are you sure want to Void"); + if (sure == true) { + var sale_id = $('#sale_id').val(); + var ajax_url = "/origami/sale/" + sale_id + '/void'; + $.ajax({ + type: 'POST', + url: ajax_url, + success: function () { + window.location.href = '/origami/'; + } + }) + } else { + + } + + }) diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 08f833a2..cef27145 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -105,7 +105,7 @@
Credit
-
0.0
+
<%= @credit %>
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0%>
diff --git a/config/routes.rb b/config/routes.rb index fea13a34..73b361ce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -81,7 +81,7 @@ Rails.application.routes.draw do post 'item_void_cancel' => "sale_edit#item_void_cancel" post 'cancel_all_void' => 'sale_edit#cancel_all_void' post 'apply_void' => 'sale_edit#apply_void' - + get 'table/:dining_id/movetable' => "movetable#move_dining" get 'table/:dining_id/moveroom' => "moveroom#move_dining" get 'sale/:sale_id' => 'sales#show' @@ -105,6 +105,7 @@ Rails.application.routes.draw do post 'payment/master' => "master#create" post 'payment/visa' => "visa#create" post 'payment/paypar' => 'paypar_payments#create' + post 'payment/credit' => 'credit_payments#create' get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index" get 'sale/:sale_id/payment/others_payment' => "others_payments#index" @@ -114,6 +115,9 @@ 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" + #---------Void --------------# + post 'sale/:sale_id/void' => 'void#overall_void' + #---------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" @@ -124,7 +128,7 @@ Rails.application.routes.draw do #resources :customers get '/:sale_id/customers', to: "customers#add_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 + post '/:sale_id/update_sale' , to: "customers#update_sale_by_customer" # update customer id in sale table end #--------- Waiter/Ordering Station ------------# diff --git a/dump.rdb b/dump.rdb index 211fd505..acef6aa7 100644 Binary files a/dump.rdb and b/dump.rdb differ