Export: Add Ebics and improve Bki export
This commit is contained in:
@ -1,14 +1,35 @@
|
||||
using Elwig.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Elwig.Helpers.Billing {
|
||||
public class Transaction {
|
||||
|
||||
public readonly Member Member;
|
||||
public readonly int AmountCent;
|
||||
public readonly long AmountCent;
|
||||
public readonly string Currency;
|
||||
public readonly int Nr;
|
||||
|
||||
public Transaction(Member m, decimal amount) {
|
||||
public Transaction(Member m, decimal amount, string currency, int nr) {
|
||||
Member = m;
|
||||
AmountCent = (int)(amount * 100);
|
||||
AmountCent = (long)Math.Round(amount * 100);
|
||||
Currency = currency;
|
||||
Nr = nr;
|
||||
}
|
||||
|
||||
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);
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public static string FormatAmountCent(long cents) => $"{cents / 100}.{cents % 100:00}";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user