namespace FKGees.DocsDefinitions.Decrets;

public class KorDetal : IDecretsDefinition
{
    public int DocType => 8;
    public string Type => "KorDetal";
    public List<Definition> Definitions { get; } = [
        new Definition("300", "MA", "[snr]"), 
        new Definition("400", "WN", "[snr]")
    ];

    public Task<List<DecretsResult>> Process(IReadOnlyList<Dok> documents)
    {
        var result = new List<DecretsResult>();

        var toProcess = documents
            .Where(x => x.TypDok == DocType);

        foreach (var dok in toProcess)
        {
            Definitions.ForEach(d =>
            {
                var item = dok.DecretKontr();
                item.Data = dok.DataPom;
                item.DataWplywu = dok.Data;
                item.Nr = dok.NrDok;
                item.Opis = dok.NrDok;
                item.StronaKonta = d.AccountSide;
                item.KontoFk = d.Account;
                item.Kwota = dok.Netto.AsString();

                result.Add(item);
            });
        }

        return Task.FromResult(result);
    }
}