0

I am trying to add a sales invoice through Sage Accounting API calls. However, I keep getting the same error and I cannot find the cause.

Request details:

Params:

{
"sales_invoice": {
    "contact_id": "2d06dde3927744f09c60557aae2d1f10",
    "date": "2019-07-01 13:14:56",
    "invoice_lines": [
        {
            "description": "Original remote control JVC RM-C3095",
            "ledger_account_id": "7ccb54ca5df741f0b6cfbb6c35791f93",
            "unit_price": "20.0000",
            "quantity": 1,
            "tax_rate_id": "ES_EXEMPT",
            "eu_goods_services_type_id": "GOODS"
        }
    ],
    "invoice_number_prefix": "INV-",
    "invoice_number": 4,
    "delivery_address": {
        "city": "xxx",
        "address_line_1": "yyy",
        "address_line_2": "zzz",
        "postal_code": "014178"
    },
    "main_address": {
        "city": "xxx",
        "address_line_1": "yyy",
        "address_line_2": "zzz",
        "postal_code": "014178"
    }
}
}

The error:

Array
(
[0] => Array
    (
        [$severity] => error
        [$dataCode] => RecordInvalid
        [$message] => is invalid
        [$source] => line_items.ledger_account
    )

)

Even though the ledger account id IS valid (as I took it directly from the ledger accounts in the app). How can I fix this?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    Can you please try a GET request on the resource `/ledger_accounts/7ccb54ca5df741f0b6cfbb6c35791f93`? This might help to investigate why the value is not accepted on an invoice line. – tosch Jul 02 '19 at 10:43

1 Answers1

0

Please double-check that the ledger account you use for the sales invoice is also listed in

GET /ledger_accounts?visible_in=sales

This will give you a list of valid ledger accounts you can use for sales invoices, sales quotes, sales credit notes, etc.

Also, check out the official documentation about invoicing.

Christoph Petschnig
  • 4,047
  • 1
  • 37
  • 46