cats_core 1.5.6 → 1.5.8
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 +4 -4
 - data/app/models/cats/core/round_plan_item_detail.rb +3 -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: 02b7883db68e256449e949034e2b56a5c40387292ab61c7346a429f1d94a04f7
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7d0230d0c98ca9c7b57ccd23bc410c7c5b0126eca37c3daca4707dd95e154a08
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 1e865e4a70b174511dd8de23aeab18e54cea7847583a206d6da5609e9487137de117b0ef3461e77f89706e88094c3f1a99249a88686ac191e61e93efb7c62a4b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9785438a4a1ce510068ebb3a693d89eb0d66297132b8b700968f3c32eec45317ed2cde89f771dfb4d63cacc03aad35eb21818d6774d236a3022c61569635e1af
         
     | 
| 
         @@ -3,9 +3,12 @@ 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 }
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  delegate(:abbreviation, to: :unit, prefix: true)
         
     | 
| 
       9 
12 
     | 
    
         
             
                end
         
     | 
| 
       10 
13 
     | 
    
         
             
              end
         
     | 
| 
       11 
14 
     | 
    
         
             
            end
         
     | 
| 
         @@ -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.8
         
     | 
| 
       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
         
     |