/// <summary> /// Sets asynchronously the invoice payment status. /// </summary> /// <param name="id">The invoice id.</param> /// <param name="status">The new payment status.</param> /// <param name="effectiveDate">The date when payment was performed.</param> public async Task SetPaymentStatusAsync(int id, InvoicePaymentStatus status, DateTime effectiveDate) { if (id < 1) { throw new ArgumentOutOfRangeException(nameof(id), "Value must be greater than zero."); } // Get url string urlFormat; switch (status) { case InvoicePaymentStatus.Paid: urlFormat = "invoices/{0}/fire.json?event=pay&paid_at=" + Uri.EscapeDataString(XmlConvert.ToString(effectiveDate, XmlDateTimeSerializationMode.RoundtripKind)); break; case InvoicePaymentStatus.ProformaPaid: urlFormat = "invoices/{0}/fire.json?event=pay_proforma&paid_at=" + Uri.EscapeDataString(XmlConvert.ToString(effectiveDate, XmlDateTimeSerializationMode.RoundtripKind)); break; case InvoicePaymentStatus.PartialProformaPaid: urlFormat = "invoices/{0}/fire.json?event=pay_partial_proforma&paid_at=" + Uri.EscapeDataString(XmlConvert.ToString(effectiveDate, XmlDateTimeSerializationMode.RoundtripKind)); break; default: urlFormat = "invoices/{0}/fire.json?event=remove_payment"; break; } var c = this.Context.GetHttpClient(); var r = await c.PostAsync(string.Format(urlFormat, id), new StringContent(string.Empty)); r.EnsureFakturoidSuccess(); }
/// <summary> /// Sets the invoice payment status. /// </summary> /// <param name="id">The invoice id.</param> /// <param name="status">The new payment status.</param> /// <param name="effectiveDate">The date when payment was performed.</param> public void SetPaymentStatus(int id, InvoicePaymentStatus status, DateTime effectiveDate) { try { this.SetPaymentStatusAsync(id, status, effectiveDate).Wait(); } catch (AggregateException aex) { throw aex.InnerException; } }
/// <summary> /// Sets asynchronously the invoice payment status. /// </summary> /// <param name="id">The invoice id.</param> /// <param name="status">The new payment status.</param> /// <returns>Instance of <see cref="JsonInvoice"/> class with modified entity.</returns> public async Task SetPaymentStatusAsync(int id, InvoicePaymentStatus status) => await this.SetPaymentStatusAsync(id, status, DateTime.Now);
/// <summary> /// Sets the invoice payment status. /// </summary> /// <param name="id">The invoice id.</param> /// <param name="status">The new payment status.</param> public void SetPaymentStatus(int id, InvoicePaymentStatus status) => this.SetPaymentStatus(id, status, DateTime.Now);
/// <summary> /// Initializes a new instance of the <see cref="Invoice" /> class. /// </summary> /// <param name="InvoiceDate">The invoice date (required).</param> /// <param name="ContractId">ContractId (required).</param> /// <param name="InvoiceNumber">InvoiceNumber (required).</param> /// <param name="Amount">The amount of your invoice (required).</param> /// <param name="AmountToBePaid">The remaining amount to be paid for this invoice (required).</param> /// <param name="CurrencyCode">CurrencyCode (required).</param> /// <param name="PaymentStatus">PaymentStatus (required).</param> /// <param name="DueDate">DueDate (required).</param> /// <param name="InvoiceUrl">The url of the invoice document.</param> public Invoice(DateTime?InvoiceDate = default(DateTime?), ContractId ContractId = default(ContractId), InvoiceNumber InvoiceNumber = default(InvoiceNumber), double?Amount = default(double?), double?AmountToBePaid = default(double?), BeezUPCommonCurrencyCode CurrencyCode = default(BeezUPCommonCurrencyCode), InvoicePaymentStatus PaymentStatus = default(InvoicePaymentStatus), DateTime?DueDate = default(DateTime?), string InvoiceUrl = default(string)) { // to ensure "InvoiceDate" is required (not null) if (InvoiceDate == null) { throw new InvalidDataException("InvoiceDate is a required property for Invoice and cannot be null"); } else { this.InvoiceDate = InvoiceDate; } // to ensure "ContractId" is required (not null) if (ContractId == null) { throw new InvalidDataException("ContractId is a required property for Invoice and cannot be null"); } else { this.ContractId = ContractId; } // to ensure "InvoiceNumber" is required (not null) if (InvoiceNumber == null) { throw new InvalidDataException("InvoiceNumber is a required property for Invoice and cannot be null"); } else { this.InvoiceNumber = InvoiceNumber; } // to ensure "Amount" is required (not null) if (Amount == null) { throw new InvalidDataException("Amount is a required property for Invoice and cannot be null"); } else { this.Amount = Amount; } // to ensure "AmountToBePaid" is required (not null) if (AmountToBePaid == null) { throw new InvalidDataException("AmountToBePaid is a required property for Invoice and cannot be null"); } else { this.AmountToBePaid = AmountToBePaid; } // to ensure "CurrencyCode" is required (not null) if (CurrencyCode == null) { throw new InvalidDataException("CurrencyCode is a required property for Invoice and cannot be null"); } else { this.CurrencyCode = CurrencyCode; } // to ensure "PaymentStatus" is required (not null) if (PaymentStatus == null) { throw new InvalidDataException("PaymentStatus is a required property for Invoice and cannot be null"); } else { this.PaymentStatus = PaymentStatus; } // to ensure "DueDate" is required (not null) if (DueDate == null) { throw new InvalidDataException("DueDate is a required property for Invoice and cannot be null"); } else { this.DueDate = DueDate; } this.InvoiceUrl = InvoiceUrl; }
/// <summary> /// Sets the invoice payment status. /// </summary> /// <param name="id">The invoice id.</param> /// <param name="status">The new payment status.</param> /// <param name="effectiveDate">The date when payment was performed.</param> public void SetPaymentStatus(int id, InvoicePaymentStatus status, DateTime effectiveDate) { if (id < 1) throw new ArgumentOutOfRangeException("id", "Value must be greater than zero."); // Get url string urlFormat; switch (status) { case InvoicePaymentStatus.Paid: urlFormat = "invoices/{0}/fire.json?event=pay&paid_at=" + Uri.EscapeDataString(XmlConvert.ToString(effectiveDate, XmlDateTimeSerializationMode.RoundtripKind)); break; case InvoicePaymentStatus.ProformaPaid: urlFormat = "invoices/{0}/fire.json?event=pay_proforma&paid_at=" + Uri.EscapeDataString(XmlConvert.ToString(effectiveDate, XmlDateTimeSerializationMode.RoundtripKind)); break; case InvoicePaymentStatus.PartialProformaPaid: urlFormat = "invoices/{0}/fire.json?event=pay_partial_proforma&paid_at=" + Uri.EscapeDataString(XmlConvert.ToString(effectiveDate, XmlDateTimeSerializationMode.RoundtripKind)); break; default: urlFormat = "invoices/{0}/fire.json?event=remove_payment"; break; } var c = this.Context.GetHttpClient(); var r = c.PostAsync(string.Format(urlFormat, id), new StringContent(string.Empty)).Result; r.EnsureFakturoidSuccess(); }
/// <summary> /// Sets the invoice payment status. /// </summary> /// <param name="id">The invoice id.</param> /// <param name="status">The new payment status.</param> public void SetPaymentStatus(int id, InvoicePaymentStatus status) { this.SetPaymentStatus(id, status, DateTime.Now); }