ecom_core 1.2.19 → 1.2.24
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 +4 -4
- data/app/models/ecom/core/attendance_sheet.rb +18 -2
- data/app/models/ecom/core/company.rb +23 -0
- data/app/models/ecom/core/crew.rb +1 -0
- data/app/models/ecom/core/overtime_sheet.rb +16 -0
- data/app/models/ecom/core/payment.rb +2 -0
- data/app/models/ecom/core/payroll.rb +10 -0
- data/app/uploaders/ecom/core/photo_uploader.rb +15 -0
- data/db/migrate/20190101085530_create_ecom_core_companies.rb +1 -1
- data/db/migrate/20191225100054_create_ecom_core_crews.rb +1 -0
- data/db/migrate/20191225140433_create_ecom_core_attendance_sheets.rb +3 -2
- data/db/migrate/20200410090701_create_ecom_core_overtime_sheets.rb +3 -2
- data/lib/ecom/core/version.rb +1 -1
- data/lib/ecom_core.rb +2 -0
- data/spec/factories/ecom/core/application_modules.rb +3 -1
- data/spec/factories/ecom/core/attendance_sheets.rb +3 -2
- data/spec/factories/ecom/core/companies.rb +9 -1
- data/spec/factories/ecom/core/crews.rb +1 -0
- data/spec/factories/ecom/core/currencies.rb +6 -2
- data/spec/factories/ecom/core/equipment.rb +3 -1
- data/spec/factories/ecom/core/equipment_categories.rb +3 -1
- data/spec/factories/ecom/core/equipment_locations.rb +3 -1
- data/spec/factories/ecom/core/lookups.rb +3 -1
- data/spec/factories/ecom/core/overtime_sheets.rb +3 -2
- data/spec/factories/ecom/core/overtime_types.rb +3 -1
- data/spec/factories/ecom/core/product_groups.rb +3 -1
- data/spec/factories/ecom/core/product_types.rb +3 -1
- data/spec/factories/ecom/core/resource_types.rb +3 -1
- data/spec/factories/ecom/core/stakeholder_types.rb +3 -1
- data/spec/factories/ecom/core/stakeholders.rb +3 -1
- metadata +51 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df898073d93a47b62e3478402f39348fb1ebce76fcb15247cbaae48b1f20da8b
|
4
|
+
data.tar.gz: 9b0e8f96058c4fcb320e42f4559c7f6ad951414935f8ad369e0d1b3f6cdd4f80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79e71c70e77d0dfdb3b13141f2be198fe8ab989293af0b7cb82b1bcb661d1a8b9f1b6604a50074c7a8c8d992e9db618720c4520702237b8b280215c4209b57c0
|
7
|
+
data.tar.gz: 5d881608dee92bd62f78e777d2b4eadeadcf80faa89852c9d1af820ff900fd373b812a4763a80949d6eec6a5bbeb17ac256404f2b7a729b6dfef63431f9a3761
|
@@ -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.
|
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.
|
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
|
@@ -1,10 +1,33 @@
|
|
1
1
|
module Ecom
|
2
2
|
module Core
|
3
3
|
class Company < ApplicationRecord
|
4
|
+
# The settings attribute is a json string containing setting key value
|
5
|
+
# pairs. The valid settings are:
|
6
|
+
# payroll_periods => a list of payroll period values. Each
|
7
|
+
# payroll period has the following entries:
|
8
|
+
# order: A numeric value indicating the order of the period.
|
9
|
+
# date: A numeric value indicating the date of each month which
|
10
|
+
# upto which timesheet data is used for payroll calculation
|
11
|
+
# for the specific period.
|
12
|
+
# comparison: One of [:exact, :days_before_month_end]. :exact will
|
13
|
+
# force calculations to be made upto the exact mentioned date
|
14
|
+
# value, whereas :days_before_month_end is often used for last
|
15
|
+
# period payroll calculation and we want to specify on which date
|
16
|
+
# before the end of the month we have to limit timesheet data to
|
17
|
+
# calculate payroll. E.g. 3 days before month end would be 27th
|
18
|
+
# for september and 28th for october.
|
19
|
+
#
|
20
|
+
# period_count - the total number of periods per month for payroll.
|
21
|
+
# this value should align with the defined payroll periods.
|
22
|
+
#
|
4
23
|
has_many :projects
|
5
24
|
|
6
25
|
validates :code, :name, :address, :telephone, presence: true
|
7
26
|
validates :code, :name, uniqueness: true
|
27
|
+
|
28
|
+
def valid_settings?
|
29
|
+
settings['payroll_periods'].count == settings['period_count']
|
30
|
+
end
|
8
31
|
end
|
9
32
|
end
|
10
33
|
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
|
@@ -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 = month + 1
|
15
|
+
y = year
|
16
|
+
if m > 12
|
17
|
+
m = 1
|
18
|
+
y += 1
|
19
|
+
end
|
20
|
+
Payroll.create(month: m, year: y, project_id: project_id)
|
21
|
+
end
|
12
22
|
end
|
13
23
|
end
|
14
24
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class PhotoUploader < CarrierWave::Uploader::Base
|
4
|
+
storage :file
|
5
|
+
|
6
|
+
def store_dir
|
7
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def extension_whitelist
|
11
|
+
%w[jpg jpeg gif png]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -12,6 +12,7 @@ class CreateEcomCoreCrews < ActiveRecord::Migration[6.0]
|
|
12
12
|
t.string :wage_in_words, null: false
|
13
13
|
t.date :employment_date
|
14
14
|
t.boolean :sub_contracted, null: false, default: false
|
15
|
+
t.string :photo
|
15
16
|
t.string :guarantor_name
|
16
17
|
t.string :guarantor_phone
|
17
18
|
t.boolean :active, null: false, default: true
|
@@ -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.
|
6
|
-
t.
|
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.
|
6
|
-
t.
|
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,
|
data/lib/ecom/core/version.rb
CHANGED
data/lib/ecom_core.rb
CHANGED
@@ -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 {
|
5
|
-
|
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,9 +3,17 @@ FactoryBot.define do
|
|
3
3
|
sequence :code do |n|
|
4
4
|
"CCode#{n}"
|
5
5
|
end
|
6
|
-
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 }
|
12
|
+
settings do
|
13
|
+
{
|
14
|
+
payroll_periods: [{ order: 1, date: 25, comparison: :exact }],
|
15
|
+
period_count: 1
|
16
|
+
}
|
17
|
+
end
|
10
18
|
end
|
11
19
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :equipment, class: Ecom::Core::Equipment do
|
3
|
-
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,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 {
|
5
|
-
submitted_at {
|
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 :product_type, class: Ecom::Core::ProductType do
|
3
|
-
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
|
@@ -1,6 +1,8 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :stakeholder, class: Ecom::Core::Stakeholder do
|
3
|
-
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.
|
4
|
+
version: 1.2.24
|
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
|
11
|
+
date: 2020-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aasm
|
@@ -38,6 +38,26 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.10.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: after_commit_everywhere
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.1'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 0.1.5
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0.1'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.1.5
|
41
61
|
- !ruby/object:Gem::Dependency
|
42
62
|
name: ancestry
|
43
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +86,34 @@ dependencies:
|
|
66
86
|
- - ">="
|
67
87
|
- !ruby/object:Gem::Version
|
68
88
|
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: carrierwave
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: carrierwave-base64
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
69
117
|
- !ruby/object:Gem::Dependency
|
70
118
|
name: jwt
|
71
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -258,6 +306,7 @@ files:
|
|
258
306
|
- app/serializers/ecom/core/user_serializer.rb
|
259
307
|
- app/services/ecom/core/menu_service.rb
|
260
308
|
- app/services/ecom/core/token_auth_service.rb
|
309
|
+
- app/uploaders/ecom/core/photo_uploader.rb
|
261
310
|
- app/validators/ecom/core/date_range_validator.rb
|
262
311
|
- config/database.ci.yml
|
263
312
|
- config/routes.rb
|