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

nigelwheelernigelwheeler Member Posts: 20

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: 98 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: 20

    @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: 98 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!

  • bluetonguedigitalbluetonguedigital Member Posts: 2

    Hi there,

    I have been trying to set up an API call to create a transaction on an account, but I was just hoping for some clarification on the 'anchor' and 'line item' schemas.

    My understanding is that the anchor account is a bank account/credit card and the line items for each transaction must have a credit & debit for the transaction, and an expenses/income account that is attached to the anchor account. Is that correct?

    In terms of the anchor account, how am I able to see the ID of each account in my Wave business? Is this the ID that is set when a new account is created, or is it found somewhere else?

    Thanks for your help!

    Daniel

  • AlexLAlexL Administrator Posts: 1,295 admin

    Hey @bluetonguedigital . I merged your thread into this one as it should have all the answers you need. Don't hesitate to reach back out if you find that you still have unanswered questions.

    edited January 16, 2020
  • bluetonguedigitalbluetonguedigital Member Posts: 2

    Hi @AlexL - thanks for that, definitely clears up a few questions!

    The main thing I'm still wondering is how I'm able to get the ID for the anchor account? Is there a GraphQL query I can find it in, or is this the ID that is set when a new account is created?

    Thanks!

  • nigelwheelernigelwheeler Member Posts: 20

    @bluetonguedigital - There's an example for getting account ids filtered by type here -

    Change the BUSINESS ID query variable for your own.
    In the main query, substitute the accounts(types: [INCOME]) filter value for appropriate AccountTypeValue(s) i.e. [ASSET] for your bank accounts/cash etc. [LIABILITY] for your credit cards (or you could use [ASSET, LIABILITY] to get both types)

    Once you've identified the correct account in the results then yes, use the id value for that as the accountId in the query variables your moneyTransactionCreate

    Hope that helps!

    edited 9:59AM
Sign In or Register to comment.