Xero Accounting API adding a repayment to an AR client which has no existing entry to match to - seems impossible

21 Views Asked by At

I am trying to add a repayment to a client which does not match to any existing invoice, credit or prepayment (weird I know but its what my customer is asking for - it will get journalled off later on !) - the closest I have got is to try adding a Bank Transaction as this :

{'BankTransactions': [{'Type': 'RECEIVE-PREPAYMENT', 'BankAccount': {'AccountID': 'e12ec8b0-4a25-47d9-88e6-9e02e62c2d1f'}, 'Contact': {'ContactID': '49445ede-1278-4f58-b3aa-0480236a95d2'}, 'LineItems': [{'Description': 'Payment refunded to card on job 110765', 'Quantity': 1, 'AccountCode': '620', 'UnitAmount': -375.31, 'TaxType': 'NONE', 'LineAmount': -375.31}], 'Date': '2023-12-07', 'Reference': 'Job No : 110765'}]}

But of course Xero barfs at the negative value - and adding as a + value is the wrong way round in the bank account and on the clients account too !

If I try to SPEND-PREPAYMENT this ends up on the Accounts Payable ledger which is not where I want this to go !

Has anyone managed such a feat in the Xero API land ? The documentation seems obtuse to say the least around this area....

Note I have tried this as a PAYMENTS entry as well but it always seems to require a prior transaction to enter a payment against so I simply get the dreaded 'Document not found' error trying to enter as a payment

1

There are 1 best solutions below

2
On

This is an accounting issue rather than an API issue. Double-entry rules mean that you need to attach a payment to something for example you can create an overpayment and then refund this by adding a payment visa the payments endpoint. You can code the line item of the overpayment to an appropriate balance sheet account but you would need to check with an accountant or tax advisor to make sure whatever you do follows good accounting practice