Jump to content

PurchaseInvoice Creation Error


 Share

Recommended Posts

Hi,

I am getting this response  while creating a Purchase Invoice . 

 [{"$severity":"error","$dataCode":"UnexpectedError","$message":"An unexpected error occurred.","$source":""}]

Request Details :

POST to https://api.accounting.sage.com/v3.1/purchase_invoices 

( Authorization token sent in the header)  .

Here is the request body . 

{"purchase_invoice":{"contact_id":"f51cda25b2514b6da40c9d27a64ff20d","date":"2021-10-15","due_date":"2021-10-16","contact_name":"Phoenix Air","reference":"5086","notes":"","total_quantity":1500.0000,"net_amount":24462.0000,"tax_amount":0.0,"total_amount":24462.0000,"exchange_rate":1.0,"inverse_exchange_rate":1.0,"base_currency_net_amount":24462.0000,"base_currency_tax_amount":0.0,"base_currency_total_amount":24462.0000,"invoice_lines":[{"description":"Lumabase 34510 Electric Luminaria Kit, Snowflake","ledger_account_id":"9031a66ad4d611eb97fe124d8c407a59","unit_price":16.3080,"product_id":"34722c10b5884edb94ef98ce718abc11","trade_of_asset":false,"quantity":1500.0000,"net_amount":24462.0000,"tax_amount":0.0,"total_amount":24462.0000,"base_currency_unit_price":16.3080,"unit_price_includes_tax":false,"base_currency_net_amount":24462.0000,"base_currency_tax_amount":0.0,"base_currency_total_amount":24462.0000,"discount_amount":0.0,"base_currency_discount_amount":0.0,"discount_percentage":0.0}]}}

 

Any ideas ?

 

Thanks,

Sachin 

 

 

Link to comment
Share on other sites

Hi Sachin

Thank you for your question.

Could you provide us with the following information please:

  • The country the business is located in.
  • If the business is registered for VAT if applicable
  • The Supplier country location
  • If the Supplier is registered for VAT

Also, from the code snippet you provided, I cannot see a tax_rate being set.

Link to comment
Share on other sites

Hi Sachin

Thanks for providing me with access to your test account.

I've confirmed all the id's for contacts, ledger and tax_rates etc and have been able to post the invoice with the following:
{
    "purchase_invoice": {
        "contact_id": "f51cda25b2514b6da40c9d27a64ff20d",
        "date": "2021-10-19",
        "due_date": "2021-11-19",
        "reference":5086,
        "invoice_lines": [
            {
                "description": "Lumabase 34510 Electric Luminaria Kit, Snowflake",
                "ledger_account_id": "9031a66ad4d611eb97fe124d8c407a59",
                "product_id": "34722c10b5884edb94ef98ce718abc11",
                "quantity": 1500,
                "tax_amount": 0.0,
                "tax_rate_id": "0cafb63d49524a3da6d1c8dd65899687",
                "unit_price": 16.3080,
                "unit_price_includes_tax": false
           
            } 
        ]   
    }
}

 

Looking at the code you provided it appears as if you are trying to set the invoice total values. You only need to provide the invoice_line values and the logic will take care of the rest. You also need to ensure you're setting the tax_rate_id.
 
Regards
 
Mark
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...