cats_core 1.4.43 → 1.4.46

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: c6e5cfab401c5346af868d378d9a068b2cef5a154e803d5fd940f2d9bebdd8ff
4
- data.tar.gz: de1ea59da4f3e9a283685e84813e2285202d707d9d5bac98d26abc4d87820ac5
3
+ metadata.gz: 35e8eb4c24f3e5499dae203f071d84e56efc538665557820ebb0c0c4b56a8d8e
4
+ data.tar.gz: fe6f7c522a28fcbdc53c0f61dfc7b0844970564de93952c134965055c0501cb3
5
5
  SHA512:
6
- metadata.gz: 1d1ad46c73a7f35f1916fd9328dbef03cfeb3b6736566eac0c44ef2372bcea6dc6b804e313396c8ed7abe05a17ff2ae2f865a6b091337cbbab0e53f075938ac1
7
- data.tar.gz: f9f9633161e3578d49ea763e6254cd18706ce7fb0abaf3673d8321e21399a16f4cc3aac607106117901eee84a15fd44e95ed8faffa56454786d51575d926f5c3
6
+ metadata.gz: 5fad95b3e3b72ab44e84cb72954d9f825a2ff40be3c615685be577fd49e54fb123f6e6b4be4ad42ea1008bd9f64c2e42091666fad8f1c7e6546cb6368e1ae83b
7
+ data.tar.gz: 385a523e608cf19f3871495b94d0b3c52621bb14caaaf164daf13c08509e24a64b3fe4a044443d0cef1952a6899ce1e760c9dcfbe04cae29265bb9f8819fd1f3
@@ -61,7 +61,7 @@ module Cats
61
61
  :dispatchable_type,
62
62
  items: %i[
63
63
  reference_no region zone woreda fdp commodity_category unit_id unit quantity source_id destination_id
64
- commodity_id
64
+ commodity_id commodity_status
65
65
  ]
66
66
  )
67
67
  end
@@ -29,6 +29,11 @@ module Cats
29
29
  end
30
30
  end
31
31
 
32
+ def filter
33
+ query = DispatchTransaction.ransack(params[:q])
34
+ render json: { success: true, data: serialize(query.result) }
35
+ end
36
+
32
37
  private
33
38
 
34
39
  def model_params
@@ -12,8 +12,8 @@ module Cats
12
12
  private
13
13
 
14
14
  def model_params
15
- params.require(:payload).permit(:reference_no, :lender, :agreement_date, :repayment_date, :quantity, :unit_id,
16
- :commodity_category_id)
15
+ params.require(:payload).permit(:reference_no, :description, :lender, :agreement_date, :repayment_date,
16
+ :quantity, :unit_id, :commodity_category_id)
17
17
  end
18
18
  end
19
19
  end
@@ -17,7 +17,7 @@ module Cats
17
17
  def model_params
18
18
  params.require(:payload).permit(:reference_no, :order_date, :requisition_no, :supplier, :cash_donation_id,
19
19
  :commodity_category_id, :quantity, :purchase_type, :unit_id, :price,
20
- :currency_id)
20
+ :currency_id, :description)
21
21
  end
22
22
  end
23
23
  end
@@ -10,6 +10,11 @@ module Cats
10
10
  end
11
11
  end
12
12
 
13
+ def filter
14
+ query = ReceiptTransaction.ransack(params[:q])
15
+ render json: { success: true, data: serialize(query.result) }
16
+ end
17
+
13
18
  private
14
19
 
15
20
  def model_params
@@ -12,9 +12,9 @@ module Cats
12
12
  private
13
13
 
14
14
  def model_params
15
- params.require(:payload).permit(:reference_no, :swapper, :agreement_date, :issued_commodity_id,
16
- :issued_quantity, :received_commodity_id, :received_quantity,
17
- :issued_unit_id, :received_unit_id)
15
+ params.require(:payload).permit(:reference_no, :swapper, :agreement_date, :issued_commodity_id, :description,
16
+ :issued_quantity, :received_commodity_id, :received_quantity, :issued_unit_id,
17
+ :received_unit_id)
18
18
  end
19
19
  end
20
20
  end
@@ -60,7 +60,7 @@ module Cats
60
60
  def name
61
61
  # For this to be efficient, our query should use includes like
62
62
  # Commodity.includes(project: { source: commodity_category })
63
- project.source.commodity_category.name
63
+ project.source.commodity_name
64
64
  end
65
65
 
66
66
  def validate_updateability
@@ -10,6 +10,10 @@ module Cats
10
10
  delegate(:reference_no, to: :plan, prefix: true, allow_nil: true)
11
11
  delegate(:name, to: :commodity_category, prefix: true)
12
12
  delegate(:abbreviation, to: :unit, prefix: true)
13
+
14
+ def commodity_name
15
+ commodity_category.name
16
+ end
13
17
  end
14
18
  end
15
19
  end
@@ -10,6 +10,10 @@ module Cats
10
10
 
11
11
  delegate(:name, to: :commodity_category, prefix: true)
12
12
  delegate(:abbreviation, to: :unit, prefix: true)
13
+
14
+ def commodity_name
15
+ commodity_category.name
16
+ end
13
17
  end
14
18
  end
15
19
  end
@@ -18,6 +18,10 @@ module Cats
18
18
  delegate(:name, to: :commodity_category, prefix: true)
19
19
  delegate(:name, to: :unit, prefix: true)
20
20
  delegate(:code, to: :currency, prefix: true)
21
+
22
+ def commodity_name
23
+ commodity_category.name
24
+ end
21
25
  end
22
26
  end
23
27
  end
@@ -21,7 +21,8 @@ module Cats
21
21
  validates :stack_status, inclusion: { in: STACK_STATUSES }
22
22
  validate :validate_coordinates, :validate_dimensions, :validate_distance_from_wall, :validate_overlap,
23
23
  :validate_space_between_stack, :validate_max_height, :validate_max_length, :validate_max_width,
24
- :validate_distance_from_ceiling, unless: -> { store && store.code == 'SUP-STORE' }
24
+ :validate_distance_from_ceiling,
25
+ unless: -> { store && (store.code == 'SUP-STORE' || store.code.start_with?('FDP;')) }
25
26
 
26
27
  delegate :batch_no, to: :commodity, prefix: true
27
28
 
@@ -14,6 +14,10 @@ module Cats
14
14
  delegate(:name, to: :received_commodity, prefix: true)
15
15
  delegate(:abbreviation, to: :issued_unit, prefix: true)
16
16
  delegate(:abbreviation, to: :received_unit, prefix: true)
17
+
18
+ def commodity_name
19
+ received_commodity.name
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -43,6 +43,23 @@ module Cats
43
43
  authorization.dispatch.stack
44
44
  authorization
45
45
  end
46
+
47
+ def receipt_authorization(id)
48
+ item = DispatchPlanItem.find(id).includes(
49
+ :destination,
50
+ :unit,
51
+ commodity: { project: :source }
52
+ )
53
+ {
54
+ date: Date.today,
55
+ reference_no: item.reference_no,
56
+ destination: item.destination.name,
57
+ source: item.commodity.project.source.description,
58
+ commodity: "#{item.commodity.project.source.commodity_name} (#{item.commodity.batch_no})",
59
+ unit: item.unit.abbreviation,
60
+ quantity: item.quantity
61
+ }
62
+ end
46
63
  end
47
64
  end
48
65
  end
data/config/routes.rb CHANGED
@@ -167,7 +167,9 @@ Cats::Core::Engine.routes.draw do
167
167
  action: :create_allocation,
168
168
  as: :allocation_transaction
169
169
  )
170
+ post '/dispatch_transactions/filter', controller: :dispatch_transactions, action: :filter
170
171
  resources :dispatch_transactions, except: %i[index new edit destroy]
172
+ post '/receipt_transactions/filter', controller: :receipt_transactions, action: :filter
171
173
  resources :receipt_transactions, except: %i[index new edit destroy]
172
174
  resources :lost_commodities, except: %i[index destroy]
173
175
  get '/plans/:id/round_plans', controller: :round_plans, action: :index, as: :round_plans_plan
@@ -2,6 +2,7 @@ class CreateCatsCorePurchaseOrders < ActiveRecord::Migration[6.1]
2
2
  def change
3
3
  create_table :cats_core_purchase_orders do |t|
4
4
  t.string :reference_no, unique: true
5
+ t.string :description
5
6
  t.date :order_date, null: false
6
7
  t.string :requisition_no
7
8
  t.string :supplier, null: false
@@ -2,6 +2,7 @@ class CreateCatsCoreLoans < ActiveRecord::Migration[7.0]
2
2
  def change
3
3
  create_table :cats_core_loans do |t|
4
4
  t.string :reference_no, unique: true
5
+ t.string :description
5
6
  t.string :lender, null: false
6
7
  t.date :agreement_date, null: false
7
8
  t.date :repayment_date
@@ -2,6 +2,7 @@ class CreateCatsCoreSwaps < ActiveRecord::Migration[7.0]
2
2
  def change
3
3
  create_table :cats_core_swaps do |t|
4
4
  t.string :reference_no, unique: true
5
+ t.string :description
5
6
  t.string :swapper, null: false
6
7
  t.date :agreement_date, null: false
7
8
  t.float :issued_quantity, null: false
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.4.43'.freeze
3
+ VERSION = '1.4.46'.freeze
4
4
  end
5
5
  end
@@ -2,7 +2,7 @@ FactoryBot.define do
2
2
  factory :dispatch_plan_item, class: 'Cats::Core::DispatchPlanItem' do
3
3
  reference_no { FFaker::Name.name }
4
4
  source factory: :location
5
- destination factory: :location
5
+ destination factory: :woreda
6
6
  dispatch_plan
7
7
  quantity { 100 }
8
8
  unit factory: :unit_of_measure
@@ -1,6 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :loan, class: 'Cats::Core::Loan' do
3
3
  reference_no { FFaker::Name.name }
4
+ description { FFaker::Name.name }
4
5
  lender { FFaker::Name.name }
5
6
  agreement_date { Date.today }
6
7
  repayment_date { agreement_date.next_month }
@@ -1,6 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :purchase_order, class: 'Cats::Core::PurchaseOrder' do
3
3
  reference_no { FFaker::Name.name }
4
+ description { FFaker::Name.name }
4
5
  order_date { Date.today }
5
6
  requisition_no { FFaker::Name.name }
6
7
  supplier { FFaker::Name.name }
@@ -1,6 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :swap, class: 'Cats::Core::Swap' do
3
3
  reference_no { FFaker::Name.name }
4
+ description { FFaker::Name.name }
4
5
  swapper { FFaker::Name.name }
5
6
  agreement_date { Date.yesterday }
6
7
  issued_commodity factory: :commodity_category
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.43
4
+ version: 1.4.46
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-06-26 00:00:00.000000000 Z
11
+ date: 2022-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers