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: Expose billing periods with invoice object #295

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lago_python_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
BillableMetricEvaluateExpression as BillableMetricEvaluateExpression,
BillableMetricEvaluateExpressionResponse as BillableMetricEvaluateExpressionResponse,
)
from .billing_period import (
BillingPeriodResponse as BillingPeriodResponse,
BillingPeriodsResponse as BillingPeriodsResponse,
)
from .charge import (
Charge as Charge,
Charges as Charges,
Expand Down
18 changes: 18 additions & 0 deletions lago_python_client/models/billing_period.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import List

from lago_python_client.base_model import BaseResponseModel


class BillingPeriodResponse(BaseResponseModel):
lago_subscription_id: str
external_subscription_id: str
lago_plan_id: str
subscription_from_datetime: str
subscription_to_datetime: str
charges_from_datetime: str
charges_to_datetime: str
invoicing_reason: str


class BillingPeriodsResponse(BaseResponseModel):
__root__: List[BillingPeriodResponse]
2 changes: 2 additions & 0 deletions lago_python_client/models/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from lago_python_client.base_model import BaseModel

from .billing_period import BillingPeriodsResponse
from .credit import CreditsResponse
from .customer import CustomerResponse
from .fee import FeesResponse
Expand Down Expand Up @@ -118,6 +119,7 @@ class InvoiceResponse(BaseResponseModel):

file_url: Optional[str]
customer: Optional[CustomerResponse]
billing_periods: Optional[BillingPeriodsResponse]
subscriptions: Optional[SubscriptionsResponse]
fees: Optional[FeesResponse]
credits: Optional[CreditsResponse]
Expand Down
12 changes: 12 additions & 0 deletions tests/fixtures/invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@
}
]
},
"billing_periods": [
{
"lago_subscription_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_subscription_id": "LAG-EXT-1234",
"lago_plan_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"subscription_from_datetime": "2025-02-00T00:00:00Z",
"subscription_to_datetime": "2025-02-28T23:59:59Z",
"charges_from_datetime": "2025-01-00T00:00:00Z",
"charges_to_datetime": "2025-01-31T23:59:59Z",
"invoicing_reason": "subscription_periodic"
}
],
"subscriptions": [
{
"lago_id": "b7ab2926-1de8-4428-9bcd-779314ac129b",
Expand Down
Loading