Implemented fixtures & Implementing Resource pattern

This commit is contained in:
2025-02-11 22:57:11 +01:00
parent ed6be838fe
commit 171875f915
6 changed files with 224 additions and 39 deletions

View File

@@ -20,14 +20,12 @@ class AccountBaseId(AccountBase):
path: str = Field(index=True)
class AccountRead(AccountBaseId):
opening_date: date = Field()
opening_balance: Decimal = Field(decimal_places=2, default=0)
pass#opening_date: date = Field()
#opening_balance: Decimal = Field(decimal_places=2, default=0)
class BaseAccountWrite(AccountBase):
path: SkipJsonSchema[str] = Field(default="")
family: SkipJsonSchema[str] = Field(default="")
opening_date: date = Field()
opening_balance: Decimal = Field(decimal_places=2, default=0)
class AccountWrite(BaseAccountWrite):
type: Asset | Liability = Field()
@@ -40,6 +38,8 @@ class AccountWrite(BaseAccountWrite):
}
}
})
opening_date: date = Field()
opening_balance: Decimal = Field(decimal_places=2, default=0)
class AccountCreate(AccountWrite):
pass
@@ -52,6 +52,17 @@ class CategoryRead(AccountBaseId):
class CategoryWrite(BaseAccountWrite):
type: CategoryFamily = Field()
parent_account_id: UUID | None = PydField(default=None, json_schema_extra={
"foreign_key": {
"reference": {
"resource": "categories",
"schema": "CategoryRead",
"label": "name"
}
}
})
opening_date: date = date(1970, 1, 1)
opening_balance: Decimal = 0
class CategoryCreate(CategoryWrite):
pass