@@ -157,6 +157,7 @@ defmodule AlgoraWeb.Org.TransactionsLive do
157157 defp calculate_balance ( transactions ) do
158158 transactions
159159 |> Enum . filter ( & ( & 1 . status == :succeeded ) )
160+ |> Enum . filter ( & ( ! & 1 . reversed_at ) )
160161 |> Enum . reduce ( Money . new! ( 0 , :USD ) , fn transaction , acc ->
161162 case transaction . type do
162163 type when type in [ :charge , :deposit , :credit ] ->
@@ -172,7 +173,9 @@ defmodule AlgoraWeb.Org.TransactionsLive do
172173 end
173174
174175 defp calculate_volume ( transactions ) do
175- Enum . reduce ( transactions , Money . new! ( 0 , :USD ) , fn transaction , acc ->
176+ transactions
177+ |> Enum . filter ( & ( ! & 1 . reversed_at ) )
178+ |> Enum . reduce ( Money . new! ( 0 , :USD ) , fn transaction , acc ->
176179 case transaction . type do
177180 type when type in [ :charge , :credit ] -> Money . add! ( acc , transaction . net_amount )
178181 _ -> acc
@@ -254,7 +257,12 @@ defmodule AlgoraWeb.Org.TransactionsLive do
254257 </ thead >
255258 < tbody class = "divide-y divide-border " >
256259 <%= for transaction <- @ transactions do %>
257- < tr class = "hover:bg-muted/50 " >
260+ < tr class = {
261+ classes ( [
262+ "hover:bg-muted/50" ,
263+ if ( transaction . reversed_at , do: "opacity-25" )
264+ ] )
265+ } >
258266 < td class = "whitespace-nowrap px-6 py-4 text-sm " >
259267 { Util . timestamp ( transaction . inserted_at , @ current_org . timezone ) }
260268 </ td >
@@ -486,6 +494,8 @@ defmodule AlgoraWeb.Org.TransactionsLive do
486494 end
487495 end
488496
497+ defp description ( % { reversed_at: reversed_at } ) when not is_nil ( reversed_at ) , do: "Refunded"
498+
489499 defp description ( % { type: :charge , status: :requires_capture } ) , do: "Authorization"
490500
491501 defp description ( % { type: type , tip_id: tip_id } ) when type in [ :debit , :credit ] and not is_nil ( tip_id ) , do: "Tip payment"
0 commit comments