Safe Haskell | Safe-Infered |
---|
Penny quantities. A quantity is simply a count (possibly fractional) of something. It does not have a commodity or a Debit/Credit.
Documentation
A quantity is always greater than zero. Various odd questions happen if quantities can be zero. For instance, what if you have a debit whose quantity is zero? Does it require a balancing credit that is also zero? And how can you have a debit of zero anyway?
I can imagine situations where a quantity of zero might be useful; for instance maybe you want to specifically indicate that a particular posting in a transaction did not happen (for instance, that a paycheck deduction did not take place). I think the better way to handle that though would be through an addition to DebitCredit - maybe DebitCredit/Zero. Barring the addition of that, though, the best way to indicate a situation such as this would be through transaction memos.
Unwrap a Qty to get the underlying Decimal. This Decimal will always be greater than zero.
partialNewQty :: Decimal -> QtySource
Make a new Qty. This function is partial. It will call error if its argument is less than or equal to zero.
newQty :: Decimal -> Maybe QtySource
Make a new Qty. Returns Nothing if its argument is less than zero.
difference :: Qty -> Qty -> DifferenceSource
Subtract the second Qty from the first.