XeroAPI/xero-php-oauth2

Delete invoice from draft, new invoices are not created

gurprreetkhattra opened this issue · 1 comments

- Version [xero-php-oauth2]

I submit all invoices the first time it's working fine, after delete invoices from the draft, API returns the validation error "Invoice not of valid status for modification", I'm not getting without changing the status for the invoices why this error occur. Please help me with this issue, It's urgent

Input:-

{
"Invoices": [
{
"Type": "ACCREC",
"Contact": {
"ContactID": "1233434234234234234",
"HasAttachments": false,
"HasValidationErrors": false
},
"LineItems": [

    {
      "Description": "dummy text",
      "Quantity": 2,
      "ItemCode": "Base Rate",
      "AccountCode": "0105"
    },
    {
      "Description": "dummy text",
      "Quantity": 3,
      "ItemCode": "Base Rate",
      "AccountCode": "0105"
    }
  ],
  "Date": "2021-10-18T00:00:00+11:00",
  "DueDate": "2021-10-25T00:00:00+11:00",
  "Reference": "sdfdsfsdfsd",
  "Status": "DRAFT",
  "HasAttachments": false,
  "HasErrors": false
}

]
}

Output:-

{
"ErrorNumber": 10,
"Type": "ValidationException",
"Message": "A validation exception occurred",
"Elements": [
{
"Type": "ACCREC",
"InvoiceID": "wqewqeqewq",
"Reference": "ewqewqe",
"Payments": [],
"CreditNotes": [],
"Prepayments": [],
"Overpayments": [],
"IsDiscounted": false,
"HasAttachments": false,
"HasErrors": true,
"Contact": {
"ContactID": "qwqwqwqwewqewqewqewqe",
"Addresses": [],
"Phones": [],
"ContactGroups": [],
"ContactPersons": [],
"HasAttachments": false,
"HasValidationErrors": false,
"ValidationErrors": []
},
"DateString": "2021-10-17T13:00:00",
"Date": "/Date(1634475600000+0000)/",
"DueDateString": "2021-10-24T13:00:00",
"DueDate": "/Date(1635080400000+0000)/",
"Status": "DRAFT",
"LineAmountTypes": "Exclusive",
"LineItems": [
{
"ItemCode": "Base Rate",
"Description": "dummy text",
"UnitAmount": 10,
"TaxType": "EXEMPTOUTPUT",
"TaxAmount": 0.00,
"LineAmount": 20,
"AccountCode": "0105",
"Tracking": [],
"Quantity": 2.0000,
"AccountID": "eqwewqeqwewqe",
"ValidationErrors": []
},
{
"ItemCode": "Base Rate",
"Description": "dummy text",
"UnitAmount": 10,
"TaxType": "EXEMPTOUTPUT",
"TaxAmount": 0.00,
"LineAmount": 30,
"AccountCode": "0105",
"Tracking": [],
"Quantity": 3.0000,
"AccountID": "qeqweqwewq",
"ValidationErrors": []
}
],
"SubTotal": 50,
"TotalTax": 0.00,
"Total": 50,
"CurrencyCode": "AUD",
"ValidationErrors": [
{
"Message": "Invoice not of valid status for modification"
}
]
}
]
}

Thanks

This is most likely an issue with the API itself, as opposed to this SDK.

I suspect you're using an update method (POST call) instead of a create method (PUT) call. If this is the case our API will attempt to edit an existing Invoice before creating a new one. Please get in touch with our support team if you aren't able to resolve the issue.