From 62ef715360150e6b9ec86ca785a5428369337ade Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Thu, 31 Aug 2023 12:13:00 +0100 Subject: [PATCH] DO NOT MERGE --- DO NOT COMMIT/delete orgs script.rb | 26 + DO NOT COMMIT/generate_urls.rb | 30 ++ DO NOT COMMIT/migration_benchmarking.rb | 130 +++++ DO NOT COMMIT/owning_org_id_script.rb | 7 + .../0a36f37c-11aa-48ef-854e-8ce8d9bccd9f.xml | 509 ++++++++++++++++++ .../c1bf33c5-f715-407a-840d-d6825554feca.xml | 509 ++++++++++++++++++ .../lettings_logs_import_service_spec.rb | 25 + 7 files changed, 1236 insertions(+) create mode 100644 DO NOT COMMIT/delete orgs script.rb create mode 100644 DO NOT COMMIT/generate_urls.rb create mode 100644 DO NOT COMMIT/migration_benchmarking.rb create mode 100644 DO NOT COMMIT/owning_org_id_script.rb create mode 100644 spec/fixtures/imports/logs/0a36f37c-11aa-48ef-854e-8ce8d9bccd9f.xml create mode 100644 spec/fixtures/imports/logs/c1bf33c5-f715-407a-840d-d6825554feca.xml diff --git a/DO NOT COMMIT/delete orgs script.rb b/DO NOT COMMIT/delete orgs script.rb new file mode 100644 index 000000000..f2819a68f --- /dev/null +++ b/DO NOT COMMIT/delete orgs script.rb @@ -0,0 +1,26 @@ +org_names = ["1625 Independent People Ltd.", "A2DOMINION HOMES", "A2DOMINION SOUTH HA Ltd", "Abri Group Ltd.", "Accent Housing Ltd.", "Access Community Trust", "Accomplish Group", "ACKEE HOUSING PROJECT", "ACTION HOMELESS - LEICESTER", "Action Housing and Support Limited", "ADDICTION RECOVERY AGENCY", "ADULLAM HOMES HA Ltd.", "AKSA HA LTD", "Alabare Christian Care and Support", "AMADUDU", "Amicus Trust Ltd.", "ANAH PROJECT", "ANCHOR HANOVER", "ARCHES HOUSING ASSOCIATION LTD.", "ASHA ASIAN WOMENS AID", "ASHIANA", "Association for Spinal Injury Research, Rehabilitation and Reintegration (ASPIRE)", "Aster Communities", "Back on Track Housing", "BANGLA HOUSING ASSOCIATION", "BARNARDOS", "Basildon District Council", "Bassetlaw District Council", "Bernicia", "BEYOND HOUSING", "Birmingham City Council", "Blackburn YMCA (T/A Y Housing)", "BOURNVILLE ALMSHOUSE TRUST", "BOURNVILLE VILLAGE TRUST", "BOURNVILLE WORKS HS Ltd", "BPHA Ltd", "Bradford Cyrenians", "BRENT, WANDSWORTH & WESTMINSTER MIND", "Bridge Mental Health", "Brighter Places", "Bushbury Hill Estate Management Board", "CALICO HOUSING ASSOCIATION", "CAMBRIDGE CYRENIANS", "Caring for Communities and People (CCP)", "Catalyst Housing Ltd.", "Causeway Irish Housing", "CAYSH", "CENTRAL & CECIL HT", "CENTREPOINT", "Certitude (Support for Living)", "Change, Grow, Live", "Changing Lives", "Chartford Housing Limited", "CHELMER HOUSING PARTNERSHIP", "CHERRYTREE SUPPORT SERVICES LTD.", "Cheshire West and Chester Council", "Chorley Community Housing", "Chorus Homes", "City of Bradford Metropolitan District Council", "Clarion Housing Group", "COASTLINE HOUSING", "COMMUNITY LINKS", "CONNECT HOUSING", "Connection Support", "COTMAN HA Ltd", "COVENTRY CYRENIANS", "COVENTRY MIND", "Coventry Refugee and Migrant Centre", "CRANSTOUN DRUG SERVICES", "CREATIVE SUPPORT", "CROSBY HA Ltd", "CROWN SIMMONS HOUSING", "CROYDON CHURCHES HA Ltd", "Curo Choice Ltd", "Curo Places", "DEPAUL UK", "DERWENT HA Ltd", "Dovecotes TMO Ltd", "East Riding of Yorkshire Council", "emh homes", "Evolve Housing and Support", "Expect Ltd.", "FAMILY HELP", "FAMILY MOSAIC HOUSING", "FLAGSHIP HOUSING GROUP LTD", "Forhousing", "FOUNDATION HOUSING (Leeds)", "FRAMEWORK HA", "Funding Affordable Homes Housing Association Ltd.", "FYLDE COAST WOMEN'S AID", "GATEWAY HOUSING ASSOCIATION", "Genesis HA", "GIPSIL", "Gloucester City Homes", "GLOUCESTERSHIRE RURAL HOUSING ASSOCIATION LTD. (GRHA)", "GRAND UNION HOUSING GROUP", "GRAVESEND CHURCHES HA Ltd", "Great Places Housing Association", "GreenSquare Accord", "GreenSquare Group", "Grimsby and Cleethorpes Area Doorstep", "HALTON YMCA", "Harbour Support Services", "HARROGATE FLOWER FUND HOMES", "Harrogate Housing Association Limited", "HAVEBURY HOUSING PARTNERSHIP", "Heart of Medway Housing Association Ltd", "HESTIA HOUSING AND SUPPORT", "HEXAGON HA", "Hightown Housing Association Limited", "HINCKLEY HOMELESS", "HITS HOMES TRUST", "HOME GROUP [1199]", "Homeless Link [software company]", "Homeless Oxfordshire Ltd.", "Honeycomb Charitable Services Ltd.", "Honeycomb Group Ltd.", "HORTON HOUSING ASSOCIATION", "Housing and Care 21", "HOUSING FOR WOMEN", "HUDDERSFIELD WOMEN'S AID", "HULL & EAST YORKSHIRE MIND", "Humankind", "HUNDRED HOUSES SOCIETY", "HYDE HA Group", "HYNDBURN HOMES", "I Choose Freedom", "Imagine Mental Health", "IMPACT HOUSING ASSOCIATION", "Impakt Housing and Support", "Incommunities", "IRWELL VALLEY HA Ltd", "ISLINGTON & SHOREDITCH HA Ltd", "Jigsaw Homes North", "Jigsaw Homes Tameside", "Karbon Homes", "KIRKLEES ASIAN AND BLACK WOMEN'S WELFARE ASSOCIATION (KABWWA)", "KURDISH HA", "Lancashire Mind", "Latin American Women's Aid Refuge (LAWA)", "LDN London", "LEEDS FEDERATED HOUSING ASSOCIATION", "LEEDS WOMEN'S AID", "Legal & General Affordable Homes", "LEICESTER HA Ltd", "Leicestershire Rural Housing Association", "Lewisham Homes", "LIFE CARE AND HOUSING TRUST", "LiveWest Homes Ltd.", "LONDON & QUADRANT", "LONDON AND QUADRANT (L&Q) HOUSING TRUST", "London Borough of Hounslow", "London Borough of Lewisham", "Longhurst & Havelok Homes Ltd", "LOOK AHEAD CARE, SUPPORT AND HOUSING", "MANNINGHAM HA LTD", "MARSHA PHOENIX MEMORIAL TRUST", "MARTLET HOMES Ltd", "MCCH", "MERLIN HOUSING SOCIETY", "METROPOLITAN HOME OWNERSHIP Ltd.", "METROPOLITAN HOUSING TRUST LTD.", "MHS HOMES LTD", "MIDLAND HEART LTD.", "Milton Keynes Borough Council", "MISSING LINK", "MITRE HA Ltd", "MOAT HOMES Ltd", "Mosscare St Vincent's (MSV) Housing Group Ltd.", "MOUNT CARMEL", "NACRO", "Network Homes", "NEW HOPE", "NewArch Homes", "NEWLON HOUSING TRUST", "Next Link Housing", "Nomad Opening Doors", "North Kent MIND", "North Star Housing Group", "Northampton Domestic Abuse Service (NDAS)", "NORTHAMPTONSHIRE RURAL HOUSING ASSOCIATION", "NORTON HOUSING AND SUPPORT", "NOTTING HILL GENESIS", "NOTTING HILL HOME OWNERSHIP Ltd.", "Nottingham Community Housing Association Limited", "Nottinghamshire Women's Aid", "Oldham Metropolitan Borough Council", "Ongo Homes Limited", "Onward Homes", "ORBIT HOUSING ASSOCIATION LTD.", "ORIGIN HOUSING", "ORWELL HOUSING ASSOCIATION LTD.", "OUTLOOK CARE Ltd.", "OUTWARD HOUSING ASSOCIATION", "OXFORDSHIRE MIND", "P3", "PA Housing Limited", "PANAHGHAR", "Pathways to Independence Ltd.", "PEABODY TRUST", "PEAK DISTRICT RURAL HOUSING ASSOCIATION", "Personal Services Society (PSS)", "PHOENIX FUTURES", "Pinnacle Affordable Homes Ltd.", "Pinnacle Housing", "Pinnacle Spaces Ltd.", "PLACES FOR PEOPLE HOMES", "PLACES FOR PEOPLE LIVING+", "POPLAR HARCA Ltd.", "PRESENTATION HA Ltd", "Prima Group", "PROGRESS HOUSING ASSOCIATION LTD.", "RAVEN HOUSING TRUST", "REFUGE", "Regenda Homes", "ReSi Homes Ltd.", "ReSI Housing Limited", "RETHINK MENTAL ILLNESS", "RICHMOND FELLOWSHIP", "RIVERSIDE HOUSING GROUP", "Rooftop Housing Association Limited", "ROTHERHAM RISE", "ROUNDABOUT LTD.", "Royal Borough of Greenwich", "RUSH HOUSE", "SafeNet Domestic Abuse Service", "SAFERPLACES", "SALTASH HS LTD", "SALVATION ARMY", "SALVATION ARMY HA Ltd", "Sanctuary Affordable Housing Limited", "SANCTUARY HA", "SAXON WEALD", "SECOND STEP HA LTD", "Sheffield City Council", "SHEPHERD'S BUSH HA", "SINGLE HOMELESS PROJECT", "SINGLE PERSONS EMERG. ACCOMM IN RICHMOND (SPEAR)", "Solace Women's Aid", "SOUTH YORKSHIRE HA Ltd", "SOUTHDOWN HA", "SOUTHERN HOUSING", "SOUTHERN HOUSING HOME OWNERSHIP", "SOVEREIGN HA", "SPITALFIELDS CRYPT TRUST", "ST BASILS HA Ltd", "ST MICHAELS FELLOWSHIP", "St Mungo's", "Staying Put", "STOKE ON TRENT GINGERBREAD", "Stonewater Limited", "STONHAM HA Ltd", "STOPOVER", "STROUD BERESFORD LIMITED", "SUFFOLK MIND", "SWAN HA", "Swindon Women's Aid", "SYNERGY HOUSING LIMITED", "TARGET HA", "TAUNTON ASSN FOR THE HOMELESS HA Ltd", "THAMES REACH", "THAMES VALLEY CHARITABLE HA Ltd.", "The Albert Kennedy Trust", "The ExtraCare Charitable Trust", "The Guinness Partnership", "THE HAVEN WOLVERHAMPTON", "The Nehemiah Project", "THE OAKLEA TRUST", "The Square Building Trust Limited", "THE VILLAGES HA Ltd", "The Wish Centre", "The YOU Trust", "THRESHOLD HOUSING PROJECT", "THT and L&Q Community Limited (TLQCM)", "Thurrock Council", "Together for Mental Wellbeing", "Together Housing Group", "TOUCHSTONE", "TOWN AND COUNTRY HOUSING", "TRAFFORD HOUSING TRUST LTD", "TRANSFORM HOUSING AND SUPPORT", "Trinity Homeless Projects", "TUNTUM HA", "Turning Lives Around", "TURNING POINT", "TWO SAINTS", "TYNE HA", "UNITED RESPONSE", "UNITY HA LTD", "VALLEY HOUSE", "VIBRANCE", "VIRIDIAN HOUSING", "VIVID", "WANDLE HA Ltd", "WAY HA LTD", "Westlea Housing Association", "Wolverhampton City Council", "Wolverhampton Homes", "Women's Aid Bromley and Croydon", "Women's Aid Leicestershire Ltd.", "WOMEN'S PIONEER HOUSING Ltd.", "Wythenshawe Community Housing Group (WCHG)", "YMCA Brunel Group", "YMCA Downslink Group", "YMCA Fylde Coast", "YORKSHIRE HOUSING LIMITED", "Young Devon", "YOUNG WOMEN'S HOUSING PROJECT (YWHP)", "Your Housing Ltd.", "YWCA Yorkshire"] + +def delete_organisations(org_names) + i = 0 + org_names.each do |org_name| + i += 1 + org = Organisation.find_by(name: org_name) + if org.blank? + p "#{i} of #{org_names.count}: Org #{org_name} not found, skipping" + next + end + + org.parent_organisation_relationships.destroy_all + org.child_organisation_relationships.destroy_all + org.users.each { |u| u.legacy_users.destroy_all } + org.owned_lettings_logs.destroy_all + org.owned_sales_logs.destroy_all + org.managed_lettings_logs.destroy_all + org.owned_schemes.each { |s| s.lettings_logs.destroy_all } + org.owned_schemes.destroy_all + org.destroy! + p "#{i} of #{org_names.count}: #{org_name} and associated objects deleted" + end +end + +delete_organisations(org_names) diff --git a/DO NOT COMMIT/generate_urls.rb b/DO NOT COMMIT/generate_urls.rb new file mode 100644 index 000000000..71af07cb6 --- /dev/null +++ b/DO NOT COMMIT/generate_urls.rb @@ -0,0 +1,30 @@ +def generate_urls + log_ids = %w[ + 56f1de1c-fb89-4698-895e-31da3da21357 + 312e4268-0fb5-4c29-b643-1366bdbceb09 + 49499139-1e4a-405a-b28b-389469de7744 + ] + + types = %w[ + CORE-AR-GN + CORE-AR-SH + CORE-IR-GN + CORE-IR-SH + CORE-SR-GN + CORE-SR-SH + CORE-Sales + ] + + years = [2021, 2022, 2023] + + years.each do |year| + log_ids.each do |log_id| + types.each do |log_type| + url = "https://core.communities.gov.uk/DataCollection/logs/#{year}-#{log_type}/#{log_id}.html" + puts url + end + end + end +end + +generate_urls diff --git a/DO NOT COMMIT/migration_benchmarking.rb b/DO NOT COMMIT/migration_benchmarking.rb new file mode 100644 index 000000000..f847dae5d --- /dev/null +++ b/DO NOT COMMIT/migration_benchmarking.rb @@ -0,0 +1,130 @@ +results = {} +record = LettingsLog.find(566_858) +include Validations::SetupValidations +# include Validations::HouseholdValidations +# include Validations::PropertyValidations +# include Validations::FinancialValidations +# include Validations::TenancyValidations +# include Validations::DateValidations +# include Validations::LocalAuthorityValidations + +# methods = %w[recalculate_start_year! reset_scheme_location! process_postcode_changes! process_previous_postcode_changes! reset_invalidated_dependent_fields! reset_location_fields! reset_previous_location_fields! set_derived_fields! process_uprn_change!] + +# def validate_startdate_setup_speedy(record) +# return unless record.startdate && date_valid?("startdate", record) +# +# first_collection_start_date = if record.startdate_was.present? +# previous_collection_start_date +# else +# previous_collection_start_date +# end +# +# unless record.startdate.between?(first_collection_start_date, current_collection_end_date) +# record.errors.add :startdate, startdate_validation_error_message +# end +# +# validate_merged_organisations_start_date(record) +# end + +# methods = Validations::SetupValidations.public_methods.select{ |method| method.starts_with?("validate_") }.map(&:to_s) +# methods += Validations::HouseholdValidations.public_methods.select{ |method| method.starts_with?("validate_") }.map(&:to_s) +# methods += Validations::PropertyValidations.public_methods.select{ |method| method.starts_with?("validate_") }.map(&:to_s) +# methods += Validations::FinancialValidations.public_methods.select{ |method| method.starts_with?("validate_") }.map(&:to_s) +# methods += Validations::TenancyValidations.public_methods.select{ |method| method.starts_with?("validate_") }.map(&:to_s) +# methods += Validations::DateValidations.public_methods.select{ |method| method.starts_with?("validate_") }.map(&:to_s) +# methods += Validations::LocalAuthorityValidations.public_methods.select{ |method| method.starts_with?("validate_") }.map(&:to_s) +methods = %w[validate_startdate_setup] +benchmark_results = Benchmark.measure do + record.valid? +end + +results[:total] = benchmark_results.real + +methods.each do |method| + validation_time = Benchmark.measure { send(method, record) }.real + results[method] = validation_time +end + +puts "Total time: #{results[:total]}" +puts "Validation times:" +results.each do |method, time| + next if method == :total + + puts "#{method}: #{time}" +end + +# formhandler_result = Benchmark.measure do +# FormHandler.instance.lettings_in_crossover_period? +# end +# formhandler_result + +results = {} +record = LettingsLog.find(566_858) +include Validations::SetupValidations +methods = %w[validate_startdate_setup] +benchmark_results = Benchmark.measure do + record.valid? +end + +results[:total] = benchmark_results.real + +methods.each do |method| + validation_time = Benchmark.measure { send(method, record) }.real + results[method] = validation_time +end + +puts "Total time: #{results[:total]}" +puts "Validation times:" +results.each do |method, time| + next if method == :total + + puts "#{method}: #{time}" +end + +org_names = [ + "Affinity (Reading) Ltd.", + "APNA GHAR HA LTD", + "Barnsley Metropolitan Borough Council", + "Berneslai Homes", + "Bournemouth, Christchurch and Poole (BCP) Council", + "Bristol City Council", + "Broxtowe Borough Council", + "Derby City Council", + "Derby Homes Ltd.", + "Gateshead Housing Company", + "Gateshead Metropolitan Borough Council", + "Homes for Haringey", + "Keswick Community Housing Trust Ltd.", + "Kingston upon Hull City Council", + "London Borough of Hammersmith and Fulham", + "London Borough of Haringey", + "London Borough of Southwark", + "North Tyneside Metropolitan Borough Council", + "Nottingham City Council", + "Nottingham City Homes", + "Reading Borough Council", + "South Kesteven District Council", + "Stoke-on-Trent City Council", + "Thirteen Group", + "York Housing Association Ltd.", +] + +def delete_organisations(org_names) + org_names.each do |org_name| + org = Organisation.find_by(name: org_name) + next unless org + + org.parent_organisation_relationships.destroy_all + org.child_organisation_relationships.destroy_all + org.users.each { |u| u.legacy_users.destroy_all } + org.owned_lettings_logs.destroy_all + org.owned_sales_logs.destroy_all + org.managed_lettings_logs.destroy_all + org.owned_schemes.each { |s| s.lettings_logs.destroy_all } + org.owned_schemes.destroy_all + org.destroy! + p "#{org_name} and associated objects deleted" + end +end + +delete_organisations(org_names) diff --git a/DO NOT COMMIT/owning_org_id_script.rb b/DO NOT COMMIT/owning_org_id_script.rb new file mode 100644 index 000000000..2ad117c4e --- /dev/null +++ b/DO NOT COMMIT/owning_org_id_script.rb @@ -0,0 +1,7 @@ +files = %w[06ae0a72f481c57e8b1f698c9cda813344bf1367.zip 47fa09adab93e048451e97cee5798189c5d247d6.zip 8e344e6b2a1f16ae4a16d480d8139c82a7f291c4.zip d32e4e7d317d4f8a211c1708cb6a8adffed73fd0.zip 090e570bec8418bf04878cc7d16a54b1cfe59012.zip 48c05da98c24647acf6e897de5f8fda082e4eb02.zip 93ce1f706dedd516ac06eec344cd0ae4644aa39c.zip d4452cbfb5983a90d4ac64a681e9bf0386ef300e.zip 12f4edb1795f64f7b9e4abf6525528636c3783f7.zip 53e21423a05825173de0bec9c73e9d956587991b.zip 954fa9714023cb22090e724814ce9d6d1df1af4d.zip d826468254617b8155861cd925e1b108534d2542.zip 1a825fc70e3eb76b03183338a38a9fa3e15ac566.zip 57d4af16cdd1adc0d18af45c538a318c41d97d74.zip a20fba5f5ee4698f05cff66e04c4061bf34a8f03.zip d9b7628c0bc296c7433b85a46e33b1525dd14729.zip 1c5069344c9178b92d6baef97f560b6986b2b35c.zip 589494b37b6f391ccf23529f431644f4ad0cf02c.zip a849e9bfcc4f3d004df0b5d9ad1952d17ad67797.zip da996a5ebf26136d31c31c675601f96a68f8f5f8.zip 1c636ad589e2ae44700126c5330ce7f5796e6b43.zip 6ad10d644c5155b586123ff0fe549c17506b80ad.zip aabe67014fa6c40c76f5f5f1e4c04cd2e4bf4dce.zip e3dd2d58868a45b682adfa0b53b122532e958397.zip 22e2e768370931e2963d09ff770fbe7c502617c8.zip 6faf53d99b53428784ad3d88b0ae54eca7fd31af.zip af0fbef7fd4ab399f24b51e32a09d27d6704952d.zip e577449386639b4f394641854bdb6fb4b614cd4e.zip 23ae94497147ce2d4ea508f9b0e120328ca50273.zip 72da8b7da212bf480309262b3d1e22f5bb41bebb.zip b22c327775ff85a42a6a9c1fcb53fb4d56e5eedf.zip ecd7b6626b25a040c07a842e41b66882ecf2f224.zip 24fb7d648ef3d1ed1a2b820fe24c37f25afbe356.zip 7918a92ad61461e916a73d5120d5ba74873aafce.zip b62c33d9b02eaccc0490f381903b78884343a7d1.zip f022129265f9d0c7d19ff054f4c3571b09dc4d0f.zip 2849e32aa3c854d0f6f6693fea96f1eda6334f05.zip 7b45f3b802f80ebd534a470644b2fddb2ee781e2.zip bfebe5e135d74091a377d8898ed6c39173110a73.zip f1e5c9885846d6929033ac17b6c1379d53222f9f.zip 298d5d055e8104d3fefea71b4b82772afa0415e7.zip 817bd0ef86b8117ff5bfa3b7400d6032929a47a6.zip c3de4da8e3752ac6d4c6773de86d4d62fc217251.zip f370fe393417f8f7d5d7d0e8c4c37a48a0126193.zip 2ae243c8c0e7d12cb848be9f53317abe621e797e.zip 830527b19250e7bd5880f327e7d542b973dcf62f.zip c4d612efb457e888246ec249cc6943b01d8ebc04.zip f4c392cb1b40b3381d9f87ade2d9cdb42f90722e.zip 41d824f458fa51930a7480d031b038fabdd6fc40.zip 8793709605ca45a08994b3de688e4bff0ae511ad.zip ce070e2003b113537fc0bf634affc9688ee5e860.zip fc2865a1be9c01ea22ef4b9d2808470e47863d2e.zip 42119695bf284b907e79e0df1fc9c8beafe678ba.zip 8808cef52e52d4e360384aab422e94124497a337.zip d1d4277b971d134a36b334d1b851f993153ae61d.zip] + +i = 0 +files.each do |file_name| + i += 1 + pp `cf run-task dluhc-core-production --command "bundle exec rake core:sales_data_import_field['owning_organisation_id','#{file_name}']" --name sales_owning_org_field_import_2.#{i}` +end diff --git a/spec/fixtures/imports/logs/0a36f37c-11aa-48ef-854e-8ce8d9bccd9f.xml b/spec/fixtures/imports/logs/0a36f37c-11aa-48ef-854e-8ce8d9bccd9f.xml new file mode 100644 index 000000000..d503fc207 --- /dev/null +++ b/spec/fixtures/imports/logs/0a36f37c-11aa-48ef-854e-8ce8d9bccd9f.xml @@ -0,0 +1,509 @@ + + + 2022-CORE-SR-GN + 0a36f37c-11aa-48ef-854e-8ce8d9bccd9f + b1722fedc3d67395cbe691b1232084dbe2b4d2df + 3a4d6ecf60d0ae017a2cec05c5686f2b3fce7ec0 + 3a4d6ecf60d0ae017a2cec05c5686f2b3fce7ec0 + 2022-11-30T11:53:58.230583Z + 2023-05-16T15:48:27.617142Z + submitted-valid + 2022 + Bulk Upload + a3ad7a94-2a9d-4a61-afef-5cdce4315b9c + + + + + Yes + 2 No + 2022-08-04 +
6492244
+ 1 Private Registered Provider + <_2bTenCode>173443 + 24BRC002002 +
+ + NG8 3AN + Nottingham + E06000018 + + + 13 Relet – internal transfer (excluding renewals of a fixed-term tenancy) + 0 + 1 Social rent basis + 7 House + 1 Purpose built + 2 No + 2 + 2020-01-16 + + + + 2 No + <_2a>2 No + 2 Assured – lifetime + + <_2cYears/> + + + 22 + + Female + 6) Not Seeking Work + 1 White: English/Scottish/Welsh/Northern Irish/British + 18 United Kingdom + 2 + + Female + Child + 9) Child under 16 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 No + + + + + 3 Tenant prefers not to say + + + + + + + + Yes + 2 No + + + + + + + + + + + + + + + + + 7 1 year but under 2 years + 2 Less than 1 year + 28 Don’t know + + 25 Any other accommodation + 1 No + + Temporary_or_Unknown + Nottingham + E06000018 + 2 No + + + + + + 1 Yes + 2 No + 2 No + + 2 Tenant applied direct (no referral or nomination) + + + + 3 Don’t know + Refused + + 2 Monthly + 6 Universal Credit housing element + 1 All + 5 Weekly for 50 weeks + 85.08 + + + + 85.08 + 3 Don’t know + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + <_100>0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + <_70>0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 22 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 22 + 20 + 22 + 2023-05-16Z + 2023-05-31Z + + + + + + + + + + + + + 0 + 0 + 0 + 0 + 0 + 20 + 20 + C + 1 + 1 + 1 + 1 + 4 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + 1 + 1 New Tenant + 1 + 1 + 931 + 2 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 5 = 1 adult + 1 or more children + + + 7 + + + 1 Private Registered Provider + + + E12000004 + 79740 + Nottingham City Council + Nottingham City Council + N/A + N/A + + 79740 + + + + + + + 7 + + + + + + + + + 7 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + 81.81 + 81.81 + + + + 21.15 + + + + 81.81 + 81.81 + + + + 21.15 + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0.5 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 2 + 0 + 81.81 + 0 + + 70.8 + 77 + 25 + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 4 + 8 + 2022 + 16 + 1 + 2020 + + + + + + NG8 + 3AN + + diff --git a/spec/fixtures/imports/logs/c1bf33c5-f715-407a-840d-d6825554feca.xml b/spec/fixtures/imports/logs/c1bf33c5-f715-407a-840d-d6825554feca.xml new file mode 100644 index 000000000..3e313a3d1 --- /dev/null +++ b/spec/fixtures/imports/logs/c1bf33c5-f715-407a-840d-d6825554feca.xml @@ -0,0 +1,509 @@ + + + 2022-CORE-SR-GN + c1bf33c5-f715-407a-840d-d6825554feca + 32df07263e56a856a100aa86ad407ed3632402f3 + 3a4d6ecf60d0ae017a2cec05c5686f2b3fce7ec0 + 3a4d6ecf60d0ae017a2cec05c5686f2b3fce7ec0 + 2023-05-25T09:59:12.32873Z + 2023-05-25T10:19:02.072309Z + submitted-valid + 2022 + Bulk Upload + fe9db6c9-c7a6-4185-81cb-71af58c7bcb6 + + + + + Yes + 2 No + 2023-02-16 +
6511592
+ 1 Private Registered Provider + <_2bTenCode>174409 + 24WEE147005 +
+ + NG8 5NR + Nottingham + E06000018 + + + 13 Relet – internal transfer (excluding renewals of a fixed-term tenancy) + 0 + 1 Social rent basis + 7 House + 1 Purpose built + 2 No + 3 + 2022-12-06 + + + + 2 No + <_2a>2 No + 2 Assured – lifetime + + <_2cYears/> + + + 35 + + Male + 2) Part Time + 13 Black: African + 12 Any other country + 30 + + Female + Partner + 6) Not Seeking Work + 3 + + Male + Child + 9) Child under 16 + 2 + + Female + Child + 9) Child under 16 + 1 + + Person prefers not to say + Child + 9) Child under 16 + + + + + + + + + + + + + + + + + + + 2 No + + + + + 3 Tenant prefers not to say + + + + + + + + Yes + 2 No + + + + + + + + + + + + + + + + + 6 Don’t Know + 9 3 years but under 4 years + 28 Don’t know + + 25 Any other accommodation + 1 No + + Temporary_or_Unknown + Nottingham + E06000018 + 3 Don’t know + + + + + + 1 Yes + 2 No + 2 No + + 2 Tenant applied direct (no referral or nomination) + + + + 3 Don’t know + Refused + + + 6 Universal Credit housing element + 2 Some + 5 Weekly for 50 weeks + 88.60 + + + + 88.60 + 3 Don’t know + + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + <_100>0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + <_70>0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 3 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + + + + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 30 + 0 + 0 + 0 + 0 + 0 + 0 + 30 + 0 + 3 + 2 + 1 + 0 + 0 + 0 + 3 + 30 + 27 + 30 + 2023-05-25Z + 2023-06-09Z + + + + + + + + + + + + + 0 + 0 + 0 + 0 + 0 + 20 + 20 + C + 1 + 1 + 1 + 1 + 4 + 1 + 1 + 1 + 1 + 4 + 1 + 1 + 1 + 1 + 4 + 1 + 1 + 1 + 1 + 4 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + 2 + 1 New Tenant + 1 + 1 + 72 + 5 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 3 + 6 = 2 or more adults and 1 or more children + + + 9 + + + 1 Private Registered Provider + + + E12000004 + 79740 + Nottingham City Council + Nottingham City Council + N/A + N/A + + 79740 + + + + + + + + + 9 + + + + + + + 9 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + 85.19 + 85.19 + + + + 49.15 + + + + 85.19 + 85.19 + + + + 49.15 + + + 1 + 0 + 0 + 0 + 0 + 1 + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 1 + 73.26 + 0 + + 212.4 + 121.05 + 10 + + + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 16 + 2 + 2023 + 6 + 12 + 2022 + + + + + + NG8 + 5NR + + diff --git a/spec/services/imports/lettings_logs_import_service_spec.rb b/spec/services/imports/lettings_logs_import_service_spec.rb index 07fd6996e..0e12eaee4 100644 --- a/spec/services/imports/lettings_logs_import_service_spec.rb +++ b/spec/services/imports/lettings_logs_import_service_spec.rb @@ -1104,6 +1104,8 @@ RSpec.describe Imports::LettingsLogsImportService do let(:organisation) { FactoryBot.create(:organisation, old_visible_id: "1", provider_type: "PRP") } let(:managing_organisation) { FactoryBot.create(:organisation, old_visible_id: "2", provider_type: "PRP") } + let(:local_authority_organisation) { FactoryBot.create(:organisation, old_visible_id: "79740", provider_type: "LA") } + let(:local_authority_organisation_managing_organisation) { FactoryBot.create(:organisation, old_visible_id: "79741", provider_type: "PRP") } let(:scheme1) { FactoryBot.create(:scheme, old_visible_id: "0123", owning_organisation: organisation) } let(:scheme2) { FactoryBot.create(:scheme, old_visible_id: "456", owning_organisation: organisation) } @@ -1118,10 +1120,12 @@ RSpec.describe Imports::LettingsLogsImportService do allow(Organisation).to receive(:find_by).and_return(nil) allow(Organisation).to receive(:find_by).with(old_visible_id: organisation.old_visible_id).and_return(organisation) allow(Organisation).to receive(:find_by).with(old_visible_id: managing_organisation.old_visible_id).and_return(managing_organisation) + allow(Organisation).to receive(:find_by).with(old_visible_id: local_authority_organisation.old_visible_id).and_return(local_authority_organisation) # Created by users FactoryBot.create(:user, old_user_id: "c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa", organisation:) FactoryBot.create(:user, old_user_id: "e29c492473446dca4d50224f2bb7cf965a261d6f", organisation:) + FactoryBot.create(:user, old_user_id: "32df07263e56a856a100aa86ad407ed3632402f3", organisation: local_authority_organisation_managing_organisation) # Location setup FactoryBot.create(:location, old_visible_id: "10", postcode: "LS166FT", scheme_id: scheme1.id, mobility_type: "W", startdate: Time.zone.local(2021, 4, 1)) @@ -1496,6 +1500,27 @@ RSpec.describe Imports::LettingsLogsImportService do end end + context "and the provider type doesn't match the org" do + let(:invalid_lettings_log_id) { "c1bf33c5-f715-407a-840d-d6825554feca" } + let(:valid_lettings_log_id) { "0a36f37c-11aa-48ef-854e-8ce8d9bccd9f" } + let(:lettings_log_file) { open_file(fixture_directory, invalid_lettings_log_id) } + let(:lettings_log_xml) { Nokogiri::XML(lettings_log_file) } + + around do |example| + Timecop.freeze(Time.zone.local(2023, 8, 24)) do + Singleton.__init__(FormHandler) + example.run + end + Timecop.return + Singleton.__init__(FormHandler) + end + + it "does not error" do + expect { lettings_log_service.send(:create_log, lettings_log_xml) } + .not_to raise_error + end + end + context "when setting location fields for 23/24 logs" do let(:lettings_log_id) { "00d2343e-d5fa-4c89-8400-ec3854b0f2b4" } let(:lettings_log_file) { open_file(fixture_directory, lettings_log_id) }