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