Merge branch 'august_spring' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
72
app/controllers/origami/voucher_controller.rb
Normal file
72
app/controllers/origami/voucher_controller.rb
Normal file
@@ -0,0 +1,72 @@
|
||||
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]
|
||||
sale_id = params[:refnumber]
|
||||
if(Sale.exists?(sale_id))
|
||||
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
|
||||
if customer_data
|
||||
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
|
||||
91
app/controllers/settings/dining_charges_controller.rb
Normal file
91
app/controllers/settings/dining_charges_controller.rb
Normal file
@@ -0,0 +1,91 @@
|
||||
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
|
||||
@dining_charges = DiningCharge.all
|
||||
end
|
||||
|
||||
# GET /dining_charges/1
|
||||
# GET /dining_charges/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /dining_charges/new
|
||||
def new
|
||||
@dining_charge = DiningCharge.new
|
||||
end
|
||||
|
||||
# GET /dining_charges/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /dining_charges
|
||||
# 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 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 }
|
||||
format.json { render json: @dining_charge.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /dining_charges/1
|
||||
# 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 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 }
|
||||
format.json { render json: @dining_charge.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /dining_charges/1
|
||||
# DELETE /dining_charges/1.json
|
||||
def destroy
|
||||
@dining_charge.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to dining_charges_url, notice: 'Dining charge was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_dining_charge
|
||||
@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.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
|
||||
Reference in New Issue
Block a user