From 089848ed4a217c026802c8700d39d4e2640bd92b Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 26 Jun 2017 17:49:55 +0630 Subject: [PATCH 1/3] credit note payment --- Gemfile | 2 +- .../origami/credit_payments_controller.rb | 22 +++ .../origami/payments_controller.rb | 3 + app/models/sale_payment.rb | 13 +- .../credit_payments/create.json.jbuilder | 1 + .../origami/credit_payments/index.html.erb | 167 +++++++++++++++++- app/views/origami/payments/show.html.erb | 2 +- config/routes.rb | 3 +- 8 files changed, 200 insertions(+), 13 deletions(-) create mode 100644 app/views/origami/credit_payments/create.json.jbuilder 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/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/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 310dfbc5..e3705294 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -39,6 +39,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 @@ -75,6 +76,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/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/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..39b9aca5 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" From feb1d662577f4bd7831a417447b07356a5ee7e8f Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Mon, 26 Jun 2017 18:00:48 +0630 Subject: [PATCH 2/3] overall void --- Gemfile.lock | 2 -- app/controllers/origami/home_controller.rb | 2 +- app/views/origami/home/show.html.erb | 20 +++++++++++++++++++- config/routes.rb | 3 +++ dump.rdb | Bin 18163 -> 18262 bytes 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e4b905ea..5c0f8a10 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -122,7 +122,6 @@ GEM nokogiri (1.8.0) mini_portile2 (~> 2.2.0) pdf-core (0.7.0) - pg (0.21.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -261,7 +260,6 @@ DEPENDENCIES kaminari (~> 1.0.1) listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) - pg prawn prawn-table puma (~> 3.0) 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/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 73f298ec..6342aee4 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -288,7 +288,7 @@ - + <% end %> @@ -454,5 +454,23 @@ $('#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/config/routes.rb b/config/routes.rb index bf5d6483..db4acb5b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -110,6 +110,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' + #---------Add Customer --------------# #resources :customers get '/:sale_id/customers', to: "customers#add_customer" diff --git a/dump.rdb b/dump.rdb index 211fd505548a6a60b85596d4201ab6d1155b4f22..041df177e5969bb1b252b44f32d8d3f28339ced3 100644 GIT binary patch delta 3514 zcma)9YiyLq72PMs3HSjN2MBn)JOZ)3o|$i+3z*#n3aV5HL4DAmnzg-lRwyD5WRU4wF1%zazs8XUDIA0NK^#G!vLo)}LKc8?}UXIsv!@qFs}&lkL&mE*ZY zE;5uzjU)#n6cgEvMK@N(lbP^HW*{*V zVO&WS5oAc>Od+zl$nc8N3XX(7kWA~o=Yc2 zlc7lH^GQQpp?0V;n@bM%C32yNn@JGCY1om3V%ilNTbddSl^*X3~7aU5Aj3)#A6XTObbEmiM^wIUJ9*7MQ z#deeMtqKx8^MU8wC%tbsm=!*<<>5LYXTIWl5PSfvEFOT5SD&6-gZ?+nqMMc;S!*9^ zg+Dg=gV|&*JJ~)LyBY5{2b!i#X7#n^rHTO#!U-$s0Cna#Mdno7M)U188@mcEp45UD z=Vu#Pm;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ea/.rakeTasks | 7 + .idea/misc.xml | 4 + .idea/modules.xml | 8 + .idea/sxrestaurant.iml | 236 ++++++ .idea/vcs.xml | 6 + .idea/workspace.xml | 817 +++++++++++++++++++++ app/controllers/origami/void_controller.rb | 28 + config/routes.rb | 2 +- dump.rdb | Bin 18262 -> 18261 bytes 10 files changed, 1115 insertions(+), 1 deletion(-) create mode 100644 .idea/.generators create mode 100644 .idea/.rakeTasks create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/sxrestaurant.iml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 app/controllers/origami/void_controller.rb 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/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/config/routes.rb b/config/routes.rb index 3bb93268..73b361ce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -128,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 041df177e5969bb1b252b44f32d8d3f28339ced3..acef6aa79d6c19cf0bb0d215a80225ad58500e81 100644 GIT binary patch delta 79 zcmV-V0I>hojsew<0gx~l!SYa9`UrJ%Wn?XFWo^Qs@f-mD0Q(gIlOPHgkzXDI&n7jI lfG`pfF*G?iG&eUgG&e3aIXE>qII+WvMhKKTSDj!bdc?;x9Bu#r delta 80 zcmV-W0I&bmjsez=0gx~lXYf#2`UrJ%Wn?XFWo^O`u^RyX0Q(gIlOGBfkzXDItLZC| mfG`shF*G?iG&eRjG%_wRGBYqYH#xDwi$(|>It&-MQ&#t<=^H`-