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: Add pay in advance logic into date service #385

Merged
merged 4 commits into from
Aug 18, 2022

Conversation

vincent-pochet
Copy link
Collaborator

@vincent-pochet vincent-pochet commented Aug 16, 2022

Context

We want to add the ability to choose to bill users at subscription date anniversary and not only on a calendar basis.

Description

Following the previous introduction of a date service (see #360) to extract logic to compute fees boundaries, few changes are required in order to use this service in the Fees::ChargeService and Fees::SubscriptionService:

  • from_date and to_date should return the boundaries of the coming subscription period when plan is payed in advance. It will kill the need for boundaries rewriting in Fees::SubscriptionService (see https://github.com/getlago/lago-api/blob/main/app/services/fees/subscription_service.rb#L152 for example)
  • Since to_date is also used for charge, a charges_to_date is required as charges are always billed on the passed billing period no matter if the plan is payed in advance or in arrear
  • a single_day_price method is required to compute the cost of a single subscription day based on the plan cost and the period duration
  • a current_usage flag is required to return forecast dates for charges boundaries

@vincent-pochet vincent-pochet added Feature Add a new feature to the app Subscription Relation to the Subscriptions Invoice Related to Invoices labels Aug 16, 2022
@vincent-pochet vincent-pochet self-assigned this Aug 16, 2022
@vincent-pochet vincent-pochet changed the title Feature/date service pay in advance feat: Add pay in advance logic into date service Aug 16, 2022
Copy link
Collaborator

@rsempe rsempe left a comment

Choose a reason for hiding this comment

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

LGTM 🚀 - The QA part will be fun! 😄

@vincent-pochet vincent-pochet merged commit f7c6876 into main Aug 18, 2022
@vincent-pochet vincent-pochet deleted the feature/date-service-pay-in-advance branch August 18, 2022 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Add a new feature to the app Invoice Related to Invoices Subscription Relation to the Subscriptions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants