Models: Add payment_member

This commit is contained in:
2023-09-07 00:40:53 +02:00
parent 1c45e95ef3
commit be734b880f
5 changed files with 47 additions and 16 deletions

View File

@ -43,6 +43,7 @@ namespace Elwig.Helpers {
public DbSet<DeliveryPartAttr> DeliveryPartAttributes { get; private set; }
public DbSet<DeliveryPartModifier> DeliveryPartModifiers { get; private set; }
public DbSet<PaymentVar> PaymentVariants { get; private set; }
public DbSet<PaymentMember> MemberPayments { get; private set; }
private readonly StreamWriter? LogFile = null;
public static DateTime LastWriteTime => File.GetLastWriteTime(App.Config.DatabaseFile);

View File

@ -19,12 +19,8 @@ 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("time")]
@ -32,19 +28,13 @@ namespace Elwig.Models {
[NotMapped]
public TimeOnly? Time {
get {
return (TimeString == null) ? null : TimeOnly.ParseExact(TimeString, "HH:mm:ss");
}
set {
TimeString = value?.ToString("HH:mm:ss");
}
get => (TimeString == null) ? null : TimeOnly.ParseExact(TimeString, "HH:mm:ss");
set => TimeString = value?.ToString("HH:mm:ss");
}
[NotMapped]
public DateTime DateTime {
get {
return Date.ToDateTime(Time ?? TimeOnly.MinValue);
}
get => Date.ToDateTime(Time ?? TimeOnly.MinValue);
set {
Date = DateOnly.FromDateTime(value);
Time = TimeOnly.FromDateTime(value);
@ -72,6 +62,9 @@ namespace Elwig.Models {
[Column("comment")]
public string? Comment { get; set; }
[ForeignKey("Year")]
public virtual Season Season { get; private set; }
[InverseProperty("Delivery")]
public virtual ISet<DeliveryPart> Parts { get; private set; }

View File

@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace Elwig.Models {
[Table("payment_member"), PrimaryKey("Year", "AvNr", "MgNr")]
public class PaymentMember {
[Column("year")]
public int Year { get; set; }
[Column("avnr")]
public int AvNr { get; set; }
[Column("mgnr")]
public int MgNr { get; set; }
[Column("amount")]
public long AmountValue { get; set; }
[NotMapped]
public decimal Amount {
get => Variant.Season.DecFromDb(AmountValue);
set => AmountValue = Variant.Season.DecToDb(value);
}
[ForeignKey("Year, AvNr")]
public virtual PaymentVar Variant { get; private set; }
[ForeignKey("MgNr")]
public virtual Member Member { get; private set; }
}
}

View File

@ -1,4 +1,4 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations.Schema;
@ -65,5 +65,8 @@ namespace Elwig.Models {
[Column("data")]
public string Data { get; set; }
[ForeignKey("Year")]
public virtual Season Season { get; private set; }
}
}

View File

@ -18,6 +18,9 @@ namespace Elwig.Models {
public string CommentFormat => (Comment != null) ? $" ({Comment})" : "";
public bool IsRed => Type == "R";
public bool IsWhite => Type == "W";
public override string ToString() {
return Name;
}