cats_core 1.5.5 → 1.5.7

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: a6b9bb64c4119d94cb514bf76741d6160682cb7adfb376daf9aff38b14fccf77
4
- data.tar.gz: 0c5b176315cfbd52ed72f3214831705bdd9a8e7fc524e2689517a3e1ff0d29cd
3
+ metadata.gz: a7b180bedd093fa12aaf7cdbf46b9a9b4d5467f9a4679f3b977ed9bd57dddac9
4
+ data.tar.gz: e142956dce9922b02289fb0852109da69480b5c2ae459ff4fc892ef6a41fccc9
5
5
  SHA512:
6
- metadata.gz: d3e0601550aebf25d5238ac8d9aabb57d933f3f48208bfe3a0cd39872a32e267dc97826c77eec6db841e40ae712ad4c7fded2ddb59b69da38f4ae874c5e4548b
7
- data.tar.gz: '09ae2320e6fdfa2ec17b922068240768a0f614947b7de1ebbdc91fa412ecbd08e7b874593352e205975bb8647ddcf3e42959f51bdb14a9be335ef6a41d407376'
6
+ metadata.gz: 37605aa2ffdc3a3f4d9741124a4b65bb3f5a8c8d73c925b0881529eca3545a86709d8a0e7600fbabcb005bd7418dfcc9cd06bff3fc895cb6d3c634f984c448e0
7
+ data.tar.gz: 0b8c7f19cd38d66128f16f6b87bbb1e2e383798213cd465482cdcd6bafeb37177bfaa2c62a5335f60eb852a01692501416c804f2ec074370173936dd9ba0821e
@@ -27,7 +27,7 @@ module Cats
27
27
  def model_params
28
28
  params.require(:payload).permit(:batch_no, :description, :unit_of_measure_id, :project_id, :commodity_grade,
29
29
  :source_type, :quantity, :best_use_before, :volume_per_metric_ton,
30
- :arrival_status, :shipping_reference)
30
+ :arrival_status, :shipping_reference, :package_unit_id)
31
31
  end
32
32
  end
33
33
  end
@@ -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
- quantity = UnitConversion.convert(ration.unit, mt, quantity) if ration.unit.abbreviation.downcase != 'pcs'
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
@@ -29,7 +29,9 @@ module Cats
29
29
  batch_no: item.commodity.batch_no,
30
30
  commodity_id: item.commodity_id,
31
31
  commodity_name: item.commodity.name,
32
- unit: item.commodity.unit_abbreviation
32
+ unit: item.commodity.unit_abbreviation,
33
+ package_unit_id: item.commodity.package_unit_id,
34
+ package_unit_abbreviation: item.commodity.package_unit_abbreviation
33
35
  }
34
36
  end
35
37
  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
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.5.5'.freeze
3
+ VERSION = '1.5.7'.freeze
4
4
  end
5
5
  end
@@ -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.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-01 00:00:00.000000000 Z
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