update member discount
This commit is contained in:
@@ -127,26 +127,34 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
|
|
||||||
# Member Discount
|
# Member Discount
|
||||||
def member_discount
|
def member_discount
|
||||||
|
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
# account_types = JSON.parse(params[:account_types])
|
is_card = params[:is_card]
|
||||||
account_types = Account.where("discount=?",true)
|
|
||||||
sub_total = params[:sub_total]
|
sub_total = params[:sub_total]
|
||||||
sale = Sale.find(sale_id)
|
sale = Sale.find(sale_id)
|
||||||
price = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
|
||||||
|
|
||||||
arr = Array.new;
|
# Check for Card Payment
|
||||||
|
is_card_payment = SaleItem.get_sale_payments_by_card(sale.sale_payments)
|
||||||
|
|
||||||
|
if is_card_payment != true
|
||||||
|
account_types = Account.where("discount=?",true)
|
||||||
|
table_id = sale.bookings[0].dining_facility_id
|
||||||
|
table_type = DiningFacility.find(table_id).type
|
||||||
|
|
||||||
|
# Get Prices for each accounts (eg: food, beverage)
|
||||||
|
account_price = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||||
|
acc_prices = Array.new;
|
||||||
|
|
||||||
account_types.each do |at|
|
account_types.each do |at|
|
||||||
price.each do |pc|
|
account_price.each do |pc|
|
||||||
if pc[:name] == at.title && pc[:price]>0
|
if pc[:name] == at.title && pc[:price]>0
|
||||||
str={type:pc[:name],amount:pc[:price]}
|
str={type:pc[:name],amount:pc[:price]}
|
||||||
arr.push(str)
|
acc_prices.push(str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
generic_customer_id = sale.customer.membership_id
|
generic_customer_id = sale.customer.membership_id
|
||||||
|
|
||||||
receipt_no = sale.receipt_no
|
receipt_no = sale.receipt_no
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
memberaction = MembershipAction.find_by_membership_type("member_discount")
|
memberaction = MembershipAction.find_by_membership_type("member_discount")
|
||||||
@@ -156,7 +164,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
|
||||||
# Check for items for Paypar Cloud
|
# Check for items for Paypar Cloud
|
||||||
if arr.length > 0
|
if acc_prices.length > 0
|
||||||
begin
|
begin
|
||||||
response = HTTParty.post(url,
|
response = HTTParty.post(url,
|
||||||
:body => { account_no: nil,
|
:body => { account_no: nil,
|
||||||
@@ -164,31 +172,29 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
campaign_type_id: campaign_type_id,
|
campaign_type_id: campaign_type_id,
|
||||||
receipt_no: receipt_no,
|
receipt_no: receipt_no,
|
||||||
merchant_uid:merchant_uid,
|
merchant_uid:merchant_uid,
|
||||||
campaign_method:arr.to_json,
|
campaign_method:acc_prices.to_json,
|
||||||
total_sale_transaction_amount: sale.grand_total,
|
total_sale_transaction_amount: sale.grand_total,
|
||||||
|
is_card: is_card,
|
||||||
auth_token:auth_token}.to_json,
|
auth_token:auth_token}.to_json,
|
||||||
:headers => {
|
:headers => {
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
'Accept' => 'application/json'
|
'Accept' => 'application/json'
|
||||||
}, :timeout => 10)
|
}, :timeout => 10)
|
||||||
rescue HTTParty::Error
|
rescue HTTParty::Error
|
||||||
response = {:status=> false, :message => "Can't open membership server " }
|
response = {"status": false, "message": "Can't open membership server " }
|
||||||
|
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = {:status=> false, :message => "Can't open membership server " }
|
response = {"status": false, "message": "Can't open membership server " }
|
||||||
rescue OpenURI::HTTPError
|
rescue OpenURI::HTTPError
|
||||||
response = {:status=> false, :message => "Can't open membership server " }
|
response = {"status": false, "message": "Can't open membership server " }
|
||||||
|
|
||||||
rescue SocketError
|
rescue SocketError
|
||||||
response = {:status=> false, :message => "Can't open membership server " }
|
response = {"status": false, "message": "Can't open membership server " }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
response = {:status=> false, :message => "You have no selected discount item" }
|
response = {"status": false, "message": "You have no selected discount item" }
|
||||||
end
|
end
|
||||||
|
|
||||||
table_id = sale.bookings[0].dining_facility_id
|
|
||||||
table_type = DiningFacility.find(table_id).type
|
|
||||||
|
|
||||||
# Re-calc All Amount in Sale
|
# Re-calc All Amount in Sale
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
discount_amount = response["discount_earned"]
|
discount_amount = response["discount_earned"]
|
||||||
@@ -197,18 +203,15 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount')
|
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount')
|
||||||
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
|
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
|
||||||
end
|
elsif response["status"] == "500"
|
||||||
|
|
||||||
if response["status"] == "500"
|
|
||||||
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
||||||
end
|
else
|
||||||
if !response.nil?
|
result = {:status=> response["message"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
||||||
if response[:status] == false
|
|
||||||
result = {:status=> response[:message],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
render :json => result.to_json
|
render :json => result.to_json
|
||||||
|
|
||||||
|
end #end Is Card Payment
|
||||||
end
|
end
|
||||||
|
|
||||||
#discount for selected order
|
#discount for selected order
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ class Origami::JcbController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
@can_jcb = total - @jcbcount - others
|
@can_jcb = total - @jcbcount - others
|
||||||
|
|
||||||
|
@member_discount = MembershipSetting.find_by_discount(1)
|
||||||
|
@sub_total = sale_data.total_amount
|
||||||
|
@membership_id = sale_data.customer.membership_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ class Origami::MasterController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
@can_master = total - @mastercount - others
|
@can_master = total - @mastercount - others
|
||||||
|
@member_discount = MembershipSetting.find_by_discount(1)
|
||||||
|
@sub_total = sale_data.total_amount
|
||||||
|
@membership_id = sale_data.customer.membership_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class Origami::MpuController < BaseOrigamiController
|
|||||||
total = sale_data.grand_total
|
total = sale_data.grand_total
|
||||||
@mpucount = 0
|
@mpucount = 0
|
||||||
others = 0
|
others = 0
|
||||||
|
|
||||||
sale_data.sale_payments.each do |sale_payment|
|
sale_data.sale_payments.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "mpu"
|
if sale_payment.payment_method == "mpu"
|
||||||
@mpucount = @mpucount + sale_payment.payment_amount
|
@mpucount = @mpucount + sale_payment.payment_amount
|
||||||
@@ -17,6 +18,9 @@ class Origami::MpuController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
@can_mpu = total - @mpucount - others
|
@can_mpu = total - @mpucount - others
|
||||||
|
|
||||||
|
@member_discount = MembershipSetting.find_by_discount(1)
|
||||||
|
@sub_total = sale_data.total_amount
|
||||||
|
@membership_id = sale_data.customer.membership_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
def show
|
def show
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
|
|
||||||
|
@member_discount = MembershipSetting.find_by_discount(1)
|
||||||
|
|
||||||
if Sale.exists?(sale_id)
|
if Sale.exists?(sale_id)
|
||||||
@cash = 0.0
|
@cash = 0.0
|
||||||
@other = 0.0
|
@other = 0.0
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ class Origami::VisaController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
@can_visa = total - @visacount - others
|
@can_visa = total - @visacount - others
|
||||||
|
@member_discount = MembershipSetting.find_by_discount(1)
|
||||||
|
@sub_total = sale_data.total_amount
|
||||||
|
@membership_id = sale_data.customer.membership_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|||||||
@@ -107,7 +107,17 @@ class SaleItem < ApplicationRecord
|
|||||||
return price,type
|
return price,type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check for Card Payment
|
||||||
|
def self.get_sale_payments_by_card(sale_payments)
|
||||||
|
|
||||||
|
# Check for Card Payment
|
||||||
|
sale_payments.each do |sp|
|
||||||
|
if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master"
|
||||||
|
return true;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
# def self.get_overall_discount(sale_id)
|
# def self.get_overall_discount(sale_id)
|
||||||
# price = 0.0
|
# price = 0.0
|
||||||
# item=SaleItem.where("product_code=?", sale_id)
|
# item=SaleItem.where("product_code=?", sale_id)
|
||||||
|
|||||||
@@ -263,6 +263,8 @@ class SalePayment < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sale_update_payment_status(paid_amount)
|
def sale_update_payment_status(paid_amount)
|
||||||
|
puts paid_amount
|
||||||
|
puts "parid Masssssssssssssssssssssssssssssssssssssssss"
|
||||||
#update amount_outstanding
|
#update amount_outstanding
|
||||||
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
||||||
self.sale.save!
|
self.sale.save!
|
||||||
|
|||||||
@@ -510,7 +510,7 @@ $(document).ready(function(){
|
|||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
data: params,
|
data: params,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
|
console.log(result)
|
||||||
if (result.status == "Success") {
|
if (result.status == "Success") {
|
||||||
type = 'green'
|
type = 'green'
|
||||||
btn_color = 'btn-green'
|
btn_color = 'btn-green'
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
<h2>JCB</h2>
|
<h2>JCB</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<span class="hidden" id="membership_id"><%= @membership_id%></span>
|
||||||
|
<span class="hidden" id="member_discount"><%= @member_discount%></span>
|
||||||
|
<span class="hidden" id="sub-total"><%= @sub_total%></span>
|
||||||
<div class="card" style="margin-top:10px;padding-top:20px;">
|
<div class="card" style="margin-top:10px;padding-top:20px;">
|
||||||
<div class="rebate-form">
|
<div class="rebate-form">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -96,12 +99,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||||
else {
|
else {
|
||||||
$('#validamount').attr("value",parseFloat("<%= @can_jcb %>") - parseFloat(localStorage.getItem("cash")));
|
$('#validamount').attr("value",parseFloat("<%= @can_jcb %>") - parseFloat(localStorage.getItem("cash")));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// number key pad
|
// number key pad
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@@ -148,10 +151,24 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$('#jcb_pay').on('click',function(){
|
$('#jcb_pay').on('click',function(){
|
||||||
var amount = $('#amount').text();
|
var amount = $('#amount').text();
|
||||||
var sale_id = "<%= @sale_id %>";
|
var sale_id = "<%= @sale_id %>";
|
||||||
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
|
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
|
||||||
|
//start member discount 5% by pay card
|
||||||
|
var sub_total = $('#sub-total').text();
|
||||||
|
var member_id = $('#membership_id').text();
|
||||||
|
var member_discount = $('#member_discount').text();
|
||||||
|
if (member_id && member_discount) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/origami/" + sale_id + "/member_discount",
|
||||||
|
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
|
||||||
|
// success:function(result){
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//end member discount
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_jcb_path %>",
|
url: "<%= origami_payment_jcb_path %>",
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
@@ -165,5 +182,5 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
}else{
|
}else{
|
||||||
alert("Paid Amount is over!");
|
alert("Paid Amount is over!");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
<h2>Master</h2>
|
<h2>Master</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<span class="hidden" id="membership_id"><%= @membership_id%></span>
|
||||||
|
<span class="hidden" id="member_discount"><%= @member_discount%></span>
|
||||||
|
<span class="hidden" id="sub-total"><%= @sub_total%></span>
|
||||||
<div class="card" style="margin-top:10px;padding-top:20px;">
|
<div class="card" style="margin-top:10px;padding-top:20px;">
|
||||||
<div class="rebate-form">
|
<div class="rebate-form">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -39,11 +42,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:75px;">
|
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:75px;">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-6 col-md-1 col-sm-1">
|
<div class="col-lg-6 col-md-1 col-sm-1">
|
||||||
@@ -88,21 +91,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||||
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment/others_payment';"> Back </button>
|
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment/others_payment';"> Back </button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||||
else {
|
else {
|
||||||
$('#validamount').attr("value",parseFloat("<%= @can_master %>") - parseFloat(localStorage.getItem("cash")));
|
$('#validamount').attr("value",parseFloat("<%= @can_master %>") - parseFloat(localStorage.getItem("cash")));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if(event.handled !== true) {
|
if(event.handled !== true) {
|
||||||
@@ -149,6 +152,20 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
var amount = $('#amount').text();
|
var amount = $('#amount').text();
|
||||||
var sale_id = "<%= @sale_id %>";
|
var sale_id = "<%= @sale_id %>";
|
||||||
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
|
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
|
||||||
|
//start member discount 5% by pay card
|
||||||
|
var sub_total = $('#sub-total').text();
|
||||||
|
var member_id = $('#membership_id').text();
|
||||||
|
var member_discount = $('#member_discount').text();
|
||||||
|
if (member_id && member_discount) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/origami/" + sale_id + "/member_discount",
|
||||||
|
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
|
||||||
|
// success:function(result){
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//end member discount
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_master_path %>",
|
url: "<%= origami_payment_master_path %>",
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
<h2>MPU</h2>
|
<h2>MPU</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<span class="hidden" id="membership_id"><%= @membership_id%></span>
|
||||||
|
<span class="hidden" id="member_discount"><%= @member_discount%></span>
|
||||||
|
<span class="hidden" id="sub-total"><%= @sub_total%></span>
|
||||||
<div class="card" style="margin-top:10px;padding-top:20px;">
|
<div class="card" style="margin-top:10px;padding-top:20px;">
|
||||||
<div class="rebate-form">
|
<div class="rebate-form">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -96,13 +99,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||||
else {
|
else {
|
||||||
$('#validamount').attr("value",parseFloat("<%= @can_mpu %>") - parseFloat(localStorage.getItem("cash")));
|
$('#validamount').attr("value",parseFloat("<%= @can_mpu %>") - parseFloat(localStorage.getItem("cash")));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if(event.handled !== true) {
|
if(event.handled !== true) {
|
||||||
@@ -144,11 +147,26 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#mpu_pay').on('click',function(){
|
$('#mpu_pay').on('click',function(){
|
||||||
var amount = $('#amount').text();
|
var amount = $('#amount').text();
|
||||||
var sale_id = "<%= @sale_id %>";
|
var sale_id = "<%= @sale_id %>";
|
||||||
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
|
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
|
||||||
|
//start member discount 5% by pay card
|
||||||
|
var sub_total = $('#sub-total').text();
|
||||||
|
var member_id = $('#membership_id').text();
|
||||||
|
var member_discount = $('#member_discount').text();
|
||||||
|
if (member_id && member_discount) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/origami/" + sale_id + "/member_discount",
|
||||||
|
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
|
||||||
|
// success:function(result){
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//end member discount
|
||||||
|
//Mpu Payment
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_mpu_path %>",
|
url: "<%= origami_payment_mpu_path %>",
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
@@ -163,4 +181,4 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
alert("Paid Amount is over!")
|
alert("Paid Amount is over!")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<div id="loading_wrapper" style="display:none;">
|
<div id="loading_wrapper" style="display:none;">
|
||||||
<div id="loading"></div>
|
<div id="loading"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-6 col-md-6 col-sm-3">
|
<div class="col-lg-6 col-md-6 col-sm-3">
|
||||||
<div class="card" >
|
<div class="card" >
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div id="order-title">
|
<div id="order-title">
|
||||||
@@ -17,6 +17,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width:50%;"><strong>Customer :</strong> <%= @sale_data.customer.name%></td>
|
<td style="width:50%;"><strong>Customer :</strong> <%= @sale_data.customer.name%></td>
|
||||||
|
<span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span>
|
||||||
|
<span class="hidden" id="member_discount"><%= @member_discount%></span>
|
||||||
<td style="width:50%;"><strong>Customer ID :</strong> <%= @sale_data.customer.customer_id%></td>
|
<td style="width:50%;"><strong>Customer ID :</strong> <%= @sale_data.customer.customer_id%></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -138,7 +140,7 @@
|
|||||||
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
|
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">MPU</div>
|
<div class="col-md-3">MPU</div>
|
||||||
<div class="col-md-4" id="others"><%= @other %></div>
|
<div class="col-md-4 mpu is_card" id="others"><%= @other %></div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="row" style="display:none">
|
<div class="row" style="display:none">
|
||||||
@@ -166,7 +168,7 @@
|
|||||||
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
|
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">Visa</div>
|
<div class="col-md-3">Visa</div>
|
||||||
<div class="col-md-4" id="visacount"><%= @visacount %></div>
|
<div class="col-md-4 visa is_card" id="visacount"><%= @visacount %></div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="row" style="display:none">
|
<div class="row" style="display:none">
|
||||||
@@ -180,7 +182,7 @@
|
|||||||
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
|
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">JCB</div>
|
<div class="col-md-3">JCB</div>
|
||||||
<div class="col-md-4" id="jcbcount"><%= @jcbcount %></div>
|
<div class="col-md-4 jcb is_card" id="jcbcount"><%= @jcbcount %></div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="row" style="display:none">
|
<div class="row" style="display:none">
|
||||||
@@ -194,7 +196,7 @@
|
|||||||
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
|
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">Master</div>
|
<div class="col-md-3">Master</div>
|
||||||
<div class="col-md-4" id="mastercount"><%= @mastercount %></div>
|
<div class="col-md-4 master is_card" id="mastercount"><%= @mastercount %></div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="row" style="display:none">
|
<div class="row" style="display:none">
|
||||||
@@ -260,21 +262,21 @@
|
|||||||
<button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
|
<button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
|
||||||
<button type="button" class="btn btn-primary btn-block" id="foc"> FOC </button>
|
<button type="button" class="btn btn-primary btn-block" id="foc"> FOC </button>
|
||||||
<button type="button" class="btn btn-primary btn-block" id="void"> Void </button>
|
<button type="button" class="btn btn-primary btn-block" id="void"> Void </button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||||
else {
|
else {
|
||||||
$('#cash').text(localStorage.getItem("cash"));
|
$('#cash').text(localStorage.getItem("cash"));
|
||||||
}
|
}
|
||||||
update_balance();
|
update_balance();
|
||||||
})
|
})
|
||||||
|
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
if(event.handled !== true) {
|
if(event.handled !== true) {
|
||||||
var original_value;
|
var original_value;
|
||||||
original_value = $('#cash').text();
|
original_value = $('#cash').text();
|
||||||
@@ -328,9 +330,9 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
// Disable click event cash to prevent
|
// Disable click event cash to prevent
|
||||||
$(".payment .cash-color").off('click');
|
$(".payment .cash-color").off('click');
|
||||||
|
|
||||||
@@ -356,16 +358,23 @@ $( document ).ready(function() {
|
|||||||
alert(" Insufficient Amount!")
|
alert(" Insufficient Amount!")
|
||||||
$( "#loading_wrapper" ).hide();
|
$( "#loading_wrapper" ).hide();
|
||||||
}else{
|
}else{
|
||||||
|
var sale_id = $('#sale_id').text();
|
||||||
|
var item_row = $('.is_card');
|
||||||
|
if (item_row.length < 1) {
|
||||||
|
calculate_member_discount(sale_id);
|
||||||
|
}
|
||||||
|
|
||||||
// payment
|
// payment
|
||||||
var cash = $('#cash').text();
|
var cash = $('#cash').text();
|
||||||
var credit = $('#credit').text();
|
var credit = $('#credit').text();
|
||||||
var card = $('#card').text();
|
var card = $('#card').text();
|
||||||
var sale_id = $('#sale_id').text();
|
|
||||||
|
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_cash_path %>",
|
url: "<%= origami_payment_cash_path %>",
|
||||||
data: "cash="+ cash + "&sale_id=" + sale_id,
|
data: "cash="+ cash + "&sale_id=" + sale_id,
|
||||||
|
async: false,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
|
|
||||||
localStorage.removeItem("cash");
|
localStorage.removeItem("cash");
|
||||||
if (result.status) {
|
if (result.status) {
|
||||||
var msg = result.message;
|
var msg = result.message;
|
||||||
@@ -388,8 +397,7 @@ $( document ).ready(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}else{
|
||||||
else{
|
|
||||||
$('#pay').text("Pay")
|
$('#pay').text("Pay")
|
||||||
$.confirm({
|
$.confirm({
|
||||||
title: 'Infomation!',
|
title: 'Infomation!',
|
||||||
@@ -410,7 +418,7 @@ $( document ).ready(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#void').on('click',function () {
|
$('#void').on('click',function () {
|
||||||
var sure = confirm("Are you sure want to Void");
|
var sure = confirm("Are you sure want to Void");
|
||||||
if (sure == true) {
|
if (sure == true) {
|
||||||
var sale_id = $('#sale_id').text();
|
var sale_id = $('#sale_id').text();
|
||||||
@@ -425,11 +433,11 @@ $('#void').on('click',function () {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function update_balance(){
|
function update_balance(){
|
||||||
var cash = $('#cash').text();
|
var cash = $('#cash').text();
|
||||||
var credit = $('#credit').text();
|
var credit = $('#credit').text();
|
||||||
var card = $('#others').text();
|
var card = $('#others').text();
|
||||||
@@ -441,16 +449,16 @@ function update_balance(){
|
|||||||
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master)
|
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master)
|
||||||
var result = amount_due - total;
|
var result = amount_due - total;
|
||||||
$('#balance').text(result.toFixed(2));
|
$('#balance').text(result.toFixed(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#foc').click(function() {
|
|
||||||
|
|
||||||
|
$('#foc').click(function() {
|
||||||
$( "#loading_wrapper" ).show();
|
$( "#loading_wrapper" ).show();
|
||||||
// payment
|
// payment
|
||||||
var cash = $('#amount_due').text();
|
var cash = $('#amount_due').text();
|
||||||
var sub_total = $('#sub-total').text();
|
var sub_total = $('#sub-total').text();
|
||||||
var sale_id = $('#sale_id').text();
|
var sale_id = $('#sale_id').text();
|
||||||
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total };
|
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total };
|
||||||
|
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_foc_path %>",
|
url: "<%= origami_payment_foc_path %>",
|
||||||
data: params,
|
data: params,
|
||||||
@@ -476,7 +484,23 @@ $('#foc').click(function() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function calculate_member_discount(sale_id) {
|
||||||
|
var sub_total = $('#sub-total').text();
|
||||||
|
var member_id = $('#membership_id').text();
|
||||||
|
var member_discount = $('#member_discount').text();
|
||||||
|
|
||||||
|
if (member_id && member_discount) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/origami/" + sale_id + "/member_discount",
|
||||||
|
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':false },
|
||||||
|
async: false,
|
||||||
|
success:function(result){
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -7,6 +7,9 @@
|
|||||||
<h2>VISA</h2>
|
<h2>VISA</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<span class="hidden" id="membership_id"><%= @membership_id%></span>
|
||||||
|
<span class="hidden" id="member_discount"><%= @member_discount%></span>
|
||||||
|
<span class="hidden" id="sub-total"><%= @sub_total%></span>
|
||||||
<div class="card" style="margin-top:10px;padding-top:20px;">
|
<div class="card" style="margin-top:10px;padding-top:20px;">
|
||||||
<div class="rebate-form">
|
<div class="rebate-form">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -39,11 +42,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:75px;">
|
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:75px;">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-6 col-md-1 col-sm-1">
|
<div class="col-lg-6 col-md-1 col-sm-1">
|
||||||
@@ -88,21 +91,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||||
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment/others_payment';"> Back </button>
|
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment/others_payment';"> Back </button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||||
else {
|
else {
|
||||||
$('#validamount').attr("value",parseFloat("<%= @can_visa %>") - parseFloat(localStorage.getItem("cash")));
|
$('#validamount').attr("value",parseFloat("<%= @can_visa %>") - parseFloat(localStorage.getItem("cash")));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if(event.handled !== true) {
|
if(event.handled !== true) {
|
||||||
@@ -149,6 +152,20 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
var amount = $('#amount').text();
|
var amount = $('#amount').text();
|
||||||
var sale_id = "<%= @sale_id %>";
|
var sale_id = "<%= @sale_id %>";
|
||||||
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value"))){
|
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value"))){
|
||||||
|
//start member discount 5% by pay card
|
||||||
|
var sub_total = $('#sub-total').text();
|
||||||
|
var member_id = $('#membership_id').text();
|
||||||
|
var member_discount = $('#member_discount').text();
|
||||||
|
if (member_id && member_discount) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/origami/" + sale_id + "/member_discount",
|
||||||
|
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':false },
|
||||||
|
// success:function(result){
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//end member discount
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_visa_path %>",
|
url: "<%= origami_payment_visa_path %>",
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user