Skip to content

Commit

Permalink
Release 144
Browse files Browse the repository at this point in the history
  • Loading branch information
CristinaRO committed Jan 24, 2024
2 parents 200a183 + a93a149 commit b8250d1
Show file tree
Hide file tree
Showing 27 changed files with 341 additions and 71 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

[Full changelog][unreleased]

## Release 144 - 2024-01-24

[Full changelog][144]

- Change the transparency identifier and names for the DSIT organisations (DSIT and DSIT Finance)
- Add a rake task to change the transparency identifier for activities that will continue under DSIT, and the providing org reference for their actual spend and forecasts
- model a simple imported row so that users can see which row in the csv import
were skipped
- the Activity actual, refund and comment upload success view now shows the
imported actuals, refunds, activity comments and skipped rows
- Use an activity's `transparency_identifier` as `iati-identifier` in XML exports, and the `previous_identifier`, if it exists, as `other-identifier`

## Release 143 - 2024-01-23

[Full changelog][143]
Expand Down Expand Up @@ -1649,7 +1661,8 @@
- Planned start and end dates are mandatory
- Actual start and end dates must not be in the future

[unreleased]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-143...HEAD
[unreleased]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-144...HEAD
[144]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-143...release-144
[143]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-142...release-143
[142]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-141...release-142
[141]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-140...release-141
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ GEM
mini_portile2 (2.8.5)
mini_racer (0.8.0)
libv8-node (~> 18.16.0.0)
minitest (5.21.1)
minitest (5.21.2)
monetize (1.12.0)
money (~> 6.12)
money (6.16.0)
Expand Down Expand Up @@ -433,7 +433,7 @@ GEM
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sexp_processor (4.16.1)
shoulda-matchers (6.0.0)
shoulda-matchers (6.1.0)
activesupport (>= 5.2.0)
sidekiq (6.5.12)
connection_pool (>= 2.2.5, < 3)
Expand Down
15 changes: 9 additions & 6 deletions app/controllers/actuals/uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ def update
@errors = importer.errors

if import_result
# the old import and the UI combine Actuals and Refunds, so we have to do the same
# once we have tested the import, we will come back and make the UI improvements
# to make the most of the new importer
imported_actuals_and_refunds = importer.imported_actuals + importer.imported_refunds
@total_actuals = total_transactions(importer.imported_actuals)
@grouped_actuals = grouped_transactions(importer.imported_actuals)

@total_refunds = total_transactions(importer.imported_refunds)
@grouped_refunds = grouped_transactions(importer.imported_refunds)

@imported_activity_comments = importer.imported_comments

@skipped_rows = importer.skipped_rows

@total_actuals = total_transactions(imported_actuals_and_refunds)
@grouped_actuals = grouped_transactions(imported_actuals_and_refunds)
@success = true

flash.now[:notice] = t("action.actual.upload.success")
Expand Down
8 changes: 0 additions & 8 deletions app/models/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -511,14 +511,6 @@ def child_level
end
end

def iati_identifier
if previous_identifier.present?
previous_identifier
else
transparency_identifier
end
end

def iati_scope
Iati::ActivityScopeService.new(benefitting_countries).call
end
Expand Down
8 changes: 8 additions & 0 deletions app/models/import/csv/imported_row.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Import::Csv::ImportedRow
attr_reader :csv_row_number, :object

def initialize(index, object)
@csv_row_number = index + 2
@object = object
end
end
2 changes: 1 addition & 1 deletion app/models/organisation.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Organisation < ApplicationRecord
SERVICE_OWNER_IATI_REFERENCE = "GB-GOV-13"
SERVICE_OWNER_IATI_REFERENCE = "GB-GOV-26"

strip_attributes only: [:iati_reference]
has_many :users
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def import!

collate_errors_from_row_importer(index, row_importer) if row_importer.errors.any?

imported_row
Import::Csv::ImportedRow.new(index, imported_row)
end

unless @errors.empty?
Expand All @@ -41,26 +41,26 @@ def import!
end

def imported_actuals
@imported_rows.select do |row|
row.is_a?(Actual)
@imported_rows.filter_map do |row|
row.object if row.object.is_a?(Actual)
end
end

def imported_refunds
@imported_rows.select do |row|
row.is_a?(Refund)
@imported_rows.filter_map do |row|
row.object if row.object.is_a?(Refund)
end
end

def imported_comments
@imported_rows.select do |row|
row.is_a?(Comment)
@imported_rows.filter_map do |row|
row.object if row.object.is_a?(Comment)
end
end

def skipped_rows
@imported_rows.select do |row|
row.is_a?(Import::Csv::ActivityActualRefundComment::SkippedRow)
row.object.is_a?(Import::Csv::ActivityActualRefundComment::SkippedRow)
end
end

Expand Down
36 changes: 36 additions & 0 deletions app/views/actuals/uploads/_actuals.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
%table.govuk-table#actuals
%caption.govuk-table__caption.govuk-table__caption--m
Actuals
%thead.govuk-table__head
%tr.govuk-table__row
%th.govuk-table__header{class: "govuk-!-width-one-third", scope: "col"} Activity
%th.govuk-table__header{class: "govuk-!-width-one-third", scope: "col"} RODA Identifier
%th.govuk-table__header{class: "govuk-!-width-one-third", scope: "col"} Value
%tbody.govuk-table__body
- @grouped_actuals.each do |activity, actuals|
%tr.govuk-table__row{ id: "activity_actuals_#{activity.id}" }
%td.govuk-table__cell{class: "govuk-!-width-one-third"}
= activity.title
%td.govuk-table__cell{class: "govuk-!-width-one-third"}
= activity.roda_identifier
%td.govuk-table__cell{class: "govuk-!-width-one-third"}
%table.govuk-table.actuals
- actuals.each do |actual|
%tr.govuk-table__row
%td.govuk-table__cell--numeric{class: "govuk-!-width-one-half", scope: "col"}
= actual.financial_quarter_and_year
%td.govuk-table__cell--numeric{class: "govuk-!-width-one-half", scope: "col"}
= actual.value
- if actual.comment
%tr.govuk-table__row
%td.govuk-table__cell--numeric{class: "govuk-!-width-full", scope: "col", colspan: 2}
= actual.comment.body


%tr.govuk-table__row.totals
%td.govuk-table__cell Total
%td.govuk-table__cell
%td.govuk-table__cell.govuk-table__cell--numeric
= @total_actuals
19 changes: 19 additions & 0 deletions app/views/actuals/uploads/_comments.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
%table.govuk-table#comments
%caption.govuk-table__caption.govuk-table__caption--m
Activity Comments
%thead.govuk-table__head
%tr.govuk-table__row
%th.govuk-table__header{class: "govuk-!-width-one-third", scope: "col"} Activity
%th.govuk-table__header{class: "govuk-!-width-one-third", scope: "col"} RODA Identifier
%th.govuk-table__header{class: "govuk-!-width-one-third", scope: "col"} Comment
%tbody.govuk-table__body
- @imported_activity_comments.each do |comment|
%tr.govuk-table__row{ id: "activity_comment_#{comment.id}" }
%td.govuk-table__cell{class: "govuk-!-width-one-third"}
= comment.associated_activity.title
%td.govuk-table__cell{class: "govuk-!-width-one-third"}
= comment.associated_activity.roda_identifier
%td.govuk-table__cell{class: "govuk-!-width-one-third"}
= comment.body
35 changes: 35 additions & 0 deletions app/views/actuals/uploads/_refunds.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
%table.govuk-table#refunds
%caption.govuk-table__caption.govuk-table__caption--m
Refunds
%thead.govuk-table__head
%tr.govuk-table__row
%th.govuk-table__header{class: "govuk-!-width-one-third", scope: "col"} Activity
%th.govuk-table__header{class: "govuk-!-width-one-third", scope: "col"} RODA Identifier
%th.govuk-table__header{class: "govuk-!-width-one-third", scope: "col"} Value
%tbody.govuk-table__body
- @grouped_refunds.each do |activity, refunds|
%tr.govuk-table__row{ id: "activity_actuals_#{activity.id}" }
%td.govuk-table__cell{class: "govuk-!-width-one-third"}
= activity.title
%td.govuk-table__cell{class: "govuk-!-width-one-third"}
= activity.roda_identifier
%td.govuk-table__cell{class: "govuk-!-width-one-third"}
%table.govuk-table.actuals
- refunds.each do |refund|
%tr.govuk-table__row
%td.govuk-table__cell--numeric{class: "govuk-!-width-one-half", scope: "col"}
= refund.financial_quarter_and_year
%td.govuk-table__cell--numeric{class: "govuk-!-width-one-half", scope: "col"}
= refund.value
- if refund.comment
%tr.govuk-table__row
%td.govuk-table__cell--numeric{class: "govuk-!-width-full", scope: "col", colspan: 2}
= refund.comment.body

%tr.govuk-table__row.totals
%td.govuk-table__cell Total
%td.govuk-table__cell
%td.govuk-table__cell.govuk-table__cell--numeric
= @total_refunds
15 changes: 15 additions & 0 deletions app/views/actuals/uploads/_skipped.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%table.govuk-table#skipped
%caption.govuk-table__caption.govuk-table__caption--m
Skipped rows
%thead.govuk-table__head
%tr.govuk-table__row
%th.govuk-table__header{class: "govuk-!-width-one-third", scope: "col"} Row number
%th.govuk-table__header{class: "govuk-!-width-two-thirds", scope: "col"} RODA Identifier
%tbody.govuk-table__body
- @skipped_rows.each do |row|
%tr.govuk-table__row{ id: "skipped-row-#{row.csv_row_number}" }
%td.govuk-table__cell{class: "govuk-!-width-one-third"}
= row.csv_row_number
%td.govuk-table__cell{class: "govuk-!-width-two-thirds"}
= row.object.roda_identifier
24 changes: 21 additions & 3 deletions app/views/actuals/uploads/update.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,27 @@
%h1.govuk-heading-xl
= t("page_title.actual.upload_success")

.govuk-grid-row
.govuk-grid-column-full
= render partial: "shared/actuals/actuals_by_activity"
- if ROLLOUT.active?(:use_new_activity_actual_refund_comment_importer)
.govuk-grid-row
.govuk-grid-column-full
= render partial: "actuals"

.govuk-grid-row
.govuk-grid-column-full
= render partial: "refunds"

.govuk-grid-row
.govuk-grid-column-full
= render partial: "comments"

.govuk-grid-row
.govuk-grid-column-full
= render partial: "skipped"

- else
.govuk-grid-row
.govuk-grid-column-full
= render partial: "shared/actuals/actuals_by_activity"

.govuk-grid-row
.govuk-grid-column-two-thirds
Expand Down
4 changes: 2 additions & 2 deletions app/views/shared/xml/_activity.xml.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%iati-activity{"default-currency" => activity.default_currency, "xml:lang" => activity.organisation.language_code }
%iati-identifier= activity.iati_identifier
%iati-identifier= activity.transparency_identifier
%reporting-org{"type" => reporting_organisation.organisation_type, "ref" => reporting_organisation.iati_reference }
%narrative= reporting_organisation.name
%title
Expand All @@ -22,7 +22,7 @@
%participating-org{"ref" => organisation.iati_reference, "type" => organisation.organisation_type, "role" => 4}
%narrative= organisation.name
- if activity.previous_identifier?
%other-identifier{"ref" => activity.transparency_identifier, type: "A1"}
%other-identifier{"ref" => activity.previous_identifier, type: "A1"}
%activity-status{"code" => activity.iati_status}/
- if activity.planned_start_date?
%activity-date{"iso-date" => activity.planned_start_date, type: "1"}/
Expand Down
2 changes: 1 addition & 1 deletion config/locales/models/actual.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ en:
description: For example, 2020 quarter one spend on the Early Career Research Network project.
disbursement_channel: The channel through which the funds will flow for this actual.
providing_organisation: The organisation where this actual is coming from.
providing_organisation_reference_html: For example, GB-GOV-13. To lookup codes or for more information see <a href="http://org-id.guide/" target="_blank" class="govuk-link">the organisation finder service (Opens in new window)</a>.
providing_organisation_reference_html: For example, GB-GOV-26. To lookup codes or for more information see <a href="http://org-id.guide/" target="_blank" class="govuk-link">the organisation finder service (Opens in new window)</a>.
receiving_organisation: The organisation receiving the money from this actual spend.
receiving_organisation_reference_html: For example, GB-COH-12345. To lookup codes or for more information see <a href="http://org-id.guide/" target="_blank" class="govuk-link">the organisation finder service (Opens in new window)</a>.
table:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/models/organisation.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ en:
organisation:
attributes:
iati_reference:
format: Identifiers must start with a country code and company type separated by a dash, eg. GB-GOV-13
format: Identifiers must start with a country code and company type separated by a dash, eg. GB-GOV-26
blank: Enter an IATI reference
default_currency:
blank: Enter a default currency
Expand Down
28 changes: 28 additions & 0 deletions db/data/20240123152048_change_beis_to_dsit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Run me with `rails runner db/data/20240123152048_change_beis_to_dsit.rb`

service_owner = Organisation.where(iati_reference: ["GB-GOV-13", "GB-GOV-26"]).first
if service_owner
service_owner.iati_reference = "GB-GOV-26"
service_owner.name = "DEPARTMENT FOR SCIENCE, INNOVATION AND TECHNOLOGY"
service_owner.beis_organisation_reference = "DSIT"
service_owner.alternate_names = [
"DEPARTMENT FOR SCIENCE, INNOVATION & TECHNOLOGY",
"Department for Science, Innovation and Technology",
"Department for Science, Innovation & Technology"
]

unless service_owner.save
puts "Failed to save the changes to #{service_owner.name}: #{service_owner.errors.messages.inspect}"
end
end

finance = Organisation.where(iati_reference: "GB-GOV-13-OPERATIONS").first
if finance
finance.iati_reference = "GB-GOV-26-OPERATIONS"
finance.name = "DSIT FINANCE"
finance.beis_organisation_reference = "DF"

unless finance.save
puts "Failed to save the changes to #{finance.name}: #{finance.errors.messages.inspect}"
end
end
2 changes: 1 addition & 1 deletion db/seeds/organisations.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- name: Department for Business, Energy and Industrial Strategy
short_name: BEIS
reference: GB-GOV-13
reference: GB-GOV-26
type: 10
role: service_owner
- name: UK Space Agency
Expand Down
2 changes: 1 addition & 1 deletion doc/activity-identifiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ end users.
This identifier is a transformed version of the RODA Identifier that's
compatible with the IATI rules. Any string of characters in the RODA Identifier
that are not letters, digits, or `-` are replaced with `-`, and the
organisational prefix `GB-GOV-13-` is prepended to the result.
organisational prefix `GB-GOV-26-` is prepended to the result.

This identifier is not set by the ingest process _or_ assigned directly by end
users; it is derived from the RODA Identifier when that is set.
Expand Down
Loading

0 comments on commit b8250d1

Please sign in to comment.