TruBudget icon indicating copy to clipboard operation
TruBudget copied to clipboard

Workflow items w/o exchangeRate cannot be closed

Open schoel-bis opened this issue 2 years ago • 0 comments

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Description 😯

When a workflow item is created via API that has amountType set to a value different from "N/A" but does not have an exchangeRate, that item cannot be closed subsequently. This is because during the closing process the workflow item is validated and the validation contains:

  exchangeRate: Joi.string()
    .when("amountType", {
      is: Joi.valid("N/A"),
      then: Joi.forbidden(),
    })
    .when("status", {
      is: Joi.valid("closed"),
      then: Joi.required(),
      otherwise: Joi.optional(),
    }),

At the same time, the exchangeRate cannot be modified through the user interface as the respective input is disabled. Thus the item is more or less stuck in this state (n.b.: it is possible to escape from it by first setting the amountType to "N/A" and then closing the item, which has implications for the budgets, though).

I am not sure what the right solution would be. A few thoughts:

  • It may be desirable to make the exchange rate editable in any case to accommodate for situations where the exchange rate changes over the course of a project
  • The system could apply a default exchange rate if none is set, either when a workflow item with amountType "allocated" or "disbursed" is first created, or during the closing of such an item
  • The system could reject any workflow items that would fail to close due to this restriction at the creation stage

How to reproduce 🕹

  • Create a workflow item through the API that has amountType set to "allocated" but does not contain an exchange rate
  • Try to close the item

Your Environment 🌎

Tech Version
Frontend v1.29.1
API v1.29.1
Blockchain v1.?.?
Export-Service v1.?.?
Email-Service v1.?.?
Storage-Service v1.?.?

schoel-bis avatar Jun 01 '22 13:06 schoel-bis