MW Polcard

This commit is contained in:
Piotr Dudek 2024-07-08 20:07:16 +02:00
parent b1e13cfe3a
commit 10210abe89
5 changed files with 20 additions and 20 deletions

View File

@ -35,14 +35,14 @@ internal class App
}
else
{
if (!DateTime.TryParseExact(args[0], Constants.DefaultdateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out var startDate))
if (!DateTime.TryParseExact(args[0], Constants.DefaultDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out var startDate))
{
Console.WriteLine("Niewłaściwy format DataOd");
await Task.Delay(4000);
Environment.Exit(1);
}
if (!DateTime.TryParseExact(args[1], Constants.DefaultdateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out var endDate))
if (!DateTime.TryParseExact(args[1], Constants.DefaultDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out var endDate))
{
Console.WriteLine("Niewłaściwy format DataOd");
await Task.Delay(4000);

View File

@ -4,7 +4,7 @@ namespace FKGees
{
internal static class Constants
{
public const string DefaultdateFormat = "yyyy-MM-dd";
public const string DefaultDateFormat = "yyyy-MM-dd";
public static class DbConfig
{
public const string Host = "DbSettings:Host";
@ -19,8 +19,7 @@ namespace FKGees
{
{nameof(KwBony), "*BONY*"},
{nameof(KwOpakowania), "*KAUCJA ZA PRZYJĘTE*"},
{nameof(KwUtarg), "*UTARG*"},
{nameof(KwPolcard), "*POLCARD*"},
{nameof(KwUtarg), "*WYPŁATA DO BANKU*"},
{nameof(KwInne), "*INNE*"},
{nameof(KwPomylkaKasjera), "*POMYŁKA*"},
{nameof(KwLotto), "*LOTTO*"},

View File

@ -17,7 +17,6 @@ public class KpKaucjaZDokUtargu : IDecretsDefinition
var toProcess = documents
.Where(x => x.TypDok == DocType && x.Kwota1 != 0)
.GroupBy(x => x.Data);
foreach (var dok in toProcess)
{

View File

@ -2,7 +2,7 @@
public class KwPolcard : IDecretsDefinition
{
public int DocType => 51;
public int DocType => 53;
public string Type => nameof(KwPolcard);
public List<Definition> Definitions { get; } =
[
@ -14,22 +14,24 @@ public class KwPolcard : IDecretsDefinition
{
var result = new List<DecretsResult>();
var toProcess = documents.Where(x => x.TypDok == DocType
&& x.NrDok.StartsWith("KW")
&& x.Tekst1() == Constants.KwTekstyDod[nameof(KwPolcard)]);
var toProcess = documents
.Where(x => x.TypDok == DocType && x.Kwota8 != 0)
.GroupBy(x => x.Data);
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.TekstZaCo();
item.StronaKonta = d.AccountSide;
item.KontoFk = d.Account;
item.Kwota = Math.Abs(dok.Zaplacono).AsString();
var item = new DecretsResult
{
Data = dok.Key,
DataWplywu = dok.Key,
Nr = string.Join(", ",dok.Select(z => z.NrDok)),
Opis = "POLCARD",
StronaKonta = d.AccountSide,
KontoFk = d.Account,
Kwota = dok.Sum(x => x.Kwota8).AsString()
};
result.Add(item);
});

View File

@ -25,11 +25,11 @@ internal class CsvService
Mode = CsvMode.RFC4180,
ShouldQuote = quoteArgs => quoteArgs.Field != nameof(DecretsResult.Data)
&& quoteArgs.Field != nameof(DecretsResult.DataWplywu)
&& !DateTime.TryParseExact(quoteArgs.Field, Constants.DefaultdateFormat, CultureInfo.InvariantCulture,
&& !DateTime.TryParseExact(quoteArgs.Field, Constants.DefaultDateFormat, CultureInfo.InvariantCulture,
DateTimeStyles.None, out _)
};
await using var csv = new CsvWriter(writer, conf);
var options = new TypeConverterOptions { Formats = [Constants.DefaultdateFormat], NullValues = { string.Empty }};
var options = new TypeConverterOptions { Formats = [Constants.DefaultDateFormat], NullValues = { string.Empty }};
csv.Context.TypeConverterOptionsCache.AddOptions<DateTime>(options);
csv.Context.TypeConverterOptionsCache.AddOptions<DateTime?>(options);