-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Payments" flow to the Support Claims page.
Add secondary navigation to Support claims page
- Loading branch information
1 parent
8d5acc9
commit 21321e0
Showing
62 changed files
with
997 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
.govuk-heading-l { | ||
.govuk-heading-group { | ||
display: flex; | ||
flex-wrap: wrap; | ||
align-items: center; | ||
gap: govuk-spacing(2); | ||
.govuk-heading-group { | ||
display: flex; | ||
flex-wrap: wrap; | ||
align-items: center; | ||
gap: govuk-spacing(2); | ||
margin-bottom: govuk-spacing(6); | ||
|
||
.govuk-heading-l { | ||
margin: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
.govuk-tag { | ||
max-width: unset; | ||
} | ||
|
||
h1 .govuk-tag { | ||
vertical-align: middle; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
class Claim::CardComponent < ApplicationComponent | ||
attr_reader :claim | ||
attr_reader :claim, :href | ||
|
||
def initialize(claim:, classes: [], html_attributes: {}) | ||
def initialize(claim:, href:, classes: [], html_attributes: {}) | ||
super(classes:, html_attributes:) | ||
|
||
@claim = claim | ||
@href = href | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class Claims::Payments::ClaimsController < Claims::ApplicationController | ||
skip_before_action :authenticate_user! | ||
|
||
before_action :skip_authorization | ||
before_action :validate_token | ||
before_action :set_payment | ||
|
||
def download | ||
send_data Claims::Claim::GenerateCSV.call(claims: @payment.claims), filename: "claims-#{Date.current}.csv" | ||
end | ||
|
||
private | ||
|
||
def validate_token | ||
@payment_id = Rails.application.message_verifier(:payment).verify(token_param) | ||
rescue ActiveSupport::MessageVerifier::InvalidSignature, ActionController::ParameterMissing | ||
render "errors/link_expired" | ||
end | ||
|
||
def token_param | ||
params.require(:token) | ||
end | ||
|
||
def set_payment | ||
@payment = Claims::Payment.find(@payment_id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/controllers/claims/support/payments/claims_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Claims::Support::Payments::ClaimsController < Claims::Support::ApplicationController | ||
before_action :set_claim | ||
before_action :authorize_claim | ||
|
||
def information_sent | ||
@claim.update!(status: :payment_information_sent) | ||
|
||
redirect_to claims_support_claim_path(@claim) | ||
end | ||
|
||
def reject | ||
@claim.update!(status: :payment_not_approved) | ||
|
||
redirect_to claims_support_claim_path(@claim) | ||
end | ||
|
||
private | ||
|
||
def set_claim | ||
@claim = policy_scope(Claims::Claim, policy_scope_class: Claims::Support::Payments::ClaimPolicy::Scope).find(params[:id]) | ||
end | ||
|
||
def authorize_claim | ||
authorize @claim, policy_class: Claims::Support::Payments::ClaimPolicy | ||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
app/controllers/claims/support/payments/confirmations_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class Claims::Support::Payments::ConfirmationsController < Claims::Support::ApplicationController | ||
before_action :authorize_confirmation | ||
|
||
def create | ||
Claims::Payment::ParseConfirmation.call(file: file_param) | ||
|
||
redirect_to claims_support_payments_path, flash: { heading: t(".success"), success: true } | ||
end | ||
|
||
private | ||
|
||
def file_param | ||
params.require(:file) | ||
end | ||
|
||
def authorize_confirmation | ||
authorize :confirmation, policy_class: Claims::Support::Payments::ConfirmationPolicy | ||
end | ||
|
||
def policy(record = nil) | ||
Claims::Support::Payments::ConfirmationPolicy.new(current_user, record) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class Claims::Support::PaymentsController < Claims::ApplicationController | ||
before_action :set_claims, only: %i[index] | ||
before_action :authorize_payment | ||
|
||
def index; end | ||
|
||
def create | ||
Claims::Payment::CreateAndDeliver.call(current_user:) | ||
|
||
redirect_to claims_support_payments_path, flash: { heading: t(".success"), success: true } | ||
end | ||
|
||
private | ||
|
||
def set_claims | ||
@pagy, @claims = pagy(Claims::Claim.where(status: %i[payment_information_requested payment_information_sent])) | ||
end | ||
|
||
def authorize_payment | ||
authorize Claims::Payment | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,13 @@ class ApplicationMailer < Mail::Notify::Mailer | |
default from: "[email protected]" | ||
|
||
def notify_email(subject:, **headers) | ||
headers.merge!(rails_mailer: mailer_name, rails_mail_template: action_name) | ||
view_mail(GENERIC_NOTIFY_TEMPLATE, subject: environment_prefix + subject, **headers) | ||
headers.merge!( | ||
rails_mailer: mailer_name, | ||
rails_mail_template: action_name, | ||
subject: environment_prefix + subject, | ||
) | ||
|
||
view_mail(GENERIC_NOTIFY_TEMPLATE, **headers) | ||
end | ||
|
||
private | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Claims::PaymentMailer < ApplicationMailer | ||
def payment_created_notification(payment) | ||
notify_email to: esfa_email_addresses, | ||
from: t("claims.support_email"), | ||
subject: t(".subject"), | ||
body: t( | ||
".body", | ||
link_to: download_claims_payments_claims_url(token: message_verifier.generate(payment.id, expires_at:)), | ||
service_name:, | ||
) | ||
end | ||
|
||
private | ||
|
||
def esfa_email_addresses | ||
ENV["CLAIMS_ESFA_EMAIL_ADDRESSES"].split(",") | ||
end | ||
|
||
def message_verifier | ||
Rails.application.message_verifier(:payment) | ||
end | ||
|
||
def expires_at | ||
30.days.from_now | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# == Schema Information | ||
# | ||
# Table name: payments | ||
# | ||
# id :uuid not null, primary key | ||
# claim_ids :string default([]), is an Array | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# sent_by_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_payments_on_sent_by_id (sent_by_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (sent_by_id => users.id) | ||
# | ||
class Claims::Payment < ApplicationRecord | ||
belongs_to :sent_by, class_name: "Claims::SupportUser" | ||
|
||
def claims | ||
@claims ||= Claims::Claim.where(id: claim_ids) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Claims::PaymentPolicy < Claims::ApplicationPolicy | ||
def new? | ||
true | ||
end | ||
|
||
def create? | ||
Claims::Claim.submitted.any? | ||
end | ||
|
||
def instructions? | ||
true | ||
end | ||
|
||
def summary? | ||
true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Claims::Support::Payments::ClaimPolicy < Claims::ApplicationPolicy | ||
def information_sent? | ||
user.support_user? && record.payment_information_requested? | ||
end | ||
alias_method :check_information_sent?, :information_sent? | ||
|
||
def reject? | ||
user.support_user? && record.payment_information_requested? | ||
end | ||
alias_method :check_reject?, :reject? | ||
|
||
class Scope < ApplicationPolicy::Scope | ||
def resolve | ||
scope.where(status: %i[payment_information_requested payment_information_sent]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Claims::Support::Payments::ConfirmationPolicy < Claims::ApplicationPolicy | ||
def new? | ||
true | ||
end | ||
|
||
def create? | ||
Claims::Claim.where(status: %i[payment_in_progress payment_information_sent payment_information_requested]).any? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.