Fix payment model injection
This commit is contained in:
parent
9b38025f20
commit
72551c44b6
@ -3,7 +3,13 @@
|
|||||||
# from .user_profile import profile_models
|
# from .user_profile import profile_models
|
||||||
#
|
#
|
||||||
# TODO: Add all models to backend_models
|
# TODO: Add all models to backend_models
|
||||||
backend_models = []
|
from backend.services.payment.models import IncomeProfileDoc
|
||||||
|
from backend.services.project.models import ProjectDoc
|
||||||
|
|
||||||
|
backend_models = [
|
||||||
|
IncomeProfileDoc,
|
||||||
|
ProjectDoc
|
||||||
|
]
|
||||||
# backend_models.extend(code_models)
|
# backend_models.extend(code_models)
|
||||||
# backend_models.extend(user_models)
|
# backend_models.extend(user_models)
|
||||||
# backend_models.extend(profile_models)
|
# backend_models.extend(profile_models)
|
||||||
|
|||||||
@ -2,7 +2,10 @@ from typing import List, Dict, Optional
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from time import time
|
from time import time
|
||||||
from beanie import Document
|
from beanie import Document
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, validator
|
||||||
|
|
||||||
|
from decimal import Decimal
|
||||||
|
from bson import Decimal128
|
||||||
|
|
||||||
from backend.services.payment.constants import PaymentGateway
|
from backend.services.payment.constants import PaymentGateway
|
||||||
from backend.infra.payment.constants import MoneyCollectionType, PaymentLocation
|
from backend.infra.payment.constants import MoneyCollectionType, PaymentLocation
|
||||||
@ -32,6 +35,12 @@ class CurrencyAmount(BaseModel):
|
|||||||
amount: Decimal
|
amount: Decimal
|
||||||
currency: str
|
currency: str
|
||||||
|
|
||||||
|
@validator("amount", pre=True)
|
||||||
|
def convert_decimal128(cls, value):
|
||||||
|
if isinstance(value, Decimal128):
|
||||||
|
return value.to_decimal() # Convert MongoDB Decimal128 to Python Decimal
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
class Wallet(BaseModel):
|
class Wallet(BaseModel):
|
||||||
payment_methods: List[PaymentMethod]
|
payment_methods: List[PaymentMethod]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user