Models: Small payment fixes
This commit is contained in:
@ -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);
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user