Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Getting Started >

Account Number already exists error when posting an Invoice Credit Note

Started by Davide G -   in Getting Started

I posted a new invoice via the API and then attempted to post a credit note for the invoice but I get error response - "The Account Number already exists. Please enter a different Account Number".

I've managed to post a bill invoice and bill credit note without error, am I missing something when it comes to Invoices?

Response:

<ApiException xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ErrorNumber>10</ErrorNumber>
<Type>ValidationException</Type>
<Message>A validation exception occurred</Message>
<Elements>
<DataContractBase xsi:type="CreditNote">
<ValidationErrors>
<ValidationError>
<Message>The Account Number already exists. Please enter a different Account Number.</Message>
</ValidationError>
</ValidationErrors>
<Contact>
<ValidationErrors>
<ValidationError>
<Message>The Account Number already exists. Please enter a different Account Number.</Message>
</ValidationError>
</ValidationErrors>
<ContactID>8e3820d9-dd00-4031-b63e-8bc7a111206e</ContactID>
<ContactNumber>TEST123</ContactNumber>
<AccountNumber>123JB</AccountNumber>
<ContactStatus>ACTIVE</ContactStatus>
<Name>test</Name>
<Addresses>
<Address>
<AddressType>STREET</AddressType>
</Address>
<Address>
<AddressType>POBOX</AddressType>
<AttentionTo>test</AttentionTo>
</Address>
</Addresses>
<Phones>
<Phone>
<PhoneType>DEFAULT</PhoneType>
</Phone>
<Phone>
<PhoneType>DDI</PhoneType>
</Phone>
<Phone>
<PhoneType>FAX</PhoneType>
</Phone>
<Phone>
<PhoneType>MOBILE</PhoneType>
</Phone>
</Phones>
<UpdatedDateUTC>2019-01-07T11:58:36.955281Z</UpdatedDateUTC>
<DefaultCurrency>GBP</DefaultCurrency>
</Contact>
<Date>2019-01-07T00:00:00</Date>
<Status>AUTHORISED</Status>
<LineAmountTypes>Exclusive</LineAmountTypes>
<LineItems>
<LineItem>
<Description>Labour</Description>
<UnitAmount>300.00</UnitAmount>
<TaxType>OUTPUT2</TaxType>
<TaxAmount>60.00</TaxAmount>
<LineAmount>300.00</LineAmount>
<Quantity>1.0000</Quantity>
</LineItem>
<LineItem>
<Description>Materials</Description>
<UnitAmount>500.00</UnitAmount>
<TaxType>OUTPUT2</TaxType>
<TaxAmount>100.00</TaxAmount>
<LineAmount>500.00</LineAmount>
<Quantity>1.0000</Quantity>
</LineItem>
</LineItems>
<SubTotal>800.00</SubTotal>
<TotalTax>160.00</TotalTax>
<Total>960.00</Total>
<CurrencyCode>GBP</CurrencyCode>
<CurrencyRate>1.000000</CurrencyRate>
<Type>ACCRECCREDIT</Type>
<Reference>AF-168</Reference>
<RemainingCredit>960.00</RemainingCredit>
<CreditNoteID>00000000-0000-0000-0000-000000000000</CreditNoteID>
<CreditNoteNumber>CN-0007</CreditNoteNumber>
</DataContractBase>
</Elements>
</ApiException>
Hey Davide,

It looks like the issue isn't with the credit note or invoice details but with the embedded contact. When creating invoices and credit notes, if the embedded contact details don't have either the Name, ContactId, or ContactNumber of an existing contact in your organisation, then a contact with your specified details will try to be created at the same time as the invoice or credit note.

The same goes for updating a contact alongside the creation of an invoice/credit note if you've supplied different details to what already exists for an existing contact.

In your case (from the XML you've provided) it looks like the contact you're supplying has a clashing account number with an already existing contact in your organisation


Cheers,
Matt
 

Matthew Mortimer (Xero Staff)  

Hi Matt,

Thank you very much for the response, I'll double check the contact info and come back if issue still exists.
 

Davide G