From 4b823dff179167be6a83bf8e52797c3657621eeb Mon Sep 17 00:00:00 2001 From: Nat Dean-Lewis Date: Mon, 23 Feb 2026 12:09:55 +0000 Subject: [PATCH] CLDC-4173: add missing sales log export fixtures and tests --- ...s_logs_csv_export_non_support_codes_26.csv | 3 ++ ..._logs_csv_export_non_support_labels_26.csv | 3 ++ .../csv/sales_log_csv_service_spec.rb | 38 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 spec/fixtures/files/sales_logs_csv_export_non_support_codes_26.csv create mode 100644 spec/fixtures/files/sales_logs_csv_export_non_support_labels_26.csv diff --git a/spec/fixtures/files/sales_logs_csv_export_non_support_codes_26.csv b/spec/fixtures/files/sales_logs_csv_export_non_support_codes_26.csv new file mode 100644 index 000000000..5902de596 --- /dev/null +++ b/spec/fixtures/files/sales_logs_csv_export_non_support_codes_26.csv @@ -0,0 +1,3 @@ +Log ID,Status of log,ID of a set of duplicate logs,Which organisation owned this property before the sale?,Which organisation owned this property before the sale? (ID),Which organisation reported the sale?,Which organisation reported the sale? (ID),Time and date the log was created,User the log is assigned to (email),User the log is assigned to (ID),Time and date the log was last updated,User that last amended the log (email),User that last amended the log (ID),Was the log submitted in-service or via bulk upload?,ID of a set of bulk uploaded logs,Year collection period opened,Day of sale completion date,Month of sale completion date,Year of sale completion date,What is the purchaser code?,Shared or discounted ownership,Type of ownership,Is this a staircasing transaction?,Is this a joint purchase?,Are there more than 2 joint buyers of this property?,Did you interview the buyer to answer these questions?,Has the buyer seen the MHCLG privacy notice?,What is the UPRN of the property?,We found an address that might be this property. Is this the property address?,Address line 1 input from address matching feature,Postcode input from address matching feature,UPRN of the address selected,Address line 1,Address line 2,Town/City,County,Part 1 of the property's postcode,Part 2 of the property's postcode,LA code,LA name,What type of unit is the property?,What is the building height classification?,How many bedrooms does the property have?,Which type of building is the property?,Is the property built or adapted to wheelchair-user standards?,What is buyer 1's age?,What is buyer 1's sex registered at birth?,Which of these best describes buyer 1's gender identity?,What is buyer 1's ethnic group?,Which of the following best describes buyer 1's ethnic background?,What is buyer 1's nationality?,Which of these best describes buyer 1's working situation?,Will buyer 1 live in the property?,Is buyer 2 or person 2 the partner of buyer 1?,What is buyer 2 or person 2's age?,What is buyer 2 or person 2's sex registered at birth?,Which of these best describes buyer 2 or person 2's gender identity?,What is buyer 2's ethnic group?,Which of the following best describes buyer 2's ethnic background?,What is buyer 2's nationality?,What is buyer 2 or person 2's working situation?,Will buyer 2 live in the property?,"Besides the buyer(s), how many other people live or will live in the property?",Is person 3 the partner of buyer 1?,What is person 3's age?,What is person 3's sex registered at birth?,What is person 3's gender identity?,What is person 3's working situation?,Is person 4 the partner of buyer 1?,What is person 4's age?,What is person 4's sex registered at birth?,What is person 4's gender identity?,What is person 4's working situation?,Is person 5 the partner of buyer 1?,What is person 5's age?,What is person 5's sex registered at birth?,What is person 5's gender identity?,What is person 5's working situation?,Is person 6 the partner of buyer 1?,What is person 6's age?,What is person 6's sex registered at birth?,What is person 6's gender identity?,What is person 6's working situation?,Household type,What was buyer 1's previous tenure?,Do you know the postcode of buyer 1's last settled accommodation?,Part 1 of postcode of buyer 1's last settled accommodation,Part 2 of postcode of buyer 1's last settled accommodation,Do you know the local authority of buyer 1's last settled accommodation?,The local authority code of buyer 1's last settled accommodation,The local authority name of buyer 1's last settled accommodation,"At the time of purchase, was buyer 2 living at the same address as buyer 1?",What was buyer 2's previous tenure?,Have any of the buyers ever served as a regular in the UK armed forces?,Is the buyer still serving in the UK armed forces?,Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?,Does anyone in the household consider themselves to have a disability?,Does anyone in the household use a wheelchair?,Is buyer 1's annual income known?,What is buyer 1's annual income?,Was buyer 1's income used for a mortgage application?,Is buyer 1's annual income known?,What is buyer 2's annual income?,Was buyer 2's income used for a mortgage application?,Were the buyers receiving any of these housing-related benefits immediately before buying this property?,Is the the total amount the buyers had in savings known?,What is the total amount the buyers had in savings before they paid any deposit for the property?,Have any of the buyers previously owned a property?,Was the previous property under shared ownership?,Is this a resale?,How long did the buyer(s) live in the property before purchasing it?,Day of the practical completion or handover date,Month of the practical completion or handover date,Year of the practical completion or handover date,How many bedrooms did the buyer's previous property have?,What was the previous property type?,What was the rent type of buyer's previous tenure?,What is the full purchase price?,What was the initial percentage equity stake purchased?,Was a mortgage used to buy this property?,What is the mortgage amount?,What is the length of the mortgage in years?,How much was the cash deposit paid on the property?,How much cash discount was given through Social Homebuy?,What is the basic monthly rent?,Does the property have any service charges?,Monthly service charges amount,Does the property have an estate management fee?,Monthly estate management fee amount,What percentage of the property has been bought in this staircasing transaction?,What percentage of the property do the buyers now own in total?,Was this transaction part of a back-to-back staircasing transaction to facilitate sale of the home on the open market?,Is this the first time the shared owner has engaged in staircasing in the home?,"Including this time, how many times has the shared owner engaged in staircasing in the home?",Day of last staircasing transaction,Month of last staircasing transaction,Year of last staircasing transaction,Day of initial staircasing transaction,Month of initial staircasing transaction,Year of initial staircasing transaction,What was the basic monthly rent prior to staircasing?,"What was the amount of any loan, grant, discount or subsidy given?",What was the percentage discount?,Does this include any extra borrowing?,Does the property have any monthly leasehold charges?,What are the total monthly leasehold charges for the property? +id,status,duplicate_set_id,owning_organisation_name,owning_organisation_id,managing_organisation_name,managing_organisation_id,created_at,assigned_to,assigned_to_id,updated_at,updated_by,updated_by_id,creation_method,bulk_upload_id,collection_start_year,day,month,year,purchid,ownershipsch,type,staircase,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la,la_label,proptype,buildheightclass,beds,builtype,wchair,age1,sexrab1,sex1,ethnic_group,ethnic,nationality_all,ecstat1,buy1livein,relat2,age2,sexrab2,sex2,ethnic_group2,ethnicbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sexrab3,sex3,ecstat3,relat4,age4,sexrab4,sex4,ecstat4,relat5,age5,sexrab5,sex5,ecstat5,relat6,age6,sexrab6,sex6,ecstat6,hhtype,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,resale,proplen,hoday,homonth,hoyear,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortlen,deposit,cashdis,mrent,has_servicecharges,servicecharges,has_management_fee,management_fee,stairbought,stairowned,staircasesale,firststair,numstair,stairlastday,stairlastmonth,stairlastyear,stairinitialday,stairinitialmonth,stairinitialyear,mrentprestaircasing,grant,discount,extrabor,has_mscharge,mscharge +,completed,,MHCLG,,MHCLG,,2026-05-01T00:00:00+01:00,billyboy@eyeklaud.com,,2026-05-01T00:00:00+01:00,,,1,,2026,1,5,2026,,2,8,,1,1,2,1,1,1,,,1,"1, Test Street",,Test Town,,SW1A,1AA,E09000033,Westminster,1,2,2,1,1,30,F,X,17,17,826,1,1,P,35,M,X,17,,826,1,1,3,X,14,F,X,9,X,-9,R,X,3,R,-9,R,R,10,,,,,,6,1,0,SW1A,1AA,1,E09000033,Westminster,3,,1,4,5,1,1,0,13400,1,0,13400,1,4,1,,1,2,,10,,,,,,,110000.0,,1,20000.0,10,80000.0,,,,,,,,,,,,,,,,,,,10000.0,,1,1,100.0 diff --git a/spec/fixtures/files/sales_logs_csv_export_non_support_labels_26.csv b/spec/fixtures/files/sales_logs_csv_export_non_support_labels_26.csv new file mode 100644 index 000000000..aa86f4f02 --- /dev/null +++ b/spec/fixtures/files/sales_logs_csv_export_non_support_labels_26.csv @@ -0,0 +1,3 @@ +Log ID,Status of log,ID of a set of duplicate logs,Which organisation owned this property before the sale?,Which organisation owned this property before the sale? (ID),Which organisation reported the sale?,Which organisation reported the sale? (ID),Time and date the log was created,User the log is assigned to (email),User the log is assigned to (ID),Time and date the log was last updated,User that last amended the log (email),User that last amended the log (ID),Was the log submitted in-service or via bulk upload?,ID of a set of bulk uploaded logs,Year collection period opened,Day of sale completion date,Month of sale completion date,Year of sale completion date,What is the purchaser code?,Shared or discounted ownership,Type of ownership,Is this a staircasing transaction?,Is this a joint purchase?,Are there more than 2 joint buyers of this property?,Did you interview the buyer to answer these questions?,Has the buyer seen the MHCLG privacy notice?,What is the UPRN of the property?,We found an address that might be this property. Is this the property address?,Address line 1 input from address matching feature,Postcode input from address matching feature,UPRN of the address selected,Address line 1,Address line 2,Town/City,County,Part 1 of the property's postcode,Part 2 of the property's postcode,LA code,LA name,What type of unit is the property?,What is the building height classification?,How many bedrooms does the property have?,Which type of building is the property?,Is the property built or adapted to wheelchair-user standards?,What is buyer 1's age?,What is buyer 1's sex registered at birth?,Which of these best describes buyer 1's gender identity?,What is buyer 1's ethnic group?,Which of the following best describes buyer 1's ethnic background?,What is buyer 1's nationality?,Which of these best describes buyer 1's working situation?,Will buyer 1 live in the property?,Is buyer 2 or person 2 the partner of buyer 1?,What is buyer 2 or person 2's age?,What is buyer 2 or person 2's sex registered at birth?,Which of these best describes buyer 2 or person 2's gender identity?,What is buyer 2's ethnic group?,Which of the following best describes buyer 2's ethnic background?,What is buyer 2's nationality?,What is buyer 2 or person 2's working situation?,Will buyer 2 live in the property?,"Besides the buyer(s), how many other people live or will live in the property?",Is person 3 the partner of buyer 1?,What is person 3's age?,What is person 3's sex registered at birth?,What is person 3's gender identity?,What is person 3's working situation?,Is person 4 the partner of buyer 1?,What is person 4's age?,What is person 4's sex registered at birth?,What is person 4's gender identity?,What is person 4's working situation?,Is person 5 the partner of buyer 1?,What is person 5's age?,What is person 5's sex registered at birth?,What is person 5's gender identity?,What is person 5's working situation?,Is person 6 the partner of buyer 1?,What is person 6's age?,What is person 6's sex registered at birth?,What is person 6's gender identity?,What is person 6's working situation?,Household type,What was buyer 1's previous tenure?,Do you know the postcode of buyer 1's last settled accommodation?,Part 1 of postcode of buyer 1's last settled accommodation,Part 2 of postcode of buyer 1's last settled accommodation,Do you know the local authority of buyer 1's last settled accommodation?,The local authority code of buyer 1's last settled accommodation,The local authority name of buyer 1's last settled accommodation,"At the time of purchase, was buyer 2 living at the same address as buyer 1?",What was buyer 2's previous tenure?,Have any of the buyers ever served as a regular in the UK armed forces?,Is the buyer still serving in the UK armed forces?,Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?,Does anyone in the household consider themselves to have a disability?,Does anyone in the household use a wheelchair?,Is buyer 1's annual income known?,What is buyer 1's annual income?,Was buyer 1's income used for a mortgage application?,Is buyer 1's annual income known?,What is buyer 2's annual income?,Was buyer 2's income used for a mortgage application?,Were the buyers receiving any of these housing-related benefits immediately before buying this property?,Is the the total amount the buyers had in savings known?,What is the total amount the buyers had in savings before they paid any deposit for the property?,Have any of the buyers previously owned a property?,Was the previous property under shared ownership?,Is this a resale?,How long did the buyer(s) live in the property before purchasing it?,Day of the practical completion or handover date,Month of the practical completion or handover date,Year of the practical completion or handover date,How many bedrooms did the buyer's previous property have?,What was the previous property type?,What was the rent type of buyer's previous tenure?,What is the full purchase price?,What was the initial percentage equity stake purchased?,Was a mortgage used to buy this property?,What is the mortgage amount?,What is the length of the mortgage in years?,How much was the cash deposit paid on the property?,How much cash discount was given through Social Homebuy?,What is the basic monthly rent?,Does the property have any service charges?,Monthly service charges amount,Does the property have an estate management fee?,Monthly estate management fee amount,What percentage of the property has been bought in this staircasing transaction?,What percentage of the property do the buyers now own in total?,Was this transaction part of a back-to-back staircasing transaction to facilitate sale of the home on the open market?,Is this the first time the shared owner has engaged in staircasing in the home?,"Including this time, how many times has the shared owner engaged in staircasing in the home?",Day of last staircasing transaction,Month of last staircasing transaction,Year of last staircasing transaction,Day of initial staircasing transaction,Month of initial staircasing transaction,Year of initial staircasing transaction,What was the basic monthly rent prior to staircasing?,"What was the amount of any loan, grant, discount or subsidy given?",What was the percentage discount?,Does this include any extra borrowing?,Does the property have any monthly leasehold charges?,What are the total monthly leasehold charges for the property? +id,status,duplicate_set_id,owning_organisation_name,owning_organisation_id,managing_organisation_name,managing_organisation_id,created_at,assigned_to,assigned_to_id,updated_at,updated_by,updated_by_id,creation_method,bulk_upload_id,collection_start_year,day,month,year,purchid,ownershipsch,type,staircase,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la,la_label,proptype,buildheightclass,beds,builtype,wchair,age1,sexrab1,sex1,ethnic_group,ethnic,nationality_all,ecstat1,buy1livein,relat2,age2,sexrab2,sex2,ethnic_group2,ethnicbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sexrab3,sex3,ecstat3,relat4,age4,sexrab4,sex4,ecstat4,relat5,age5,sexrab5,sex5,ecstat5,relat6,age6,sexrab6,sex6,ecstat6,hhtype,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,resale,proplen,hoday,homonth,hoyear,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortlen,deposit,cashdis,mrent,has_servicecharges,servicecharges,has_management_fee,management_fee,stairbought,stairowned,staircasesale,firststair,numstair,stairlastday,stairlastmonth,stairlastyear,stairinitialday,stairinitialmonth,stairinitialyear,mrentprestaircasing,grant,discount,extrabor,has_mscharge,mscharge +,completed,,MHCLG,,MHCLG,,2026-05-01T00:00:00+01:00,billyboy@eyeklaud.com,,2026-05-01T00:00:00+01:00,,,single log,,2026,1,5,2026,,Discounted Ownership,Right to Acquire (RTA),,Yes,Yes,Yes,1,1,Yes,,,1,"1, Test Street",,Test Town,,SW1A,1AA,E09000033,Westminster,Flat or maisonette,Low-rise,2,Purpose built,Yes,30,Female,Non-binary,Buyer prefers not to say,17,United Kingdom,Full-time – 30 hours or more per week,Yes,Yes,35,Male,Non-binary,Buyer prefers not to say,,United Kingdom,Full-time – 30 hours or more per week,Yes,3,No,14,Female,Non-binary,Child under 16,No,Not known,Prefers not to say,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Prefers not to say,,,,,,6,Local authority tenant,Yes,SW1A,1AA,Yes,E09000033,Westminster,Don’t know,,Yes,Yes,No,Yes,Yes,Yes,13400,Yes,Yes,13400,Yes,Don’t know ,No,,Yes,No,,10,,,,,,,110000.0,,Yes,20000.0,10,80000.0,,,,,,,,,,,,,,,,,,,10000.0,,Yes,Yes,100.0 diff --git a/spec/services/csv/sales_log_csv_service_spec.rb b/spec/services/csv/sales_log_csv_service_spec.rb index 53940580c..ace87ea08 100644 --- a/spec/services/csv/sales_log_csv_service_spec.rb +++ b/spec/services/csv/sales_log_csv_service_spec.rb @@ -468,5 +468,43 @@ RSpec.describe Csv::SalesLogCsvService do end end end + + context "and the requested form is 2026" do + let(:year) { 2026 } + let(:now) { Time.zone.local(2026, 5, 1) } + let(:fixed_time) { Time.zone.local(2026, 5, 1) } + + before do + log.update!(nationality_all: 36, manual_address_entry_selected: false, uprn: "1", uprn_known: 1, buildheightclass: 2) + end + + context "and exporting with labels" do + let(:service) { described_class.new(user:, export_type: "labels", year:) } + + it "exports the CSV with all values correct" do + expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_non_support_labels_26.csv") + values_to_delete = %w[id owning_organisation_id managing_organisation_id assigned_to_id updated_by_id] + values_to_delete.each do |attribute| + index = attribute_line.index(attribute) + content_line[index] = nil + end + expect(csv[1..]).to eq expected_content[1..] # Skip the first line as it contains the definitions + end + end + + context "and exporting with codes" do + let(:service) { described_class.new(user:, export_type: "codes", year:) } + + it "exports the CSV with all values correct" do + expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_non_support_codes_26.csv") + values_to_delete = %w[id owning_organisation_id managing_organisation_id assigned_to_id updated_by_id] + values_to_delete.each do |attribute| + index = attribute_line.index(attribute) + content_line[index] = nil + end + expect(csv[1..]).to eq expected_content[1..] # Skip the first line as it contains the definitions + end + end + end end end