Models: Add payment_member
This commit is contained in:
@ -43,6 +43,7 @@ namespace Elwig.Helpers {
|
|||||||
public DbSet<DeliveryPartAttr> DeliveryPartAttributes { get; private set; }
|
public DbSet<DeliveryPartAttr> DeliveryPartAttributes { get; private set; }
|
||||||
public DbSet<DeliveryPartModifier> DeliveryPartModifiers { get; private set; }
|
public DbSet<DeliveryPartModifier> DeliveryPartModifiers { get; private set; }
|
||||||
public DbSet<PaymentVar> PaymentVariants { get; private set; }
|
public DbSet<PaymentVar> PaymentVariants { get; private set; }
|
||||||
|
public DbSet<PaymentMember> MemberPayments { get; private set; }
|
||||||
|
|
||||||
private readonly StreamWriter? LogFile = null;
|
private readonly StreamWriter? LogFile = null;
|
||||||
public static DateTime LastWriteTime => File.GetLastWriteTime(App.Config.DatabaseFile);
|
public static DateTime LastWriteTime => File.GetLastWriteTime(App.Config.DatabaseFile);
|
||||||
|
@ -19,12 +19,8 @@ namespace Elwig.Models {
|
|||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public DateOnly Date {
|
public DateOnly Date {
|
||||||
get {
|
get => DateOnly.ParseExact(DateString, "yyyy-MM-dd");
|
||||||
return DateOnly.ParseExact(DateString, "yyyy-MM-dd");
|
set => DateString = value.ToString("yyyy-MM-dd");
|
||||||
}
|
|
||||||
set {
|
|
||||||
DateString = value.ToString("yyyy-MM-dd");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Column("time")]
|
[Column("time")]
|
||||||
@ -32,19 +28,13 @@ namespace Elwig.Models {
|
|||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public TimeOnly? Time {
|
public TimeOnly? Time {
|
||||||
get {
|
get => (TimeString == null) ? null : TimeOnly.ParseExact(TimeString, "HH:mm:ss");
|
||||||
return (TimeString == null) ? null : TimeOnly.ParseExact(TimeString, "HH:mm:ss");
|
set => TimeString = value?.ToString("HH:mm:ss");
|
||||||
}
|
|
||||||
set {
|
|
||||||
TimeString = value?.ToString("HH:mm:ss");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public DateTime DateTime {
|
public DateTime DateTime {
|
||||||
get {
|
get => Date.ToDateTime(Time ?? TimeOnly.MinValue);
|
||||||
return Date.ToDateTime(Time ?? TimeOnly.MinValue);
|
|
||||||
}
|
|
||||||
set {
|
set {
|
||||||
Date = DateOnly.FromDateTime(value);
|
Date = DateOnly.FromDateTime(value);
|
||||||
Time = TimeOnly.FromDateTime(value);
|
Time = TimeOnly.FromDateTime(value);
|
||||||
@ -72,6 +62,9 @@ namespace Elwig.Models {
|
|||||||
[Column("comment")]
|
[Column("comment")]
|
||||||
public string? Comment { get; set; }
|
public string? Comment { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("Year")]
|
||||||
|
public virtual Season Season { get; private set; }
|
||||||
|
|
||||||
[InverseProperty("Delivery")]
|
[InverseProperty("Delivery")]
|
||||||
public virtual ISet<DeliveryPart> Parts { get; private set; }
|
public virtual ISet<DeliveryPart> Parts { get; private set; }
|
||||||
|
|
||||||
|
31
Elwig/Models/PaymentMember.cs
Normal file
31
Elwig/Models/PaymentMember.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
@ -65,5 +65,8 @@ namespace Elwig.Models {
|
|||||||
|
|
||||||
[Column("data")]
|
[Column("data")]
|
||||||
public string Data { get; set; }
|
public string Data { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("Year")]
|
||||||
|
public virtual Season Season { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,9 @@ namespace Elwig.Models {
|
|||||||
|
|
||||||
public string CommentFormat => (Comment != null) ? $" ({Comment})" : "";
|
public string CommentFormat => (Comment != null) ? $" ({Comment})" : "";
|
||||||
|
|
||||||
|
public bool IsRed => Type == "R";
|
||||||
|
public bool IsWhite => Type == "W";
|
||||||
|
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user