components/financial_assistance/app/domain/financial_assistance/operations/applications/transformers/application_to/cv3_application.rb
# Physical households(mitc_households) are groups based on the member's Home Address.
Physical households(mitc_households) are groups based on the member's Home Address.
Physical households ( mitc_households ) are groups based on the member ' s Home Address .
def mitc_households(application)
              address_people_combinations = [{ application.primary_applicant.home_address => [{ person_id: application.primary_applicant.person_hbx_id }] }]
              non_primary_applicants = application.applicants.where(is_primary_applicant: false)
              non_primary_applicants.each do |dependent|
                home_address = dependent.home_address
                next dependent unless home_address
                all_addresses = address_people_combinations.inject([]) do |adds, add_people_combination|
                  adds << add_people_combination.keys.first
                end
                matching_existing_address = all_addresses.compact.detect do |address|
                  address.matches_addresses?(home_address)
                end
                if matching_existing_address.present?
                  matched_combi = address_people_combinations.detect do |each_combi|
                    each_combi.keys.first.matches_addresses?(home_address) if each_combi&.keys&.first
                  end
                  address_people_combinations.delete(matched_combi)
                  matched_combi[matched_combi.keys.first] << { person_id: dependent.person_hbx_id }
                  address_people_combinations << matched_combi
                else
                  address_people_combinations << { home_address => [{ person_id: dependent.person_hbx_id }] }
                end
              end
              household_id_people_combinations = []
              address_people_combinations.each_with_index do |address_people_combination, indx|
                household_id_people_combinations << { household_id: (indx + 1).to_s, people: address_people_combination.values.first }
              end
              household_id_people_combinations
            end
def mitc_households ( application ) address_people_combinations = [ { application . primary_applicant . home_address => [ { person_id : application . primary_applicant . person_hbx_id } ] } ] non_primary_applicants = application . applicants . where ( is_primary_applicant : false ) non_primary_applicants . each do | dependent | home_address = dependent . home_address next dependent unless home_address all_addresses = address_people_combinations . inject ( [ ] ) do | adds , add_people_combination | adds << add_people_combination . keys . first end matching_existing_address = all_addresses . compact . detect do | address | address . matches_addresses? ( home_address ) end if matching_existing_address . present? matched_combi = address_people_combinations . detect do | each_combi | each_combi . keys . first . matches_addresses? ( home_address ) if each_combi &. keys &. first end address_people_combinations . delete ( matched_combi ) matched_combi [ matched_combi . keys . first ] << { person_id : dependent . person_hbx_id } address_people_combinations << matched_combi else address_people_combinations << { home_address => [ { person_id : dependent . person_hbx_id } ] } end end household_id_people_combinations = [ ] address_people_combinations . each_with_index do | address_people_combination , indx | household_id_people_combinations << { household_id : ( indx + 1 ) . to_s , people : address_people_combination . values . first } end household_id_people_combinations end
Physical households(mitc_households) are groups based on the member's Home Address.
Physical households ( mitc_households ) are groups based on the member ' s Home Address .
application