53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
namespace FKGees.DocsDefinitions;
|
|
|
|
public class Wz : IDocumentDefinition
|
|
{
|
|
public int DocType => 2;
|
|
public string Type => "Wz";
|
|
public List<Definition> Definitions { get; } =
|
|
[
|
|
new Definition("305-60-24", "MA", "[znr]"),
|
|
new Definition("342-0-24", "MA", "[snr]-[znr]"),
|
|
new Definition("343-0-24", "MA", "[sbr]-[snr]"),
|
|
new Definition("332-0-24", "WN", "[sbr]")
|
|
];
|
|
|
|
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.FillKontr();
|
|
item.Data = dok.DataPom.ToString(Constants.DefaultdateFormat);
|
|
item.DataWplywu = dok.Data.ToString(Constants.DefaultdateFormat);
|
|
item.Nr = dok.NrDok;
|
|
item.Opis = dok.NrDok;
|
|
item.StronaKonta = d.AccountSide;
|
|
item.KontoFk = d.Account;
|
|
item.Kwota = ProcessValue(dok, d.Expression);
|
|
|
|
result.Add(item);
|
|
});
|
|
}
|
|
|
|
return Task.FromResult(result);
|
|
}
|
|
|
|
private static decimal ProcessValue(Dok doc, string expression)
|
|
{
|
|
return expression switch
|
|
{
|
|
"[znr]" => doc.NettoMag,
|
|
"[snr]-[znr]" => doc.Netto - doc.NettoMag,
|
|
"[sbr]-[snr]" => doc.Podatek,
|
|
"[sbr]" => doc.Netto + doc.Podatek,
|
|
_ => 0
|
|
};
|
|
}
|
|
} |