cats_core 1.4.41 → 1.4.44
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/controllers/cats/core/cash_donations_controller.rb +19 -0
- data/app/controllers/cats/core/commodity_donations_controller.rb +22 -0
- data/app/controllers/cats/core/dispatch_plans_controller.rb +24 -0
- data/app/controllers/cats/core/loans_controller.rb +20 -0
- data/app/controllers/cats/core/purchase_orders_controller.rb +24 -0
- data/app/controllers/cats/core/round_beneficiaries_controller.rb +49 -0
- data/app/controllers/cats/core/swaps_controller.rb +21 -0
- data/app/models/cats/core/beneficiary.rb +9 -0
- data/app/models/cats/core/cash_donation.rb +11 -0
- data/app/models/cats/core/commodity_donation.rb +15 -0
- data/app/models/cats/core/dispatch_plan.rb +1 -1
- data/app/models/cats/core/donation.rb +2 -16
- data/app/models/cats/core/gift_certificate.rb +3 -23
- data/app/models/cats/core/loan.rb +15 -0
- data/app/models/cats/core/plan.rb +4 -0
- data/app/models/cats/core/purchase_order.rb +5 -13
- data/app/models/cats/core/rhn_request.rb +4 -4
- data/app/models/cats/core/round_beneficiary.rb +16 -0
- data/app/models/cats/core/round_plan.rb +2 -4
- data/app/models/cats/core/round_plan_item.rb +1 -0
- data/app/models/cats/core/swap.rb +19 -0
- data/app/models/concerns/cats/core/dispatchable.rb +8 -0
- data/app/serializers/cats/core/cash_donation_serializer.rb +8 -0
- data/app/serializers/cats/core/commodity_donation_serializer.rb +9 -0
- data/app/serializers/cats/core/loan_serializer.rb +8 -0
- data/app/serializers/cats/core/purchase_order_serializer.rb +9 -0
- data/app/serializers/cats/core/round_beneficiary_serializer.rb +8 -0
- data/app/serializers/cats/core/swap_serializer.rb +9 -0
- data/app/services/cats/core/beneficiary_service.rb +87 -0
- data/app/services/cats/core/dispatch_plan_service.rb +79 -0
- data/config/routes.rb +19 -0
- data/db/migrate/20210717032330_create_cats_core_commodity_donations.rb +29 -0
- data/db/migrate/20210717032408_create_cats_core_cash_donations.rb +20 -0
- data/db/migrate/20210717032602_create_cats_core_gift_certificates.rb +2 -8
- data/db/migrate/20210717032855_create_cats_core_purchase_orders.rb +9 -5
- data/db/migrate/20220511082354_create_cats_core_beneficiaries.rb +4 -0
- data/db/migrate/20220626063501_create_cats_core_loans.rb +21 -0
- data/db/migrate/20220626063757_create_cats_core_swaps.rb +29 -0
- data/db/migrate/20220626132050_create_cats_core_round_beneficiaries.rb +26 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/beneficiaries.rb +1 -0
- data/spec/factories/cats/core/cash_donations.rb +10 -0
- data/spec/factories/cats/core/{donations.rb → commodity_donations.rb} +3 -6
- data/spec/factories/cats/core/gift_certificates.rb +5 -6
- data/spec/factories/cats/core/loans.rb +11 -0
- data/spec/factories/cats/core/projects.rb +1 -1
- data/spec/factories/cats/core/purchase_orders.rb +3 -1
- data/spec/factories/cats/core/round_beneficiaries.rb +10 -0
- data/spec/factories/cats/core/swaps.rb +13 -0
- metadata +33 -7
- data/db/migrate/20210717032330_create_cats_core_donations.rb +0 -35
| @@ -59,6 +59,85 @@ module Cats | |
| 59 59 | 
             
                      end
         | 
| 60 60 | 
             
                    end
         | 
| 61 61 | 
             
                  end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                  # This method generates dispatch plan for a round plan by aggregating the FDP level
         | 
| 64 | 
            +
                  # quantities into woreda level quantity per commodity.
         | 
| 65 | 
            +
                  #
         | 
| 66 | 
            +
                  # Parameters:
         | 
| 67 | 
            +
                  #   id => The ID of the round plan for which dispatch plan is to be generated
         | 
| 68 | 
            +
                  #
         | 
| 69 | 
            +
                  def generate(id)
         | 
| 70 | 
            +
                    details = RoundPlanItemDetail.joins(
         | 
| 71 | 
            +
                      beneficiary_round_plan_item: { round_plan_item: :round_plan }
         | 
| 72 | 
            +
                    ).where(
         | 
| 73 | 
            +
                      beneficiary_round_plan_item: { cats_core_round_plan_items: { round_plan_id: id } }
         | 
| 74 | 
            +
                    ).includes(
         | 
| 75 | 
            +
                      beneficiary_round_plan_item: {
         | 
| 76 | 
            +
                        round_plan_item: %i[round_plan region zone woreda fdp]
         | 
| 77 | 
            +
                      },
         | 
| 78 | 
            +
                      round_ration: :commodity_category
         | 
| 79 | 
            +
                    )
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                    items = details.each_with_object([]) do |detail, res|
         | 
| 82 | 
            +
                      res << {
         | 
| 83 | 
            +
                        reference_no: nil,
         | 
| 84 | 
            +
                        region: detail.beneficiary_round_plan_item.round_plan_item.region.name,
         | 
| 85 | 
            +
                        zone: detail.beneficiary_round_plan_item.round_plan_item.zone.name,
         | 
| 86 | 
            +
                        woreda: detail.beneficiary_round_plan_item.round_plan_item.woreda.name,
         | 
| 87 | 
            +
                        fdp: detail.beneficiary_round_plan_item.round_plan_item.fdp.name,
         | 
| 88 | 
            +
                        commodity_category: detail.round_ration.commodity_category.name,
         | 
| 89 | 
            +
                        unit_id: detail.round_ration.unit_of_measure_id,
         | 
| 90 | 
            +
                        unit: detail.round_ration.unit_of_measure.abbreviation,
         | 
| 91 | 
            +
                        quantity: detail.quantity,
         | 
| 92 | 
            +
                        source_id: nil,
         | 
| 93 | 
            +
                        destination_id: detail.beneficiary_round_plan_item.round_plan_item.fdp.id,
         | 
| 94 | 
            +
                        commodity_id: nil,
         | 
| 95 | 
            +
                        commodity_status: Cats::Core::Commodity::GOOD
         | 
| 96 | 
            +
                      }
         | 
| 97 | 
            +
                    end
         | 
| 98 | 
            +
                    {
         | 
| 99 | 
            +
                      reference_no: nil,
         | 
| 100 | 
            +
                      dispatchable_id: id,
         | 
| 101 | 
            +
                      dispatchable_type: 'Cats::Core::RoundPlan',
         | 
| 102 | 
            +
                      items: items
         | 
| 103 | 
            +
                    }
         | 
| 104 | 
            +
                  end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                  # This method creates dispatch and dispatch plan items once
         | 
| 107 | 
            +
                  # users fill out additional details such as source and destination
         | 
| 108 | 
            +
                  # for generated dispatch plan items.
         | 
| 109 | 
            +
                  #
         | 
| 110 | 
            +
                  # NOTE: Users still have to go through each plan item and set the
         | 
| 111 | 
            +
                  #       reference_no. If the product team comes up with a reference_no
         | 
| 112 | 
            +
                  #       generation scheme, then we may use that to avoid this.
         | 
| 113 | 
            +
                  #
         | 
| 114 | 
            +
                  def bulk_create(payload, user)
         | 
| 115 | 
            +
                    plan = Cats::Core::DispatchPlan.new(
         | 
| 116 | 
            +
                      reference_no: payload[:reference_no],
         | 
| 117 | 
            +
                      dispatchable_id: payload[:dispatchable_id],
         | 
| 118 | 
            +
                      dispatchable_type: payload[:dispatchable_type],
         | 
| 119 | 
            +
                      prepared_by: user
         | 
| 120 | 
            +
                    )
         | 
| 121 | 
            +
                    ActiveRecord::Base.transaction do
         | 
| 122 | 
            +
                      plan.save!
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                      items = payload[:items].each_with_object([]) do |item, res|
         | 
| 125 | 
            +
                        res << {
         | 
| 126 | 
            +
                          reference_no: item[:reference_no],
         | 
| 127 | 
            +
                          source_id: item[:source_id],
         | 
| 128 | 
            +
                          destination_id: item[:destination_id],
         | 
| 129 | 
            +
                          dispatch_plan_id: plan.id,
         | 
| 130 | 
            +
                          quantity: item[:quantity],
         | 
| 131 | 
            +
                          unit_id: item[:unit_id],
         | 
| 132 | 
            +
                          commodity_id: item[:commodity_id],
         | 
| 133 | 
            +
                          commodity_status: item[:commodity_status],
         | 
| 134 | 
            +
                          status: Cats::Core::DispatchPlanItem::UNAUTHORIZED
         | 
| 135 | 
            +
                        }
         | 
| 136 | 
            +
                      end
         | 
| 137 | 
            +
                      Cats::Core::DispatchPlanItem.insert_all(items, record_timestamps: true)
         | 
| 138 | 
            +
                    end
         | 
| 139 | 
            +
                    plan
         | 
| 140 | 
            +
                  end
         | 
| 62 141 | 
             
                end
         | 
| 63 142 | 
             
              end
         | 
| 64 143 | 
             
            end
         | 
    
        data/config/routes.rb
    CHANGED
    
    | @@ -84,7 +84,18 @@ Cats::Core::Engine.routes.draw do | |
| 84 84 | 
             
              post '/routes/bulk_create', controller: :routes, action: :bulk_create
         | 
| 85 85 | 
             
              resources :routes, except: %i[destroy]
         | 
| 86 86 |  | 
| 87 | 
            +
              resources :commodity_donations, except: %i[destroy]
         | 
| 88 | 
            +
              resources :purchase_orders, except: %i[index destroy]
         | 
| 89 | 
            +
              resources :cash_donations, except: %i[destroy] do
         | 
| 90 | 
            +
                member do
         | 
| 91 | 
            +
                  get 'purchase_orders', controller: :purchase_orders, action: :index
         | 
| 92 | 
            +
                end
         | 
| 93 | 
            +
              end
         | 
| 94 | 
            +
              resources :swaps, except: %i[destory]
         | 
| 95 | 
            +
              resources :loans, except: %i[destory]
         | 
| 96 | 
            +
             | 
| 87 97 | 
             
              post '/dispatch_plans/filter', controller: :dispatch_plans, action: :filter
         | 
| 98 | 
            +
              post '/dispatch_plans/bulk_create'
         | 
| 88 99 | 
             
              resources :dispatch_plans do
         | 
| 89 100 | 
             
                member do
         | 
| 90 101 | 
             
                  get 'items', controller: :dispatch_plan_items, action: :index
         | 
| @@ -160,13 +171,21 @@ Cats::Core::Engine.routes.draw do | |
| 160 171 | 
             
              resources :receipt_transactions, except: %i[index new edit destroy]
         | 
| 161 172 | 
             
              resources :lost_commodities, except: %i[index destroy]
         | 
| 162 173 | 
             
              get '/plans/:id/round_plans', controller: :round_plans, action: :index, as: :round_plans_plan
         | 
| 174 | 
            +
              
         | 
| 175 | 
            +
              post '/round_beneficiaries/filter'
         | 
| 176 | 
            +
              resources :round_beneficiaries, only: %i[show]
         | 
| 163 177 | 
             
              post '/round_plans/generate'
         | 
| 164 178 | 
             
              post '/round_plans/filter'
         | 
| 165 179 | 
             
              resources :round_plans, except: %i[index destroy] do
         | 
| 166 180 | 
             
                member do
         | 
| 181 | 
            +
                  post 'generate_dispatch_plan', controller: :dispatch_plans, action: :generate
         | 
| 167 182 | 
             
                  post 'remove_items'
         | 
| 183 | 
            +
                  post 'remove_beneficiaries', controller: :round_beneficiaries, action: :remove_beneficiaries
         | 
| 184 | 
            +
                  post 'confirm_receipt', controller: :round_beneficiaries, action: :confirm_receipt
         | 
| 168 185 | 
             
                  post 'generate_round_needs'
         | 
| 169 186 | 
             
                  post 'approve'
         | 
| 187 | 
            +
                  post 'generate_distribution_list', controller: :round_beneficiaries, action: :generate
         | 
| 188 | 
            +
                  get 'beneficiaries', controller: :round_beneficiaries, action: :index
         | 
| 170 189 | 
             
                end
         | 
| 171 190 | 
             
              end
         | 
| 172 191 |  | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            class CreateCatsCoreCommodityDonations < ActiveRecord::Migration[6.1]
         | 
| 2 | 
            +
              def change
         | 
| 3 | 
            +
                create_table :cats_core_commodity_donations do |t|
         | 
| 4 | 
            +
                  t.string :reference_no, unique: true
         | 
| 5 | 
            +
                  t.string :description
         | 
| 6 | 
            +
                  t.string :shipping_reference
         | 
| 7 | 
            +
                  t.date :donated_on, null: false
         | 
| 8 | 
            +
                  t.references :donor,
         | 
| 9 | 
            +
                               null: false,
         | 
| 10 | 
            +
                               index: { name: 'donor_on_cd_indx' },
         | 
| 11 | 
            +
                               foreign_key: { to_table: :cats_core_donors }
         | 
| 12 | 
            +
                  t.references :commodity_category,
         | 
| 13 | 
            +
                               null: false,
         | 
| 14 | 
            +
                               index: { name: 'cc_on_cd_indx' },
         | 
| 15 | 
            +
                               foreign_key: { to_table: :cats_core_commodity_categories }
         | 
| 16 | 
            +
                  t.references :plan,
         | 
| 17 | 
            +
                               null: true,
         | 
| 18 | 
            +
                               index: { name: 'plan_on_cd_indx' },
         | 
| 19 | 
            +
                               foreign_key: { to_table: :cats_core_plans }
         | 
| 20 | 
            +
                  t.float :quantity, null: false
         | 
| 21 | 
            +
                  t.references :unit,
         | 
| 22 | 
            +
                               null: false,
         | 
| 23 | 
            +
                               index: { name: 'unit_on_cd_indx' },
         | 
| 24 | 
            +
                               foreign_key: { to_table: :cats_core_unit_of_measures }
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  t.timestamps
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            class CreateCatsCoreCashDonations < ActiveRecord::Migration[7.0]
         | 
| 2 | 
            +
              def change
         | 
| 3 | 
            +
                create_table :cats_core_cash_donations do |t|
         | 
| 4 | 
            +
                  t.string :reference_no, unique: true
         | 
| 5 | 
            +
                  t.string :description
         | 
| 6 | 
            +
                  t.date :donated_on, null: false
         | 
| 7 | 
            +
                  t.references :donor,
         | 
| 8 | 
            +
                               null: false,
         | 
| 9 | 
            +
                               index: { name: 'donor_on_cad_indx' },
         | 
| 10 | 
            +
                               foreign_key: { to_table: :cats_core_donors }
         | 
| 11 | 
            +
                  t.float :amount, null: false
         | 
| 12 | 
            +
                  t.references :currency,
         | 
| 13 | 
            +
                               null: false,
         | 
| 14 | 
            +
                               index: { name: 'currency_on_cad_indx' },
         | 
| 15 | 
            +
                               foreign_key: { to_table: :cats_core_currencies }
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  t.timestamps
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| @@ -3,12 +3,6 @@ class CreateCatsCoreGiftCertificates < ActiveRecord::Migration[6.1] | |
| 3 3 | 
             
                create_table :cats_core_gift_certificates do |t|
         | 
| 4 4 | 
             
                  t.string :reference_no, unique: true
         | 
| 5 5 | 
             
                  t.date :gift_date, null: false
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                  t.references :donation,
         | 
| 8 | 
            -
                               null: true,
         | 
| 9 | 
            -
                               index: { name: 'gc_on_donation_indx' },
         | 
| 10 | 
            -
                               foreign_key: { to_table: :cats_core_donations }
         | 
| 11 | 
            -
             | 
| 12 6 | 
             
                  t.string :vessel
         | 
| 13 7 | 
             
                  t.string :port
         | 
| 14 8 | 
             
                  t.string :customs_declaration_no
         | 
| @@ -20,9 +14,9 @@ class CreateCatsCoreGiftCertificates < ActiveRecord::Migration[6.1] | |
| 20 14 | 
             
                               null: false,
         | 
| 21 15 | 
             
                               index: { name: 'gc_on_cc_indx' },
         | 
| 22 16 | 
             
                               foreign_key: { to_table: :cats_core_commodity_categories }
         | 
| 23 | 
            -
                  t.references : | 
| 17 | 
            +
                  t.references :unit,
         | 
| 24 18 | 
             
                               null: false,
         | 
| 25 | 
            -
                               index: { name: ' | 
| 19 | 
            +
                               index: { name: 'unit_on_gc_indx' },
         | 
| 26 20 | 
             
                               foreign_key: { to_table: :cats_core_unit_of_measures }
         | 
| 27 21 | 
             
                  t.references :destination_warehouse,
         | 
| 28 22 | 
             
                               null: false,
         | 
| @@ -7,14 +7,18 @@ class CreateCatsCorePurchaseOrders < ActiveRecord::Migration[6.1] | |
| 7 7 | 
             
                  t.string :supplier, null: false
         | 
| 8 8 | 
             
                  t.float :quantity, null: false
         | 
| 9 9 | 
             
                  t.string :purchase_type, null: false
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                  t.references : | 
| 10 | 
            +
                  t.float :price, null: false
         | 
| 11 | 
            +
                  t.references :currency,
         | 
| 12 | 
            +
                               null: false,
         | 
| 13 | 
            +
                               index: { name: 'currency_on_po_indx' },
         | 
| 14 | 
            +
                               foreign_key: { to_table: :cats_core_currencies }
         | 
| 15 | 
            +
                  t.references :cash_donation,
         | 
| 12 16 | 
             
                               null: false,
         | 
| 13 | 
            -
                               index: { name: ' | 
| 14 | 
            -
                               foreign_key: { to_table: : | 
| 17 | 
            +
                               index: { name: 'cd_on_po_indx' },
         | 
| 18 | 
            +
                               foreign_key: { to_table: :cats_core_cash_donations }
         | 
| 15 19 | 
             
                  t.references :commodity_category,
         | 
| 16 20 | 
             
                               null: false,
         | 
| 17 | 
            -
                               index: { name: ' | 
| 21 | 
            +
                               index: { name: 'cc_on_po_indx' },
         | 
| 18 22 | 
             
                               foreign_key: { to_table: :cats_core_commodity_categories }
         | 
| 19 23 | 
             
                  t.references :unit,
         | 
| 20 24 | 
             
                               null: false,
         | 
| @@ -9,6 +9,10 @@ class CreateCatsCoreBeneficiaries < ActiveRecord::Migration[7.0] | |
| 9 9 | 
             
                               null: false,
         | 
| 10 10 | 
             
                               index: { name: 'bc_on_beneficiaries_indx' },
         | 
| 11 11 | 
             
                               foreign_key: { to_table: :cats_core_beneficiary_categories }
         | 
| 12 | 
            +
                  t.references :fdp,
         | 
| 13 | 
            +
                               null: false,
         | 
| 14 | 
            +
                               index: { name: 'fdp_on_beneficiaries_indx' },
         | 
| 15 | 
            +
                               foreign_key: { to_table: :cats_core_locations }
         | 
| 12 16 |  | 
| 13 17 | 
             
                  t.timestamps
         | 
| 14 18 | 
             
                end
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            class CreateCatsCoreLoans < ActiveRecord::Migration[7.0]
         | 
| 2 | 
            +
              def change
         | 
| 3 | 
            +
                create_table :cats_core_loans do |t|
         | 
| 4 | 
            +
                  t.string :reference_no, unique: true
         | 
| 5 | 
            +
                  t.string :lender, null: false
         | 
| 6 | 
            +
                  t.date :agreement_date, null: false
         | 
| 7 | 
            +
                  t.date :repayment_date
         | 
| 8 | 
            +
                  t.references :commodity_category,
         | 
| 9 | 
            +
                               null: false,
         | 
| 10 | 
            +
                               index: { name: 'cc_on_loan_indx' },
         | 
| 11 | 
            +
                               foreign_key: { to_table: :cats_core_commodity_categories }
         | 
| 12 | 
            +
                  t.float :quantity, null: false
         | 
| 13 | 
            +
                  t.references :unit,
         | 
| 14 | 
            +
                               null: false,
         | 
| 15 | 
            +
                               index: { name: 'unit_on_loan_indx' },
         | 
| 16 | 
            +
                               foreign_key: { to_table: :cats_core_unit_of_measures }
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  t.timestamps
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            class CreateCatsCoreSwaps < ActiveRecord::Migration[7.0]
         | 
| 2 | 
            +
              def change
         | 
| 3 | 
            +
                create_table :cats_core_swaps do |t|
         | 
| 4 | 
            +
                  t.string :reference_no, unique: true
         | 
| 5 | 
            +
                  t.string :swapper, null: false
         | 
| 6 | 
            +
                  t.date :agreement_date, null: false
         | 
| 7 | 
            +
                  t.float :issued_quantity, null: false
         | 
| 8 | 
            +
                  t.float :received_quantity, null: false
         | 
| 9 | 
            +
                  t.references :issued_commodity,
         | 
| 10 | 
            +
                               null: false,
         | 
| 11 | 
            +
                               index: { name: 'ic_on_swap_indx' },
         | 
| 12 | 
            +
                               foreign_key: { to_table: :cats_core_commodity_categories }
         | 
| 13 | 
            +
                  t.references :received_commodity,
         | 
| 14 | 
            +
                               null: false,
         | 
| 15 | 
            +
                               index: { name: 'rc_on_swap_indx' },
         | 
| 16 | 
            +
                               foreign_key: { to_table: :cats_core_commodity_categories }
         | 
| 17 | 
            +
                  t.references :issued_unit,
         | 
| 18 | 
            +
                               null: false,
         | 
| 19 | 
            +
                               index: { name: 'iu_on_swap_indx' },
         | 
| 20 | 
            +
                               foreign_key: { to_table: :cats_core_unit_of_measures }
         | 
| 21 | 
            +
                  t.references :received_unit,
         | 
| 22 | 
            +
                               null: false,
         | 
| 23 | 
            +
                               index: { name: 'ru_on_swap_indx' },
         | 
| 24 | 
            +
                               foreign_key: { to_table: :cats_core_unit_of_measures }
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  t.timestamps
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            class CreateCatsCoreRoundBeneficiaries < ActiveRecord::Migration[7.0]
         | 
| 2 | 
            +
              def change
         | 
| 3 | 
            +
                create_table :cats_core_round_beneficiaries do |t|
         | 
| 4 | 
            +
                  t.references :beneficiary, 
         | 
| 5 | 
            +
                               null: false,
         | 
| 6 | 
            +
                               index: { name: 'beneficiary_on_rb_indx' },
         | 
| 7 | 
            +
                               foreign_key: { to_table: :cats_core_beneficiaries }
         | 
| 8 | 
            +
                  t.references :round_plan_item,
         | 
| 9 | 
            +
                               null: false,
         | 
| 10 | 
            +
                               index: { name: 'rpi_on_rb_indx' },
         | 
| 11 | 
            +
                               foreign_key: { to_table: :cats_core_round_plan_items }
         | 
| 12 | 
            +
                  t.references :commodity_category,
         | 
| 13 | 
            +
                               null: false,
         | 
| 14 | 
            +
                               index: { name: 'cc_on_rb_indx' },
         | 
| 15 | 
            +
                               foreign_key: { to_table: :cats_core_commodity_categories }
         | 
| 16 | 
            +
                  t.float :quantity, null: false
         | 
| 17 | 
            +
                  t.references :unit,
         | 
| 18 | 
            +
                               null: false,
         | 
| 19 | 
            +
                               index: { name: 'unit_on_rb_indx' },
         | 
| 20 | 
            +
                               foreign_key: { to_table: :cats_core_unit_of_measures }
         | 
| 21 | 
            +
                  t.boolean :received, null: false, default: false
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  t.timestamps
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
            end
         | 
    
        data/lib/cats/core/version.rb
    CHANGED
    
    
| @@ -1,16 +1,13 @@ | |
| 1 1 | 
             
            FactoryBot.define do
         | 
| 2 | 
            -
              factory : | 
| 2 | 
            +
              factory :commodity_donation, class: 'Cats::Core::CommodityDonation' do
         | 
| 3 3 | 
             
                reference_no { FFaker::Name.name }
         | 
| 4 4 | 
             
                description { FFaker::Name.name }
         | 
| 5 | 
            -
                donation_type { Cats::Core::Donation::KIND }
         | 
| 6 5 | 
             
                shipping_reference { FFaker::Name.name }
         | 
| 7 6 | 
             
                donated_on { Date.today }
         | 
| 8 7 | 
             
                donor
         | 
| 9 8 | 
             
                plan
         | 
| 10 | 
            -
                 | 
| 11 | 
            -
                currency { nil }
         | 
| 9 | 
            +
                quantity { 100 }
         | 
| 12 10 | 
             
                commodity_category
         | 
| 13 | 
            -
                unit_of_measure
         | 
| 14 | 
            -
                active { false }
         | 
| 11 | 
            +
                unit factory: :unit_of_measure
         | 
| 15 12 | 
             
              end
         | 
| 16 13 | 
             
            end
         | 
| @@ -2,10 +2,6 @@ FactoryBot.define do | |
| 2 2 | 
             
              factory :gift_certificate, class: 'Cats::Core::GiftCertificate' do
         | 
| 3 3 | 
             
                reference_no { FFaker::Name.name }
         | 
| 4 4 | 
             
                gift_date { Date.today - 1.month }
         | 
| 5 | 
            -
                donation
         | 
| 6 | 
            -
                commodity_category { donation.commodity_category }
         | 
| 7 | 
            -
                unit_of_measure
         | 
| 8 | 
            -
                destination_warehouse factory: :warehouse
         | 
| 9 5 | 
             
                vessel { FFaker::Name.name }
         | 
| 10 6 | 
             
                port { FFaker::Name.name }
         | 
| 11 7 | 
             
                customs_declaration_no { FFaker::Name.name }
         | 
| @@ -13,8 +9,11 @@ FactoryBot.define do | |
| 13 9 | 
             
                expiry_date { Date.today + 6.month }
         | 
| 14 10 | 
             
                bill_of_lading_no { FFaker::Name.name }
         | 
| 15 11 | 
             
                quantity { 1.5 }
         | 
| 16 | 
            -
                 | 
| 17 | 
            -
                 | 
| 12 | 
            +
                commodity_category
         | 
| 13 | 
            +
                unit factory: :unit_of_measure
         | 
| 14 | 
            +
                destination_warehouse factory: :warehouse
         | 
| 15 | 
            +
                estimated_price { 500 }
         | 
| 16 | 
            +
                estimated_tax { 200 }
         | 
| 18 17 | 
             
                currency
         | 
| 19 18 | 
             
                registration_no { FFaker::Name.name }
         | 
| 20 19 | 
             
                requested_by { FFaker::Name.name }
         | 
| @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            FactoryBot.define do
         | 
| 2 | 
            +
              factory :loan, class: 'Cats::Core::Loan' do
         | 
| 3 | 
            +
                reference_no { FFaker::Name.name }
         | 
| 4 | 
            +
                lender { FFaker::Name.name }
         | 
| 5 | 
            +
                agreement_date { Date.today }
         | 
| 6 | 
            +
                repayment_date { agreement_date.next_month }
         | 
| 7 | 
            +
                commodity_category
         | 
| 8 | 
            +
                quantity { 100 }
         | 
| 9 | 
            +
                unit factory: :unit_of_measure
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
            end
         | 
| @@ -2,7 +2,7 @@ FactoryBot.define do | |
| 2 2 | 
             
              factory :project, class: 'Cats::Core::Project' do
         | 
| 3 3 | 
             
                code { FFaker::Name.name }
         | 
| 4 4 | 
             
                description { FFaker::Name.name }
         | 
| 5 | 
            -
                source factory: : | 
| 5 | 
            +
                source factory: :commodity_donation
         | 
| 6 6 | 
             
                program
         | 
| 7 7 | 
             
                year { 2022 }
         | 
| 8 8 | 
             
                implementing_agency { FFaker::Name.name }
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            FactoryBot.define do
         | 
| 2 | 
            +
              factory :swap, class: 'Cats::Core::Swap' do
         | 
| 3 | 
            +
                reference_no { FFaker::Name.name }
         | 
| 4 | 
            +
                swapper { FFaker::Name.name }
         | 
| 5 | 
            +
                agreement_date { Date.yesterday }
         | 
| 6 | 
            +
                issued_commodity factory: :commodity_category
         | 
| 7 | 
            +
                issued_quantity { 100 }
         | 
| 8 | 
            +
                issued_unit factory: :unit_of_measure
         | 
| 9 | 
            +
                received_commodity factory: :commodity_category
         | 
| 10 | 
            +
                received_quantity { 150 }
         | 
| 11 | 
            +
                received_unit factory: :unit_of_measure
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            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.4. | 
| 4 | 
            +
              version: 1.4.44
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Henock L.
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022-06- | 
| 11 | 
            +
            date: 2022-06-26 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: active_model_serializers
         | 
| @@ -232,27 +232,33 @@ files: | |
| 232 232 | 
             
            - Rakefile
         | 
| 233 233 | 
             
            - app/controllers/cats/core/access_controller.rb
         | 
| 234 234 | 
             
            - app/controllers/cats/core/application_controller.rb
         | 
| 235 | 
            +
            - app/controllers/cats/core/cash_donations_controller.rb
         | 
| 235 236 | 
             
            - app/controllers/cats/core/commodities_controller.rb
         | 
| 236 237 | 
             
            - app/controllers/cats/core/commodity_categories_controller.rb
         | 
| 238 | 
            +
            - app/controllers/cats/core/commodity_donations_controller.rb
         | 
| 237 239 | 
             
            - app/controllers/cats/core/currencies_controller.rb
         | 
| 238 240 | 
             
            - app/controllers/cats/core/dispatch_authorizations_controller.rb
         | 
| 239 241 | 
             
            - app/controllers/cats/core/dispatch_plan_items_controller.rb
         | 
| 240 242 | 
             
            - app/controllers/cats/core/dispatch_plans_controller.rb
         | 
| 241 243 | 
             
            - app/controllers/cats/core/dispatch_transactions_controller.rb
         | 
| 242 244 | 
             
            - app/controllers/cats/core/dispatches_controller.rb
         | 
| 245 | 
            +
            - app/controllers/cats/core/loans_controller.rb
         | 
| 243 246 | 
             
            - app/controllers/cats/core/locations_controller.rb
         | 
| 244 247 | 
             
            - app/controllers/cats/core/lost_commodities_controller.rb
         | 
| 245 248 | 
             
            - app/controllers/cats/core/menus_controller.rb
         | 
| 246 249 | 
             
            - app/controllers/cats/core/notifications_controller.rb
         | 
| 250 | 
            +
            - app/controllers/cats/core/purchase_orders_controller.rb
         | 
| 247 251 | 
             
            - app/controllers/cats/core/receipt_authorizations_controller.rb
         | 
| 248 252 | 
             
            - app/controllers/cats/core/receipt_transactions_controller.rb
         | 
| 249 253 | 
             
            - app/controllers/cats/core/receipts_controller.rb
         | 
| 250 254 | 
             
            - app/controllers/cats/core/roles_controller.rb
         | 
| 255 | 
            +
            - app/controllers/cats/core/round_beneficiaries_controller.rb
         | 
| 251 256 | 
             
            - app/controllers/cats/core/round_plans_controller.rb
         | 
| 252 257 | 
             
            - app/controllers/cats/core/routes_controller.rb
         | 
| 253 258 | 
             
            - app/controllers/cats/core/spaces_controller.rb
         | 
| 254 259 | 
             
            - app/controllers/cats/core/stacks_controller.rb
         | 
| 255 260 | 
             
            - app/controllers/cats/core/stores_controller.rb
         | 
| 261 | 
            +
            - app/controllers/cats/core/swaps_controller.rb
         | 
| 256 262 | 
             
            - app/controllers/cats/core/transporters_controller.rb
         | 
| 257 263 | 
             
            - app/controllers/cats/core/unit_conversions_controller.rb
         | 
| 258 264 | 
             
            - app/controllers/cats/core/unit_of_measures_controller.rb
         | 
| @@ -267,8 +273,10 @@ files: | |
| 267 273 | 
             
            - app/models/cats/core/beneficiary_category.rb
         | 
| 268 274 | 
             
            - app/models/cats/core/beneficiary_plan_item.rb
         | 
| 269 275 | 
             
            - app/models/cats/core/beneficiary_round_plan_item.rb
         | 
| 276 | 
            +
            - app/models/cats/core/cash_donation.rb
         | 
| 270 277 | 
             
            - app/models/cats/core/commodity.rb
         | 
| 271 278 | 
             
            - app/models/cats/core/commodity_category.rb
         | 
| 279 | 
            +
            - app/models/cats/core/commodity_donation.rb
         | 
| 272 280 | 
             
            - app/models/cats/core/commodity_substitution.rb
         | 
| 273 281 | 
             
            - app/models/cats/core/contract_item.rb
         | 
| 274 282 | 
             
            - app/models/cats/core/currency.rb
         | 
| @@ -281,6 +289,7 @@ files: | |
| 281 289 | 
             
            - app/models/cats/core/donor.rb
         | 
| 282 290 | 
             
            - app/models/cats/core/gift_certificate.rb
         | 
| 283 291 | 
             
            - app/models/cats/core/hub_authorization.rb
         | 
| 292 | 
            +
            - app/models/cats/core/loan.rb
         | 
| 284 293 | 
             
            - app/models/cats/core/location.rb
         | 
| 285 294 | 
             
            - app/models/cats/core/lost_commodity.rb
         | 
| 286 295 | 
             
            - app/models/cats/core/menu.rb
         | 
| @@ -302,6 +311,7 @@ files: | |
| 302 311 | 
             
            - app/models/cats/core/rhn_request.rb
         | 
| 303 312 | 
             
            - app/models/cats/core/role.rb
         | 
| 304 313 | 
             
            - app/models/cats/core/role_menu.rb
         | 
| 314 | 
            +
            - app/models/cats/core/round_beneficiary.rb
         | 
| 305 315 | 
             
            - app/models/cats/core/round_plan.rb
         | 
| 306 316 | 
             
            - app/models/cats/core/round_plan_item.rb
         | 
| 307 317 | 
             
            - app/models/cats/core/round_plan_item_detail.rb
         | 
| @@ -312,6 +322,7 @@ files: | |
| 312 322 | 
             
            - app/models/cats/core/stacking_rule.rb
         | 
| 313 323 | 
             
            - app/models/cats/core/store.rb
         | 
| 314 324 | 
             
            - app/models/cats/core/supplier.rb
         | 
| 325 | 
            +
            - app/models/cats/core/swap.rb
         | 
| 315 326 | 
             
            - app/models/cats/core/tenderer.rb
         | 
| 316 327 | 
             
            - app/models/cats/core/transaction.rb
         | 
| 317 328 | 
             
            - app/models/cats/core/transport_bid.rb
         | 
| @@ -333,7 +344,9 @@ files: | |
| 333 344 | 
             
            - app/notifications/cats/core/allocation_notification.rb
         | 
| 334 345 | 
             
            - app/notifications/cats/core/dispatch_notification.rb
         | 
| 335 346 | 
             
            - app/notifications/cats/core/simple_notification.rb
         | 
| 347 | 
            +
            - app/serializers/cats/core/cash_donation_serializer.rb
         | 
| 336 348 | 
             
            - app/serializers/cats/core/commodity_category_serializer.rb
         | 
| 349 | 
            +
            - app/serializers/cats/core/commodity_donation_serializer.rb
         | 
| 337 350 | 
             
            - app/serializers/cats/core/commodity_serializer.rb
         | 
| 338 351 | 
             
            - app/serializers/cats/core/currency_serializer.rb
         | 
| 339 352 | 
             
            - app/serializers/cats/core/dispatch_authorization_serializer.rb
         | 
| @@ -341,22 +354,27 @@ files: | |
| 341 354 | 
             
            - app/serializers/cats/core/dispatch_plan_serializer.rb
         | 
| 342 355 | 
             
            - app/serializers/cats/core/dispatch_serializer.rb
         | 
| 343 356 | 
             
            - app/serializers/cats/core/dispatch_transaction_serializer.rb
         | 
| 357 | 
            +
            - app/serializers/cats/core/loan_serializer.rb
         | 
| 344 358 | 
             
            - app/serializers/cats/core/location_serializer.rb
         | 
| 345 359 | 
             
            - app/serializers/cats/core/lost_commodity_serializer.rb
         | 
| 360 | 
            +
            - app/serializers/cats/core/purchase_order_serializer.rb
         | 
| 346 361 | 
             
            - app/serializers/cats/core/receipt_authorization_serializer.rb
         | 
| 347 362 | 
             
            - app/serializers/cats/core/receipt_serializer.rb
         | 
| 348 363 | 
             
            - app/serializers/cats/core/receipt_transaction_serializer.rb
         | 
| 349 364 | 
             
            - app/serializers/cats/core/role_menu_serializer.rb
         | 
| 350 365 | 
             
            - app/serializers/cats/core/role_serializer.rb
         | 
| 366 | 
            +
            - app/serializers/cats/core/round_beneficiary_serializer.rb
         | 
| 351 367 | 
             
            - app/serializers/cats/core/round_plan_serializer.rb
         | 
| 352 368 | 
             
            - app/serializers/cats/core/route_serializer.rb
         | 
| 353 369 | 
             
            - app/serializers/cats/core/stack_serializer.rb
         | 
| 354 370 | 
             
            - app/serializers/cats/core/store_serializer.rb
         | 
| 371 | 
            +
            - app/serializers/cats/core/swap_serializer.rb
         | 
| 355 372 | 
             
            - app/serializers/cats/core/transporter_serializer.rb
         | 
| 356 373 | 
             
            - app/serializers/cats/core/unit_conversion_serializer.rb
         | 
| 357 374 | 
             
            - app/serializers/cats/core/unit_of_measure_serializer.rb
         | 
| 358 375 | 
             
            - app/serializers/cats/core/user_serializer.rb
         | 
| 359 376 | 
             
            - app/services/cats/core/authorization_service.rb
         | 
| 377 | 
            +
            - app/services/cats/core/beneficiary_service.rb
         | 
| 360 378 | 
             
            - app/services/cats/core/dispatch_plan_service.rb
         | 
| 361 379 | 
             
            - app/services/cats/core/dispatch_service.rb
         | 
| 362 380 | 
             
            - app/services/cats/core/menu_service.rb
         | 
| @@ -386,7 +404,8 @@ files: | |
| 386 404 | 
             
            - db/migrate/20210717032270_create_cats_core_rations.rb
         | 
| 387 405 | 
             
            - db/migrate/20210717032290_create_cats_core_beneficiary_plan_items.rb
         | 
| 388 406 | 
             
            - db/migrate/20210717032295_create_cats_core_plan_item_details.rb
         | 
| 389 | 
            -
            - db/migrate/ | 
| 407 | 
            +
            - db/migrate/20210717032330_create_cats_core_commodity_donations.rb
         | 
| 408 | 
            +
            - db/migrate/20210717032408_create_cats_core_cash_donations.rb
         | 
| 390 409 | 
             
            - db/migrate/20210717032602_create_cats_core_gift_certificates.rb
         | 
| 391 410 | 
             
            - db/migrate/20210717032855_create_cats_core_purchase_orders.rb
         | 
| 392 411 | 
             
            - db/migrate/20210717032927_create_cats_core_projects.rb
         | 
| @@ -434,6 +453,9 @@ files: | |
| 434 453 | 
             
            - db/migrate/20220506082329_create_cats_core_transport_orders.rb
         | 
| 435 454 | 
             
            - db/migrate/20220506083042_create_cats_core_transport_order_items.rb
         | 
| 436 455 | 
             
            - db/migrate/20220511082354_create_cats_core_beneficiaries.rb
         | 
| 456 | 
            +
            - db/migrate/20220626063501_create_cats_core_loans.rb
         | 
| 457 | 
            +
            - db/migrate/20220626063757_create_cats_core_swaps.rb
         | 
| 458 | 
            +
            - db/migrate/20220626132050_create_cats_core_round_beneficiaries.rb
         | 
| 437 459 | 
             
            - lib/cats/core.rb
         | 
| 438 460 | 
             
            - lib/cats/core/engine.rb
         | 
| 439 461 | 
             
            - lib/cats/core/version.rb
         | 
| @@ -444,8 +466,10 @@ files: | |
| 444 466 | 
             
            - spec/factories/cats/core/beneficiary_categories.rb
         | 
| 445 467 | 
             
            - spec/factories/cats/core/beneficiary_plan_items.rb
         | 
| 446 468 | 
             
            - spec/factories/cats/core/beneficiary_round_plan_items.rb
         | 
| 469 | 
            +
            - spec/factories/cats/core/cash_donations.rb
         | 
| 447 470 | 
             
            - spec/factories/cats/core/commodities.rb
         | 
| 448 471 | 
             
            - spec/factories/cats/core/commodity_categories.rb
         | 
| 472 | 
            +
            - spec/factories/cats/core/commodity_donations.rb
         | 
| 449 473 | 
             
            - spec/factories/cats/core/commodity_substitutions.rb
         | 
| 450 474 | 
             
            - spec/factories/cats/core/contract_items.rb
         | 
| 451 475 | 
             
            - spec/factories/cats/core/currencies.rb
         | 
| @@ -454,10 +478,10 @@ files: | |
| 454 478 | 
             
            - spec/factories/cats/core/dispatch_plans.rb
         | 
| 455 479 | 
             
            - spec/factories/cats/core/dispatch_transactions.rb
         | 
| 456 480 | 
             
            - spec/factories/cats/core/dispatches.rb
         | 
| 457 | 
            -
            - spec/factories/cats/core/donations.rb
         | 
| 458 481 | 
             
            - spec/factories/cats/core/donors.rb
         | 
| 459 482 | 
             
            - spec/factories/cats/core/gift_certificates.rb
         | 
| 460 483 | 
             
            - spec/factories/cats/core/hub_authorizations.rb
         | 
| 484 | 
            +
            - spec/factories/cats/core/loans.rb
         | 
| 461 485 | 
             
            - spec/factories/cats/core/locations.rb
         | 
| 462 486 | 
             
            - spec/factories/cats/core/lost_commodities.rb
         | 
| 463 487 | 
             
            - spec/factories/cats/core/menu_items.rb
         | 
| @@ -479,6 +503,7 @@ files: | |
| 479 503 | 
             
            - spec/factories/cats/core/rhn_requests.rb
         | 
| 480 504 | 
             
            - spec/factories/cats/core/role_menus.rb
         | 
| 481 505 | 
             
            - spec/factories/cats/core/roles.rb
         | 
| 506 | 
            +
            - spec/factories/cats/core/round_beneficiaries.rb
         | 
| 482 507 | 
             
            - spec/factories/cats/core/round_plan_item_details.rb
         | 
| 483 508 | 
             
            - spec/factories/cats/core/round_plan_items.rb
         | 
| 484 509 | 
             
            - spec/factories/cats/core/round_plans.rb
         | 
| @@ -489,6 +514,7 @@ files: | |
| 489 514 | 
             
            - spec/factories/cats/core/stacks.rb
         | 
| 490 515 | 
             
            - spec/factories/cats/core/stores.rb
         | 
| 491 516 | 
             
            - spec/factories/cats/core/suppliers.rb
         | 
| 517 | 
            +
            - spec/factories/cats/core/swaps.rb
         | 
| 492 518 | 
             
            - spec/factories/cats/core/tenderers.rb
         | 
| 493 519 | 
             
            - spec/factories/cats/core/transport_bid_items.rb
         | 
| 494 520 | 
             
            - spec/factories/cats/core/transport_bids.rb
         | 
| @@ -513,7 +539,7 @@ metadata: | |
| 513 539 | 
             
              homepage_uri: http://cats.ndrmcapps.org
         | 
| 514 540 | 
             
              source_code_uri: https://github.com/ndrmc/cats_core
         | 
| 515 541 | 
             
              changelog_uri: https://github.com/ndrmc/cats_core/CHANGELOG.md
         | 
| 516 | 
            -
            post_install_message: | 
| 542 | 
            +
            post_install_message:
         | 
| 517 543 | 
             
            rdoc_options: []
         | 
| 518 544 | 
             
            require_paths:
         | 
| 519 545 | 
             
            - lib
         | 
| @@ -529,7 +555,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 529 555 | 
             
                  version: '0'
         | 
| 530 556 | 
             
            requirements: []
         | 
| 531 557 | 
             
            rubygems_version: 3.3.7
         | 
| 532 | 
            -
            signing_key: | 
| 558 | 
            +
            signing_key:
         | 
| 533 559 | 
             
            specification_version: 4
         | 
| 534 560 | 
             
            summary: Core module for CATS applications
         | 
| 535 561 | 
             
            test_files: []
         |