Compare commits

...

16 Commits

Author SHA1 Message Date
2a3a69d96f Bump version to 0.7.1
Some checks failed
Deploy / Build and Deploy (push) Has been cancelled
2024-03-11 14:54:25 +01:00
3f09717922 App: Header cleanup 2024-03-11 10:22:09 +01:00
f242b077bd AppDbContext: Fix NextMgNr() for gaps greater than 1000 2024-03-10 13:06:49 +01:00
61c8d1ee97 MemberAdminWindow: Remove Rundschreiben capabilities 2024-03-10 00:26:18 +01:00
a5df03aa2c MailWindow: Move Location field to first page 2024-03-10 00:05:15 +01:00
c0f4a484ab Printing/Pdf: Update WinziPrint version to 0.2.9 2024-03-09 22:57:36 +01:00
6a5507060a MailWindow: Return cleanly if WinziPrint fails 2 2024-03-09 21:23:58 +01:00
c70772b47d MailWindow: Return cleanly if WinziPrint fails 2024-03-09 21:17:47 +01:00
d0fe264af4 [#40] BillingTest: Fix tests 2024-03-09 21:11:20 +01:00
dc83e64db6 [#40] Billing: Add Rebelzuschlag 2024-03-09 20:24:49 +01:00
34ebc8fa34 MailWindow: Add feature to change location 2024-03-09 15:46:32 +01:00
0629f4eb1b MailWindow: Wrap text in FooterInputs 2024-03-09 15:11:52 +01:00
746d0f10de MailWindow: Order members by billing address if applicable 2024-03-09 15:08:51 +01:00
58c7eec6f8 [#40] DeliveryConfirmation: Fix last row cell count 2024-03-08 16:33:32 +01:00
e1201bc6b8 [#40] DeliveryConfirmation: Add column indication gross/net weight 2024-03-08 15:18:47 +01:00
ccd4a58007 BillingData: Compact data even more 2024-03-07 10:42:26 +01:00
22 changed files with 314 additions and 121 deletions

View File

@ -1,11 +1,10 @@
<Application x:Class="Elwig.App"
<Application
x:Class="Elwig.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Elwig"
xmlns:ctrl="clr-namespace:Elwig.Controls"
StartupUri="Windows\MainWindow.xaml"
Exit="Application_Exit"
xmlns:ui="http://schemas.modernwpf.com/2019">
Exit="Application_Exit">
<Application.Resources>
<ctrl:BoolToStringConverter x:Key="BoolToStarConverter" FalseValue="" TrueValue="*"/>
<ctrl:WidthToPaddingConverter x:Key="WidthToPaddingConverter"/>

View File

@ -7,13 +7,12 @@ using System.Linq;
namespace Elwig.Documents {
public abstract class BusinessDocument : Document {
public bool ShowDateAndLocation = false;
public Member Member;
public string? Location;
public bool IncludeSender = false;
public bool UseBillingAddress = false;
public bool ShowDateAndLocation = false;
public string Aside;
public string? Location;
public BusinessDocument(string title, Member m, bool includeSender = false) : base(title) {
Member = m;

View File

@ -10,13 +10,14 @@
<colgroup>
<col style="width: 25mm;"/>
<col style="width: 5mm;"/>
<col style="width: 24mm;"/>
<col style="width: 16mm;"/>
<col style="width: 22mm;"/>
<col style="width: 15mm;"/>
<col style="width: 10mm;"/>
<col style="width: 10mm;"/>
<col style="width: 15mm;"/>
<col style="width: 12mm;"/>
<col style="width: 15mm;"/>
<col style="width: 13mm;"/>
<col style="width: 5mm;"/>
<col style="width: 17mm;"/>
<col style="width: 16mm;"/>
</colgroup>
@ -29,6 +30,7 @@
<th colspan="2">Gradation</th>
<th colspan="2">Flächenbindung</th>
<th>Preis</th>
<th class="narrow">Rbl.</th>
<th class="narrow">Zu-/Abschläge</th>
<th>Betrag</th>
</tr>
@ -37,6 +39,7 @@
<th class="unit narrow">[°KMW]</th>
<th class="unit" colspan="2">[kg]</th>
<th class="unit">[@Model.CurrencySymbol/kg]</th>
<th class="narrow unit">[%]</th>
<th class="unit">[@Model.CurrencySymbol]</th>
<th class="unit">[@Model.CurrencySymbol]</th>
</tr>
@ -50,14 +53,17 @@
<td rowspan="@rows">@p.LsNr</td>
<td rowspan="@rows">@p.DPNr</td>
<td class="small">@p.Variety</td>
<td class="small">@p.Attribute@(p.Attribute != null && p.Cultivation != null ? " / " : "")@p.Cultivation</td>
<td class="small">
@p.Attribute@(p.Attribute != null && p.Cultivation != null ? " / " : "")@p.Cultivation
@((p.Attribute != null || p.Cultivation != null) && p.QualId == "WEI" ? " / " : "")@Raw(p.QualId == "WEI" ? "<i>abgew.</i>" : "")
</td>
<td rowspan="@rows" class="center">@($"{p.Gradation.Oe:N0}")</td>
<td rowspan="@rows" class="center">@($"{p.Gradation.Kmw:N1}")</td>
}
@if (i > 0 && i <= p.Modifiers.Length) {
<td colspan="2" class="small mod">@p.Modifiers[i - 1]</td>
<td colspan="4" class="small mod">@p.Modifiers[i - 1]</td>
} else if (i > 0) {
<td colspan="2"></td>
<td colspan="4"></td>
}
@if (i < p.Buckets.Length) {
var bucket = p.Buckets[i];
@ -65,10 +71,12 @@
<td class="number">@($"{bucket.Value:N0}")</td>
<td class="number">@($"{bucket.Price:N4}")</td>
} else {
<td colspan="3"></td>
<td></td>
}
@if (i == p.Buckets.Length - 1) {
var rebelMod = p.WeighingModifier * 100;
var totalMod = p.TotalModifiers ?? 0;
<td class="tiny center">@(rebelMod == 0 ? "-" : (Utils.GetSign(rebelMod) + $"{Math.Abs(rebelMod):0.0##}"))</td>
<td class="number@(totalMod == 0 ? " center" : "")">@(totalMod == 0 ? "-" : Utils.GetSign(totalMod) + $"{Math.Abs(totalMod):N2}")</td>
<td class="number">@($"{p.Amount:N2}")</td>
} else {

View File

@ -11,13 +11,14 @@
<col style="width: 25mm;"/>
<col style="width: 5mm;"/>
<col style="width: 24mm;"/>
<col style="width: 16mm;"/>
<col style="width: 17mm;"/>
<col style="width: 19mm;"/>
<col style="width: 10mm;"/>
<col style="width: 10mm;"/>
<col style="width: 15mm;"/>
<col style="width: 12mm;"/>
<col style="width: 14mm;"/>
<col style="width: 3mm;"/>
<col style="width: 14mm;"/>
</colgroup>
<thead>
@ -30,6 +31,14 @@
<th colspan="2">Gradation</th>
<th colspan="2">Flächenbindung</th>
<th>Gewicht</th>
<th rowspan="3" style="padding: 0;">
<svg width="10" height="40" xmlns="http://www.w3.org/2000/svg">
<text x="-40" y="5" transform="rotate(270)" font-size="8pt" font-style="italic" font-family="Times New Roman"
style="text-anchor: start; alignment-baseline: middle;">
bto./nto.
</text>
</svg>
</th>
<th>Davon<br/>abzuwerten</th>
</tr>
<tr>
@ -72,8 +81,10 @@
}
@if (i == p.Buckets.Length - 1) {
<td class="number">@($"{p.Weight:N0}")</td>
<td class="small">@(p.IsNetWeight ? "n" : "b")</td>
} else {
<td></td>
<td></td>
}
@if (first) {
<td rowspan="@rows" class="number"></td>
@ -87,6 +98,7 @@
<td colspan="8">Gesamt:</td>
<td colspan="2" class="number">@($"{Model.Data.Rows.Sum(p => p.Weight):N0}")</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>

View File

@ -57,6 +57,9 @@ main table .small {
main table .large {
font-size: 12pt;
}
main table .tiny {
font-size: 6pt;
}
main table.number td,
main table.number th {

View File

@ -7,7 +7,7 @@
<UseWPF>true</UseWPF>
<PreserveCompilationContext>true</PreserveCompilationContext>
<ApplicationIcon>Resources\Images\Elwig.ico</ApplicationIcon>
<Version>0.7.0</Version>
<Version>0.7.1</Version>
<SatelliteResourceLanguages>de-AT</SatelliteResourceLanguages>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplicationManifest>app.manifest</ApplicationManifest>

View File

@ -183,7 +183,7 @@ namespace Elwig.Helpers {
public async Task<int> NextMgNr() {
int c = 0;
(await Members.OrderBy(m => m.MgNr).Select(m => m.MgNr).ToListAsync())
.ForEach(a => { if (a <= c + 1000) c = a; });
.ForEach(a => { if (a <= c + 10000) c = a; });
return c + 1;
}

View File

@ -42,6 +42,15 @@ namespace Elwig.Helpers.Billing {
set => SetConsider(value, "consider_auto_business_shares");
}
public double NetWeightModifier {
get => GetWeightModifier("net_weight_modifier", "Rebelzuschlag");
set => SetWeightModifier(value, "net_weight_modifier", "Rebelzuschlag");
}
public double GrossWeightModifier {
get => GetWeightModifier("gross_weight_modifier");
set => SetWeightModifier(value, "gross_weight_modifier");
}
private bool GetConsider(string name, string? wgMasterName = null) {
return ((Mode == CalculationMode.Elwig) ? Data[name] : Data[wgMasterName ?? ""])?.AsValue().GetValue<bool>() ?? false;
}
@ -56,6 +65,23 @@ namespace Elwig.Helpers.Billing {
}
}
private double GetWeightModifier(string name, string? wgMasterName = null) {
var isElwig = (Mode == CalculationMode.Elwig);
var val = (isElwig ? Data[name] : Data[wgMasterName ?? ""])?.AsValue().GetValue<double>() ?? 0;
return isElwig ? val : val / 100.0;
}
private void SetWeightModifier(double value, string name, string? wgMasterName = null) {
var isElwig = (Mode == CalculationMode.Elwig);
if (Mode == CalculationMode.WgMaster && wgMasterName == null) {
return;
} else if (value != 0) {
Data[isElwig ? name : wgMasterName ?? ""] = isElwig ? value : value * 100.0;
} else {
Data.Remove(isElwig ? name : wgMasterName ?? "");
}
}
public BillingData(JsonObject data) {
Data = data;
var mode = Data["mode"]?.GetValue<string>();
@ -252,11 +278,11 @@ namespace Elwig.Helpers.Billing {
return curve;
}
protected static void CollapsePaymentData(JsonObject data, IEnumerable<RawVaribute> vaributes, bool useDefault = true) {
protected static (Dictionary<string, List<string>>, Dictionary<decimal, List<string>>) GetReverseKeys(JsonObject data, bool strict = true) {
Dictionary<string, List<string>> rev1 = [];
Dictionary<decimal, List<string>> rev2 = [];
foreach (var (k, v) in data) {
if (k == "default" || k.StartsWith('/') || !k.Contains('/') || v is not JsonValue val) {
if (k == "default" || (strict && (k.StartsWith('/') || !k.Contains('/'))) || v is not JsonValue val) {
continue;
} else if (val.TryGetValue<decimal>(out var dec)) {
rev2[dec] = rev2.GetValueOrDefault(dec) ?? [];
@ -266,6 +292,11 @@ namespace Elwig.Helpers.Billing {
rev1[cur].Add(k);
}
}
return (rev1, rev2);
}
protected static void CollapsePaymentData(JsonObject data, IEnumerable<RawVaribute> vaributes, bool useDefault = true) {
var (rev1, rev2) = GetReverseKeys(data);
if (!data.ContainsKey("default")) {
foreach (var (v, ks) in rev1) {
if ((ks.Count >= vaributes.Count() * 0.5 && useDefault) || ks.Count == vaributes.Count()) {
@ -322,6 +353,32 @@ namespace Elwig.Helpers.Billing {
data.Add(k.Replace("/-", "-"), val);
}
}
(rev1, rev2) = GetReverseKeys(data, false);
var keyVaributes = data
.Select(e => e.Key.Split('-')[0])
.Where(e => e.Length > 0 && e != "default")
.Distinct()
.ToList();
foreach (var idx in keyVaributes) {
var len = data.Count(e => e.Key == idx || (e.Key.Length > idx.Length && e.Key.StartsWith(idx) && e.Key[idx.Length] == '-'));
foreach (var (v, ks) in rev1) {
var myKs = ks.Where(k => k == idx || (k.Length > idx.Length && k.StartsWith(idx) && k[idx.Length] == '-' && !data.ContainsKey(k[idx.Length..]))).ToList();
if (myKs.Count == len) {
foreach (var k in myKs) {
if (k != idx) data.Remove(k);
}
}
}
foreach (var (v, ks) in rev2) {
var myKs = ks.Where(k => k == idx || (k.Length > idx.Length && k.StartsWith(idx) && k[idx.Length] == '-' && !data.ContainsKey(k[idx.Length..]))).ToList();
if (myKs.Count == len) {
foreach (var k in myKs) {
if (k != idx) data.Remove(k);
}
}
}
}
}
public static JsonObject FromGraphEntries(

View File

@ -146,6 +146,8 @@ namespace Elwig.Helpers.Billing {
var inserts = new List<(int Year, int DId, int DPNr, int BktNr, long Price, long Amount)>();
foreach (var part in parts) {
if (part.Value == 0)
continue;
var ungeb = part.Discr == "_";
var payAttrId = (part.Discr is "" or "_") ? null : part.Discr;
var attrId = part.AttrAreaCom ? payAttrId : part.AttrId;
@ -162,7 +164,16 @@ namespace Elwig.Helpers.Billing {
}
protected async Task CalculateDeliveryModifiers(SqliteConnection cnx) {
var netMod = Data.NetWeightModifier.ToString().Replace(',', '.');
var grossMod = Data.GrossWeightModifier.ToString().Replace(',', '.');
await AppDbContext.ExecuteBatch(cnx, $"""
INSERT INTO payment_delivery_part (year, did, dpnr, avnr, net_amount, mod_abs, mod_rel)
SELECT d.year, d.did, d.dpnr, {AvNr}, 0, 0, IIF(d.net_weight, {netMod}, {grossMod})
FROM delivery_part d
WHERE d.year = {Year}
ON CONFLICT DO UPDATE
SET mod_rel = mod_rel + excluded.mod_rel;
INSERT INTO payment_delivery_part (year, did, dpnr, avnr, net_amount, mod_abs, mod_rel)
SELECT d.year, d.did, d.dpnr, {AvNr}, 0, COALESCE(m.abs, 0), COALESCE(m.rel, 0)
FROM delivery_part d
@ -171,7 +182,7 @@ namespace Elwig.Helpers.Billing {
WHERE d.year = {Year}
ON CONFLICT DO UPDATE
SET mod_abs = mod_abs + excluded.mod_abs,
mod_rel = mod_rel + excluded.mod_rel
mod_rel = mod_rel + excluded.mod_rel;
""");
}
}

View File

@ -88,7 +88,9 @@ namespace Elwig.Helpers {
input.Text = text;
input.CaretIndex = pos;
if (text.Length == 0) {
if (text == "-") {
return new(false, "Ungültige Kommazahl");
} else if (text.Length == 0) {
return required ? new(false, "Wert ist nicht optional") : new(true, null);
} else if (v2 == 0) {
return new(false, "Ungültige Kommazahl");

View File

@ -1,5 +1,7 @@
using Elwig.Models.Entities;
using Elwig.Helpers.Billing;
using Elwig.Models.Entities;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
@ -26,10 +28,13 @@ namespace Elwig.Models.Dtos {
}
public static async Task<IDictionary<int, CreditNoteDeliveryData>> ForPaymentVariant(DbSet<CreditNoteDeliveryRowSingle> table, DbSet<Season> seasons, int year, int avnr) {
var variant = (await seasons.FindAsync(year))?.PaymentVariants.Where(v => v.AvNr == avnr).SingleOrDefault();
BillingData? varData = null;
try { varData = variant != null ? BillingData.FromJson(variant.Data) : null; } catch { }
return (await FromDbSet(table, year, avnr))
.GroupBy(
r => new { r.Year, r.AvNr, r.MgNr, r.TgNr, r.DId, r.DPNr },
(k, g) => new CreditNoteDeliveryRow(g, seasons))
(k, g) => new CreditNoteDeliveryRow(g, seasons, varData?.NetWeightModifier ?? 0.0, varData?.GrossWeightModifier ?? 0.0))
.GroupBy(
r => new { r.Year, r.AvNr, r.MgNr, r.TgNr },
(k, g) => new CreditNoteDeliveryData(g, k.Year, k.TgNr, mgnr: k.MgNr))
@ -43,7 +48,7 @@ namespace Elwig.Models.Dtos {
return await table.FromSqlRaw($"""
SELECT d.year, c.tgnr, v.avnr, d.mgnr, d.did, d.lsnr, d.dpnr, d.weight, d.modifiers,
b.bktnr, d.sortid, b.discr, b.value, pb.price, pb.amount, p.net_amount, p.amount AS total_amount,
s.name AS variety, a.name AS attribute, c.name AS cultivation, q.name AS quality_level, d.oe, d.kmw
s.name AS variety, a.name AS attribute, c.name AS cultivation, q.qualid AS qualid, q.name AS quality_level, d.oe, d.kmw, d.net_weight
FROM v_delivery d
JOIN wine_variety s ON s.sortid = d.sortid
LEFT JOIN wine_attribute a ON a.attrid = d.attrid
@ -64,7 +69,7 @@ namespace Elwig.Models.Dtos {
public int Year;
public int? TgNr;
public int AvNr;
public int? AvNr;
public int MgNr;
public string LsNr;
@ -73,16 +78,19 @@ namespace Elwig.Models.Dtos {
public string? Attribute;
public string? Cultivation;
public string[] Modifiers;
public string QualId;
public string QualityLevel;
public (double Oe, double Kmw) Gradation;
public (string Name, int Value, decimal? Price, decimal? Amount)[] Buckets;
public decimal? TotalModifiers;
public decimal? Amount;
public double WeighingModifier;
public CreditNoteDeliveryRow(IEnumerable<CreditNoteDeliveryRowSingle> rows, DbSet<Season> seasons) {
public CreditNoteDeliveryRow(IEnumerable<CreditNoteDeliveryRowSingle> rows, DbSet<Season> seasons, double netWeightModifier, double grossWeightModifier) {
var f = rows.First();
Year = f.Year;
TgNr = f.TgNr;
AvNr = f.AvNr;
MgNr = f.MgNr;
var season = seasons.Find(Year);
@ -97,6 +105,7 @@ namespace Elwig.Models.Dtos {
.OrderBy(m => m.Ordering)
.ToList();
Modifiers = modifiers.Select(m => m.Name).ToArray();
QualId = f.QualId;
QualityLevel = f.QualityLevel;
Gradation = (f.Oe, f.Kmw);
Buckets = rows
@ -106,9 +115,11 @@ namespace Elwig.Models.Dtos {
b.Price != null ? season?.DecFromDb((long)b.Price) : null,
b.Amount != null ? season?.DecFromDb((long)b.Amount) : null))
.ToArray();
WeighingModifier = f.NetWeight ? netWeightModifier : grossWeightModifier;
Amount = f.TotalAmount != null ? season?.DecFromDb((long)f.TotalAmount) : null;
var netAmount = f.NetAmount != null ? season?.DecFromDb((long)f.NetAmount) : null;
TotalModifiers = Amount - netAmount;
var amt = netAmount * (decimal)(1.0 + WeighingModifier);
TotalModifiers = Amount - (amt != null ? Math.Round((decimal)amt, season?.Precision ?? 0) : null);
}
}
@ -154,11 +165,15 @@ namespace Elwig.Models.Dtos {
public string? Attribute { get; set; }
[Column("cultivation")]
public string? Cultivation { get; set; }
[Column("qualid")]
public required string QualId { get; set; }
[Column("quality_level")]
public required string QualityLevel { get; set; }
[Column("oe")]
public double Oe { get; set; }
[Column("kmw")]
public double Kmw { get; set; }
[Column("net_weight")]
public bool NetWeight { get; set; }
}
}

View File

@ -78,6 +78,7 @@ namespace Elwig.Models.Dtos {
public (double Oe, double Kmw) Gradation;
public string[] Modifiers;
public int Weight;
public bool IsNetWeight;
public (string Name, int Value)[] Buckets;
public DeliveryConfirmationDeliveryRow(DeliveryPart p) {
@ -93,6 +94,7 @@ namespace Elwig.Models.Dtos {
.Select(m => m.Name)
.ToArray();
Weight = p.Weight;
IsNetWeight = p.IsNetWeight;
Buckets = p.Buckets
.Where(b => b.Value > 0)
.OrderByDescending(b => b.BktNr)

View File

@ -12,6 +12,8 @@
"consider_contract_penalties": {"type": "boolean"},
"consider_total_penalty": {"type": "boolean"},
"consider_auto_business_shares": {"type": "boolean"},
"net_weight_modifier": {"type": "number"},
"gross_weight_modifier": {"type": "number"},
"payment": {"$ref": "#/definitions/payment_1"},
"quality": {"$ref": "#/definitions/quality_1"},
"curves": {
@ -23,6 +25,7 @@
"required": ["AuszahlungSorten", "Kurven"],
"properties": {
"mode": {"enum": ["wgmaster"]},
"Rebelzuschlag": {"type": "number"},
"AuszahlungSorten": {"$ref": "#/definitions/payment_1"},
"AuszahlungSortenQualitätsstufe": {"$ref": "#/definitions/quality_1"},
"Kurven": {

View File

@ -85,14 +85,20 @@
<Label x:Name="DocumentFooterLabel" Content="Fußtext:" Margin="10,40,0,10"/>
<TextBox x:Name="DeliveryConfirmationFooterInput" Grid.Column="1"
Margin="0,40,10,10" Height="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
AcceptsReturn="True" VerticalScrollBarVisibility="Visible"/>
AcceptsReturn="True" VerticalScrollBarVisibility="Visible" TextWrapping="Wrap"/>
<TextBox x:Name="CreditNoteFooterInput" Grid.Column="1"
Margin="0,10,10,10" Height="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
AcceptsReturn="True" VerticalScrollBarVisibility="Visible"/>
AcceptsReturn="True" VerticalScrollBarVisibility="Visible" TextWrapping="Wrap"/>
</Grid>
</GroupBox>
<GroupBox Header="Adressaten" Margin="10,10,10,47" Grid.Column="1">
<TextBox x:Name="PostalLocation" Grid.Column="1"
Margin="10,30,10,10" Width="120" HorizontalAlignment="Left"/>
<Label Margin="130,30,10,10" FontSize="14" Grid.Column="1">
<TextBlock>, am <Run x:Name="PostalDate">01.01.2020</Run></TextBlock>
</Label>
<GroupBox Header="Adressaten" Margin="10,70,10,47" Grid.Column="1">
<Grid>
<RadioButton GroupName="Recipients" x:Name="RecipientsActiveMembersInput" Content="aktive Mitglieder"
Margin="10,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
@ -192,7 +198,6 @@
Margin="10,300,10,10"/>
<TextBox x:Name="PostalSender2"
Margin="10,330,10,10"/>
</Grid>
</GroupBox>

View File

@ -119,6 +119,8 @@ namespace Elwig.Windows {
PostalSender1.Text = App.Client.Sender1;
PostalSender2.Text = App.Client.Sender2;
PostalLocation.Text = App.BranchLocation;
PostalDate.Text = $"{Utils.Today:dd.MM.yyyy}";
EmailSubjectInput.Text = App.Client.TextEmailSubject ?? "Rundschreiben";
EmailBodyInput.Text = App.Client.TextEmailBody ?? "Sehr geehrtes Mitglied,\n\nim Anhang finden Sie das aktuelle Rundschreiben.\n\nIhre Winzergenossenschaft\n";
}
@ -374,6 +376,10 @@ namespace Elwig.Windows {
DisposeDocs();
await UpdateTextParameters();
var doublePaged = DoublePagedInput.IsChecked == true;
var location = PostalLocation.Text.Trim();
var docs = SelectedDocs.OrderByDescending(d => d.Type).ToList();
IEnumerable<Member> recipients = Recipients;
if (OrderMgNrInput.IsChecked == true) {
recipients = recipients
@ -386,17 +392,24 @@ namespace Elwig.Windows {
.ThenBy(m => m.MgNr)
.ToList();
} else if (OrderPlzInput.IsChecked == true) {
if (docs.Any(d => d.Type == DocType.DeliveryConfirmation || d.Type == DocType.CreditNote)) {
recipients = recipients
.OrderBy(m => m.PostalDest.AtPlz.Plz)
.ThenBy(m => m.PostalDest.AtPlz.Ort.Name)
.OrderBy(m => m.BillingAddress?.PostalDest.AtPlz?.Plz ?? m.PostalDest.AtPlz?.Plz)
.ThenBy(m => m.BillingAddress?.PostalDest.AtPlz?.Ort.Name ?? m.PostalDest.AtPlz?.Ort.Name)
.ThenBy(m => m.FamilyName)
.ThenBy(m => m.GivenName)
.ThenBy(m => m.MgNr)
.ToList();
} else {
recipients = recipients
.OrderBy(m => m.PostalDest.AtPlz?.Plz)
.ThenBy(m => m.PostalDest.AtPlz?.Ort.Name)
.ThenBy(m => m.FamilyName)
.ThenBy(m => m.GivenName)
.ThenBy(m => m.MgNr)
.ToList();
}
var doublePaged = DoublePagedInput.IsChecked == true;
var docs = SelectedDocs.OrderByDescending(d => d.Type).ToList();
}
Dictionary<int, IDictionary<int, DeliveryConfirmationDeliveryData>> dcData = [];
Dictionary<(int, int), (IDictionary<int, CreditNoteDeliveryData>, IDictionary<int, PaymentMember>, BillingData)> cnData = [];
@ -487,8 +500,10 @@ namespace Elwig.Windows {
var docs = m.Docs.Select(d => d.Doc).ToList();
foreach (var doc in docs) {
doc!.DoublePaged = false;
if (doc is BusinessDocument b)
if (doc is BusinessDocument b) {
b.IncludeSender = false;
b.Location = location;
}
};
return docs;
});
@ -503,6 +518,8 @@ namespace Elwig.Windows {
}
} catch (Exception exc) {
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
GenerateButton.IsEnabled = true;
Mouse.OverrideCursor = null;
return;
}
if (email.Count > 0) {
@ -519,7 +536,11 @@ namespace Elwig.Windows {
if (docs.Count == 0 || m.Docs[0].Type == DocType.Custom) {
docs.Insert(0, new Letterhead(m.Member));
}
docs.ForEach(doc => doc.DoublePaged = doublePaged);
docs.ForEach(doc => {
doc.DoublePaged = doublePaged;
if (doc is BusinessDocument b)
b.Location = location;
});
if (docs.Count > 0 && docs[0] is BusinessDocument b)
b.IncludeSender = true;
return docs;
@ -536,6 +557,8 @@ namespace Elwig.Windows {
PrintDocument = print;
} catch (Exception exc) {
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
GenerateButton.IsEnabled = true;
Mouse.OverrideCursor = null;
return;
}
}

View File

@ -56,18 +56,6 @@
Click="Menu_Show_MemberDataSheet_Click" InputGestureText="Strg+P"/>
<MenuItem x:Name="Menu_Print_MemberDataSheet" Header="Stammdatenblatt drucken" IsEnabled="False"
Click="Menu_Print_MemberDataSheet_Click" InputGestureText="Strg+Shift+P"/>
<MenuItem Header="Briefköpfe drucken">
<MenuItem x:Name="Menu_Print_Letterheads_MgNr" Header="nach MgNr. sortiert"
Click="Menu_Print_Letterheads_MgNr_Click"/>
<MenuItem x:Name="Menu_Print_Letterheads_Name" Header="nach Name sortiert"
Click="Menu_Print_Letterheads_Name_Click"/>
<MenuItem x:Name="Menu_Print_Letterheads_Plz" Header="nach PLZ, Ort, Name sortiert"
Click="Menu_Print_Letterheads_Plz_Click"/>
</MenuItem>
</MenuItem>
<MenuItem Header="Rundschreiben">
<MenuItem Header="Runschreiben ausschicken"/>
<MenuItem Header="Alle Stammdatenblätter ausschicken"/>
</MenuItem>
<MenuItem Header="Werkzeuge">
<MenuItem Header="Alle Mitglieder überprüfen"/>

View File

@ -441,58 +441,6 @@ namespace Elwig.Windows {
Mouse.OverrideCursor = null;
}
private async Task PrintLetterheads(int ordering) {
var n = await Context.Members.CountAsync(m => m.IsActive);
var res = MessageBox.Show(
$"Sollen wirklich {n} Seiten gedruckt werden?", "Ausdruck Bestätigen",
MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
if (res != MessageBoxResult.Yes)
return;
Mouse.OverrideCursor = Cursors.AppStarting;
var members = Context.Members.Where(m => m.IsActive && m.ContactViaPost);
switch (ordering) {
case 0: members = members
.OrderBy(m => m.MgNr);
break;
case 1: members = members
.OrderBy(m => m.FamilyName)
.ThenBy(m => m.GivenName)
.ThenBy(m => m.MgNr);
break;
case 2: members = members
.OrderBy(m => m.PostalDest.AtPlz.Plz)
.ThenBy(m => m.PostalDest.AtPlz.Ort.Name)
.ThenBy(m => m.FamilyName)
.ThenBy(m => m.GivenName)
.ThenBy(m => m.MgNr);
break;
}
try {
using var doc = Document.Merge((await members.ToListAsync()).Select(m => new Letterhead(m)));
await doc.Generate();
if (App.Config.Debug) {
doc.Show();
} else {
await doc.Print();
}
} catch (Exception exc) {
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
}
Mouse.OverrideCursor = null;
}
private async void Menu_Print_Letterheads_MgNr_Click(object sender, RoutedEventArgs evt) {
await PrintLetterheads(0);
}
private async void Menu_Print_Letterheads_Name_Click(object sender, RoutedEventArgs evt) {
await PrintLetterheads(1);
}
private async void Menu_Print_Letterheads_Plz_Click(object sender, RoutedEventArgs evt) {
await PrintLetterheads(2);
}
private async void Menu_Print_MemberDataSheet_Click(object sender, RoutedEventArgs evt) {
if (MemberList.SelectedItem is not Member m)
return;

View File

@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elwig.Windows"
xmlns:ctrl="clr-namespace:Elwig.Controls"
mc:Ignorable="d"
Title="Auszahlungsvarianten - Elwig" Height="510" Width="820" MinHeight="500" MinWidth="820">
<Window.Resources>
@ -86,6 +87,11 @@
<TextBox x:Name="TransferDateInput" Grid.Column="2" Width="77" HorizontalAlignment="Left" Margin="0,100,10,0"
TextChanged="TransferDateInput_TextChanged"/>
<Label Content="Rebelzuschlag:" Margin="10,130,0,0" Grid.Column="1"/>
<ctrl:UnitTextBox x:Name="WeightModifierInput" Grid.Column="2" Width="60" Margin="0,130,10,0" Unit="%"
HorizontalAlignment="Left" VerticalAlignment="Top"
TextChanged="WeightModifierInput_TextChanged" LostFocus="WeightModifierInput_LostFocus"/>
<Label Content="Berücksichtigen:" Margin="90,70,10,10" Grid.Column="2"/>
<CheckBox x:Name="ConsiderModifiersInput" Content="Zu-/Abschläge bei Lieferungen"
Margin="110,95,10,10" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top"

View File

@ -20,6 +20,7 @@ namespace Elwig.Windows {
public readonly bool SeasonLocked;
private bool DataValid, DataChanged, NameChanged, CommentChanged, TransferDateValid, TransferDateChanged;
private BillingData? BillingData;
private bool WeightModifierChanged = false;
private static readonly JsonSerializerOptions JsonOpt = new() { WriteIndented = true };
@ -70,6 +71,13 @@ namespace Elwig.Windows {
ConsiderPenaltiesInput.IsChecked = BillingData.ConsiderContractPenalties;
ConsiderPenaltyInput.IsChecked = BillingData.ConsiderTotalPenalty;
ConsiderAutoInput.IsChecked = BillingData.ConsiderAutoBusinessShares;
if (BillingData.NetWeightModifier != 0) {
WeightModifierInput.Text = $"{Math.Round(BillingData.NetWeightModifier * 100.0, 8)}";
} else if (BillingData.GrossWeightModifier != 0) {
WeightModifierInput.Text = $"{Math.Round(BillingData.GrossWeightModifier * 100.0, 8)}";
} else {
WeightModifierInput.Text = "";
}
DataInput.Text = JsonSerializer.Serialize(BillingData.Data, JsonOpt);
} catch {
BillingData = null;
@ -77,8 +85,10 @@ namespace Elwig.Windows {
ConsiderPenaltiesInput.IsChecked = false;
ConsiderPenaltyInput.IsChecked = false;
ConsiderAutoInput.IsChecked = false;
WeightModifierInput.Text = "";
DataInput.Text = v.Data;
}
WeightModifierInput.TextBox.IsReadOnly = false;
ConsiderModifiersInput.IsEnabled = !locked;
ConsiderPenaltiesInput.IsEnabled = !locked;
ConsiderPenaltyInput.IsEnabled = !locked;
@ -109,6 +119,8 @@ namespace Elwig.Windows {
DateInput.IsReadOnly = true;
TransferDateInput.Text = "";
TransferDateInput.IsReadOnly = true;
WeightModifierInput.Text = "";
WeightModifierInput.TextBox.IsReadOnly = true;
ConsiderModifiersInput.IsChecked = false;
ConsiderModifiersInput.IsEnabled = false;
ConsiderPenaltiesInput.IsChecked = false;
@ -131,7 +143,8 @@ namespace Elwig.Windows {
(ConsiderModifiersInput.IsChecked != BillingData?.ConsiderDelieryModifiers) ||
(ConsiderPenaltiesInput.IsChecked != BillingData?.ConsiderContractPenalties) ||
(ConsiderPenaltyInput.IsChecked != BillingData?.ConsiderTotalPenalty) ||
(ConsiderAutoInput.IsChecked != BillingData?.ConsiderAutoBusinessShares));
(ConsiderAutoInput.IsChecked != BillingData?.ConsiderAutoBusinessShares) ||
WeightModifierChanged);
CalculateButton.IsEnabled = !SaveButton.IsEnabled && PaymentVariantList.SelectedItem is PaymentVar { TestVariant: true };
CommitButton.IsEnabled = CalculateButton.IsEnabled;
}
@ -362,6 +375,10 @@ namespace Elwig.Windows {
d.ConsiderContractPenalties = ConsiderPenaltiesInput.IsChecked ?? false;
d.ConsiderTotalPenalty = ConsiderPenaltyInput.IsChecked ?? false;
d.ConsiderAutoBusinessShares = ConsiderAutoInput.IsChecked ?? false;
var modVal = WeightModifierInput.Text.Length > 0 ? double.Parse(WeightModifierInput.Text) : 0;
d.NetWeightModifier = modVal > 0 ? modVal / 100.0 : 0;
d.GrossWeightModifier = modVal < 0 ? modVal / 100.0 : 0;
WeightModifierChanged = false;
v.Data = JsonSerializer.Serialize(d.Data);
Context.Update(v);
await Context.SaveChangesAsync();
@ -371,6 +388,7 @@ namespace Elwig.Windows {
ConsiderPenaltiesInput_Changed(null, null);
ConsiderPenaltyInput_Changed(null, null);
ConsiderAutoInput_Changed(null, null);
WeightModifierInput_TextChanged(null, null);
} catch (Exception exc) {
await HintContextChange();
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
@ -511,5 +529,27 @@ namespace Elwig.Windows {
}
UpdateSaveButton();
}
private void WeightModifierInput_TextChanged(object? sender, TextChangedEventArgs? evt) {
var res = Validator.CheckDecimal(WeightModifierInput.TextBox, false, 3, 2, true);
if (BillingData == null) {
ControlUtils.ClearInputState(WeightModifierInput.TextBox);
return;
}
var val = WeightModifierInput.Text.Length > 0 && res.IsValid ? double.Parse(WeightModifierInput.Text) : 0;
WeightModifierChanged = (val != Math.Round(BillingData.NetWeightModifier * 100.0, 8) && val != Math.Round(BillingData.GrossWeightModifier * 100.0, 8)) ||
(val == 0 && (BillingData.NetWeightModifier != 0 || BillingData.GrossWeightModifier != 0));
if (WeightModifierChanged) {
ControlUtils.SetInputChanged(WeightModifierInput.TextBox);
} else {
ControlUtils.ClearInputState(WeightModifierInput.TextBox);
}
UpdateSaveButton();
}
private void WeightModifierInput_LostFocus(object sender, RoutedEventArgs evt) {
if (WeightModifierInput.Text.EndsWith(','))
WeightModifierInput.Text = WeightModifierInput.Text[..^1];
}
}
}

Binary file not shown.

View File

@ -556,7 +556,7 @@ namespace Tests.HelperTests {
}
[Test]
public void TestWrite_06_Cultivation() {
public void TestWrite_06_Cultivation_1() {
List<GraphEntry> entries = [
new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.5m,
@ -604,7 +604,84 @@ namespace Tests.HelperTests {
}
[Test]
public void TestWrite_07_AttributeAndCultivation() {
public void TestWrite_07_Cultivation_2() {
List<GraphEntry> entries = [
new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.6m,
[84] = 1.0m
}, null), GetSelection(["GV/-", "GV/-B"])),
new GraphEntry(2, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.75m,
}, null), GetSelection(["ZW/-", "ZW/-B"])),
new GraphEntry(2, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.8m,
}, null), GetSelection(["BP/-", "BP/-B"])),
];
var data = BillingData.FromGraphEntries(entries);
Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo("""
{
"mode": "elwig",
"version": 1,
"payment": {
"GV": "curve:1",
"ZW": 0.75,
"BP": 0.8
},
"curves": [
{
"id": 1,
"mode": "oe",
"data": {
"73oe": 0.6,
"84oe": 1
}
}
]
}
"""));
}
[Test]
public void TestWrite_08_Cultivation_3() {
List<GraphEntry> entries = [
new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.6m,
[84] = 1.0m
}, null), GetSelection(["GV/-", "GV/-B"])),
new GraphEntry(2, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.75m,
}, null), GetSelection(["BP/-B", "ZW/-B", "FV/-B"])),
new GraphEntry(2, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.8m,
}, null), GetSelection(["BP/-", "ZW/-", "FV/-", "WR/-", "BL/-"])),
];
var data = BillingData.FromGraphEntries(entries);
Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo("""
{
"mode": "elwig",
"version": 1,
"payment": {
"default": 0.8,
"GV": "curve:1",
"GV-B": "curve:1",
"-B": 0.75
},
"curves": [
{
"id": 1,
"mode": "oe",
"data": {
"73oe": 0.6,
"84oe": 1
}
}
]
}
"""));
}
[Test]
public void TestWrite_09_AttributeAndCultivation() {
List<GraphEntry> entries = [
new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.75m,

View File

@ -191,16 +191,13 @@ namespace Tests.HelperTests {
await b.Calculate(false, false, false);
var prices = await GetMemberDeliveryPrices(year, mgnr);
Assert.Multiple(() => {
Assert.That(prices, Has.Count.EqualTo(10));
Assert.That(prices, Has.Count.EqualTo(7));
// Kabinett
Assert.That(prices[("20211001X001/1", "GV_")], Is.EqualTo(( 0, GV_ungeb)));
Assert.That(prices[("20211001X001/1", "GV")] , Is.EqualTo((4_000, GV_geb)));
// ohne Attribut
Assert.That(prices[("20211001X001/2", "GV_")], Is.EqualTo(( 0, GV_ungeb)));
Assert.That(prices[("20211001X001/2", "GV")], Is.EqualTo((4_000, GV_geb)));
// Bio
Assert.That(prices[("20211001X002/1", "GV_")], Is.EqualTo((4_000, GVB_ungeb)));
Assert.That(prices[("20211001X002/1", "GV")], Is.EqualTo(( 0, GVB_geb)));
// Bio
Assert.That(prices[("20211001X002/2", "GV_")], Is.EqualTo((2_000, GVB_ungeb)));
Assert.That(prices[("20211001X002/2", "GV")], Is.EqualTo((2_000, GVB_geb)));
@ -240,14 +237,12 @@ namespace Tests.HelperTests {
await b.Calculate(true, false, false);
var prices = await GetMemberDeliveryPrices(year, mgnr);
Assert.Multiple(() => {
Assert.That(prices, Has.Count.EqualTo(8));
Assert.That(prices, Has.Count.EqualTo(6));
// Kabinett
Assert.That(prices[("20211001X001/1", "GV_")], Is.EqualTo(( 0, GV_ungeb)));
Assert.That(prices[("20211001X001/1", "GV")], Is.EqualTo((4_000, GV_geb)));
// ohne Attribut
Assert.That(prices[("20211001X001/2", "GV_")], Is.EqualTo((4_000, GV_ungeb)));
// Bio
Assert.That(prices[("20211001X002/1", "GV_")], Is.EqualTo(( 0, GVB_ungeb)));
Assert.That(prices[("20211001X002/1", "GV")], Is.EqualTo((4_000, GVB_geb)));
// Bio
Assert.That(prices[("20211001X002/2", "GV_")], Is.EqualTo((4_000, GVB_ungeb)));