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

feat(fees): Invoice non-invoiceable fees at the end of the period #2171

Merged
merged 16 commits into from
Jul 4, 2024

Conversation

julienbourdeau
Copy link
Contributor

@julienbourdeau julienbourdeau commented Jun 12, 2024

Overview

This pull request introduces a new feature to handle fees paid in advance that are not invoiceable. The goal is to provide clear visibility for end users on what they have paid during a specific billing period and to ensure all such fees are grouped into invoices at the end of each billing period.

Changes Introduced

The code in this PR is currently commented out because we are planning to merge another PR that will allow this code to be toggled based on a setting. Once the subsequent PR is merged, this code will be enabled accordingly.

Feel free to adjust the wording to better fit your style or to provide additional context if necessary.

  • New Job Implementation: Introduced BillNonInvoiceableFeesJob to handle the periodic billing of non-invoiceable fees, ensuring they are invoiced at the end of each billing period.
  • New Invoice Type: Added a new invoice type advance_charges to categorize and manage the fees paid in advance that were previously not included in invoices.
  • Service for Advance Charges: Created Invoices::AdvanceChargesService to generate invoices for non-invoiceable fees, ensuring all relevant fees within the billing period are grouped and included.
  • Integration in Billing Workflows: Integrated the new job and service into existing billing workflows within Subscriptions::BillingService, Subscriptions::CreateService, and Subscriptions::TerminateService to ensure seamless operation and timely invoicing.

New Invoice template

CleanShot 2024-06-27 at 11 13 56@2x

@julienbourdeau julienbourdeau self-assigned this Jun 12, 2024
@julienbourdeau julienbourdeau force-pushed the feat-regroup-fees branch 5 times, most recently from a9ff010 to de6b963 Compare June 19, 2024 08:51
@julienbourdeau julienbourdeau changed the base branch from main to feat-fees-part-1 June 19, 2024 08:51
julienbourdeau added a commit that referenced this pull request Jun 24, 2024
…o invoice yet (#2197)

## Description

When [non-invoiceable fees were
introduced](#1069), we only
allowed change of `payment_status` if the fee was attached to a
non-invoiceable charge.

What we really meant is _"the fee is standalone, not attached to an
invoice"_. Now we're working on attaching the non-invoiceable fees to an
invoice at the end of the period. See
#2171

I'm changing the condition so the fee can be updated, only if it's not
attached to any invoice yet.
@julienbourdeau julienbourdeau changed the title feat(fees): Regroup non-invoiceable fees into invoices at the end of the period feat(fees): Invoice non-invoiceable fees at the end of the period Jun 24, 2024
Base automatically changed from feat-fees-part-1 to main June 26, 2024 07:47
@brunomiguelpinto brunomiguelpinto self-assigned this Jun 26, 2024
@brunomiguelpinto brunomiguelpinto added Invoice Related to Invoices Fee labels Jun 26, 2024
@julienbourdeau julienbourdeau force-pushed the feat-regroup-fees branch 2 times, most recently from 9b298c0 to 1d3474d Compare June 27, 2024 08:46
@julienbourdeau julienbourdeau marked this pull request as ready for review June 27, 2024 08:47
@brunomiguelpinto brunomiguelpinto force-pushed the feat-regroup-fees branch 2 times, most recently from 5af195f to 107e52f Compare June 28, 2024 14:02
@julienbourdeau julienbourdeau merged commit 94fd48a into main Jul 4, 2024
6 checks passed
@julienbourdeau julienbourdeau deleted the feat-regroup-fees branch July 4, 2024 08:34
julienbourdeau added a commit that referenced this pull request Jul 4, 2024
## Context

When your charge is pay in advance but not invoiceable, the fees are
created but not attached to any invoice.
This adds an options so at the end of the period, you get a new invoice
showing all PAID fees. unpaid fees are ignored.

See also #2171

## Description

We're dropping the idea of `invoice_strategy` because it turned out to
be a bad idea. Instead we're adding `regroup_paid_fees` attribute that
takes only one value today `invoice`.
ancorcruz pushed a commit that referenced this pull request Jul 7, 2024
)

## Overview

This pull request introduces a new feature to handle fees paid in
advance that are not invoiceable. The goal is to provide clear
visibility for end users on what they have paid during a specific
billing period and to ensure all such fees are grouped into invoices at
the end of each billing period.

## Changes Introduced

> 
> The code in this PR is currently commented out because we are planning
to merge another PR that will allow this code to be toggled based on a
setting. Once the subsequent PR is merged, this code will be enabled
accordingly.

Feel free to adjust the wording to better fit your style or to provide
additional context if necessary.

- **New Job Implementation**: Introduced `BillNonInvoiceableFeesJob` to
handle the periodic billing of non-invoiceable fees, ensuring they are
invoiced at the end of each billing period.
- **New Invoice Type**: Added a new invoice type `advance_charges` to
categorize and manage the fees paid in advance that were previously not
included in invoices.
- **Service for Advance Charges**: Created
`Invoices::AdvanceChargesService` to generate invoices for
non-invoiceable fees, ensuring all relevant fees within the billing
period are grouped and included.
- **Integration in Billing Workflows**: Integrated the new job and
service into existing billing workflows within
`Subscriptions::BillingService`, `Subscriptions::CreateService`, and
`Subscriptions::TerminateService` to ensure seamless operation and
timely invoicing.
   
## New Invoice template
   
![CleanShot 2024-06-27 at 11 13
56@2x](https://github.com/getlago/lago-api/assets/1525636/dd14317d-ced2-4e46-8c2e-47a853bf75e9)

---------

Co-authored-by: Miguel Pinto <darkymiguel@gmail.com>
ancorcruz pushed a commit that referenced this pull request Jul 7, 2024
When your charge is pay in advance but not invoiceable, the fees are
created but not attached to any invoice.
This adds an options so at the end of the period, you get a new invoice
showing all PAID fees. unpaid fees are ignored.

See also #2171

We're dropping the idea of `invoice_strategy` because it turned out to
be a bad idea. Instead we're adding `regroup_paid_fees` attribute that
takes only one value today `invoice`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fee Invoice Related to Invoices
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants