Make depreciation functions more flexible.
[?]
Jan 17, 2015, 7:51 PM
SLL7262CJUE7TZDDZZXFROHCVVDA527WA4PHXCKEGZUJF2EN5MQACDependencies
- [2]
7XN3I3QJAdd 'loggedIntervals' endpoint. - [3]
TLQ72DSJLenses, sqlite-simple - [4]
2OIPAQCBMerge branch 'master' of github.com:nuttycom/ananke - [5]
RSEB2NFGReplacing Snap with Scotty. - [6]
Y35QCWYWMinor improvement in WorkIndex type to eliminate duplicated information. - [7]
P6NR2CGXBeginning of implementation of depreciation. - [8]
A2J7B4SCInitial impl of depreciation function. - [9]
7DBNV3GVInitial, stack-based impl of time log event reduction. - [10]
NVOCQVASInitial failing tests. - [11]
GKGVYBZGAdded JSON serialization to TimeLog - [12]
64C6AWH6Rename Ananke -> Quixotic, project reboot. - [13]
4QX5E5ACInitial compilation of payouts function succeeds. - [14]
N4NDAZYTInitial implementation of payouts.
Change contents
- replacement in lib/Quixotic/TimeLog.hs at line 16
, Depreciation(..), DepF - edit in lib/Quixotic/TimeLog.hs at line 62
type Payouts = Map BtcAddr Rational - edit in lib/Quixotic/TimeLog.hs at line 64
type Payouts = Map BtcAddr Rationaltype NDT = NominalDiffTime - edit in lib/Quixotic/TimeLog.hs at line 65
type NDT = NominalDiffTime - replacement in lib/Quixotic/TimeLog.hs at line 72
newtype Depreciation = Depreciation { depf :: NDT -> Rational }type DepF = UTCTime -> Interval -> NDT - replacement in lib/Quixotic/TimeLog.hs at line 79
payouts :: Depreciation -> UTCTime -> WorkIndex -> Payoutspayouts :: DepF -> UTCTime -> WorkIndex -> Payouts - replacement in lib/Quixotic/TimeLog.hs at line 90[3.1022]→[3.1373:1561](∅→∅),[3.1223]→[3.599:600](∅→∅),[3.1561]→[3.599:600](∅→∅),[3.599]→[3.599:600](∅→∅),[3.600]→[3.1562:1892](∅→∅)
workCredit :: (Functor f, Foldable f) => Depreciation -> UTCTime -> f Interval -> NDTworkCredit dep ptime ivals = F.foldl' (+) (fromInteger 0) $ fmap (depreciateInterval dep ptime) ivals{-|Compute the depreciated difftime for a single Interval value.-}depreciateInterval :: Depreciation -> UTCTime -> Interval -> NDTdepreciateInterval dep ptime ival =let depreciation :: Rationaldepreciation = depf dep $ diffUTCTime ptime (end $ ival)in fromRational $ depreciation * (toRational . ilen $ ival)workCredit :: (Functor f, Foldable f) => DepF -> UTCTime -> f Interval -> NDTworkCredit depf ptime ivals =F.foldl' (+) (fromInteger 0) $ fmap (depf ptime) ivals - replacement in lib/Quixotic/TimeLog.hs at line 119
linearDepreciation :: Months -> Months -> DepreciationlinearDepreciation undepPeriod depPeriod =linearDepreciation :: Months -> Months -> DepFlinearDepreciation undepPeriod depPeriod = \ptime ival -> - replacement in lib/Quixotic/TimeLog.hs at line 127
depf' :: NominalDiffTime -> Rationaldepf' dt = if dt < monthsLength undepPeriodthen 1depPct :: NominalDiffTime -> RationaldepPct dt =if dt < monthsLength undepPeriod then 1 - replacement in lib/Quixotic/TimeLog.hs at line 131
in Depreciation depf'[3.586]depreciation = depPct $ diffUTCTime ptime (end $ ival)in fromRational $ depreciation * (toRational . ilen $ ival)