@@ -61,6 +61,10 @@ async function _createSingleWorkPeriodPaymentWithWorkPeriodAndResourceBooking (w
61
61
throw new errors . ConflictError ( `id: ${ correspondingResourceBooking . id } "ResourceBooking" Billing account is not assigned to the resource booking` )
62
62
}
63
63
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
+
64
68
if ( ! _ . has ( workPeriodPayment , 'days' ) || workPeriodPayment . days > 0 ) {
65
69
if ( _ . isNil ( correspondingResourceBooking . memberRate ) ) {
66
70
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
83
87
workPeriodPayment . days = _ . defaultTo ( workPeriodPayment . days , maxPossibleDays )
84
88
workPeriodPayment . amount = _ . round ( workPeriodPayment . memberRate * workPeriodPayment . days / 5 , 2 )
85
89
}
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
+
89
91
workPeriodPayment . id = uuid . v4 ( )
90
92
workPeriodPayment . status = WorkPeriodPaymentStatus . SCHEDULED
91
93
workPeriodPayment . createdBy = createdBy
0 commit comments