public static Boolean addorupdatePaymentFromUNMS(PaymentReadOnly upayment) { ClientReadOnly uclient = getclientbyid(Convert.ToDouble(upayment.ClientId)); string clientxeroid = ""; foreach (ClientAttributeReadOnly ca in uclient.Attributes) { if (ca.name == "xeroIdclient") { clientxeroid = ca.value; } ; } if (clientxeroid == "") { return(false); } string paymentxeroid = ""; foreach (PaymentAttributeReadOnly ca in upayment.Attributes) { if (ca.Name == "xeroIdinvoice") { paymentxeroid = ca.Value; } ; } if (paymentxeroid == "") { XeroHelper.updateorcreatexeropayment(upayment, clientxeroid); } return(true); }
public static bool updateorcreatexeropayment(PaymentReadOnly Upayment, string clientxeroid) { XeroCoreApi xeroapp = getxeroapp(); Xero.Api.Core.Model.Payment Xpayment = new Xero.Api.Core.Model.Payment(); Xpayment.Amount = Convert.ToDecimal(Upayment.Amount); Xpayment.Date = Convert.ToDateTime(Upayment.CreatedDate); Xpayment.Status = Xero.Api.Core.Model.Status.PaymentStatus.Authorised; Xpayment.Type = Xero.Api.Core.Model.Types.PaymentType.AccountsReceivable; Xpayment.Account = xeroapp.Accounts.Where("Name==\"Stripe Payment Account\"").Find().First(); Xpayment.Reference = "from Unms"; foreach (PaymentCoverReadOnly pc in Upayment.PaymentCovers) { string invnumber = UNMSHelper.getinvoicenumberbyid(Convert.ToDouble(pc.InvoiceId)); Xpayment.Invoice = xeroapp.Invoices.Where("InvoiceNumber=\"" + invnumber + "\"").Find().FirstOrDefault(); } Xero.Api.Core.Model.Payment Xpaymentreturned = xeroapp.Update(Xpayment); return(true); }