Skip to content

Commit fd671f7

Browse files
committed
include all claims when calculating total paid
1 parent 744269b commit fd671f7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/algora_web/live/claim_live.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ defmodule AlgoraWeb.ClaimLive do
3131
|> Enum.map(& &1.amount)
3232
|> Enum.reduce(Money.zero(:USD, no_fraction_if_integer: true), &Money.add!(&1, &2))
3333

34+
credits =
35+
claims
36+
|> Enum.flat_map(& &1.transactions)
37+
|> Enum.filter(&(&1.type == :credit and &1.status == :succeeded))
38+
3439
total_paid =
35-
primary_claim.transactions
36-
|> Enum.filter(&(&1.type == :debit and &1.status == :succeeded))
40+
credits
3741
|> Enum.map(& &1.net_amount)
3842
|> Enum.reduce(Money.zero(:USD, no_fraction_if_integer: true), &Money.add!(&1, &2))
3943

0 commit comments

Comments
 (0)