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(invoices): Ability to skip 0 invoices #2462

Merged
merged 6 commits into from
Aug 30, 2024
Merged

Conversation

brunomiguelpinto
Copy link
Contributor

@brunomiguelpinto brunomiguelpinto commented Aug 22, 2024

Context

We currently finalize all invoices, including those with a total amount of $0, leading to unnecessary clutter and potential confusion. To improve flexibility and reduce unnecessary finalizations, organizations will now have the option to decide whether $0 invoices should be finalized or not. This setting can be configured at the organization level, with the option to override it for individual customers.

Description

This PR introduces a new service, TransitionToFinalStatusService, which checks the finalize_zero_amount_invoice setting to decide whether to finalize an invoice or move it to the closed state after checking the customer and organization setting ( if the invoice fees_amount_cents is 0 )

Changes

Organization Setting

Added a new parameter finalize_zero_amount_invoice to the organization settings:

{
  "organization": {
    "finalize_zero_amount_invoice": "false" // default is true
  }
}

Customer Setting

Added a new parameter finalize_zero_amount_invoice to the customer settings to allow overriding the organization-level setting:

{
  "customer": {
    "finalize_zero_amount_invoice": "finalize" // default value is "inherit"
  }
}

Possible Values:

  • inherit: (Default) The setting follows the organization-level configuration.
  • finalize: Invoices are issued and finalized, even if the total amount is $0.
  • skip: Invoices with a total amount of $0 are not finalized.

TransitionToFinalStatusService

The service checks the finalize_zero_amount_invoice setting to determine whether to finalize an invoice or move it to the closed state after evaluating the customer, organization, and invoice amount.

Invoice State: closed

  • Introduces a closed state for invoices with a total amount of $0.
  • Invoices in this state:
    • Will not be assigned a number.
    • Will not appear in the application.
    • Will only exist in the database.

Service Integration

The new TransitionToFinalStatusService was integrated into various points where invoices are finalized:

  • Invoices::AdvanceChargesService
  • Invoices::CreateOneOffService
  • Invoices::CreatePayInAdvanceChargeService
  • Invoices::RefreshDraftAndFinalizeService
  • Invoices::SubscriptionService

@brunomiguelpinto brunomiguelpinto marked this pull request as draft August 22, 2024 13:30
@brunomiguelpinto brunomiguelpinto self-assigned this Aug 22, 2024
@brunomiguelpinto brunomiguelpinto added Customer Customer management Organization Related to Organization Invoice Related to Invoices labels Aug 22, 2024
@brunomiguelpinto brunomiguelpinto force-pushed the feat-skip-0-invoices branch 3 times, most recently from 1812509 to 339e425 Compare August 23, 2024 16:07
@brunomiguelpinto brunomiguelpinto marked this pull request as ready for review August 28, 2024 14:41
@brunomiguelpinto brunomiguelpinto changed the title feat: add migrations to the new fields feat(invoices): Aug 28, 2024
@brunomiguelpinto brunomiguelpinto changed the title feat(invoices): feat(invoices): Ability to skip 0 invoices Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Customer Customer management Invoice Related to Invoices Organization Related to Organization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants