Skip to content

feat(multientities): Support for invoice custom sections for billing entities #315

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

Merged
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 @@ -65,6 +65,10 @@
InvoiceFee as InvoiceFee,
)
from .invoice_item import InvoiceItemResponse as InvoiceItemResponse
from .invoice_custom_section import (
InvoiceCustomSectionResponse as InvoiceCustomSectionResponse,
InvoiceCustomSectionsResponseList as InvoiceCustomSectionsResponseList,
)
from .minimum_commitment import (
MinimumCommitment as MinimumCommitment,
MinimumCommitmentResponse as MinimumCommitmentResponse,
Expand Down
6 changes: 5 additions & 1 deletion lago_python_client/models/billing_entity.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import Optional, List
from datetime import datetime

from ..base_model import BaseModel, BaseResponseModel
from .tax import TaxesResponse
from datetime import datetime
from .invoice_custom_section import InvoiceCustomSectionsResponseList


class BillingEntityBillingConfiguration(BaseModel):
Expand Down Expand Up @@ -60,6 +62,7 @@ class BillingEntityUpdate(BaseModel):
tax_codes: Optional[List[str]]
email_settings: Optional[List[str]]
billing_configuration: Optional[BillingEntityBillingConfiguration]
invoice_custom_section_codes: Optional[List[str]]


class BillingEntityResponse(BaseResponseModel):
Expand Down Expand Up @@ -92,5 +95,6 @@ class BillingEntityResponse(BaseResponseModel):
invoice_grace_period: Optional[int]
email_settings: Optional[List[str]]
taxes: Optional[TaxesResponse]
selected_invoice_custom_sections: Optional[InvoiceCustomSectionsResponseList]
created_at: datetime
updated_at: datetime
16 changes: 1 addition & 15 deletions lago_python_client/models/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from ..base_model import BaseResponseModel

from .tax import TaxesResponse
from .invoice_custom_section import InvoiceCustomSectionsResponseList


class CustomerBillingConfiguration(BaseModel):
Expand Down Expand Up @@ -75,21 +76,6 @@ class MetadataResponseList(BaseModel):
__root__: List[MetadataResponse]


class InvoiceCustomSection(BaseModel):
lago_id: Optional[str]
code: Optional[str]
name: Optional[str]
description: Optional[str]
details: Optional[str]
display_name: Optional[str]
applied_to_organization: Optional[bool]
created_at: Optional[str]


class InvoiceCustomSectionsResponseList(BaseModel):
__root__: List[InvoiceCustomSection]


class Customer(BaseModel):
external_id: str
address_line1: Optional[str]
Expand Down
17 changes: 17 additions & 0 deletions lago_python_client/models/invoice_custom_section.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from typing import List, Optional

from ..base_model import BaseResponseModel


class InvoiceCustomSectionResponse(BaseResponseModel):
lago_id: Optional[str]
code: Optional[str]
name: Optional[str]
description: Optional[str]
details: Optional[str]
display_name: Optional[str]
applied_to_organization: Optional[bool] # Deprecated


class InvoiceCustomSectionsResponseList(BaseResponseModel):
__root__: List[InvoiceCustomSectionResponse]
10 changes: 10 additions & 0 deletions tests/fixtures/billing_entity.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
"created_at": "2022-04-29T08:59:51Z"
}
],
"selected_invoice_custom_sections": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "custom_section_name",
"code": "custom_section_code",
"description": "custom_section_description",
"details": "custom_section_details",
"display_name": "custom_section_display_name"
}
],
"email_settings": [
"invoice.finalized",
"payment_receipt.created"
Expand Down
28 changes: 0 additions & 28 deletions tests/fixtures/billing_entity_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@
"invoice_grace_period": 3,
"document_locale": "en",
"tax_identification_number": "TAX123456",
"taxes": [
{
"lago_id": "b7ab2926-1de8-4428-9bcd-779314ac129b",
"name": "tax_name",
"code": "tax_code",
"rate": 15.0,
"description": "tax_desc",
"created_at": "2022-04-29T08:59:51Z"
}
],
"email_settings": [
"invoice.finalized",
"payment_receipt.created"
Expand Down Expand Up @@ -70,24 +60,6 @@
"invoice_grace_period": 3,
"document_locale": "fr",
"tax_identification_number": "TAX654321",
"taxes": [
{
"lago_id": "b7ab2926-1de8-4428-9bcd-779314ac129b",
"name": "tax_name",
"code": "tax_code",
"rate": 15.0,
"description": "tax_desc",
"created_at": "2022-04-29T08:59:51Z"
},
{
"lago_id": "986212f2-25dd-431c-a3cf-421588b40489",
"name": "tax_name_2",
"code": "tax_code_2",
"rate": 27.5,
"description": "tax_description_2",
"created_at": "2022-04-29T08:59:51Z"
}
],
"email_settings": [
"invoice.finalized"
],
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/customer.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@
"applied_to_organization": false,
"created_at": "2022-04-29T08:59:51Z"
}
],
"applicable_invoice_custom_sections": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "custom_section_name",
"code": "custom_section_code",
"description": "custom_section_description",
"details": "custom_section_details",
"display_name": "custom_section_display_name"
}
]
}
}
1 change: 1 addition & 0 deletions tests/test_billing_entity_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def update_billing_entity_input():
invoice_grace_period=5,
document_locale="fr",
),
invoice_custom_section_codes=["custom_section_1", "custom_section_2"],
)


Expand Down
1 change: 1 addition & 0 deletions tests/test_customer_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def test_valid_create_customers_request(httpx_mock: HTTPXMock):
assert response.shipping_address.state == "XZ"
assert response.integration_customers.__root__[0].external_customer_id == "test-12345"
assert response.integration_customers.__root__[0].type == "netsuite"
assert response.applicable_invoice_custom_sections.__root__[0].code == "custom_section_code"
assert response.metadata.__root__[0].lago_id == "12345"
assert response.metadata.__root__[0].key == "key"
assert response.metadata.__root__[0].value == "value"
Expand Down