#771·lago

[BUG]: Incorrect invoice periods/dates when free trial is extended and crosses into next billing month

Author: bb-nikCreated Jul 29, 2026Updated Jul 30, 2026

Describe the bug When a customer's free trial is extended so that it crosses into a new calendar month, invoice periods and billing dates are calculated incorrectly. Specifically:

Invoices are only created for the period Lago decides to bill, not necessarily reflecting the real (adjusted) trial end date. No invoice is generated for the month in which the free trial rolls over into the next month (a month's invoice is skipped entirely). Lago appears to count the signup date itself as "Day 1" of the trial (start date treated as inclusive), which is inconsistent with how invoice periods are later calculated. After extending a trial (adding extra days), the resulting invoices still use the original trial end date instead of the adjusted one, producing wrong billing periods, wrong invoice generation dates, and wrong prorated amounts.

To Reproduce Steps to reproduce the behavior: Create a subscription on a paid plan (e.g. Pro, $149.00/month) with a free trial, starting Monday, 15 June 2026. Original trial length: 30 days (would end Wednesday, 15 July 2026).

Note the invoice generated at the start of the subscription: Invoice A (LEA-7439-202607-021), $0.00, issued Jul 1, 2026, for period "Jul 1, 2026 to Jul 15, 2026."

Extend the customer's free trial by 11 days (e.g. to work around a custom domain issue), making it a 41-day trial. New trial end/payment date should be Sunday, 26 July 2026.

Observe Invoice B (LEA-7439-202607-046), generated on 15 Jul 2026, for period "Jul 1, 2026 to Jul 15, 2026."

Observe Invoice C (LEA-7439-202607-063), generated on 27 Jul 2026, for period "Jul 15, 2026 to Jul 31, 2026," amount $28.84.

Compare against the expected dates/amounts (see spreadsheet in Screenshots section).

Expected behavior

When a free trial is extended and the new trial end date crosses into the next calendar month, Lago should:

Generate an invoice for each calendar month the trial spans (no skipped months — e.g. June should have its own invoice).

Use the adjusted trial end date (26 July 2026) as the billing/payment date, not the original one (15 July 2026).

Generate Invoice B for the period Jul 1–26, 2026, not Jul 1–15, 2026.

Generate Invoice C on 26 July 2026 (not 27 July), for the period Jul 26–31, 2026 = 6 days inclusive, not Jul 15–31, 2026.

Apply a consistent inclusive/exclusive day-counting convention across both the trial-length calculation and the invoice period calculation (currently the signup date is counted inconsistently between the two). Also indicate that dates are inclusive.

Screenshots

Image

Invoice A, B, and C overview pages, with billing periods circled (Invoice A: LEA-7439-202607-021; Invoice B: LEA-7439-202607-046; Invoice C: LEA-7439-202607-063).

A day-rate reference table for the $149/month Pro plan, showing prorated daily amounts for months with 28–31 days.

A comparison table: "Original Free Trial" (start Mon 15 Jun, 30 days, billing date Wed 15 Jul) vs. "Adjusted Free Trial" (start Mon 15 Jun, 41 days, billing date Sun 26 Jul, end of billing month Fri 31 Jul, 6 days in billing cycle).

Support OS: not applicable (server-side billing/invoicing logic) Browser: not applicable (issue is in invoice generation, not UI rendering) Version: 1.45.2 (self-hosted)

Additional context

Deployment: self-hosted Lago instance.

The core issue seems to be in how Lago recalculates billing/invoice periods after a subscription's trial end date is changed mid-trial — it does not appear to re-derive the invoice schedule from the new trial end date, and instead continues generating invoices anchored to the original (pre-extension) trial end date.

Root cause may also involve an inconsistency in how the trial's day count is calculated (inclusive of the signup date) versus how invoice period boundaries are calculated (which appears to exclude or shift by one day), leading to the one-day discrepancy seen in Invoice C's generation date (27 Jul vs. expected 26 Jul).