Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions unit/models/codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@

"receivedPayment.created": lambda _id, _type, attributes, relationships:
ReceivedPaymentCreatedEvent.from_json_api(_id, _type, attributes, relationships),

"writeOffTransaction": lambda _id, _type, attributes, relationships:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these not getting sent as transaction.created events?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codec resolves any unlisted types as a generic RawUnitObject. We should still be processing it appropriately but I'll add a test in our app to make sure.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so what was happening here? Was there an error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I'm just adding the DTO to be used in some tests mocking the transaction.

WriteOffTransactionDTO.from_json_api(_id, _type, attributes, relationships),
}


Expand Down
12 changes: 12 additions & 0 deletions unit/models/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,18 @@ def from_json_api(_id, _type, attributes, relationships):
return NegativeBalanceCoverageTransactionDTO(
_id, date_utils.to_datetime(attributes["createdAt"]), attributes["amount"], attributes["direction"], attributes["balance"], attributes["summary"], attributes.get("tags"), relationships)

class WriteOffTransactionDTO(BaseTransactionDTO):
def __init__(self, id: str, created_at: datetime, amount: int, direction: str,
balance: int, summary: str, tags: Optional[Dict[str, str]], relationships: Optional[Dict[str, Relationship]]):
BaseTransactionDTO.__init__(self, id, created_at, direction, amount, balance, summary, tags, relationships)
self.type = 'writeOffTransaction'

@staticmethod
def from_json_api(_id, _type, attributes, relationships):
return WriteOffTransactionDTO(
_id, date_utils.to_datetime(attributes["createdAt"]), attributes["amount"], attributes["direction"], attributes["balance"], attributes["summary"], attributes.get("tags"), relationships)


TransactionDTO = Union[OriginatedAchTransactionDTO, ReceivedAchTransactionDTO, ReturnedAchTransactionDTO,
ReturnedReceivedAchTransactionDTO, DishonoredAchTransactionDTO, BookTransactionDTO,
PurchaseTransactionDTO, AtmTransactionDTO, FeeTransactionDTO, CardTransactionDTO,
Expand Down
Loading