Created
January 20, 2018 15:10
-
-
Save StevenXL/913d0532b56c634b794e4aac2e095e67 to your computer and use it in GitHub Desktop.
Sum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calculateReport :: Budget -> [Transaction] -> Report | |
calculateReport budget transactions = | |
Report | |
{ budgetProfit = budgetProfit' | |
, netProfit = netProfit' | |
, difference = netProfit' - budgetProfit' | |
} | |
where | |
budgetProfit' = budgetIncome budget - budgetExpenditure budget | |
netProfit' = getSum (foldMap asProfit transactions) | |
asProfit (Sale m) = pure m | |
asProfit (Purchase m) = pure (negate m) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment