feat: bank file contracts for remittances and statements (#70 #71)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-13 08:32:59 +01:00
1 parent cfca29d71c
commit 88a0c8ce9c
2 files changed
+290

No files matched your search

@@ -0,0 +1,58 @@
using Khaemhat.Core.Treasury;
namespace Khaemhat.Fiscal.Abstractions;
/// <summary>
/// Writes the national remittance files the SEPA formats do not cover (Italy: RiBa in the CBI fixed-width layout).
/// SEPA credit transfers and direct debits are written by <c>Khaemhat.Core.Treasury.SepaXmlWriter</c> for every
/// country.
/// </summary>
public interface IRemittanceFileWriter
{
/// <summary>Whether this writer writes a kind of remittance.</summary>
/// <param name="kind">The kind.</param>
/// <returns><see langword="true"/> when <see cref="Write"/> accepts it.</returns>
bool Supports(RemittanceKind kind);
/// <summary>Writes the file.</summary>
/// <param name="remittance">The remittance.</param>
/// <returns>The file.</returns>
/// <exception cref="BankFileException">A value cannot be written in the format.</exception>
BankFile Write(BankFileRemittance remittance);
}
/// <summary>
/// Reads the national bank statement format of the country (Italy: CBI). CSV and <c>camt.053</c> are read by
/// <c>Khaemhat.Core.Treasury</c> for every country.
/// </summary>
public interface IBankStatementReader
{
/// <summary>The format read.</summary>
StatementFormat Format { get; }
/// <summary>Whether the start of a file looks like this format.</summary>
/// <param name="head">The first bytes of the file (up to 4 KB).</param>
/// <returns><see langword="true"/> when <see cref="Read"/> should be tried.</returns>
bool Recognizes(ReadOnlySpan<byte> head);
/// <summary>Reads a statement.</summary>
/// <param name="content">The file.</param>
/// <returns>The statement.</returns>
/// <exception cref="BankFileException">The file is not in the format.</exception>
StatementFile Read(Stream content);
}
/// <summary>Late payment interest between companies (Italy: D.Lgs. 231/2002).</summary>
public interface ILatePaymentRules
{
/// <summary>The yearly rate, in percent, that applies to the days of a half-year.</summary>
/// <param name="day">A day.</param>
/// <returns>The reference rate of the half-year plus the margin.</returns>
decimal RateOn(DateOnly day);
/// <summary>The law the interest comes from, for the letters (Italy: <c>D.Lgs. 231/2002</c>).</summary>
string LegalReference { get; }
/// <summary>The fixed compensation for recovery costs, per invoice (Italy: 40 euro, art. 6).</summary>
decimal RecoveryCompensation { get; }
}