-
Notifications
You must be signed in to change notification settings - Fork 100
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 new date service to compute bounds for subscription and charge fees #360
Conversation
Just a general thought: Do you think extracting that logic into 3 smaller classes (weekly, monthly and yearly) can be interesting? |
Yeah, good suggestion, it could make it a bit easier to read. Let's try it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a small typo
🚀
39ecc41
to
850285e
Compare
Context
We want to add the ability to choose to bill users at subscription date anniversary and not only on a calendar basis.
Changes
The objective of this pull request is to introduce a new
Subscriptions::DatesService
.This service is responsible for computing all bounds for invoice and related subscription and charge fees.
It exposes few methods:
from_date
: compute the lower bound of an invoicing period based on a provided timestamp and subscriptionto_date
: compute the upper bound of an invoicing period based on a provided timestamp and subscriptioncharges_from_date
: compute the lower bound of an invoicing period for charges based on a provided timestamp and subscription. It allows to handle thebill_charge_monthly
case for yearly plansnext_end_of_period
: compute the next end of period for a given subscription and dateNote: The service is not yet used in invoicing services. This will come with a latter change
Related resources
This PR follows the previous one #352 to update the subscription data model.