ecom_core 1.2.20 → 1.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57de1b5bb610121618f09d6623d8f83e5c38e4d0f91415264c0c90008c4aca92
4
- data.tar.gz: 2d1c048ac5692e8675a86a3fd769f5a3200be47d7790fd7df1ac25a7f1e6b045
3
+ metadata.gz: 76cfd20fab207f93e180437a06181c5a72c682b358918d9187d37a7e63639eb4
4
+ data.tar.gz: 1013344fd51d5226101fa61b7517c3e69eb05d9e05b38f6984b6cf29684810a4
5
5
  SHA512:
6
- metadata.gz: 5d32fb2ceea452a4327a86d3b0521ba719ed45bbf1392c754270686aeca4fb406bba683bb4ce7a60748ddcbd74f7fe1f955701eea507d5077b10ab6dfa23ac0c
7
- data.tar.gz: 2a89d665d5ca5899193ce27d423ada50b36bf03a5a728c803b7839e0d15bab8a875eebd43152d66fbe7e378fdfd7522ac80cc4763f0903cfc7c1bcc195dbb4ec
6
+ metadata.gz: bfb8306c686dcfdae803be799e979d072de88abec6a81dda73e2db6916e444826947b7b7d7bf9868bccc950698b8a8d5b29eab2dfe30876ca7036b71250cb10b
7
+ data.tar.gz: 889d5da78b1bc946007b65fd923272106f79d9839f94673a78967d5a9815bc5becec7288ad56c9306504a67808f3f3ca74d99d78afedf801e439901dd89dd88a
@@ -61,7 +61,7 @@ module Ecom
61
61
 
62
62
  raise 'There is no open attendance sheet to submit.' if sheet.nil?
63
63
 
64
- sheet.closed_at = Time.now
64
+ sheet.submitted_at = DateTime.now
65
65
  sheet.status = StatusConstants::SUBMITTED
66
66
  sheet.save
67
67
  sheet
@@ -75,11 +75,27 @@ module Ecom
75
75
  sheet = AttendanceSheet.open_for_date(date, project_id)
76
76
  raise 'There is no open attendance sheet to submit for the selected day.' unless sheet
77
77
 
78
- sheet.closed_at = Time.now
78
+ sheet.submitted_at = DateTime.now
79
79
  sheet.status = StatusConstants::SUBMITTED
80
80
  sheet.save
81
81
  sheet
82
82
  end
83
+
84
+ def submit
85
+ raise 'Attendance sheet is not open and cannot be submitted' if status != StatusConstants::OPEN
86
+
87
+ self.submitted_at = DateTime.now
88
+ self.status = StatusConstants::SUBMITTED
89
+ save
90
+ end
91
+
92
+ def approve
93
+ raise 'Attendance sheet is not submitted and cannot be approved' unless status == StatusConstants::SUBMITTED
94
+
95
+ self.status = StatusConstants::APPROVED
96
+ self.approved_at = DateTime.now
97
+ save
98
+ end
83
99
  end
84
100
  end
85
101
  end
@@ -44,6 +44,22 @@ module Ecom
44
44
 
45
45
  OvertimeSheet.create(date: date, opened_at: Time.now, status: StatusConstants::OPEN, project_id: project_id)
46
46
  end
47
+
48
+ def submit
49
+ raise 'Overtime sheet is not open and cannot be submitted' if status != StatusConstants::OPEN
50
+
51
+ self.submitted_at = DateTime.now
52
+ self.status = StatusConstants::SUBMITTED
53
+ save
54
+ end
55
+
56
+ def approve
57
+ raise 'Overtime sheet is not submitted and cannot be approved' unless status == StatusConstants::SUBMITTED
58
+
59
+ self.status = StatusConstants::APPROVED
60
+ self.approved_at = DateTime.now
61
+ save
62
+ end
47
63
  end
48
64
  end
49
65
  end
@@ -7,6 +7,8 @@ module Ecom
7
7
 
8
8
  before_validation :set_payment_order
9
9
 
10
+ scope :by_status, ->(status) { where(approved: status) }
11
+
10
12
  def set_payment_order
11
13
  unless payroll
12
14
  self.payment_order = 1
@@ -9,6 +9,16 @@ module Ecom
9
9
  scope :by_project, ->(id) { where(project_id: id) }
10
10
  scope :by_month, ->(month) { where(month: month) }
11
11
  scope :by_year, ->(year) { where(year: year) }
12
+
13
+ def create_next
14
+ m = payroll.month + 1
15
+ y = payroll.year
16
+ if m > 12
17
+ m = 1
18
+ y += 1
19
+ end
20
+ Payroll.create(month: m, year: y)
21
+ end
12
22
  end
13
23
  end
14
24
  end
@@ -2,8 +2,9 @@ class CreateEcomCoreAttendanceSheets < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  create_table :ecom_core_attendance_sheets do |t|
4
4
  t.date :date, null: false
5
- t.time :opened_at, null: false
6
- t.time :closed_at
5
+ t.datetime :opened_at, null: false
6
+ t.datetime :submitted_at
7
+ t.datetime :approved_at
7
8
  t.string :remark
8
9
  t.string :status, null: false, default: 'Open'
9
10
  t.references :project,
@@ -2,8 +2,9 @@ class CreateEcomCoreOvertimeSheets < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  create_table :ecom_core_overtime_sheets do |t|
4
4
  t.date :date, null: false
5
- t.time :opened_at, null: false
6
- t.time :submitted_at
5
+ t.datetime :opened_at, null: false
6
+ t.datetime :submitted_at
7
+ t.datetime :approved_at
7
8
  t.string :remark
8
9
  t.string :status, null: false, default: 'Open'
9
10
  t.references :project,
@@ -1,5 +1,5 @@
1
1
  module Ecom
2
2
  module Core
3
- VERSION = '1.2.20'.freeze
3
+ VERSION = '1.2.21'.freeze
4
4
  end
5
5
  end
@@ -3,6 +3,8 @@ FactoryBot.define do
3
3
  sequence :code do |n|
4
4
  "AMCode#{n}"
5
5
  end
6
- name { FFaker::Name.name }
6
+ sequence :name do |n|
7
+ "AMName#{n}"
8
+ end
7
9
  end
8
10
  end
@@ -1,8 +1,9 @@
1
1
  FactoryBot.define do
2
2
  factory :attendance_sheet, class: Ecom::Core::AttendanceSheet do
3
3
  date { Date.today }
4
- opened_at { Time.now }
5
- closed_at { nil }
4
+ opened_at { DateTime.now }
5
+ submitted_at { nil }
6
+ approved_at { nil }
6
7
  remark { FFaker::Name.name }
7
8
  status { Ecom::Core::StatusConstants::OPEN }
8
9
  association :project
@@ -3,7 +3,9 @@ FactoryBot.define do
3
3
  sequence :code do |n|
4
4
  "CCode#{n}"
5
5
  end
6
- name { FFaker::Name.name }
6
+ sequence :name do |n|
7
+ "CName#{n}"
8
+ end
7
9
  address { FFaker::Address.street_address }
8
10
  telephone { FFaker::PhoneNumber.phone_number }
9
11
  email { FFaker::Internet.email }
@@ -1,6 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :equipment, class: Ecom::Core::Equipment do
3
- name { FFaker::Name.name }
3
+ sequence :name do |n|
4
+ "EQName#{n}"
5
+ end
4
6
  description { FFaker::Name.name }
5
7
  minimum_acquisition_time { 10 }
6
8
  brands { ['Brand I', 'Brand II', 'Brand III'] }
@@ -1,6 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :equipment_category, class: Ecom::Core::EquipmentCategory do
3
- name { FFaker::Name.name }
3
+ sequence :name do |n|
4
+ "ECName#{n}"
5
+ end
4
6
  description { FFaker::Name.name }
5
7
  association :equipment_type
6
8
  end
@@ -1,6 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :equipment_location, class: Ecom::Core::EquipmentLocation do
3
- name { FFaker::Name.name }
3
+ sequence :name do |n|
4
+ "ELName#{n}"
5
+ end
4
6
  description { FFaker::Name.name }
5
7
  address { FFaker::Name.name }
6
8
  association :location_type
@@ -1,6 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :lookup, class: Ecom::Core::Lookup do
3
- name { FFaker::Name.name }
3
+ sequence :name do |n|
4
+ "LName#{n}"
5
+ end
4
6
  type { 'Ecom::Core::Lookup' }
5
7
  end
6
8
  end
@@ -1,8 +1,9 @@
1
1
  FactoryBot.define do
2
2
  factory :overtime_sheet, class: Ecom::Core::OvertimeSheet do
3
3
  date { Date.today }
4
- opened_at { Time.now }
5
- submitted_at { Time.now + 1.day }
4
+ opened_at { DateTime.now }
5
+ submitted_at { nil }
6
+ approved_at { nil }
6
7
  status { Ecom::Core::StatusConstants::OPEN }
7
8
  association :project
8
9
  end
@@ -1,6 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :overtime_type, class: Ecom::Core::OvertimeType do
3
- name { FFaker::Name.name }
3
+ sequence :name do |n|
4
+ "OTName#{n}"
5
+ end
4
6
  from { '07:00 AM' }
5
7
  to { '08:00 AM' }
6
8
  rate { 1.5 }
@@ -1,6 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :product_group, class: Ecom::Core::ProductGroup do
3
- name { FFaker::Name.name }
3
+ sequence :name do |n|
4
+ "PGName#{n}"
5
+ end
4
6
  association :project
5
7
  end
6
8
  end
@@ -1,6 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :product_type, class: Ecom::Core::ProductType do
3
- name { FFaker::Name.name }
3
+ sequence :name do |n|
4
+ "PTname#{n}"
5
+ end
4
6
  association :work_product_template
5
7
  dimension { [{ name: 'length', label: 'length' }, { name: 'width', label: 'width' }] }
6
8
  end
@@ -3,7 +3,9 @@ FactoryBot.define do
3
3
  sequence :code do |n|
4
4
  "RTCode#{n}"
5
5
  end
6
- name { FFaker::Name.name }
6
+ sequence :name do |n|
7
+ "RTName#{n}"
8
+ end
7
9
  base_unit { FFaker::Name.name }
8
10
  type { 'Ecom::Core::CrewType' }
9
11
  end
@@ -1,5 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :stakeholder_type, class: Ecom::Core::StakeholderType do
3
- name { FFaker::Name.name }
3
+ sequence :name do |n|
4
+ "STName#{n}"
5
+ end
4
6
  end
5
7
  end
@@ -1,6 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :stakeholder, class: Ecom::Core::Stakeholder do
3
- name { FFaker::Name.unique.name }
3
+ sequence :name do |n|
4
+ "Stakeholder #{n}"
5
+ end
4
6
  type_of_business { FFaker::Name.name }
5
7
  address { FFaker::Name.name }
6
8
  license_no { FFaker::Name.name }
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.2.20
4
+ version: 1.2.21
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-07-25 00:00:00.000000000 Z
11
+ date: 2020-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm