diff --git a/app/controllers/origami/in_juties_controller.rb b/app/controllers/origami/in_juties_controller.rb
index d424186b..2f7ff21f 100644
--- a/app/controllers/origami/in_juties_controller.rb
+++ b/app/controllers/origami/in_juties_controller.rb
@@ -28,7 +28,7 @@ class Origami::InJutiesController < BaseOrigamiController
respond_to do |format|
if @in_juty.save
- format.html { redirect_to @in_juty, notice: 'In juty was successfully created.' }
+ format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully created.' }
format.json { render :show, status: :created, location: @in_juty }
else
format.html { render :new }
@@ -42,7 +42,7 @@ class Origami::InJutiesController < BaseOrigamiController
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.html { redirect_to origami_in_juty_path(@in_juty), notice: 'In juty was successfully updated.' }
format.json { render :show, status: :ok, location: @in_juty }
else
format.html { render :edit }
@@ -56,7 +56,7 @@ class Origami::InJutiesController < BaseOrigamiController
def destroy
@in_juty.destroy
respond_to do |format|
- format.html { redirect_to in_juties_url, notice: 'In juty was successfully destroyed.' }
+ format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully destroyed.' }
format.json { head :no_content }
end
end
@@ -69,6 +69,6 @@ class Origami::InJutiesController < BaseOrigamiController
# Never trust parameters from the scary internet, only allow the white list through.
def in_juty_params
- params.fetch(:in_juty, {})
+ params.require(:in_juty).permit(:dinning_id,:commissioner_ids,:in_time,:out_time)
end
end
diff --git a/app/models/commissioner.rb b/app/models/commissioner.rb
index ac199468..dd22278a 100644
--- a/app/models/commissioner.rb
+++ b/app/models/commissioner.rb
@@ -1,5 +1,6 @@
class Commissioner < ApplicationRecord
belongs_to :employee, foreign_key: 'emp_id'
belongs_to :commission, foreign_key: 'commission_type'
+ has_many :in_juties
scope :active, -> { where(is_active: true) }
end
diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb
index f441612a..ba01afb6 100644
--- a/app/models/dining_facility.rb
+++ b/app/models/dining_facility.rb
@@ -1,6 +1,7 @@
class DiningFacility < ApplicationRecord
belongs_to :zone
has_many :dining_charges
+ has_many :in_juties
TABLE_TYPE = "Table"
ROOM_TYPE = "Room"
diff --git a/app/models/in_juty.rb b/app/models/in_juty.rb
index d5ca9685..2f023ff0 100644
--- a/app/models/in_juty.rb
+++ b/app/models/in_juty.rb
@@ -1,2 +1,4 @@
class InJuty < ApplicationRecord
+ belongs_to :dining_facility, foreign_key: 'dinning_id'
+ belongs_to :commissioner, foreign_key: 'commissioner_ids'
end
diff --git a/app/views/origami/commissions/_form.html.erb b/app/views/origami/commissions/_form.html.erb
index 1f7fee4a..5077f946 100644
--- a/app/views/origami/commissions/_form.html.erb
+++ b/app/views/origami/commissions/_form.html.erb
@@ -8,6 +8,7 @@
<%= f.input :amount %>
<%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %>
+
<%= notice %>
- -| - | ||
|---|---|---|
| <%= link_to 'Show', in_juty %> | -<%= link_to 'Edit', edit_in_juty_path(in_juty) %> | -<%= link_to 'Destroy', in_juty, method: :delete, data: { confirm: 'Are you sure?' } %> | -
| Dining Facility Name | +Commissioner Ids | +In time | +Out time | ++ | ||
|---|---|---|---|---|---|---|
| <%= in_juty.dining_facility.name rescue '-' %> | +<%= in_juty.commissioner.name rescue '-' %> | +<%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> | +<%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> | +<%= link_to 'Show', origami_in_juty_path(in_juty) %> | +<%= link_to 'Edit', edit_origami_in_juty_path(in_juty) %> | +<%= link_to 'Destroy', origami_in_juty_path(in_juty), method: :delete, data: {confirm: 'Are you sure?'} %> | +
<%= notice %>
+| Dining Facility Name | +<%= @in_juty.dining_facility.name%> | +
| Commissioner Name | ++ <%= @in_juty.commissioner.name rescue '-' %> + | +
| In Time | +<%= @in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> | +
| Out Time | +<%= @in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> | +