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);
}
}