cats_core 1.4.33 → 1.4.36

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: e34b55e4d9cc5537027134594fd2f39946cd9b1001ab3a3d20c24109402a7797
4
- data.tar.gz: 2437a6f18cab7ce976653738467dd0849182281f2fb1e5b2e832390538adf112
3
+ metadata.gz: 9b1a42d7b3cdd50ebcdcb1636aadeeeda8ecc3e9103f2ddf073c991f254d6fc5
4
+ data.tar.gz: 5bbee2e2655b3cb7d8d1f907ff941d4652e4e9058c9b7864dce87f0ad46cfef2
5
5
  SHA512:
6
- metadata.gz: a574e2522a5d9c2ba8257ee18c5217023c23e7b6f5d69dddd9dc0d81f9169a697afc6fde167f4b41a36fd861f78abc7a3b3ad156859a1e49dc1bf412dab771e4
7
- data.tar.gz: f1d30af5df117fb71047df56a7602024df16270e2531c94e65acf1f77e58fe56f3a895e64c14d6629ae88ce0b48f1a4aa3e3095c2bb5872cda31d44ad0c52a16
6
+ metadata.gz: 7a9b2a00fa941cabd75a6b0dccc6ed2eb0aa8402315759d27a76786a25070193eab2ffc20c43dfe195d5353b914f9cf765578aaed6895257efb2a8360a6c2a7b
7
+ data.tar.gz: '09237ecb718238ad54943cdd534c99afce076e6afdaedfaf116c87ba68f5b0a81e6a9a6f1086504986c3f89411266ef2d0bb82c353b87ce76c23598eb93039cc'
@@ -18,7 +18,7 @@ module Cats
18
18
 
19
19
  def model_params
20
20
  params.require(:payload).permit(:reference_no, :dispatch_plan_id, :source_id, :destination_id, :quantity,
21
- :commodity_status, :status, :commodity_id)
21
+ :unit_id, :commodity_status, :status, :commodity_id)
22
22
  end
23
23
  end
24
24
  end
@@ -19,6 +19,12 @@ module Cats
19
19
  render json: { success: true, data: serialize(query.result) }
20
20
  end
21
21
 
22
+ def woredas
23
+ region = Location.find(params[:id])
24
+ woredas = Location.where(id: region.descendant_ids, location_type: Location::WOREDA)
25
+ render json: { success: true, data: serialize(woredas) }
26
+ end
27
+
22
28
  private
23
29
 
24
30
  def model_params
@@ -12,7 +12,8 @@ module Cats
12
12
  private
13
13
 
14
14
  def model_params
15
- params.require(:payload).permit(:receipt_authorization_id, :commodity_status, :commodity_grade, :quantity, :remark)
15
+ params.require(:payload).permit(:receipt_authorization_id, :commodity_status, :commodity_grade, :quantity,
16
+ :remark)
16
17
  end
17
18
  end
18
19
  end
@@ -11,6 +11,7 @@ module Cats
11
11
  belongs_to :destination, class_name: 'Cats::Core::Location'
12
12
  belongs_to :dispatch_plan
13
13
  belongs_to :commodity
14
+ belongs_to :unit, class_name: 'Cats::Core::UnitOfMeasure'
14
15
 
15
16
  has_many :dispatches
16
17
  has_many :hub_authorizations
@@ -26,6 +27,8 @@ module Cats
26
27
  delegate(:name, to: :destination, prefix: true)
27
28
  delegate(:location_type, to: :source, prefix: true)
28
29
  delegate(:location_type, to: :destination, prefix: true)
30
+ delegate(:abbreviation, to: :unit, prefix: true)
31
+ delegate(:shipping_reference, to: :commodity, prefix: true)
29
32
 
30
33
  # Authorize a dispatch plan item if it contains authorization entries
31
34
  # under it. A dispatch plan item can be authorized by source hub, or
@@ -3,7 +3,8 @@ module Cats
3
3
  class DispatchPlanItemSerializer < ActiveModel::Serializer
4
4
  attributes :id, :reference_no, :dispatch_plan_id, :plan_reference_no, :source_id, :source_name, :destination_id,
5
5
  :destination_name, :quantity, :source_location_type, :destination_location_type, :commodity_status,
6
- :status, :commodity_id, :commodity_name, :commodity_batch_no
6
+ :status, :commodity_id, :commodity_name, :commodity_batch_no, :unit_abbreviation,
7
+ :commodity_shipping_reference
7
8
  end
8
9
  end
9
10
  end
@@ -7,7 +7,7 @@ module Cats
7
7
 
8
8
  raise(StandardError, 'Plan has no plan items.') if round_plan.round_plan_items.count.zero?
9
9
 
10
- round_plan.round_plan_item_details.delete_all if round_plan.round_plan_item_details.count.positive?
10
+ clear_needs(round_plan.id)
11
11
 
12
12
  details = []
13
13
  rations = round_plan.round_rations
@@ -32,6 +32,13 @@ module Cats
32
32
  round_plan
33
33
  end
34
34
 
35
+ def clear_needs(plan_id)
36
+ Cats::Core::RoundPlanItemDetail
37
+ .joins(beneficiary_round_plan_item: :round_plan_item)
38
+ .where(cats_core_beneficiary_round_plan_items: { cats_core_round_plan_items: { round_plan_id: plan_id } })
39
+ .delete_all
40
+ end
41
+
35
42
  def generate_round_plan(reference_no, rounds, plan_id, region_id)
36
43
  round_plan = Cats::Core::RoundPlan.create!(
37
44
  plan_id: plan_id,
data/config/routes.rb CHANGED
@@ -39,6 +39,7 @@ Cats::Core::Engine.routes.draw do
39
39
  end
40
40
  end
41
41
 
42
+ get '/regions/:id/woredas', controller: :locations, action: :woredas, as: :region_woredas
42
43
  post '/locations/filter', controller: :locations, action: :filter
43
44
  resources :locations, except: %i[destroy] do
44
45
  member do
@@ -19,6 +19,10 @@ class CreateCatsCoreDispatchPlanItems < ActiveRecord::Migration[6.1]
19
19
  index: { name: 'commodity_on_dpi_indx' },
20
20
  foreign_key: { to_table: :cats_core_commodities }
21
21
  t.float :quantity, null: false
22
+ t.references :unit,
23
+ null: false,
24
+ index: { name: 'unit_on_dpi_indx' },
25
+ foreign_key: { to_table: :cats_core_unit_of_measures }
22
26
  t.string :commodity_status, null: false, default: 'Good'
23
27
  t.string :status, null: false, default: 'Unauthorized'
24
28
 
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.4.33'.freeze
3
+ VERSION = '1.4.36'.freeze
4
4
  end
5
5
  end
@@ -5,6 +5,7 @@ FactoryBot.define do
5
5
  destination factory: :location
6
6
  dispatch_plan
7
7
  quantity { 100 }
8
+ unit factory: :unit_of_measure
8
9
  commodity
9
10
  commodity_status { Cats::Core::Commodity::GOOD }
10
11
  status { Cats::Core::DispatchPlanItem::UNAUTHORIZED }
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.33
4
+ version: 1.4.36
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-05 00:00:00.000000000 Z
11
+ date: 2022-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers