merged loyalty
This commit is contained in:
2
Gemfile
2
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'
|
||||
|
||||
@@ -268,4 +268,4 @@ DEPENDENCIES
|
||||
web-console (>= 3.3.0)
|
||||
|
||||
BUNDLED WITH
|
||||
1.15.0
|
||||
1.15.1
|
||||
|
||||
3
app/assets/javascripts/api/origami/paypar.coffee
Normal file
3
app/assets/javascripts/api/origami/paypar.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/javascripts/origami/paypar.coffee
Normal file
3
app/assets/javascripts/origami/paypar.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/stylesheets/api/origami/paypar.scss
Normal file
3
app/assets/stylesheets/api/origami/paypar.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the api/origami/paypar controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
3
app/assets/stylesheets/origami/paypar.scss
Normal file
3
app/assets/stylesheets/origami/paypar.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the origami/paypar controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
29
app/controllers/origami/card_payments_controller.rb
Normal file
29
app/controllers/origami/card_payments_controller.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
class Origami::CardPaymentsController < BaseOrigamiController
|
||||
|
||||
|
||||
def index
|
||||
@membership_rebate_balance = 0
|
||||
@membership_id = 0
|
||||
if !@membership_id.nil?
|
||||
membership_setting = MembershipSetting.find_by_membership_type("smartpay_url")
|
||||
membership_data = SalePayment.get_paypar_account(membership_setting.gateway_url,membership_setting.auth_token,@membership_id)
|
||||
if membership_data["status"]==true
|
||||
membership_account_data = membership_data["data"];
|
||||
membership_account_data.each do |acc_data|
|
||||
if acc_data["accountable_type"] == "REBATEACCOUNT"
|
||||
@membership_rebate_balance=acc_data["balance"]
|
||||
else
|
||||
@membership_rebate_balance = 0
|
||||
end
|
||||
end
|
||||
else
|
||||
@membership_rebate_balance = 0
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,6 +2,27 @@ class Origami::OthersPaymentsController < BaseOrigamiController
|
||||
|
||||
|
||||
def index
|
||||
@membership_rebate_balance = 0
|
||||
@sale_id = params[:sale_id]
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
|
||||
@membership_id = customer_data.membership_id
|
||||
if !@membership_id.nil?
|
||||
membership_setting = MembershipSetting.find_by_membership_type("smartpay_url")
|
||||
membership_data = SalePayment.get_paypar_account(membership_setting.gateway_url,membership_setting.auth_token,@membership_id)
|
||||
if membership_data["status"]==true
|
||||
membership_account_data = membership_data["data"];
|
||||
membership_account_data.each do |acc_data|
|
||||
if acc_data["accountable_type"] == "REBATEACCOUNT"
|
||||
@membership_rebate_balance=acc_data["balance"]
|
||||
else
|
||||
@membership_rebate_balance = 0
|
||||
end
|
||||
end
|
||||
else
|
||||
@membership_rebate_balance = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
22
app/controllers/origami/paypar_payments_controller.rb
Normal file
22
app/controllers/origami/paypar_payments_controller.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
class Origami::PayparPaymentsController < BaseOrigamiController
|
||||
def create
|
||||
sale_id = params[:sale_id]
|
||||
redeem_amount = params[:redeem_amount]
|
||||
membership_id = params[:membership_id]
|
||||
payment_method = "paypar"
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
status,msg =sale_payment.process_payment(saleObj, @user, redeem_amount,payment_method)
|
||||
|
||||
if status == true
|
||||
@out = true, "Success!"
|
||||
else
|
||||
@out =false, "Please try again payment!"
|
||||
end
|
||||
else
|
||||
@out = false, "There has no sale record!"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
2
app/helpers/api/origami/paypar_helper.rb
Normal file
2
app/helpers/api/origami/paypar_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Api::Origami::PayparHelper
|
||||
end
|
||||
2
app/helpers/origami/paypar_helper.rb
Normal file
2
app/helpers/origami/paypar_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Origami::PayparHelper
|
||||
end
|
||||
@@ -8,12 +8,10 @@ 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)
|
||||
def process_payment(invoice, action_by, cash_amount,payment_method)
|
||||
|
||||
self.sale = invoice
|
||||
self.received_amount = cash_amount
|
||||
|
||||
payment_method = "cash"
|
||||
amount_due = invoice.grand_total
|
||||
|
||||
#get all payment for this invoices
|
||||
@@ -54,7 +52,7 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
|
||||
#record an payment in sale-audit
|
||||
remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{amount} | Payment Status ->#{payment_status}"
|
||||
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.sale
|
||||
@@ -66,6 +64,34 @@ class SalePayment < ApplicationRecord
|
||||
return false, "No outstanding Amount"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def self.get_paypar_account(paypar_url,token,membership_id)
|
||||
url = paypar_url.to_s + "/api/get_membership_data".to_s
|
||||
response = HTTParty.get(url,
|
||||
:body => { app_token: token,membership_id:membership_id}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
}
|
||||
)
|
||||
return response;
|
||||
|
||||
end
|
||||
|
||||
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id,campaign_type_id)
|
||||
url = paypar_url.to_s + "/api/redeem".to_s
|
||||
response = HTTParty.post(url,
|
||||
:body => { generic_customer_id:membership_id,total_amount:received_amount,receipet_no:sale_id,campaign_type_id:campaign_type_id,account_no:""}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
}
|
||||
)
|
||||
puts "RRRRRRRR"
|
||||
puts response.to_json
|
||||
return response;
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
@@ -148,15 +174,38 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
|
||||
def paypar_payment
|
||||
##TODO - Integration with Paypar (SmartPay)
|
||||
puts "Paypar Payment"
|
||||
payment_status = false
|
||||
|
||||
#Next time - validate if the vochure number is valid - within
|
||||
self.payment_method = "paypar"
|
||||
self.payment_amount = self.received_amount
|
||||
self.payment_reference = self.voucher_no
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "pending"
|
||||
payment_method = self.save!
|
||||
|
||||
campaign_type_id =1;
|
||||
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
||||
membership_setting = MembershipSetting.find_by_membership_type("smartpay_url")
|
||||
membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id,campaign_type_id)
|
||||
if membership_data["status"]==true
|
||||
SalePayment.where(:sale_payment_id => self.sale_payment_id).update_all(:payment_status => 'paid')
|
||||
sale_update_payment_status(self.received_amount.to_f)
|
||||
|
||||
else
|
||||
sale_update_payment_status(0)
|
||||
end
|
||||
|
||||
|
||||
return payment_status
|
||||
|
||||
end
|
||||
|
||||
def sale_update_payment_status(paid_amount)
|
||||
puts "paid_amount"
|
||||
puts paid_amount
|
||||
#update amount_outstanding
|
||||
self.sale.amount_received = self.sale.amount_received + paid_amount
|
||||
self.sale.amount_changed = amount - self.sale.amount_received
|
||||
self.sale.amount_changed = paid_amount - self.sale.amount_received
|
||||
if (self.sale.grand_total <= self.sale.amount_received && self.sale.amount_changed > 0)
|
||||
self.sale.payment_status = "paid"
|
||||
self.sale.sale_status = "completed"
|
||||
|
||||
@@ -1 +1,165 @@
|
||||
Hello Card Payment
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-5 col-md-5 col-sm-3">
|
||||
<div class="card">
|
||||
<% if @membership_id!=0 %>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 long purple " id="redeem_account">Redim Amount</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-7 col-md-7 col-sm-7">
|
||||
<div class="rebate-form" hidden="true">
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="col-lg-4 col-md-4 col-sm-4">Valid Amount</label>
|
||||
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="1000">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="col-lg-4 col-md-4 col-sm-4">Used Amount</label>
|
||||
<div id="used_amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-3 cashier_number" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-3 cashier_number" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="1000" data-type="add">1000</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" data-value="4" data-type="num">4</div>
|
||||
<div class="col-md-3 cashier_number" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-3 cashier_number" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="5000" data-type="add">5000</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-3 cashier_number" data-value="8" data-type="num">8</div>
|
||||
<div class="col-md-3 cashier_number" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="10000" data-type="add">10000</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-3 cashier_number" data-value="." data-type="num">.</div>
|
||||
<div class="col-md-3 cashier_number" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="50000" data-type="add">50000</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number"></div>
|
||||
<div class="col-md-3 cashier_number">DEL</div>
|
||||
<div class="col-md-3 cashier_number">CLR</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long purple" id="redeem" data-value="<%=@sale_id %>" data-member-value = "<%= @membership_id %>">PAY</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).on('click', '.cashier_number', function(event){
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if(event.handled !== true) {
|
||||
var original_value;
|
||||
original_value = $('#used_amount').text();
|
||||
|
||||
var input_value = $(this).attr("data-value");
|
||||
|
||||
var input_type = $(this).attr("data-type");
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
if (original_value == "0.0"){
|
||||
$('#used_amount').text(input_value);
|
||||
}else{
|
||||
$('#used_amount').append(input_value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value) + parseInt(original_value);
|
||||
$('#used_amount').html(amount);
|
||||
|
||||
break;
|
||||
case 'clr':
|
||||
$('#used_amount').html("0.0");
|
||||
break;
|
||||
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$("#redeem_account").click(function(){
|
||||
$('.rebate-form').removeAttr("hidden");
|
||||
});
|
||||
|
||||
$("#redeem").click(function(){
|
||||
valid_amount = $("#valid_amount").val();
|
||||
sale_id = $(this).attr("data-value")
|
||||
membership_id = $(this).attr("data-member-value");
|
||||
redeem_amount = parseInt($("#used_amount").text());
|
||||
if(redeem_amount<=0){
|
||||
alert(" Insufficient Amount!")
|
||||
}else if(valid_amount< redeem_amount){
|
||||
alert("Please type valid amount");
|
||||
}else{
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=origami_paypar_payment_process_path%>",
|
||||
data: {redeem_amount:redeem_amount,membership_id:membership_id,sale_id:sale_id},
|
||||
success: function(result){
|
||||
if(result.status == true){
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment"
|
||||
}else{
|
||||
alert(result.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -218,21 +218,21 @@ $( document ).ready(function() {
|
||||
|
||||
$('#pay').click(function() {
|
||||
|
||||
if($('#balance').text() > 0){
|
||||
alert(" Insufficient Amount!")
|
||||
}else{
|
||||
if($('#balance').text() > 0){
|
||||
alert(" Insufficient Amount!")
|
||||
}else{
|
||||
// payment
|
||||
var cash = $('#cash').text();
|
||||
var credit = $('#credit').text();
|
||||
var card = $('#card').text();
|
||||
var sale_id = $('#sale_id').text();
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_payment_process_path %>",
|
||||
data: "cash="+ cash + "&sale_id=" + sale_id,
|
||||
success:function(result){
|
||||
alert("THANK YOU")
|
||||
}
|
||||
});
|
||||
var cash = $('#cash').text();
|
||||
var credit = $('#credit').text();
|
||||
var card = $('#card').text();
|
||||
var sale_id = $('#sale_id').text();
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_payment_process_path %>",
|
||||
data: "cash="+ cash + "&sale_id=" + sale_id,
|
||||
success:function(result){
|
||||
alert("THANK YOU")
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
2
app/views/origami/paypar_payments/create.json.jbuilder
Normal file
2
app/views/origami/paypar_payments/create.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.set! :status, @out[0]
|
||||
json.set! :message, @out[1]
|
||||
137
app/views/origami/paypar_payments/index.html.erb
Normal file
137
app/views/origami/paypar_payments/index.html.erb
Normal file
@@ -0,0 +1,137 @@
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-5 col-md-5 col-sm-3">
|
||||
<div class="card">
|
||||
<% if @membership_id!=0 %>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 long purple " id="redim">Redim Amount</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-7 col-md-7 col-sm-7">
|
||||
<div class="rebate-form" hidden="true">
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="col-lg-4 col-md-4 col-sm-4">Valid Amount</label>
|
||||
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @membership_rebate_balance %>">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="col-lg-4 col-md-4 col-sm-4">Used Amount</label>
|
||||
<div id="used_amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-3 cashier_number" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-3 cashier_number" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="1000" data-type="add">1000</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" data-value="4" data-type="num">4</div>
|
||||
<div class="col-md-3 cashier_number" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-3 cashier_number" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="5000" data-type="add">5000</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-3 cashier_number" data-value="8" data-type="num">8</div>
|
||||
<div class="col-md-3 cashier_number" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="10000" data-type="add">10000</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-3 cashier_number" data-value="." data-type="num">.</div>
|
||||
<div class="col-md-3 cashier_number" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="50000" data-type="add">50000</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number"></div>
|
||||
<div class="col-md-3 cashier_number">DEL</div>
|
||||
<div class="col-md-3 cashier_number">CLR</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long purple " id="pay">PAY</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).on('click', '.cashier_number', function(event){
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if(event.handled !== true) {
|
||||
var original_value;
|
||||
original_value = $('#used_amount').text();
|
||||
|
||||
var input_value = $(this).attr("data-value");
|
||||
|
||||
var input_type = $(this).attr("data-type");
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
if (original_value == "0.0"){
|
||||
$('#used_amount').text(input_value);
|
||||
}else{
|
||||
$('#used_amount').append(input_value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value) + parseInt(original_value);
|
||||
$('#used_amount').html(amount);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$("#redim").click(function(){
|
||||
$('.rebate-form').removeAttr("hidden");
|
||||
})
|
||||
</script>
|
||||
@@ -79,6 +79,7 @@ Rails.application.routes.draw do
|
||||
#--------- Payment ------------#
|
||||
get 'sale/:sale_id/payment' => 'payments#show'
|
||||
post 'payment_process' => 'payments#create'
|
||||
post 'paypar_payment_process' => 'paypar_payments#create'
|
||||
get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index"
|
||||
get 'sale/:sale_id/payment/others_payment' => "others_payments#index"
|
||||
|
||||
|
||||
10
db/migrate/2017031024747_create_accounts.rb
Normal file
10
db/migrate/2017031024747_create_accounts.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateAccounts < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :accounts do |t|
|
||||
t.string :title
|
||||
t.string :account_type
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
10
db/seeds.rb
10
db/seeds.rb
@@ -140,9 +140,9 @@ admin_employee = Employee.create({name: "Administrator", role: "Administrator",
|
||||
food = Account.create({title: "Food", account_type: "0"})
|
||||
beverage = Account.create({title: "Beverage", account_type: "1"})
|
||||
|
||||
shop = Shop.create(
|
||||
{name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon",
|
||||
country: "Myanmar", phone_no: "09123456789", reservation_no: "bip000001", license: "license",
|
||||
activated_at: "2017-06-06", license_data: "license_data", base_currency: "Ks", id_prefix: "abc"}
|
||||
)
|
||||
# shop = Shop.create(
|
||||
# {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon",
|
||||
# country: "Myanmar", phone_no: "09123456789", reservation_no: "bip000001", license: "license",
|
||||
# activated_at: "2017-06-06", license_data: "license_data", base_currency: "Ks", id_prefix: "abc"}
|
||||
# )
|
||||
|
||||
|
||||
5
spec/controllers/api/origami/paypar_controller_spec.rb
Normal file
5
spec/controllers/api/origami/paypar_controller_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::Origami::PayparController, type: :controller do
|
||||
|
||||
end
|
||||
5
spec/controllers/origami/paypar_controller_spec.rb
Normal file
5
spec/controllers/origami/paypar_controller_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Origami::PayparController, type: :controller do
|
||||
|
||||
end
|
||||
15
spec/helpers/api/origami/paypar_helper_spec.rb
Normal file
15
spec/helpers/api/origami/paypar_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Api::Origami::PayparHelper. For example:
|
||||
#
|
||||
# describe Api::Origami::PayparHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Api::Origami::PayparHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
15
spec/helpers/origami/paypar_helper_spec.rb
Normal file
15
spec/helpers/origami/paypar_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Origami::PayparHelper. For example:
|
||||
#
|
||||
# describe Origami::PayparHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Origami::PayparHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
Reference in New Issue
Block a user