0

Using Xero.Api for Xero accounting, I am looking to update expenses from Authorised to Paid. At present, I am getting the following error:

"Invalid status change. An expense claim with status 'AUTHORISED', cannot be updated to have the status 'PAID'"

Is this possible to do through the API, if so what are the minimum field changes so this is processed?

Many thanks.

public static void SetExpensePaid(Xero.Api.Example.Applications.Private.Core api,List<Guid> guids)
    {
        var account = api.Accounts.Find();
        var bank = account.Where(x => x.Name == "Bank").FirstOrDefault();
        foreach (var g in guids)
        {
            var exp =api.ExpenseClaims.Find(g);
            var amount = exp.AmountDue;
            exp.AmountPaid = amount;
            exp.AmountDue = 0;
            exp.Status = Xero.Api.Core.Model.Status.ExpenseClaimStatus.Paid;
            Payment payment = new Payment()
            {
                Account = bank,
                BankAmount = (decimal?)amount,
                Date = DateTime.Today,
                IsReconciled = false,
                Amount = (decimal?)amount
            };
            api.Payments.Create(payment);

            exp.Payments.Add(payment);
            api.ExpenseClaims.Update(exp);
        }

    }
RFigg
  • 21
  • 3

1 Answers1

2

For anyone else wondering, managed to get a response from Xero....

Normally, for invoices or credit notes, you need to make full payments to them using the Payments endpoint to mark them as PAID.

Unfortunately, you cannot pay an expense claim via the Xero API at this time. Payment needs to be done in the Xero app.

https://developer.xero.com/documentation/api/expense-claims#POST

So can't be done at present.

RFigg
  • 21
  • 3