Xero integration doesn't deal with negative payment method totals
We ran into this problem at the Coalheavers the other day: we had done a lot of cashback, so the cash total for the day was negative (although the overall total was positive, as usual).
Adding the payments to the invoice via the Xero API was rejected with the following validation errors:
- Payment amounts must be positive amounts
- Payment amount exceeds the amount outstanding on this document
After some fiddling with Xero, I have a plan to make this work.
- For each negative payment total, add a line to the invoice recording that total against the suspense account with No VAT. When sending the payments, don't send the negative ones.
- For each negative payment, create a Spend Money transaction between the configured account for that payment method and the suspense account.
The suspense account balance should be unchanged by this, and the payment method accounts should all have transactions of the correct values.
We should record the Spend Money transaction IDs in the session log. We might need a new log entry type for this.
Current state: the invoice is sent to Xero with a line for each negative payment recording it against the suspense account, but the Spend Money transaction is not created automatically. The invoice is left in "Draft" state.