From 1ef88c4e7042fe9f547af4506247aa77cbaf392a Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 13 Jun 2017 14:37:23 +0630 Subject: [PATCH 1/3] update --- app/views/origami/payments/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index f9ae06b7..c23a17cf 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -6,8 +6,8 @@
- - + + From 8a7c1f0d888c71287e37bd907d0ad0b53d9475ff Mon Sep 17 00:00:00 2001 From: Phyo Date: Tue, 13 Jun 2017 16:05:20 +0630 Subject: [PATCH 2/3] Payment Vs Tax --- .../origami/redeem_payments_controller.rb | 20 ++++++++++++++++++- app/views/origami/payments/show.html.erb | 2 +- .../origami/redeem_payments/index.html.erb | 7 +++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index b68fd30a..1f650e36 100644 --- a/app/controllers/origami/redeem_payments_controller.rb +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -4,7 +4,25 @@ class Origami::RedeemPaymentsController < BaseOrigamiController payment_method = params[:payment_method] @membership_rebate_balance=0 sale_data = Sale.find_by_sale_id(@sale_id) - @food_prices, @beverage_prices = SaleItem.calculate_food_beverage(sale_data.sale_items) + + # limit redeem_amount + food_prices, beverage_prices = SaleItem.calculate_food_beverage(sale_data.sale_items) + @payparcount = 0 + others = 0 + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "paypar" + @payparcount = @payparcount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + is_bervage_exceed = others - (beverage_prices + sale_data.total_tax) + if is_bervage_exceed < 0 + @food_prices = food_prices - @payparcount + else + @food_prices = food_prices - @payparcount -is_bervage_exceed + end + if sale_data if sale_data.customer_id customer_data= Customer.find_by_customer_id(sale_data.customer_id) diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index a47fb64f..f582007a 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -253,6 +253,6 @@ function update_balance(){ var amount_due = $('#amount_due').text(); var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) var result = amount_due - total - $('#balance').text(result); + $('#balance').text(result.toFixed(2)); } diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index ae714bea..7936e66a 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -18,8 +18,11 @@
-

You can rebate upto <%= @food_prices %>

+ <% if @payparcount > 0 %> +

Last time rebate amount is <%= @payparcount %>

+ <% end %> +

You can rebate upto <%= @food_prices %>

@@ -117,7 +120,7 @@ $("#redeem").click(function(){ valid_amount = $("#valid_amount").val(); sale_id = $("#valid_amount").attr('data-value'); membership_id = $("#valid_amount").attr('data-member-value'); - redeem_amount = parseInt($("#used_amount").text()); + redeem_amount = parseFloat($("#used_amount").text()); if(redeem_amount<=0 ){ alert("Please type valid amount"); From 19160a96308623723a12e5124de17a48a333fd67 Mon Sep 17 00:00:00 2001 From: Moe Su Date: Tue, 13 Jun 2017 17:41:50 +0630 Subject: [PATCH 3/3] Change redeem name --- app/views/origami/redeem_payments/index.html.erb | 4 ++-- config/routes.rb | 2 +- db/seeds.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index ae714bea..50ae6ee1 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -5,14 +5,14 @@
- +

- +
0.0

diff --git a/config/routes.rb b/config/routes.rb index c4592d6d..697b4741 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -95,7 +95,7 @@ Rails.application.routes.draw do get 'sale/:sale_id/payment/others_payment/MPU' => "mpu#index" post 'payment/mpu' => "mpu#create" - get 'sale/:sale_id/payment/others_payment/REDEEM' => "redeem_payments#index" + get 'sale/:sale_id/payment/others_payment/Redeem' => "redeem_payments#index" #---------Add Customer --------------# #resources :customers diff --git a/db/seeds.rb b/db/seeds.rb index 1e3e30b1..4d241119 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -156,7 +156,7 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance", payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http//192.168.1.47:3006"}) -payment_methods = PaymentMethodSetting.create({payment_method:"REDEEM",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) +payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) # shop = Shop.create(
Receipt No : <%=@sale_data.receipt_no rescue ' '%>Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>Receipt No : <%=@sale_data.receipt_no rescue ' '%>Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
Table No <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %>