mafm / ledger.fs

Simple command-line, double-entry accounting in F#. Excel and text output.
MIT License
7 stars 2 forks source link

Multi-Entity Support #3

Closed ChernayaKoshka closed 7 years ago

ChernayaKoshka commented 7 years ago

@mafm Could you define precisely what you mean by Multi-Entity support? What kind of formatting are we looking at here? I would love to implement it, I would just like some clarification on the desired outcome. From my understanding, the kind of format/style we're looking at is [Entity]:[Account]:[Sub Account1].... In addition, each entity's accounts would be completely separate from the others. Is this accurate? I'd love to hop right on it

mafm commented 7 years ago

Yep, that's what I had in mind.

Would suggest that separator between entity and account should differ from separator used between account and sub-account, so syntax makes it clear what's an entity and what's the account.

For example:

Entity/Account:SubAccount1.SubSubAccount

A transaction could include postings for multiple entities. The postings in a transaction should balance for each entity mentioned in the transaction.

Example transaction:

2017-09-17 A lent $100 to B
    A/Assets:CashAtBank -$100
    A/Assets:Loans:BorrowedByB $100
    B/Assets:CashAtBank $100
    B/Liabilities:Loans/BorrowedFromA $100

For reports, had in mind:

Entities should be at root level of report - so all the output for an entity should effectively be demoted one level. Should then be possible to see values for several entities in a single file.

ChernayaKoshka commented 7 years ago

Should entities be mandatory in a single file or should an error be thrown whenever a mix of entity/non-entity accounts are seen?

mafm commented 7 years ago

I would make the entity optional in the transaction syntax.

If a posting doesn't contain an entity specifier, the posting should be assigned to "the default" entity.

If no entities are explicitly mentioned in the transaction file all reports should look like they do in current code.

If an explicit entity is used for any posting in the transaction file, reports should be generated as a multi-entity report (even if there is only 1 entity).

Would probably also:

  1. add some (optional) syntax to allow default entity to be specified at the start of the transaction file: e.g.

    defaultEntity=AcmeCorporation
  2. generate reports as multi-entity reports if a name is assigned to the default entity using the syntax in (1), even if only the default entity is used for all transactions - i.e. specifying a name for the default entity should be equivalent to specifying that entity name explicitly on all transactions.

ChernayaKoshka commented 7 years ago

I finally got around to working on this, would you mind taking a look at my current commits to see if I am currently headed in the direction you would like? Naturally, it is in-progress and reports are currently broken. However, it passes all current tests.

ChernayaKoshka commented 7 years ago

@mafm I believe I have completed adding entity support, all of the reports function as I would expect them to. The only current issue is whitespace, as it seems that adding entity support has messed up the expected whitespace, causing "garbled" (but still correct) reports. See below for an example of ""balances-by-date"; "2013-01-05"; "2013-01-10"" . "balances-by-date"; "2013-01-05"; "2013-01-10"

Edit: On second thought, Default/Assets shows up twice, I'm no accountant but that seems off. Could you verify whether or not the above image is an accurate representation of the "entity_sample.transactions" file?

Edit2: Silly me, looks like I messed up that report. I'll fix it.

ChernayaKoshka commented 7 years ago

Fixed formatting for ReportBalancesByDate report in https://github.com/FatherFoxxy/ledger.fs/commit/be31edc1cc038d30c51ffdc80312909f6c605010

ChernayaKoshka commented 7 years ago

Pull request https://github.com/mafm/ledger.fs/pull/6 created