cats_core 1.5.30 → 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: 03b358ca3dc8a8908dc00309ca843ab82e9703f9224c5d726cf1762034bf76ed
4
- data.tar.gz: 3e0da8d5c95a1bd32c90f76d78bd17bd3b70e2c5466916945b96d6292c3ae3f7
3
+ metadata.gz: a7911574179f48f97106983fea8b4ca2989786a8db813b9512302c2cbae7a5d3
4
+ data.tar.gz: b7f622e7bc236fe0d831696064041efc2d8fa06a3e5f13df93b0acad00ae2294
5
5
  SHA512:
6
- metadata.gz: fb22c2473633590d0c8f760b2a8dd178d19646e6ff9193b79f7536c0bbe9e3f2c16e3a860b9de66938d13279a1bcd0a3855b9593ff48ac5662ce10c9bc071c6c
7
- data.tar.gz: 73fe0f22b150696c145d28eb4343145f033643ec7259f6865f6b725e2c052880e1905c28b78ea860858da58bb5d0753b96a16fa358e9a7cd2319b3376de27f4f
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
 
@@ -7,6 +7,7 @@ module Cats
7
7
 
8
8
  belongs_to :transporter
9
9
  belongs_to :transport_bid
10
+ belongs_to :region, class_name: "Cats::Core::Location"
10
11
  has_many :contract_items
11
12
 
12
13
  validates :contract_no, presence: true, uniqueness: true
@@ -15,6 +16,7 @@ module Cats
15
16
 
16
17
  delegate(:name, to: :transporter, prefix: true)
17
18
  delegate(:reference_no, to: :transport_bid, prefix: :bid)
19
+ delegate(:name, to: :region, prefix: true, allow_nil: true)
18
20
  end
19
21
  end
20
22
  end
@@ -7,7 +7,8 @@ module Cats
7
7
 
8
8
  ACTIVE = "Active".freeze
9
9
  CANCELLED = "Cancelled".freeze
10
- ORDER_STATUSES = [ACTIVE, CANCELLED].freeze
10
+ EXPIRED = "Expired".freeze
11
+ ORDER_STATUSES = [ACTIVE, CANCELLED, EXPIRED].freeze
11
12
 
12
13
  belongs_to :transport_requisition
13
14
  belongs_to :prepared_by, class_name: "Cats::Core::User"
@@ -3,8 +3,9 @@ module Cats
3
3
  class TransportOrderItem < ApplicationRecord
4
4
  ACTIVE = "Active".freeze
5
5
  CANCELLED = "Cancelled".freeze
6
+ EXPIRED = "Expired".freeze
6
7
 
7
- ORDER_ITEM_STATUSES = [ACTIVE, CANCELLED].freeze
8
+ ORDER_ITEM_STATUSES = [ACTIVE, CANCELLED, EXPIRED].freeze
8
9
  belongs_to :transport_order
9
10
  belongs_to :transporter
10
11
  belongs_to :transport_requisition_item
@@ -12,8 +13,8 @@ module Cats
12
13
  belongs_to :unit, class_name: "Cats::Core::UnitOfMeasure"
13
14
  belongs_to :route
14
15
 
15
- validates :valid_for, :quantity, presence: true
16
- validates :valid_for, numericality: {greater_than: 0}
16
+ validates :valid_for, :quantity, :price, presence: true
17
+ validates :valid_for, :price, numericality: {greater_than: 0}
17
18
  validates :status, presence: true, inclusion: {in: ORDER_ITEM_STATUSES}
18
19
  validates :transport_requisition_item_id, uniqueness: true
19
20
  validate :validate_requisition
@@ -22,6 +23,12 @@ module Cats
22
23
  delegate(:name, to: :route, prefix: true)
23
24
  delegate(:abbreviation, to: :unit, prefix: true)
24
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)
25
32
 
26
33
  def validate_requisition
27
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,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.30".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,6 +3,7 @@ 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 }
@@ -6,6 +6,7 @@ FactoryBot.define do
6
6
  transport_requisition_item { transport_order.transport_requisition.transport_requisition_items.first }
7
7
  valid_for { 10 }
8
8
  quantity { 12 }
9
+ price { 100 }
9
10
  status { Cats::Core::TransportOrderItem::ACTIVE }
10
11
  unit factory: :unit_of_measure
11
12
  route
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.30
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-02-01 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
@@ -535,6 +535,8 @@ files:
535
535
  - db/migrate/20240125051557_add_status_unit_and_quantity_to_transport_order_item.rb
536
536
  - db/migrate/20240125051632_add_status_to_transport_order.rb
537
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
538
540
  - lib/cats/core.rb
539
541
  - lib/cats/core/engine.rb
540
542
  - lib/cats/core/version.rb