aboutsummaryrefslogtreecommitdiff
path: root/cmd/Main/Output.hs
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2017-06-24 13:36:19 +0300
committerIgor Pashev <pashev.igor@gmail.com>2017-06-24 13:44:42 +0300
commitebe8cba9837872de3dd611d6cd615425c51fefec (patch)
tree776af0f6361d5727f65143b9d8066b85a180c2b2 /cmd/Main/Output.hs
parent2ed435c73d0bc80a6b0d9d16a9fd0e9a0b464ed2 (diff)
downloadmolodivo-ebe8cba9837872de3dd611d6cd615425c51fefec.tar.gz
Support many bills
Diffstat (limited to 'cmd/Main/Output.hs')
-rw-r--r--cmd/Main/Output.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/cmd/Main/Output.hs b/cmd/Main/Output.hs
new file mode 100644
index 0000000..1024ecd
--- /dev/null
+++ b/cmd/Main/Output.hs
@@ -0,0 +1,30 @@
+{-
+This modules describes output data for the command line utlity.
+-}
+{-# LANGUAGE DeriveAnyClass #-}
+{-# LANGUAGE DeriveGeneric #-}
+
+module Main.Output
+ ( BillBudget(..)
+ , zipBills
+ ) where
+
+import GHC.Generics (Generic)
+
+import Data.Aeson (ToJSON)
+
+import Malodivo.Budget (DistrictFunds)
+import Malodivo.Types.Bill (Bill)
+
+import Main.DistrictInfo (DistrictInfo, df2di)
+
+-- | This is output type. It describes contribution of each district into a bill.
+data BillBudget = BillBudget
+ { bill :: Bill
+ , districts :: [DistrictInfo]
+ } deriving (Generic, ToJSON)
+
+zipBills :: [Bill] -> [DistrictFunds] -> [BillBudget]
+zipBills = zipWith zipper
+ where
+ zipper b df = BillBudget {bill = b, districts = df2di df}