From c3ab976407fc5fd8fd3f4cbbcf801b935ff7728c Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Mon, 29 May 2023 17:14:01 -0400 Subject: [PATCH] ENH check accounts in multiallocations --- lib/Internal/Budget.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Internal/Budget.hs b/lib/Internal/Budget.hs index 6e59e9c..8414b53 100644 --- a/lib/Internal/Budget.hs +++ b/lib/Internal/Budget.hs @@ -40,7 +40,7 @@ insertBudget , bgtInterval } = whenHash CTBudget b () $ \key -> do - intAllos <- combineError3 pre_ tax_ post_ (,,) + (intAllos, _) <- combineError intAlloRes acntRes (,) let res1 = mapErrors (insertIncome key bgtLabel intAllos bgtInterval) bgtIncomes let res2 = expandTransfers key bgtLabel bgtInterval bgtTransfers txs <- combineError (concat <$> res1) res2 (++) @@ -48,10 +48,16 @@ insertBudget shadow <- liftExcept $ addShadowTransfers m bgtShadowTransfers txs void $ mapErrors insertBudgetTx $ balanceTransfers $ txs ++ shadow where + acntRes = mapErrors isNotIncomeAcnt alloAcnts + intAlloRes = combineError3 pre_ tax_ post_ (,,) pre_ = sortAllos bgtPretax tax_ = sortAllos bgtTax post_ = sortAllos bgtPosttax - sortAllos = liftExcept . combineErrors . fmap sortAllo + sortAllos = liftExcept . mapErrors sortAllo + alloAcnts = + (alloAcnt <$> bgtPretax) + ++ (alloAcnt <$> bgtTax) + ++ (alloAcnt <$> bgtPosttax) balanceTransfers :: [UnbalancedTransfer] -> [BalancedTransfer] balanceTransfers = snd . L.mapAccumR go M.empty . reverse . L.sortOn ftWhen