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

This commit is contained in:
yamin
2017-08-23 15:04:34 +06:30
26 changed files with 707 additions and 647 deletions

View File

@@ -1,91 +0,0 @@
class Origami::CommissionsController < BaseOrigamiController
before_action :set_commission, only: [:show, :edit, :update, :destroy]
# GET /commissions
# GET /commissions.json
def index
@commissions = Commission.all
end
# GET /commissions/1
# GET /commissions/1.json
def show
end
# GET /commissions/new
def new
@commission = Commission.new
@products = MenuItem.all
end
# GET /commissions/1/edit
def edit
@products = MenuItem.all
end
# POST /commissions
# POST /commissions.json
def create
@commission = Commission.new(commission_params)
respond_to do |format|
if @commission.save
format.html { redirect_to origami_commissions_path , notice: 'Commission was successfully created.' }
format.json { render :show, status: :created, location: @commission }
else
format.html { render :new }
format.json { render json: @commission.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /commissions/1
# PATCH/PUT /commissions/1.json
def update
respond_to do |format|
if @commission.update(commission_params)
format.html { redirect_to origami_commission_path(@commission), notice: 'Commission was successfully updated.' }
format.json { render :show, status: :ok, location: @commission }
else
format.html { render :edit }
format.json { render json: @commission.errors, status: :unprocessable_entity }
end
end
end
# DELETE /commissions/1
# DELETE /commissions/1.json
def destroy
@commission.destroy
respond_to do |format|
format.html { redirect_to origami_commissions_path, notice: 'Commission was successfully destroyed.' }
format.json { head :no_content }
end
end
def load_commissioners
sale_id = params[:sale_id]
@table_id = params[:table_id]
@saleobj = Sale.find(sale_id)
@commissioners = []
end
def select_sale_item
byebug
sale_item_id = params[:sale_item_id]
@sale_item = SaleItem.find_by_sale_item_id(sale_item_id)
@commissioners = Commissioner.active.all
end
private
# Use callbacks to share common setup or constraints between actions.
def set_commission
@commission = Commission.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def commission_params
params.require(:commission).permit(:product_id,:amount,:commission_type, :is_active)
end
end

View File

@@ -0,0 +1,74 @@
class Origami::InJutiesController < BaseOrigamiController
before_action :set_in_juty, only: [:show, :edit, :update, :destroy]
# GET /in_juties
# GET /in_juties.json
def index
@in_juties = InJuty.all
end
# GET /in_juties/1
# GET /in_juties/1.json
def show
end
# GET /in_juties/new
def new
@in_juty = InJuty.new
end
# GET /in_juties/1/edit
def edit
end
# POST /in_juties
# POST /in_juties.json
def create
@in_juty = InJuty.new(in_juty_params)
respond_to do |format|
if @in_juty.save
format.html { redirect_to @in_juty, notice: 'In juty was successfully created.' }
format.json { render :show, status: :created, location: @in_juty }
else
format.html { render :new }
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /in_juties/1
# PATCH/PUT /in_juties/1.json
def update
respond_to do |format|
if @in_juty.update(in_juty_params)
format.html { redirect_to @in_juty, notice: 'In juty was successfully updated.' }
format.json { render :show, status: :ok, location: @in_juty }
else
format.html { render :edit }
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
end
end
end
# DELETE /in_juties/1
# DELETE /in_juties/1.json
def destroy
@in_juty.destroy
respond_to do |format|
format.html { redirect_to in_juties_url, notice: 'In juty was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_in_juty
@in_juty = InJuty.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def in_juty_params
params.fetch(:in_juty, {})
end
end

View File

@@ -0,0 +1,2 @@
module Origami::InJutiesHelper
end

View File

@@ -3,19 +3,22 @@ class DiningCharge < ApplicationRecord
belongs_to :room
def self.amount_calculate(dining_charges_obj, checkin , checkout)
# note :: the first Charge Block will cost all, the Time rounding block will included in 2nd Charge Block
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
price = 0
minutes = DiningCharge.time_diff(checkout, checkin)
free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.strftime('%H:%M'))
free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.utc.localtime.strftime('%H:%M'))
dining_minutes = minutes - free_time # stayminutes - free minutes
charge_type = dining_charges_obj.charge_type
if charge_type == 'hr'
price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
elsif charge_type == 'day'
price = charges(dining_charges_obj, dining_minutes, 'day')
if dining_minutes <= 0
price = 0
else
charge_type = dining_charges_obj.charge_type
if charge_type == 'hr'
price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
elsif charge_type == 'day'
price = charges(dining_charges_obj, dining_minutes, 'day')
end
end
return price
else
puts "<<<<<<<< NO"
@@ -25,14 +28,15 @@ class DiningCharge < ApplicationRecord
def self.charges(chargesObj, dining_minutes, type)
solid_price = 0
block = DiningCharge.convert_to_minutes(chargesObj.charge_block.strftime('%H:%M'))
block = DiningCharge.convert_to_minutes(chargesObj.charge_block.utc.localtime.strftime('%H:%M'))
result = dining_minutes / block
if result.to_i < 1
return chargesObj.unit_price
elsif result.to_i >= 1
solid_price = result * chargesObj.unit_price
remain_value = dining_minutes % block
rounding_block = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.strftime('%H:%M'))
rounding_block = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.localtime.strftime('%H:%M'))
roundingblock = remain_value / rounding_block
if roundingblock.to_i < 1
return DiningCharge.check_rounding(chargesObj, solid_price)
@@ -48,7 +52,7 @@ class DiningCharge < ApplicationRecord
end
end
def self.check_rounding(chargesObj)
def self.check_rounding(chargesObj,solid_price)
if chargesObj.time_rounding == "down"
return solid_price
else

2
app/models/in_juty.rb Normal file
View File

@@ -0,0 +1,2 @@
class InJuty < ApplicationRecord
end

View File

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

View File

@@ -0,0 +1,2 @@
json.extract! in_juty, :id, :created_at, :updated_at
json.url in_juty_url(in_juty, format: :json)

View File

@@ -0,0 +1,6 @@
<h1>Editing In Juty</h1>
<%= render 'form', in_juty: @in_juty %>
<%= link_to 'Show', @in_juty %> |
<%= link_to 'Back', in_juties_path %>

View File

@@ -0,0 +1,25 @@
<p id="notice"><%= notice %></p>
<h1>In Juties</h1>
<table>
<thead>
<tr>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @in_juties.each do |in_juty| %>
<tr>
<td><%= link_to 'Show', in_juty %></td>
<td><%= link_to 'Edit', edit_in_juty_path(in_juty) %></td>
<td><%= link_to 'Destroy', in_juty, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New In Juty', new_in_juty_path %>

View File

@@ -0,0 +1 @@
json.array! @in_juties, partial: 'in_juties/in_juty', as: :in_juty

View File

@@ -0,0 +1,5 @@
<h1>New In Juty</h1>
<%= render 'form', in_juty: @in_juty %>
<%= link_to 'Back', in_juties_path %>

View File

@@ -0,0 +1,4 @@
<p id="notice"><%= notice %></p>
<%= link_to 'Edit', edit_in_juty_path(@in_juty) %> |
<%= link_to 'Back', in_juties_path %>

View File

@@ -0,0 +1 @@
json.partial! "in_juties/in_juty", in_juty: @in_juty