Skip to content

Commit 1afad93

Browse files
committed
fix: memberRate for additional payments
ref issue #430
1 parent 23ac85f commit 1afad93

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/services/WorkPeriodPaymentService.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async function _createSingleWorkPeriodPaymentWithWorkPeriodAndResourceBooking (w
6868
if (correspondingResourceBooking.memberRate <= 0) {
6969
throw new errors.ConflictError(`Can't process payment with member rate: ${correspondingResourceBooking.memberRate}. It must be higher than 0`)
7070
}
71-
workPeriodPayment.memberRate = correspondingResourceBooking.memberRate
71+
7272
const maxPossibleDays = correspondingWorkPeriod.daysWorked - correspondingWorkPeriod.daysPaid
7373
if (workPeriodPayment.days > maxPossibleDays) {
7474
throw new errors.BadRequestError(`Days cannot be more than not paid days which is ${maxPossibleDays}`)
@@ -83,7 +83,8 @@ async function _createSingleWorkPeriodPaymentWithWorkPeriodAndResourceBooking (w
8383
workPeriodPayment.days = _.defaultTo(workPeriodPayment.days, maxPossibleDays)
8484
workPeriodPayment.amount = _.round(workPeriodPayment.memberRate * workPeriodPayment.days / 5, 2)
8585
}
86-
workPeriodPayment.memberRate = _.defaultTo(workPeriodPayment.memberRate, 0)
86+
// TODO: we should allow `memberRate` to be `null` as it's not required for additional payments
87+
workPeriodPayment.memberRate = _.defaultTo(correspondingResourceBooking.memberRate, 0)
8788
workPeriodPayment.customerRate = _.defaultTo(correspondingResourceBooking.customerRate, null)
8889
workPeriodPayment.id = uuid.v4()
8990
workPeriodPayment.status = WorkPeriodPaymentStatus.SCHEDULED

0 commit comments

Comments
 (0)