Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Endpoints >

Overpayment allocation not working - the document total does not equal the sum of the lines

Started by Michael Gois -   in API Endpoints

Im trying to apply a part payment to an invoice through the API.

I have succesfully created an overpayment by creating a BankTransaction of type ReceiveOverpayment. I save the overpayment Id, and then I am trying to create an allocation of this payment against an invoice. The invoice amount is for £24 and the overpaymentpayment is for £10.

I'm using the .NET API SDK, and creating an OverpaymentAllocation object, populating the overpayment id, the invoice number and appliedamount, which I set to £10 as that is the value of the overpayment.

I call teh Add method for Allocations, my assumption is that this will call the /{overpaymentid}/allocation endpoint. However when I post this, I get a validation error "The document total does not equal the sum of the lines., The document total does not equal the sum of the lines." I am aware the overpayment does not equal £24, but I want to apply a part payment to this invoice. I have no problems doing this through Xero UI, so I dont see why it doesnt work through the API. I can use the overpayment I have created through the API and allocate this to the invoice through the UI, by opening up the invoice and clicking on the link at the bottom of the invoice to credit the overpayment, but I need to automate this.

Any ideas please!