Skip to end of banner
Go to start of banner

Fees/fines refactoring

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

This document outlines issues with current fees/fines functionality implementation and proposes solutions to these issues.

Move fee/fine actions calculation to BE

Currently, calculations for fee/fine actions are happening on FE without any checks on the BE side. Instead, when a value is entered in the amount field ("Payment amount", "Waive amount" etc.) a call to one of the new endpoints should be made in order to check if this value is valid and if the action is allowed:

POST /feefineaction/check-pay

POST /feefineaction/check-waive

POST /feefineaction/check-transfer

POST /feefineaction/check-refund

Body:

{
  "accountId": "e74d50c9-0c69-4f80-9e1b-a819719fc0c9"
  "amount": "1.0"
}
Reponse

In case of success:

Status code: 200
Response body:

{
  "accountId": "e74d50c9-0c69-4f80-9e1b-a819719fc0c9"
  "amount": "1.0",
  "allowed": true,
  "remainingAmount": "9.0"
}


In case if the amount is too high:

Status code: 422
Response body:

{
  "accountId": "e74d50c9-0c69-4f80-9e1b-a819719fc0c9"
  "amount": "1.0",
  "allowed": false,
  "errorMessage": "Payment amount exceeds the selected amount"
}


In case of invalid amount value (e.g. negative or not parsable):

Status code: 422
Response body:

{
  "accountId": "e74d50c9-0c69-4f80-9e1b-a819719fc0c9"
  "amount": "abcdefg",
  "allowed": false,
  "errorMessage": "Invalid amount entered"
}


After receiving a positive response from BE ("allowed": true), when a user proceeds with the fee/fine action, instead of updating Account and creating FeeFineAction objects directly UI needs to call one of the new endpoints with the same body:

POST /feefineaction/pay

POST /feefineaction/waive

POST /feefineaction/transfer

POST /feefineaction/refund

Body:

{
  "accountId": "e74d50c9-0c69-4f80-9e1b-a819719fc0c9"
  "amount": "1.0"
}

BE should take care of updating Account object and creating new FeeFineAction object.

Reponse

In case of success:

Status code: 201
Response body:

{
  "accountId": "e74d50c9-0c69-4f80-9e1b-a819719fc0c9"
  "amount": "1.0"
  "feeFineActionId": "8fe3026e-8eb0-49b3-8613-f889b8d0fe20"
}


FE's responsibility is to (re)load Account and new FeeFineAction objects and update the page accordingly.

In case of a failure (which is still possible - for example, someone else can waive a fine that we're trying to pay between "check" and "perform" calls):

Status code: 422
Response body:

{
  "accountId": "e74d50c9-0c69-4f80-9e1b-a819719fc0c9"
  "amount": "1.0"
  "errorMessage": "Payment amount exceeds the selected amount"
}
  • No labels