Merge branch 'august_spring' of bitbucket.org:code2lab/sxrestaurant into august_spring

This commit is contained in:
yamin
2017-08-14 10:19:22 +06:30
20 changed files with 315 additions and 30 deletions

View File

@@ -0,0 +1,32 @@
class Origami::VoucherController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
# limit voucher_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
@vouchercount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "voucher"
@vouchercount = @vouchercount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_voucher = total - @vouchercount - 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, "voucher")
end
end
end

View File

@@ -1,6 +1,7 @@
class DiningChargesController < ApplicationController
class Settings::DiningChargesController < ApplicationController
before_action :set_dining_charge, only: [:show, :edit, :update, :destroy]
before_action :set_settings_facility
before_action :set_settings_zone
# GET /dining_charges
# GET /dining_charges.json
def index
@@ -25,10 +26,10 @@ class DiningChargesController < ApplicationController
# POST /dining_charges.json
def create
@dining_charge = DiningCharge.new(dining_charge_params)
@dining_charge.dining_facility_id = @settings_dining_facility.id
respond_to do |format|
if @dining_charge.save
format.html { redirect_to @dining_charge, notice: 'Dining charge was successfully created.' }
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' }
format.json { render :show, status: :created, location: @dining_charge }
else
format.html { render :new }
@@ -41,8 +42,9 @@ class DiningChargesController < ApplicationController
# PATCH/PUT /dining_charges/1.json
def update
respond_to do |format|
@dining_charge.dining_facility_id = @settings_dining_facility.id
if @dining_charge.update(dining_charge_params)
format.html { redirect_to @dining_charge, notice: 'Dining charge was successfully updated.' }
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' }
format.json { render :show, status: :ok, location: @dining_charge }
else
format.html { render :edit }
@@ -67,8 +69,23 @@ class DiningChargesController < ApplicationController
@dining_charge = DiningCharge.find(params[:id])
end
def set_settings_facility
if params[:table_id]
@table = true
@settings_dining_facility = Table.find(params[:table_id])
elsif params[:room_id]
@room = true
@settings_dining_facility = Room.find(params[:room_id])
end
end
def set_settings_zone
@zone = Zone.find(params[:zone_id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def dining_charge_params
params.fetch(:dining_charge, {})
# params.fetch(:dining_charge, {})
params.require(:dining_charge).permit(:item_code, :unit_price, :taxable, :charge_type,:minimum_free_time ,:charge_block,:time_rounding,:time_rounding_block, :zone_id)
end
end

View File

@@ -1,2 +1,4 @@
class DiningCharge < ApplicationRecord
belongs_to :table
belongs_to :room
end

View File

@@ -1,5 +1,6 @@
class DiningFacility < ApplicationRecord
belongs_to :zone
has_many :dining_charges
TABLE_TYPE = "Table"
ROOM_TYPE = "Room"

View File

@@ -1,10 +0,0 @@
<%= simple_form_for(@dining_charge) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>

View File

@@ -1,6 +0,0 @@
<h1>Editing Dining Charge</h1>
<%= render 'form', dining_charge: @dining_charge %>
<%= link_to 'Show', @dining_charge %> |
<%= link_to 'Back', dining_charges_path %>

View File

@@ -1,5 +0,0 @@
<h1>New Dining Charge</h1>
<%= render 'form', dining_charge: @dining_charge %>
<%= link_to 'Back', dining_charges_path %>

View File

@@ -0,0 +1,5 @@
if(@status)
json.status @status
else
json.status false
end

View File

@@ -0,0 +1,169 @@
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-3">
<div class="row">
<div class="col-md-6">
<h2>Voucher / Coupon</h2>
</div>
</div>
<div class="card" style="margin-top:10px;padding-top:20px;">
<div class="rebate-form">
<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">You can pay up to </label>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_voucher %>" data-member-value="">
</div>
<hr>
</div>
<% if @vouchercount != 0 %>
<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">Recent Voucher paid amount </label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@vouchercount %>" data-member-value="">
</div>
<hr>
</div>
<% end %>
<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">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="">
</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">Amount</label>
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:75px;">
<div class="row">
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class=" cashier_number " data-value="1" data-type="num">1</div>
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="4" data-type="num">4</div>
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="7" data-type="num">7</div>
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="0" data-type="num">0</div>
<div class=" cashier_number left" data-value="." data-type="num">.</div>
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class=" cashier_number green" data-type="nett" >Nett</div>
<div class=" cashier_number red left" data-type="del">Del</div>
<div class=" cashier_number orange left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class="cashier_number long" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom">
<div class="cashier_number long" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom">
<div class="pay purple" id="voucher_pay">Pay</div>
</div>
</div>
</div>
</div>
<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>
</div>
</div>
<script>
$(document).ready(function() {
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_voucher %>") - parseFloat(localStorage.getItem("cash")));
}
});
// number key pad
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#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"){
$('#amount').text(input_value);
}else{
$('#amount').append(input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#amount').html(amount);
break;
case 'clr':
$('#amount').html("0.0");
break;
case 'del' :
var cash=$('#amount').text();
$('#amount').text(cash.substr(0,cash.length-1));
break;
case 'nett':
var remain_amount = $('#validamount').val();
$('#amount').text(remain_amount);
break;
}
event.handled = true;
} else {
return false;
}
});
$('#voucher_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
$.ajax({type: "POST",
url: "<%= origami_payment_jcb_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
alert("Payment success")
window.location.href = '/origami/sale/'+ sale_id + "/payment";
}
}
});
}else{
alert("Paid Amount is over!");
}
})
</script>

View File

@@ -0,0 +1,18 @@
<%= simple_form_for([:settings,@zone,@settings_dining_facility,@dining_charge]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :item_code %>
<%= f.input :unit_price %>
<%= f.input :taxable %>
<%= f.input :charge_type %>
<%= f.input :minimum_free_time %>
<%= f.input :charge_block %>
<%= f.input :time_rounding %>
<%= f.input :time_rounding_block %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>

View File

@@ -0,0 +1,19 @@
<!-- <h1>Editing Dining Charge</h1>
<%= render 'form', dining_charge: @dining_charge %>-->
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= root_path %>">Home</a></li>
<li><a href="<%= settings_zone_path(@zone) %>">Zone</a></li>
<% if @table %>
<li><a href="<%= edit_settings_zone_table_path(@zone,@settings_dining_facility) %>">Table / Room</a></li>
<% elsif @room %>
<li><a href="<%= edit_settings_zone_room_path(@zone,@settings_dining_facility) %>">Table / Room</a></li>
<% end %>
<li>New</li>
</ul>
</div>
<%= render 'form', dining_charge: @dining_charge %>
</div>

View File

@@ -0,0 +1,18 @@
<!-- <h1>New Dining Charge</h1>
<%= render 'form', dining_charge: @dining_charge %> -->
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= root_path %>">Home</a></li>
<li><a href="<%= settings_zone_path(@zone) %>">Zone</a></li>
<% if @table %>
<li><a href="<%= edit_settings_zone_table_path(@zone,@settings_dining_facility) %>">Table / Room</a></li>
<% elsif @room %>
<li><a href="<%= edit_settings_zone_room_path(@zone,@settings_dining_facility) %>">Table / Room</a></li>
<% end %>
<li>New</li>
</ul>
</div>
<%= render 'form', dining_charge: @dining_charge %>
</div>

View File

@@ -7,6 +7,26 @@
<%= f.input :seater %>
<%= f.input :order_by %>
<%= f.input :is_active %>
<% if @settings_table.dining_charges.length == 0 %>
<div class="div-border">
<div class="col-md-10">
<%= link_to 'Add For Extra Charges', new_settings_zone_table_dining_charge_path(@zone,@settings_table),:class => 'btn btn-primary' %>
</div>
</div>
<% else %>
<% @settings_table.dining_charges.each do |dc| %>
<div class="div-border">
<div class="col-md-10"><b><u>Dining Charge</u></b></div>
<div class="col-md-10">item code : <%= dc.item_code %></div>
<div class="col-md-10">Unit price : <%= dc.unit_price %></div>
<div class="col-md-10">Charge type : <%= dc.charge_type %></div>
<div class="col-md-10">
<%= link_to 'Edit Charges', edit_settings_zone_table_dining_charge_path(@zone,@settings_table,dc),:class => 'btn btn-primary' %>
<!-- <button class="btn btn-primary" src="<%= edit_settings_zone_table_dining_charge_path(@zone,@settings_table,dc) %>">Edit Charge</button> -->
</div>
</div>
<% end %>
<% end %>
</div>
<div class="form-actions">

View File

@@ -2,7 +2,6 @@ require 'sidekiq/web'
Rails.application.routes.draw do
resources :dining_charges
root 'home#index'
mount Sidekiq::Web => '/kiq'
@@ -146,6 +145,7 @@ Rails.application.routes.draw do
get 'sale/:sale_id/payment/others_payment/Master' => "master#index"
get 'sale/:sale_id/payment/others_payment/JCB' => "jcb#index"
get 'sale/:sale_id/payment/others_payment/Redeem' => "redeem_payments#index"
get 'sale/:sale_id/payment/others_payment/Voucher' => "voucher#index"
#---------Void --------------#
post 'sale/:sale_id/void' => 'void#overall_void'
@@ -254,9 +254,13 @@ Rails.application.routes.draw do
#zones
resources :zones do
#tables
resources :tables
resources :tables do
resources :dining_charges
end
#rooms
resources :rooms
resources :rooms do
resources :dining_charges
end
end
end

View File

@@ -1224,6 +1224,7 @@ payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url
payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://staging.membership.paypar.ws"})
payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://staging.membership.paypar.ws"})
payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://staging.membership.paypar.ws",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv"})
payment_methods = PaymentMethodSetting.create({payment_method:"Voucher",gateway_url: "http://staging.membership.paypar.ws",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv"})
#Default Order Queue stations
order_queue_station1 = OrderQueueStation.create({station_name: "K1", is_active: true,printer_name: "Cashier", processing_items: JSON.generate(['I0001','I0002','I0003','I0004']), print_copy:false, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})