merge with august spring

This commit is contained in:
Yan
2017-08-28 18:33:49 +06:30
50 changed files with 1677 additions and 976 deletions

View File

@@ -1,75 +0,0 @@
class Origami::CommissionersController < BaseOrigamiController
before_action :set_commissioner, only: [:show, :edit, :update, :destroy]
# GET /commissioners
# GET /commissioners.json
def index
@commissioners = Commissioner.all.order("id asc")
end
# GET /commissioners/1
# GET /commissioners/1.json
def show
end
# GET /commissioners/new
def new
@commissioner = Commissioner.new
@employee = Employee.all.order('name asc')
end
# GET /commissioners/1/edit
def edit
end
# POST /commissioners
# POST /commissioners.json
def create
@commissioner = Commissioner.new(commissioner_params)
@commissioner.created_by = current_user.id
respond_to do |format|
if @commissioner.save
format.html { redirect_to origami_commissioners_path , notice: 'Commissioner was successfully created.' }
format.json { render :show, status: :created, location: @commissioner }
else
format.html { render :new }
format.json { render json: @commissioner.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /commissioners/1
# PATCH/PUT /commissioners/1.json
def update
respond_to do |format|
if @commissioner.update(commissioner_params)
format.html { redirect_to origami_commissioner_path(@commissioner) , notice: 'Commissioner was successfully updated.' }
format.json { render :show, status: :ok, location: @commissioner }
else
format.html { render :edit }
format.json { render json: @commissioner.errors, status: :unprocessable_entity }
end
end
end
# DELETE /commissioners/1
# DELETE /commissioners/1.json
def destroy
@commissioner.destroy
respond_to do |format|
format.html { redirect_to origami_commissioners_path , notice: 'Commissioner was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_commissioner
@commissioner = Commissioner.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def commissioner_params
params.require(:commissioner).permit(:name,:emp_id,:created_by,:commission_type, :is_active)
end
end

View File

@@ -8,9 +8,10 @@ class Origami::InJutiesController < BaseOrigamiController
end
def index_in_juty
@juties_in= InJuty.where("dinning_id=?",params[:table_id])
@juty_in= InJuty.where("dinning_id=?",params[:table_id])
@table = DiningFacility.find(params[:table_id])
@in_juty = InJuty.new
@juties_in = Kaminari.paginate_array(@juty_in).page(params[:page]).per(10)
end
# GET /in_juties/1
@@ -31,6 +32,9 @@ class Origami::InJutiesController < BaseOrigamiController
def edit_in_juty
@in_juty = InJuty.find(params[:id])
@table = DiningFacility.find(params[:table_id])
@commissioner = @in_juty.commissioner
render json: {in_juty: @in_juty, commissioner: @commissioner}
end
def assign_in_juty
@@ -89,12 +93,19 @@ class Origami::InJutiesController < BaseOrigamiController
end
def update_for_in_juty
@in_juty.dinning_id = params[:dining_id]
@in_juty.commissioner_ids = params[:commissioner_ids]
@in_juty.in_time = params[:in_time]
@in_juty.out_time = params[:out_time]
@in_juty.save
def update_for_in_juty
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
@in_juty.in_time = in_juty_params[:in_time]
@in_juty.out_time = in_juty_params[:out_time]
respond_to do |format|
if @in_juty.save
format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), 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
@@ -125,6 +136,6 @@ class Origami::InJutiesController < BaseOrigamiController
# Never trust parameters from the scary internet, only allow the white list through.
def in_juty_params
params.require(:in_juty).permit(:dinning_id,:commissioner_ids,:in_time,:out_time)
params.require(:in_juty).permit(:id,:dinning_id,:commissioner_ids,:in_time,:out_time)
end
end

View File

@@ -62,15 +62,16 @@ class Origami::ProductCommissionsController < ApplicationController
end
def set_commissioner_to_sale_item
# byebug
deselect = false
sale_item_id = params[:sale_item_id]
commissioner_id = params[:commissioner_id]
@sale_item = SaleItem.find(sale_item_id)
@menu_item = MenuItem.find_by_item_code(@sale_item.product_code)
@commission = Commission.where('product_id = ? AND is_active = ?', @menu_item.id, true).take
@commission = Commission.where('product_code = ? AND is_active = ?', @menu_item.id, true).take
@commissioner = Commissioner.where('id = ? AND is_active = ?', commissioner_id, true).take
@product_commission = ProductCommission.where('sale_item_id = ?', @sale_item.id).take
# byebug
if !@product_commission.nil?
if @product_commission.commissioner_id == @commissioner.id
@product_commission.destroy
@@ -81,7 +82,8 @@ class Origami::ProductCommissionsController < ApplicationController
end
else
@product_commission = ProductCommission.new
@product_commission.product_id = @menu_item.id
@product_commission.product_code = @menu_item.id
@product_commission.product_type = 'menu_item' # use for dummy data ToDo::need to change product type
unless @commission.nil?
@product_commission.commission_id = @commission.id
if @commission.commission_type == 'Percentage'

View File

@@ -0,0 +1,50 @@
class Reports::CommissionController < BaseReportController
# authorize_resource :class => false
def index
from, to = get_date_range_from_params
@shift = ''
if params[:shift_name].to_i != 0
@shift = ShiftSale.find(params[:shift_name])
end
@sale_data = Sale.get_by_shiftsales(from,to,@shift)
@from = from
@to = to
if @shift.present?
@shift_from = @shift.shift_started_at.nil? ? '-' : @shift.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = @shift
end
respond_to do |format|
format.html
format.xls
end
end
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
shift_id = sale.id.nil? ? '-' : sale.id
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
date_arr.push(str)
end
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
end
end

View File

@@ -0,0 +1,93 @@
class Settings::CommissionersController < ApplicationController
before_action :set_commissioner, only: [:show, :edit, :update, :destroy]
# GET /commissioners
# GET /commissioners.json
def index
@commissioners = Commissioner.all.order("id asc")
end
# GET /commissioners/1
# GET /commissioners/1.json
def show
end
# GET /commissioners/new
def new
@commissioner = Commissioner.new
@employee = Employee.all.order('name asc')
end
# GET /commissioners/1/edit
def edit
end
# POST /commissioners
# POST /commissioners.json
def create
@commissioner = Commissioner.new(commissioner_params)
@commissioner.created_by = current_user.id
unless @commissioner.joined_date.nil?
@commissioner.joined_date = @commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d')
end
unless @commissioner.resigned_date.nil?
@commissioner.resigned_date = @commissioner.resigned_date.utc.getlocal.strftime('%Y-%b-%d')
end
respond_to do |format|
if @commissioner.save
format.html {redirect_to settings_commissioners_path, notice: 'Commissioner was successfully created.'}
format.json {render :show, status: :created, location: @commissioner}
else
format.html {render :new}
format.json {render json: @commissioner.errors, status: :unprocessable_entity}
end
end
end
# PATCH/PUT /commissioners/1
# PATCH/PUT /commissioners/1.json
def update
respond_to do |format|
if @commissioner.update(commissioner_params)
format.html {redirect_to settings_commissioner_path(@commissioner), notice: 'Commissioner was successfully updated.'}
format.json {render :show, status: :ok, location: @commissioner}
else
format.html {render :edit}
format.json {render json: @commissioner.errors, status: :unprocessable_entity}
end
end
end
# DELETE /commissioners/1
# DELETE /commissioners/1.json
def destroy
@commissioner.destroy
respond_to do |format|
format.html {redirect_to settings_commissioners_path, notice: 'Commissioner was successfully destroyed.'}
format.json {head :no_content}
end
end
def get_transaction_by_commissioner
commissioner_id = params[:commissioner_id]
@transactions = []
@product_commissions = ProductCommission.where(commissioner_id: commissioner_id).order('updated_at desc')
@product_commissions.each_with_index do |p, i|
@transactions[i] = []
@transactions[i] << p
@transactions[i] << p.commission.menu_item.name
end
render json: @transactions
end
private
# Use callbacks to share common setup or constraints between actions.
def set_commissioner
@commissioner = Commissioner.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def commissioner_params
params.require(:commissioner).permit(:name, :emp_id, :created_by, :commission_id, :joined_date, :resigned_date, :is_active)
end
end

View File

@@ -1,4 +1,4 @@
class Origami::CommissionsController < BaseOrigamiController
class Settings::CommissionsController < ApplicationController
before_action :set_commission, only: [:show, :edit, :update, :destroy]
# GET /commissions
@@ -27,10 +27,11 @@ class Origami::CommissionsController < BaseOrigamiController
# POST /commissions.json
def create
@commission = Commission.new(commission_params)
@commission.product_type = 'menu_item'
respond_to do |format|
if @commission.save
format.html {redirect_to origami_commissions_path, notice: 'Commission was successfully created.'}
format.html {redirect_to settings_commissions_path, notice: 'Commission was successfully created.'}
format.json {render :show, status: :created, location: @commission}
else
format.html {render :new}
@@ -44,7 +45,7 @@ class Origami::CommissionsController < BaseOrigamiController
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.html {redirect_to settings_commission_path(@commission), notice: 'Commission was successfully updated.'}
format.json {render :show, status: :ok, location: @commission}
else
format.html {render :edit}
@@ -58,7 +59,7 @@ class Origami::CommissionsController < BaseOrigamiController
def destroy
@commission.destroy
respond_to do |format|
format.html {redirect_to origami_commissions_path, notice: 'Commission was successfully destroyed.'}
format.html {redirect_to settings_commissions_path, notice: 'Commission was successfully destroyed.'}
format.json {head :no_content}
end
end
@@ -96,6 +97,6 @@ class Origami::CommissionsController < BaseOrigamiController
# 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)
params.require(:commission).permit(:product_type, :product_code, :amount, :commission_type, :is_active)
end
end