ecom_core 1.3.1 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6eda813a28d309d4d0c69554387680286f822304a01ca6148c31e2bb39cfffb4
4
- data.tar.gz: 66d0904746ae71d5b0647f1b500492c5bb0cd53366cad9556e33de38118b36f1
3
+ metadata.gz: ce6cc11612b16aefac6121429ece4bee60b97ada78dcfdba961c792fedc0c0f4
4
+ data.tar.gz: 52a55fb8f1e97dc391a7ccede45bf7ed97d318f8f7029a2a465960ec089db864
5
5
  SHA512:
6
- metadata.gz: ce78c84074487ea4794572450122156c0d6c799b94d274269a4fac690d3ec47e46eeba14822a7f970aeef7b32ba31c036e99e0de5cbf52eda4753349b30b66b7
7
- data.tar.gz: 219a960401bdbfb0b9b73922242ff043d89984304b938f1835677230a06b57fc41e0ea25bd6bcd602e9cf3886c13d121ea9aeaeff3982ec8cf3f769a507e35d4
6
+ metadata.gz: 5bbacc01ee8a03bf4c2c16f3774da1657faa9f00d449ee3368625652f0d562ea22e0721bcaf0038de3de9d4245de2f955746f7f5006cc0835965f2db87a84ee7
7
+ data.tar.gz: 13b332676a15fa87e7fecb4ac22e15aaeb359ca498bc1b05ae7b0d4bb202eff3c849f4a2cfb5e7fde3af413c0a9937f2e0a63fcbb0f65fdca005ab5d83069133
@@ -4,6 +4,8 @@ module Ecom
4
4
  belongs_to :attendance_sheet
5
5
  belongs_to :crew
6
6
  has_many :crew_times
7
+
8
+ validates :total_hours, presence: true, numericality: { greater_than_or_equal_to: 0 }
7
9
  end
8
10
  end
9
11
  end
@@ -10,6 +10,10 @@ module Ecom
10
10
 
11
11
  validates :hours, :raw_hours, presence: true
12
12
  validate :validate_overtime_by_type
13
+ validates :hours, presence: true, numericality: { greater_than_or_equal_to: 0 }
14
+ validates :overtime_type_id,
15
+ uniqueness: { scope: :overtime_sheet_entry_id,
16
+ message: 'There exists a crew overtime for the given overtime sheet and overtime type' }
13
17
 
14
18
  scope :by_overtime, lambda { |id|
15
19
  joins(:overtime_sheet_entry).where(ecom_core_overtime_sheet_entries: { overtime_sheet_id: id })
@@ -23,8 +27,11 @@ module Ecom
23
27
 
24
28
  start = Time.zone.parse(overtime_type.from)
25
29
  finish = Time.zone.parse(overtime_type.to)
26
- diff = ((finish - start) / 3600).round
27
-
30
+ diff = if finish >= start
31
+ ((finish - start) / 3600).round
32
+ else
33
+ ((start - finish) / 3600).round
34
+ end
28
35
  return unless raw_hours > diff
29
36
 
30
37
  errors.add(:crew_overtime, 'The selected overtime type does not allow the specified amount of hours.')
@@ -13,6 +13,7 @@ module Ecom
13
13
 
14
14
  validates :checkin_time, presence: true, if: :checkout_time
15
15
  validate :time_range_validation, :total_time_validation
16
+ validates :hours, presence: true, numericality: { greater_than_or_equal_to: 0 }
16
17
 
17
18
  scope :by_attendance, lambda { |id|
18
19
  joins(:attendance_sheet_entry).where(ecom_core_attendance_sheet_entries: { attendance_sheet_id: id })
@@ -31,9 +32,13 @@ module Ecom
31
32
  def total_time_validation
32
33
  return if checkout_time.nil? || checkin_time.nil?
33
34
 
34
- return unless attendance_sheet_entry.total_hours + compute_hours > 8
35
-
36
- errors.add(:attendance_sheet_entry, 'has more than 8 hours')
35
+ if new_record? & !persisted?
36
+ if attendance_sheet_entry.total_hours + compute_hours > 8
37
+ errors.add(:attendance_sheet_entry, 'has more than 8 hours')
38
+ end
39
+ elsif attendance_sheet_entry.total_hours + compute_hours - computed_hour > 8
40
+ errors.add(:attendance_sheet_entry, 'has more than 8 hours')
41
+ end
37
42
  end
38
43
 
39
44
  def calculate_hours
@@ -109,6 +114,21 @@ module Ecom
109
114
  time -= 1 if day_part == FULL_DAY
110
115
  time
111
116
  end
117
+
118
+ # A similar method as `compute_hours` but this one computes hours for
119
+ # the the currently presisted checkin_time and checkout_time
120
+ def computed_hour
121
+ # Reparse time to avoid errors caused by date differences
122
+ range = define_range
123
+ start = Time.zone.parse(checkin_time_was.strftime('%I:%M%p'))
124
+ finish = Time.zone.parse(checkout_time_was.strftime('%I:%M%p'))
125
+ day_part = find_range(start, finish)
126
+ left = start.before?(range[day_part][:start]) ? range[day_part][:start] : start
127
+ right = finish.after?(range[day_part][:finish]) ? range[day_part][:finish] : finish
128
+ time = (right - left) / 1.hour
129
+ time -= 1 if day_part == FULL_DAY
130
+ time
131
+ end
112
132
  end
113
133
  end
114
134
  end
@@ -4,6 +4,8 @@ module Ecom
4
4
  belongs_to :overtime_sheet
5
5
  belongs_to :crew
6
6
  has_many :crew_overtimes
7
+
8
+ validates :total_overtime, presence: true, numericality: { greater_than_or_equal_to: 0 }
7
9
  end
8
10
  end
9
11
  end
@@ -5,7 +5,7 @@ module Ecom
5
5
  belongs_to :payment
6
6
 
7
7
  validates :hours, :ot_hours, :base_salary, :overtime, :gross_salary, :tax, :pension, :net_salary, :net_pay,
8
- :advance, presence: true
8
+ :advance, presence: true, numericality: { greater_than_or_equal_to: 0 }
9
9
  end
10
10
  end
11
11
  end
@@ -4,7 +4,6 @@ module Ecom
4
4
  has_ancestry
5
5
 
6
6
  belongs_to :task_template_type
7
- belongs_to :unit_of_measure
8
7
 
9
8
  has_many :task_template_inspection_checklists
10
9
  has_many :inspection_checklists, through: :task_template_inspection_checklists
@@ -12,7 +11,7 @@ module Ecom
12
11
  has_many :work_product_templates, through: :project_work_item_templates
13
12
  has_and_belongs_to_many :resource_types, join_table: 'ecom_core_task_templates_resource_types'
14
13
 
15
- validates :name, :code, :takeoff_fields, :task_completion_detail, presence: true
14
+ validates :name, :code, presence: true
16
15
  validates :code, uniqueness: true
17
16
  validates :percentage_contribution,
18
17
  numericality: {
@@ -0,0 +1,19 @@
1
+ module Ecom
2
+ module Core
3
+ class FilterService
4
+ def get_filtered_data(type, filters)
5
+ positive = {}
6
+ negative = {}
7
+ obj = type.constantize
8
+ filters.each { |f|
9
+ if f[:cond] == 'P'
10
+ positive[f[:key]] = f[:value]
11
+ else
12
+ negative[f[:key]] = f[:value]
13
+ end
14
+ }
15
+ obj.where(positive).where.not(negative)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -9,12 +9,12 @@ module Ecom
9
9
  SQL
10
10
  menu = Menu.joins(join_sql).where('UR.id IN (?)', role_ids).order(:id).distinct
11
11
  menu_list = menu.select { |m| m.parent.nil? }.each_with_object([]) do |item, list|
12
- list << { id: item.id, text: item.label, iconCss: item.icon, items: [] }
12
+ list << { id: item.id, label: item.label, icon: item.icon, items: [] }
13
13
  end
14
14
 
15
15
  menu_list.each do |ml|
16
16
  ml[:items] = menu.reject { |m| m.parent.nil? }.each_with_object([]) do |item, list|
17
- list << { id: item.id, text: item.label, iconCss: item.icon, url: item.route } if item.parent_id == ml[:id]
17
+ list << { id: item.id, label: item.label, icon: item.icon, url: item.route } if item.parent_id == ml[:id]
18
18
  end
19
19
  end
20
20
  { success: true, data: menu_list }
@@ -8,18 +8,14 @@ class CreateEcomCoreTaskTemplates < ActiveRecord::Migration[6.0]
8
8
  null: false,
9
9
  index: { name: 'tt_on_ttt_indx' },
10
10
  foreign_key: { to_table: :ecom_core_task_template_types }
11
- t.references :unit_of_measure,
12
- null: false,
13
- index: { name: 'tt_on_uof_indx' },
14
- foreign_key: { to_table: :ecom_core_unit_of_measures }
15
11
  t.string :ancestry, index: true
16
- t.boolean :has_takeoff_fields, null:false, default: false
17
- t.jsonb :takeoff_fields, null: false, default: {}
12
+ t.boolean :has_takeoff_fields, null: false, default: false
13
+ t.jsonb :takeoff_fields, null: true
18
14
  t.integer :percentage_contribution
19
15
  t.integer :task_sequence
20
16
  t.boolean :has_inspection, null: false, default: false
21
17
  t.boolean :discipline, null: false, default: false
22
- t.jsonb :task_completion_detail, null: false, default: {}
18
+ t.jsonb :task_completion_detail, null: true
23
19
 
24
20
  t.timestamps
25
21
  end
@@ -23,5 +23,6 @@ class CreateEcomCoreCrewOvertimes < ActiveRecord::Migration[6.0]
23
23
 
24
24
  t.timestamps
25
25
  end
26
+ add_index :ecom_core_crew_overtimes, [:overtime_type_id, :overtime_sheet_entry_id],unique: true, name: 'ot_on_ose_name_indx'
26
27
  end
27
28
  end
@@ -8,7 +8,7 @@ class CreateEcomCoreCrewIdCards < ActiveRecord::Migration[6.0]
8
8
 
9
9
  t.datetime :issued_on, null: false
10
10
  t.datetime :valid_until, null: false
11
- t.string :status, null: false, default: 'Active'
11
+ t.string :status, null: false, default: 'Valid'
12
12
 
13
13
  t.timestamps
14
14
  end
@@ -1,5 +1,5 @@
1
1
  module Ecom
2
2
  module Core
3
- VERSION = '1.3.1'.freeze
3
+ VERSION = '1.3.6'.freeze
4
4
  end
5
5
  end
@@ -6,7 +6,6 @@ FactoryBot.define do
6
6
  name { FFaker::Name.name }
7
7
  description { FFaker::Name.name }
8
8
  association :task_template_type
9
- association :unit_of_measure
10
9
  has_takeoff_fields { false }
11
10
  takeoff_fields { [{ name: 'length', label: 'Length' }] }
12
11
  percentage_contribution { nil }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecom_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-17 00:00:00.000000000 Z
11
+ date: 2021-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm
@@ -375,6 +375,7 @@ files:
375
375
  - app/serializers/ecom/core/user_role_serializer.rb
376
376
  - app/serializers/ecom/core/user_serializer.rb
377
377
  - app/services/ecom/core/crew_contract_transaction_service.rb
378
+ - app/services/ecom/core/filter_service.rb
378
379
  - app/services/ecom/core/menu_service.rb
379
380
  - app/services/ecom/core/site_crew_service.rb
380
381
  - app/services/ecom/core/token_auth_service.rb
@@ -571,7 +572,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
571
572
  - !ruby/object:Gem::Version
572
573
  version: '0'
573
574
  requirements: []
574
- rubygems_version: 3.1.4
575
+ rubygems_version: 3.1.2
575
576
  signing_key:
576
577
  specification_version: 4
577
578
  summary: Core engine for construction management application.