1477 - Changes as per review comments
@@ -688,20 +688,19 @@ public class DefaultSubscriptionBaseApiService implements SubscriptionBaseApiSer
addonUtils.isAddonIncluded(baseProduct, addonCurrentPlan) ||
!addonUtils.isAddonAvailable(baseProduct, addonCurrentPlan)) {
- SubscriptionBaseEvent cancelEvent;
- if(cur.getState() == EntitlementState.PENDING) { // Perform AO cancellation using the future start date of ADDON
- cancelEvent = new ApiEventCancel(new ApiEventBuilder()
- .setSubscriptionId(cur.getId())
- .setEffectiveDate(cur.getAlignStartDate())
- .setFromDisk(true));
+ final SubscriptionBaseEvent cancelEvent;
+ final DateTime cancellationDateTime;
+
+ if (effectiveDate.isAfter(cur.getAlignStartDate())) {
+ cancellationDateTime = effectiveDate;
+ } else {
+ cancellationDateTime = cur.getAlignStartDate();
}
- else { // Perform AO cancellation using the effectiveDate of the BP
+
cancelEvent = new ApiEventCancel(new ApiEventBuilder()
.setSubscriptionId(cur.getId())
- .setEffectiveDate(effectiveDate)
+ .setEffectiveDate(cancellationDateTime)
.setFromDisk(true));
- }
-
subscriptionsToBeCancelled.add(cur);
events.add(cancelEvent);
}
