| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Haspara.Accounting.Event
Description
This module provides definitions for economic events.
/Note: The concept is not YET REA-compatible although we want to achieve it at some point/.
Synopsis
- data Event o (s :: Nat)
- = EventDecrement Day o (UnsignedQuantity s)
- | EventIncrement Day o (UnsignedQuantity s)
- eventDate :: KnownNat s => Event o s -> Day
- eventObject :: KnownNat s => Event o s -> o
- negateEvent :: KnownNat s => Event o s -> Event o s
- mkEvent :: MonadError String m => KnownNat s => Day -> o -> Quantity s -> m (Event o s)
Documentation
data Event o (s :: Nat) Source #
Type encoding of an economic increment/decrement event.
The event explicitly carries the date and quantity information along with a parameterized, arbitrary object providing the source of the event.
>>>:set -XDataKinds>>>let date = read "2021-01-01">>>let oid = 1 :: Int>>>let qty = $$(Refined.refineTH 42) :: UnsignedQuantity 2>>>let event = EventDecrement date oid qty>>>let json = Data.Aeson.encode event>>>json"{\"qty\":42.0,\"type\":\"DECREMENT\",\"obj\":1,\"date\":\"2021-01-01\"}">>>Data.Aeson.decode @(Event Int 2) jsonJust (EventDecrement 2021-01-01 1 (Refined 42.00))>>>Data.Aeson.decode json == Just eventTrue
Constructors
| EventDecrement Day o (UnsignedQuantity s) | |
| EventIncrement Day o (UnsignedQuantity s) |
Instances
| Eq o => Eq (Event o s) Source # | |
| Ord o => Ord (Event o s) Source # | |
| (Show o, KnownNat s) => Show (Event o s) Source # | |
| (ToJSON o, KnownNat s) => ToJSON (Event o s) Source # | |
Defined in Haspara.Accounting.Event | |
| (FromJSON o, KnownNat s) => FromJSON (Event o s) Source # | |
eventObject :: KnownNat s => Event o s -> o Source #
Returns the source object of the event.