Models: Add Credit
This commit is contained in:
@ -44,6 +44,7 @@ namespace Elwig.Helpers {
|
||||
public DbSet<DeliveryPartModifier> DeliveryPartModifiers { get; private set; }
|
||||
public DbSet<PaymentVar> PaymentVariants { get; private set; }
|
||||
public DbSet<PaymentMember> MemberPayments { get; private set; }
|
||||
public DbSet<Credit> Credits { get; private set; }
|
||||
|
||||
private readonly StreamWriter? LogFile = null;
|
||||
public static DateTime LastWriteTime => File.GetLastWriteTime(App.Config.DatabaseFile);
|
||||
|
@ -21,12 +21,9 @@ namespace Elwig.Helpers.Billing {
|
||||
public static IEnumerable<Transaction> FromPaymentVariant(PaymentVar variant) {
|
||||
var last = variant.Season.PaymentVariants.Where(v => v.TransferDate != null).OrderBy(v => v.TransferDate).LastOrDefault();
|
||||
var dict = last?.MemberPayments.ToDictionary(m => m.MgNr, m => m.Amount) ?? new();
|
||||
return variant.MemberPayments
|
||||
.OrderBy(m => m.MgNr)
|
||||
.Select(m => {
|
||||
var amt = Math.Round(dict.GetValueOrDefault(m.MgNr, 0), 2);
|
||||
return new Transaction(m.Member, m.Amount - amt, m.Variant.Season.CurrencyCode, m.TgNr ?? 0);
|
||||
})
|
||||
return variant.Credits
|
||||
.OrderBy(c => c.MgNr)
|
||||
.Select(c => new Transaction(c.Member, c.Amount, variant.Season.CurrencyCode, c.TgNr))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user