diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 0ba2fcb2..e58b34db 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,31 +2,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -63,7 +39,7 @@ - + @@ -73,6 +49,16 @@ + + + + + + + + + + @@ -183,11 +169,11 @@ @@ -605,12 +591,12 @@ - + - @@ -621,19 +607,19 @@ + + - - @@ -936,14 +922,6 @@ - - - - - - - - @@ -1008,5 +986,13 @@ + + + + + + + + \ No newline at end of file diff --git a/app/controllers/origami/commissions_controller.rb b/app/controllers/origami/commissions_controller.rb new file mode 100644 index 00000000..3e4f3301 --- /dev/null +++ b/app/controllers/origami/commissions_controller.rb @@ -0,0 +1,91 @@ +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