Skip to content

Commit ff54e2a

Browse files
committed
fix memberRate when creating WPP
ref issue #430
1 parent ea06ea1 commit ff54e2a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/services/WorkPeriodPaymentService.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ async function _createSingleWorkPeriodPaymentWithWorkPeriodAndResourceBooking (w
6161
throw new errors.ConflictError(`id: ${correspondingResourceBooking.id} "ResourceBooking" Billing account is not assigned to the resource booking`)
6262
}
6363
workPeriodPayment.billingAccountId = correspondingResourceBooking.billingAccountId
64+
// TODO: we should allow `memberRate` to be `null` as it's not required for additional payments
65+
workPeriodPayment.memberRate = _.defaultTo(correspondingResourceBooking.memberRate, 0)
66+
workPeriodPayment.customerRate = _.defaultTo(correspondingResourceBooking.customerRate, null)
67+
6468
if (!_.has(workPeriodPayment, 'days') || workPeriodPayment.days > 0) {
6569
if (_.isNil(correspondingResourceBooking.memberRate)) {
6670
throw new errors.ConflictError(`Can't find a member rate in ResourceBooking: ${correspondingResourceBooking.id} to calculate the amount`)
@@ -83,9 +87,7 @@ async function _createSingleWorkPeriodPaymentWithWorkPeriodAndResourceBooking (w
8387
workPeriodPayment.days = _.defaultTo(workPeriodPayment.days, maxPossibleDays)
8488
workPeriodPayment.amount = _.round(workPeriodPayment.memberRate * workPeriodPayment.days / 5, 2)
8589
}
86-
// TODO: we should allow `memberRate` to be `null` as it's not required for additional payments
87-
workPeriodPayment.memberRate = _.defaultTo(correspondingResourceBooking.memberRate, 0)
88-
workPeriodPayment.customerRate = _.defaultTo(correspondingResourceBooking.customerRate, null)
90+
8991
workPeriodPayment.id = uuid.v4()
9092
workPeriodPayment.status = WorkPeriodPaymentStatus.SCHEDULED
9193
workPeriodPayment.createdBy = createdBy

0 commit comments

Comments
 (0)