[#40] Billing: Add Rebelzuschlag
This commit is contained in:
@ -10,13 +10,14 @@
|
|||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width: 25mm;"/>
|
<col style="width: 25mm;"/>
|
||||||
<col style="width: 5mm;"/>
|
<col style="width: 5mm;"/>
|
||||||
<col style="width: 24mm;"/>
|
<col style="width: 22mm;"/>
|
||||||
<col style="width: 16mm;"/>
|
<col style="width: 15mm;"/>
|
||||||
<col style="width: 10mm;"/>
|
<col style="width: 10mm;"/>
|
||||||
<col style="width: 10mm;"/>
|
<col style="width: 10mm;"/>
|
||||||
<col style="width: 15mm;"/>
|
<col style="width: 15mm;"/>
|
||||||
<col style="width: 12mm;"/>
|
<col style="width: 12mm;"/>
|
||||||
<col style="width: 15mm;"/>
|
<col style="width: 13mm;"/>
|
||||||
|
<col style="width: 5mm;"/>
|
||||||
<col style="width: 17mm;"/>
|
<col style="width: 17mm;"/>
|
||||||
<col style="width: 16mm;"/>
|
<col style="width: 16mm;"/>
|
||||||
</colgroup>
|
</colgroup>
|
||||||
@ -29,6 +30,7 @@
|
|||||||
<th colspan="2">Gradation</th>
|
<th colspan="2">Gradation</th>
|
||||||
<th colspan="2">Flächenbindung</th>
|
<th colspan="2">Flächenbindung</th>
|
||||||
<th>Preis</th>
|
<th>Preis</th>
|
||||||
|
<th class="narrow">Rbl.</th>
|
||||||
<th class="narrow">Zu-/Abschläge</th>
|
<th class="narrow">Zu-/Abschläge</th>
|
||||||
<th>Betrag</th>
|
<th>Betrag</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -37,6 +39,7 @@
|
|||||||
<th class="unit narrow">[°KMW]</th>
|
<th class="unit narrow">[°KMW]</th>
|
||||||
<th class="unit" colspan="2">[kg]</th>
|
<th class="unit" colspan="2">[kg]</th>
|
||||||
<th class="unit">[@Model.CurrencySymbol/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>
|
||||||
<th class="unit">[@Model.CurrencySymbol]</th>
|
<th class="unit">[@Model.CurrencySymbol]</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -50,14 +53,17 @@
|
|||||||
<td rowspan="@rows">@p.LsNr</td>
|
<td rowspan="@rows">@p.LsNr</td>
|
||||||
<td rowspan="@rows">@p.DPNr</td>
|
<td rowspan="@rows">@p.DPNr</td>
|
||||||
<td class="small">@p.Variety</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.Oe:N0}")</td>
|
||||||
<td rowspan="@rows" class="center">@($"{p.Gradation.Kmw:N1}")</td>
|
<td rowspan="@rows" class="center">@($"{p.Gradation.Kmw:N1}")</td>
|
||||||
}
|
}
|
||||||
@if (i > 0 && i <= p.Modifiers.Length) {
|
@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) {
|
} else if (i > 0) {
|
||||||
<td colspan="2"></td>
|
<td colspan="4"></td>
|
||||||
}
|
}
|
||||||
@if (i < p.Buckets.Length) {
|
@if (i < p.Buckets.Length) {
|
||||||
var bucket = p.Buckets[i];
|
var bucket = p.Buckets[i];
|
||||||
@ -65,10 +71,12 @@
|
|||||||
<td class="number">@($"{bucket.Value:N0}")</td>
|
<td class="number">@($"{bucket.Value:N0}")</td>
|
||||||
<td class="number">@($"{bucket.Price:N4}")</td>
|
<td class="number">@($"{bucket.Price:N4}")</td>
|
||||||
} else {
|
} else {
|
||||||
<td colspan="3"></td>
|
<td></td>
|
||||||
}
|
}
|
||||||
@if (i == p.Buckets.Length - 1) {
|
@if (i == p.Buckets.Length - 1) {
|
||||||
|
var rebelMod = p.WeighingModifier * 100;
|
||||||
var totalMod = p.TotalModifiers ?? 0;
|
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@(totalMod == 0 ? " center" : "")">@(totalMod == 0 ? "-" : Utils.GetSign(totalMod) + $"{Math.Abs(totalMod):N2}")</td>
|
||||||
<td class="number">@($"{p.Amount:N2}")</td>
|
<td class="number">@($"{p.Amount:N2}")</td>
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,6 +57,9 @@ main table .small {
|
|||||||
main table .large {
|
main table .large {
|
||||||
font-size: 12pt;
|
font-size: 12pt;
|
||||||
}
|
}
|
||||||
|
main table .tiny {
|
||||||
|
font-size: 6pt;
|
||||||
|
}
|
||||||
|
|
||||||
main table.number td,
|
main table.number td,
|
||||||
main table.number th {
|
main table.number th {
|
||||||
|
@ -42,6 +42,15 @@ namespace Elwig.Helpers.Billing {
|
|||||||
set => SetConsider(value, "consider_auto_business_shares");
|
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) {
|
private bool GetConsider(string name, string? wgMasterName = null) {
|
||||||
return ((Mode == CalculationMode.Elwig) ? Data[name] : Data[wgMasterName ?? ""])?.AsValue().GetValue<bool>() ?? false;
|
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) {
|
public BillingData(JsonObject data) {
|
||||||
Data = data;
|
Data = data;
|
||||||
var mode = Data["mode"]?.GetValue<string>();
|
var mode = Data["mode"]?.GetValue<string>();
|
||||||
|
@ -146,6 +146,8 @@ 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) {
|
||||||
|
if (part.Value == 0)
|
||||||
|
continue;
|
||||||
var ungeb = part.Discr == "_";
|
var ungeb = part.Discr == "_";
|
||||||
var payAttrId = (part.Discr is "" or "_") ? null : part.Discr;
|
var payAttrId = (part.Discr is "" or "_") ? null : part.Discr;
|
||||||
var attrId = part.AttrAreaCom ? payAttrId : part.AttrId;
|
var attrId = part.AttrAreaCom ? payAttrId : part.AttrId;
|
||||||
@ -162,7 +164,16 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async Task CalculateDeliveryModifiers(SqliteConnection cnx) {
|
protected async Task CalculateDeliveryModifiers(SqliteConnection cnx) {
|
||||||
|
var netMod = Data.NetWeightModifier.ToString().Replace(',', '.');
|
||||||
|
var grossMod = Data.GrossWeightModifier.ToString().Replace(',', '.');
|
||||||
await AppDbContext.ExecuteBatch(cnx, $"""
|
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)
|
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)
|
||||||
FROM delivery_part d
|
FROM delivery_part d
|
||||||
@ -171,7 +182,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
WHERE d.year = {Year}
|
WHERE d.year = {Year}
|
||||||
ON CONFLICT DO UPDATE
|
ON CONFLICT DO UPDATE
|
||||||
SET mod_abs = mod_abs + excluded.mod_abs,
|
SET mod_abs = mod_abs + excluded.mod_abs,
|
||||||
mod_rel = mod_rel + excluded.mod_rel
|
mod_rel = mod_rel + excluded.mod_rel;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,9 @@ namespace Elwig.Helpers {
|
|||||||
input.Text = text;
|
input.Text = text;
|
||||||
input.CaretIndex = pos;
|
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);
|
return required ? new(false, "Wert ist nicht optional") : new(true, null);
|
||||||
} else if (v2 == 0) {
|
} else if (v2 == 0) {
|
||||||
return new(false, "Ungültige Kommazahl");
|
return new(false, "Ungültige Kommazahl");
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using Elwig.Models.Entities;
|
using Elwig.Helpers.Billing;
|
||||||
|
using Elwig.Models.Entities;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
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) {
|
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))
|
return (await FromDbSet(table, year, avnr))
|
||||||
.GroupBy(
|
.GroupBy(
|
||||||
r => new { r.Year, r.AvNr, r.MgNr, r.TgNr, r.DId, r.DPNr },
|
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(
|
.GroupBy(
|
||||||
r => new { r.Year, r.AvNr, r.MgNr, r.TgNr },
|
r => new { r.Year, r.AvNr, r.MgNr, r.TgNr },
|
||||||
(k, g) => new CreditNoteDeliveryData(g, k.Year, k.TgNr, mgnr: k.MgNr))
|
(k, g) => new CreditNoteDeliveryData(g, k.Year, k.TgNr, mgnr: k.MgNr))
|
||||||
@ -43,7 +48,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
return await table.FromSqlRaw($"""
|
return await table.FromSqlRaw($"""
|
||||||
SELECT d.year, c.tgnr, v.avnr, d.mgnr, d.did, d.lsnr, d.dpnr, d.weight, d.modifiers,
|
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,
|
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
|
FROM v_delivery d
|
||||||
JOIN wine_variety s ON s.sortid = d.sortid
|
JOIN wine_variety s ON s.sortid = d.sortid
|
||||||
LEFT JOIN wine_attribute a ON a.attrid = d.attrid
|
LEFT JOIN wine_attribute a ON a.attrid = d.attrid
|
||||||
@ -64,7 +69,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
|
|
||||||
public int Year;
|
public int Year;
|
||||||
public int? TgNr;
|
public int? TgNr;
|
||||||
public int AvNr;
|
public int? AvNr;
|
||||||
public int MgNr;
|
public int MgNr;
|
||||||
|
|
||||||
public string LsNr;
|
public string LsNr;
|
||||||
@ -73,16 +78,19 @@ namespace Elwig.Models.Dtos {
|
|||||||
public string? Attribute;
|
public string? Attribute;
|
||||||
public string? Cultivation;
|
public string? Cultivation;
|
||||||
public string[] Modifiers;
|
public string[] Modifiers;
|
||||||
|
public string QualId;
|
||||||
public string QualityLevel;
|
public string QualityLevel;
|
||||||
public (double Oe, double Kmw) Gradation;
|
public (double Oe, double Kmw) Gradation;
|
||||||
public (string Name, int Value, decimal? Price, decimal? Amount)[] Buckets;
|
public (string Name, int Value, decimal? Price, decimal? Amount)[] Buckets;
|
||||||
public decimal? TotalModifiers;
|
public decimal? TotalModifiers;
|
||||||
public decimal? Amount;
|
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();
|
var f = rows.First();
|
||||||
Year = f.Year;
|
Year = f.Year;
|
||||||
TgNr = f.TgNr;
|
TgNr = f.TgNr;
|
||||||
|
AvNr = f.AvNr;
|
||||||
MgNr = f.MgNr;
|
MgNr = f.MgNr;
|
||||||
var season = seasons.Find(Year);
|
var season = seasons.Find(Year);
|
||||||
|
|
||||||
@ -97,6 +105,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
.OrderBy(m => m.Ordering)
|
.OrderBy(m => m.Ordering)
|
||||||
.ToList();
|
.ToList();
|
||||||
Modifiers = modifiers.Select(m => m.Name).ToArray();
|
Modifiers = modifiers.Select(m => m.Name).ToArray();
|
||||||
|
QualId = f.QualId;
|
||||||
QualityLevel = f.QualityLevel;
|
QualityLevel = f.QualityLevel;
|
||||||
Gradation = (f.Oe, f.Kmw);
|
Gradation = (f.Oe, f.Kmw);
|
||||||
Buckets = rows
|
Buckets = rows
|
||||||
@ -106,9 +115,11 @@ namespace Elwig.Models.Dtos {
|
|||||||
b.Price != null ? season?.DecFromDb((long)b.Price) : null,
|
b.Price != null ? season?.DecFromDb((long)b.Price) : null,
|
||||||
b.Amount != null ? season?.DecFromDb((long)b.Amount) : null))
|
b.Amount != null ? season?.DecFromDb((long)b.Amount) : null))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
WeighingModifier = f.NetWeight ? netWeightModifier : grossWeightModifier;
|
||||||
Amount = f.TotalAmount != null ? season?.DecFromDb((long)f.TotalAmount) : null;
|
Amount = f.TotalAmount != null ? season?.DecFromDb((long)f.TotalAmount) : null;
|
||||||
var netAmount = f.NetAmount != null ? season?.DecFromDb((long)f.NetAmount) : 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; }
|
public string? Attribute { get; set; }
|
||||||
[Column("cultivation")]
|
[Column("cultivation")]
|
||||||
public string? Cultivation { get; set; }
|
public string? Cultivation { get; set; }
|
||||||
|
[Column("qualid")]
|
||||||
|
public required string QualId { get; set; }
|
||||||
[Column("quality_level")]
|
[Column("quality_level")]
|
||||||
public required string QualityLevel { get; set; }
|
public required string QualityLevel { get; set; }
|
||||||
[Column("oe")]
|
[Column("oe")]
|
||||||
public double Oe { get; set; }
|
public double Oe { get; set; }
|
||||||
[Column("kmw")]
|
[Column("kmw")]
|
||||||
public double Kmw { get; set; }
|
public double Kmw { get; set; }
|
||||||
|
[Column("net_weight")]
|
||||||
|
public bool NetWeight { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
"consider_contract_penalties": {"type": "boolean"},
|
"consider_contract_penalties": {"type": "boolean"},
|
||||||
"consider_total_penalty": {"type": "boolean"},
|
"consider_total_penalty": {"type": "boolean"},
|
||||||
"consider_auto_business_shares": {"type": "boolean"},
|
"consider_auto_business_shares": {"type": "boolean"},
|
||||||
|
"net_weight_modifier": {"type": "number"},
|
||||||
|
"gross_weight_modifier": {"type": "number"},
|
||||||
"payment": {"$ref": "#/definitions/payment_1"},
|
"payment": {"$ref": "#/definitions/payment_1"},
|
||||||
"quality": {"$ref": "#/definitions/quality_1"},
|
"quality": {"$ref": "#/definitions/quality_1"},
|
||||||
"curves": {
|
"curves": {
|
||||||
@ -23,6 +25,7 @@
|
|||||||
"required": ["AuszahlungSorten", "Kurven"],
|
"required": ["AuszahlungSorten", "Kurven"],
|
||||||
"properties": {
|
"properties": {
|
||||||
"mode": {"enum": ["wgmaster"]},
|
"mode": {"enum": ["wgmaster"]},
|
||||||
|
"Rebelzuschlag": {"type": "number"},
|
||||||
"AuszahlungSorten": {"$ref": "#/definitions/payment_1"},
|
"AuszahlungSorten": {"$ref": "#/definitions/payment_1"},
|
||||||
"AuszahlungSortenQualitätsstufe": {"$ref": "#/definitions/quality_1"},
|
"AuszahlungSortenQualitätsstufe": {"$ref": "#/definitions/quality_1"},
|
||||||
"Kurven": {
|
"Kurven": {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Elwig.Windows"
|
xmlns:local="clr-namespace:Elwig.Windows"
|
||||||
|
xmlns:ctrl="clr-namespace:Elwig.Controls"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Auszahlungsvarianten - Elwig" Height="510" Width="820" MinHeight="500" MinWidth="820">
|
Title="Auszahlungsvarianten - Elwig" Height="510" Width="820" MinHeight="500" MinWidth="820">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
@ -86,6 +87,11 @@
|
|||||||
<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"/>
|
||||||
|
|
||||||
|
<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"/>
|
<Label Content="Berücksichtigen:" Margin="90,70,10,10" Grid.Column="2"/>
|
||||||
<CheckBox x:Name="ConsiderModifiersInput" Content="Zu-/Abschläge bei Lieferungen"
|
<CheckBox x:Name="ConsiderModifiersInput" Content="Zu-/Abschläge bei Lieferungen"
|
||||||
Margin="110,95,10,10" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top"
|
Margin="110,95,10,10" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||||
|
@ -20,6 +20,7 @@ namespace Elwig.Windows {
|
|||||||
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 BillingData? BillingData;
|
||||||
|
private bool WeightModifierChanged = false;
|
||||||
|
|
||||||
private static readonly JsonSerializerOptions JsonOpt = new() { WriteIndented = true };
|
private static readonly JsonSerializerOptions JsonOpt = new() { WriteIndented = true };
|
||||||
|
|
||||||
@ -70,6 +71,13 @@ namespace Elwig.Windows {
|
|||||||
ConsiderPenaltiesInput.IsChecked = BillingData.ConsiderContractPenalties;
|
ConsiderPenaltiesInput.IsChecked = BillingData.ConsiderContractPenalties;
|
||||||
ConsiderPenaltyInput.IsChecked = BillingData.ConsiderTotalPenalty;
|
ConsiderPenaltyInput.IsChecked = BillingData.ConsiderTotalPenalty;
|
||||||
ConsiderAutoInput.IsChecked = BillingData.ConsiderAutoBusinessShares;
|
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);
|
DataInput.Text = JsonSerializer.Serialize(BillingData.Data, JsonOpt);
|
||||||
} catch {
|
} catch {
|
||||||
BillingData = null;
|
BillingData = null;
|
||||||
@ -77,8 +85,10 @@ namespace Elwig.Windows {
|
|||||||
ConsiderPenaltiesInput.IsChecked = false;
|
ConsiderPenaltiesInput.IsChecked = false;
|
||||||
ConsiderPenaltyInput.IsChecked = false;
|
ConsiderPenaltyInput.IsChecked = false;
|
||||||
ConsiderAutoInput.IsChecked = false;
|
ConsiderAutoInput.IsChecked = false;
|
||||||
|
WeightModifierInput.Text = "";
|
||||||
DataInput.Text = v.Data;
|
DataInput.Text = v.Data;
|
||||||
}
|
}
|
||||||
|
WeightModifierInput.TextBox.IsReadOnly = false;
|
||||||
ConsiderModifiersInput.IsEnabled = !locked;
|
ConsiderModifiersInput.IsEnabled = !locked;
|
||||||
ConsiderPenaltiesInput.IsEnabled = !locked;
|
ConsiderPenaltiesInput.IsEnabled = !locked;
|
||||||
ConsiderPenaltyInput.IsEnabled = !locked;
|
ConsiderPenaltyInput.IsEnabled = !locked;
|
||||||
@ -109,6 +119,8 @@ namespace Elwig.Windows {
|
|||||||
DateInput.IsReadOnly = true;
|
DateInput.IsReadOnly = true;
|
||||||
TransferDateInput.Text = "";
|
TransferDateInput.Text = "";
|
||||||
TransferDateInput.IsReadOnly = true;
|
TransferDateInput.IsReadOnly = true;
|
||||||
|
WeightModifierInput.Text = "";
|
||||||
|
WeightModifierInput.TextBox.IsReadOnly = true;
|
||||||
ConsiderModifiersInput.IsChecked = false;
|
ConsiderModifiersInput.IsChecked = false;
|
||||||
ConsiderModifiersInput.IsEnabled = false;
|
ConsiderModifiersInput.IsEnabled = false;
|
||||||
ConsiderPenaltiesInput.IsChecked = false;
|
ConsiderPenaltiesInput.IsChecked = false;
|
||||||
@ -131,7 +143,8 @@ namespace Elwig.Windows {
|
|||||||
(ConsiderModifiersInput.IsChecked != BillingData?.ConsiderDelieryModifiers) ||
|
(ConsiderModifiersInput.IsChecked != BillingData?.ConsiderDelieryModifiers) ||
|
||||||
(ConsiderPenaltiesInput.IsChecked != BillingData?.ConsiderContractPenalties) ||
|
(ConsiderPenaltiesInput.IsChecked != BillingData?.ConsiderContractPenalties) ||
|
||||||
(ConsiderPenaltyInput.IsChecked != BillingData?.ConsiderTotalPenalty) ||
|
(ConsiderPenaltyInput.IsChecked != BillingData?.ConsiderTotalPenalty) ||
|
||||||
(ConsiderAutoInput.IsChecked != BillingData?.ConsiderAutoBusinessShares));
|
(ConsiderAutoInput.IsChecked != BillingData?.ConsiderAutoBusinessShares) ||
|
||||||
|
WeightModifierChanged);
|
||||||
CalculateButton.IsEnabled = !SaveButton.IsEnabled && PaymentVariantList.SelectedItem is PaymentVar { TestVariant: true };
|
CalculateButton.IsEnabled = !SaveButton.IsEnabled && PaymentVariantList.SelectedItem is PaymentVar { TestVariant: true };
|
||||||
CommitButton.IsEnabled = CalculateButton.IsEnabled;
|
CommitButton.IsEnabled = CalculateButton.IsEnabled;
|
||||||
}
|
}
|
||||||
@ -362,6 +375,10 @@ namespace Elwig.Windows {
|
|||||||
d.ConsiderContractPenalties = ConsiderPenaltiesInput.IsChecked ?? false;
|
d.ConsiderContractPenalties = ConsiderPenaltiesInput.IsChecked ?? false;
|
||||||
d.ConsiderTotalPenalty = ConsiderPenaltyInput.IsChecked ?? false;
|
d.ConsiderTotalPenalty = ConsiderPenaltyInput.IsChecked ?? false;
|
||||||
d.ConsiderAutoBusinessShares = ConsiderAutoInput.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);
|
v.Data = JsonSerializer.Serialize(d.Data);
|
||||||
Context.Update(v);
|
Context.Update(v);
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
@ -371,6 +388,7 @@ namespace Elwig.Windows {
|
|||||||
ConsiderPenaltiesInput_Changed(null, null);
|
ConsiderPenaltiesInput_Changed(null, null);
|
||||||
ConsiderPenaltyInput_Changed(null, null);
|
ConsiderPenaltyInput_Changed(null, null);
|
||||||
ConsiderAutoInput_Changed(null, null);
|
ConsiderAutoInput_Changed(null, null);
|
||||||
|
WeightModifierInput_TextChanged(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;
|
||||||
@ -511,5 +529,27 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
UpdateSaveButton();
|
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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user