Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial fix for 1869 #1877

Merged
merged 1 commit into from
Jun 21, 2023
Merged

Initial fix for 1869 #1877

merged 1 commit into from
Jun 21, 2023

Conversation

reshmabidikar
Copy link
Contributor

@reshmabidikar reshmabidikar commented Jun 7, 2023

Initial fix for #1869

@reshmabidikar reshmabidikar marked this pull request as ready for review June 7, 2023 08:33
@@ -744,7 +744,7 @@ private DateTime alignToNextBCDIfRequired(final Plan curPlan, final PlanPhase cu
}

final BillingPeriod billingPeriod = curPlanPhase.getRecurring() != null ? curPlanPhase.getRecurring().getBillingPeriod() : BillingPeriod.NO_BILLING_PERIOD;
final LocalDate resultingLocalDate = BillCycleDayCalculator.alignProposedNextBillCycleDate(originalTransitionDate, bcd, billingPeriod, context);
final LocalDate resultingLocalDate = BillCycleDayCalculator.alignProposedNextBillCycleDate(originalTransitionDate, lastTransitionDate, bcd, billingPeriod, context);
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated to your change, but the name are so confusing. Would it make sense to rename

  • originalTransitionDate -> curTransitionDate # Really the transition time associated with the Plan#EffectiveDateForExistingSubscriptions
  • lastTransitionDate -> prevTransitionDate

And perhaps swap the 2 in the method signature?

@@ -76,22 +76,27 @@ public static LocalDate alignProposedBillCycleDate(final DateTime proposedDate,
}


public static LocalDate alignProposedNextBillCycleDate(final LocalDate proposedDate, final int billingCycleDay, final BillingPeriod billingPeriod) {
public static LocalDate alignProposedNextBillCycleDate(final LocalDate proposedDate, final LocalDate originalDate, final int billingCycleDay, final BillingPeriod billingPeriod) {
Copy link
Member

Choose a reason for hiding this comment

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

Same thing here - rename and swap:

  • originalDate -> prevTransitionDate
  • proposedDate -> curTransitionDate

Copy link
Member

Choose a reason for hiding this comment

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

What about we also change the method name to alignProposedNextBillCycleDate -> alignToNextBillCycleDate. It would take as a first argument prevTransitionDate, and then curTransitionDate with a comment /* date to be aligned */ ?

@@ -172,7 +172,7 @@ public void testAlignProposedNextBillCycleDate1() {
// BCD > proposed day of the month
Copy link
Member

Choose a reason for hiding this comment

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

Could we add a few unit tests here to cover for non monthly billing periods - at least the one matching the scenario?

@sbrossie
Copy link
Member

@reshmabidikar I am merging your PR as-is - optionally we could have another small one to clean things up and address the comments.

@sbrossie sbrossie merged commit 286ebba into killbill:master Jun 21, 2023
11 checks passed
@reshmabidikar reshmabidikar deleted the test-1869 branch June 28, 2023 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants