使用 Xero.Api 进行 Xero 会计,我希望将费用从授权更新为付费。目前,我收到以下错误:
“状态更改无效。状态为‘授权’的费用报销,无法更新为状态‘已支付’”
这是否可以通过 API 完成,如果可以,那么最小的字段更改是多少?
非常感谢。
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);
}
}