mirror of
https://github.com/bitwarden/server
synced 2025-12-15 07:43:54 +00:00
* Moved AccountsBilling controller to be owned by Billing * Added org billing history endpoint * Updated GetBillingInvoicesAsync to only retrieve paid, open, and uncollectible invoices, and added option to limit results * Removed invoices and transactions from GetBillingAsync * Limiting the number of invoices and transactions returned * Moved Billing models to Billing namespace * Split billing info and billing history objects * Removed billing method GetBillingBalanceAndSourceAsync * Removed unused using * Cleaned up BillingInfo a bit * Update migration scripts to use `CREATE OR ALTER` instead of checking for the `OBJECT_ID` * Applying limit to aggregated invoices after they return from Stripe
62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using Bit.Core.Billing.Models;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Models.Api;
|
|
|
|
namespace Bit.Api.Billing.Models.Responses;
|
|
|
|
public class BillingHistoryResponseModel : ResponseModel
|
|
{
|
|
public BillingHistoryResponseModel(BillingHistoryInfo billing)
|
|
: base("billingHistory")
|
|
{
|
|
Transactions = billing.Transactions?.Select(t => new BillingTransaction(t));
|
|
Invoices = billing.Invoices?.Select(i => new BillingInvoice(i));
|
|
}
|
|
public IEnumerable<BillingInvoice> Invoices { get; set; }
|
|
public IEnumerable<BillingTransaction> Transactions { get; set; }
|
|
}
|
|
|
|
public class BillingInvoice
|
|
{
|
|
public BillingInvoice(BillingHistoryInfo.BillingInvoice inv)
|
|
{
|
|
Amount = inv.Amount;
|
|
Date = inv.Date;
|
|
Url = inv.Url;
|
|
PdfUrl = inv.PdfUrl;
|
|
Number = inv.Number;
|
|
Paid = inv.Paid;
|
|
}
|
|
|
|
public decimal Amount { get; set; }
|
|
public DateTime? Date { get; set; }
|
|
public string Url { get; set; }
|
|
public string PdfUrl { get; set; }
|
|
public string Number { get; set; }
|
|
public bool Paid { get; set; }
|
|
}
|
|
|
|
public class BillingTransaction
|
|
{
|
|
public BillingTransaction(BillingHistoryInfo.BillingTransaction transaction)
|
|
{
|
|
CreatedDate = transaction.CreatedDate;
|
|
Amount = transaction.Amount;
|
|
Refunded = transaction.Refunded;
|
|
RefundedAmount = transaction.RefundedAmount;
|
|
PartiallyRefunded = transaction.PartiallyRefunded;
|
|
Type = transaction.Type;
|
|
PaymentMethodType = transaction.PaymentMethodType;
|
|
Details = transaction.Details;
|
|
}
|
|
|
|
public DateTime CreatedDate { get; set; }
|
|
public decimal Amount { get; set; }
|
|
public bool? Refunded { get; set; }
|
|
public bool? PartiallyRefunded { get; set; }
|
|
public decimal? RefundedAmount { get; set; }
|
|
public TransactionType Type { get; set; }
|
|
public PaymentMethodType? PaymentMethodType { get; set; }
|
|
public string Details { get; set; }
|
|
}
|