Add first revenue date to project payout computation.

[?]
Jan 31, 2021, 11:49 PM
XXJFUZOVELM3KIPRU6C2NHB3YQ3B3A3GGF2YYBTYJGPU3PR2OV4AC

Dependencies

  • [2] W3PIWHDK Fix logged hours display error.
  • [3] PBD7LZYQ Postgres & auth are beginning to function.
  • [4] UWMGUJOW Autoformat sources.
  • [5] 7KZP4RHZ Switch from Data.Time to Data.Thyme
  • [6] 4QX5E5AC Initial compilation of payouts function succeeds.
  • [7] HMDM3B55 Implement core of payments/billing infrastructure.
  • [8] QMRKFEPG Refactor QDB to use a free monad algebra instead.
  • [9] 4354Y4PE Add endpoint to list project contributors.
  • [10] 7DBNV3GV Initial, stack-based impl of time log event reduction.
  • [11] TLQ72DSJ Lenses, sqlite-simple
  • [12] 2XQD6KKK Add invitation logic and clean up DBProg error handling.
  • [13] 4R7XIYK3 Switch from ClassyPrelude to Relude
  • [14] EFSXYZPO Autoformat everything with brittany.
  • [15] DZ7G36NC Allow first-revenue cutoff for depreciation.
  • [16] MU6WOCCJ Update auctions to permit zcash as a funding currency.
  • [17] NEDDHXUK Reformat via stylish-haskell
  • [18] IR75ZMX3 Return actual events for interval ends, not just timestamps.
  • [19] HALRDT2F Added initial auction create route.
  • [20] X3ES7NUA Fine. I'll use ormolu. At least it doesn't break the code.
  • [21] CI4OPKQM Add payouts spec.
  • [22] M4PWY5RU Preliminary work to add support for Zcash payments.
  • [23] 5DRIWGLU Improving TimeLog specs
  • [24] NVOCQVAS Initial failing tests.
  • [25] N4NDAZYT Initial implementation of payouts.
  • [26] DXIGERDT Change order of Docker build to avoid rebuilding the universe.
  • [27] SLL7262C Make depreciation functions more flexible.
  • [28] U7YAT2ZK Add error reporting to signup form.
  • [29] RKY3XCSI Get the correct contributor data.
  • [*] KEP5WUFJ Convert project to stack-based build.
  • [*] B6HWAPDP Modularize & update to recent haskoin.
  • [*] 2WOOGXDH Use dbmigrations to manage database state.

Change contents

  • replacement in lib/Aftok/Database/PostgreSQL/Projects.hs at line 34
    [3.48044][3.48044:48054]()
    depf,
    [3.48044]
    [3.48054]
    depRules,
  • edit in lib/Aftok/Database/PostgreSQL/Projects.hs at line 48
    [3.48248]
    [3.48248]
    DepreciationRules(..),
    depf
  • replacement in lib/Aftok/Database/PostgreSQL/Projects.hs at line 67
    [3.48730][3.48730:48785]()
    <*> (unSerDepFunction <$> fieldWith fromJSONField)
    [3.48730]
    [3.48785]
    <*> (
    DepreciationRules
    <$> (unSerDepFunction <$> fieldWith fromJSONField)
    <*> (fmap C.toThyme <$> field)
    )
  • replacement in lib/Aftok/Database/PostgreSQL/Projects.hs at line 91
    [3.49316][3.49316:49361]()
    toJSON $ p ^. depf . to SerDepFunction
    [3.49316]
    [3.49361]
    toJSON $ p ^. depRules . depf . to SerDepFunction
  • replacement in lib/Aftok/Database/PostgreSQL/Projects.hs at line 103
    [3.49605][3.49605:49714]()
    [sql| SELECT project_name, inception_date, initiator_id, depreciation_fn FROM projects WHERE id = ? |]
    [3.49605]
    [3.49714]
    [sql| SELECT project_name, inception_date, initiator_id, depreciation_fn, first_revenue_date
    FROM projects WHERE id = ? |]
  • replacement in lib/Aftok/Database/PostgreSQL/Projects.hs at line 112
    [3.49935][3.49935:50019]()
    p.id, p.project_name, p.inception_date, p.initiator_id, p.depreciation_fn
    [3.49935]
    [3.50019]
    p.id, p.project_name, p.inception_date, p.initiator_id, p.depreciation_fn, p.first_revenue_date
  • replacement in lib/Aftok/Payments/Util.hs at line 18
    [3.80035][3.80035:80063]()
    import Aftok.Project (depf)
    [3.80035]
    [3.80063]
    import Aftok.Project (depRules)
  • replacement in lib/Aftok/Payments/Util.hs at line 37
    [3.80612][3.80612:80674]()
    pure $ TL.payouts (TL.toDepF $ project' ^. depf) ptime widx
    [3.80612]
    [3.80674]
    pure $ TL.payouts (TL.toDepF $ project' ^. depRules) ptime widx
  • replacement in lib/Aftok/Project.hs at line 25
    [3.49549][3.49549:49587]()
    _depf :: DepreciationFunction
    [3.49549]
    [3.49587]
    _depRules :: DepreciationRules
  • edit in lib/Aftok/TimeLog.hs at line 20
    [3.22356]
    [3.22356]
    DepreciationRules(..),
  • replacement in lib/Aftok/TimeLog.hs at line 139
    [3.327][3.327:397]()
    type DepF = Maybe C.UTCTime -> C.UTCTime -> Interval C.UTCTime -> NDT
    [3.327]
    [3.397]
    type DepF = C.UTCTime -> Interval C.UTCTime -> NDT
  • replacement in lib/Aftok/TimeLog.hs at line 141
    [3.398][3.9395:9434](),[3.2354][3.9395:9434](),[3.9434][3.12222:12317]()
    toDepF :: DepreciationFunction -> DepF
    toDepF (LinearDepreciation undepLength depLength) =
    linearDepreciation undepLength depLength
    [3.398]
    [3.399]
    toDepF :: DepreciationRules -> DepF
    toDepF (DepreciationRules (LinearDepreciation undepLength depLength) firstRevenue) =
    linearDepreciation firstRevenue undepLength depLength
  • edit in lib/Aftok/TimeLog.hs at line 151
    [3.562]
    [3.562]
    -- | The date of first revenue, if applicable
    Maybe C.UTCTime ->
  • replacement in lib/Aftok/TimeLog.hs at line 159
    [3.796][3.796:835]()
    linearDepreciation undepDays depDays =
    [3.796]
    [3.835]
    linearDepreciation firstRevenue undepDays depDays =
  • replacement in lib/Aftok/TimeLog.hs at line 170
    [3.1289][3.1289:1328]()
    in \firstRevenue payoutDate ival ->
    [3.1289]
    [3.1328]
    in \payoutDate ival ->
  • replacement in lib/Aftok/TimeLog.hs at line 183
    [2.190][2.190:294]()
    let intervalCredit ival = (Sum . ilen &&& Sum . depf Nothing payoutDate) $ fmap (view eventTime) ival
    [2.190]
    [3.1793]
    let intervalCredit ival = (Sum . ilen &&& Sum . depf payoutDate) $ fmap (view eventTime) ival
  • edit in lib/Aftok/Types.hs at line 65
    [32.33998]
    data DepreciationRules = DepreciationRules
    { _depf :: DepreciationFunction
    , _firstRevenue :: Maybe C.UTCTime
    }
    makeLenses ''DepreciationRules
  • file addition: 2021-01-31_23-40-41_project_first_revenue.txt (----------)
    [33.1]
    Description: (Describe migration here.)
    Created: 2021-01-31 23:40:52.022174268 UTC
    Depends: 2016-10-13_05-36-55_user-event-log
    Apply: |
    alter table projects add column first_revenue_date timestamp with time zone;
  • replacement in server/Aftok/Snaplet/Projects.hs at line 88
    [3.53725][3.8871:8935](),[3.64295][3.8871:8935](),[3.8871][3.8871:8935]()
    snapEval . createProject $ Project (cpn cp) t uid (cpdepf cp)
    [3.64295]
    [3.3442]
    snapEval . createProject $ Project (cpn cp) t uid (DepreciationRules (cpdepf cp) Nothing)
  • replacement in server/Aftok/Snaplet/Projects.hs at line 113
    [3.25680][3.25680:25736]()
    let p = payouts (toDepF $ project ^. depf) ptime widx
    [3.25680]
    [3.25736]
    let p = payouts (toDepF $ project ^. depRules) ptime widx
  • replacement in server/Aftok/Snaplet/Projects.hs at line 149
    [3.26895][3.26895:26950]()
    pure $ payouts (toDepF $ project ^. depf) ptime widx
    [3.26895]
    [3.8936]
    pure $ payouts (toDepF $ project ^. depRules) ptime widx
  • replacement in server/Aftok/Snaplet/Projects.hs at line 224
    [3.27363][3.27363:27402]()
    "depf" .= depfToJSON (p ^. depf)
    [3.27363]
    [3.27402]
    "depf" .= depfToJSON (p ^. depRules . depf)