Skip to content

Commit 961d535

Browse files
Merge pull request #352 from topcoder-platform/feature/work-period-automation
Work period automation
2 parents acd1e0b + b0242d8 commit 961d535

25 files changed

+6829
-8200
lines changed

app-constants.js

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ const ChallengeStatus = {
8484
COMPLETED: 'Completed'
8585
}
8686

87+
/**
88+
* Aggregate payment status for Work Period which is determined
89+
* based on the payments the Work Period has using `PaymentStatusRules`
90+
*/
91+
const AggregatePaymentStatus = {
92+
PENDING: 'pending',
93+
IN_PROGRESS: 'in-progress',
94+
PARTIALLY_COMPLETED: 'partially-completed',
95+
COMPLETED: 'completed',
96+
NO_DAYS: 'no-days'
97+
}
98+
99+
/**
100+
* `WorkPeriodPayment.status` - possible values
101+
*/
87102
const WorkPeriodPaymentStatus = {
88103
COMPLETED: 'completed',
89104
SCHEDULED: 'scheduled',
@@ -92,6 +107,37 @@ const WorkPeriodPaymentStatus = {
92107
CANCELLED: 'cancelled'
93108
}
94109

110+
/**
111+
* The rules how to determine WorkPeriod.paymentStatus based on the payments
112+
*
113+
* The top rule has priority over the bottom rules.
114+
*/
115+
const PaymentStatusRules = [
116+
{ paymentStatus: AggregatePaymentStatus.NO_DAYS, condition: { daysWorked: 0 } },
117+
{ paymentStatus: AggregatePaymentStatus.IN_PROGRESS, condition: { hasWorkPeriodPaymentStatus: [WorkPeriodPaymentStatus.SCHEDULED, WorkPeriodPaymentStatus.IN_PROGRESS] } },
118+
{ paymentStatus: AggregatePaymentStatus.COMPLETED, condition: { hasWorkPeriodPaymentStatus: [WorkPeriodPaymentStatus.COMPLETED], hasDueDays: false } },
119+
{ paymentStatus: AggregatePaymentStatus.PARTIALLY_COMPLETED, condition: { hasWorkPeriodPaymentStatus: [WorkPeriodPaymentStatus.COMPLETED], hasDueDays: true } },
120+
{ paymentStatus: AggregatePaymentStatus.PENDING, condition: { hasDueDays: true } }
121+
]
122+
123+
/**
124+
* The WorkPeriodPayment.status values which we take into account when calculate
125+
* aggregate values inside WorkPeriod:
126+
* - daysPaid
127+
* - paymentTotal
128+
* - paymentStatus
129+
*/
130+
const ActiveWorkPeriodPaymentStatuses = [
131+
WorkPeriodPaymentStatus.SCHEDULED,
132+
WorkPeriodPaymentStatus.IN_PROGRESS,
133+
WorkPeriodPaymentStatus.COMPLETED
134+
]
135+
136+
const WorkPeriodPaymentUpdateStatus = {
137+
SCHEDULED: 'scheduled',
138+
CANCELLED: 'cancelled'
139+
}
140+
95141
const PaymentProcessingSwitch = {
96142
ON: 'ON',
97143
OFF: 'OFF'
@@ -112,7 +158,11 @@ module.exports = {
112158
Scopes,
113159
Interviews,
114160
ChallengeStatus,
161+
AggregatePaymentStatus,
115162
WorkPeriodPaymentStatus,
163+
WorkPeriodPaymentUpdateStatus,
116164
PaymentSchedulerStatus,
117-
PaymentProcessingSwitch
165+
PaymentProcessingSwitch,
166+
PaymentStatusRules,
167+
ActiveWorkPeriodPaymentStatuses
118168
}

0 commit comments

Comments
 (0)