cats_core 1.5.12 → 1.5.14

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: 276a2fded748139110b7415ef828d512d5c589f9363fc5519619d7fe5a02ddf7
4
- data.tar.gz: c10be63fba572250f567c947c3bd09c06592d8ae1e323d60a0f3464c9796ed2f
3
+ metadata.gz: 6e2ffcd4caf018a81ee3d83fabd7b7e20ddf97c9f6309a66a005805c78c41bc4
4
+ data.tar.gz: 4d139393006f70306d84cbef40f273e1e578cf855783f63dc1ee37ff2d2e979f
5
5
  SHA512:
6
- metadata.gz: cb500f43316387c327ec23d75c514b96e707b81b839fa690578261d9b1be74ddc4bed2d9fc1cb2796d7bb210b434ce4443cd17e37da0b946345d217289f6957c
7
- data.tar.gz: a8bed5ed9018d105a24cd701ef904a11d067513901be84354df3619d2b02ab0a191f23fc59234aa656b44b5c81f06b53c22c18eea3df9df3701bff9b66590b30
6
+ metadata.gz: '0309049d3508085b5cacfb155388fab2de02480a91b7869b9b2f1f5e8a51e6f574a70955e04aaa8b9524fd3f374410a27c864217d524557015eaf08b293ff57c'
7
+ data.tar.gz: 3667ef926f2952820d2b6c73c20fe3515ccdd411f7e8b91605e90f7e3bcaba7507611f74f76a2f389e4236eb96ca63ab4e6ef10da74c146b97b753dc5dec595f
@@ -37,7 +37,8 @@ module Cats
37
37
  private
38
38
 
39
39
  def model_params
40
- params.require(:payload).permit(:source_id, :dispatch_authorization_id, :transaction_date, :quantity, :unit_id)
40
+ params.require(:payload).permit(:source_id, :dispatch_authorization_id, :transaction_date, :quantity, :unit_id,
41
+ :reference_no)
41
42
  end
42
43
  end
43
44
  end
@@ -13,7 +13,7 @@ module Cats
13
13
 
14
14
  def model_params
15
15
  params.require(:payload).permit(:receipt_authorization_id, :commodity_status, :commodity_grade, :quantity,
16
- :unit_id, :remark)
16
+ :unit_id, :remark, :reference_no)
17
17
  end
18
18
  end
19
19
  end
@@ -61,6 +61,7 @@ module Cats
61
61
 
62
62
  def region
63
63
  return nil if dispatchable.instance_of?(RhnRequest)
64
+ return dispatch_plan_items.first.source.parent.name if dispatchable.nil?
64
65
 
65
66
  dispatchable.region.name
66
67
  end
@@ -7,6 +7,7 @@ module Cats
7
7
  belongs_to :dispatch_authorization
8
8
 
9
9
  validates :source_id, uniqueness: { scope: :dispatch_authorization_id }
10
+ validates :reference_no, presence: true
10
11
  validate :validate_dispatch
11
12
  validate :validate_source_quantity, :validate_authorized_quantity, unless: :skip_quantity_validation
12
13
 
@@ -17,6 +17,9 @@ module Cats
17
17
  validates :location_type, inclusion: { in: LOCATION_TYPES }
18
18
  validate :validate_location_parent
19
19
 
20
+ delegate(:code, to: :parent, prefix: true, allow_nil: true)
21
+ delegate(:name, to: :parent, prefix: true, allow_nil: true)
22
+
20
23
  def validate_location_parent
21
24
  parents = {
22
25
  REGION => [],
@@ -4,7 +4,7 @@ module Cats
4
4
  belongs_to :transport_offer
5
5
  belongs_to :transport_bid_item
6
6
 
7
- validates :price, presence: true, numericality: { greater_than: 0 }
7
+ validates :price, presence: true, numericality: { greater_than_or_equal_to: 0 }
8
8
  validates :rank, numericality: { greater_than: 0 }, allow_nil: true
9
9
  validate :validate_rank_is_set_for_winner
10
10
 
@@ -9,6 +9,7 @@ module Cats
9
9
  validates :commodity_status, presence: true, inclusion: { in: Commodity::COMMODITY_STATUSES }
10
10
  validates :commodity_grade, inclusion: { in: Commodity::COMMODITY_GRADES }, allow_nil: true
11
11
  validates :quantity, presence: true, numericality: { greater_than: 0 }
12
+ validates :reference_no, presence: true
12
13
  validate :validate_quantity
13
14
 
14
15
  delegate(:abbreviation, to: :unit, prefix: true)
@@ -13,7 +13,7 @@ module Cats
13
13
 
14
14
  validates :reference_no, :request_date, :quantity, presence: true
15
15
  validates :reference_no, uniqueness: true
16
- validates :quantity, numericality: { greater_than: 0 }
16
+ validates :quantity, numericality: { greater_than_or_equal_to: 0 }
17
17
  validates :status, presence: true, inclusion: { in: STATUSES }
18
18
  validate :validate_commodity_status, :validate_quantity
19
19
 
@@ -15,7 +15,7 @@ module Cats
15
15
  return value if from == to
16
16
 
17
17
  conversion = find_by(from: from, to: to)
18
- return value * conversion.factor if conversion
18
+ return (value * conversion.factor).round(2) if conversion
19
19
 
20
20
  # Check if there is reverse conversion entry defined
21
21
  conversion = find_by(from: to, to: from)
@@ -23,7 +23,7 @@ module Cats
23
23
  raise(StandardError, "Conversion factor between #{from.abbreviation} and #{to.abbreviation} not found.")
24
24
  end
25
25
 
26
- value / conversion.factor
26
+ (value / conversion.factor).round(2)
27
27
  end
28
28
 
29
29
  ##
@@ -2,7 +2,7 @@ module Cats
2
2
  module Core
3
3
  class DispatchTransactionSerializer < ActiveModel::Serializer
4
4
  attributes :id, :source_id, :source_code, :dispatch_authorization_id, :quantity, :transaction_date, :status,
5
- :unit_id, :unit_abbreviation
5
+ :unit_id, :unit_abbreviation, :reference_no
6
6
  end
7
7
  end
8
8
  end
@@ -1,7 +1,7 @@
1
1
  module Cats
2
2
  module Core
3
3
  class LocationSerializer < ActiveModel::Serializer
4
- attributes :id, :code, :name, :location_type, :description, :parent_id
4
+ attributes :id, :code, :name, :location_type, :description, :parent_id, :parent_name
5
5
  end
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@ module Cats
3
3
  class ReceiptAuthorizationSerializer < ActiveModel::Serializer
4
4
  attributes :id, :dispatch_id, :dispatch_reference_no, :store_id, :store_name, :quantity, :received_quantity,
5
5
  :remark, :status, :authorized_by_id, :authorizer_full_name, :auth_details, :plate_no, :driver_name,
6
- :dispatch_status, :unit_id, :unit_abbreviation
6
+ :dispatch_status, :unit_id, :unit_abbreviation, :driver_confirmed
7
7
  end
8
8
  end
9
9
  end
@@ -2,7 +2,7 @@ module Cats
2
2
  module Core
3
3
  class ReceiptSerializer < ActiveModel::Serializer
4
4
  attributes :id, :receipt_authorization_id, :commodity_status, :commodity_grade, :quantity, :remark,
5
- :unit_id, :unit_abbreviation
5
+ :unit_id, :unit_abbreviation, :reference_no
6
6
  end
7
7
  end
8
8
  end
@@ -0,0 +1,5 @@
1
+ class AddReferenceNoToCatsCoreReceipts < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :cats_core_receipts, :reference_no, :string, null: false
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddReferenceNoToCatsCoreDispatchTransactions < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :cats_core_dispatch_transactions, :reference_no, :string, null: false
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.5.12'.freeze
3
+ VERSION = '1.5.14'.freeze
4
4
  end
5
5
  end
@@ -9,5 +9,6 @@ FactoryBot.define do
9
9
  quantity { 100 }
10
10
  unit { dispatch_authorization.unit }
11
11
  status { Cats::Core::Transaction::DRAFT }
12
+ reference_no { FFaker::Name.name }
12
13
  end
13
14
  end
@@ -5,5 +5,6 @@ FactoryBot.define do
5
5
  quantity { 50 }
6
6
  unit { receipt_authorization.unit }
7
7
  remark { FFaker::Name.name }
8
+ reference_no { FFaker::Name.name }
8
9
  end
9
10
  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.5.12
4
+ version: 1.5.14
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-10-07 00:00:00.000000000 Z
11
+ date: 2023-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -475,6 +475,8 @@ files:
475
475
  - db/migrate/20220626063757_create_cats_core_swaps.rb
476
476
  - db/migrate/20220626132050_create_cats_core_round_beneficiaries.rb
477
477
  - db/migrate/20220923190857_create_cats_core_application_settings.rb
478
+ - db/migrate/20221024081134_add_reference_no_to_cats_core_receipts.rb
479
+ - db/migrate/20221024081141_add_reference_no_to_cats_core_dispatch_transactions.rb
478
480
  - lib/cats/core.rb
479
481
  - lib/cats/core/engine.rb
480
482
  - lib/cats/core/version.rb