cats_core 1.5.6 → 1.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/cats/core/round_plan_item_detail.rb +1 -0
- data/app/services/cats/core/round_plan_service.rb +7 -2
- data/db/migrate/20220107132433_create_cats_core_round_plan_item_details.rb +4 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/round_plan_item_details.rb +4 -0
- 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: a7b180bedd093fa12aaf7cdbf46b9a9b4d5467f9a4679f3b977ed9bd57dddac9
|
4
|
+
data.tar.gz: e142956dce9922b02289fb0852109da69480b5c2ae459ff4fc892ef6a41fccc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37605aa2ffdc3a3f4d9741124a4b65bb3f5a8c8d73c925b0881529eca3545a86709d8a0e7600fbabcb005bd7418dfcc9cd06bff3fc895cb6d3c634f984c448e0
|
7
|
+
data.tar.gz: 0b8c7f19cd38d66128f16f6b87bbb1e2e383798213cd465482cdcd6bafeb37177bfaa2c62a5335f60eb852a01692501416c804f2ec074370173936dd9ba0821e
|
@@ -3,6 +3,7 @@ module Cats
|
|
3
3
|
class RoundPlanItemDetail < ApplicationRecord
|
4
4
|
belongs_to :beneficiary_round_plan_item
|
5
5
|
belongs_to :round_ration
|
6
|
+
belongs_to :unit, class_name: 'Cats::Core::UnitOfMeasure'
|
6
7
|
|
7
8
|
validates :quantity, presence: true, numericality: { greater_than: 0 }
|
8
9
|
validates :beneficiary_round_plan_item_id, uniqueness: { scope: :round_ration_id }
|
@@ -19,12 +19,17 @@ module Cats
|
|
19
19
|
round_rations.each do |ration|
|
20
20
|
quantity = (no_of_days / ration.no_of_days * ration.quantity) * plan_item.beneficiaries *
|
21
21
|
round_plan.rounds.count
|
22
|
-
|
22
|
+
unit = ration.unit
|
23
|
+
if ration.unit.abbreviation.downcase != 'pc'
|
24
|
+
quantity = UnitConversion.convert(unit, mt, quantity)
|
25
|
+
unit = mt
|
26
|
+
end
|
23
27
|
|
24
28
|
details << {
|
25
29
|
beneficiary_round_plan_item_id: plan_item.id,
|
26
30
|
round_ration_id: ration.id,
|
27
|
-
quantity: quantity
|
31
|
+
quantity: quantity,
|
32
|
+
unit_id: unit.id
|
28
33
|
}
|
29
34
|
end
|
30
35
|
end
|
@@ -10,6 +10,10 @@ class CreateCatsCoreRoundPlanItemDetails < ActiveRecord::Migration[6.1]
|
|
10
10
|
index: { name: 'rr_on_rpid_indx' },
|
11
11
|
foreign_key: { to_table: :cats_core_round_rations }
|
12
12
|
t.float :quantity, null: false
|
13
|
+
t.references :unit,
|
14
|
+
null: false,
|
15
|
+
index: { name: 'unit_on_rpid_indx' },
|
16
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
13
17
|
|
14
18
|
t.timestamps
|
15
19
|
end
|
data/lib/cats/core/version.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :round_plan_item_detail, class: 'Cats::Core::RoundPlanItemDetail' do
|
3
|
+
transient do
|
4
|
+
mt { create(:unit_of_measure, abbreviation: 'mt', name: 'Metric Tonne') }
|
5
|
+
end
|
3
6
|
beneficiary_round_plan_item
|
4
7
|
round_ration
|
5
8
|
quantity { 150 }
|
9
|
+
unit { round_ration.unit.abbreviation == 'pc' ? round_ration.unit : mt }
|
6
10
|
end
|
7
11
|
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.5.
|
4
|
+
version: 1.5.7
|
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-10-
|
11
|
+
date: 2022-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|