cats_core 1.4.36 → 1.4.37

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: 9b1a42d7b3cdd50ebcdcb1636aadeeeda8ecc3e9103f2ddf073c991f254d6fc5
4
- data.tar.gz: 5bbee2e2655b3cb7d8d1f907ff941d4652e4e9058c9b7864dce87f0ad46cfef2
3
+ metadata.gz: f2ea0d3a39edea3ab29b38b312d3d2e31e16ba07d54c0f985f5ceb248869fef4
4
+ data.tar.gz: 02e0ba07bbc6bf360a637a215faa26de072c2fe3d955547b9ba68193eca1220e
5
5
  SHA512:
6
- metadata.gz: 7a9b2a00fa941cabd75a6b0dccc6ed2eb0aa8402315759d27a76786a25070193eab2ffc20c43dfe195d5353b914f9cf765578aaed6895257efb2a8360a6c2a7b
7
- data.tar.gz: '09237ecb718238ad54943cdd534c99afce076e6afdaedfaf116c87ba68f5b0a81e6a9a6f1086504986c3f89411266ef2d0bb82c353b87ce76c23598eb93039cc'
6
+ metadata.gz: 9c2f4ba51cc505f5320d2dee177e5cfa1e42d72bc8bd0b69b3128141b568354220a3e4b9d681d9412aa740b2ceda1bdc1a118a774f6ff34b1e8656eaff9e08b8
7
+ data.tar.gz: c976d634759281fb71a769495282b74459ed8167eb8c61be21f8566213e7394ee6fd873ba0cc2e3905eb473a56fc8cbdbe427913d40b3e784ca33a9bbcb9296c
@@ -37,7 +37,7 @@ module Cats
37
37
  end
38
38
 
39
39
  def remove_items
40
- plan = @service.remove_items(params[:id], remove_params)
40
+ plan = @service.remove_items(params[:id], remove_params[:ids])
41
41
  render json: { success: true, data: serialize(plan) }
42
42
  rescue StandardError => e
43
43
  render json: { success: false, error: e.message }
@@ -16,7 +16,15 @@ module Cats
16
16
  # Commodity statuses
17
17
  GOOD = 'Good'.freeze
18
18
  DAMAGED = 'Damaged'.freeze
19
- COMMODITY_STATUSES = [GOOD, DAMAGED].freeze
19
+ LEAKAGE = 'Leakage'.freeze
20
+ WET = 'Wet'.freeze
21
+ MOLDY = 'Moldy'.freeze
22
+ INFESTED = 'Infested'.freeze
23
+ INSECT_INFECTED = 'Insect Infected'.freeze
24
+ FAECES_FROM_RODENTS = 'Faeces From Rodents'.freeze
25
+ UNDERWEIGHT_PACKAGE = 'Underweight Package'.freeze
26
+ COMMODITY_STATUSES = [GOOD, DAMAGED, LEAKAGE, WET, MOLDY, INFESTED, INSECT_INFECTED, FAECES_FROM_RODENTS,
27
+ UNDERWEIGHT_PACKAGE].freeze
20
28
 
21
29
  # Arrival Statuses
22
30
  AT_SOURCE = 'At Source'.freeze
@@ -3,7 +3,7 @@ module Cats
3
3
  class DispatchSerializer < ActiveModel::Serializer
4
4
  attributes :id, :reference_no, :dispatch_plan_item_id, :transporter_id, :transporter_name, :plate_no,
5
5
  :driver_name, :driver_phone, :quantity, :remark, :prepared_by_id, :prepared_by_email,
6
- :dispatch_status, :destination, :auth_details
6
+ :dispatch_status, :destination, :auth_details, :unit_id, :commodity_status
7
7
 
8
8
  def destination
9
9
  object.dispatch_plan_item.destination.name
@@ -115,7 +115,7 @@ module Cats
115
115
  .where(beneficiary_round_plan_items: { id: ids })
116
116
  raise(StandardError, 'Round plan items should be from the same plan.') if plans.count > 1
117
117
 
118
- unless plans.count.positive? && plan_id == plans[0].id
118
+ unless plans.count.positive? && plan.id == plans[0].id
119
119
  raise(StandardError, 'Round plan items are not from the given round plan.')
120
120
  end
121
121
 
@@ -146,10 +146,16 @@ module Cats
146
146
  if plan.plan.program.code == 'PSNP'
147
147
  rounds = plan.rounds.count
148
148
  item_ids = plan.beneficiary_round_plan_items.pluck('beneficiary_plan_item_id').flatten
149
- plan_items = BeneficiaryPlanItem.where(id: item_ids)
150
- invalid = plan_items.select { |pi| pi.rounds - (pi.rounds_served || 0) < rounds }
151
- error = 'There are plan items whose served rounds may exceed the allowed number of rounds.'
152
- raise(StandardError, error) if invalid.count.positive?
149
+ plan_items = BeneficiaryPlanItem.includes(plan_item: :fdp).where(id: item_ids)
150
+ invalid = plan_items.select { |pi| pi.rounds - (pi.rounds_served || 0) < rounds }.map do |pi|
151
+ pi.plan_item.fdp.name
152
+ end
153
+
154
+ if invalid.count.positive?
155
+ msg = invalid.join(', ')
156
+ error = "The FDPs [#{msg}] exceeded their allowed number of rounds."
157
+ raise(StandardError, error)
158
+ end
153
159
 
154
160
  items = plan_items.each_with_object([]) do |plan_item, res|
155
161
  rounds_served = plan_item.rounds_served || 0
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.4.36'.freeze
3
+ VERSION = '1.4.37'.freeze
4
4
  end
5
5
  end
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.36
4
+ version: 1.4.37
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-06-06 00:00:00.000000000 Z
11
+ date: 2022-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers