Skip to content

Commit

Permalink
overdue: Remove joda Period from OverdueState (and use KB duration)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrossie committed Apr 6, 2017
1 parent e58d9f5 commit 66a68f8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Expand Up @@ -64,7 +64,7 @@ public OverdueStateConfigJson(final OverdueState input) {
this.subscriptionCancellationPolicy = input.getOverdueCancellationPolicy(); this.subscriptionCancellationPolicy = input.getOverdueCancellationPolicy();
Integer tmpAutoReevaluationIntervalDays = null; Integer tmpAutoReevaluationIntervalDays = null;
try { try {
tmpAutoReevaluationIntervalDays = input.getAutoReevaluationInterval().getDays(); tmpAutoReevaluationIntervalDays = input.getAutoReevaluationInterval().toJodaPeriod().getDays();
} catch (final OverdueApiException e) { } catch (final OverdueApiException e) {
} finally { } finally {
this.autoReevaluationIntervalDays = tmpAutoReevaluationIntervalDays; this.autoReevaluationIntervalDays = tmpAutoReevaluationIntervalDays;
Expand Down
Expand Up @@ -64,7 +64,7 @@ public OverdueStateJson(final OverdueState overdueState, final PaymentConfig pay


Period reevaluationIntervalPeriod = null; Period reevaluationIntervalPeriod = null;
try { try {
reevaluationIntervalPeriod = overdueState.getAutoReevaluationInterval(); reevaluationIntervalPeriod = overdueState.getAutoReevaluationInterval().toJodaPeriod();
} catch (final OverdueApiException ignored) { } catch (final OverdueApiException ignored) {
} }


Expand Down
Expand Up @@ -189,7 +189,7 @@ private Period getReevaluationInterval(final OverdueStateSet overdueStateSet, fi
if (nextOverdueState.isClearState()) { if (nextOverdueState.isClearState()) {
return overdueStateSet.getInitialReevaluationInterval(); return overdueStateSet.getInitialReevaluationInterval();
} else { } else {
return nextOverdueState.getAutoReevaluationInterval(); return nextOverdueState.getAutoReevaluationInterval().toJodaPeriod();
} }
} catch (final OverdueApiException e) { } catch (final OverdueApiException e) {
if (e.getCode() == ErrorCode.OVERDUE_NO_REEVALUATION_INTERVAL.getCode()) { if (e.getCode() == ErrorCode.OVERDUE_NO_REEVALUATION_INTERVAL.getCode()) {
Expand Down
Expand Up @@ -26,6 +26,7 @@


import org.joda.time.Period; import org.joda.time.Period;
import org.killbill.billing.ErrorCode; import org.killbill.billing.ErrorCode;
import org.killbill.billing.catalog.api.Duration;
import org.killbill.billing.catalog.api.TimeUnit; import org.killbill.billing.catalog.api.TimeUnit;
import org.killbill.billing.overdue.ConditionEvaluation; import org.killbill.billing.overdue.ConditionEvaluation;
import org.killbill.billing.overdue.api.EmailNotification; import org.killbill.billing.overdue.api.EmailNotification;
Expand Down Expand Up @@ -112,11 +113,11 @@ public OverdueCancellationPolicy getOverdueCancellationPolicy() {
} }


@Override @Override
public Period getAutoReevaluationInterval() throws OverdueApiException { public Duration getAutoReevaluationInterval() throws OverdueApiException {
if (autoReevaluationInterval == null || autoReevaluationInterval.getUnit() == TimeUnit.UNLIMITED || autoReevaluationInterval.getNumber() == 0) { if (autoReevaluationInterval == null || autoReevaluationInterval.getUnit() == TimeUnit.UNLIMITED || autoReevaluationInterval.getNumber() == 0) {
throw new OverdueApiException(ErrorCode.OVERDUE_NO_REEVALUATION_INTERVAL, name); throw new OverdueApiException(ErrorCode.OVERDUE_NO_REEVALUATION_INTERVAL, name);
} }
return autoReevaluationInterval.toJodaPeriod(); return autoReevaluationInterval;
} }


public void setAutoReevaluationInterval(final DefaultDuration autoReevaluationInterval) { public void setAutoReevaluationInterval(final DefaultDuration autoReevaluationInterval) {
Expand Down

1 comment on commit 66a68f8

@pierre
Copy link
Member

@pierre pierre commented on 66a68f8 Apr 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.