What exactly is the the `anchor` account in a `MoneyTransaction`?

nigelwheelernigelwheeler Member Posts: 15

Hi,
I'm experimenting with the MoneyTransactionCreateInput mutation in the API. It 'nearly works' but can't figure out what the "anchor" is about (MoneyTransactionCreateAnchorInput).

For my test, my assumption is that this is the Asset account the transaction relates to, so I've use the id for the "Cash on Hand" account, with direction "WITHDRAWAL".

My transaction lines are a CREDIT to this account and a matching DEBIT to the id of a random expense account (accounting fees).

The runtime inputError I'm getting is:

"code": "UNKNOWN",
          "message": "This value is invalid. MULTIPLE_POSSIBLE_ANCHORS",
          "path": null

Query & Variable syntax otherwise all seems OK, Full thing:

mutation ($inputMoneyTransactionCreate: MoneyTransactionCreateInput!) {
  moneyTransactionCreate(input: $inputMoneyTransactionCreate) {
    didSucceed
    inputErrors {
      code
      message
      path
    }
  }
}
{
  "inputMoneyTransactionCreate":{
    "businessId":   "QnVzaW5lc3M6ZTMzMzVjMDQtMDg1Mi00OTIxLWE2NTktZjM1YjgxYjQwMTU2",
        "externalId":   "MyExternalID", 
        "date": "2019-11-22",
        "description":  "MyDescription some accounting fees",
        "notes":    "blah blah blah",
        "anchor": {
      "accountId":"QWNjb3VudDo2MzE2MzcyNjEzMTM2ODY4NTU7QnVzaW5lc3M6ZTMzMzVjMDQtMDg1Mi00OTIxLWE2NTktZjM1YjgxYjQwMTU2",
        "amount": 1.99,
      "direction": "WITHDRAWAL"
    },
        "lineItems":    [{
      "accountId":"QWNjb3VudDo2MzE2MzcyNjM2NjI0OTcxNjU7QnVzaW5lc3M6ZTMzMzVjMDQtMDg1Mi00OTIxLWE2NTktZjM1YjgxYjQwMTU2",
        "amount": 1.99,
      "balance": "DEBIT",
      "taxes": []
    },
      {
      "accountId":"QWNjb3VudDo2MzE2MzcyNjEzMTM2ODY4NTU7QnVzaW5lc3M6ZTMzMzVjMDQtMDg1Mi00OTIxLWE2NTktZjM1YjgxYjQwMTU2",
        "amount": 1.99,
      "balance": "CREDIT",
      "taxes": []
      }
    ]
    }
}

Comments

  • dshatzdshatz Member Posts: 1

    Having the same issue

  • PaulCPaulC Administrator Posts: 94 admin

    Hi @nigelwheeler,

    As you say - you're close!

    The best way to think about this is to keep in mind what a categorized transaction looks like in Wave:

    • A deposit or withdrawal to a bank or credit card account
    • One or more lines of categorization (which could be 'uncategorized income' or 'uncategorized expense' in a default state.

    The MoneyTransacationCreate mutation has the same shape. The bank/credit card account from which the transaction takes place is the Anchor; the line items are the categorizations. Therefore, in your example, you do not need to repeat the Cash on Hand account in the line items; you should have just one line item, which is your accounting fees expense account.

    A separate point to note is that you appear to be confusing DEBIT and CREDIT direction. If it were correct to have 2 line items, you should actually be CREDITING cash on hand and DEBITING accounting fees expense. If you would like to fully understand Debits and Credits, please refer to Accounting Coffee Break #5 in Fearless Accounting with Wave, which explains this topic. More simply, use the convenience directions INCREASE and DECREASE, which work out when to Debit and when to Credit for you.

    In summary:

    • WITHDRAW from your anchor account
    • categorize as an INCREASE of accounting fees expense in your line items.

    Hope that helps. Paul

    cc @dshatz

  • nigelwheelernigelwheeler Member Posts: 15

    @PaulC Thanks for your help.

    So just to clarify, the anchor account is an asset (cash or bank/credit card) account which payment is being made to or from, the line items are the balancing entries/splits (expenses, income etc.) on the other side of the transaction.

    I think this was my original assumption but when I got an error (from using wrong account code, see below) I started to explore the idea that the line items should themselves be in balance.

    Perhaps the docs could be enhanced a bit to clarify?

    p.s. If you look very very closely you'll see I was trying CR the same account in the lines as my anchor account, mistakenly thinking this was the node id for Cash in hand when it wasn't, caused by using copypasta with horribly similar strings in graphiql editor rather than getting account codes programmatically.

  • PaulCPaulC Administrator Posts: 94 admin

    Correct, yes.

    Although, to be strict, the anchor account is an asset (cash and bank) or liability (credit card / LoC) account. In either case, WITHDRAWAL means you are spending money; DEPOSIT means you are receiving it (in the case of a credit card, therefore, paying down your debt).

    Agreed, IDs are not exactly human-readable!

Sign In or Register to comment.