Billing: Update EBICS exporter

This commit is contained in:
2023-12-29 13:14:32 +01:00
parent 6cf5e0d45e
commit 4738cde9e4
5 changed files with 79 additions and 93 deletions

View File

@ -0,0 +1,26 @@
using Elwig.Models.Entities;
using System.Collections.Generic;
using System.Linq;
namespace Elwig.Models.Dtos {
public class Transaction(Member member, decimal amount, string currency, int nr) {
public readonly Member Member = member;
public readonly decimal Amount = amount;
public readonly string Currency = currency;
public readonly int Nr = nr;
public Transaction(Credit c) : this(c.Member, c.Amount, c.Variant.Season.CurrencyCode, c.TgNr) { }
public static IEnumerable<Transaction> FromPaymentVariant(PaymentVar variant) {
return variant.Credits
.OrderBy(c => c.TgNr)
.Select(c => new Transaction(c))
.ToList();
}
public static string FormatAmountCent(long cents) => $"{cents / 100}.{cents % 100:00}";
public static string FormatAmount(decimal amount) => FormatAmountCent((int)(amount * 100));
}
}