cats_core 1.5.4 → 1.5.6

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: e9a6ea1b862a6804a3e215898c7aac9966ffedbdf7aa3c8d9661f9356c4b8a24
4
- data.tar.gz: f08e17d946b62d02d148cffbe97ab52c9b1f113245d4dffca6f5d67256ec7ea0
3
+ metadata.gz: 3cb500b5c99210b40ab7cd416cd861caf4cd61528515e5317ba1abc9690ab2a9
4
+ data.tar.gz: 4279dca09b00c065f1c4568c12baa404970ce8fa093d0eba4939e232eb849692
5
5
  SHA512:
6
- metadata.gz: ea2045f6a7a7954a4157952747c932e096f5df6e8ab2a56e888ca1f656a85eb7bd08a572ad0f15a05b53b0defc51354c27755be960c69c4c0ec49b232ad9b5db
7
- data.tar.gz: d91d382689b7abab6221e64457123334bc93bc0357ffdf6eb28e71466d46183ba3aeab2b0d01b24abb0184a7b01b06ae5d0e2331220b710b3a193ac751061ad6
6
+ metadata.gz: e90c5c515b3fdd39a415dd6b174b0dddfac4775b067822aeec0dca3193125857fbc918cc46b04428a70badd5817353b2fd1eded643c387f66f1bbbbabc6014d3
7
+ data.tar.gz: 86ffddf979ddeead9980606491667acf4837606ef50d631230054c7e4c79180f7a2c6557f4aa747c0aa6ca918325a1045c7ae9a83bc86d8caa467e34284101d9
@@ -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
@@ -12,6 +12,8 @@ module Cats
12
12
  delegate(:name, to: :beneficiary_category, prefix: true)
13
13
  delegate(:abbreviation, to: :unit_of_measure, prefix: true)
14
14
  delegate(:reference_no, to: :round_plan, prefix: true)
15
+
16
+ alias_attribute :unit, :unit_of_measure
15
17
  end
16
18
  end
17
19
  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
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.5.4'.freeze
3
+ VERSION = '1.5.6'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cats_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.