ecom_core 1.2.30 → 1.2.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/ecom/core/{project_crews_controller.rb → site_crews_controller.rb} +5 -4
- data/app/models/ecom/core/attendance_sheet.rb +19 -19
- data/app/models/ecom/core/available_unit_of_measurement.rb +10 -0
- data/app/models/ecom/core/crew.rb +14 -3
- data/app/models/ecom/core/crew_contract.rb +41 -1
- data/app/models/ecom/core/crew_contract_transaction.rb +29 -0
- data/app/models/ecom/core/crew_id_card.rb +36 -0
- data/app/models/ecom/core/crew_time.rb +11 -3
- data/app/models/ecom/core/dimension_element.rb +22 -0
- data/app/models/ecom/core/inspection_checklist.rb +6 -0
- data/app/models/ecom/core/job_card.rb +1 -1
- data/app/models/ecom/core/material.rb +6 -0
- data/app/models/ecom/core/material_identity.rb +21 -0
- data/app/models/ecom/core/material_item.rb +18 -0
- data/app/models/ecom/core/material_sub_type.rb +20 -0
- data/app/models/ecom/core/measurement_unit.rb +55 -0
- data/app/models/ecom/core/overtime_sheet.rb +26 -16
- data/app/models/ecom/core/payroll.rb +3 -3
- data/app/models/ecom/core/plan.rb +18 -0
- data/app/models/ecom/core/project.rb +0 -3
- data/app/models/ecom/core/project_template.rb +11 -0
- data/app/models/ecom/core/project_work_item_template.rb +9 -0
- data/app/models/ecom/core/schedule_setting.rb +8 -6
- data/app/models/ecom/core/{project_crew.rb → site.rb} +8 -4
- data/app/models/ecom/core/site_crew.rb +27 -0
- data/app/models/ecom/core/takeoff.rb +10 -0
- data/app/models/ecom/core/task.rb +32 -4
- data/app/models/ecom/core/task_inspection_checklist.rb +18 -0
- data/app/models/ecom/core/task_resource.rb +2 -0
- data/app/models/ecom/core/task_template.rb +22 -2
- data/app/models/ecom/core/task_template_inspection_checklist.rb +8 -0
- data/app/models/ecom/core/work_order.rb +26 -0
- data/app/models/ecom/core/work_package.rb +3 -0
- data/app/models/ecom/core/work_product.rb +3 -18
- data/app/models/ecom/core/work_product_template.rb +2 -2
- data/app/services/ecom/core/crew_contract_transaction_service.rb +89 -0
- data/app/services/ecom/core/site_crew_service.rb +44 -0
- data/app/uploaders/ecom/core/photo_uploader.rb +8 -1
- data/config/routes.rb +2 -2
- data/db/migrate/20191119012030_create_ecom_core_task_templates.rb +6 -1
- data/db/migrate/20191119013236_create_ecom_core_work_product_templates.rb +0 -15
- data/db/migrate/20191119021405_create_ecom_core_project_templates.rb +15 -0
- data/db/migrate/20191119034319_create_ecom_core_project_work_item_templates.rb +20 -0
- data/db/migrate/20191201145849_create_ecom_core_sites.rb +16 -0
- data/db/migrate/20191202222210_create_ecom_core_work_packages.rb +12 -0
- data/db/migrate/20191202235434_create_ecom_core_work_products.rb +2 -18
- data/db/migrate/{20191225100054_create_ecom_core_crews.rb → 20191207103729_create_ecom_core_crews.rb} +3 -3
- data/db/migrate/20191207103730_create_ecom_core_plans.rb +12 -0
- data/db/migrate/20191207103731_create_ecom_core_work_orders.rb +23 -0
- data/db/migrate/20191207103735_create_ecom_core_tasks.rb +23 -7
- data/db/migrate/20191225140433_create_ecom_core_attendance_sheets.rb +4 -4
- data/db/migrate/20200126081005_create_ecom_core_payrolls.rb +3 -3
- data/db/migrate/20200410090701_create_ecom_core_overtime_sheets.rb +4 -4
- data/db/migrate/20200616044231_create_ecom_core_material_sub_types.rb +14 -0
- data/db/migrate/20200616051902_create_ecom_core_material_identities.rb +17 -0
- data/db/migrate/20200618105233_create_ecom_core_material_items.rb +16 -0
- data/db/migrate/20200813165553_create_ecom_core_measurement_units.rb +14 -0
- data/db/migrate/20200813165555_create_ecom_core_available_unit_of_measurements.rb +16 -0
- data/db/migrate/20200814043632_create_ecom_core_takeoffs.rb +14 -0
- data/db/migrate/20200901085227_create_ecom_core_crew_contracts.rb +7 -1
- data/db/migrate/20200901134912_create_ecom_core_dimension_elements.rb +23 -0
- data/db/migrate/20200919085613_create_ecom_core_job_cards.rb +1 -0
- data/db/migrate/20201013072924_create_ecom_core_crew_contract_transactions.rb +16 -0
- data/db/migrate/20201013090609_create_ecom_core_site_crews.rb.rb +22 -0
- data/db/migrate/20201013094100_create_ecom_core_crew_id_cards.rb +16 -0
- data/db/migrate/20201113050953_create_ecom_core_task_inspection_checklists.rb +22 -0
- data/db/migrate/20201113094302_create_ecom_core_task_template_inspection_checklists.rb +17 -0
- data/lib/ecom/core/version.rb +1 -1
- data/spec/factories/ecom/core/attendance_sheet_entries.rb +1 -1
- data/spec/factories/ecom/core/attendance_sheets.rb +1 -1
- data/spec/factories/ecom/core/available_unit_of_measurements.rb +6 -0
- data/spec/factories/ecom/core/crew_contract_transactions.rb +8 -0
- data/spec/factories/ecom/core/crew_contracts.rb +12 -0
- data/spec/factories/ecom/core/crew_id_cards.rb +8 -0
- data/spec/factories/ecom/core/dimension_elements.rb +8 -0
- data/spec/factories/ecom/core/inspection_checklists.rb +5 -0
- data/spec/factories/ecom/core/maintenance_statuses.rb +1 -1
- data/spec/factories/ecom/core/material_identities.rb +6 -0
- data/spec/factories/ecom/core/material_items.rb +6 -0
- data/spec/factories/ecom/core/material_sub_types.rb +6 -0
- data/spec/factories/ecom/core/materials.rb +5 -0
- data/spec/factories/ecom/core/measurement_units.rb +16 -0
- data/spec/factories/ecom/core/overtime_sheets.rb +1 -1
- data/spec/factories/ecom/core/payrolls.rb +1 -1
- data/spec/factories/ecom/core/plans.rb +8 -0
- data/spec/factories/ecom/core/project_templates.rb +8 -0
- data/spec/factories/ecom/core/project_work_item_templates.rb +7 -0
- data/spec/factories/ecom/core/site_crews.rb +10 -0
- data/spec/factories/ecom/core/sites.rb +8 -0
- data/spec/factories/ecom/core/takeoffs.rb +6 -0
- data/spec/factories/ecom/core/task_inspection_checklists.rb +11 -0
- data/spec/factories/ecom/core/task_template_inspection_checklists.rb +7 -0
- data/spec/factories/ecom/core/task_templates.rb +11 -1
- data/spec/factories/ecom/core/tasks.rb +8 -3
- data/spec/factories/ecom/core/work_orders.rb +10 -0
- data/spec/factories/ecom/core/work_packages.rb +6 -0
- data/spec/factories/ecom/core/work_product_templates.rb +0 -1
- data/spec/factories/ecom/core/work_products.rb +1 -8
- metadata +75 -9
- data/app/services/ecom/core/project_crew_service.rb +0 -39
- data/db/migrate/20191225121850_create_ecom_core_project_crews.rb +0 -19
- data/db/migrate/20200922044959_add_costs_approved_to_job_card.rb +0 -5
- data/spec/factories/ecom/core/project_crews.rb +0 -9
@@ -1,31 +1,39 @@
|
|
1
1
|
module Ecom
|
2
2
|
module Core
|
3
3
|
class OvertimeSheet < ApplicationRecord
|
4
|
-
validates :date, :opened_at, presence: true, uniqueness: { scope: :
|
4
|
+
validates :date, :opened_at, presence: true, uniqueness: { scope: :site_id }
|
5
5
|
validates :status, inclusion: StatusConstants::STATUSES
|
6
6
|
|
7
|
-
belongs_to :
|
7
|
+
belongs_to :site
|
8
8
|
|
9
9
|
has_many :overtime_sheet_entries
|
10
10
|
has_many :crew_overtimes, through: :overtime_sheet_entries
|
11
11
|
|
12
|
-
scope :
|
12
|
+
scope :by_site, ->(id) { where(site_id: id) }
|
13
13
|
scope :by_date, ->(date) { where(date: date) }
|
14
14
|
scope :by_status, ->(status) { where(status: status) }
|
15
15
|
scope :by_date_between, ->(from, to) { where('date BETWEEN ? AND ?', from, to) }
|
16
|
-
scope :open, ->(id) { where(status: StatusConstants::OPEN, project_id: id) }
|
17
|
-
scope :submitted, ->(id) { where(status: StatusConstants::SUBMITTED, project_id: id) }
|
18
16
|
|
19
|
-
def self.open_exists?(
|
20
|
-
OvertimeSheet
|
17
|
+
def self.open_exists?(site_id)
|
18
|
+
OvertimeSheet
|
19
|
+
.by_site(site_id)
|
20
|
+
.by_status(StatusConstants::OPEN)
|
21
|
+
.exists?
|
21
22
|
end
|
22
23
|
|
23
|
-
def self.open_for_date_exists?(date,
|
24
|
-
OvertimeSheet
|
24
|
+
def self.open_for_date_exists?(date, site_id)
|
25
|
+
OvertimeSheet
|
26
|
+
.by_site(site_id)
|
27
|
+
.by_status(StatusConstants::OPEN)
|
28
|
+
.by_date(date)
|
29
|
+
.exists?
|
25
30
|
end
|
26
31
|
|
27
|
-
def self.exists_for_date?(date,
|
28
|
-
OvertimeSheet
|
32
|
+
def self.exists_for_date?(date, site_id)
|
33
|
+
OvertimeSheet
|
34
|
+
.by_site(site_id)
|
35
|
+
.by_date(date)
|
36
|
+
.exists?
|
29
37
|
end
|
30
38
|
|
31
39
|
# Overtime sheet should be created using the
|
@@ -33,16 +41,18 @@ module Ecom
|
|
33
41
|
# check if there is an open overtime already,
|
34
42
|
# and also that we have only one open overtime
|
35
43
|
# sheet at a time.
|
36
|
-
def self.create_new(date,
|
37
|
-
if OvertimeSheet.exists_for_date?(date,
|
44
|
+
def self.create_new(date, site_id)
|
45
|
+
if OvertimeSheet.exists_for_date?(date, site_id)
|
38
46
|
raise 'There is already an overtime sheet for the selected date.'
|
39
47
|
end
|
40
48
|
|
41
|
-
if OvertimeSheet.open_exists?(
|
42
|
-
|
49
|
+
if OvertimeSheet.open_exists?(site_id)
|
50
|
+
open_overtime_sheet = OvertimeSheet.find_by(status: 'Open')
|
51
|
+
raise "There is already an open overtime sheet for #{open_overtime_sheet.date}.
|
52
|
+
It has to be submitted before creating a new one."
|
43
53
|
end
|
44
54
|
|
45
|
-
OvertimeSheet.create(date: date, opened_at: Time.now, status: StatusConstants::OPEN,
|
55
|
+
OvertimeSheet.create(date: date, opened_at: Time.now, status: StatusConstants::OPEN, site_id: site_id)
|
46
56
|
end
|
47
57
|
|
48
58
|
def submit
|
@@ -4,9 +4,9 @@ module Ecom
|
|
4
4
|
validates :month, :year, presence: true
|
5
5
|
|
6
6
|
has_many :payments, class_name: 'Ecom::Core::Payment'
|
7
|
-
belongs_to :
|
7
|
+
belongs_to :site
|
8
8
|
|
9
|
-
scope :
|
9
|
+
scope :by_site, ->(id) { where(site_id: id) }
|
10
10
|
scope :by_month, ->(month) { where(month: month) }
|
11
11
|
scope :by_year, ->(year) { where(year: year) }
|
12
12
|
|
@@ -17,7 +17,7 @@ module Ecom
|
|
17
17
|
m = 1
|
18
18
|
y += 1
|
19
19
|
end
|
20
|
-
Payroll.create(month: m, year: y,
|
20
|
+
Payroll.create(month: m, year: y, site_id: site_id)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class Plan < ApplicationRecord
|
4
|
+
NEW = 'New'.freeze
|
5
|
+
READY_TO_START = 'Ready to start'.freeze
|
6
|
+
IN_PROGRESS = 'In Progress'.freeze
|
7
|
+
COMPLETED = 'Completed'.freeze
|
8
|
+
|
9
|
+
STATUSES = [NEW, READY_TO_START, IN_PROGRESS, COMPLETED].freeze
|
10
|
+
|
11
|
+
validates :name, :start_date, :end_date, :status, presence: true
|
12
|
+
|
13
|
+
validates :status, presence: true, inclusion: STATUSES
|
14
|
+
|
15
|
+
has_many :tasks
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -9,9 +9,6 @@ module Ecom
|
|
9
9
|
belongs_to :currency
|
10
10
|
belongs_to :company
|
11
11
|
|
12
|
-
has_many :project_crews
|
13
|
-
has_many :crews, through: :project_crews
|
14
|
-
|
15
12
|
validates :name, :location, :contract_number, :date_contract_signed, :commencement_date, :completion_date,
|
16
13
|
:contract_amount, :advance_payment, :retention, presence: true
|
17
14
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
-
module Ecom
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class ScheduleSetting < ApplicationRecord
|
4
|
+
belongs_to :equipment
|
5
|
+
belongs_to :maintenance_type
|
6
|
+
belongs_to :schedule_unit
|
6
7
|
|
7
|
-
|
8
|
+
validates :value, presence: true
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
@@ -1,15 +1,19 @@
|
|
1
1
|
module Ecom
|
2
2
|
module Core
|
3
|
-
class
|
3
|
+
class Site < ApplicationRecord
|
4
4
|
ACTIVE = 'Active'.freeze
|
5
5
|
INACTIVE = 'Inactive'.freeze
|
6
|
+
|
6
7
|
STATUSES = [ACTIVE, INACTIVE].freeze
|
7
8
|
|
8
|
-
|
9
|
-
belongs_to :crew
|
9
|
+
validates :name, :project_id, :project, :address, :status, presence: true
|
10
10
|
|
11
|
-
validates :start_date, :status, presence: true
|
12
11
|
validates :status, inclusion: STATUSES
|
12
|
+
|
13
|
+
belongs_to :project
|
14
|
+
|
15
|
+
has_many :site_crews
|
16
|
+
has_many :crews, through: :site_crews
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class SiteCrew < ApplicationRecord
|
4
|
+
TEMPORARY_SITE_CREW = 'Temporary site crew'.freeze
|
5
|
+
PERMANENT_SITE_CREW = 'Permanent site crew'.freeze
|
6
|
+
|
7
|
+
SITE_CREW_TYPES = [TEMPORARY_SITE_CREW, PERMANENT_SITE_CREW].freeze
|
8
|
+
|
9
|
+
ACTIVE = 'Active'.freeze
|
10
|
+
INACTIVE = 'Inactive'.freeze
|
11
|
+
STATUSES = [ACTIVE, INACTIVE].freeze
|
12
|
+
|
13
|
+
validates :crew_id, :crew, :site_id, :site, :start_date, :site_crew_type, :status, presence: true
|
14
|
+
|
15
|
+
validates_uniqueness_of :site_id,
|
16
|
+
scope: :crew_id,
|
17
|
+
conditions: -> { where(status: 'Active') },
|
18
|
+
message: 'There can only be one record with status `Active` for a given site and crew'
|
19
|
+
|
20
|
+
validates :site_crew_type, inclusion: SITE_CREW_TYPES
|
21
|
+
validates :status, inclusion: STATUSES
|
22
|
+
|
23
|
+
belongs_to :crew
|
24
|
+
belongs_to :site
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -5,24 +5,52 @@ module Ecom
|
|
5
5
|
|
6
6
|
has_ancestry
|
7
7
|
|
8
|
+
NOT_INSPECTED = 'Not Inspected'.freeze
|
9
|
+
IN_PROGRESS = 'In Progress'.freeze
|
10
|
+
PASS = 'Pass'.freeze
|
11
|
+
FAIL = 'Fail'.freeze
|
12
|
+
|
13
|
+
INSPECTION_STATUSES = [NOT_INSPECTED, IN_PROGRESS, PASS, FAIL].freeze
|
14
|
+
|
8
15
|
belongs_to :work_product
|
9
16
|
belongs_to :task_template
|
10
17
|
belongs_to :work_package, optional: true
|
18
|
+
belongs_to :work_order, optional: true
|
19
|
+
belongs_to :plan, optional: true
|
11
20
|
belongs_to :performer, class_name: 'Ecom::Core::User', optional: true
|
12
|
-
belongs_to :
|
13
|
-
belongs_to :
|
14
|
-
belongs_to :
|
21
|
+
belongs_to :client_consultant, class_name: 'Ecom::Core::User', optional: true
|
22
|
+
belongs_to :foreman, class_name: 'Ecom::Core::User', optional: true
|
23
|
+
belongs_to :inspector, class_name: 'Ecom::Core::User', optional: true
|
24
|
+
belongs_to :change_order_for, class_name: 'Ecom::Core::User', optional: true
|
15
25
|
|
16
|
-
|
26
|
+
has_many :task_resources
|
27
|
+
has_one :takeoff
|
28
|
+
has_one :change_order, foreign_key: :change_order_for_id, class_name: 'Ecom::Core::Task'
|
29
|
+
|
30
|
+
validates_with DateRangeValidator
|
31
|
+
validates :code, :name, :status, :inspection_status, :percent_completed, presence: true
|
17
32
|
validates_numericality_of :percent_completed,
|
18
33
|
only_integer: true,
|
19
34
|
greater_than_or_equal_to: 0,
|
20
35
|
less_than_or_equal_to: 100
|
36
|
+
validates :percentage_contribution,
|
37
|
+
numericality: {
|
38
|
+
greater_than_or_equal_to: 0,
|
39
|
+
less_than_or_equal_to: 100,
|
40
|
+
only_integer: true
|
41
|
+
},
|
42
|
+
allow_nil: true
|
43
|
+
|
44
|
+
validates_inclusion_of :inspection_status, in: INSPECTION_STATUSES
|
21
45
|
|
22
46
|
scope :by_status, ->(status) { where(status: status) }
|
23
47
|
|
48
|
+
# State: planned -> The task has be planned for execution
|
49
|
+
# State: ready_to_start -> All resources for the task has been set and is ready to start
|
24
50
|
aasm column: 'status' do
|
25
51
|
state :new, initial: true
|
52
|
+
state :planned
|
53
|
+
state :ready_to_start
|
26
54
|
state :in_progress
|
27
55
|
state :submitted
|
28
56
|
state :under_review
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class TaskInspectionChecklist < ApplicationRecord
|
4
|
+
NOT_INSPECTED = 'Not Inspected'.freeze
|
5
|
+
IN_PROGRESS = 'In Progress'.freeze
|
6
|
+
PASS = 'Pass'.freeze
|
7
|
+
FAIL = 'Fail'.freeze
|
8
|
+
|
9
|
+
INSPECTION_STATUSES = [NOT_INSPECTED, IN_PROGRESS, PASS, FAIL].freeze
|
10
|
+
|
11
|
+
belongs_to :inspected_by, class_name: 'Ecom::Core::User'
|
12
|
+
belongs_to :task
|
13
|
+
|
14
|
+
validates :name, :status, presence: true
|
15
|
+
validates :status, inclusion: INSPECTION_STATUSES
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -4,13 +4,26 @@ module Ecom
|
|
4
4
|
has_ancestry
|
5
5
|
|
6
6
|
belongs_to :task_template_type
|
7
|
-
|
7
|
+
has_many :task_template_inspection_checklists
|
8
|
+
has_many :inspection_checklists, through: :task_template_inspection_checklists
|
9
|
+
has_many :project_work_item_templates
|
10
|
+
has_many :work_product_templates, through: :project_work_item_templates
|
8
11
|
has_and_belongs_to_many :resource_types, join_table: 'ecom_core_task_templates_resource_types'
|
9
12
|
|
10
|
-
validates :name, :code, presence: true
|
13
|
+
validates :name, :code, :takeoff_fields, :task_completion_detail, presence: true
|
11
14
|
validates :code, uniqueness: true
|
15
|
+
validates :percentage_contribution,
|
16
|
+
numericality: {
|
17
|
+
greater_than_or_equal_to: 0,
|
18
|
+
less_than_or_equal_to: 100,
|
19
|
+
only_integer: true
|
20
|
+
},
|
21
|
+
allow_nil: true
|
22
|
+
|
12
23
|
delegate(:name, to: :task_template_type, prefix: true)
|
13
24
|
|
25
|
+
validate :percentage_contribution_sum_validator
|
26
|
+
|
14
27
|
def full_name
|
15
28
|
parent_name = parent&.name
|
16
29
|
return name unless parent_name
|
@@ -29,6 +42,13 @@ module Ecom
|
|
29
42
|
def equipment_types
|
30
43
|
resource_types.where(type: 'Ecom::Core::EquipmentType')
|
31
44
|
end
|
45
|
+
|
46
|
+
def percentage_contribution_sum_validator
|
47
|
+
return if percentage_contribution.nil?
|
48
|
+
|
49
|
+
sum = siblings.sum(:percentage_contribution)
|
50
|
+
errors.add(:task, 'Sum of percentage contributions has to be 100') if sum > 100
|
51
|
+
end
|
32
52
|
end
|
33
53
|
end
|
34
54
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class WorkOrder < ApplicationRecord
|
4
|
+
before_save :add_reference_number
|
5
|
+
|
6
|
+
NEW = 'New'.freeze
|
7
|
+
IN_PROGRESS = 'In Progress'.freeze
|
8
|
+
COMPLETED = 'Completed'.freeze
|
9
|
+
|
10
|
+
STATUSES = [NEW, IN_PROGRESS, COMPLETED].freeze
|
11
|
+
|
12
|
+
validates :name, :assigned_to_id, :generated_by_id, :status,
|
13
|
+
:start_date, :end_date, presence: true
|
14
|
+
|
15
|
+
validates :status, presence: true, inclusion: STATUSES
|
16
|
+
|
17
|
+
belongs_to :assigned_to, class_name: 'Ecom::Core::Crew'
|
18
|
+
belongs_to :generated_by, class_name: 'Ecom::Core::User'
|
19
|
+
has_many :tasks
|
20
|
+
|
21
|
+
def add_reference_number
|
22
|
+
self.reference_number = "WO-#{(Time.now.to_f * 1000).to_i}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -2,9 +2,12 @@ module Ecom
|
|
2
2
|
module Core
|
3
3
|
class WorkPackage < ApplicationRecord
|
4
4
|
belongs_to :project
|
5
|
+
belongs_to :site_engineer, class_name: 'Ecom::Core::User', optional: true
|
6
|
+
belongs_to :project_manager, class_name: 'Ecom::Core::User', optional: true
|
5
7
|
|
6
8
|
validates :code, :name, presence: true
|
7
9
|
validates :code, uniqueness: true
|
10
|
+
validates :budget, numericality: true, unless: proc { budget.nil? }
|
8
11
|
|
9
12
|
has_many :tasks
|
10
13
|
end
|
@@ -15,29 +15,14 @@
|
|
15
15
|
module Ecom
|
16
16
|
module Core
|
17
17
|
class WorkProduct < ApplicationRecord
|
18
|
-
include AASM
|
19
|
-
|
20
|
-
NEW = 'New'.freeze
|
21
|
-
UNDER_CONSTRUCTION = 'Under Construction'.freeze
|
22
|
-
COMPLETED = 'Completed'.freeze
|
23
|
-
|
24
|
-
STATUSES = [NEW, UNDER_CONSTRUCTION, COMPLETED].freeze
|
25
|
-
|
26
18
|
belongs_to :work_product_template
|
27
19
|
belongs_to :project
|
28
20
|
belongs_to :product_group, optional: true
|
29
|
-
belongs_to :approver, class_name: 'Ecom::Core::User', optional: true
|
30
|
-
belongs_to :supervisor, class_name: 'Ecom::Core::User', optional: true
|
31
|
-
belongs_to :quality_controller, class_name: 'Ecom::Core::User', optional: true
|
32
21
|
has_many :tasks
|
22
|
+
has_many :dimension_elements
|
33
23
|
|
34
|
-
validates :name, :
|
35
|
-
validates :
|
36
|
-
validates :status, inclusion: STATUSES
|
37
|
-
validates_numericality_of :percent_completed,
|
38
|
-
only_integer: true,
|
39
|
-
greater_than_or_equal_to: 0,
|
40
|
-
less_than_or_equal_to: 100
|
24
|
+
validates :name, :design_reference, presence: true
|
25
|
+
validates :design_reference, uniqueness: { scope: :project_id }
|
41
26
|
end
|
42
27
|
end
|
43
28
|
end
|