Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type UserJournals = Map Username Journal
- type AddT' env m = RWST (FullOptions env) () UserJournals (ErrorT m)
- type AddOptions = FullOptions [Partner]
- type AddT m = AddT' [Partner] m
- data Partner = Partner {}
- partners :: (MonadReader AddOptions m, MonadError Msg m) => m [Partner]
- add :: AddT' [Username] IO ()
- toPartner :: Monad m => User -> AddT' env m Partner
- hello :: Monad m => AddT m String
- mainLoop :: AddT IO ()
- saveAndClear :: Maybe Transaction -> Bool -> (Maybe Transaction, [(Partner, Transaction)]) -> AddT IO ()
- modifyJournal :: MonadState UserJournals m => User -> (Journal -> Journal) -> m ()
- getJournal :: MonadState UserJournals m => User -> m Journal
- clearSecondPosting :: Transaction -> (Transaction, Transaction)
- split :: [EditablePosting] -> ([Posting], [(Partner, NonEmpty Posting, MixedAmount)])
- finishTransaction :: (MonadIO m, MonadReader AddOptions m) => Bool -> Maybe (Transaction, [EditablePosting]) -> m (Maybe Transaction, [(Partner, Transaction)])
- iso8601 :: UTCTime -> String
- myJournalAddTransaction :: FilePath -> User -> [Transaction] -> AddT IO ()
- clearNthPosting :: Int -> Transaction -> Transaction
- data Asserted a = AA {
- aComment :: Comment
- aAssertion :: BalanceAssertion
- aAmount :: a
- type AssertedAmount = Asserted MixedAmount
- fromPosting :: Posting -> Asserted MixedAmount
- showAssertedAmount :: Asserted MixedAmount -> Text
- sugTrans :: AddT IO (AssertedAmount, Maybe Transaction)
- data Choice
- choose :: [String] -> IO Choice
- menup :: Int -> Parser Choice
- stripP
- myEd :: EditorConf (AddT IO) EditablePosting Transaction
- mainPrompt :: (ListLike m item, IsString m) => m
- quiet :: Monad m => a -> m (Maybe a)
- clearTrans :: Zipper EditablePosting -> Zipper EditablePosting
- nextNotFirst :: EditablePosting -> EditablePosting
- balanceTransactionIfRequired :: Transaction -> Either String Transaction
- data Balancing = B {}
- balanceRequirement :: MonadError String m => [Posting] -> m Balancing
- checkDone :: LState EditablePosting Transaction -> AddT IO (Maybe (LState EditablePosting Transaction))
- askDescription :: Maybe Text -> IO Text
- askDate :: Maybe Day -> IO (Day, Text)
- dateandcodep :: Parsec Void Text (SmartDate, Text)
- myAskAccount :: User -> Maybe AccountName -> Maybe String -> Either Text Text -> AddT IO AccountName
- askAmount :: Maybe AssertedAmount -> Text -> Maybe Text -> AddT IO AssertedAmount
- parseAmount :: Journal -> Text -> Either (ParseError Char Void) AssertedAmount
- _amountp2
- nosymbolamountp2 :: Monad m => JournalParser m Amount
- getDefaultCommodityAndStyle2 :: Journal -> Maybe (CommoditySymbol, AmountStyle)
- askPercent :: IO Decimal
- data EditablePosting = EditablePosting {}
- type EditablePostings = Zipper EditablePosting
- editablePosting
- userZippers
- addPosting :: AccountName -> Maybe AssertedAmount -> EditablePosting -> EditablePosting
- setMissing :: EditablePosting -> EditablePosting
- removeAmount :: EditablePosting -> EditablePosting
- jumpTo :: Int -> Zipper a -> Zipper a
- editDate :: LState a Transaction -> AddT IO (LState a Transaction)
- editDescription :: LState a Transaction -> AddT IO (LState a Transaction)
- editCurAmount :: EditablePostings -> AddT IO EditablePostings
- modifyCurAmount :: (AssertedAmount -> AssertedAmount -> AssertedAmount) -> Bool -> EditablePostings -> AddT IO EditablePostings
- replaceMissing :: MixedAmount -> MixedAmount
- defNumSuggestedAccounts :: Int
- suggestedPostingsSingleUser :: Monad m => Text -> Zipper (Either User Partner) -> AddT m [EditablePosting]
- suggestedPostings :: MonadIO m => AccountName -> Maybe AssertedAmount -> AddT m (NonEmpty EditablePosting)
- next :: EditablePosting -> EditablePosting
- roundP :: EditablePosting -> EditablePosting
- assignOpenBalance :: Decimal -> EditablePostings -> EditablePostings
- showEditablePosting :: EditablePostings -> Text
- getUser :: Either User Partner -> User
- totalBalance :: [EditablePosting] -> MixedAmount
- showAmount2 :: Amount -> Text
- showMixedAmount2 :: MixedAmount -> Text
- addNewPosting :: Bool -> EditablePostings -> AddT IO EditablePostings
- moveToNextEmpty :: EditablePostings -> EditablePostings
- data Align
- fillLeft
- fillRight
- fillCenter
- renderTable :: ([Align], [Align], [Text]) -> [[Text]] -> Maybe [Text] -> Text
Types
type AddT' env m = RWST (FullOptions env) () UserJournals (ErrorT m) Source #
type AddOptions = FullOptions [Partner] Source #
Partner | |
|
partners :: (MonadReader AddOptions m, MonadError Msg m) => m [Partner] Source #
Extract partner information from the env and throw errors if there are any readPartner :: (MonadReader AddOptions m, MonadError Msg m) => (Partner -> a) -> m (Maybe a) readPartner f = reader $ fmap f . oEnv
Entry point
:: Maybe Transaction | matching transaction for clearing |
-> Bool | clear the matching transactions |
-> (Maybe Transaction, [(Partner, Transaction)]) | transactioons to be saved: ((user's,other's), |
-> AddT IO () |
Saves transaction into the designated ledgers files of each user,
and clears the transaction tht was matched (conditional on a Bool
argument)
modifyJournal :: MonadState UserJournals m => User -> (Journal -> Journal) -> m () Source #
getJournal :: MonadState UserJournals m => User -> m Journal Source #
split :: [EditablePosting] -> ([Posting], [(Partner, NonEmpty Posting, MixedAmount)]) Source #
Split EditablePosting
s in User's Postings and (Partner,
Postings, Open Balance)
:: (MonadIO m, MonadReader AddOptions m) | |
=> Bool | require balanced transactions |
-> Maybe (Transaction, [EditablePosting]) | the transaction and postings to be combined |
-> m (Maybe Transaction, [(Partner, Transaction)]) | (user's, partners') transactions |
generate the main and possibly the other users' transactions
myJournalAddTransaction :: FilePath -> User -> [Transaction] -> AddT IO () Source #
add transaction to ledger file and return new ledger
clearNthPosting :: Int -> Transaction -> Transaction Source #
Transaction suggestions
AA | |
|
type AssertedAmount = Asserted MixedAmount Source #
fromPosting :: Posting -> Asserted MixedAmount Source #
sugTrans :: AddT IO (AssertedAmount, Maybe Transaction) Source #
Ask an amount, and return transactions matching the entered amount
stripP
Main editing loop
myEd :: EditorConf (AddT IO) EditablePosting Transaction Source #
combines everything into an EditorConf
mainPrompt :: (ListLike m item, IsString m) => m Source #
clearTrans :: Zipper EditablePosting -> Zipper EditablePosting Source #
clear all postings
nextNotFirst :: EditablePosting -> EditablePosting Source #
change user of current posting, but not for the first posting ReferenceA
balanceRequirement :: MonadError String m => [Posting] -> m Balancing Source #
check, if the transaction should be passed through
balanceTransaction
to infer missing amounts
checkDone :: LState EditablePosting Transaction -> AddT IO (Maybe (LState EditablePosting Transaction)) Source #
Try to balance the transactions and present the final transactions
Asking (with completion)
myAskAccount :: User -> Maybe AccountName -> Maybe String -> Either Text Text -> AddT IO AccountName Source #
:: Maybe AssertedAmount | default value, if "" is entered |
-> Text | prompt |
-> Maybe Text | initial |
-> AddT IO AssertedAmount |
parseAmount :: Journal -> Text -> Either (ParseError Char Void) AssertedAmount Source #
_amountp2
nosymbolamountp2 :: Monad m => JournalParser m Amount Source #
askPercent :: IO Decimal Source #
Posting and Suggestions
data EditablePosting Source #
Type holding suggested or temporary postings
type EditablePostings = Zipper EditablePosting Source #
editablePosting
userZippers
addPosting :: AccountName -> Maybe AssertedAmount -> EditablePosting -> EditablePosting Source #
generate and add new Posting
to EditablePosting
editDate :: LState a Transaction -> AddT IO (LState a Transaction) Source #
editDescription :: LState a Transaction -> AddT IO (LState a Transaction) Source #
editCurAmount :: EditablePostings -> AddT IO EditablePostings Source #
edit the amount of the selected posting
:: (AssertedAmount -> AssertedAmount -> AssertedAmount) | oldAmout -> enteredAmount -> newAmount |
-> Bool | Show old amound |
-> EditablePostings | |
-> AddT IO EditablePostings |
modfiy current amount by asking for a new amount, that is combined with the old to get a new amount (e.g. with (+))
defNumSuggestedAccounts :: Int Source #
Hardcoded default number of suggested accounts
suggestedPostingsSingleUser :: Monad m => Text -> Zipper (Either User Partner) -> AddT m [EditablePosting] Source #
suggestedPostings :: MonadIO m => AccountName -> Maybe AssertedAmount -> AddT m (NonEmpty EditablePosting) Source #
retrieve a number of suggested contra postings for a given account, sort frequency of that contra account for the given account.
TODO incorporate old behavior: duplicate each posting for both users, but only if the other user's account is present in the suggestions.
next :: EditablePosting -> EditablePosting Source #
change posting's user to the next user
assignOpenBalance :: Decimal -> EditablePostings -> EditablePostings Source #
assign the Transaction'
s open balance to an empty EditablePosting
totalBalance :: [EditablePosting] -> MixedAmount Source #
showAmount2 :: Amount -> Text Source #
showMixedAmount2 :: MixedAmount -> Text Source #
:: Bool | for next partner |
-> EditablePostings | |
-> AddT IO EditablePostings |
ask for new account (display old as default) and use existing posting, if same account without a posting/amount already exists or append.
moveToNextEmpty :: EditablePostings -> EditablePostings Source #
move the focus to the next empty posting
Pretty Table Printer
fillLeft
fillRight
fillCenter