relational-databaseaccounting

How to design a relational model for double-entry accounting with job costing


I would like to commend to readers the answers here and here for the depth and thought that went into them. I stumbled across them while searching for something tangential for a project I'm working on, and I got caught up reading them from top to bottom.

I am trying to build a niche-market app using these principles (namely, double-entry accounting), with job-costing thrown in. The above answers have been extremely helpful in reshaping my concept of what both the accounting and the database-ing should look and work like. However, I'm having a hard time integrating the job-costing portion of the equation into the excellent graphical examples that were provided.

There were several transaction examples using the House, account holders, fees, etc. I have a few other specific use-cases I would love to get some input on:

  1. I have no customers. I buy a property (usually cash goes out, a liability (loan) is created, an asset (the property) is created), spend a bunch of money to fix it up (either cash out at a store, credit card charges at a store, or a check written to a vendor, which debits the property asset and debits or credits the funding source), and then sell it (cash comes in, the loan is paid off, and hopefully there's more cash left than what I spent on the project). This likely creates more ledger entries than I've listed above, but I'm not an accountant. I think I understand that all my costs go toward my basis in the property, and if my net proceeds are greater than my basis, then I've made money, and if not, then not.

  2. So what I need to record are expenses that a) come from a specific account (i.e. company checking account or owner's Best Buy card etc.), b) are generally associated with a specific job (but not always - I do have the occasional overhead expense like office supplies), and c) are always associated with a cost code (i.e. '100.12 - Window Materials', '100.13 - Window Labor', etc.).

  3. Frequently I receive bills from vendors that are due sometime in the future. I would like to track the bills received but not-yet-paid for a given job (committed costs). I think this transaction looks like this, but I'm not really sure:

    Vendor bill received

  4. As you may have surmised from my quip above about the "owner's Best Buy card," I sometimes (more often than I should) use my personal funds for company- and job-related expenses. I think (again with the caveat that I'm a layman) that all of those expenditures credit "Owner's Equity," and debit/credit other accounts as needed.

I've been keeping track of all of this in a big, ugly spreadsheet, which is why I'm trying to build an app to replace it - the spreadsheet method doesn't work very well and it certainly won't scale.


Solution

  • Preliminary

    For those reading this Answer, please note that the context is as follows, in increments:

    If you have not availed yourself to that, this Answer may not make sense.

    I will respond in a sequence that is Normalised, which is of course different to the way you have laid out the problem.

    Principle & Correction

    There are a few, more than one, errors in your stated problem which you are not aware of, so the first step is awareness; understanding. Once a problem is correctly and precisely declared, it is easy to solve. These are errors that developers commonly make, so they need to be understood as such ... long before an app is contemplated.

    1 First Principle

    I've been keeping track of all of this in a big, ugly spreadsheet [the spreadsheet method doesn't work very well and it certainly won't scale], which is why I'm trying to build an app to replace it

    2 Second Principle

    I've been keeping track of all of this in a big, ugly spreadsheet [...] - the spreadsheet method doesn't work very well

    3 Third Principle

    I've been keeping track of all of this in a big, ugly spreadsheet [...] - the spreadsheet method doesn't work very well

    Problem & Solution

    Now that we understand the principles, we can move on to determination of the specific problems, and their solutions. Each of these is a specific application of the Third Principle.

    4 Property/Mortgage Treatment

    I have no customers. I buy a property (usually cash goes out, a liability (loan) is created, an asset (the property) is created), spend a bunch of money to fix it up (either cash out at a store, credit card charges at a store, or a check written to a vendor, which debits the property asset and debits or credits the funding source), and then sell it

    niche-market app ...
    I have a few other specific use-cases ...

    5 Ledger

    Where the above points have to do with the intellectual realm, the understanding of each problem and therein the solution, which causes little work in the physical realm, this point, which has the same demand for the intellectual, is onerous at the physical level. That is, the number of keystrokes; checking; changes; checking ... before you get it set up correctly.

    [your graphics re transactions]

    expenses that a) come from a specific account (i.e. company checking account or owner's Best Buy card etc.),

    Ledger-ExternalAccount
    (one DEA leg in the Ledger, the other leg in the External Account). Noting the caveats above. The other DEA leg will be to one of these (hierarchy):

    expenses that c) are always associated with a cost code (i.e. '100.12 - Window Materials', '100.13 - Window Labor', etc.).

    You will no longer have "cost codes", they will all be Ledger Account Numbers LedgerNos, because the Ledger is where you account for anything and everything.

    One DEA leg in the Ledger, the other leg in the External Account for the particular property. The hierarchy will be the same as the previous point.

    expenses that b) are generally associated with a specific job

    Ledger-ExternalAccount
    (one DEA leg in the Ledger, the other in the External Account).

    (but not always - I do have the occasional overhead expense like office supplies)

    Ledger-Ledger

    6 Credit & Other Card Treatment

    credit card charge
    Best Buy card

    Each of your cards represents a contract, an Account that that needs to be transacted against, that must be balanced against the monthly statement provided by the institution that issued the card.

    7 Job Costing

    Notice that I am addressing this last, because once you fix the big problems, the problems that remain, are small. What you set out as the big problems (job costing; profit/loss per property) are, once the Ledger has been set up correctly for your business, actually small problems.

    As far as I can see, Job Costing is the only remaining point that I have not addressed. First, the issue to be understood here is, the difference between Actuals and Estimates. Everything I have discussed thus far are Actuals.

    8 Data Model • Job Costing

    Noting that the data model in the first and second linked Answers are complete for the purpose, wherein the Ledger is not expanded:

    Obviously too large for an inline graphic. Here is a PDF in two pages:


    Comments

    Javad
    How do you insert the first ledger (e.g. 100 Asset, no parent)?

    The Ledger is a Tree, a Single Parent Hierarchy (aka "one way" for strange reasons), as per Account Hierarchy.

    Refer to the Relational Hierarchy doc for an overview of Relational Hierarchies and a generic definition of each.

    A root row is required. In a database build operation (using DDL from a file), we generally do all our CREATE TABLEs, followed by all our ADD CONSTRAINT FKs. Insert the root row in with the CREATE TABLE.

    Given that the reverse of Comprises is belongs to, all first-level Ledgers eg. Fees, House, Interbank and your Asset would belong to this root row.


    bknux
    I assume in your transfer example you left out a transfer id because this is an example. Else I don't really get how you track money in a larger context where transaction with the same amount, may occur in the same time.

    The data model is Relational, Id fields are prohibited in the Relational Model, the additional field & additional index are simply not necessary here. The LedgerTransaction.PK (and AK) does prevent duplicates (transactions that occur "at the same time", 3 ms precision) regardless of Amount. Money is tracked due to DEA, not merely due to good Keys.

    I'm referring to your related DEA Answer, §5 Business Transaction with Row, Example 4, the transfer of 100$ between Mary and John. By the DEA example given, I can track amounts in total, so I know, that the housecash grew 100$ and mary's amount shrank 100$, for the other side vice versa.
    But to know, that mary send 100$ to john, requires both AccountXact and the one ledgerXact (or only the two account Xacts) to be matched by time (fuzzy) and amount.
    By Tracking I mean having a connection between Mary and John

    There is no connection between Mary and John [in the Ledger], so do not try to make one, especially not by time, because DateTime already has specific meaning. It would be a gigantic fudge, adding meaning to a column that means something else.

    To track something outside the Ledger, use a tracking device outside the Ledger. Say that Mary walked in with 1 Withdrawal slip and 1 Deposit slip: even if the slips have serial nos, they would not be related, so that is not useful. For tracking several different Ledger Transactions, outside the Ledger, we need to define precisely, what that is, and add the necessary tables.

    Larger context: I will assume that such Transactions need to be tracked because they are a single batch, which is what identifies that they are related (not only because the Amount is the same). A single event:

    It requires a Data Model that is a bit more advanced (which is why I brought your question over to this answer), and

    Refer to page 3 in this Data Model PDF.