Korekta cen zakupu
This commit is contained in:
parent
625a679b88
commit
43656d1d55
@ -5,6 +5,7 @@ namespace FKGees
|
|||||||
internal static class Constants
|
internal static class Constants
|
||||||
{
|
{
|
||||||
public const string DefaultDateFormat = "yyyy-MM-dd";
|
public const string DefaultDateFormat = "yyyy-MM-dd";
|
||||||
|
|
||||||
public static class DbConfig
|
public static class DbConfig
|
||||||
{
|
{
|
||||||
public const string Host = "DbSettings:Host";
|
public const string Host = "DbSettings:Host";
|
||||||
@ -22,7 +23,7 @@ namespace FKGees
|
|||||||
{nameof(KwUtarg), "*WYPŁATA DO BANKU*"},
|
{nameof(KwUtarg), "*WYPŁATA DO BANKU*"},
|
||||||
{nameof(KwInne), "*INNE*"},
|
{nameof(KwInne), "*INNE*"},
|
||||||
{nameof(KwPomylkaKasjera), "*POMYŁKA*"},
|
{nameof(KwPomylkaKasjera), "*POMYŁKA*"},
|
||||||
{nameof(KwLotto), "*LOTTO*"},
|
{nameof(KwLotto), "*LOTTO*"}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly Dictionary<string, string> KpTekstyDod = new()
|
public static readonly Dictionary<string, string> KpTekstyDod = new()
|
||||||
@ -33,7 +34,12 @@ namespace FKGees
|
|||||||
{nameof(KpInne), "*INNE*"},
|
{nameof(KpInne), "*INNE*"},
|
||||||
{nameof(KpPaysafe), "*PAYSAFE*"},
|
{nameof(KpPaysafe), "*PAYSAFE*"},
|
||||||
{nameof(KpLotto), "*LOTTO*"},
|
{nameof(KpLotto), "*LOTTO*"},
|
||||||
|
};
|
||||||
|
|
||||||
|
public static readonly Dictionary<string, string> TekstPowodKorekty = new()
|
||||||
|
{
|
||||||
|
{nameof(KorCenZak), "korekta ilości"},
|
||||||
|
{nameof(Rozb), "korekta ceny"},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
70
FKGees/DocsDefinitions/Decrets/KorCenZak.cs
Normal file
70
FKGees/DocsDefinitions/Decrets/KorCenZak.cs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
using FKGees.Services;
|
||||||
|
|
||||||
|
namespace FKGees.DocsDefinitions.Decrets;
|
||||||
|
|
||||||
|
public class KorCenZak : IDecretsDefinition
|
||||||
|
{
|
||||||
|
public int DocType => 26;
|
||||||
|
public string Type => "KorCenZak";
|
||||||
|
public List<Definition> Definitions { get; } =
|
||||||
|
[
|
||||||
|
new Definition("361-0-24", "WN", "[znr]"),
|
||||||
|
new Definition("221-0-24", "WN", "[zvr]"),
|
||||||
|
new Definition("210-1", "MA", "[zbr]"),
|
||||||
|
new Definition("301-0-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]")
|
||||||
|
];
|
||||||
|
|
||||||
|
private readonly PcmService _pcmService;
|
||||||
|
|
||||||
|
public KorCenZak(PcmService pcmService)
|
||||||
|
{
|
||||||
|
_pcmService = pcmService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<List<DecretsResult>> Process(IReadOnlyList<Dok> documents)
|
||||||
|
{
|
||||||
|
var result = new List<DecretsResult>();
|
||||||
|
|
||||||
|
var toProcess = documents
|
||||||
|
.Where(x => x.TypDok == DocType
|
||||||
|
&& x.PowodKorekty().Contains(Constants.TekstPowodKorekty[nameof(KorCenZak)]));
|
||||||
|
|
||||||
|
foreach (var dok in toProcess)
|
||||||
|
{
|
||||||
|
var opis = _pcmService.RozbNrFakturyKor(dok.DokId);
|
||||||
|
Definitions.ForEach(d =>
|
||||||
|
{
|
||||||
|
var item = dok.DecretKontr();
|
||||||
|
item.Data = dok.DataPom;
|
||||||
|
item.DataWplywu = dok.Data;
|
||||||
|
item.Nr = dok.NrDok;
|
||||||
|
item.Opis = opis;
|
||||||
|
item.StronaKonta = d.AccountSide;
|
||||||
|
item.KontoFk = d.Account;
|
||||||
|
item.Kwota = Processvalue(dok, d.Expression)
|
||||||
|
.AsString();
|
||||||
|
|
||||||
|
result.Add(item);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.FromResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static decimal Processvalue(Dok doc, string expression)
|
||||||
|
{
|
||||||
|
return expression switch
|
||||||
|
{
|
||||||
|
"[znr]" => doc.Netto,
|
||||||
|
"[zvr]" => doc.Podatek,
|
||||||
|
"[zbr]" => doc.Netto + doc.Podatek,
|
||||||
|
"[sbr]" => doc.NettoDet + doc.PodatekDet,
|
||||||
|
"[snr]-[znr]" => doc.NettoDet - doc.Netto,
|
||||||
|
"[sbr]-[snr]" => doc.NettoDet + doc.PodatekDet - doc.Netto,
|
||||||
|
_ => 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -29,7 +29,8 @@ public class Rozb : IDecretsDefinition
|
|||||||
var result = new List<DecretsResult>();
|
var result = new List<DecretsResult>();
|
||||||
|
|
||||||
var toProcess = documents
|
var toProcess = documents
|
||||||
.Where(x => x.TypDok == DocType);
|
.Where(x => x.TypDok == DocType
|
||||||
|
&& x.PowodKorekty().Contains(Constants.TekstPowodKorekty[nameof(Rozb)]));
|
||||||
|
|
||||||
foreach (var dok in toProcess)
|
foreach (var dok in toProcess)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -48,4 +48,9 @@ internal static class DokExtensions
|
|||||||
return dok.TekstDok.FirstOrDefault(x => x.Znaczenie == 71)?.Tekst ?? string.Empty;
|
return dok.TekstDok.FirstOrDefault(x => x.Znaczenie == 71)?.Tekst ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string PowodKorekty(this Dok dok)
|
||||||
|
{
|
||||||
|
return dok.TekstDok.FirstOrDefault(x => x.Znaczenie == 144)?.Tekst ?? string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -31,8 +31,9 @@ internal static class ServiceCollectionExtensions
|
|||||||
services.AddSingleton<IDecretsDefinition, KpLotto>();
|
services.AddSingleton<IDecretsDefinition, KpLotto>();
|
||||||
services.AddSingleton<IDecretsDefinition, KpPaysafe>();
|
services.AddSingleton<IDecretsDefinition, KpPaysafe>();
|
||||||
services.AddSingleton<IDecretsDefinition, KpRachunki>();
|
services.AddSingleton<IDecretsDefinition, KpRachunki>();
|
||||||
services.AddSingleton<IDecretsDefinition, Rozb>();
|
|
||||||
services.AddSingleton<IDecretsDefinition, Zwroty>();
|
services.AddSingleton<IDecretsDefinition, Zwroty>();
|
||||||
|
services.AddSingleton<IDecretsDefinition, Rozb>();
|
||||||
|
services.AddSingleton<IDecretsDefinition, KorCenZak>();
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user