-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CRIMAPP-907] Translate MAAT decisions #777
Conversation
48ff1e9
to
f3ec6d1
Compare
Gemfile
Outdated
@@ -25,7 +25,7 @@ gem 'laa-criminal-applications-datastore-api-client', | |||
|
|||
gem 'laa-criminal-legal-aid-schemas', | |||
github: 'ministryofjustice/laa-criminal-legal-aid-schemas', | |||
tag: 'v1.4.3' | |||
tag: 'v1.5.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use version of schema locked down to a simplified version of the Funding Decision data model.
@@ -1,7 +1,7 @@ | |||
module Deciding | |||
class SetFundingDecision < Command | |||
attribute :user_id, Types::Uuid | |||
attribute :funding_decision, Types::FundingDecisionResult | |||
attribute :funding_decision, Types::FundingDecision | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The FundingDecisionResult field has been renamed to FundingDecision and its values simplified.
Previously, it supported all 11 MAAT decision types for Magistrates' Court and Crown Court. Now, it only allows two values: grant
, refuse
attribute :user_id, Types::Uuid | ||
|
||
def call | ||
with_decision do |decision| | ||
decision.sync_with_maat(maat_decision:, user_id:) | ||
raise MaatRecordNotChanged unless maat_decision.checksum != decision.checksum | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this guard to the command from the aggregate as it is not required in all contexts.
f3ec6d1
to
080a870
Compare
else | ||
'green' | ||
end | ||
{ 'grant' => 'green', 'refuse' => 'red' }.fetch(result, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are now only two possible Funding Decisions
attribute :maat_id, Types::Integer | ||
attribute? :case_id, Types::String.optional | ||
attribute :funding_decision, Types::FundingDecisionResult.optional | ||
class Decision < Dry::Struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This struct represents the untranslated MAAT record. Additional work is now required to clean up and translate the MAAT decision into the Apply/Review context. To facilitate this, dedicated translators for the Decision and associated tests have been created.
080a870
to
3db6996
Compare
d07f41e
to
605cd1a
Compare
@@ -13,16 +13,16 @@ en: | |||
success: | |||
assigned_to_self: You assigned this application to your list | |||
completed: You marked the application as complete | |||
completed_with_decisions: Application complete. Decision sent to provider. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the linting changes. I have fixed my LSP......
942cec9
to
e49e577
Compare
e49e577
to
0ba1e0b
Compare
@@ -2,7 +2,7 @@ module Deciding | |||
class CreateDraftFromMaat < Command | |||
attribute :application_id, Types::Uuid | |||
attribute :application_type, Types::ApplicationType | |||
attribute :maat_decision, Maat::Decision |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now use the Decisions::Draft struct in commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description of change
Introduce translators to the MAAT decision adapter.
Link to relevant ticket
Notes for reviewer
Translating MAAT decisions has become more complex as we now handle both Magistrates' and Crown Court decisions, along with workarounds like IoJ appeals and passporting versus standard means decisions. This PR introduces translators to address this complexity.
Additionally, it simplifies the Crime Apply/Review decision data model types to better reflect their context, as opposed to previously copying the types directly from MAAT.
Screenshots of changes (if applicable)
Before changes:
After changes:
How to manually test the feature