Skip to content

Commit 99f97b3

Browse files
committed
fix: additional payments
1 parent 3204533 commit 99f97b3

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
@@ -80,7 +80,7 @@ async function _createSingleWorkPeriodPaymentWithWorkPeriodAndResourceBooking (w
8080
throw new errors.BadRequestError(`Cannot process payments for the future WorkPeriods. You can process after ${workPeriodStartTime.diff(moment(), 'hours')} hours`)
8181
}
8282
workPeriodPayment.days = _.defaultTo(workPeriodPayment.days, maxPossibleDays)
83-
workPeriodPayment.amount = _.round(workPeriodPayment.memberRate * workPeriodPayment.days / 5, 2)
83+
workPeriodPayment.amount = workPeriodPayment.days > 0 ? _.round(workPeriodPayment.memberRate * workPeriodPayment.days / 5, 2) : workPeriodPayment.amount
8484
workPeriodPayment.customerRate = _.defaultTo(correspondingResourceBooking.customerRate, null)
8585
workPeriodPayment.id = uuid.v4()
8686
workPeriodPayment.status = WorkPeriodPaymentStatus.SCHEDULED
@@ -185,7 +185,8 @@ async function createWorkPeriodPayment (currentUser, workPeriodPayment) {
185185

186186
const singleCreateWorkPeriodPaymentSchema = Joi.object().keys({
187187
workPeriodId: Joi.string().uuid().required(),
188-
days: Joi.number().integer().min(1).max(5)
188+
days: Joi.number().integer().min(0).max(5),
189+
amount: Joi.number()
189190
})
190191
createWorkPeriodPayment.schema = Joi.object().keys({
191192
currentUser: Joi.object().required(),

0 commit comments

Comments
 (0)