PaymentVariantsWindow: Add possibility to switch options on/off
This commit is contained in:
@ -17,6 +17,7 @@ namespace Elwig.Documents {
|
|||||||
public int Precision;
|
public int Precision;
|
||||||
public string MemberModifier;
|
public string MemberModifier;
|
||||||
public IEnumerable<(string Name, int Kg, decimal Amount)>? MemberUnderDeliveries;
|
public IEnumerable<(string Name, int Kg, decimal Amount)>? MemberUnderDeliveries;
|
||||||
|
public decimal MemberTotalUnderDelivery;
|
||||||
|
|
||||||
public CreditNote(AppDbContext ctx, PaymentMember p, CreditNoteData data, Dictionary<string, UnderDelivery>? underDeliveries = null) :
|
public CreditNote(AppDbContext ctx, PaymentMember p, CreditNoteData data, Dictionary<string, UnderDelivery>? underDeliveries = null) :
|
||||||
base($"{Name} {(p.Credit != null ? $"Nr. {p.Credit.Year}/{p.Credit.TgNr:000}" : p.Member.Name)} – {p.Variant.Name}", p.Member) {
|
base($"{Name} {(p.Credit != null ? $"Nr. {p.Credit.Year}/{p.Credit.TgNr:000}" : p.Member.Name)} – {p.Variant.Name}", p.Member) {
|
||||||
@ -32,6 +33,10 @@ namespace Elwig.Documents {
|
|||||||
} else {
|
} else {
|
||||||
MemberModifier = "Sonstige Zu-/Abschläge";
|
MemberModifier = "Sonstige Zu-/Abschläge";
|
||||||
}
|
}
|
||||||
|
var total = data.Rows.SelectMany(r => r.Buckets).Sum(b => b.Value);
|
||||||
|
var totalUnderDelivery = total - p.Member.BusinessShares * season.MinKgPerBusinessShare;
|
||||||
|
MemberTotalUnderDelivery = totalUnderDelivery < 0 ? totalUnderDelivery * (season.PenaltyPerKg ?? 0) - (season.PenaltyAmount ?? 0) : 0;
|
||||||
|
if (total == 0) MemberTotalUnderDelivery -= (season.PenaltyNone ?? 0);
|
||||||
Aside = Aside.Replace("</table>", "") +
|
Aside = Aside.Replace("</table>", "") +
|
||||||
$"<thead><tr><th colspan='2'>Gutschrift</th></tr></thead><tbody>" +
|
$"<thead><tr><th colspan='2'>Gutschrift</th></tr></thead><tbody>" +
|
||||||
$"<tr><th>TG-Nr.</th><td>{(p.Credit != null ? $"{p.Credit.Year}/{p.Credit.TgNr:000}" : "-")}</td></tr>" +
|
$"<tr><th>TG-Nr.</th><td>{(p.Credit != null ? $"{p.Credit.Year}/{p.Credit.TgNr:000}" : "-")}</td></tr>" +
|
||||||
|
@ -136,6 +136,10 @@
|
|||||||
}
|
}
|
||||||
penalty = Math.Round(penalty, 2, MidpointRounding.AwayFromZero);
|
penalty = Math.Round(penalty, 2, MidpointRounding.AwayFromZero);
|
||||||
}
|
}
|
||||||
|
@if (Model.MemberTotalUnderDelivery != 0) {
|
||||||
|
@Raw(FormatRow("Unterlieferung (GA)", Model.MemberTotalUnderDelivery, add: true));
|
||||||
|
penalty += Math.Round(Model.MemberTotalUnderDelivery, 2, MidpointRounding.AwayFromZero);
|
||||||
|
}
|
||||||
|
|
||||||
@if (Model.Credit == null) {
|
@if (Model.Credit == null) {
|
||||||
@Raw(FormatRow("Auszahlungsbetrag", (Model.Payment?.Amount + penalty) ?? (sum + penalty), bold: true))
|
@Raw(FormatRow("Auszahlungsbetrag", (Model.Payment?.Amount + penalty) ?? (sum + penalty), bold: true))
|
||||||
|
@ -9,7 +9,7 @@ namespace Elwig.Helpers {
|
|||||||
public static class AppDbUpdater {
|
public static class AppDbUpdater {
|
||||||
|
|
||||||
// Don't forget to update value in Tests/fetch-resources.bat!
|
// Don't forget to update value in Tests/fetch-resources.bat!
|
||||||
public static readonly int RequiredSchemaVersion = 12;
|
public static readonly int RequiredSchemaVersion = 13;
|
||||||
|
|
||||||
private static int VersionOffset = 0;
|
private static int VersionOffset = 0;
|
||||||
|
|
||||||
|
@ -23,12 +23,44 @@ namespace Elwig.Helpers.Billing {
|
|||||||
Schema = await JsonSchema.FromJsonAsync(stream ?? throw new ArgumentException("JSON schema not found"));
|
Schema = await JsonSchema.FromJsonAsync(stream ?? throw new ArgumentException("JSON schema not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public readonly JsonObject Data;
|
||||||
|
|
||||||
private readonly CalculationMode Mode;
|
private readonly CalculationMode Mode;
|
||||||
private readonly JsonObject Data;
|
|
||||||
private readonly Dictionary<int, Curve> Curves;
|
private readonly Dictionary<int, Curve> Curves;
|
||||||
private readonly Dictionary<string, Curve> PaymentData;
|
private readonly Dictionary<string, Curve> PaymentData;
|
||||||
private readonly Dictionary<string, Curve> QualityData;
|
private readonly Dictionary<string, Curve> QualityData;
|
||||||
|
|
||||||
|
public bool ConsiderDelieryModifiers {
|
||||||
|
get => GetConsider("consider_delivery_modifiers");
|
||||||
|
set => SetConsider(value, "consider_delivery_modifiers");
|
||||||
|
}
|
||||||
|
public bool ConsiderContractPenalties {
|
||||||
|
get => GetConsider("consider_contract_penalties");
|
||||||
|
set => SetConsider(value, "consider_contract_penalties");
|
||||||
|
}
|
||||||
|
public bool ConsiderTotalPenalty {
|
||||||
|
get => GetConsider("consider_total_penalty");
|
||||||
|
set => SetConsider(value, "consider_total_penalty");
|
||||||
|
}
|
||||||
|
public bool ConsiderAutoBusinessShares {
|
||||||
|
get => GetConsider("consider_auto_business_shares");
|
||||||
|
set => SetConsider(value, "consider_total_penalty");
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool GetConsider(string name, string? wgMasterName = null) {
|
||||||
|
return ((Mode == CalculationMode.Elwig) ? Data[name] : Data[wgMasterName ?? ""])?.AsValue().GetValue<bool>() ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetConsider(bool value, string name, string? wgMasterName = null) {
|
||||||
|
if (Mode == CalculationMode.WgMaster && wgMasterName == null) {
|
||||||
|
return;
|
||||||
|
} else if (value) {
|
||||||
|
Data[(Mode == CalculationMode.Elwig) ? name : wgMasterName ?? ""] = value;
|
||||||
|
} else {
|
||||||
|
Data.Remove((Mode == CalculationMode.Elwig) ? name : wgMasterName ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BillingData(JsonObject data, IEnumerable<string> attributeVariants) {
|
public BillingData(JsonObject data, IEnumerable<string> attributeVariants) {
|
||||||
if (attributeVariants.Any(e => e.Any(c => c < 'A' || c > 'Z')))
|
if (attributeVariants.Any(e => e.Any(c => c < 'A' || c > 'Z')))
|
||||||
throw new ArgumentException("Invalid attributeVariants");
|
throw new ArgumentException("Invalid attributeVariants");
|
||||||
@ -51,6 +83,10 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BillingData FromJson(string json) {
|
||||||
|
return FromJson(json, []);
|
||||||
|
}
|
||||||
|
|
||||||
public static BillingData FromJson(string json, IEnumerable<string> attributeVariants) {
|
public static BillingData FromJson(string json, IEnumerable<string> attributeVariants) {
|
||||||
return new(ParseJson(json), attributeVariants);
|
return new(ParseJson(json), attributeVariants);
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,19 @@ namespace Elwig.Helpers.Billing {
|
|||||||
|
|
||||||
protected readonly int AvNr;
|
protected readonly int AvNr;
|
||||||
protected readonly PaymentVar PaymentVariant;
|
protected readonly PaymentVar PaymentVariant;
|
||||||
|
protected readonly BillingData Data;
|
||||||
|
|
||||||
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");
|
||||||
|
var attrVariants = Context.DeliveryParts
|
||||||
|
.Where(d => d.Year == Year)
|
||||||
|
.Select(d => $"{d.SortId}{d.AttrId}")
|
||||||
|
.Distinct()
|
||||||
|
.ToList()
|
||||||
|
.Union(Context.WineVarieties.Select(v => v.SortId))
|
||||||
|
.ToList();
|
||||||
|
Data = BillingData.FromJson(PaymentVariant.Data, attrVariants);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Calculate() {
|
public async Task Calculate() {
|
||||||
@ -22,7 +31,8 @@ namespace Elwig.Helpers.Billing {
|
|||||||
await DeleteInDb(cnx);
|
await DeleteInDb(cnx);
|
||||||
await SetCalcTime(cnx);
|
await SetCalcTime(cnx);
|
||||||
await CalculatePrices(cnx);
|
await CalculatePrices(cnx);
|
||||||
await CalculateModifiers(cnx);
|
if (Data.ConsiderDelieryModifiers)
|
||||||
|
await CalculateDeliveryModifiers(cnx);
|
||||||
await CalculateMemberModifiers(cnx);
|
await CalculateMemberModifiers(cnx);
|
||||||
await tx.CommitAsync();
|
await tx.CommitAsync();
|
||||||
}
|
}
|
||||||
@ -39,7 +49,11 @@ namespace Elwig.Helpers.Billing {
|
|||||||
ROUND(p.amount / POW(10, s.precision - 2)) AS net_amount,
|
ROUND(p.amount / POW(10, s.precision - 2)) AS net_amount,
|
||||||
ROUND(lp.amount / POW(10, s.precision - 2)) AS prev_amount,
|
ROUND(lp.amount / POW(10, s.precision - 2)) AS prev_amount,
|
||||||
IIF(m.buchführend, s.vat_normal, s.vat_flatrate) AS vat,
|
IIF(m.buchführend, s.vat_normal, s.vat_flatrate) AS vat,
|
||||||
ROUND(COALESCE(u.total_penalty, 0) / POW(10, 4 - 2)) AS modifiers,
|
ROUND(
|
||||||
|
IIF({Data.ConsiderContractPenalties}, COALESCE(u.total_penalty, 0) / POW(10, 4 - 2), 0) +
|
||||||
|
IIF({Data.ConsiderTotalPenalty}, COALESCE(b.total_penalty, 0), 0) +
|
||||||
|
IIF({Data.ConsiderAutoBusinessShares}, 0, 0)
|
||||||
|
) AS modifiers,
|
||||||
lc.modifiers AS prev_modifiers
|
lc.modifiers AS prev_modifiers
|
||||||
FROM season s
|
FROM season s
|
||||||
JOIN payment_variant v ON v.year = s.year
|
JOIN payment_variant v ON v.year = s.year
|
||||||
@ -62,6 +76,14 @@ namespace Elwig.Helpers.Billing {
|
|||||||
FROM v_under_delivery u
|
FROM v_under_delivery u
|
||||||
JOIN area_commitment_type t ON t.vtrgid = u.bucket
|
JOIN area_commitment_type t ON t.vtrgid = u.bucket
|
||||||
GROUP BY year, mgnr) u ON (u.year, u.mgnr) = (s.year, m.mgnr)
|
GROUP BY year, mgnr) u ON (u.year, u.mgnr) = (s.year, m.mgnr)
|
||||||
|
LEFT JOIN (SELECT s.year, u.mgnr,
|
||||||
|
(COALESCE(IIF(u.weight = 0, -s.penalty_none, 0), 0) +
|
||||||
|
COALESCE(IIF(u.diff < 0, -s.penalty_amount, 0), 0) +
|
||||||
|
COALESCE(u.diff * s.penalty_per_kg, 0)
|
||||||
|
) / POW(10, s.precision - 2) AS total_penalty
|
||||||
|
FROM v_total_under_delivery u
|
||||||
|
JOIN season s ON s.year = u.year
|
||||||
|
WHERE u.diff < 0) b ON (b.year, b.mgnr) = (s.year, m.mgnr)
|
||||||
WHERE s.year = {Year} AND v.avnr = {AvNr};
|
WHERE s.year = {Year} AND v.avnr = {AvNr};
|
||||||
|
|
||||||
UPDATE payment_variant SET test_variant = FALSE WHERE (year, avnr) = ({Year}, {AvNr});
|
UPDATE payment_variant SET test_variant = FALSE WHERE (year, avnr) = ({Year}, {AvNr});
|
||||||
@ -119,17 +141,6 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async Task CalculatePrices(SqliteConnection cnx) {
|
protected async Task CalculatePrices(SqliteConnection cnx) {
|
||||||
var jsonData = PaymentVariant.Data;
|
|
||||||
var attrVariants = Context.DeliveryParts
|
|
||||||
.Where(d => d.Year == Year)
|
|
||||||
.Select(d => $"{d.SortId}{d.AttrId}")
|
|
||||||
.Distinct()
|
|
||||||
.ToList()
|
|
||||||
.Union(Context.WineVarieties.Select(v => v.SortId))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var data = BillingData.FromJson(jsonData, attrVariants);
|
|
||||||
|
|
||||||
var parts = new List<(int Year, int DId, int DPNr, int BktNr, string SortId, string Discr, int Value, double Oe, double Kmw, string QualId)>();
|
var parts = new List<(int Year, int DId, int DPNr, int BktNr, string SortId, string Discr, int Value, double Oe, double Kmw, string QualId)>();
|
||||||
using (var cmd = cnx.CreateCommand()) {
|
using (var cmd = cnx.CreateCommand()) {
|
||||||
cmd.CommandText = $"""
|
cmd.CommandText = $"""
|
||||||
@ -151,7 +162,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
var inserts = new List<(int Year, int DId, int DPNr, int BktNr, long Price, long Amount)>();
|
var inserts = new List<(int Year, int DId, int DPNr, int BktNr, long Price, long Amount)>();
|
||||||
foreach (var part in parts) {
|
foreach (var part in parts) {
|
||||||
var attrId = (part.Discr == "_" || part.Discr == "") ? null : part.Discr;
|
var attrId = (part.Discr == "_" || part.Discr == "") ? null : part.Discr;
|
||||||
var price = data.CalculatePrice(part.SortId, attrId, part.QualId, part.Discr != "_", part.Oe, part.Kmw);
|
var price = Data.CalculatePrice(part.SortId, attrId, part.QualId, part.Discr != "_", part.Oe, part.Kmw);
|
||||||
var priceL = PaymentVariant.Season.DecToDb(price);
|
var priceL = PaymentVariant.Season.DecToDb(price);
|
||||||
inserts.Add((part.Year, part.DId, part.DPNr, part.BktNr, priceL, priceL * part.Value));
|
inserts.Add((part.Year, part.DId, part.DPNr, part.BktNr, priceL, priceL * part.Value));
|
||||||
}
|
}
|
||||||
@ -162,7 +173,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task CalculateModifiers(SqliteConnection cnx) {
|
protected async Task CalculateDeliveryModifiers(SqliteConnection cnx) {
|
||||||
await AppDbContext.ExecuteBatch(cnx, $"""
|
await AppDbContext.ExecuteBatch(cnx, $"""
|
||||||
INSERT INTO payment_delivery_part (year, did, dpnr, avnr, net_amount, mod_abs, 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)
|
SELECT d.year, d.did, d.dpnr, {AvNr}, 0, COALESCE(m.abs, 0), COALESCE(m.rel, 0)
|
||||||
|
@ -8,6 +8,10 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"mode": {"enum": ["elwig"]},
|
"mode": {"enum": ["elwig"]},
|
||||||
"version": {"enum": [1]},
|
"version": {"enum": [1]},
|
||||||
|
"consider_delivery_modifiers": {"type": "boolean"},
|
||||||
|
"consider_contract_penalties": {"type": "boolean"},
|
||||||
|
"consider_total_penalty": {"type": "boolean"},
|
||||||
|
"consider_auto_business_shares": {"type": "boolean"},
|
||||||
"payment": {"$ref": "#/definitions/payment_1"},
|
"payment": {"$ref": "#/definitions/payment_1"},
|
||||||
"quality": {"$ref": "#/definitions/quality_1"},
|
"quality": {"$ref": "#/definitions/quality_1"},
|
||||||
"curves": {
|
"curves": {
|
||||||
|
31
Elwig/Resources/Sql/12-13.sql
Normal file
31
Elwig/Resources/Sql/12-13.sql
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
-- schema version 11 to 12
|
||||||
|
|
||||||
|
ALTER TABLE season ADD COLUMN bs_value INTEGER;
|
||||||
|
|
||||||
|
CREATE TABLE member_history (
|
||||||
|
mgnr INTEGER NOT NULL,
|
||||||
|
date TEXT NOT NULL CHECK (date REGEXP '^[1-9][0-9]{3}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$') DEFAULT CURRENT_DATE,
|
||||||
|
|
||||||
|
business_shares INTEGER NOT NULL,
|
||||||
|
type TEXT NOT NULL CHECK (type REGEXP '^[a-z_]+$'),
|
||||||
|
comment TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT pk_member_history PRIMARY KEY (mgnr, date),
|
||||||
|
CONSTRAINT fk_member_history_member FOREIGN KEY (mgnr) REFERENCES member (mgnr)
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
ON DELETE CASCADE
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
CREATE VIEW v_total_under_delivery AS
|
||||||
|
SELECT s.year, m.mgnr, m.business_shares,
|
||||||
|
m.business_shares * s.min_kg_per_bs AS min_kg,
|
||||||
|
m.business_shares * s.max_kg_per_bs AS max_kg,
|
||||||
|
COALESCE(d.sum, 0) AS weight,
|
||||||
|
IIF(COALESCE(d.sum, 0) < m.business_shares * s.min_kg_per_bs,
|
||||||
|
COALESCE(d.sum, 0) - m.business_shares * s.min_kg_per_bs,
|
||||||
|
IIF(COALESCE(d.sum, 0) > m.business_shares * s.max_kg_per_bs,
|
||||||
|
COALESCE(d.sum, 0) - m.business_shares * s.max_kg_per_bs,
|
||||||
|
0)) AS diff
|
||||||
|
FROM member m, season s
|
||||||
|
LEFT JOIN v_stat_member d ON (d.year, d.mgnr) = (s.year, m.mgnr)
|
||||||
|
ORDER BY s.year, m.mgnr;
|
@ -65,6 +65,12 @@
|
|||||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,60,5,0" Grid.RowSpan="2"
|
VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,60,5,0" Grid.RowSpan="2"
|
||||||
Click="DeleteButton_Click"/>
|
Click="DeleteButton_Click"/>
|
||||||
|
|
||||||
|
<TextBox x:Name="DataInput" Margin="10,200,35,10" Grid.Column="0" Grid.RowSpan="2"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="auto"
|
||||||
|
AcceptsReturn="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto"
|
||||||
|
FontFamily="Cascadia Code Light" FontSize="13"
|
||||||
|
TextChanged="DataInput_TextChanged"/>
|
||||||
|
|
||||||
<Label Content="Name:" Margin="10,10,0,0" Grid.Column="1"/>
|
<Label Content="Name:" Margin="10,10,0,0" Grid.Column="1"/>
|
||||||
<TextBox x:Name="NameInput" Width="200" Grid.Column="2" HorizontalAlignment="Left" Margin="0,10,0,0"
|
<TextBox x:Name="NameInput" Width="200" Grid.Column="2" HorizontalAlignment="Left" Margin="0,10,0,0"
|
||||||
TextChanged="NameInput_TextChanged"/>
|
TextChanged="NameInput_TextChanged"/>
|
||||||
@ -80,11 +86,20 @@
|
|||||||
<TextBox x:Name="TransferDateInput" Grid.Column="2" Width="77" HorizontalAlignment="Left" Margin="0,100,10,0"
|
<TextBox x:Name="TransferDateInput" Grid.Column="2" Width="77" HorizontalAlignment="Left" Margin="0,100,10,0"
|
||||||
TextChanged="TransferDateInput_TextChanged"/>
|
TextChanged="TransferDateInput_TextChanged"/>
|
||||||
|
|
||||||
<TextBox x:Name="DataInput" Margin="82,70,10,74" Grid.Column="2"
|
<Label Content="Berücksichtigen:" Margin="90,70,10,10" Grid.Column="2"/>
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="auto"
|
<CheckBox x:Name="ConsiderModifiersInput" Content="Zu-/Abschläge bei Lieferungen"
|
||||||
AcceptsReturn="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto"
|
Margin="110,95,10,10" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||||
FontFamily="Cascadia Code Light" FontSize="13"
|
Checked="ConsiderModifiersInput_Changed" Unchecked="ConsiderModifiersInput_Changed"/>
|
||||||
TextChanged="DataInput_TextChanged"/>
|
<CheckBox x:Name="ConsiderPenaltiesInput" Content="Pönalen bei Unterlieferungen (FB)"
|
||||||
|
Margin="110,115,10,10" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||||
|
Checked="ConsiderPenaltiesInput_Changed" Unchecked="ConsiderPenaltiesInput_Changed"/>
|
||||||
|
<CheckBox x:Name="ConsiderPenaltyInput" Content="Strafen bei Unterlieferungen (GA)"
|
||||||
|
Margin="110,135,10,10" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||||
|
Checked="ConsiderPenaltyInput_Changed" Unchecked="ConsiderPenaltyInput_Changed"/>
|
||||||
|
<CheckBox x:Name="ConsiderAutoInput" Content="Automatische Nachzeichnungen der GA"
|
||||||
|
Margin="110,155,10,10" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||||
|
Checked="ConsiderAutoInput_Changed" Unchecked="ConsiderAutoInput_Changed"/>
|
||||||
|
<Label Content="" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="0" Grid.Column="2" Margin="108,175,10,10"/>
|
||||||
|
|
||||||
<Grid Grid.Column="1" Grid.ColumnSpan="2" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="10,10,10,10">
|
<Grid Grid.Column="1" Grid.ColumnSpan="2" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="10,10,10,10">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
@ -21,6 +21,7 @@ namespace Elwig.Windows {
|
|||||||
public readonly int Year;
|
public readonly int Year;
|
||||||
public readonly bool SeasonLocked;
|
public readonly bool SeasonLocked;
|
||||||
private bool DataValid, DataChanged, NameChanged, CommentChanged, TransferDateValid, TransferDateChanged;
|
private bool DataValid, DataChanged, NameChanged, CommentChanged, TransferDateValid, TransferDateChanged;
|
||||||
|
private BillingData? BillingData;
|
||||||
|
|
||||||
private static readonly JsonSerializerOptions JsonOpt = new() { WriteIndented = true };
|
private static readonly JsonSerializerOptions JsonOpt = new() { WriteIndented = true };
|
||||||
|
|
||||||
@ -56,16 +57,37 @@ namespace Elwig.Windows {
|
|||||||
ExportButton.IsEnabled = locked;
|
ExportButton.IsEnabled = locked;
|
||||||
|
|
||||||
NameInput.Text = v.Name;
|
NameInput.Text = v.Name;
|
||||||
|
NameInput.IsReadOnly = false;
|
||||||
CommentInput.Text = v.Comment;
|
CommentInput.Text = v.Comment;
|
||||||
|
CommentInput.IsReadOnly = false;
|
||||||
DateInput.Text = $"{v.Date:dd.MM.yyyy}";
|
DateInput.Text = $"{v.Date:dd.MM.yyyy}";
|
||||||
|
DateInput.IsReadOnly = false;
|
||||||
TransferDateInput.Text = $"{v.TransferDate:dd.MM.yyyy}";
|
TransferDateInput.Text = $"{v.TransferDate:dd.MM.yyyy}";
|
||||||
if (App.Config.Debug) {
|
TransferDateInput.IsReadOnly = false;
|
||||||
try {
|
try {
|
||||||
var json = BillingData.ParseJson(v.Data);
|
BillingData = BillingData.FromJson(v.Data);
|
||||||
DataInput.Text = JsonSerializer.Serialize(json, JsonOpt);
|
ConsiderModifiersInput.IsChecked = BillingData.ConsiderDelieryModifiers;
|
||||||
|
ConsiderModifiersInput.IsEnabled = !locked;
|
||||||
|
ConsiderPenaltiesInput.IsChecked = BillingData.ConsiderContractPenalties;
|
||||||
|
ConsiderPenaltiesInput.IsEnabled = !locked;
|
||||||
|
ConsiderPenaltyInput.IsChecked = BillingData.ConsiderTotalPenalty;
|
||||||
|
ConsiderPenaltyInput.IsEnabled = !locked;
|
||||||
|
ConsiderAutoInput.IsChecked = BillingData.ConsiderAutoBusinessShares;
|
||||||
|
ConsiderAutoInput.IsEnabled = !locked;
|
||||||
|
DataInput.Text = JsonSerializer.Serialize(BillingData.Data, JsonOpt);
|
||||||
|
DataInput.IsReadOnly = locked;
|
||||||
} catch {
|
} catch {
|
||||||
|
BillingData = null;
|
||||||
|
ConsiderModifiersInput.IsChecked = false;
|
||||||
|
ConsiderModifiersInput.IsEnabled = false;
|
||||||
|
ConsiderPenaltiesInput.IsChecked = false;
|
||||||
|
ConsiderPenaltiesInput.IsEnabled = false;
|
||||||
|
ConsiderPenaltyInput.IsChecked = false;
|
||||||
|
ConsiderPenaltyInput.IsEnabled = false;
|
||||||
|
ConsiderAutoInput.IsChecked = false;
|
||||||
|
ConsiderAutoInput.IsEnabled = false;
|
||||||
DataInput.Text = v.Data;
|
DataInput.Text = v.Data;
|
||||||
}
|
DataInput.IsEnabled = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EditButton.Content = "Bearbeiten";
|
EditButton.Content = "Bearbeiten";
|
||||||
@ -81,11 +103,25 @@ namespace Elwig.Windows {
|
|||||||
PrintButton.IsEnabled = false;
|
PrintButton.IsEnabled = false;
|
||||||
ExportButton.IsEnabled = false;
|
ExportButton.IsEnabled = false;
|
||||||
|
|
||||||
|
BillingData = null;
|
||||||
NameInput.Text = "";
|
NameInput.Text = "";
|
||||||
|
NameInput.IsReadOnly = true;
|
||||||
CommentInput.Text = "";
|
CommentInput.Text = "";
|
||||||
|
CommentInput.IsReadOnly = true;
|
||||||
DateInput.Text = "";
|
DateInput.Text = "";
|
||||||
|
DateInput.IsReadOnly = true;
|
||||||
TransferDateInput.Text = "";
|
TransferDateInput.Text = "";
|
||||||
|
TransferDateInput.IsReadOnly = true;
|
||||||
|
ConsiderModifiersInput.IsChecked = false;
|
||||||
|
ConsiderModifiersInput.IsEnabled = false;
|
||||||
|
ConsiderPenaltiesInput.IsChecked = false;
|
||||||
|
ConsiderPenaltiesInput.IsEnabled = false;
|
||||||
|
ConsiderPenaltyInput.IsChecked = false;
|
||||||
|
ConsiderPenaltyInput.IsEnabled = false;
|
||||||
|
ConsiderAutoInput.IsChecked = false;
|
||||||
|
ConsiderAutoInput.IsEnabled = false;
|
||||||
DataInput.Text = "";
|
DataInput.Text = "";
|
||||||
|
DataInput.IsReadOnly = true;
|
||||||
}
|
}
|
||||||
UpdateSums();
|
UpdateSums();
|
||||||
UpdateSaveButton();
|
UpdateSaveButton();
|
||||||
@ -94,7 +130,11 @@ namespace Elwig.Windows {
|
|||||||
private void UpdateSaveButton() {
|
private void UpdateSaveButton() {
|
||||||
SaveButton.IsEnabled = PaymentVariantList.SelectedItem != null &&
|
SaveButton.IsEnabled = PaymentVariantList.SelectedItem != null &&
|
||||||
((DataChanged && DataValid) || NameChanged || CommentChanged ||
|
((DataChanged && DataValid) || NameChanged || CommentChanged ||
|
||||||
(TransferDateChanged && TransferDateValid));
|
(TransferDateChanged && TransferDateValid)) ||
|
||||||
|
(ConsiderModifiersInput.IsChecked != BillingData?.ConsiderDelieryModifiers) ||
|
||||||
|
(ConsiderPenaltiesInput.IsChecked != BillingData?.ConsiderContractPenalties) ||
|
||||||
|
(ConsiderPenaltyInput.IsChecked != BillingData?.ConsiderTotalPenalty) ||
|
||||||
|
(ConsiderAutoInput.IsChecked != BillingData?.ConsiderAutoBusinessShares);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateSums() {
|
private void UpdateSums() {
|
||||||
@ -268,15 +308,25 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void SaveButton_Click(object sender, RoutedEventArgs evt) {
|
private async void SaveButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
if (PaymentVariantList.SelectedItem is not PaymentVar v) return;
|
if (PaymentVariantList.SelectedItem is not PaymentVar v || BillingData == null) return;
|
||||||
try {
|
try {
|
||||||
v.Name = NameInput.Text;
|
v.Name = NameInput.Text;
|
||||||
v.Comment = (CommentInput.Text != "") ? CommentInput.Text : null;
|
v.Comment = (CommentInput.Text != "") ? CommentInput.Text : null;
|
||||||
v.TransferDateString = (TransferDateInput.Text != "") ? string.Join("-", TransferDateInput.Text.Split(".").Reverse()) : null;
|
v.TransferDateString = (TransferDateInput.Text != "") ? string.Join("-", TransferDateInput.Text.Split(".").Reverse()) : null;
|
||||||
if (App.Config.Debug) v.Data = JsonSerializer.Serialize(BillingData.ParseJson(DataInput.Text));
|
var d = App.Config.Debug ? BillingData.FromJson(DataInput.Text) : BillingData;
|
||||||
|
d.ConsiderDelieryModifiers = ConsiderModifiersInput.IsChecked ?? false;
|
||||||
|
d.ConsiderContractPenalties = ConsiderPenaltiesInput.IsChecked ?? false;
|
||||||
|
d.ConsiderTotalPenalty = ConsiderPenaltyInput.IsChecked ?? false;
|
||||||
|
d.ConsiderAutoBusinessShares = ConsiderAutoInput.IsChecked ?? false;
|
||||||
|
v.Data = JsonSerializer.Serialize(d.Data);
|
||||||
Context.Update(v);
|
Context.Update(v);
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
await App.HintContextChange();
|
await App.HintContextChange();
|
||||||
|
CommentInput_TextChanged(null, null);
|
||||||
|
ConsiderModifiersInput_Changed(null, null);
|
||||||
|
ConsiderPenaltiesInput_Changed(null, null);
|
||||||
|
ConsiderPenaltyInput_Changed(null, null);
|
||||||
|
ConsiderAutoInput_Changed(null, null);
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
await HintContextChange();
|
await HintContextChange();
|
||||||
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||||
@ -304,7 +354,7 @@ namespace Elwig.Windows {
|
|||||||
UpdateSaveButton();
|
UpdateSaveButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CommentInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
private void CommentInput_TextChanged(object? sender, TextChangedEventArgs? evt) {
|
||||||
if (PaymentVariantList.SelectedItem is not PaymentVar v) {
|
if (PaymentVariantList.SelectedItem is not PaymentVar v) {
|
||||||
ControlUtils.ClearInputState(CommentInput);
|
ControlUtils.ClearInputState(CommentInput);
|
||||||
return;
|
return;
|
||||||
@ -366,6 +416,58 @@ namespace Elwig.Windows {
|
|||||||
UpdateSaveButton();
|
UpdateSaveButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ConsiderModifiersInput_Changed(object? sender, RoutedEventArgs? evt) {
|
||||||
|
if (BillingData == null) {
|
||||||
|
ControlUtils.ClearInputState(ConsiderModifiersInput);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (BillingData.ConsiderDelieryModifiers != ConsiderModifiersInput.IsChecked) {
|
||||||
|
ControlUtils.SetInputChanged(ConsiderModifiersInput);
|
||||||
|
} else {
|
||||||
|
ControlUtils.ClearInputState(ConsiderModifiersInput);
|
||||||
|
}
|
||||||
|
UpdateSaveButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConsiderPenaltiesInput_Changed(object? sender, RoutedEventArgs? evt) {
|
||||||
|
if (BillingData == null) {
|
||||||
|
ControlUtils.ClearInputState(ConsiderPenaltiesInput);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (BillingData.ConsiderContractPenalties != ConsiderPenaltiesInput.IsChecked) {
|
||||||
|
ControlUtils.SetInputChanged(ConsiderPenaltiesInput);
|
||||||
|
} else {
|
||||||
|
ControlUtils.ClearInputState(ConsiderPenaltiesInput);
|
||||||
|
}
|
||||||
|
UpdateSaveButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConsiderPenaltyInput_Changed(object? sender, RoutedEventArgs? evt) {
|
||||||
|
if (BillingData == null) {
|
||||||
|
ControlUtils.ClearInputState(ConsiderPenaltyInput);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (BillingData.ConsiderTotalPenalty != ConsiderPenaltyInput.IsChecked) {
|
||||||
|
ControlUtils.SetInputChanged(ConsiderPenaltyInput);
|
||||||
|
} else {
|
||||||
|
ControlUtils.ClearInputState(ConsiderPenaltyInput);
|
||||||
|
}
|
||||||
|
UpdateSaveButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConsiderAutoInput_Changed(object? sender, RoutedEventArgs? evt) {
|
||||||
|
if (BillingData == null) {
|
||||||
|
ControlUtils.ClearInputState(ConsiderAutoInput);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (BillingData.ConsiderAutoBusinessShares != ConsiderAutoInput.IsChecked) {
|
||||||
|
ControlUtils.SetInputChanged(ConsiderAutoInput);
|
||||||
|
} else {
|
||||||
|
ControlUtils.ClearInputState(ConsiderAutoInput);
|
||||||
|
}
|
||||||
|
UpdateSaveButton();
|
||||||
|
}
|
||||||
|
|
||||||
private async Task Generate(int mode) {
|
private async Task Generate(int mode) {
|
||||||
if (PaymentVariantList.SelectedItem is not PaymentVar v)
|
if (PaymentVariantList.SelectedItem is not PaymentVar v)
|
||||||
return;
|
return;
|
||||||
|
@ -1 +1 @@
|
|||||||
curl -s "https://www.necronda.net/elwig/files/create.sql?v=12" -u "elwig:ganzGeheim123!" -o "Resources\Create.sql"
|
curl -s "https://www.necronda.net/elwig/files/create.sql?v=13" -u "elwig:ganzGeheim123!" -o "Resources\Create.sql"
|
||||||
|
Reference in New Issue
Block a user