load commissioner

This commit is contained in:
Zin Lin Phyo
2017-08-23 10:24:26 +06:30
parent 74c2955ef0
commit fd1bfb7c0e
13 changed files with 738 additions and 255 deletions

View File

@@ -1,2 +1,4 @@
class Commission < ApplicationRecord
belongs_to :product, foreign_key: 'product_id'
has_many :commissioners
end

View File

@@ -1,3 +1,5 @@
class Commissioner < ApplicationRecord
has_many :employees
belongs_to :employee, foreign_key: 'emp_id'
belongs_to :commission, foreign_key: 'commission_type'
scope :active, -> { where(is_active: true) }
end

View File

@@ -1,7 +1,8 @@
class Employee < ApplicationRecord
has_secure_password
belongs_to :commissioner
has_many :commissioners
has_many :shit_sales
validates_presence_of :name, :role
validates_presence_of :password, :on => [:create]
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true

View File

@@ -1,6 +1,7 @@
class Product < ApplicationRecord
validates_presence_of :name
has_many :commissions
# Product Image Uploader
mount_uploader :image_path, ProductImageUploader
end