2020-05-07 12:50:07 +02:00
|
|
|
using System;
|
2017-09-13 08:47:34 +02:00
|
|
|
using System.Collections.Generic;
|
2020-06-24 10:51:00 +02:00
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2023-02-21 07:06:34 +01:00
|
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
2017-09-13 08:47:34 +02:00
|
|
|
|
|
|
|
namespace BTCPayServer.Data
|
|
|
|
{
|
2023-02-21 07:06:34 +01:00
|
|
|
public class InvoiceData : IHasBlobUntyped
|
2017-10-27 10:53:04 +02:00
|
|
|
{
|
2020-12-28 21:57:21 +01:00
|
|
|
public string Id { get; set; }
|
2017-09-13 08:47:34 +02:00
|
|
|
|
2020-12-28 21:57:21 +01:00
|
|
|
public string StoreDataId { get; set; }
|
|
|
|
public StoreData StoreData { get; set; }
|
2017-09-13 08:47:34 +02:00
|
|
|
|
2020-12-28 21:57:21 +01:00
|
|
|
public DateTimeOffset Created { get; set; }
|
|
|
|
public List<PaymentData> Payments { get; set; }
|
|
|
|
public List<InvoiceEventData> Events { get; set; }
|
2018-01-14 13:48:23 +01:00
|
|
|
|
2023-02-21 07:06:34 +01:00
|
|
|
[Obsolete("Use Blob2 instead")]
|
2020-12-28 21:57:21 +01:00
|
|
|
public byte[] Blob { get; set; }
|
2023-02-21 07:06:34 +01:00
|
|
|
public string Blob2 { get; set; }
|
2020-12-28 21:57:21 +01:00
|
|
|
public string ItemCode { get; set; }
|
|
|
|
public string OrderId { get; set; }
|
|
|
|
public string Status { get; set; }
|
|
|
|
public string ExceptionStatus { get; set; }
|
|
|
|
public string CustomerEmail { get; set; }
|
|
|
|
public List<AddressInvoiceData> AddressInvoices { get; set; }
|
2020-05-07 12:50:07 +02:00
|
|
|
public bool Archived { get; set; }
|
2018-07-19 12:31:17 +02:00
|
|
|
public List<PendingInvoiceData> PendingInvoices { get; set; }
|
2020-12-28 11:10:53 +01:00
|
|
|
public List<InvoiceSearchData> InvoiceSearchData { get; set; }
|
2020-06-24 10:51:00 +02:00
|
|
|
public List<RefundData> Refunds { get; set; }
|
2020-12-28 21:57:21 +01:00
|
|
|
|
|
|
|
|
2023-02-21 07:06:34 +01:00
|
|
|
internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
|
2020-06-24 10:51:00 +02:00
|
|
|
{
|
2020-06-27 14:55:16 +02:00
|
|
|
builder.Entity<InvoiceData>()
|
|
|
|
.HasOne(o => o.StoreData)
|
|
|
|
.WithMany(a => a.Invoices).OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.Entity<InvoiceData>().HasIndex(o => o.StoreDataId);
|
2020-12-08 06:43:39 +01:00
|
|
|
builder.Entity<InvoiceData>().HasIndex(o => o.OrderId);
|
2022-05-18 08:44:58 +02:00
|
|
|
builder.Entity<InvoiceData>().HasIndex(o => o.Created);
|
2023-02-21 07:06:34 +01:00
|
|
|
|
|
|
|
if (databaseFacade.IsNpgsql())
|
|
|
|
{
|
|
|
|
builder.Entity<InvoiceData>()
|
|
|
|
.Property(o => o.Blob2)
|
|
|
|
.HasColumnType("JSONB");
|
|
|
|
}
|
2020-06-24 10:51:00 +02:00
|
|
|
}
|
2017-10-27 10:53:04 +02:00
|
|
|
}
|
2017-09-13 08:47:34 +02:00
|
|
|
}
|