project_transactions.hamlet 2.08 KB
Newer Older
1
<div .row>
2 3 4 5
    <div .col-sm-3>
        Account balance:
    <div .col-sm-5>
        #{show (accountBalance account)}
6

7 8 9 10 11 12 13 14 15 16 17
$if null transaction_groups
    <p> no transactions recorded
$else
    <table>
        $forall (maybe_payday, transactions) <- transaction_groups
            $maybe Entity _ payday <- maybe_payday
                <tr>
                    <td>
                        ^{renderTime $ paydayDate payday} ago
                    <td .colspan=3>
                        payday yielding #{sum $ map transactionAmount $ map entityVal transactions}
18

19 20 21 22 23 24
            $nothing
                $forall (Entity _ transaction) <- transactions
                    $with is_credit <- transactionCredit transaction == Just (projectAccount project)
                        <tr>
                            <td>
                                ^{renderTime (transactionTs transaction)} ago
25

26 27 28 29 30
                            <td>
                                $if is_credit
                                    #{show (transactionAmount transaction)}
                                $else
                                    (#{show (transactionAmount transaction)})
31

32 33 34 35 36
                            <td>
                                $maybe other_account_id <- getOtherAccount transaction
                                    $case M.lookup other_account_id account_map
                                        $of Just (Right user)
                                            <a href=@{UserR $ entityKey user}>
37
                                                #{userDisplayName user}
38

39 40 41
                                        $of Just (Left project)
                                            <a href=@{ProjectR $ projectHandle $ entityVal project}>
                                                #{projectName $ entityVal project}
42

43
                                        $of Nothing
44
                                                unaffiliated account ##{either (error . T.unpack) id $ fromPersistValueText $ toPersistValue other_account_id}
45

46 47
                            <td>
                                #{transactionReason transaction}