Models: Small payment fixes
This commit is contained in:
@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace Elwig.Models {
|
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 {
|
public class PaymentMember {
|
||||||
[Column("year")]
|
[Column("year")]
|
||||||
public int Year { get; set; }
|
public int Year { get; set; }
|
||||||
@ -16,6 +16,9 @@ namespace Elwig.Models {
|
|||||||
[Column("amount")]
|
[Column("amount")]
|
||||||
public long AmountValue { get; set; }
|
public long AmountValue { get; set; }
|
||||||
|
|
||||||
|
[Column("tgnr")]
|
||||||
|
public int? TgNr { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public decimal Amount {
|
public decimal Amount {
|
||||||
get => Variant.Season.DecFromDb(AmountValue);
|
get => Variant.Season.DecFromDb(AmountValue);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace Elwig.Models {
|
namespace Elwig.Models {
|
||||||
@ -19,12 +20,17 @@ 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("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")]
|
[Column("test_variant")]
|
||||||
@ -68,5 +74,8 @@ namespace Elwig.Models {
|
|||||||
|
|
||||||
[ForeignKey("Year")]
|
[ForeignKey("Year")]
|
||||||
public virtual Season Season { get; private set; }
|
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")]
|
[InverseProperty("Season")]
|
||||||
public virtual ISet<Modifier> Modifiers { get; private set; }
|
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) {
|
public decimal DecFromDb(long value) {
|
||||||
return Utils.DecFromDb(value, Precision);
|
return Utils.DecFromDb(value, Precision);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user