Skip to content

[$100] Edit payments fields #431

Closed
Closed
@maxceem

Description

@maxceem

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-payments endpoints should allow updating the next fields if the status is NOT in-progress:

    • amount - float number greater then 0

    • days - integer value from 0 till maximum days we can pay:

      we cannot pay for more days than user worked this week. So WorkPeriod.daysPaid cannot be more than WorkPeriod.daysWorked. WorkPeriod.daysPaid is calculated as a sum of the days of all the payment of this WorkPeriod not including cancelled or failed payments. If user pass such a value which would cause WorkPeriod.daysPaid to be more than WorkPeriod.daysWorked we 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 challengeId field. if we update the payment and challengeId is not null i. e. challenge for the payment was already created we have to update the corresponding challenge prize to reflect new amount (only if amount has been changed).

    • So before writing new payment data to DB and send Kafka update the challenge prizeSets[0].prizes[0].value to 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}

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions