validation for commission, commissioner

This commit is contained in:
phyusin
2017-10-27 13:51:45 +06:30
parent 20c0c2ca98
commit d916c262d7
3 changed files with 7 additions and 1 deletions

View File

@@ -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')

View File

@@ -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

View File

@@ -7,7 +7,7 @@
<div class="form-inputs">
<%= f.label :product_code, 'Product' %>
<%= f.collection_select :product_code, @products, :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %><br/>
<%= f.collection_select :product_code, MenuItem.all.order('name asc'), :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %><br/>
<%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %>
<%= f.input :amount %>
<%= f.input :is_active %> Active