cats_core 1.3.17 → 1.3.18

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: d4e94853a5eeb64254a1aea6d8fac50f41a2e64501a8c8bea4ee933e27601437
4
- data.tar.gz: da74f7e6aa2b19108804cfe3f8a266847bc1d91299cc92fa54e746ae01c541d1
3
+ metadata.gz: 551532d2140d05f61a268ef27a1e2b8b9a7abb9f084dc808f161962d7f319b19
4
+ data.tar.gz: 78e9e7fd69241d39c84542d5160041df4ab2c697c60ea6cd9cd719182d7de43c
5
5
  SHA512:
6
- metadata.gz: 3f9b95fb8c0897a122eda69aafab63102a08317004b7e3b6500e3a3545c71d0ded6177e1ba761225b1dfac86735618405e5796666477e256e0f9fb887f5eda1b
7
- data.tar.gz: 33c9cee86d027666238e7d53cd93e3d209efbee762d4238b8d0585e0ae7c0f67d0fffa0b5a78f628767a81b774102d1c73e47499421057e33e02e2c656c54905
6
+ metadata.gz: a48bca9d45e6cfc5ea41bd5657d8142aafde2cc8fb3da40d37f2ba1a306bf98c3b6f403a15996579c5f4fb0b73d26aee6f92a6ffa30696f5f61f4dec5fa6f13c
7
+ data.tar.gz: ac88009a158bd3596389611e60e558eaf6bc1f99f7686955b7ae1e1987376d153bd7a21f0c67ae6bfec474907f7a0748f8a5b2636bfbbbb7fe271c0db2d83ba8
@@ -11,8 +11,7 @@ module Cats
11
11
  private
12
12
 
13
13
  def model_params
14
- params.require(:payload).permit(:dispatch_plan_id, :source_id, :destination_id, :quantity, :commodity_id,
15
- :commodity_status)
14
+ params.require(:payload).permit(:dispatch_plan_id, :source_id, :destination_id, :quantity, :commodity_status)
16
15
  end
17
16
  end
18
17
  end
@@ -57,7 +57,7 @@ module Cats
57
57
  end
58
58
 
59
59
  def commodity
60
- data = @dispatch.dispatch_plan_item.commodity
60
+ data = @dispatch.dispatch_plan_item.dispatch_plan.commodity
61
61
  render json: { success: true, data: serialize(data) }
62
62
  end
63
63
 
@@ -15,9 +15,7 @@ module Cats
15
15
  validates :reference_no, presence: true, uniqueness: true
16
16
  validates :status, inclusion: { in: STATUSES }
17
17
 
18
- delegate(:batch_no, to: :commodity, prefix: true)
19
- delegate(:name, to: :commodity, prefix: true)
20
- delegate(:quantity, to: :commodity, prefix: true)
18
+ delegate(:batch_no, :name, :quantity, to: :commodity, prefix: true)
21
19
  delegate(:reference_no, to: :request, prefix: true, allow_nil: true)
22
20
 
23
21
  def approve
@@ -1,7 +1,6 @@
1
1
  module Cats
2
2
  module Core
3
3
  class DispatchPlanItem < ApplicationRecord
4
- belongs_to :commodity
5
4
  belongs_to :source, class_name: 'Cats::Core::Location'
6
5
  belongs_to :destination, class_name: 'Cats::Core::Location'
7
6
  belongs_to :dispatch_plan
@@ -11,7 +10,7 @@ module Cats
11
10
  validates :quantity, presence: true, numericality: { greater_than: 0 }
12
11
 
13
12
  delegate(:reference_no, to: :dispatch_plan, prefix: :plan, allow_nil: true)
14
- delegate(:batch_no, to: :commodity, prefix: true)
13
+ delegate(:commodity_batch_no, :commodity_name, to: :dispatch_plan)
15
14
  delegate(:name, to: :source, prefix: true)
16
15
  delegate(:name, to: :destination, prefix: true)
17
16
  delegate(:location_type, to: :source, prefix: true)
@@ -7,7 +7,7 @@ module Cats
7
7
 
8
8
  def message
9
9
  dispatch = params[:dispatch]
10
- commodity = dispatch.dispatch_plan_item.commodity
10
+ commodity = dispatch.dispatch_plan_item.dispatch_plan.commodity
11
11
  title = "Dispatch Notification - #{commodity.name}"
12
12
  date = Date.today
13
13
  body = <<~BODY
@@ -3,7 +3,8 @@ module Cats
3
3
  class DispatchPlanService
4
4
  def approve(plan)
5
5
  plan.approve
6
- send_notification(plan)
6
+ plan.request.allocate if plan.request_id
7
+ # send_notification(plan)
7
8
  plan
8
9
  end
9
10
 
@@ -18,7 +19,6 @@ module Cats
18
19
  end
19
20
  plan.prepared_by = user
20
21
  result = plan.save
21
- plan.request.allocate if result && plan.request_id
22
22
 
23
23
  [result, plan]
24
24
  end
@@ -10,7 +10,7 @@ module Cats
10
10
  store = Cats::Core::Store.find_by(code: 'SUP-STORE')
11
11
  raise(StandardError, 'Supplier store does not exist.') unless store
12
12
 
13
- commodity = plan_item.commodity
13
+ commodity = plan_item.dispatch_plan.commodity
14
14
  stack = store.stacks.find_by(commodity: commodity)
15
15
 
16
16
  raise(StandardError, 'Commodity not found in supplier store.') unless stack
@@ -5,10 +5,6 @@ class CreateCatsCoreDispatchPlanItems < ActiveRecord::Migration[6.1]
5
5
  null: false,
6
6
  index: { name: 'dpi_on_dp_indx' },
7
7
  foreign_key: { to_table: :cats_core_dispatch_plans }
8
- t.references :commodity,
9
- null: false,
10
- index: { name: 'dpi_on_commodity_indx' },
11
- foreign_key: { to_table: :cats_core_commodities }
12
8
  t.references :source,
13
9
  null: false,
14
10
  index: { name: 'dpi_on_source_indx' },
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.3.17'.freeze
3
+ VERSION = '1.3.18'.freeze
4
4
  end
5
5
  end
@@ -1,6 +1,5 @@
1
1
  FactoryBot.define do
2
2
  factory :dispatch_plan_item, class: 'Cats::Core::DispatchPlanItem' do
3
- commodity
4
3
  source factory: :location
5
4
  destination factory: :location
6
5
  dispatch_plan
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cats_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.17
4
+ version: 1.3.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.