From 16db72e6a30621771d0cef9542d12d5e0fef1720 Mon Sep 17 00:00:00 2001 From: Piotr Dudek Date: Mon, 23 Sep 2024 15:06:47 +0200 Subject: [PATCH] Rozb Fixes --- FKGees/DocsDefinitions/Decrets/Rozb.cs | 4 +-- FKGees/Services/PcmService.cs | 40 ++++++++++++++++++++------ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/FKGees/DocsDefinitions/Decrets/Rozb.cs b/FKGees/DocsDefinitions/Decrets/Rozb.cs index 605288f..3d72fe5 100644 --- a/FKGees/DocsDefinitions/Decrets/Rozb.cs +++ b/FKGees/DocsDefinitions/Decrets/Rozb.cs @@ -34,7 +34,7 @@ public class Rozb : IDecretsDefinition foreach (var dok in toProcess) { - var opis = _pcmService.RozbNrFakturyKor(dok.DokId); + var opis = _pcmService.RozbNrFakturyDost(dok.DokId); Definitions.ForEach(d => { var item = dok.DecretKontr(); @@ -63,7 +63,7 @@ public class Rozb : IDecretsDefinition "[zbr]" => (doc.Netto + doc.Podatek), "[sbr]" => doc.NettoDet + doc.PodatekDet, "[svr]" => doc.PodatekDet, - "[sbr]-[znr]" => doc.NettoDet + doc.PodatekDet - doc.Netto, + "[sbr]-[znr]" => doc.NettoDet - doc.Netto, _ => 0 }; } diff --git a/FKGees/Services/PcmService.cs b/FKGees/Services/PcmService.cs index 8839bc7..98bf37f 100644 --- a/FKGees/Services/PcmService.cs +++ b/FKGees/Services/PcmService.cs @@ -26,7 +26,7 @@ public class PcmService .ThenInclude(x => x.Dok) .Include(x => x.DokKasa) .ThenInclude(x => x.Kasa) - .Where(x => typdok.Contains(x.TypDok) + .Where(x => typdok.Contains(x.TypDok) && x.Data >= dataOd && x.Data <= dataDo && x.Aktywny == 1) .ToListAsync(); @@ -43,7 +43,7 @@ public class PcmService .ThenInclude(x => x.Kontr) .Include(x => x.TekstDok) .Include(x => x.RozbicieDok) - .Where(x => typdok.Contains(x.TypDok) + .Where(x => typdok.Contains(x.TypDok) && x.Data >= dataOd && x.Data <= dataDo && x.Aktywny == 1) .ToListAsync(); @@ -75,16 +75,40 @@ public class PcmService return dok?.Dok.NrDok ?? string.Empty; } + public string RozbNrFakturyDost(decimal dokId) + { + using var context = _dbContextFactory.CreateDbContext(); + context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; + + var dok = context.Rozlicza + .Where(x => x.RozliczanyDokId == dokId) + .Include(x => x.Dok) + .FirstOrDefault(); + + if (dok == null) + return string.Empty; + + var dok2 = context.Rozlicza + .Where(x => x.DokId == dok.DokId) + .Include(x => x.RozliczanyDok) + .Include(rozlicza => rozlicza.Dok) + .ToList(); + + return dok2.FirstOrDefault(x => x.RozliczanyDok is {TypDok: 31, Aktywny: 1}) + ?.RozliczanyDok.NrDok ?? string.Empty; + } + public async Task> FormyPlatnosci() { await using var context = await _dbContextFactory.CreateDbContextAsync(); context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; - var fplat = await context.FormaPlatnosci.Where(x => x.FormaPlat > 4).ToListAsync(); - fplat.Add(new FormaPlatnosci{ FormaPlat = 0, Tekst = "Gotówka"}); - fplat.Add(new FormaPlatnosci{ FormaPlat = 1, Tekst = "Przelew"}); - fplat.Add(new FormaPlatnosci{ FormaPlat = 2, Tekst = "Czek potwierdzony"}); - fplat.Add(new FormaPlatnosci{ FormaPlat = 3, Tekst = "Karta płatnicza"}); - fplat.Add(new FormaPlatnosci{ FormaPlat = 4, Tekst = "Inna"}); + var fplat = await context.FormaPlatnosci.Where(x => x.FormaPlat > 4) + .ToListAsync(); + fplat.Add(new FormaPlatnosci {FormaPlat = 0, Tekst = "Gotówka"}); + fplat.Add(new FormaPlatnosci {FormaPlat = 1, Tekst = "Przelew"}); + fplat.Add(new FormaPlatnosci {FormaPlat = 2, Tekst = "Czek potwierdzony"}); + fplat.Add(new FormaPlatnosci {FormaPlat = 3, Tekst = "Karta płatnicza"}); + fplat.Add(new FormaPlatnosci {FormaPlat = 4, Tekst = "Inna"}); return fplat; } } \ No newline at end of file