-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Background
At the moment we do not allow editing work period payments (only status). But to fulfill the need of this frontend task topcoder-archive/topcoder-platform-micro-frontends-taas-admin-app#80 we should support editing amount and days.
Task
Update payment endpoint
-
PATCH /work-period-paymentsendpoints should allow updating the next fields if thestatusis NOTin-progress:-
amount- float number greater then0 -
days- integer value from0till maximum days we can pay:we cannot pay for more days than user worked this week. So
WorkPeriod.daysPaidcannot be more thanWorkPeriod.daysWorked.WorkPeriod.daysPaidis calculated as a sum of thedaysof all the payment of this WorkPeriod not includingcancelledorfailedpayments. If user pass such a value which would causeWorkPeriod.daysPaidto be more thanWorkPeriod.daysWorkedwe should return an error like during creating https://github.com/topcoder-platform/taas-apis/blob/dev/src/services/WorkPeriodPaymentService.js#L71-L74
-
-
Each payment actually is processed by the challenge which is stored in
challengeIdfield. if we update the payment andchallengeIdis notnulli. e. challenge for the payment was already created we have to update the corresponding challenge prize to reflect newamount(only ifamounthas been changed).- So before writing new payment data to DB and send Kafka update the challenge
prizeSets[0].prizes[0].valueto the new amount. See how we create a challenge https://github.com/topcoder-platform/taas-apis/blob/dev/src/services/PaymentService.js#L75-L78. You would have to create a new method in this service to update the challenge.- If updating challenge request failed, then trow error
Cannot update the payment amount inside the challenge: ${erro message from Challenge API}
- If updating challenge request failed, then trow error
- So before writing new payment data to DB and send Kafka update the challenge
Automation logic
We have some automation logic which happens when we create or cancel payment, see "Automation Logic" section here #288.
The automation logic should be also triggered when we edit payment amount or days. I think it should work without any additional changes, just, please, make sure.
General Requirements
Please, follow general requirements which are applicable for this task https://github.com/topcoder-platform/taas-apis#documentation-and-utils