cats_core 1.1.4 → 1.1.8

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: 63d1bc4e2e97985bc79c49007a2d826b43caec3b8fc31eca51fa4f588d22e10f
4
- data.tar.gz: d4d08836b88121d75bd29fb711975726285b9ab5f7b64285ed48349cff51e2e3
3
+ metadata.gz: e88cccfc4e2d6d554ec178e2f7e981462ace4db4fa8e43fb142b617550eadde7
4
+ data.tar.gz: cb8b5bfe4186b7e2394ca8ed765d6a1c5c7c2694f503a031d42f64fce0d3b4c1
5
5
  SHA512:
6
- metadata.gz: 6bc9fdab7012e63bcda95512f54f0fe8586c225a8eec25c88dcc3ed6b0634aa21a6a62ba5e6091f21b718f10d9df93eeabdf0a88a62a78891f244dc2c14d3bac
7
- data.tar.gz: 9ced66786a2d6303d5ea944366cf9357ff9d3a9ab8e4406d2a6c490d8969e0c6431b2265e321a965a2ab10c503bc51e4cbdd40766581f8af6ccf844405f58527
6
+ metadata.gz: 49cb848b9e249982677944e85e91305ebb7997237a570ce9f91cfecfedc058ea7f02052e8e8aea79ae7020ee8618998a48f1d97e26886415b807d619c25dcf73
7
+ data.tar.gz: 6959a9bdb0a8474785fb1a63b6282d0f1030fcf0ed0f182246e310d73681eff892f38f64eb72c24e1d43c47541912f8292694a717676aa56916184fea63c3f47
@@ -4,7 +4,7 @@ module Cats
4
4
  include Common
5
5
 
6
6
  before_action :set_service, only: %i[create_receipt_authorization approve start search confirm]
7
- before_action :set_dispatch, only: %i[approve start confirm]
7
+ before_action :set_dispatch, only: %i[approve start confirm commodity]
8
8
 
9
9
  def index
10
10
  dispatches = Cats::Core::Dispatch.where(allocation_item_id: params[:id])
@@ -56,6 +56,11 @@ module Cats
56
56
  render json: { success: true, data: serialize(data) }
57
57
  end
58
58
 
59
+ def commodity
60
+ data = @dispatch.allocation_item.allocation.commodity
61
+ render json: { success: true, data: serialize(data) }
62
+ end
63
+
59
64
  private
60
65
 
61
66
  def set_service
@@ -17,10 +17,10 @@ module Cats
17
17
  render json: { success: false, error: e.message }
18
18
  end
19
19
 
20
- def stack
20
+ def finish_stacking
21
21
  receipt = Cats::Core::Receipt.find(params[:id])
22
22
  service = ReceiptService.new
23
- result = service.stack(receipt)
23
+ result = service.finish_stacking(receipt)
24
24
  render json: { success: true, data: serialize(result) }
25
25
  rescue StandardError => e
26
26
  render json: { success: false, error: e.message }
@@ -5,6 +5,16 @@ module Cats
5
5
 
6
6
  validates :reference_no, presence: true, uniqueness: true
7
7
  validates :gift_date, presence: true
8
+
9
+ after_create :update_donation
10
+
11
+ def update_donation
12
+ donation = self.donation
13
+ return if donation.active
14
+
15
+ donation.active = true
16
+ donation.save!
17
+ end
8
18
  end
9
19
  end
10
20
  end
@@ -8,6 +8,16 @@ module Cats
8
8
  validates :reference_no, uniqueness: true
9
9
 
10
10
  delegate(:name, to: :commodity_category, prefix: true)
11
+
12
+ after_create :update_donation
13
+
14
+ def update_donation
15
+ donation = self.donation
16
+ return if donation.active
17
+
18
+ donation.active = true
19
+ donation.save!
20
+ end
11
21
  end
12
22
  end
13
23
  end
@@ -0,0 +1,9 @@
1
+ module Cats
2
+ module Core
3
+ class CommoditySerializer < ActiveModel::Serializer
4
+ attributes :id, :batch_no, :description, :unit_of_measure_id, :unit_of_measure_abbreviation, :source_id,
5
+ :source_type, :source_reference_no, :quantity, :best_use_before, :volume_per_metric_ton,
6
+ :commodity_category_id, :commodity_category_name, :arrival_status, :approved
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  class LocationSerializer < ActiveModel::Serializer
2
- attributes :id, :name, :location_type, :description, :parent_id
2
+ attributes :id, :code, :name, :location_type, :description, :parent_id
3
3
  end
@@ -11,7 +11,7 @@ module Cats
11
11
  receipt
12
12
  end
13
13
 
14
- def stack(receipt)
14
+ def finish_stacking(receipt)
15
15
  unless receipt.status == Cats::Core::Receipt::STACKING
16
16
  raise(StandardError, 'Receipt should be in stacking state.')
17
17
  end
data/config/routes.rb CHANGED
@@ -60,6 +60,7 @@ Cats::Core::Engine.routes.draw do
60
60
  resources :dispatches, except: %i[index destroy] do
61
61
  member do
62
62
  get 'receipts', controller: :receipts, action: :index
63
+ get 'commodity'
63
64
  post 'approve'
64
65
  post 'start'
65
66
  post 'confirm'
@@ -69,7 +70,7 @@ Cats::Core::Engine.routes.draw do
69
70
  resources :receipts, except: %i[index new edit destroy] do
70
71
  member do
71
72
  post 'start_stacking'
72
- post 'stack'
73
+ post 'finish_stacking'
73
74
  end
74
75
  end
75
76
  resources :receipt_transactions, except: %i[new edit destroy]
@@ -25,6 +25,7 @@ class CreateCatsCoreDonations < ActiveRecord::Migration[6.1]
25
25
  null: true,
26
26
  index: { name: 'uom_on_donation_indx' },
27
27
  foreign_key: { to_table: :cats_core_unit_of_measures }
28
+ t.boolean :active, null: false, default: false
28
29
 
29
30
  t.timestamps
30
31
  end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.1.4'.freeze
3
+ VERSION = '1.1.8'.freeze
4
4
  end
5
5
  end
@@ -9,5 +9,6 @@ FactoryBot.define do
9
9
  currency { nil }
10
10
  commodity_category
11
11
  unit_of_measure
12
+ active { false }
12
13
  end
13
14
  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.1.4
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-26 00:00:00.000000000 Z
11
+ date: 2021-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -273,6 +273,7 @@ files:
273
273
  - app/models/cats/core/user.rb
274
274
  - app/notifications/cats/core/simple_notification.rb
275
275
  - app/serializers/cats/core/commodity_category_serializer.rb
276
+ - app/serializers/cats/core/commodity_serializer.rb
276
277
  - app/serializers/cats/core/currency_serializer.rb
277
278
  - app/serializers/cats/core/dispatch_serializer.rb
278
279
  - app/serializers/cats/core/dispatch_transaction_serializer.rb