cats_core 1.3.40 → 1.4.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1563c8d3250c1cda415de5081c46f445a82f593c727be676c3f9a7041f28fa7
|
4
|
+
data.tar.gz: b614991a9f6a2a4046c7c4e54af584d59a33478c62b5a0c6dee77ddbbdad2e6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff00ffac606dfa2136aaaed05a6825238b5ae38f737f4a3790db2b94193f0108b6d394097c0828339af8aab226acf871d65ddefa68c54ad929a47e7069d9d49b
|
7
|
+
data.tar.gz: fd1b163787f8fc21ba49f79929f027143f1a45d74425518536d9adc4369eb33ea6ab9b96a30fb34b7cba6e9f8ba11e2f9f191acd83200debf91589cc9be490e3
|
@@ -16,7 +16,8 @@ module Cats
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def model_params
|
19
|
-
params.require(:payload).permit(:dispatch_plan_id, :source_id, :destination_id, :quantity, :commodity_status
|
19
|
+
params.require(:payload).permit(:dispatch_plan_id, :source_id, :destination_id, :quantity, :commodity_status,
|
20
|
+
:status)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
@@ -12,15 +12,17 @@ module Cats
|
|
12
12
|
|
13
13
|
def message
|
14
14
|
allocation_item = params[:allocation_item]
|
15
|
-
commodity = allocation_item.
|
15
|
+
commodity = allocation_item.dispatch_plan.commodity.name
|
16
|
+
source = allocation_item.source.name
|
17
|
+
destination = allocation_item.destination.name
|
16
18
|
title = "Allocation Notification - #{commodity}"
|
17
19
|
date = Date.today
|
18
20
|
body = <<~BODY
|
19
21
|
Commodity with the following specification has been allocated to you:
|
20
|
-
Batch No. = #{allocation_item.
|
22
|
+
Batch No. = #{allocation_item.dispatch_plan.commodity.batch_no}
|
21
23
|
Commodity = #{commodity}
|
22
24
|
Quantity = #{allocation_item.quantity}
|
23
|
-
The commodity is expected to be delivered from #{
|
25
|
+
The commodity is expected to be delivered from #{source} to #{destination}
|
24
26
|
BODY
|
25
27
|
{ title: title, date: date, body: body }
|
26
28
|
end
|
@@ -25,7 +25,7 @@ module Cats
|
|
25
25
|
plan.dispatch_plan_items.update_all(status: DispatchPlanItem::SOURCE_AUTHORIZED)
|
26
26
|
plan.dispatchable.allocate
|
27
27
|
end
|
28
|
-
|
28
|
+
send_notification(plan)
|
29
29
|
plan
|
30
30
|
end
|
31
31
|
|
@@ -37,6 +37,28 @@ module Cats
|
|
37
37
|
rescue ActiveRecord::RecordInvalid
|
38
38
|
raise(StandardError, plan.errors.full_messages[0])
|
39
39
|
end
|
40
|
+
|
41
|
+
def send_notification(allocation)
|
42
|
+
notification_rule = Cats::Core::NotificationRule.find_by(code: 'allocation')
|
43
|
+
raise(StandardError, 'Notification rule not found for allocation notification.') unless notification_rule
|
44
|
+
|
45
|
+
users = Cats::Core::User.joins(:roles).where(cats_core_roles: { name: notification_rule.roles })
|
46
|
+
allocation.dispatch_plan_items.each do |item|
|
47
|
+
location_id = item.destination_id
|
48
|
+
|
49
|
+
recipients = users.map do |user|
|
50
|
+
details = user.details
|
51
|
+
if (details.key?('warehouse') && details['warehouse'] == location_id) ||
|
52
|
+
(details.key?('hub') && details['hub'] == location_id)
|
53
|
+
user
|
54
|
+
end
|
55
|
+
end.compact
|
56
|
+
unless recipients.empty?
|
57
|
+
notification = Cats::Core::AllocationNotification.with(allocation_item: item)
|
58
|
+
notification.deliver(recipients)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
40
62
|
end
|
41
63
|
end
|
42
64
|
end
|
data/lib/cats/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cats_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|