* CLDC-4028: Ensure logs will update when an organisation name change is created, as they draw the org name
this could lead to redundant exports if the name change does not impact the log at its startdate (which we put into the log), but it'd be more difficult to query this way so fine to be safe here
also query name changes by updated_at. shouldn't really matter as we don't expect name changes to be updated but worth being safe in case we need to update a name change for maintenance reasons
* CLDC-4028: Fix created at name change in lettings log
always safer to use updated at for checking whether the record has changed
* CLDC-4094: Use IDs to reassociate logs after a merge
using names was unsafe as these are not guaranteed unique in an organisation or scheme
build a list of old to new log IDs as merging schemes and locations, then use this when merging lettings logs
* CLDC-4094: Add a verifying test
LettingsLog.exportable.where("(updated_at >= :from AND updated_at <= :to) OR (values_updated_at IS NOT NULL AND values_updated_at >= :from AND values_updated_at <= :to)",params).filter_by_year(year)
SalesLog.exportable.where("(updated_at >= :from AND updated_at <= :to) OR (values_updated_at IS NOT NULL AND values_updated_at >= :from AND values_updated_at <= :to)",params).filter_by_year(year)
User.where("(updated_at >= :from AND updated_at <= :to) OR (values_updated_at IS NOT NULL AND values_updated_at >= :from AND values_updated_at <= :to)",params)
invalid:"Enter a postcode in the correct format, for example AA1 1AA."
not_in_england:"It looks like you have an entered a postcode outside of England. Only create logs for lettings in England."
la_not_valid_for_date:"%{la} does not exist on the tenancy start date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the tenancy start date"
rsnvac:
non_temp_accommodation:"Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as this accommodation is not temporary."
referral_invalid:"Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as a different source of referral for this letting."
@ -22,17 +23,24 @@ en:
uprn:
invalid:"UPRN must be 12 digits or less."
not_in_england:"It looks like you have entered an address outside of England. Only create logs for lettings in England."
la_not_valid_for_date:"%{la} does not exist on the tenancy start date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the tenancy start date"
uprn_confirmation:
not_in_england:"It looks like you have entered an address outside of England. Only create logs for lettings in England."
la_not_valid_for_date:"%{la} does not exist on the tenancy start date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the tenancy start date"
uprn_selection:
not_in_england:"It looks like you have entered an address outside of England. Only create logs for lettings in England."
la_not_valid_for_date:"%{la} does not exist on the tenancy start date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the tenancy start date"
la:
not_in_england:"It looks like you have entered an address outside of England. Only create logs for lettings in England."
la_not_valid_for_date:"%{la} does not exist on the tenancy start date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the tenancy start date"
scheme_id:
not_in_england:"This scheme’s only location is outside of England. Only create logs for lettings in England."
la_not_valid_for_date:"%{la} does not exist on the tenancy start date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the tenancy start date"
location_id:
not_in_england:"It looks like you have selected a location outside of England. Only create logs for lettings in England."
la_not_valid_for_date:"%{la} does not exist on the tenancy start date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the tenancy start date"
startdate:
postcode_not_in_england:"It looks like you have an entered a postcode outside of England. Only create logs for lettings in England."
address_not_in_england:"It looks like you have entered an address outside of England. Only create logs for lettings in England."
location_not_in_england:"It looks like you have selected a location outside of England. Only create logs for lettings in England."
la_not_valid_for_date:"%{la} does not exist on the tenancy start date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the tenancy start date"
not_joint_purchase:"Buyer’s last accommodation and discounted ownership postcodes must match."
invalid:"Enter a postcode in the correct format, for example AA1 1AA."
not_in_england:"It looks like you have entered a postcode outside of England. Only create logs for sales in England."
la_not_valid_for_date:"%{la} does not exist on the property sale date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the sale date"
ppostcode_full:
postcode_must_match_previous:
joint_purchase:"Buyers’ last accommodation and discounted ownership postcodes must match."
@ -22,6 +23,7 @@ en:
not_joint_purchase:"Buyer’s last accommodation and discounted ownership postcodes must match."
invalid:"UPRN must be 12 digits or less."
not_in_england:"It looks like you have entered an address outside of England. Only create logs for sales in England."
la_not_valid_for_date:"%{la} does not exist on the property sale date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the sale date"
beds:
bedsits_have_max_one_bedroom:"Number of bedrooms must be 1 if the property is a bedsit."
proptype:
@ -30,10 +32,14 @@ en:
invalid:"You must answer UPRN known?"
la:
not_in_england:"It looks like you have entered an address outside of England. Only create logs for sales in England."
la_not_valid_for_date:"%{la} does not exist on the property sale date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the sale date"
uprn_confirmation:
not_in_england:"It looks like you have entered an address outside of England. Only create logs for sales in England."
la_not_valid_for_date:"%{la} does not exist on the property sale date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the sale date"
uprn_selection:
not_in_england:"It looks like you have entered an address outside of England. Only create logs for sales in England."
la_not_valid_for_date:"%{la} does not exist on the property sale date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the sale date"
saledate:
postcode_not_in_england:"It looks like you have entered a postcode outside of England. Only create logs for sales in England."
address_not_in_england:"It looks like you have entered an address outside of England. Only create logs for sales in England."
la_not_valid_for_date:"%{la} does not exist on the property sale date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the sale date"
@ -147,22 +138,30 @@ Also ensure you have firefox installed
bundle exec rake db:seed
```
5. For Ordinance Survey related functionality, such as using the UPRN, you will need to set `OS_DATA_KEY` in your .env file. This key is shared across the team and can be found in AWS Secrets Manager.
6. For email functionality, you will need a GOV.UK Notify API key, which is individual to you. Ask an existing team member to invite you to the "CORE Helpdesk" Notify service. Once invited, sign in and go to "API integration" to generate an API key, and set this as `GOVUK_NOTIFY_API_KEY` in your .env file.
5. Build assets once before running the app for the first time:
```bash
yarn build --mode=development
```
6. For Ordinance Survey related functionality, such as using the UPRN, you will need to set `OS_DATA_KEY` in your .env file. This key is shared across the team and can be found in AWS Secrets Manager.
7. For email functionality, you will need a GOV.UK Notify API key, which is individual to you. Ask an existing team member to invite you to the "CORE Helpdesk" Notify service. Once invited, sign in and go to "API integration" to generate an API key, and set this as `GOVUK_NOTIFY_API_KEY` in your .env file.
## Running Locally
### Application
Start the dev servers
Start the dev servers via one of the following methods:
a. Using Foreman:
a. If using RubyMine, run the "submit-social-housing-lettings-and-sales-data" Rails configuration.
b. Using Foreman:
```bash
./bin/dev
```
b. Individually:
c. Individually:
Rails:
@ -176,20 +175,18 @@ JavaScript (for hot reloading):
yarn build --mode=development --watch
```
If you’re not modifying front end assets you can bundle them as a one off task:
```bash
yarn build --mode=development
```
Development mode will target the latest versions of Chrome, Firefox and Safari for transpilation while production mode will target older browsers.
The Rails server will start on <http://localhost:3000>.
To sign in locally, you can use any username and password from your local database. The seed task in `seeds.rb` creates users in various roles all with the password `REVIEW_APP_USER_PASSWORD` from your .env file (which has default value `password`).
To create any other users, you can edit the seed commands, or run similar commands in the rails console.
To create any other users, you can log in as a support user and create new users via the admin interface. Or, you can edit the seed commands, or run similar commands in the rails console.
You can also insert a new user row using SQL, but you will need to generate a correctly encrypted password. You can find the value to use for encrypted password which corresponds to the password `YOURPASSWORDHERE` using `User.new(:password => [YOURPASSWORDHERE]).encrypted_password`.
### rbenv
In general, whenever needing to run a Ruby command, use `bundle exec <command>` to ensure the correct Ruby version and gemset are used. Rbenv will automatically use the correct Ruby version.
### Debugging
Add the line `binding.pry` to the code to pause the execution of the code at that line and open a powerful interactive console for debugging.
@ -219,6 +216,8 @@ More details on debugging in RubyMine can be found at <https://www.jetbrains.com
bundle exec rspec
```
Or if using RubyMine, right click a spec file and select the 'Run' option.