2025-04-12 11:55:18 +02:00
|
|
|
from typing import Literal, Optional, Self
|
|
|
|
from pydantic import BaseModel, ConfigDict, EmailStr, Field, model_validator
|
2025-04-12 14:53:33 +02:00
|
|
|
from pydantic_extra_types.phone_numbers import PhoneNumber
|
2025-04-12 11:55:18 +02:00
|
|
|
|
|
|
|
class FromAccount(BaseModel):
|
|
|
|
"""
|
|
|
|
Fields which can be extracted from account.pdf
|
|
|
|
"""
|
|
|
|
model_config = ConfigDict(validate_assignment=True, str_strip_whitespace=True)
|
|
|
|
|
2025-04-12 15:21:22 +02:00
|
|
|
# Details of the Account and Client
|
2025-04-12 13:38:43 +02:00
|
|
|
account_name: str = Field(min_length=1)
|
|
|
|
account_holder_name: str = Field(min_length=1)
|
|
|
|
account_holder_surname: str = Field(min_length=1)
|
2025-04-12 11:55:18 +02:00
|
|
|
|
|
|
|
@model_validator(mode='after')
|
|
|
|
def check_account_name_is_name_surname(self) -> Self:
|
|
|
|
combined = f"{self.account_holder_name} {self.account_holder_surname}"
|
|
|
|
if combined != self.account_name:
|
|
|
|
raise ValueError(f'Account name is not name + surname: {self.account_name} != {combined}')
|
|
|
|
return self
|
|
|
|
|
2025-04-12 13:38:43 +02:00
|
|
|
passport_number: str = Field(min_length=5)
|
2025-04-12 11:55:18 +02:00
|
|
|
|
|
|
|
reference_currency: Literal["CHF", "EUR", "USD", "Other"]
|
|
|
|
other_currency: Optional[str] = None
|
|
|
|
|
2025-04-12 15:21:22 +02:00
|
|
|
# Delivery of Communication
|
2025-04-12 13:38:43 +02:00
|
|
|
building_number: str = Field(min_length=1)
|
|
|
|
street_name: str = Field(min_length=1)
|
|
|
|
postal_code: str = Field(min_length=1)
|
|
|
|
city: str = Field(min_length=1)
|
|
|
|
country: str = Field(min_length=1)
|
2025-04-12 11:55:18 +02:00
|
|
|
|
2025-04-12 15:21:22 +02:00
|
|
|
# Application for e-banking
|
|
|
|
ebanking_name: str = Field(min_length=1)
|
|
|
|
@model_validator(mode='after')
|
|
|
|
def check_account_name_ebanking_name(self) -> Self:
|
|
|
|
if self.ebanking_name != self.account_name:
|
|
|
|
raise ValueError(f'Ebanking name is different from account name')
|
|
|
|
return self
|
2025-04-12 14:53:33 +02:00
|
|
|
phone_number: PhoneNumber
|
2025-04-12 11:55:18 +02:00
|
|
|
email: EmailStr
|