File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -536,6 +536,30 @@ async def get_store_history(
536536 f"Store { store .id } should never have transfers" ,
537537 )
538538
539+ # We add refunds
540+ refunds = await cruds_myeclpay .get_refunds_by_wallet_id (
541+ wallet_id = store .wallet_id ,
542+ db = db ,
543+ )
544+ for refund in refunds :
545+ if refund .debited_wallet_id == store .wallet_id :
546+ transaction_type = HistoryType .REFUND_DEBITED
547+ other_wallet_info = refund .credited_wallet
548+ else :
549+ transaction_type = HistoryType .REFUND_CREDITED
550+ other_wallet_info = refund .debited_wallet
551+
552+ history .append (
553+ schemas_myeclpay .History (
554+ id = refund .id ,
555+ type = transaction_type ,
556+ other_wallet_name = other_wallet_info .owner_name or "Unknown" ,
557+ total = refund .total ,
558+ creation = refund .creation ,
559+ status = TransactionStatus .CONFIRMED ,
560+ ),
561+ )
562+
539563 return history
540564
541565
@@ -1553,10 +1577,10 @@ async def get_user_wallet_history(
15531577 )
15541578 for refund in refunds :
15551579 if refund .debited_wallet_id == user_payment .wallet_id :
1556- transaction_type = HistoryType .GIVEN
1580+ transaction_type = HistoryType .REFUND_DEBITED
15571581 other_wallet_info = refund .credited_wallet
15581582 else :
1559- transaction_type = HistoryType .RECEIVED
1583+ transaction_type = HistoryType .REFUND_CREDITED
15601584 other_wallet_info = refund .debited_wallet
15611585
15621586 history .append (
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ class HistoryType(str, Enum):
2323 TRANSFER = "transfer"
2424 RECEIVED = "received"
2525 GIVEN = "given"
26+ REFUND_CREDITED = "refund_credited"
27+ REFUND_DEBITED = "refund_debited"
2628
2729
2830class TransactionStatus (str , Enum ):
You can’t perform that action at this time.
0 commit comments