diff --git a/app/models/commission.rb b/app/models/commission.rb index 40d69f81..84771e9f 100755 --- a/app/models/commission.rb +++ b/app/models/commission.rb @@ -8,6 +8,9 @@ class Commission < ApplicationRecord has_many :commissioners has_many :product_commissions + # validations + validates_presence_of :commission_type, :amount + private def generate_custom_id self.commission_id = SeedGenerator.generate_id(self.class.name, 'COM') diff --git a/app/models/commissioner.rb b/app/models/commissioner.rb index 17fa2036..2b262afc 100755 --- a/app/models/commissioner.rb +++ b/app/models/commissioner.rb @@ -4,4 +4,7 @@ class Commissioner < ApplicationRecord has_many :in_juties has_many :product_commissions scope :active, -> { where(is_active: true) } + + # validations + validates_presence_of :name end diff --git a/app/views/settings/commissions/_form.html.erb b/app/views/settings/commissions/_form.html.erb index 15bdf52a..a1a2368a 100755 --- a/app/views/settings/commissions/_form.html.erb +++ b/app/views/settings/commissions/_form.html.erb @@ -7,7 +7,7 @@
<%= f.label :product_code, 'Product' %> - <%= f.collection_select :product_code, @products, :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %>
+ <%= f.collection_select :product_code, MenuItem.all.order('name asc'), :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %>
<%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %> <%= f.input :amount %> <%= f.input :is_active %> Active