cats_core 1.4.10 → 1.4.13

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: 5c497f5ed7c7fd9a82dd7a8f2450db08ab9e6ea307cfebf448819c15affe9baa
4
- data.tar.gz: 0c7514559659448cf6b1b83381b3eda706b37497b7fc2d4e2556430c50cfe21a
3
+ metadata.gz: c2a2d3b649cc7d706426630befadcda681cb80e886fb1347a9621c2c2db38a6c
4
+ data.tar.gz: fb61fef9d7d60138b51e833009f467389ce76323c72cbe32d96b5016ca93f26f
5
5
  SHA512:
6
- metadata.gz: cda6953720eb9492fd45083008ab61c38dc28ed1d7f1995f882335725d9f2beeb07b4e1bf1b012eddb6639bce628c6c3e98c939fe6ce59d18ad450d91bd17ffc
7
- data.tar.gz: 8785eba470967b8c6b765363c9c88d27270e482a1196decc995182030a6448160590eabe0bb696fabcdceed73e59f17cfffd2c6edb88d9870b4c45fe496652e7
6
+ metadata.gz: '090040e502dd0cca57b485ec9fd17deed37c9fec16d3ac39ee28e274b82ebacc2e9a77e38942e5cfdbc864c843de3c820ea0b4e469422694351a15754a7c3e9d'
7
+ data.tar.gz: b98de5aa7d98ce805bf738c3250268f2746fcf212233b9e3bbd30d87b072e98e54e03a53f490d90762182ad2b3387667fd460ef6aeb480a8c14fcb6c46b2d052
@@ -7,11 +7,18 @@ module Cats
7
7
 
8
8
  belongs_to :transport_requisition
9
9
  belongs_to :prepared_by, class_name: 'Cats::Core::User'
10
- belongs_to :approved_by, class_name: 'Cats::Core::User'
10
+ belongs_to :approved_by, class_name: 'Cats::Core::User', optional: true
11
+
12
+ has_many :transport_order_items
11
13
 
12
14
  validates :status, presence: true, inclusion: { in: STATUSES }
15
+ validates :order_date, presence: true
13
16
  validate :validate_against_requisition
14
17
 
18
+ delegate(:full_name, to: :prepared_by, prefix: true)
19
+ delegate(:full_name, to: :approved_by, prefix: true, allow_nil: true)
20
+ delegate(:reference_no, to: :transport_requisition, prefix: 'requisition')
21
+
15
22
  def validate_against_requisition
16
23
  return unless transport_requisition
17
24
 
@@ -6,11 +6,14 @@ module Cats
6
6
  belongs_to :transport_requisition_item
7
7
  belongs_to :transport_contract, optional: true
8
8
 
9
- validates :order_date, :valid_for, presence: true
9
+ validates :valid_for, presence: true
10
10
  validates :valid_for, numericality: { greater_than: 0 }
11
11
  validates :transport_requisition_item_id, uniqueness: true
12
12
  validate :validate_requisition
13
13
 
14
+ delegate(:name, to: :transporter, prefix: true)
15
+ delegate(:contract_no, to: :transport_contract, prefix: false)
16
+
14
17
  def validate_requisition
15
18
  return unless transport_requisition_item
16
19
 
@@ -10,9 +10,10 @@ class CreateCatsCoreTransportOrders < ActiveRecord::Migration[7.0]
10
10
  index: { name: 'pb_on_to_indx' },
11
11
  foreign_key: { to_table: :cats_core_users }
12
12
  t.references :approved_by,
13
- null: false,
13
+ null: true,
14
14
  index: { name: 'ab_on_to_indx' },
15
15
  foreign_key: { to_table: :cats_core_users }
16
+ t.date :order_date, null: false
16
17
  t.string :status, null: false, default: 'Draft'
17
18
 
18
19
  t.timestamps
@@ -17,7 +17,6 @@ class CreateCatsCoreTransportOrderItems < ActiveRecord::Migration[7.0]
17
17
  null: false,
18
18
  index: { name: 'tri_on_toi_indx' },
19
19
  foreign_key: { to_table: :cats_core_transport_requisition_items }
20
- t.date :order_date, null: false, default: Date.today
21
20
  t.integer :valid_for, null: false, default: 10
22
21
 
23
22
  t.timestamps
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.4.10'.freeze
3
+ VERSION = '1.4.13'.freeze
4
4
  end
5
5
  end
@@ -4,7 +4,6 @@ FactoryBot.define do
4
4
  transporter
5
5
  transport_contract
6
6
  transport_requisition_item { transport_order.transport_requisition.transport_requisition_items.first }
7
- order_date { Date.today }
8
7
  valid_for { 10 }
9
8
  end
10
9
  end
@@ -1,13 +1,9 @@
1
1
  FactoryBot.define do
2
2
  factory :transport_order, class: 'Cats::Core::TransportOrder' do
3
- transport_requisition do
4
- requisition = create(:transport_requisition)
5
- create(:transport_requisition_item, transport_requisition: requisition)
6
- requisition.approve
7
- requisition
8
- end
3
+ association :transport_requisition, :approved
9
4
  prepared_by factory: :user
10
5
  approved_by factory: :user
6
+ order_date { Date.today }
11
7
  status { Cats::Core::TransportOrder::DRAFT }
12
8
  end
13
9
  end
@@ -6,5 +6,12 @@ FactoryBot.define do
6
6
  approved_by factory: :user
7
7
  status { Cats::Core::TransportRequisition::DRAFT }
8
8
  unit factory: :unit_of_measure
9
+
10
+ trait :approved do
11
+ after(:create) do |requisition|
12
+ create(:transport_requisition_item, transport_requisition: requisition)
13
+ requisition.approve
14
+ end
15
+ end
9
16
  end
10
17
  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.4.10
4
+ version: 1.4.13
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-05-07 00:00:00.000000000 Z
11
+ date: 2022-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers