Jump to content

Getting an error code 422 when posting an invoice


 Share

Recommended Posts

Some additional information and background on this messaging is that it started on March 1st, 2021 as mentioned.  The error message is confusing as the 3 fields listed include a line item quantity, when the unit price is allowed. The Artefact is a SALES INVOICE.

I seem to remember that due_date might not be supported for any region in SBCA-Start (version) and am looking at a payload similar to the following that is causing the above Error code: 422 for the three attributes/fields mentioned in the error returned. Also, each line item has a quantity which can be inferred by the unit_price and net_amount, so the error message seems to be suggesting not to provide a quantity, either.  I believe the discount_amount should probably be omitted if 0, but may also not be supported in the "Start" edition of Sage Business Cloud Accounting in the UK.

I do note that goods and services are mixed in the following payload for the SALES INVOICE that is getting the error.

The sample payload:

{
  "sales_invoice": {
    "contact_id": "923c137cab894caa8b3ec9fcf1309d31",
    "date": "2021-03-31",
    "due_date": "2021-03-31",
    "invoice_number_prefix": "",
    "invoice_number": 403,
    "reference": "4540156044",
    "main_address": {
      "address_line_1": "C/O TEST\r",
      "address_line_2": "Accounts Payable Department\r",
      "city": "PO Box 0001\r",
      "region": "Glasgow\r",
      "postal_code": "G74 9FU"
    },
    "invoice_lines": [
      {
        "description": "TXU2 TEST PRODUCT",
        "ledger_account_id": "d2e342ce773b11ebb6a30662051ba57b",
        "unit_price": 392,
        "unit_price_includes_tax": false,
        "quantity": 1,
        "net_amount": 392,
        "discount_amount": 0,
        "tax_rate_id": "GB_STANDARD",
        "tax_amount": 78.4
      },
      {
        "description": "TX-2RL TEST PRODUCT2",
        "ledger_account_id": "d2e342ce773b11ebb6a30662051ba57b",
        "unit_price": 364,
        "unit_price_includes_tax": false,
        "quantity": 1,
        "net_amount": 364,
        "discount_amount": 0,
        "tax_rate_id": "GB_STANDARD",
        "tax_amount": 72.8
      },
      {
        "description": "SERVICES 01/02/21 to 28/02/21 = 28 days - invoice#403",
        "ledger_account_id": "d2e342ce773b11ebb6a30662051ba57b",
        "unit_price": 0,
        "unit_price_includes_tax": false,
        "quantity": 1,
        "net_amount": 0,
        "discount_amount": 0,
        "tax_rate_id": "GB_STANDARD",
        "tax_amount": 0
      },
      {
        "description": "ONGOING SERVICES",
        "ledger_account_id": "d2e342ce773b11ebb6a30662051ba57b",
        "unit_price": 0,
        "unit_price_includes_tax": false,
        "quantity": 1,
        "net_amount": 0,
        "discount_amount": 0,
        "tax_rate_id": "GB_STANDARD",
        "tax_amount": 0
      }
    ]
  }
}

 

Lastly... 

Things got complicated in the UK post-brexit!  So it's worth mentioning the discussions in the Developer Guides here: https://developer.sage.com/accounting/guides/brexit/sbca_api_brexit_guide/

Which points here to highlight the breaking changes that must be dealt with: https://developer.sage.com/accounting/guides/brexit/artefacts-breaking-changes-to-support-brexit-in-api-31/, specifically the "Required artefact parameters"

 

Edited by Farris, Rick
text formatting and readability
Link to comment
Share on other sites

  • Administrators

Hi, just to add to this - invoicing in Start is significantly more simplistic than in the other variants, allowing the following to be included:

  • Contact
  • Invoice date
  • Reference
  • Description
  • Category (ledger id)
  • Price/net amount
  • VAT rate
  • Total

You can then add Notes, and Terms & Conditions etc.

955822959_startinvoice.thumb.png.7e093c454126305c1f136bbd55e12bfc.png

I think the ideal solution would be for you to check the variant that a person is using via the businesses/{id} endpoint to check the subscription they have as part of the initial authorisation process/integration:

 

    "subscriptions": [

        {

            "created_at": "2017-06-06T08:25:46Z",

            "updated_at": "2017-06-14T14:28:32Z",

            "displayed_as": "Accounting",

            "id": "ACCOUNTING",

            "active": true,

            "status": "trial",

            "accountant_pays": false

        }

    ],

This will enable you to change how you post sales invoices and prevent the posting of other transaction types for users of Accounting Start.

Hope this helps,

 

Ben

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...