def _create_transaction_draft(
         self, draft: types.TransactionDraft) -> types.Transaction:
     return types.Transaction(
         id=str(uuid.uuid4()),
         timestamp=draft.timestamp,
         type=draft.type,
         amount=utils._money_to_typed(draft.amount),
         interaction_id=draft.interaction_id,
         state=draft.state,
     )
 def _create_transaction_draft(
     self, obj: types.TransactionDraft
 ) -> types.Transaction:
     return types.Transaction(
         id=str(uuid.uuid4()),
         timestamp=obj.timestamp,
         type=obj.type,
         amount=obj.amount,
         interaction_id=obj.interaction_id,
         state=obj.state,
     )
 def updater(self, obj, action):
     draft: types.TransactionDraft = getattr(action, "transaction")
     transaction = types.Transaction(
         id=str(uuid.uuid4()),
         timestamp=draft.timestamp,
         type=draft.type,
         amount=utils._money_to_typed(draft.amount),
         interaction_id=draft.interaction_id,
         state=draft.state,
     )
     transaction = schemas.TransactionSchema().dump(transaction)
     if not obj["transactions"]:
         obj["transactions"] = []
     new = copy.deepcopy(obj)
     new["transactions"].append(transaction)
     return new
示例#4
0
 def post_load(self, data, **kwargs):
     return types.Transaction(**data)