|
26 | 26 | from typing import Optional, Set |
27 | 27 | from typing_extensions import Annotated, Self, NotRequired, TypedDict |
28 | 28 |
|
| 29 | +from codat_bankfeeds.types import OptionalNullable, UNSET, UNSET_SENTINEL |
29 | 30 | class BankTransaction(BaseModel): |
30 | 31 |
|
31 | 32 | @model_serializer(mode="wrap") |
32 | 33 | def _serialize_drop_none(self, handler): |
33 | 34 | serialized = handler(self) |
34 | | - return {k: v for k, v in serialized.items() if v is not None} |
| 35 | + _nullable = {'counterparty', 'description', 'reconciled', 'reference', 'transactionType', 'transaction_type'} |
| 36 | + return { |
| 37 | + k: v for k, v in serialized.items() |
| 38 | + if v != UNSET_SENTINEL and (v is not None or k in _nullable) |
| 39 | + } |
35 | 40 | """ |
36 | 41 | BankTransaction |
37 | 42 | """ # noqa: E501 |
38 | 43 | id: Optional[str] = Field(default=None, description="Identifier for the bank account transaction, unique for the company in the accounting software.") |
39 | 44 | date_: Optional[str] = Field(default=None, description="In Codat's data model, dates and times are represented using the <a class=\"external\" href=\"https://en.wikipedia.org/wiki/ISO_8601\" target=\"_blank\">ISO 8601 standard</a>. Date and time fields are formatted as strings; for example: ``` 2023-08-22T10:21:00 2023-08-22 ``` When pushing bank transaction data to Codat, the date is treated as a local date. This means: - The date/time is used exactly as provided, without any timezone conversion. - If a timezone offset is included (e.g., `2023-08-22T10:21:00-05:00`), the offset will be ignored and only the local date/time portion will be used. - We recommend providing dates without a timezone suffix for clarity (e.g., `2023-08-22T10:21:00` rather than `2023-08-22T10:21:00Z`).", alias="date") |
40 | | - description: Optional[str] = Field(default=None, description="Description of the bank transaction.") |
41 | | - counterparty: Optional[str] = Field(default=None, description="The giving or receiving party such as a person or organization.") |
42 | | - reference: Optional[str] = Field(default=None, description="An optional reference to the bank transaction.") |
43 | | - reconciled: Optional[bool] = Field(default=None, description="`True` if the bank transaction has been [reconciled](https://www.xero.com/uk/guides/what-is-bank-reconciliation/) in the accounting software.") |
| 45 | + description: OptionalNullable[str] = Field(default=UNSET, description="Description of the bank transaction.") |
| 46 | + counterparty: OptionalNullable[str] = Field(default=UNSET, description="The giving or receiving party such as a person or organization.") |
| 47 | + reference: OptionalNullable[str] = Field(default=UNSET, description="An optional reference to the bank transaction.") |
| 48 | + reconciled: OptionalNullable[bool] = Field(default=UNSET, description="`True` if the bank transaction has been [reconciled](https://www.xero.com/uk/guides/what-is-bank-reconciliation/) in the accounting software.") |
44 | 49 | amount: Annotated[Optional[Decimal], BeforeValidator(validate_decimal), PlainSerializer(serialize_decimal(False))] = Field(default=None, description="The amount transacted in the bank transaction.") |
45 | 50 | balance: Annotated[Optional[Decimal], BeforeValidator(validate_decimal), PlainSerializer(serialize_decimal(False))] = Field(default=None, description="The remaining balance in the account with ID `accountId`. This field is optional for QuickBooks Online but is required for Xero, Sage, NetSuite, Exact, and FreeAgent.") |
46 | | - transaction_type: Optional[BankTransactionType] = Field(default=None, description="Type of transaction for the bank statement line.", alias="transactionType") |
| 51 | + transaction_type: OptionalNullable[BankTransactionType] = Field(default=UNSET, description="Type of transaction for the bank statement line.", alias="transactionType") |
47 | 52 | __properties: ClassVar[List[str]] = ["id", "date", "description", "counterparty", "reference", "reconciled", "amount", "balance", "transactionType"] |
48 | 53 |
|
49 | 54 | @field_validator('transaction_type') |
|
0 commit comments