Poprawki - utarg i opakowania
This commit is contained in:
parent
44b37587d9
commit
24afd2b0f0
@ -12,6 +12,7 @@ namespace FKGees
|
||||
public const string Login = "DbSettings:Login";
|
||||
public const string Password = "DbSettings:Password";
|
||||
public const string Database = "DbSettings:Database";
|
||||
public const string Timeout = "DbSettings:Timeout";
|
||||
}
|
||||
|
||||
public static readonly Dictionary<string, string> KwTekstyDod = new()
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
namespace FKGees;
|
||||
namespace FKGees;
|
||||
|
||||
public class Context
|
||||
{
|
||||
@ -8,4 +6,6 @@ public class Context
|
||||
public DateTime StatDate { get; set; } = DateTime.Today - TimeSpan.FromDays(1);
|
||||
public DateTime EndDate { get; set; } = DateTime.Today - TimeSpan.FromSeconds(1);
|
||||
public List<FormaPlatnosci> PaymentForms { get; set; } = new();
|
||||
public string RegistersFileName { get; set; }
|
||||
public string DecretsFileName { get; set; }
|
||||
}
|
||||
@ -15,7 +15,9 @@ public class KpKaucjaZDokUtargu : IDecretsDefinition
|
||||
var result = new List<DecretsResult>();
|
||||
|
||||
var toProcess = documents
|
||||
.Where(x => x.TypDok == DocType && x.Kwota1 != 0);
|
||||
.Where(x => x.TypDok == DocType && x.Kwota1 != 0)
|
||||
.GroupBy(x => x.Data);
|
||||
|
||||
|
||||
foreach (var dok in toProcess)
|
||||
{
|
||||
@ -23,13 +25,13 @@ public class KpKaucjaZDokUtargu : IDecretsDefinition
|
||||
{
|
||||
var item = new DecretsResult
|
||||
{
|
||||
Data = dok.DataPom,
|
||||
DataWplywu = dok.Data,
|
||||
Nr = dok.NrDok,
|
||||
Opis = $"KAUCJA ZA OPAKOWANIA {dok.DokKasa?.Kasa.Nazwa ?? string.Empty}",
|
||||
Data = dok.Key,
|
||||
DataWplywu = dok.Key,
|
||||
Nr = string.Join(", ",dok.Select(z => z.NrDok)),
|
||||
Opis = "KAUCJA ZA OPAKOWANIA-SPRZEDAŻ",
|
||||
StronaKonta = d.AccountSide,
|
||||
KontoFk = d.Account,
|
||||
Kwota = dok.Kwota1.AsString()
|
||||
Kwota = dok.Sum(x => x.Kwota1).AsString()
|
||||
};
|
||||
|
||||
result.Add(item);
|
||||
|
||||
43
FKGees/DocsDefinitions/Decrets/KwKaucjaZDokUtargu.cs
Normal file
43
FKGees/DocsDefinitions/Decrets/KwKaucjaZDokUtargu.cs
Normal file
@ -0,0 +1,43 @@
|
||||
namespace FKGees.DocsDefinitions.Decrets;
|
||||
|
||||
public class KwKaucjaZDokUtargu : IDecretsDefinition
|
||||
{
|
||||
public int DocType => 53;
|
||||
public string Type => nameof(KwKaucjaZDokUtargu);
|
||||
public List<Definition> Definitions { get; } =
|
||||
[
|
||||
new Definition("100-1-24", "MA", "[sbr]"),
|
||||
new Definition("139-1-24", "WN", "[sbr]")
|
||||
];
|
||||
|
||||
public Task<List<DecretsResult>> Process(IReadOnlyList<Dok> documents)
|
||||
{
|
||||
var result = new List<DecretsResult>();
|
||||
|
||||
var toProcess = documents
|
||||
.Where(x => x.TypDok == DocType && x.Kwota2 != 0)
|
||||
.GroupBy(x => x.Data);
|
||||
|
||||
|
||||
foreach (var dok in toProcess)
|
||||
{
|
||||
Definitions.ForEach(d =>
|
||||
{
|
||||
var item = new DecretsResult
|
||||
{
|
||||
Data = dok.Key,
|
||||
DataWplywu = dok.Key,
|
||||
Nr = string.Join(", ",dok.Select(z => z.NrDok)),
|
||||
Opis = "KAUCJA ZA OPAKOWANIA-ZWROT",
|
||||
StronaKonta = d.AccountSide,
|
||||
KontoFk = d.Account,
|
||||
Kwota = dok.Sum(x => x.Kwota2).AsString()
|
||||
};
|
||||
|
||||
result.Add(item);
|
||||
});
|
||||
}
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
}
|
||||
@ -51,8 +51,8 @@ public class RapFisk : IDecretsDefinition
|
||||
{
|
||||
return expression switch
|
||||
{
|
||||
"[sbr]" => doc.Netto+ doc.Podatek + doc.NettoUslugi + doc.PodatekUslugi,
|
||||
"[svr]" => doc.Podatek + doc.PodatekUslugi,
|
||||
"[sbr]" => doc.Razem - doc.Kwota1 + doc.Kwota2,
|
||||
"[svr]" => doc.Podatek,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
public class Wz : IDecretsDefinition
|
||||
{
|
||||
public int DocType => 2;
|
||||
public int DocType => 5;
|
||||
public string Type => "Wz";
|
||||
public List<Definition> Definitions { get; } =
|
||||
[
|
||||
|
||||
@ -27,6 +27,7 @@ internal static class ServiceCollectionExtensions
|
||||
services.AddSingleton<IDecretsDefinition, KpKasy>();
|
||||
services.AddSingleton<IDecretsDefinition, KpKaucjaZaOpakowania>();
|
||||
services.AddSingleton<IDecretsDefinition, KpKaucjaZDokUtargu>();
|
||||
services.AddSingleton<IDecretsDefinition, KwKaucjaZDokUtargu>();
|
||||
services.AddSingleton<IDecretsDefinition, KpLotto>();
|
||||
services.AddSingleton<IDecretsDefinition, KpPaysafe>();
|
||||
services.AddSingleton<IDecretsDefinition, KpRachunki>();
|
||||
|
||||
@ -62,10 +62,21 @@ static IServiceCollection AddServices(IConfiguration config)
|
||||
{
|
||||
var connectionString =
|
||||
$"Server={config[Constants.DbConfig.Host]},{config[Constants.DbConfig.Port]};Database={config[Constants.DbConfig.Database]};User Id={config[Constants.DbConfig.Login]}; Password={config[Constants.DbConfig.Password]};TrustServerCertificate=True";
|
||||
var symbolMag = config["SymbolMag"] ?? string.Empty;
|
||||
var context = new Context();
|
||||
context.SymbolMag = symbolMag;
|
||||
|
||||
if (!int.TryParse(config[Constants.DbConfig.Timeout], out var dbTimeout) || dbTimeout < 30)
|
||||
{
|
||||
dbTimeout = 30;
|
||||
}
|
||||
|
||||
var symbolMag = config["SymbolMag"] ?? string.Empty;
|
||||
var nazwaPlikuRejestry = config["NazwaPlikuRejestry"] ?? "rejestry.txt";
|
||||
var nazwaPlikuDekrety = config["NazwaPlikuDekrety"] ?? "dekrety.txt";
|
||||
var context = new Context
|
||||
{
|
||||
SymbolMag = symbolMag,
|
||||
RegistersFileName = nazwaPlikuRejestry,
|
||||
DecretsFileName = nazwaPlikuDekrety
|
||||
};
|
||||
|
||||
var services = new ServiceCollection()
|
||||
.AddLogging(loggingBuilder =>
|
||||
@ -84,7 +95,10 @@ static IServiceCollection AddServices(IConfiguration config)
|
||||
.AddTransient<PcmService>()
|
||||
.AddDbContextFactory<PcmDbContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(connectionString);
|
||||
options.UseSqlServer(connectionString, o =>
|
||||
{
|
||||
o.CommandTimeout(dbTimeout);
|
||||
});
|
||||
options.UseModel(Blink.Backoffice.Services.PcmDb.CompiledEntities.PcmDbContextModel.Instance);
|
||||
options.EnableSensitiveDataLogging(false);
|
||||
});
|
||||
|
||||
@ -22,6 +22,8 @@ internal class DecretsService
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("DecretsService - Start exports decrets, StartDate: {StartDate}, EndDate: {EndDate}", _context.StatDate , _context.EndDate);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Export dekretów");
|
||||
var doctypes = _definitions.Select(x => x.DocType)
|
||||
.ToArray();
|
||||
|
||||
@ -39,7 +41,7 @@ internal class DecretsService
|
||||
_logger.LogInformation("DecretsService - Export success");
|
||||
Console.WriteLine("Eksport do pliku dekretów");
|
||||
Console.WriteLine();
|
||||
await _csvService.CsvExport("Export/dekrety.csv", result.OrderBy(x => x.Data).ThenBy(x => x.Nr));
|
||||
await _csvService.CsvExport($"Export/{_context.DecretsFileName}", result.OrderBy(x => x.Data).ThenBy(x => x.Nr));
|
||||
Console.WriteLine("Eksport do pliku dekretów zakończony powodzeniem");
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@ -22,10 +22,16 @@ internal class RegistersService
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("RegistersService - Start exports registers, StartDate: {StartDate}, EndDate: {EndDate}", _context.StatDate , _context.EndDate);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Export rejestrów");
|
||||
|
||||
var result = new List<RegistersResult>();
|
||||
|
||||
foreach (var definition in _definitions)
|
||||
{
|
||||
_logger.LogInformation("RegistersService - Export type: {Type}", definition.Type);
|
||||
Console.WriteLine($"Export: {definition.Type}");
|
||||
var docs = await _pcmService.FetchRegistersDocuments(definition.DocTypes, _context.StatDate, _context.EndDate);
|
||||
result.AddRange(await definition.Process(docs));
|
||||
}
|
||||
@ -33,7 +39,7 @@ internal class RegistersService
|
||||
_logger.LogInformation("RegistersService - Export success");
|
||||
Console.WriteLine("Eksport do pliku rejestrów");
|
||||
Console.WriteLine();
|
||||
await _csvService.CsvExport("Export/rejestry.csv", result.OrderBy(x => x.dwystawienia));
|
||||
await _csvService.CsvExport($"Export/{_context.RegistersFileName}", result.OrderBy(x => x.dwystawienia));
|
||||
Console.WriteLine("Eksport do pliku rejestrów zakończony powodzeniem");
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -44,17 +50,4 @@ internal class RegistersService
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<FormaPlatnosci>> GetPaymentForms()
|
||||
{
|
||||
var paymentForms = await _pcmService.FormyPlatnosci();
|
||||
paymentForms.Add(new FormaPlatnosci {FormaPlat = 0, Tekst = "Gotówka"});
|
||||
paymentForms.Add(new FormaPlatnosci {FormaPlat = 1, Tekst = "Przelew"});
|
||||
paymentForms.Add(new FormaPlatnosci {FormaPlat = 2, Tekst = "Czek potwierdzony"});
|
||||
paymentForms.Add(new FormaPlatnosci {FormaPlat = 3, Tekst = "Karta płatnicza"});
|
||||
paymentForms.Add(new FormaPlatnosci {FormaPlat = 4, Tekst = "Inna"});
|
||||
|
||||
return paymentForms.OrderBy(x => x.FormaPlat)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
@ -11,7 +11,10 @@
|
||||
"Port": "1433",
|
||||
"Login": "sa",
|
||||
"Password": "10Coma123",
|
||||
"Database": "HECZNAROWICE"
|
||||
"Database": "HECZNAROWICE",
|
||||
"Timeout": 666
|
||||
},
|
||||
"SymbolMag": "FajnySklep"
|
||||
"SymbolMag": "FajnySklep",
|
||||
"NazwaPlikuDekrety": "dekrety.txt",
|
||||
"NazwaPlikuRejestry": "rejestry.txt"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user