validation for commission, commissioner
This commit is contained in:
@@ -8,6 +8,9 @@ class Commission < ApplicationRecord
|
|||||||
has_many :commissioners
|
has_many :commissioners
|
||||||
has_many :product_commissions
|
has_many :product_commissions
|
||||||
|
|
||||||
|
# validations
|
||||||
|
validates_presence_of :commission_type, :amount
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
self.commission_id = SeedGenerator.generate_id(self.class.name, 'COM')
|
self.commission_id = SeedGenerator.generate_id(self.class.name, 'COM')
|
||||||
|
|||||||
@@ -4,4 +4,7 @@ class Commissioner < ApplicationRecord
|
|||||||
has_many :in_juties
|
has_many :in_juties
|
||||||
has_many :product_commissions
|
has_many :product_commissions
|
||||||
scope :active, -> { where(is_active: true) }
|
scope :active, -> { where(is_active: true) }
|
||||||
|
|
||||||
|
# validations
|
||||||
|
validates_presence_of :name
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<div class="form-inputs">
|
<div class="form-inputs">
|
||||||
<%= f.label :product_code, 'Product' %>
|
<%= 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 :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %>
|
||||||
<%= f.input :amount %>
|
<%= f.input :amount %>
|
||||||
<%= f.input :is_active %> Active
|
<%= f.input :is_active %> Active
|
||||||
|
|||||||
Reference in New Issue
Block a user