2020-05-07 12:50:07 +02:00
|
|
|
using System;
|
2017-09-13 08:47:34 +02:00
|
|
|
using System.Collections.Generic;
|
2023-12-20 10:41:28 +01:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
2020-06-24 10:51:00 +02:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2023-02-21 07:06:34 +01:00
|
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
2024-08-27 02:53:28 +02:00
|
|
|
using Newtonsoft.Json.Linq;
|
2017-09-13 08:47:34 +02:00
|
|
|
|
2024-09-09 14:21:04 +02:00
|
|
|
|
2017-09-13 08:47:34 +02:00
|
|
|
namespace BTCPayServer.Data
|
|
|
|
{
|
2024-04-04 09:31:04 +02:00
|
|
|
public partial class InvoiceData : IHasBlobUntyped
|
2017-10-27 10:53:04 +02:00
|
|
|
{
|
2020-12-28 21:57:21 +01:00
|
|
|
public string Id { get; set; }
|
2024-04-04 09:31:04 +02:00
|
|
|
public string Currency { get; set; }
|
|
|
|
public decimal? Amount { get; set; }
|
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; }
|
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 Status { get; set; }
|
|
|
|
public string ExceptionStatus { get; set; }
|
|
|
|
public List<AddressInvoiceData> AddressInvoices { get; set; }
|
2020-05-07 12:50:07 +02:00
|
|
|
public bool Archived { 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
|
|
|
|
2024-08-27 02:53:28 +02:00
|
|
|
public static string GetOrderId(string blob) => throw new NotSupportedException();
|
|
|
|
public static string GetItemCode(string blob) => throw new NotSupportedException();
|
2024-09-17 10:28:58 +02:00
|
|
|
public static bool IsPending(string status) => throw new NotSupportedException();
|
2024-08-27 02:53:28 +02:00
|
|
|
|
2024-09-17 10:28:58 +02:00
|
|
|
[Timestamp]
|
2023-12-20 10:41:28 +01:00
|
|
|
// With this, update of InvoiceData will fail if the row was modified by another process
|
|
|
|
public uint XMin { get; set; }
|
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);
|
2022-05-18 08:44:58 +02:00
|
|
|
builder.Entity<InvoiceData>().HasIndex(o => o.Created);
|
2024-04-15 12:08:25 +02:00
|
|
|
builder.Entity<InvoiceData>()
|
|
|
|
.Property(o => o.Blob2)
|
|
|
|
.HasColumnType("JSONB");
|
|
|
|
builder.Entity<InvoiceData>()
|
|
|
|
.Property(o => o.Amount)
|
|
|
|
.HasColumnType("NUMERIC");
|
2024-08-27 02:53:28 +02:00
|
|
|
builder.HasDbFunction(typeof(InvoiceData).GetMethod(nameof(GetOrderId), new[] { typeof(string) }), b => b.HasName("get_orderid"));
|
|
|
|
builder.HasDbFunction(typeof(InvoiceData).GetMethod(nameof(GetItemCode), new[] { typeof(string) }), b => b.HasName("get_itemcode"));
|
2024-09-17 10:28:58 +02:00
|
|
|
builder.HasDbFunction(typeof(InvoiceData).GetMethod(nameof(IsPending), new[] { typeof(string) }), b => b.HasName("is_pending"));
|
|
|
|
}
|
2017-10-27 10:53:04 +02:00
|
|
|
}
|
2017-09-13 08:47:34 +02:00
|
|
|
}
|