cats_core 1.5.29 → 1.5.31

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3871baf3450e7366757ebaa26bbf157b8bed3d9445f8cedd32a384be3c085a75
4
- data.tar.gz: bade4250d1176e8ebc8bc99136dafcbab78761b8d2d8dab93d004f3eabbc49d4
3
+ metadata.gz: a7911574179f48f97106983fea8b4ca2989786a8db813b9512302c2cbae7a5d3
4
+ data.tar.gz: b7f622e7bc236fe0d831696064041efc2d8fa06a3e5f13df93b0acad00ae2294
5
5
  SHA512:
6
- metadata.gz: 87458b788af5a370a0fdc04ef9214ae4b2abefdb5c4a94e472bbccc71281c9d464a00fa5f6046a722946aaf9a30cbacbe5fe370ac3a236e88ae6705fe7a3fc89
7
- data.tar.gz: 3e618ea3300eb3b742668ccd3e694672545d9bef499a4bd46b4221505cc6fb396c0bee19dda5d0f65788fc50e70803cb167337f828013e55331b946fcea6b185
6
+ metadata.gz: af19792212cf56eca8d34915d3e849c66caeed14d102ac46a0a85131b1a8236d97c69636387f5b00e6273c5c19e395a98957dd1a5ae80b10dd659ccda099a762
7
+ data.tar.gz: 93bce0e798090fe6aba7a85861d262bdf95692a112a22359b82058aba9f153665cdb66a245aa3990530745e122a7d21bb62a828509b6b4ab62163de5a63b8a5c
@@ -19,6 +19,12 @@ module Cats
19
19
  render json: {success: true, data: serialize(query.result)}
20
20
  end
21
21
 
22
+ def filter_location_by_region
23
+ descendants = Location.find(params[:id]).descendants
24
+ query = descendants.ransack(params[:q])
25
+ render json: {success: true, data: serialize(query.result)}
26
+ end
27
+
22
28
  def woredas
23
29
  region = Location.find(params[:id])
24
30
  woredas = Location.where(id: region.descendant_ids, location_type: Location::WOREDA)
@@ -5,7 +5,7 @@ module Cats
5
5
  belongs_to :route
6
6
  belongs_to :unit, class_name: "Cats::Core::UnitOfMeasure"
7
7
 
8
- validates :price, presence: true, numericality: {greater_than: 0}
8
+ validates :price, :quantity, presence: true, numericality: {greater_than: 0}
9
9
 
10
10
  delegate(:name, to: :route, prefix: true)
11
11
  delegate(:contract_no, to: :transport_contract, prefix: false)
@@ -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_or_equal_to: 0}
7
+ validates :price, numericality: {greater_than_or_equal_to: 0}, allow_nil: true
8
8
  validates :rank, numericality: {greater_than: 0}, allow_nil: true
9
9
  validate :validate_rank_is_set_for_winner
10
10
 
@@ -1,15 +1,22 @@
1
1
  module Cats
2
2
  module Core
3
3
  class TransportContract < ApplicationRecord
4
+ ACTIVE = "Active".freeze
5
+ CANCELLED = "Cancelled".freeze
6
+ CONTRACT_STATUSES = [ACTIVE, CANCELLED].freeze
7
+
4
8
  belongs_to :transporter
5
9
  belongs_to :transport_bid
10
+ belongs_to :region, class_name: "Cats::Core::Location"
6
11
  has_many :contract_items
7
12
 
8
13
  validates :contract_no, presence: true, uniqueness: true
9
14
  validates :contract_date, :expires_on, presence: true
15
+ validates :status, presence: true, inclusion: {in: CONTRACT_STATUSES}
10
16
 
11
17
  delegate(:name, to: :transporter, prefix: true)
12
18
  delegate(:reference_no, to: :transport_bid, prefix: :bid)
19
+ delegate(:name, to: :region, prefix: true, allow_nil: true)
13
20
  end
14
21
  end
15
22
  end
@@ -5,6 +5,11 @@ module Cats
5
5
  APPROVED = "Approved".freeze
6
6
  STATUSES = [DRAFT, APPROVED].freeze
7
7
 
8
+ ACTIVE = "Active".freeze
9
+ CANCELLED = "Cancelled".freeze
10
+ EXPIRED = "Expired".freeze
11
+ ORDER_STATUSES = [ACTIVE, CANCELLED, EXPIRED].freeze
12
+
8
13
  belongs_to :transport_requisition
9
14
  belongs_to :prepared_by, class_name: "Cats::Core::User"
10
15
  belongs_to :approved_by, class_name: "Cats::Core::User", optional: true
@@ -12,7 +17,8 @@ module Cats
12
17
  has_many :transport_order_items
13
18
 
14
19
  validates :status, presence: true, inclusion: {in: STATUSES}
15
- validates :order_date, presence: true
20
+ validates :order_status, presence: true, inclusion: {in: ORDER_STATUSES}
21
+ validates :order_date, :order_no, presence: true
16
22
  validate :validate_against_requisition, :validate_status
17
23
 
18
24
  delegate(:full_name, to: :prepared_by, prefix: true)
@@ -1,18 +1,34 @@
1
1
  module Cats
2
2
  module Core
3
3
  class TransportOrderItem < ApplicationRecord
4
+ ACTIVE = "Active".freeze
5
+ CANCELLED = "Cancelled".freeze
6
+ EXPIRED = "Expired".freeze
7
+
8
+ ORDER_ITEM_STATUSES = [ACTIVE, CANCELLED, EXPIRED].freeze
4
9
  belongs_to :transport_order
5
10
  belongs_to :transporter
6
11
  belongs_to :transport_requisition_item
7
12
  belongs_to :transport_contract, optional: true
13
+ belongs_to :unit, class_name: "Cats::Core::UnitOfMeasure"
14
+ belongs_to :route
8
15
 
9
- validates :valid_for, presence: true
10
- validates :valid_for, numericality: {greater_than: 0}
16
+ validates :valid_for, :quantity, :price, presence: true
17
+ validates :valid_for, :price, numericality: {greater_than: 0}
18
+ validates :status, presence: true, inclusion: {in: ORDER_ITEM_STATUSES}
11
19
  validates :transport_requisition_item_id, uniqueness: true
12
20
  validate :validate_requisition
13
21
 
14
22
  delegate(:name, to: :transporter, prefix: true)
15
- delegate(:contract_no, to: :transport_contract, prefix: false)
23
+ delegate(:name, to: :route, prefix: true)
24
+ delegate(:abbreviation, to: :unit, prefix: true)
25
+ delegate(:contract_no, to: :transport_contract, prefix: false, allow_nil: true)
26
+ delegate(:region, to: :transport_requisition_item, allow_nil: true, prefix: "req_item")
27
+ delegate(:zone, to: :transport_requisition_item, allow_nil: true, prefix: "req_item")
28
+ delegate(:woreda, to: :transport_requisition_item, allow_nil: true, prefix: "req_item")
29
+ delegate(:fdp, to: :transport_requisition_item, allow_nil: true, prefix: "req_item")
30
+ delegate(:commodity_name, to: :transport_requisition_item, allow_nil: true)
31
+ delegate(:plan_item_reference_no, to: :transport_requisition_item, allow_nil: true)
16
32
 
17
33
  def validate_requisition
18
34
  return unless transport_requisition_item
@@ -10,6 +10,7 @@ module Cats
10
10
  delegate(:reference_no, to: :transport_requisition, prefix: "requisition")
11
11
  delegate(:abbreviation, to: :unit, prefix: true)
12
12
  delegate(:source_name, to: :dispatch_plan_item, prefix: false)
13
+ delegate(:reference_no, to: :dispatch_plan_item, prefix: "plan_item")
13
14
 
14
15
  def commodity_name
15
16
  dispatch_plan_item.commodity.name
data/config/routes.rb CHANGED
@@ -46,6 +46,7 @@ Cats::Core::Engine.routes.draw do
46
46
  resources :locations, except: %i[destroy] do
47
47
  member do
48
48
  get "children"
49
+ post "filter_location_by_region"
49
50
  end
50
51
  end
51
52
 
@@ -0,0 +1,18 @@
1
+ class AddStatusUnitAndQuantityToTransportOrderItem < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :cats_core_transport_order_items, :unit_id, :integer
4
+ add_foreign_key :cats_core_transport_order_items,
5
+ :cats_core_unit_of_measures,
6
+ column: :unit_id, null: false,
7
+ index: {name: "unit_on_toi_indx"}
8
+ add_column :cats_core_transport_order_items, :route_id, :integer
9
+ add_foreign_key :cats_core_transport_order_items,
10
+ :cats_core_routes,
11
+ column: :route_id, null: false,
12
+ index: {name: "route_on_toi_indx"}
13
+ add_column :cats_core_transport_order_items, :quantity, :float, null: false
14
+ add_column :cats_core_transport_order_items, :status, :string, null: false
15
+ remove_index :cats_core_transport_order_items, :transport_requisition_item_id,
16
+ name: "tri_on_toi_uniq_indx"
17
+ end
18
+ end
@@ -0,0 +1,6 @@
1
+ class AddStatusToTransportOrder < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :cats_core_transport_orders, :order_status, :string, null: false, default: "Active"
4
+ add_column :cats_core_transport_orders, :order_no, :string, null: false
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddStatusToContract < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :cats_core_transport_contracts, :status, :string, null: false, default: "Active"
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class AddRegionAndQuantityToContract < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :cats_core_contract_items, :quantity, :float
4
+ add_column :cats_core_transport_contracts, :region_id, :integer
5
+ add_foreign_key :cats_core_transport_contracts,
6
+ :cats_core_locations,
7
+ column: :region_id, null: false,
8
+ index: {name: "region_on_trans_cont_indx"}
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ class AddPriceToOrderItem < ActiveRecord::Migration[7.0]
2
+ def up
3
+ add_column :cats_core_transport_order_items, :price, :float, null: true
4
+ change_column :cats_core_offer_items, :price, :float, null: true
5
+ add_column :cats_core_transport_orders, :requested_dispatch_date, :date
6
+ add_column :cats_core_transport_orders, :order_expiry_date, :date
7
+ add_column :cats_core_transport_orders, :performance_bond_receipt, :string
8
+ end
9
+
10
+ def down
11
+ remove_column :cats_core_transport_order_items, :price
12
+ change_column :cats_core_offer_items, :price, :float, null: true
13
+ remove_column :cats_core_transport_orders, :requested_dispatch_date
14
+ remove_column :cats_core_transport_orders, :order_expiry_date
15
+ remove_column :cats_core_transport_orders, :performance_bond_receipt
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = "1.5.29".freeze
3
+ VERSION = "1.5.31".freeze
4
4
  end
5
5
  end
@@ -3,6 +3,7 @@ FactoryBot.define do
3
3
  transport_contract
4
4
  route
5
5
  price { 150 }
6
+ quantity { 100 }
6
7
  unit factory: :unit_of_measure
7
8
  end
8
9
  end
@@ -3,8 +3,10 @@ FactoryBot.define do
3
3
  contract_no { FFaker::Name.name }
4
4
  transporter
5
5
  transport_bid
6
+ region factory: :location
6
7
  contract_date { Date.today }
7
8
  expires_on { Date.today + 6.month }
8
9
  payment_term { FFaker::Name.name }
10
+ status { Cats::Core::TransportContract::ACTIVE }
9
11
  end
10
12
  end
@@ -5,5 +5,10 @@ FactoryBot.define do
5
5
  transport_contract
6
6
  transport_requisition_item { transport_order.transport_requisition.transport_requisition_items.first }
7
7
  valid_for { 10 }
8
+ quantity { 12 }
9
+ price { 100 }
10
+ status { Cats::Core::TransportOrderItem::ACTIVE }
11
+ unit factory: :unit_of_measure
12
+ route
8
13
  end
9
14
  end
@@ -5,5 +5,7 @@ FactoryBot.define do
5
5
  approved_by factory: :user
6
6
  order_date { Date.today }
7
7
  status { Cats::Core::TransportOrder::DRAFT }
8
+ order_status { Cats::Core::TransportOrder::ACTIVE }
9
+ order_no { "2/2024/TNA/REQ-001" }
8
10
  end
9
11
  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.29
4
+ version: 1.5.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-03 00:00:00.000000000 Z
11
+ date: 2024-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -532,6 +532,11 @@ files:
532
532
  - db/migrate/20230102064317_add_receipt_number_to_cats_core_receipt_transactions.rb
533
533
  - db/migrate/20231129071520_create_cats_core_inventory_adjustments.rb
534
534
  - db/migrate/20231227114358_add_beneficiaries_to_cats_core_dispatch_plan_items.rb
535
+ - db/migrate/20240125051557_add_status_unit_and_quantity_to_transport_order_item.rb
536
+ - db/migrate/20240125051632_add_status_to_transport_order.rb
537
+ - db/migrate/20240125051644_add_status_to_contract.rb
538
+ - db/migrate/20240304080545_add_region_and_quantity_to_contract.rb
539
+ - db/migrate/20240304145823_add_price_to_order_item.rb
535
540
  - lib/cats/core.rb
536
541
  - lib/cats/core/engine.rb
537
542
  - lib/cats/core/version.rb