Compare commits

...

4 Commits

8 changed files with 29 additions and 28 deletions

View File

@ -15,7 +15,7 @@ namespace Elwig.Helpers.Billing {
public BillingVariant(int year, int avnr) : base(year) { public BillingVariant(int year, int avnr) : base(year) {
AvNr = avnr; AvNr = avnr;
PaymentVariant = Context.PaymentVariants.Find(Year, AvNr) ?? throw new ArgumentException("PaymentVar not found"); PaymentVariant = Context.PaymentVariants.Find(Year, AvNr) ?? throw new ArgumentException("PaymentVar not found");
Data = PaymentBillingData.FromJson(PaymentVariant.Data, Utils.GetAttributeVarieties(Context, Year)); Data = PaymentBillingData.FromJson(PaymentVariant.Data, Utils.GetAttributeVarieties(Context, Year, onlyDelivered: false));
} }
public async Task Calculate() { public async Task Calculate() {
@ -24,9 +24,10 @@ namespace Elwig.Helpers.Billing {
await DeleteInDb(cnx); await DeleteInDb(cnx);
await SetCalcTime(cnx); await SetCalcTime(cnx);
await CalculatePrices(cnx); await CalculatePrices(cnx);
if (Data.ConsiderDelieryModifiers) if (Data.ConsiderDelieryModifiers) {
await CalculateDeliveryModifiers(cnx); await CalculateDeliveryModifiers(cnx);
await CalculateMemberModifiers(cnx); await CalculateMemberModifiers(cnx);
}
await tx.CommitAsync(); await tx.CommitAsync();
} }

View File

@ -74,12 +74,16 @@ namespace Elwig.Helpers.Printing {
} }
public static async Task Print(string path, int copies = 1) { public static async Task Print(string path, int copies = 1) {
var p = new Process() { StartInfo = new() { FileName = PdfToPrinter } }; try {
p.StartInfo.ArgumentList.Add(path); var p = new Process() { StartInfo = new() { FileName = PdfToPrinter } };
p.StartInfo.ArgumentList.Add("/s"); p.StartInfo.ArgumentList.Add(path);
p.StartInfo.ArgumentList.Add($"copies={copies}"); p.StartInfo.ArgumentList.Add("/s");
p.Start(); p.StartInfo.ArgumentList.Add($"copies={copies}");
await p.WaitForExitAsync(); p.Start();
await p.WaitForExitAsync();
} catch (Exception e) {
MessageBox.Show("Beim Drucken ist ein Fehler aufgetreten:\n\n" + e.Message, "Fehler beim Drucken");
}
} }
} }
} }

View File

@ -362,25 +362,21 @@ namespace Elwig.Helpers {
return output.OrderByDescending(l => l.Count()); return output.OrderByDescending(l => l.Count());
} }
public static List<string> GetAttributeVarieties(AppDbContext ctx, int year, bool withSlash = false) { public static List<string> GetAttributeVarieties(AppDbContext ctx, int year, bool withSlash = false, bool onlyDelivered = true) {
return ctx.DeliveryParts var varieties = ctx.WineVarieties.Select(v => v.SortId).ToList();
var delivered = ctx.DeliveryParts
.Where(d => d.Year == year) .Where(d => d.Year == year)
.Select(d => $"{d.SortId}{(withSlash ? "/" : "")}{d.AttrId}") .Select(d => $"{d.SortId}{(withSlash ? "/" : "")}{d.AttrId}")
.Distinct() .Distinct()
.ToList()
.Union(ctx.WineVarieties.Select(v => v.SortId))
.ToList(); .ToList();
return [.. (onlyDelivered ? delivered : delivered.Union(varieties)).Order()];
} }
public static List<ContractSelection> GetContractsForYear(AppDbContext ctx, int year) { public static List<ContractSelection> GetContractsForYear(AppDbContext ctx, int year, bool onlyDelivered = true) {
return ctx.DeliveryParts var varieties = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v);
.Where(p => p.Year == year) var attributes = ctx.WineAttributes.ToDictionary(a => a.AttrId, a => a);
.Select(d => new ContractSelection(d.Variant, d.Attribute)) return GetAttributeVarieties(ctx, year, false, onlyDelivered)
.Distinct() .Select(s => new ContractSelection(varieties[s[..2]], s.Length > 2 ? attributes[s[2..]] : null))
.ToList()
.Union(ctx.WineVarieties.Select(v => new ContractSelection(v, null)))
.DistinctBy(c => c.Listing)
.Order()
.ToList(); .ToList();
} }
} }

View File

@ -635,7 +635,7 @@ namespace Elwig.Windows {
private async void SaveButton_Click(object sender, RoutedEventArgs e) { private async void SaveButton_Click(object sender, RoutedEventArgs e) {
var origData = BillingData.FromJson(PaymentVar.Data); var origData = BillingData.FromJson(PaymentVar.Data);
var data = BillingData.FromGraphEntries(GraphEntries, origData, Utils.GetAttributeVarieties(Context, Year, true)); var data = BillingData.FromGraphEntries(GraphEntries, origData, Utils.GetAttributeVarieties(Context, Year, withSlash: true));
EntityEntry<PaymentVar>? tr = null; EntityEntry<PaymentVar>? tr = null;
try { try {

View File

@ -1,5 +1,5 @@
::mkdir "C:\Program Files\Elwig" ::mkdir "C:\Program Files\Elwig"
::curl -s "http://www.columbia.edu/~em36/PDFtoPrinter.exe" -z "C:\Program Files\Elwig\PDFtoPrinter.exe" -o "C:\Program Files\Elwig\PDFtoPrinter.exe" ::curl -s -L "http://www.columbia.edu/~em36/PDFtoPrinter.exe" -z "C:\Program Files\Elwig\PDFtoPrinter.exe" -o "C:\Program Files\Elwig\PDFtoPrinter.exe"
mkdir "C:\ProgramData\Elwig\resources" mkdir "C:\ProgramData\Elwig\resources"
copy /b /y Documents\*.css "C:\ProgramData\Elwig\resources" copy /b /y Documents\*.css "C:\ProgramData\Elwig\resources"
copy /b /y Documents\*.cshtml "C:\ProgramData\Elwig\resources" copy /b /y Documents\*.cshtml "C:\ProgramData\Elwig\resources"

View File

@ -25,7 +25,7 @@
</Task> </Task>
</UsingTask> </UsingTask>
<Target Name="CustomBeforeBuild" BeforeTargets="BeforeBuild"> <Target Name="CustomBeforeBuild" BeforeTargets="BeforeBuild">
<Exec Command="curl -s &quot;http://www.columbia.edu/~em36/PDFtoPrinter.exe&quot; -z &quot;$(TargetDir)PDFtoPrinter.exe&quot; -o &quot;$(TargetDir)PDFtoPrinter.exe&quot;" /> <Exec Command="curl -s -L &quot;http://www.columbia.edu/~em36/PDFtoPrinter.exe&quot; -z &quot;$(TargetDir)PDFtoPrinter.exe&quot; -o &quot;$(TargetDir)PDFtoPrinter.exe&quot;" />
<Exec Command="dotnet publish &quot;$(SolutionDir)Elwig\Elwig.csproj&quot; &quot;/p:PublishProfile=$(SolutionDir)\Elwig\Properties\PublishProfiles\FolderProfile.pubxml&quot;" /> <Exec Command="dotnet publish &quot;$(SolutionDir)Elwig\Elwig.csproj&quot; &quot;/p:PublishProfile=$(SolutionDir)\Elwig\Properties\PublishProfiles\FolderProfile.pubxml&quot;" />
<GetFileVersion AssemblyPath="..\Elwig\bin\Publish\Elwig.exe"> <GetFileVersion AssemblyPath="..\Elwig\bin\Publish\Elwig.exe">
<Output TaskParameter="Version" PropertyName="ElwigFileVersion" /> <Output TaskParameter="Version" PropertyName="ElwigFileVersion" />

View File

@ -5,8 +5,8 @@
<Cultures>de-AT</Cultures> <Cultures>de-AT</Cultures>
</PropertyGroup> </PropertyGroup>
<Target Name="CustomBeforeBuild" BeforeTargets="BeforeBuild"> <Target Name="CustomBeforeBuild" BeforeTargets="BeforeBuild">
<Exec Command='curl -L -s "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -z "$(TargetDir)MicrosoftEdgeWebview2Setup.exe" -o "$(TargetDir)MicrosoftEdgeWebview2Setup.exe"' /> <Exec Command='curl -s -L "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -z "$(TargetDir)MicrosoftEdgeWebview2Setup.exe" -o "$(TargetDir)MicrosoftEdgeWebview2Setup.exe"' />
<Exec Command='curl -L -s "https://aka.ms/vs/17/release/vc_redist.x86.exe" -z "$(TargetDir)VC_redist.x86.exe" -o "$(TargetDir)VC_redist.x86.exe"' /> <Exec Command='curl -s -L "https://aka.ms/vs/17/release/vc_redist.x86.exe" -z "$(TargetDir)VC_redist.x86.exe" -o "$(TargetDir)VC_redist.x86.exe"' />
<PropertyGroup> <PropertyGroup>
<DefineConstants>ElwigProjectDir=..\Elwig</DefineConstants> <DefineConstants>ElwigProjectDir=..\Elwig</DefineConstants>
</PropertyGroup> </PropertyGroup>

View File

@ -1 +1 @@
curl -s "https://www.necronda.net/elwig/files/create.sql?v=13" -u "elwig:ganzGeheim123!" -o "Resources\Create.sql" curl -s -L "https://www.necronda.net/elwig/files/create.sql?v=13" -u "elwig:ganzGeheim123!" -o "Resources\Create.sql"