diff --git a/Elwig/Models/PaymentMember.cs b/Elwig/Models/PaymentMember.cs index 56f1f43..a73e1f1 100644 --- a/Elwig/Models/PaymentMember.cs +++ b/Elwig/Models/PaymentMember.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations.Schema; namespace Elwig.Models { - [Table("payment_member"), PrimaryKey("Year", "AvNr", "MgNr")] + [Table("payment_member"), PrimaryKey("Year", "AvNr", "MgNr"), Index("Year", "TgNr", IsUnique = true)] public class PaymentMember { [Column("year")] public int Year { get; set; } @@ -16,6 +16,9 @@ namespace Elwig.Models { [Column("amount")] public long AmountValue { get; set; } + [Column("tgnr")] + public int? TgNr { get; set; } + [NotMapped] public decimal Amount { get => Variant.Season.DecFromDb(AmountValue); diff --git a/Elwig/Models/PaymentVar.cs b/Elwig/Models/PaymentVar.cs index 573fb92..13b25c7 100644 --- a/Elwig/Models/PaymentVar.cs +++ b/Elwig/Models/PaymentVar.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; namespace Elwig.Models { @@ -19,12 +20,17 @@ namespace Elwig.Models { [NotMapped] public DateOnly Date { - get { - return DateOnly.ParseExact(DateString, "yyyy-MM-dd"); - } - set { - DateString = value.ToString("yyyy-MM-dd"); - } + get => DateOnly.ParseExact(DateString, "yyyy-MM-dd"); + set => DateString = value.ToString("yyyy-MM-dd"); + } + + [Column("transfer_date")] + public string? TransferDateString { get; set; } + + [NotMapped] + public DateOnly? TransferDate { + get => TransferDateString != null ? DateOnly.ParseExact(TransferDateString, "yyyy-MM-dd") : null; + set => TransferDateString = value?.ToString("yyyy-MM-dd"); } [Column("test_variant")] @@ -68,5 +74,8 @@ namespace Elwig.Models { [ForeignKey("Year")] public virtual Season Season { get; private set; } + + [InverseProperty("Variant")] + public virtual ISet<PaymentMember> MemberPayments { get; private set; } } } diff --git a/Elwig/Models/Season.cs b/Elwig/Models/Season.cs index 23a5aec..6c6d09d 100644 --- a/Elwig/Models/Season.cs +++ b/Elwig/Models/Season.cs @@ -48,6 +48,12 @@ namespace Elwig.Models { [InverseProperty("Season")] public virtual ISet<Modifier> Modifiers { get; private set; } + [InverseProperty("Season")] + public virtual ISet<PaymentVar> PaymentVariants { get; private set; } + + [InverseProperty("Season")] + public virtual ISet<Delivery> Deliveries { get; private set; } + public decimal DecFromDb(long value) { return Utils.DecFromDb(value, Precision); }