Compare commits
3 Commits
af8334a912
...
314a0d37a8
| Author | SHA1 | Date | |
|---|---|---|---|
| 314a0d37a8 | |||
| 765edbdae6 | |||
| 9a0a422c8a |
@@ -18,7 +18,7 @@ namespace Elwig.Documents {
|
||||
public class BusinessDocument : Document {
|
||||
|
||||
public Member Member;
|
||||
public MemberHistoryPoint MemberHistory;
|
||||
public MemberHistoryPoint MemberShares;
|
||||
public string? Location;
|
||||
public bool IncludeSender = false;
|
||||
public bool UseBillingAddress = false;
|
||||
@@ -52,7 +52,7 @@ namespace Elwig.Documents {
|
||||
public BusinessDocument(string title, Member m, DateOnly? dateFrom, bool includeSender = false) :
|
||||
base(title) {
|
||||
Member = m;
|
||||
MemberHistory = new(m.Shares, m.SharesRed, m.SharesWhite, m.SharesDormant);
|
||||
MemberShares = new(m.Shares, m.SharesRed, m.SharesWhite, m.SharesDormant);
|
||||
Location = App.BranchLocation;
|
||||
IncludeSender = includeSender;
|
||||
DateFrom = dateFrom;
|
||||
@@ -318,19 +318,19 @@ namespace Elwig.Documents {
|
||||
.Where(b => !fbVars.Contains(b.Key))
|
||||
.OrderBy(b => b.Value.Name);
|
||||
|
||||
if (MemberHistory.Shares != 0 || (MemberHistory.SharesRed == 0 && MemberHistory.SharesWhite == 0)) {
|
||||
if (MemberShares.Shares != 0 || (MemberShares.SharesRed == 0 && MemberShares.SharesWhite == 0)) {
|
||||
tbl.AddCell(NewBucketTh("Gesamtlieferung lt. gez. GA", isTiny: isTiny));
|
||||
tbl.AddCells(FormatRow(MemberHistory.Shares * (season.MinKgPerShare ?? 0), MemberHistory.Shares * (season.MaxKgPerShare ?? 0),
|
||||
tbl.AddCells(FormatRow(MemberShares.Shares * (season.MinKgPerShare ?? 0), MemberShares.Shares * (season.MaxKgPerShare ?? 0),
|
||||
deliveredWeightRed + deliveredWeightWhite, isGa: true, showPayment: includePayment, showArea: !includeDelivery, isTiny: isTiny));
|
||||
}
|
||||
|
||||
if (MemberHistory.SharesRed != 0 || MemberHistory.SharesWhite != 0) {
|
||||
if (MemberShares.SharesRed != 0 || MemberShares.SharesWhite != 0) {
|
||||
tbl.AddCell(NewBucketTh("Gesamtlieferung lt. gez. GA (rot)", isTiny: isTiny));
|
||||
tbl.AddCells(FormatRow(MemberHistory.SharesRed * (season.MinKgPerShareRed ?? season.MinKgPerShare ?? 0), MemberHistory.SharesRed * (season.MaxKgPerShareRed ?? season.MaxKgPerShare ?? 0),
|
||||
tbl.AddCells(FormatRow(MemberShares.SharesRed * (season.MinKgPerShareRed ?? season.MinKgPerShare ?? 0), MemberShares.SharesRed * (season.MaxKgPerShareRed ?? season.MaxKgPerShare ?? 0),
|
||||
deliveredWeightRed, isGa: true, showPayment: includePayment, showArea: !includeDelivery, isTiny: isTiny));
|
||||
|
||||
tbl.AddCell(NewBucketTh("Gesamtlieferung lt. gez. GA (weiß)", isTiny: isTiny));
|
||||
tbl.AddCells(FormatRow(MemberHistory.SharesWhite * (season.MinKgPerShareWhite ?? season.MinKgPerShare ?? 0), MemberHistory.SharesWhite * (season.MaxKgPerShareWhite ?? season.MaxKgPerShare ?? 0),
|
||||
tbl.AddCells(FormatRow(MemberShares.SharesWhite * (season.MinKgPerShareWhite ?? season.MinKgPerShare ?? 0), MemberShares.SharesWhite * (season.MaxKgPerShareWhite ?? season.MaxKgPerShare ?? 0),
|
||||
deliveredWeightWhite, isGa: true, showPayment: includePayment, showArea: !includeDelivery, isTiny: isTiny));
|
||||
}
|
||||
|
||||
|
||||
@@ -101,11 +101,8 @@ namespace Elwig.Documents {
|
||||
MemberTotalUnderDelivery -= (season.PenaltyNone ?? 0) + (season.PenaltyPerShareNone * (Member.Shares + Member.SharesRed + Member.SharesWhite) ?? 0);
|
||||
}
|
||||
if (ConsiderAutoBusinessShares) {
|
||||
var fromDate = $"{season.Year}-01-01";
|
||||
var toDate = $"{season.Year}-12-31";
|
||||
MemberAutoBusinessShares = await ctx.MemberHistory
|
||||
.Where(h => h.ToMgNr == Member.MgNr && h.Reason == "auto")
|
||||
.Where(h => h.DateString.CompareTo(fromDate) >= 0 && h.DateString.CompareTo(toDate) <= 0)
|
||||
.Where(h => h.ToMgNr == Member.MgNr && h.DeductYear == season.Year)
|
||||
.SumAsync(h => h.Shares);
|
||||
MemberAutoBusinessSharesAmount = MemberAutoBusinessShares * (-season.BusinessShareValue ?? 0);
|
||||
}
|
||||
@@ -205,7 +202,7 @@ namespace Elwig.Documents {
|
||||
penalty += MemberTotalUnderDelivery;
|
||||
}
|
||||
if (MemberAutoBusinessSharesAmount != 0) {
|
||||
tbl2.AddCells(FormatRow($"Autom. Nachz. von GA ({MemberAutoBusinessShares})", MemberAutoBusinessSharesAmount, add: true));
|
||||
tbl2.AddCells(FormatRow($"Nachzeichnung von GA ({MemberAutoBusinessShares})", MemberAutoBusinessSharesAmount, add: true));
|
||||
penalty += MemberAutoBusinessSharesAmount;
|
||||
}
|
||||
if (CustomPayment?.Amount != null) {
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Elwig.Documents {
|
||||
.ToDictionaryAsync(g => g.Key, g => g.Sum(p => p.Weight));
|
||||
MemberDeliveredWeightRed = weights.GetValueOrDefault("R", 0);
|
||||
MemberDeliveredWeightWhite = weights.GetValueOrDefault("W", 0);
|
||||
MemberHistory = await ctx.GetMemberHistory(Season.Year, Member.MgNr);
|
||||
MemberShares = await ctx.GetMemberHistory(Season.Year, Member.MgNr);
|
||||
MemberBuckets = await ctx.GetMemberBuckets(Season.Year, Member.MgNr);
|
||||
MemberStats = await AppDbContext.GetMemberStats(Season.Year, Member.MgNr);
|
||||
Data ??= await DeliveryConfirmationDeliveryData.ForMember(ctx.DeliveryParts, Season.Year, Member);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Elwig.Documents {
|
||||
.ToDictionaryAsync(g => g.Key, g => g.Sum(p => p.Weight));
|
||||
MemberDeliveredWeightRed = weights.GetValueOrDefault("R", 0);
|
||||
MemberDeliveredWeightWhite = weights.GetValueOrDefault("W", 0);
|
||||
MemberHistory = await ctx.GetMemberHistory(Delivery.Year, Member.MgNr);
|
||||
MemberShares = await ctx.GetMemberHistory(Delivery.Year, Member.MgNr);
|
||||
MemberBuckets = await ctx.GetMemberBuckets(Delivery.Year, Member.MgNr) ?? [];
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Elwig.Documents {
|
||||
public Season? Season;
|
||||
public int MemberDeliveredWeightRed;
|
||||
public int MemberDeliveredWeightWhite;
|
||||
public List<MemberHistory> MemberHistory = [];
|
||||
public Dictionary<string, MemberBucket> MemberBuckets = [];
|
||||
public List<AreaCom> ActiveAreaCommitments = [];
|
||||
|
||||
@@ -37,6 +38,10 @@ namespace Elwig.Documents {
|
||||
protected override async Task LoadData(AppDbContext ctx) {
|
||||
await base.LoadData(ctx);
|
||||
Season = await ctx.FetchSeasons().FirstOrDefaultAsync() ?? throw new ArgumentException("Invalid season");
|
||||
MemberHistory = await ctx.MemberHistory
|
||||
.Where(h => h.FromMgNr == Member.MgNr || h.ToMgNr == Member.MgNr)
|
||||
.OrderBy(h => h.DateString).ThenBy(h => h.HistNr)
|
||||
.ToListAsync();
|
||||
MemberBuckets = await ctx.GetMemberBuckets(Utils.CurrentYear, Member.MgNr);
|
||||
ActiveAreaCommitments = await Member.ActiveAreaCommitments(ctx)
|
||||
.Include(c => c.Contract).ThenInclude(c => c.Revisions)
|
||||
@@ -61,9 +66,18 @@ namespace Elwig.Documents {
|
||||
doc.Add(new AreaBreak(AreaBreakType.NEXT_PAGE));
|
||||
firstOnPage = true;
|
||||
}
|
||||
doc.Add(new KernedParagraph(12).Add(Bold($"Flächenbindungen per {Date:dd.MM.yyyy}")).SetMargins(firstOnPage ? 0 : 24, 0, 12, 0));
|
||||
doc.Add(new KernedParagraph(12).Add(Bold($"Flächenbindungen per {Date:dd.MM.yyyy}")).SetMargins(firstOnPage ? 0 : 24, 0, 6, 0));
|
||||
doc.Add(NewAreaComTable(ActiveAreaCommitments));
|
||||
}
|
||||
if (App.Client.EnableMemberHistory) {
|
||||
bool firstOnPage = false;
|
||||
if (pdf.GetNumberOfPages() == 1) {
|
||||
doc.Add(new AreaBreak(AreaBreakType.NEXT_PAGE));
|
||||
firstOnPage = true;
|
||||
}
|
||||
doc.Add(new KernedParagraph(12).Add(Bold($"Verlauf der Geschäftsanteile per {Date:dd.MM.yyyy}")).SetMargins(firstOnPage ? 0 : 24, 0, 6, 0));
|
||||
doc.Add(NewMemberBusinessSharesTable(MemberHistory));
|
||||
}
|
||||
}
|
||||
|
||||
protected Cell NewDataHdr(string title, int colspan) {
|
||||
@@ -169,10 +183,10 @@ namespace Elwig.Documents {
|
||||
}).OrderByDescending(a => a.Size).ToList();
|
||||
|
||||
var tbl = new Table(ColsMM(40, 30, 35, 15, 25, 20), true)
|
||||
.SetWidth(UnitValue.CreatePercentValue(100)).SetFixedLayout()
|
||||
.SetBorderCollapse(BorderCollapsePropertyValue.COLLAPSE)
|
||||
.SetBorder(Border.NO_BORDER)
|
||||
.SetFontSize(10);
|
||||
.SetWidth(UnitValue.CreatePercentValue(100)).SetFixedLayout()
|
||||
.SetBorderCollapse(BorderCollapsePropertyValue.COLLAPSE)
|
||||
.SetBorder(Border.NO_BORDER)
|
||||
.SetFontSize(10);
|
||||
|
||||
tbl.AddHeaderCell(NewTh("Katastralgemeinde", rowspan: 2, left: true))
|
||||
.AddHeaderCell(NewTh("Ried", rowspan: 2, left: true))
|
||||
@@ -209,5 +223,135 @@ namespace Elwig.Documents {
|
||||
|
||||
return tbl;
|
||||
}
|
||||
|
||||
protected Cell[] NewBusinessSharesCells(MemberHistoryPoint p, bool isDiff = true) {
|
||||
if (App.Client.HasRedWhite) {
|
||||
return [
|
||||
NewTd(isDiff ? (p.SharesRed == 0 ? "" : p.SharesRed < 0 ? $"–{-p.SharesRed:N0}" : $"+{p.SharesRed:N0}") : $"{p.SharesRed:N0}",
|
||||
right: true, bold: !isDiff, borderTop: !isDiff),
|
||||
NewTd(isDiff ? (p.SharesWhite == 0 ? "" : p.SharesWhite < 0 ? $"–{-p.SharesWhite:N0}" : $"+{p.SharesWhite:N0}") : $"{p.SharesWhite:N0}",
|
||||
right: true, bold: !isDiff, borderTop: !isDiff),
|
||||
NewTd(isDiff ? (p.SharesDormant == 0 ? "" : p.SharesDormant < 0 ? $"–{-p.SharesDormant:N0}" : $"+{p.SharesDormant:N0}") : $"{p.SharesDormant:N0}",
|
||||
right: true, bold: !isDiff, borderTop: !isDiff),
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
NewTd(isDiff ? (p.Shares == 0 ? "" : p.Shares < 0 ? $"–{-p.Shares:N0}" : $"+{p.Shares:N0}") : $"{p.Shares:N0}",
|
||||
right: true, bold: !isDiff, borderTop: !isDiff),
|
||||
NewTd(isDiff ? (p.SharesDormant == 0 ? "" : p.SharesDormant < 0 ? $"–{-p.SharesDormant:N0}" : $"+{p.SharesDormant:N0}") : $"{p.SharesDormant:N0}",
|
||||
right : true, bold: !isDiff, borderTop: !isDiff),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
protected Table NewMemberBusinessSharesTable(IEnumerable<MemberHistory> history) {
|
||||
var tbl = new Table(ColsMM(18, 111, 12, 12, 12), true)
|
||||
.SetWidth(UnitValue.CreatePercentValue(100)).SetFixedLayout()
|
||||
.SetBorderCollapse(BorderCollapsePropertyValue.COLLAPSE)
|
||||
.SetBorder(Border.NO_BORDER)
|
||||
.SetFontSize(10);
|
||||
|
||||
var tw = App.Client.HasRedWhite ? 1 : 2;
|
||||
tbl.AddHeaderCell(NewTh("Datum", rowspan: 2))
|
||||
.AddHeaderCell(NewTh("Text", rowspan: 2, colspan: tw, left: true))
|
||||
.AddHeaderCell(NewTh("Geschäftsanteile", colspan: App.Client.HasRedWhite ? 3 : 2));
|
||||
if (App.Client.HasRedWhite) {
|
||||
tbl.AddHeaderCell(NewTh("rot"))
|
||||
.AddHeaderCell(NewTh("weiß"))
|
||||
.AddHeaderCell(NewTh("ruhend"));
|
||||
} else {
|
||||
tbl.AddHeaderCell(NewTh("normal"))
|
||||
.AddHeaderCell(NewTh("ruhend"));
|
||||
}
|
||||
|
||||
if (!history.Any() || Member.EntryDate <= history.First().Date) {
|
||||
tbl.AddCell(NewTd($"{Member.EntryDate:dd.MM.yyyy}"))
|
||||
.AddCell(NewTd("Eintritt", colspan: tw, bold: true))
|
||||
.AddCells(NewBusinessSharesCells(new()));
|
||||
}
|
||||
|
||||
var recorded = history.Aggregate(new MemberHistoryPoint(), (s, h) => new(
|
||||
s.Shares + (h.ToMgNr == Member.MgNr && h.ToType == 1 ? h.Shares : 0) - (h.FromMgNr == Member.MgNr && h.FromType == 1 ? h.Shares : 0),
|
||||
s.SharesRed + (h.ToMgNr == Member.MgNr && h.ToType == 2 ? h.Shares : 0) - (h.FromMgNr == Member.MgNr && h.FromType == 2 ? h.Shares : 0),
|
||||
s.SharesWhite + (h.ToMgNr == Member.MgNr && h.ToType == 3 ? h.Shares : 0) - (h.FromMgNr == Member.MgNr && h.FromType == 3 ? h.Shares : 0),
|
||||
s.SharesDormant + (h.ToMgNr == Member.MgNr && h.ToType == 9 ? h.Shares : 0) - (h.FromMgNr == Member.MgNr && h.FromType == 9 ? h.Shares : 0)));
|
||||
var cur = new MemberHistoryPoint(Member.Shares - recorded.Shares, Member.SharesRed - recorded.SharesRed, Member.SharesWhite - recorded.SharesWhite, Member.SharesDormant - recorded.SharesDormant);
|
||||
|
||||
if (cur.Shares != 0 || cur.SharesRed != 0 || cur.SharesWhite != 0 || cur.SharesDormant != 0) {
|
||||
tbl.AddCell(NewTd())
|
||||
.AddCell(NewTd("Nicht erfasst", colspan: tw, italic: true))
|
||||
.AddCells(NewBusinessSharesCells(cur));
|
||||
if (history.Any()) {
|
||||
tbl.AddCell(NewTd(borderTop: true))
|
||||
.AddCell(NewTd($"Bis Lese {history.First().Date.Year - 1}", borderTop: true, colspan: tw, bold: true))
|
||||
.AddCells(NewBusinessSharesCells(cur, isDiff: false));
|
||||
}
|
||||
}
|
||||
|
||||
DateOnly? lastDate = null;
|
||||
foreach (var row in history) {
|
||||
int s = 0, r = 0, w = 0, d = 0;
|
||||
if (row.FromMgNr == Member.MgNr) {
|
||||
switch (row.FromType) {
|
||||
case 1: s -= row.Shares; break;
|
||||
case 2: r -= row.Shares; break;
|
||||
case 3: w -= row.Shares; break;
|
||||
case 9: d -= row.Shares; break;
|
||||
}
|
||||
}
|
||||
if (row.ToMgNr == Member.MgNr) {
|
||||
switch (row.ToType) {
|
||||
case 1: s += row.Shares; break;
|
||||
case 2: r += row.Shares; break;
|
||||
case 3: w += row.Shares; break;
|
||||
case 9: d += row.Shares; break;
|
||||
}
|
||||
}
|
||||
if (lastDate < Member.EntryDate && row.Date <= Member.EntryDate) {
|
||||
tbl.AddCell(NewTd($"{Member.EntryDate:dd.MM.yyyy}"))
|
||||
.AddCell(NewTd("Eintritt", colspan: tw, bold: true))
|
||||
.AddCells(NewBusinessSharesCells(new()));
|
||||
}
|
||||
if (lastDate != null && row.Date.Year != lastDate?.Year) {
|
||||
tbl.AddCell(NewTd(borderTop: true))
|
||||
.AddCell(NewTd(lastDate?.Year == row.Date.Year - 1 ? $"Lese {lastDate?.Year}" : $"Lese {lastDate?.Year}–{row.Date.Year - 1}", borderTop: true, colspan: tw, bold: true))
|
||||
.AddCells(NewBusinessSharesCells(cur, isDiff: false));
|
||||
}
|
||||
if (lastDate < Member.ExitDate && row.Date <= Member.ExitDate) {
|
||||
tbl.AddCell(NewTd($"{Member.ExitDate:dd.MM.yyyy}"))
|
||||
.AddCell(NewTd("Austritt", colspan: tw, bold: true))
|
||||
.AddCells(NewBusinessSharesCells(new()));
|
||||
}
|
||||
cur = new(cur.Shares + s, cur.SharesRed + r, cur.SharesWhite + w, cur.SharesDormant + d);
|
||||
|
||||
var reason = row.Reason;
|
||||
if (reason == "auto") {
|
||||
reason = "Automatische Nachzeichnung";
|
||||
} else if (reason == "transfer") {
|
||||
if (row.ToMgNr == Member.MgNr) {
|
||||
reason = $"Übertragen von {row.FromMember.AdministrativeName} (MgNr. {row.FromMgNr})";
|
||||
} else {
|
||||
reason = $"Übertragen an {row.ToMember.AdministrativeName} (MgNr. {row.ToMgNr})";
|
||||
}
|
||||
}
|
||||
|
||||
tbl.AddCell(NewTd($"{row.Date:dd.MM.yyyy}"))
|
||||
.AddCell(NewTd(reason, colspan: tw))
|
||||
.AddCells(NewBusinessSharesCells(new(s, r, w, d)));
|
||||
lastDate = row.Date;
|
||||
}
|
||||
|
||||
if (Member.ExitDate != null && (!history.Any() || Member.ExitDate > history.Last().Date)) {
|
||||
tbl.AddCell(NewTd($"{Member.ExitDate:dd.MM.yyyy}"))
|
||||
.AddCell(NewTd("Austritt", colspan: tw, bold: true))
|
||||
.AddCells(NewBusinessSharesCells(new()));
|
||||
}
|
||||
|
||||
tbl.AddCell(NewTd(borderTop: true))
|
||||
.AddCell(NewTd(lastDate == null ? "Aktuell" : $"Ab Lese {lastDate?.Year}", borderTop: true, colspan: tw, bold: true))
|
||||
.AddCells(NewBusinessSharesCells(cur, isDiff: false));
|
||||
|
||||
return tbl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Elwig.Documents {
|
||||
|
||||
.AddCell(NewSectionTh("Datum/Überw.:", overflow: true))
|
||||
.AddCell(NewTd($"{Variant.Date:dd.MM.yyyy} / {Variant.TransferDate:dd.MM.yyyy}", colspan: 4, center: true))
|
||||
.AddCell(NewSectionTh("Automatische Nachzeichnung der GA:", colspan: 2, borderLeft: true))
|
||||
.AddCell(NewSectionTh("(Automatische) Nachzeichnung von GA:", colspan: 2, borderLeft: true))
|
||||
.AddCell(NewTd(BillingData.ConsiderAutoBusinessShares ? "Ja" : "Nein", center: true))
|
||||
|
||||
.AddCell(NewSectionTh("Berechnung:"))
|
||||
|
||||
@@ -54,10 +54,10 @@ namespace Elwig.Helpers.Billing {
|
||||
if (addMinShares < 1) addMinShares = 1;
|
||||
using var cnx = await AppDbContext.ConnectAsync();
|
||||
await cnx.ExecuteBatch($"""
|
||||
DELETE FROM member_history WHERE source = 'elwig' AND reason = 'auto' AND SUBSTR(date, 1, 4) = '{Year}';
|
||||
INSERT INTO member_history (histnr, from_mgnr, from_type, to_mgnr, to_type, date, reason, source, shares, value_per_share, currency)
|
||||
DELETE FROM member_history WHERE source = 'elwig' AND reason = 'auto' AND deduct_year = {Year};
|
||||
INSERT INTO member_history (histnr, from_mgnr, from_type, to_mgnr, to_type, date, reason, source, deduct_year, shares, value_per_share, currency)
|
||||
SELECT COALESCE((SELECT MAX(histnr) AS histnr FROM member_history), 0) + ROW_NUMBER() OVER(ORDER BY m.mgnr),
|
||||
NULL, NULL, u.mgnr, 1, '{date:yyyy-MM-dd}', 'auto', 'elwig',
|
||||
NULL, NULL, u.mgnr, 1, '{date:yyyy-MM-dd}', 'auto', 'elwig', s.year,
|
||||
CEIL((u.diff - {allowanceKg}.0 - {allowanceKgPerShare}.0 * u.shares) / s.max_kg_per_share
|
||||
- {allowanceShares.ToString(CultureInfo.InvariantCulture)}
|
||||
- {allowanceRel.ToString(CultureInfo.InvariantCulture)} * u.shares) AS adjust_shares,
|
||||
@@ -72,7 +72,7 @@ namespace Elwig.Helpers.Billing {
|
||||
public async Task UnAdjustBusinessShares() {
|
||||
using var cnx = await AppDbContext.ConnectAsync();
|
||||
await cnx.ExecuteBatch($"""
|
||||
DELETE FROM member_history WHERE source = 'elwig' AND reason = 'auto' AND SUBSTR(date, 1, 4) = '{Year}';
|
||||
DELETE FROM member_history WHERE source = 'elwig' AND reason = 'auto' AND deduct_year = {Year};
|
||||
""");
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,9 @@ namespace Elwig.Models.Entities {
|
||||
[Column("currency")]
|
||||
public string? CurrencyCode { get; set; }
|
||||
|
||||
[Column("deduct_year")]
|
||||
public int? DeductYear { get; set; }
|
||||
|
||||
[Column("comment")]
|
||||
public string? Comment { get; set; }
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ CREATE TABLE member_history_new (
|
||||
shares INTEGER NOT NULL,
|
||||
value_per_share INTEGER DEFAULT NULL,
|
||||
currency TEXT DEFAULT NULL,
|
||||
deduct_year INTEGER DEFAULT NULL,
|
||||
comment TEXT DEFAULT NULL,
|
||||
|
||||
CONSTRAINT pk_member_history PRIMARY KEY (histnr),
|
||||
@@ -44,8 +45,8 @@ CREATE TABLE member_history_new (
|
||||
((to_mgnr IS NULL AND to_type IS NULL) OR (to_mgnr IS NOT NULL AND to_type IS NOT NULL)))
|
||||
) STRICT;
|
||||
|
||||
INSERT INTO member_history_new (histnr, from_mgnr, from_type, to_mgnr, to_type, date, reason, source, shares, value_per_share, currency, comment)
|
||||
SELECT ROW_NUMBER() OVER(ORDER BY h.date, h.mgnr), NULL, NULL, h.mgnr, 1, h.date, h.type, 'elwig', h.business_shares, s.bs_value / POW(10, s.precision - 2), s.currency, comment
|
||||
INSERT INTO member_history_new (histnr, from_mgnr, from_type, to_mgnr, to_type, date, reason, source, shares, value_per_share, currency, deduct_year, comment)
|
||||
SELECT ROW_NUMBER() OVER(ORDER BY h.date, h.mgnr), NULL, NULL, h.mgnr, 1, h.date, h.type, 'elwig', h.business_shares, s.bs_value / POW(10, s.precision - 2), s.currency, IIF(h.type = 'auto', s.year, NULL), comment
|
||||
FROM member_history h
|
||||
JOIN season s ON s.year = SUBSTR(h.date, 1, 4);
|
||||
|
||||
|
||||
@@ -552,7 +552,8 @@
|
||||
|
||||
<Label Content="Mitgliederbewegungen:" Margin="10,40,10,10"/>
|
||||
<CheckBox x:Name="ParameterBusinessShareHistoryInput" Content="Mit Elwig erfassen" Margin="160,45,10,15"
|
||||
HorizontalAlignment="Left"/>
|
||||
HorizontalAlignment="Left"
|
||||
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox x:Name="ParameterAreaComGroup" Header="Berechnung Flächenbindungen (aktuelle Saison)" Margin="10,10,10,0" VerticalAlignment="Top">
|
||||
|
||||
@@ -619,22 +619,26 @@
|
||||
Margin="0,40,10,0" Width="78" Grid.Column="1" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
TextChanged="DateInput_TextChanged" LostFocus="DateInput_LostFocus"/>
|
||||
|
||||
<Label Content="Geschäftsanteile:" Margin="10,65,0,0" Grid.Column="0"/>
|
||||
<Label x:Name="BusinessSharesLabel" Content="(rot/weiß/ruhend)" Margin="10,78,0,0" Grid.Column="0" FontSize="10"/>
|
||||
<Label Content="BH-Konto:" Margin="10,70,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="AccountingNrInput" Text="{Binding AccountingNr, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,70,10,0" Width="63" Grid.Column="1" HorizontalAlignment="Left"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<Label Content="Geschäftsanteile:" Margin="10,95,0,0" Grid.Column="0"/>
|
||||
<Label x:Name="BusinessSharesLabel" Content="(rot/weiß/ruhend)" Margin="10,108,0,0" Grid.Column="0" FontSize="10"/>
|
||||
<TextBox x:Name="BusinessShares1Input" Text="{Binding BusinessShares1String, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,70,10,0" Width="32" Grid.Column="1" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
Margin="0,100,10,0" Width="32" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
TextChanged="IntegerInput_TextChanged"/>
|
||||
<TextBox x:Name="BusinessShares2Input" Text="{Binding BusinessShares2String, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="37,70,10,0" Width="32" Grid.Column="1" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
Margin="37,100,10,0" Width="32" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
TextChanged="IntegerInput_TextChanged"/>
|
||||
<TextBox x:Name="BusinessShares3Input" Text="{Binding BusinessShares3String, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="74,70,10,0" Width="32" Grid.Column="1" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
Margin="74,100,10,0" Width="32" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
TextChanged="IntegerInput_TextChanged"/>
|
||||
|
||||
<Label Content="BH-Konto:" Margin="10,100,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="AccountingNrInput" Text="{Binding AccountingNr, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,100,10,0" Grid.Column="1"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
<Button x:Name="BusinessSharesButton" FontFamily="Segoe MDL2 Assets" Content="" FontSize="16" Padding="0.5,0,0,0" IsEnabled="{Binding IsMemberSelected}"
|
||||
Margin="111,100,10,0" Width="25" Height="25" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
ToolTip="Geschäftsanteile bearbeiten"
|
||||
Click="BusinessSharesButton_Click"/>
|
||||
|
||||
<CheckBox x:Name="ActiveInput" Content="Aktiv" IsChecked="{Binding IsActive, Mode=TwoWay}" IsEnabled="False"
|
||||
Checked="ActiveInput_Changed" Unchecked="ActiveInput_Changed"
|
||||
@@ -663,7 +667,7 @@
|
||||
|
||||
<Label Content="Anmerkung:" Margin="10,190,0,0" Grid.Column="0"/>
|
||||
<TextBox x:Name="CommentInput" Text="{Binding Comment, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,190,10,70" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
Margin="0,190,10,70" Grid.Column="1" Grid.ColumnSpan="2" FontSize="12"
|
||||
TextChanged="TextBox_TextChanged"
|
||||
VerticalAlignment="Stretch" Height="auto" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible"/>
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ using Elwig.Services;
|
||||
using Elwig.ViewModels;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Elwig.Windows {
|
||||
public partial class MemberAdminWindow : AdministrationWindow {
|
||||
@@ -38,9 +39,16 @@ namespace Elwig.Windows {
|
||||
CommandBindings.Add(new CommandBinding(CtrlO, Menu_List_ShowActive_Click));
|
||||
CommandBindings.Add(new CommandBinding(CtrlShiftP, Menu_MemberDataSheet_Print_Click));
|
||||
CommandBindings.Add(new CommandBinding(CtrlShiftO, Menu_List_PrintActive_Click));
|
||||
ExemptInputs = [
|
||||
List<Control> exempt = [
|
||||
SearchInput, ActiveMemberInput, MemberList,
|
||||
];
|
||||
if (App.Client.EnableMemberHistory) {
|
||||
exempt.AddRange([BusinessShares1Input, BusinessShares2Input, BusinessShares3Input]);
|
||||
BusinessShares1Input.IsReadOnly = true;
|
||||
BusinessShares2Input.IsReadOnly = true;
|
||||
BusinessShares3Input.IsReadOnly = true;
|
||||
}
|
||||
ExemptInputs = [.. exempt];
|
||||
RequiredInputs = [
|
||||
MgNrInput, GivenNameInput, NameInput,
|
||||
AddressInput, PlzInput, OrtInput, BillingOrtInput,
|
||||
@@ -101,6 +109,11 @@ namespace Elwig.Windows {
|
||||
BusinessShares2Input.Background = Brushes.WhiteSmoke;
|
||||
BusinessShares2Input.ToolTip = "Geschäftsanteile (ruhend)";
|
||||
BusinessShares3Input.Visibility = Visibility.Hidden;
|
||||
BusinessSharesButton.Margin = new(74, 100, 10, 0);
|
||||
}
|
||||
|
||||
if (!App.Client.EnableMemberHistory) {
|
||||
BusinessSharesButton.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
UpdateContactInfoVisibility();
|
||||
@@ -198,6 +211,17 @@ namespace Elwig.Windows {
|
||||
ClearOriginalValues();
|
||||
ClearDefaultValues();
|
||||
await ViewModel.InitInputs();
|
||||
if (App.Client.EnableMemberHistory) {
|
||||
BusinessShares1Input.Text = "0";
|
||||
BusinessShares2Input.Text = "0";
|
||||
BusinessShares3Input.Text = "0";
|
||||
} else if (App.Client.HasRedWhite) {
|
||||
BusinessShares3Input.Text = "0";
|
||||
SetDefaultValue(BusinessShares3Input);
|
||||
} else {
|
||||
BusinessShares2Input.Text = "0";
|
||||
SetDefaultValue(BusinessShares2Input);
|
||||
}
|
||||
SetDefaultValue(MgNrInput);
|
||||
SetDefaultValue(EntryDateInput);
|
||||
SetDefaultValue(ActiveInput);
|
||||
@@ -493,6 +517,11 @@ namespace Elwig.Windows {
|
||||
ViewModel.EnableSearchInputs = true;
|
||||
}
|
||||
|
||||
private void BusinessSharesButton_Click(object sender, RoutedEventArgs evt) {
|
||||
// TODO
|
||||
// App.FocusBusinessSharesWindow(ViewModel.SelectedMember!.MgNr);
|
||||
}
|
||||
|
||||
private void AreaCommitmentButton_Click(object sender, RoutedEventArgs evt) {
|
||||
App.FocusMemberAreaComs(ViewModel.SelectedMember!.MgNr);
|
||||
}
|
||||
@@ -760,6 +789,14 @@ namespace Elwig.Windows {
|
||||
|
||||
new protected void ClearInputs(bool validate = false) {
|
||||
ViewModel.ClearInputs();
|
||||
if (App.Client.EnableMemberHistory) {
|
||||
BusinessShares1Input.Text = "";
|
||||
BusinessShares2Input.Text = "";
|
||||
BusinessShares3Input.Text = "";
|
||||
ControlUtils.ClearInputState(BusinessShares1Input);
|
||||
ControlUtils.ClearInputState(BusinessShares2Input);
|
||||
ControlUtils.ClearInputState(BusinessShares3Input);
|
||||
}
|
||||
base.ClearInputs(validate);
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="Automatische Nachzeichnung der Geschäftsanteile" Margin="5,10,10,10" Height="180" Width="365"
|
||||
<GroupBox Header="Automatische Nachzeichnung von Geschäftsanteilen" Margin="5,10,10,10" Height="180" Width="365"
|
||||
VerticalAlignment="Bottom" HorizontalAlignment="Left">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Elwig.Windows {
|
||||
CustomPayments = await ctx.CustomPayments.Where(p => p.Year == Year).ToDictionaryAsync(p => p.MgNr, p => p);
|
||||
|
||||
var history = await ctx.MemberHistory
|
||||
.Where(h => h.DateString.CompareTo($"{Year}-01-01") >= 0 && h.DateString.CompareTo($"{Year}-12-31") <= 0 && h.Reason == "auto" && h.Shares > 0)
|
||||
.Where(h => h.DeductYear == Year)
|
||||
.GroupBy(h => h.ToMember)
|
||||
.ToDictionaryAsync(h => h.Key.MgNr, h => h.Sum(g => g.Shares));
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
Margin="110,135,10,10" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Checked="ConsiderPenaltyInput_Changed" Unchecked="ConsiderPenaltyInput_Changed"/>
|
||||
<CheckBox x:Name="ConsiderAutoInput" IsChecked="{Binding ConsiderAuto, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsEnabled}"
|
||||
Content="Automatische Nachzeichnungen der GA"
|
||||
Content="(Automatische) Nachzeichnungen von GA"
|
||||
Margin="110,155,10,10" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Checked="ConsiderAutoInput_Changed" Unchecked="ConsiderAutoInput_Changed"/>
|
||||
<CheckBox x:Name="ConsiderCustomInput" IsChecked="{Binding ConsiderCustom, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsEnabled}"
|
||||
|
||||
Reference in New Issue
Block a user