xMerge branch 'august_spring' of bitbucket.org:code2lab/sxrestaurant into august_spring
This commit is contained in:
@@ -22,10 +22,50 @@ class Origami::VoucherController < BaseOrigamiController
|
|||||||
def create
|
def create
|
||||||
cash = params[:amount]
|
cash = params[:amount]
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
|
sale_id = params[:refnumber]
|
||||||
if(Sale.exists?(sale_id))
|
if(Sale.exists?(sale_id))
|
||||||
saleObj = Sale.find(sale_id)
|
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
|
||||||
sale_payment = SalePayment.new
|
if customer_data
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "voucher")
|
membership_id = customer_data.membership_id
|
||||||
|
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
|
if membership_setting.gateway_url
|
||||||
|
member_actions =MembershipAction.find_by_membership_type("get_account_balance") #need to modify here
|
||||||
|
if member_actions.gateway_url
|
||||||
|
campaign_type_id = member_actions.additional_parameter["campaign_type_id"]
|
||||||
|
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||||
|
merchant_uid= member_actions.merchant_account_id
|
||||||
|
auth_token = member_actions.auth_token.to_s
|
||||||
|
# membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
|
||||||
|
# if membership_data["status"]==true
|
||||||
|
begin
|
||||||
|
response = HTTParty.get(url,
|
||||||
|
:body => { app_token: token,membership_id:membership_id,
|
||||||
|
campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,
|
||||||
|
auth_token:auth_token
|
||||||
|
}.to_json,
|
||||||
|
:headers => {
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
'Accept' => 'application/json'
|
||||||
|
}, :timeout => 10
|
||||||
|
)
|
||||||
|
rescue Net::OpenTimeout
|
||||||
|
response = { status: false }
|
||||||
|
|
||||||
|
rescue OpenURI::HTTPError
|
||||||
|
response = { status: false}
|
||||||
|
|
||||||
|
rescue SocketError
|
||||||
|
response = { status: false}
|
||||||
|
end
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if( response["status"]==true )
|
||||||
|
saleObj = Sale.find(sale_id)
|
||||||
|
sale_payment = SalePayment.new
|
||||||
|
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "voucher")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,41 @@
|
|||||||
class DiningCharge < ApplicationRecord
|
class DiningCharge < ApplicationRecord
|
||||||
belongs_to :table
|
belongs_to :table
|
||||||
belongs_to :room
|
belongs_to :room
|
||||||
|
|
||||||
|
def amount_calculate(dining_charges_obj, checkin , checkout)
|
||||||
|
|
||||||
|
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
|
||||||
|
|
||||||
|
minutes = ((checkin - checkout) * 24 * 60).to_i # stay minutes
|
||||||
|
dining_minutes = minutes - dining_charges_obj.minimum_free_time # stayminutes - free minutes
|
||||||
|
charge_type = dining_charges_obj.charge_type
|
||||||
|
if charge_type == 'hr'
|
||||||
|
|
||||||
|
elsif charge_type == 'day'
|
||||||
|
price = charge_by_day
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def charge_by_hour
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def charge_by_day(chargesObj, dining_minutes)
|
||||||
|
minues_per_day = 12 * 60
|
||||||
|
result = dining_minutes / minues_per_day
|
||||||
|
if result < 1
|
||||||
|
return chargesObj.unit_price
|
||||||
|
elsif result > 1
|
||||||
|
solid_price = result * chargesObj.unit_price
|
||||||
|
|
||||||
|
remain_value = dining_minutes % minues_per_day
|
||||||
|
roundingblock = remain_value / chargesObj.time_rounding_block
|
||||||
|
if roundingblock > 1
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,14 +28,15 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
<label class="col-lg-4 col-md-4 col-sm-4">Reference Number</label>
|
<label class="col-lg-4 col-md-4 col-sm-4">Reference Number</label>
|
||||||
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
|
<input type="text" name="valid_amount" id="<%=@sale_id %>" class="form-control col-lg-7 col-md-7 col-sm-7 float-value" value="" data-value="<%=@sale_id %>" data-member-value="">
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
<label class="col-lg-4 col-md-4 col-sm-4">Amount</label>
|
<label class="col-lg-4 col-md-4 col-sm-4">Amount</label>
|
||||||
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
<!-- <div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div> -->
|
||||||
|
<input type="text" name="" id="amount" class="form-control col-lg-7 col-md-7 col-sm-7 float-value" value="" data-value="amount" data-member-value="">
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
@@ -103,12 +104,17 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// number key pad
|
// number key pad
|
||||||
|
var float_value = ""
|
||||||
|
var total = 0
|
||||||
|
|
||||||
|
$(document).on('focusout', '.float-value', function(event){
|
||||||
|
float_value = $(this).attr("data-value");
|
||||||
$(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) {
|
||||||
var original_value;
|
var original_value;
|
||||||
original_value = $('#amount').text();
|
original_value = $('#'+float_value).val();
|
||||||
|
|
||||||
var input_value = $(this).attr("data-value");
|
var input_value = $(this).attr("data-value");
|
||||||
|
|
||||||
@@ -116,28 +122,28 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
switch (input_type) {
|
switch (input_type) {
|
||||||
case 'num':
|
case 'num':
|
||||||
if (original_value == "0.0"){
|
if (original_value == "0.0"){
|
||||||
$('#amount').text(input_value);
|
$('#'+float_value).val(input_value);
|
||||||
}else{
|
}else{
|
||||||
$('#amount').append(input_value);
|
$('#'+float_value).val(original_value+input_value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'add':
|
case 'add':
|
||||||
var input_value = $(this).attr("data-value");
|
var input_value = $(this).attr("data-value");
|
||||||
amount = parseInt(input_value) + parseInt(original_value);
|
amount = parseInt(input_value) + parseInt(original_value);
|
||||||
$('#amount').html(amount);
|
$('#'+float_value).val(amount);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'clr':
|
case 'clr':
|
||||||
$('#amount').html("0.0");
|
$('#'+float_value).val("0.0");
|
||||||
break;
|
break;
|
||||||
case 'del' :
|
case 'del' :
|
||||||
var cash=$('#amount').text();
|
var cash=$('#'+float_value).val();
|
||||||
$('#amount').text(cash.substr(0,cash.length-1));
|
$('#'+float_value).val(cash.substr(0,cash.length-1));
|
||||||
break;
|
break;
|
||||||
case 'nett':
|
case 'nett':
|
||||||
var remain_amount = $('#validamount').val();
|
var remain_amount = $('#validamount').val();
|
||||||
$('#amount').text(remain_amount);
|
$('#'+float_value).val(remain_amount);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -146,15 +152,19 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
$('#voucher_pay').on('click',function(){
|
$('#voucher_pay').on('click',function(){
|
||||||
var amount = $('#amount').text();
|
var amount = $('#amount').val();
|
||||||
|
var refnumber = $("#<%=@sale_id %>").val();
|
||||||
var sale_id = "<%= @sale_id %>";
|
var sale_id = "<%= @sale_id %>";
|
||||||
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
|
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
|
||||||
|
// alert(amount);
|
||||||
|
// alert(refnumber);
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_jcb_path %>",
|
url: "<%= origami_payment_voucher_path %>",
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id+ "&refnumber="+ refnumber,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
if(result){
|
if(result){
|
||||||
alert("Payment success")
|
alert("Payment success")
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<th style="width:20%">Name</th>
|
<th style="width:20%">Name</th>
|
||||||
<th style="width:20%">Role</th>
|
<th style="width:20%">Role</th>
|
||||||
<th style="width:20%">Created At</th>
|
<th style="width:20%">Created At</th>
|
||||||
|
<th style="width:20%">Updated At</th>
|
||||||
<th style="width:20%">Action</th>
|
<th style="width:20%">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
<td><%= link_to employee.name,settings_employee_path(employee) %></td>
|
<td><%= link_to employee.name,settings_employee_path(employee) %></td>
|
||||||
<td><%= employee.role %></td>
|
<td><%= employee.role %></td>
|
||||||
<td><%= employee.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
|
<td><%= employee.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
|
||||||
|
<td><%= employee.updated_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to 'Edit', edit_settings_employee_path(employee) %>
|
<%= link_to 'Edit', edit_settings_employee_path(employee) %>
|
||||||
<%if employee.role != "administrator"%>
|
<%if employee.role != "administrator"%>
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Role</th>
|
<th>Role</th>
|
||||||
|
<th>Created At</th>
|
||||||
|
<th>Updated At</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -24,6 +25,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= @employee.name %></td>
|
<td><%= @employee.name %></td>
|
||||||
<td><%= @employee.role %></td>
|
<td><%= @employee.role %></td>
|
||||||
|
<td><%= @employee.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
|
||||||
|
<td><%= @employee.updated_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to 'Edit', edit_settings_employee_path(@employee) %>
|
<%= link_to 'Edit', edit_settings_employee_path(@employee) %>
|
||||||
</td>
|
</td>
|
||||||
@@ -34,4 +37,3 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ Rails.application.routes.draw do
|
|||||||
post 'payment/visa' => "visa#create"
|
post 'payment/visa' => "visa#create"
|
||||||
post 'payment/paypar' => 'paypar_payments#create'
|
post 'payment/paypar' => 'paypar_payments#create'
|
||||||
post 'payment/credit' => 'credit_payments#create'
|
post 'payment/credit' => 'credit_payments#create'
|
||||||
|
post 'payment/voucher' => 'voucher_payments#create'
|
||||||
|
|
||||||
get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index"
|
get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index"
|
||||||
get 'sale/:sale_id/payment/others_payment' => "others_payments#index"
|
get 'sale/:sale_id/payment/others_payment' => "others_payments#index"
|
||||||
|
|||||||
Reference in New Issue
Block a user