cats_core 1.5.3 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/cats/core/commodities_controller.rb +2 -2
- data/app/controllers/cats/core/dispatch_authorizations_controller.rb +2 -2
- data/app/controllers/cats/core/dispatch_transactions_controller.rb +1 -1
- data/app/controllers/cats/core/lost_commodities_controller.rb +1 -1
- data/app/controllers/cats/core/receipt_authorizations_controller.rb +2 -2
- data/app/controllers/cats/core/receipt_transactions_controller.rb +1 -1
- data/app/controllers/cats/core/receipts_controller.rb +1 -1
- data/app/controllers/cats/core/stacks_controller.rb +2 -2
- data/app/models/cats/core/authorization.rb +4 -9
- data/app/models/cats/core/commodity.rb +1 -0
- data/app/models/cats/core/dispatch.rb +0 -6
- data/app/models/cats/core/dispatch_plan.rb +3 -1
- data/app/models/cats/core/dispatch_transaction.rb +1 -1
- data/app/models/cats/core/hub_authorization.rb +2 -1
- data/app/models/cats/core/lost_commodity.rb +3 -1
- data/app/models/cats/core/receipt.rb +3 -1
- data/app/models/cats/core/receipt_transaction.rb +1 -1
- data/app/models/cats/core/rhn_request.rb +2 -1
- data/app/models/cats/core/round_ration.rb +2 -0
- data/app/models/cats/core/stack.rb +1 -0
- data/app/models/cats/core/transaction.rb +2 -0
- data/app/serializers/cats/core/commodity_serializer.rb +1 -1
- data/app/serializers/cats/core/dispatch_authorization_serializer.rb +2 -1
- data/app/serializers/cats/core/dispatch_plan_item_serializer.rb +1 -1
- data/app/serializers/cats/core/dispatch_transaction_serializer.rb +2 -1
- data/app/serializers/cats/core/lost_commodity_serializer.rb +1 -1
- data/app/serializers/cats/core/receipt_authorization_serializer.rb +1 -1
- data/app/serializers/cats/core/receipt_serializer.rb +2 -1
- data/app/serializers/cats/core/receipt_transaction_serializer.rb +1 -1
- data/app/serializers/cats/core/stack_serializer.rb +1 -1
- data/app/services/cats/core/round_plan_service.rb +6 -5
- data/app/utils/cats/core/util.rb +6 -0
- data/lib/cats/core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6b9bb64c4119d94cb514bf76741d6160682cb7adfb376daf9aff38b14fccf77
|
4
|
+
data.tar.gz: 0c5b176315cfbd52ed72f3214831705bdd9a8e7fc524e2689517a3e1ff0d29cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3e0601550aebf25d5238ac8d9aabb57d933f3f48208bfe3a0cd39872a32e267dc97826c77eec6db841e40ae712ad4c7fded2ddb59b69da38f4ae874c5e4548b
|
7
|
+
data.tar.gz: '09ae2320e6fdfa2ec17b922068240768a0f614947b7de1ebbdc91fa412ecbd08e7b874593352e205975bb8647ddcf3e42959f51bdb14a9be335ef6a41d407376'
|
@@ -5,7 +5,7 @@ module Cats
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
super do
|
8
|
-
Commodity.all.includes({ project: { source: :commodity_category } }, :unit_of_measure)
|
8
|
+
Commodity.all.includes({ project: { source: :commodity_category } }, :unit_of_measure, :package_unit)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -18,7 +18,7 @@ module Cats
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def filter
|
21
|
-
query = Commodity.includes(:project, :unit_of_measure).ransack(params[:q])
|
21
|
+
query = Commodity.includes(:project, :unit_of_measure, :package_unit).ransack(params[:q])
|
22
22
|
render json: { success: true, data: serialize(query.result) }
|
23
23
|
end
|
24
24
|
|
@@ -5,7 +5,7 @@ module Cats
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
super do
|
8
|
-
DispatchAuthorization.includes(:dispatch, :store, :authorized_by).where(dispatch_id: params[:id])
|
8
|
+
DispatchAuthorization.includes(:dispatch, :store, :authorized_by, :unit).where(dispatch_id: params[:id])
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -21,7 +21,7 @@ module Cats
|
|
21
21
|
storekeeper = User.find(params[:id])
|
22
22
|
stores = storekeeper.stores
|
23
23
|
authorizations = DispatchAuthorization.joins(:dispatch)
|
24
|
-
.includes(:dispatch, :store, :authorized_by)
|
24
|
+
.includes(:dispatch, :store, :authorized_by, :unit)
|
25
25
|
.where(store: stores, dispatch: { dispatch_status: Dispatch::APPROVED })
|
26
26
|
render json: { success: true, data: serialize(authorizations) }
|
27
27
|
end
|
@@ -7,7 +7,7 @@ module Cats
|
|
7
7
|
|
8
8
|
def index
|
9
9
|
super do
|
10
|
-
ReceiptAuthorization.includes(:dispatch, :store, :authorized_by).where(dispatch_id: params[:id])
|
10
|
+
ReceiptAuthorization.includes(:dispatch, :store, :authorized_by, :unit).where(dispatch_id: params[:id])
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -40,7 +40,7 @@ module Cats
|
|
40
40
|
storekeeper = User.find(params[:id])
|
41
41
|
status = params[:status]
|
42
42
|
stores = storekeeper.stores
|
43
|
-
authorizations = ReceiptAuthorization.includes(:dispatch, :store, :authorized_by)
|
43
|
+
authorizations = ReceiptAuthorization.includes(:dispatch, :store, :authorized_by, :unit)
|
44
44
|
.where(store: stores, status: status)
|
45
45
|
render json: { success: true, data: serialize(authorizations) }
|
46
46
|
end
|
@@ -5,7 +5,7 @@ module Cats
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
super do
|
8
|
-
ReceiptTransaction.includes(:destination, { receipt_authorization: :dispatch })
|
8
|
+
ReceiptTransaction.includes(:destination, { receipt_authorization: :dispatch }, :unit)
|
9
9
|
.where(receipt_authorization_id: params[:id])
|
10
10
|
end
|
11
11
|
end
|
@@ -5,12 +5,12 @@ module Cats
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
super do
|
8
|
-
Stack.includes(:commodity).where(store_id: params[:id])
|
8
|
+
Stack.includes(:commodity, :unit).where(store_id: params[:id])
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
def filter
|
13
|
-
query = Stack.includes(:commodity).where(store_id: params[:id]).ransack(params[:q])
|
13
|
+
query = Stack.includes(:commodity, :unit).where(store_id: params[:id]).ransack(params[:q])
|
14
14
|
render json: { success: true, data: serialize(query.result) }
|
15
15
|
end
|
16
16
|
|
@@ -3,7 +3,7 @@ module Cats
|
|
3
3
|
class Authorization < ApplicationRecord
|
4
4
|
self.abstract_class = true
|
5
5
|
after_initialize :set_status
|
6
|
-
|
6
|
+
before_validation :set_unit
|
7
7
|
|
8
8
|
# Authorization statuses
|
9
9
|
AUTHORIZED = 'Authorized'.freeze
|
@@ -25,6 +25,7 @@ module Cats
|
|
25
25
|
delegate(:dispatch_status, to: :dispatch)
|
26
26
|
delegate(:plate_no, to: :dispatch)
|
27
27
|
delegate(:driver_name, to: :dispatch)
|
28
|
+
delegate(:abbreviation, to: :unit, prefix: true)
|
28
29
|
|
29
30
|
def set_unit
|
30
31
|
return if unit
|
@@ -64,7 +65,7 @@ module Cats
|
|
64
65
|
save!
|
65
66
|
reload
|
66
67
|
if dispatch.all_authorizations_confirmed?
|
67
|
-
|
68
|
+
Util.generate_pin(dispatch)
|
68
69
|
dispatch.quantity = dispatch.dispatch_transactions.sum(:quantity)
|
69
70
|
dispatch.dispatch_status = Dispatch::READY_TO_START
|
70
71
|
dispatch.save!
|
@@ -81,17 +82,11 @@ module Cats
|
|
81
82
|
self.received_quantity = total_received
|
82
83
|
self.status = CONFIRMED
|
83
84
|
save!
|
84
|
-
generate_pin
|
85
|
+
Util.generate_pin(self)
|
85
86
|
end
|
86
87
|
self
|
87
88
|
end
|
88
89
|
|
89
|
-
def generate_pin
|
90
|
-
pin = SecureRandom.hex(10)
|
91
|
-
self.auth_details = { pin: pin, active: true, expires_at: DateTime.now + 1.hour }
|
92
|
-
save!
|
93
|
-
end
|
94
|
-
|
95
90
|
private
|
96
91
|
|
97
92
|
def set_status
|
@@ -54,7 +54,9 @@ module Cats
|
|
54
54
|
# A method which returns the total quantity in the dispatch plan
|
55
55
|
# based on dispatch plan item quantities.
|
56
56
|
def quantity
|
57
|
-
|
57
|
+
raise(StandardError, 'Dispatchable must be RHN request.') unless dispatchable.instance_of?(RhnRequest)
|
58
|
+
|
59
|
+
UnitConversion.harmonized_total(dispatch_plan_items, dispatchable.unit)
|
58
60
|
end
|
59
61
|
|
60
62
|
def region
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class HubAuthorization < ApplicationRecord
|
4
|
-
|
4
|
+
before_validation :set_unit
|
5
5
|
|
6
6
|
SOURCE = 'Source'.freeze
|
7
7
|
DESTINATION = 'Destination'.freeze
|
@@ -20,6 +20,7 @@ module Cats
|
|
20
20
|
delegate(:plan_reference_no, to: :dispatch_plan_item)
|
21
21
|
delegate(:full_name, to: :authorized_by, prefix: true)
|
22
22
|
delegate(:name, to: :store, prefix: true)
|
23
|
+
delegate(:abbreviation, to: :unit, prefix: true)
|
23
24
|
|
24
25
|
def set_unit
|
25
26
|
return if unit
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class LostCommodity < ApplicationRecord
|
4
|
-
|
4
|
+
before_validation :set_unit
|
5
5
|
|
6
6
|
belongs_to :receipt_authorization
|
7
7
|
belongs_to :unit, class_name: 'Cats::Core::UnitOfMeasure'
|
@@ -9,6 +9,8 @@ module Cats
|
|
9
9
|
validates :quantity, presence: true, numericality: { greater_than: 0 }
|
10
10
|
validate :validate_quantity
|
11
11
|
|
12
|
+
delegate(:abbreviation, to: :unit, prefix: true)
|
13
|
+
|
12
14
|
def set_unit
|
13
15
|
return if unit
|
14
16
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class Receipt < ApplicationRecord
|
4
|
-
|
4
|
+
before_validation :set_unit
|
5
5
|
|
6
6
|
belongs_to :receipt_authorization
|
7
7
|
belongs_to :unit, class_name: 'Cats::Core::UnitOfMeasure'
|
@@ -11,6 +11,8 @@ module Cats
|
|
11
11
|
validates :quantity, presence: true, numericality: { greater_than: 0 }
|
12
12
|
validate :validate_quantity
|
13
13
|
|
14
|
+
delegate(:abbreviation, to: :unit, prefix: true)
|
15
|
+
|
14
16
|
def set_unit
|
15
17
|
return if unit
|
16
18
|
|
@@ -3,7 +3,7 @@ module Cats
|
|
3
3
|
class RhnRequest < ApplicationRecord
|
4
4
|
include Dispatchable
|
5
5
|
|
6
|
-
|
6
|
+
before_validation :set_unit
|
7
7
|
|
8
8
|
ALLOCATED = 'Allocated'.freeze
|
9
9
|
STATUSES << ALLOCATED
|
@@ -18,6 +18,7 @@ module Cats
|
|
18
18
|
validate :validate_commodity_status, :validate_quantity
|
19
19
|
|
20
20
|
delegate(:batch_no, to: :commodity, prefix: true)
|
21
|
+
delegate(:abbreviation, to: :unit, prefix: true)
|
21
22
|
|
22
23
|
def set_unit
|
23
24
|
return if unit
|
@@ -15,6 +15,8 @@ module Cats
|
|
15
15
|
validates :quantity, numericality: { greater_than: 0 }
|
16
16
|
validates :status, inclusion: { in: STATUSES }
|
17
17
|
|
18
|
+
delegate(:abbreviation, to: :unit, prefix: true)
|
19
|
+
|
18
20
|
def commit
|
19
21
|
raise(NotImplementedError, 'Method should be implemented in child classes.')
|
20
22
|
end
|
@@ -3,7 +3,7 @@ module Cats
|
|
3
3
|
class CommoditySerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :name, :batch_no, :description, :unit_of_measure_id, :unit_abbreviation, :project_id,
|
5
5
|
:project_code, :quantity, :best_use_before, :volume_per_metric_ton, :arrival_status, :status,
|
6
|
-
:shipping_reference, :commodity_grade
|
6
|
+
:shipping_reference, :commodity_grade, :package_unit_id, :package_unit_abbreviation
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -2,7 +2,8 @@ module Cats
|
|
2
2
|
module Core
|
3
3
|
class DispatchAuthorizationSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :dispatch_id, :dispatch_reference_no, :store_id, :store_name, :quantity, :authorized_by_id,
|
5
|
-
:authorizer_full_name, :dispatch_status, :plate_no, :driver_name, :status
|
5
|
+
:authorizer_full_name, :dispatch_status, :plate_no, :driver_name, :status, :unit_id,
|
6
|
+
:unit_abbreviation
|
6
7
|
end
|
7
8
|
end
|
8
9
|
end
|
@@ -4,7 +4,7 @@ module Cats
|
|
4
4
|
attributes :id, :reference_no, :dispatch_plan_id, :plan_reference_no, :source_id, :source_name, :destination_id,
|
5
5
|
:destination_name, :quantity, :source_location_type, :destination_location_type, :commodity_status,
|
6
6
|
:status, :commodity_id, :commodity_name, :commodity_batch_no, :unit_abbreviation,
|
7
|
-
:commodity_shipping_reference
|
7
|
+
:commodity_shipping_reference, :unit_id
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class DispatchTransactionSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :source_id, :source_code, :dispatch_authorization_id, :quantity, :transaction_date, :status
|
4
|
+
attributes :id, :source_id, :source_code, :dispatch_authorization_id, :quantity, :transaction_date, :status,
|
5
|
+
:unit_id, :unit_abbreviation
|
5
6
|
end
|
6
7
|
end
|
7
8
|
end
|
@@ -3,7 +3,7 @@ module Cats
|
|
3
3
|
class ReceiptAuthorizationSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :dispatch_id, :dispatch_reference_no, :store_id, :store_name, :quantity, :received_quantity,
|
5
5
|
:remark, :status, :authorized_by_id, :authorizer_full_name, :auth_details, :plate_no, :driver_name,
|
6
|
-
:dispatch_status
|
6
|
+
:dispatch_status, :unit_id, :unit_abbreviation
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class ReceiptSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :receipt_authorization_id, :commodity_status, :commodity_grade, :quantity, :remark
|
4
|
+
attributes :id, :receipt_authorization_id, :commodity_status, :commodity_grade, :quantity, :remark,
|
5
|
+
:unit_id, :unit_abbreviation
|
5
6
|
end
|
6
7
|
end
|
7
8
|
end
|
@@ -2,7 +2,7 @@ module Cats
|
|
2
2
|
module Core
|
3
3
|
class ReceiptTransactionSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :receipt_authorization_id, :dispatch_reference_no, :destination_id, :destination_code, :quantity,
|
5
|
-
:transaction_date, :status
|
5
|
+
:transaction_date, :status, :unit_id, :unit_abbreviation
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
@@ -2,7 +2,7 @@ module Cats
|
|
2
2
|
module Core
|
3
3
|
class StackSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :code, :length, :width, :height, :start_x, :start_y, :commodity_id, :store_id, :commodity_status,
|
5
|
-
:stack_status, :quantity, :commodity_batch_no
|
5
|
+
:stack_status, :quantity, :commodity_batch_no, :unit_id, :unit_abbreviation
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
@@ -13,17 +13,18 @@ module Cats
|
|
13
13
|
rations = round_plan.round_rations
|
14
14
|
plan = round_plan.plan
|
15
15
|
no_of_days = plan.total_days / plan.rounds
|
16
|
+
mt = UnitOfMeasure.find_by(abbreviation: 'mt')
|
16
17
|
round_plan.beneficiary_round_plan_items.each do |plan_item|
|
17
18
|
round_rations = rations.select { |r| r.beneficiary_category_id == plan_item.beneficiary_category_id }
|
18
19
|
round_rations.each do |ration|
|
20
|
+
quantity = (no_of_days / ration.no_of_days * ration.quantity) * plan_item.beneficiaries *
|
21
|
+
round_plan.rounds.count
|
22
|
+
quantity = UnitConversion.convert(ration.unit, mt, quantity) if ration.unit.abbreviation.downcase != 'pcs'
|
23
|
+
|
19
24
|
details << {
|
20
25
|
beneficiary_round_plan_item_id: plan_item.id,
|
21
26
|
round_ration_id: ration.id,
|
22
|
-
quantity:
|
23
|
-
(no_of_days / ration.no_of_days * ration.quantity) *
|
24
|
-
plan_item.beneficiaries *
|
25
|
-
round_plan.rounds.count
|
26
|
-
)
|
27
|
+
quantity: quantity
|
27
28
|
}
|
28
29
|
end
|
29
30
|
end
|
data/app/utils/cats/core/util.rb
CHANGED
@@ -4,6 +4,12 @@ module Cats
|
|
4
4
|
def self.send_chain(obj, arr)
|
5
5
|
arr.inject(obj) { |o, a| o.send(a) }
|
6
6
|
end
|
7
|
+
|
8
|
+
def self.generate_pin(obj)
|
9
|
+
pin = SecureRandom.hex(10)
|
10
|
+
obj.auth_details = { pin: pin, active: true, expires_at: DateTime.now + 24.hour }
|
11
|
+
obj.save!
|
12
|
+
end
|
7
13
|
end
|
8
14
|
end
|
9
15
|
end
|
data/lib/cats/core/version.rb
CHANGED
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.
|
4
|
+
version: 1.5.5
|
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-
|
11
|
+
date: 2022-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|