[$45] Edit payments #80
Description
Background
At the moment we can only create new payments and cancel whole payments if we need to. But sometimes managers would like to change the amount of payment.
Task
-
We already can show the list of all the payments:
-
Replace
Cancel
button in this list withActions
dropdown menu with 2 options:Cancel Payment
- which would do the same asCancel
button does now (option should be disabled forcancelled
orin-progress
payments)Edit Payment
- which would open a modal window to edit payment details (option should be disabledin-progress
payments, payment in other statuses can be edited)- The actions dropdown is already implemented in https://github.com/topcoder-platform/taas-app see demo page https://platform.topcoder-dev.com/taas/myteams/18102. Please, port it from there. Or reuse it if it was already ported during another task [$80] Additional Payments #82.
-
For modal, use the same design as for adding payment: [$80] Additional Payments #82
-
We have 2 kind of payments:
- payment for days which user worked (we pay per day as per member rate)
- all the payments for days have
days
greater than0
- all the payments for days have
- additional payment - any amount which is additional to the payment for days, and is not counted for days
- all the additional payments have
days === 0
- all the additional payments have
- payment for days which user worked (we pay per day as per member rate)
-
Edit Payment for days
Inside payment for days we should NOT allow editing
Amount
we can only editDays
- reuse the same field which we use for Working Days
- the minimal value of days is1
(disable-
button if the value is1
and show tooltip saying:The payment cannot be done for less than 1 day
)- the maximum value of days: we cannot pay for more days than user worked this week. So
WorkPeriod.daysPaid
cannot be more thanWorkPeriod.daysWorked
.WorkPeriod.daysPaid
is calculated as a sum of thedays
of all the payments of this WorkPeriod not includingcancelled
orfailed
payments. Disable the+
button if increasing one days would causeWorkPeriod.daysPaid
to be more thanWorkPeriod.daysWorked
, see how we calculate it server-side https://github.com/topcoder-platform/taas-apis/blob/dev/src/services/WorkPeriodPaymentService.js#L285-L291
- the maximum value of days: we cannot pay for more days than user worked this week. So
-
Edit Additional Payment
For additional payment
days === 0
and we cannot edit that. We can only edit the amount. It shouldfloat
number greater than0
. And less than100 000
. If we enter wrong amount show a red validation error under the field like saying:Amount should be greater than 0 and less than 100 000
. It should look like this https://monosnap.com/file/J4f0foiyUi7FvQPCIZEdFFcfIS4hHi try removing job title here https://platform.topcoder-dev.com/taas/myteams/16873/positions/ecaf2c7f-2b43-4397-bcf5-0ddf38c7f6a6/edit -
If we click
Cancel
orX
just close the modal. -
if we click
Update
show a loading indicator inside the modal OR just disable the fields and all the buttons while sending request to the server.
API
- API has been updated to support editing payments [$100] Edit payments fields topcoder-platform/taas-apis#431
- Use
PATCH /work-period-payments/:id
endpoint https://topcoder-platform.github.io/taas-apis/#/WorkPeriodPayments/patch_work_period_payments__id_