packages feed

bookkeeping 0.2.1.4 → 0.3.0.0

raw patch · 2 files changed

+62/−21 lines, 2 filesdep +semigroupsPVP ok

version bump matches the API change (PVP)

Dependencies added: semigroups

API changes (from Hackage documentation)

- Business.Bookkeeping: Amount :: Int -> Amount
- Business.Bookkeeping: CategoryName :: Text -> CategoryName
- Business.Bookkeeping: Date :: Int -> Date
- Business.Bookkeeping: Description :: Text -> Description
- Business.Bookkeeping: Month :: Int -> Month
- Business.Bookkeeping: SubDescription :: Text -> SubDescription
- Business.Bookkeeping: Year :: Integer -> Year
- Business.Bookkeeping: [unAmount] :: Amount -> Int
- Business.Bookkeeping: [unCategoryName] :: CategoryName -> Text
- Business.Bookkeeping: [unDate] :: Date -> Int
- Business.Bookkeeping: [unDescription] :: Description -> Text
- Business.Bookkeeping: [unMonth] :: Month -> Int
- Business.Bookkeeping: [unSubDescription] :: SubDescription -> Text
- Business.Bookkeeping: [unYear] :: Year -> Integer
- Business.Bookkeeping: newtype Amount
- Business.Bookkeeping: newtype CategoryName
- Business.Bookkeeping: newtype Date
- Business.Bookkeeping: newtype Description
- Business.Bookkeeping: newtype Month
- Business.Bookkeeping: newtype SubDescription
- Business.Bookkeeping: newtype Year
+ Business.Bookkeeping: categoryName :: Text -> Maybe Text -> CategoryName
+ Business.Bookkeeping: data Amount
+ Business.Bookkeeping: data CategoryName
+ Business.Bookkeeping: data Date
+ Business.Bookkeeping: data Description
+ Business.Bookkeeping: data Month
+ Business.Bookkeeping: data SubDescription
+ Business.Bookkeeping: data Year
+ Business.Bookkeeping: instance Data.Semigroup.Semigroup Business.Bookkeeping.Description
+ Business.Bookkeeping: instance Data.Semigroup.Semigroup Business.Bookkeeping.SubDescription

Files

bookkeeping.cabal view
@@ -1,5 +1,5 @@ name:                bookkeeping-version:             0.2.1.4+version:             0.3.0.0 synopsis:            A module for bookkeeping by double entry. description:     A module for bookkeeping by double entry. This module provides a way to do bookkeeping programmatically.@@ -26,6 +26,9 @@   default-extensions:  OverloadedStrings                      , RecordWildCards   other-extensions:    GeneralizedNewtypeDeriving+  ghc-options:         -Wcompat -Wall+  if !impl(ghc >= 8.0)+    build-depends: semigroups == 0.18.*  test-suite bookkeeping-test   type:                exitcode-stdio-1.0
src/Business/Bookkeeping.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE Strict #-} {-# LANGUAGE StrictData #-}+{-# LANGUAGE CPP #-}  {- | Module      :  Business.Bookkeeping@@ -26,6 +27,7 @@   , month   , activity   , dateTrans+  , categoryName    -- * Converters   , runTransactions@@ -36,14 +38,14 @@   , MonthTransactions   , DateTransactions   , Transaction(..)-  , Year(..)-  , Month(..)-  , Date(..)-  , Description(..)-  , SubDescription(..)-  , Amount(..)+  , Year+  , Month+  , Date+  , Description+  , SubDescription+  , Amount   , Category(..)-  , CategoryName(..)+  , CategoryName   , CategoryType(..)   , DebitCategory(..)   , CreditCategory(..)@@ -53,6 +55,7 @@ import qualified Data.DList as DList import Data.DList (DList) import Data.Monoid ((<>))+import qualified Data.Semigroup as Sem import Data.String (IsString(..)) import Data.Text (Text) import qualified Data.Text as T@@ -162,14 +165,24 @@         [ "tDay: " <> (T.pack . show) tDay         , "tDescription: " <> unDescription tDescription         , "tSubDescription: " <> unSubDescription tSubDescription-        , "tDebit: " <> (unCategoryName . cName . unDebitCategory) tDebit <>-          " (" <>-          (T.pack . show . cType . unDebitCategory) tDebit <>-          ")"-        , "tCredit: " <> (unCategoryName . cName . unCreditCategory) tCredit <>-          " (" <>-          (T.pack . show . cType . unCreditCategory) tCredit <>-          ")"+        , T.concat+          [ "tDebit: "+          , (unCategoryName . cName . unDebitCategory) tDebit+          , maybe "" (" - " <>) $+            (unCategorySubName . cName . unDebitCategory) tDebit+          , " ("+          , (T.pack . show . cType . unDebitCategory) tDebit+          , ")"+          ]+        , T.concat+          [ "tCredit: "+          , (unCategoryName . cName . unCreditCategory) tCredit+          , maybe "" (" - " <>) $+            (unCategorySubName . cName . unCreditCategory) tCredit+          , " ("+          , (T.pack . show . cType . unCreditCategory) tCredit+          , ")"+          ]         , "tAmount: " <> (T.pack . show . unAmount) tAmount         ] @@ -220,9 +233,14 @@ instance IsString Description where   fromString = Description . fromString +instance Sem.Semigroup Description where+  Description a <> Description b = Description $ mappend a b+ instance Monoid Description where   mempty = Description mempty-  mappend (Description a) (Description b) = Description $ mappend a b+#if !(MIN_VERSION_base(4,11,0))+  mappend = (Sem.<>)+#endif  newtype SubDescription = SubDescription   { unSubDescription :: Text@@ -231,9 +249,14 @@ instance IsString SubDescription where   fromString = SubDescription . fromString +instance Sem.Semigroup SubDescription where+  SubDescription a <> SubDescription b = SubDescription $ mappend a b+ instance Monoid SubDescription where   mempty = SubDescription mempty-  mappend (SubDescription a) (SubDescription b) = SubDescription $ mappend a b+#if !(MIN_VERSION_base(4,11,0))+  mappend = (Sem.<>)+#endif  newtype Amount = Amount   { unAmount :: Int@@ -254,12 +277,27 @@   , cType :: CategoryType   } deriving (Show, Read, Ord, Eq) -newtype CategoryName = CategoryName-  { unCategoryName :: Text+data CategoryName = CategoryName+  { name :: Text+  , sub :: Maybe Text   } deriving (Show, Read, Ord, Eq) ++unCategoryName :: CategoryName -> Text+unCategoryName CategoryName {..} = name++unCategorySubName :: CategoryName -> Maybe Text+unCategorySubName CategoryName {..} = sub++categoryName :: Text -> Maybe Text -> CategoryName+categoryName = CategoryName+ instance IsString CategoryName where-  fromString = CategoryName . fromString+  fromString str =+    CategoryName+      { name = fromString str+      , sub = Nothing+      }  data CategoryType   = Assets