allTurnovers bqry calcTotals calcSaldo qry account = do
  cr :# c <- creditTurnovers qry account
  dt :# _ <- debitTurnovers  qry account
  opts <- gets lsConfig
  incomingSaldo <- case qStart qry of
                     Nothing    -> return $ BalanceInfo (Just 0) (Just 0)
                     Just start -> runAtomically $ getBalanceInfoAt (Just start) bqry account
  outgoingSaldo <- runAtomically $ getBalanceInfoAt (qEnd qry) bqry account
  return $ TRecord {
             trCredit = cr :# c,
             trDebit  = dt :# c,
             trIncSaldo = balanceInfoSetCurrency incomingSaldo c,
             trOutSaldo = balanceInfoSetCurrency outgoingSaldo c,
             trTotals = if calcTotals
                          then Just $ (cr + dt) :# c
                          else Nothing ,
             trSaldo  = if calcSaldo
                          then Just $ if isAssets opts (getAttrs account)
                                        then (dt - cr) :# c
                                        else (cr - dt) :# c
                          else Nothing }
allTurnovers bqry calcTotals calcSaldo qry account = do
  cr :# c <- creditTurnovers qry account
  dt :# _ <- debitTurnovers  qry account
  opts <- gets lsConfig
  incomingSaldo <- case qStart qry of
                     Nothing    -> return $ BalanceInfo (Just 0) (Just 0)
                     Just start -> runAtomically $ getBalanceInfoAt (Just start) bqry account
  outgoingSaldo <- runAtomically $ getBalanceInfoAt (qEnd qry) bqry account
  return $ TRecord {
             trCredit = cr :# c,
             trDebit  = dt :# c,
             trIncSaldo = balanceInfoSetCurrency incomingSaldo c,
             trOutSaldo = balanceInfoSetCurrency outgoingSaldo c,
             trTotals = if calcTotals
                          then Just $ (cr + dt) :# c
                          else Nothing ,
             trSaldo  = if calcSaldo
                          then Just $ if isAssets opts (getAttrs account)
                                        then (dt - cr) :# c
                                        else (cr - dt) :# c
                          else Nothing }
allTurnovers bqry calcTotals calcSaldo qry account = do
  cr :# c <- creditTurnovers qry account
  dt :# _ <- debitTurnovers  qry account
  opts <- gets lsConfig
  incomingSaldo <- case qStart qry of
                     Nothing    -> return $ BalanceInfo (Just 0) (Just 0)
                     Just start -> runAtomically $ getBalanceInfoAt (Just start) bqry account
  outgoingSaldo <- runAtomically $ getBalanceInfoAt (qEnd qry) bqry account
  return $ TRecord {
             trCredit = cr :# c,
             trDebit  = dt :# c,
             trIncSaldo = balanceInfoSetCurrency incomingSaldo c,
             trOutSaldo = balanceInfoSetCurrency outgoingSaldo c,
             trTotals = if calcTotals
                          then Just $ (cr + dt) :# c
                          else Nothing ,
             trSaldo  = if calcSaldo
                          then Just $ if isAssets opts (getAttrs account)
                                        then (dt - cr) :# c
                                        else (cr - dt) :# c
                          else Nothing }