Skip to content

[Bug]: Incorrect Billing-To Date calculation for quarterly contracts starting late in the month with "Align to End of Month" setting. [SubscriptionBilling] [27.0] #5089

@djukicmilica

Description

@djukicmilica

Describe the issue

Backport of #4401

There is a bug filed to Microsoft under ID 581883 titled:

Incorrect Billing-To Date calculation for quarterly contracts starting late in the month with "Align to End of Month" setting.

The "Align to End of Month" option is intended to adjust the end date of the subscription so that if the subscription starts within the last 3 days of a month, the subscription end date will maintain the same delta from the end of the month, plus one additional day only if the full billing period is being billed.

However, this behavior is not consistent in the system. Below are examples of how the end dates should be calculated for quarterly subscriptions when a full Quarter is being billed:

Start Date Delta to End of Month Calculated End Date Delta to End of Month
27.02.2020 1 day 28.05.2020 2 days
29.03.2020 1 day 28.06.2020 2 days
26.02.2020 2 days 27.05.2020 3 days

Expected behavior

For a contract starting on 27.02.2020, billed quarterly with "Align to End of Month" enabled:

  • When the first billing period is split manually as 27.02.2020–29.02.2020, and the next period starts from 01.03.2020, the system should calculate the Billing To date as 31.05.2020 (i.e., 3 months forward, aligned to the fact that Start of Billing Period has been moved to the first of the month).
  • Instead, the system incorrectly calculates it as 27.06.2020.
  • Manual adjustment of the start date does not produce a correct end date, nor does it correctly calculate the amount.

Steps to reproduce

  1. Set up a Subscription Package with the following line:
    • Partner = Customer
    • Template = Quarterly
    • Invoicing via = Subscription Contract
    • Calculation Base % = 100
    • Billing Base Period = 1M
    • Billing Rhythm = 3M or 1Q
    • Period Calculation = Align to End of Month
    • Initial Term = 12M
    • Subsequent Term = 12M
    • Notice Period = 3M or 1Q
  2. Create an Item and enable the "Subscription Item" option.
  3. Assign the Subscription Package to this Item.
  4. Create a new Subscription and select the created Item.
  5. Create a Customer Subscription Contract.
  6. Fetch the Subscription Lines into the contract.
  7. Set the Subscription Line Start Date to 27.02.2020.
  8. Navigate to Recurring Billing and set:
    • Billing Date = 27.02.2020
    • Billing To Date = 29.02.2020
  9. Run the action "Create Billing Proposal" → A line is created for 27.02.2020–29.02.2020.
  10. Update the Billing Date to 01.03.2020 and leave Billing To Date empty.
  11. Run "Create Billing Proposal" again → A line is created for 01.03.2020–27.06.2020
    • ❌ This is incorrect.
    • ✅ Expected: 01.03.2020–31.05.2020.

Additional context

No response

I will provide a fix for a bug

  • I will provide a fix for a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    ApprovedThe issue is approvedFinanceGitHub request for Finance area

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions