Compare commits
3 Commits
b76d43a5ff
...
28b424fe65
| Author | SHA1 | Date | |
|---|---|---|---|
| 28b424fe65 | |||
| 324c5db94e | |||
| faaeefe6ce |
@@ -2,7 +2,6 @@
|
|||||||
@inherits TemplatePage<Elwig.Documents.BusinessDocument>
|
@inherits TemplatePage<Elwig.Documents.BusinessDocument>
|
||||||
@model Elwig.Documents.BusinessDocument
|
@model Elwig.Documents.BusinessDocument
|
||||||
@{ Layout = "Document"; }
|
@{ Layout = "Document"; }
|
||||||
|
|
||||||
<div class="info-wrapper">
|
<div class="info-wrapper">
|
||||||
<div class="address-wrapper">
|
<div class="address-wrapper">
|
||||||
<div class="sender">
|
<div class="sender">
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
@inherits TemplatePage<Elwig.Documents.BusinessLetter>
|
@inherits TemplatePage<Elwig.Documents.BusinessLetter>
|
||||||
@model Elwig.Documents.BusinessLetter
|
@model Elwig.Documents.BusinessLetter
|
||||||
@{ Layout = "BusinessDocument"; }
|
@{ Layout = "BusinessDocument"; }
|
||||||
|
|
||||||
<p>Sehr geehrtes Mitglied,</p>
|
<p>Sehr geehrtes Mitglied,</p>
|
||||||
<p>nein.</p>
|
<p>nein.</p>
|
||||||
<p>Mit freundlichen Grüßen<br/>Ihre Winzergenossenschaft</p>
|
<p>Mit freundlichen Grüßen<br/>Ihre Winzergenossenschaft</p>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
@inherits TemplatePage<Elwig.Documents.DeliveryNote>
|
@inherits TemplatePage<Elwig.Documents.DeliveryNote>
|
||||||
@model Elwig.Documents.DeliveryNote
|
@model Elwig.Documents.DeliveryNote
|
||||||
@{ Layout = "BusinessDocument"; }
|
@{ Layout = "BusinessDocument"; }
|
||||||
|
|
||||||
<div class="date">@Model.Location, am @($"{Model.Date:dd.MM.yyyy}")</div>
|
<div class="date">@Model.Location, am @($"{Model.Date:dd.MM.yyyy}")</div>
|
||||||
<h1>@Model.Title</h1>
|
<h1>@Model.Title</h1>
|
||||||
@{
|
@{
|
||||||
@@ -11,24 +10,35 @@
|
|||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
const hidden = document.getElementsByClassName("hidden")[0];
|
const hidden = document.getElementsByClassName("hidden")[0];
|
||||||
const bottom = hidden.offsetTop + hidden.offsetHeight;
|
const table = document.getElementsByClassName("delivery")[0];
|
||||||
const cm = bottom * 2.54 / 96 * window.devicePixelRatio;
|
const stats = document.getElementById("delivery-stats");
|
||||||
|
const mm = px2mm(0, hidden.offsetTop + hidden.offsetHeight);
|
||||||
|
const heightTable = px2mm(table.offsetTop, hidden.offsetTop + hidden.offsetHeight);
|
||||||
|
|
||||||
if (cm > 25.75) {
|
if (mm >= heightA4 - heightFooter) {
|
||||||
// force page break
|
if (heightTable + 10 >= heightMain) {
|
||||||
const table = document.getElementsByClassName("delivery")[0];
|
// force page break in table
|
||||||
|
const tblOff = px2mm(0, table.offsetTop);
|
||||||
|
let last = null;
|
||||||
|
for (const tr of table.getElementsByTagName("tr")) {
|
||||||
|
if (!tr.classList.contains("main")) continue;
|
||||||
|
const mm2 = tblOff + px2mm(0, tr.offsetTop);
|
||||||
|
if (mm2 >= heightA4 - heightFooter) {
|
||||||
|
last.classList.add("page-break");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
last = tr;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// force page break
|
||||||
|
const hr = document.createElement("hr");
|
||||||
|
hr.classList.add("page-break");
|
||||||
|
table.before(hr);
|
||||||
|
|
||||||
const hr = document.createElement("hr");
|
const p = document.createElement("p");
|
||||||
hr.classList.add("page-break");
|
p.innerText = "Siehe nächste Seite."
|
||||||
table.before(hr);
|
hr.before(p);
|
||||||
|
}
|
||||||
const stats = document.getElementById("delivery-stats");
|
|
||||||
stats.getElementsByTagName("table")[0].classList.add("expanded");
|
|
||||||
hr.before(stats);
|
|
||||||
|
|
||||||
const p = document.createElement("p");
|
|
||||||
p.innerText = "Siehe nächste Seite."
|
|
||||||
stats.before(p);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
@using RazorLight
|
@using RazorLight
|
||||||
@inherits TemplatePage<Elwig.Documents.Document>
|
@inherits TemplatePage<Elwig.Documents.Document>
|
||||||
@model Elwig.Documents.Document
|
@model Elwig.Documents.Document
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de-AT">
|
<html lang="de-AT">
|
||||||
<head>
|
<head>
|
||||||
@@ -13,9 +12,15 @@
|
|||||||
window.addEventListener("beforeprint", async () => { await window.PagedPolyfill.preview(); });
|
window.addEventListener("beforeprint", async () => { await window.PagedPolyfill.preview(); });
|
||||||
window.addEventListener("afterprint", () => { location.reload(); });
|
window.addEventListener("afterprint", () => { location.reload(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const heightA4 = 297, widhtA4 = 210, heightFooter = 35, heightHeader = 25;
|
||||||
|
const heightMain = heightA4 - heightFooter - heightHeader;
|
||||||
|
function px2mm(px1, px2) {
|
||||||
|
return (px2 - px1 + 1) * 2.54 / 96 * window.devicePixelRatio * 10;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<script src="@Raw(Model.DataPath)\resources\paged.polyfill.js"></script>
|
<script src="file:///@Raw(Model.DataPath)\resources\paged.polyfill.js"></script>
|
||||||
<link rel="stylesheet" href="@Raw(Model.DataPath)\resources\style.css" />
|
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\style.css"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="m1"></div>
|
<div class="m1"></div>
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ main p.comment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.pre-footer {
|
.pre-footer {
|
||||||
margin: 4.23mm 0;
|
margin: 1em 0;
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
@@ -327,6 +327,10 @@ hr.page-break {
|
|||||||
break-after: page;
|
break-after: page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr.page-break {
|
||||||
|
break-before: page;
|
||||||
|
}
|
||||||
|
|
||||||
@page {
|
@page {
|
||||||
size: A4;
|
size: A4;
|
||||||
margin: 25mm 0 35mm 0;
|
margin: 25mm 0 35mm 0;
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using ScottPlot;
|
using ScottPlot;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.Contracts;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text.Json.Nodes;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Markup;
|
|
||||||
|
|
||||||
namespace Elwig.Models {
|
namespace Elwig.Helpers.Billing {
|
||||||
public class Graph : ICloneable {
|
public class Graph : ICloneable {
|
||||||
|
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
@@ -30,7 +26,7 @@ namespace Elwig.Models {
|
|||||||
DataY = DataGen.Zeros(MaxX - MinX + 1);
|
DataY = DataGen.Zeros(MaxX - MinX + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Graph(string type, int num, JToken graphData, string contracts, int minX, int maxX) {
|
public Graph(string type, int num, JsonObject graphData, string contracts, int minX, int maxX) {
|
||||||
Type = type;
|
Type = type;
|
||||||
Num = num;
|
Num = num;
|
||||||
Contracts = contracts;
|
Contracts = contracts;
|
||||||
@@ -52,8 +48,8 @@ namespace Elwig.Models {
|
|||||||
DataY = dataY;
|
DataY = dataY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseGraphData(JToken graphData) {
|
private void ParseGraphData(JsonObject graphData) {
|
||||||
var GraphPoints = graphData.Children().OfType<JProperty>().ToDictionary(p => int.Parse(p.Name[..^2]), p => (double)p.Value);
|
var GraphPoints = graphData.ToDictionary(p => int.Parse(p.Key[..^2]), p => (double)p.Value?.AsValue());
|
||||||
|
|
||||||
if (GraphPoints.Keys.Count < 1) {
|
if (GraphPoints.Keys.Count < 1) {
|
||||||
return;
|
return;
|
||||||
@@ -99,19 +95,19 @@ namespace Elwig.Models {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JObject ToJson() {
|
public JsonObject ToJson() {
|
||||||
JObject graph = new();
|
JsonObject graph = new();
|
||||||
|
|
||||||
if (DataY[0] != DataY[1]) {
|
if (DataY[0] != DataY[1]) {
|
||||||
graph.Add(new JProperty(DataX[0] + Type.ToLower(), Math.Round(DataY[0], 4)));
|
graph.Add(new KeyValuePair<string, JsonNode?>(DataX[0] + Type.ToLower(), Math.Round(DataY[0], 4)));
|
||||||
}
|
}
|
||||||
for (int i = 1; i < DataX.Length - 1; i++) {
|
for (int i = 1; i < DataX.Length - 1; i++) {
|
||||||
if (Math.Round(DataY[i] - DataY[i - 1], 4) != Math.Round(DataY[i + 1] - DataY[i], 4)) {
|
if (Math.Round(DataY[i] - DataY[i - 1], 4) != Math.Round(DataY[i + 1] - DataY[i], 4)) {
|
||||||
graph.Add(new JProperty(DataX[i] + Type.ToLower(), Math.Round(DataY[i], 4)));
|
graph.Add(new KeyValuePair<string, JsonNode?>(DataX[i] + Type.ToLower(), Math.Round(DataY[i], 4)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DataY[^1] != DataY[^2]) {
|
if (DataY[^1] != DataY[^2]) {
|
||||||
graph.Add(new JProperty(DataX[^1] + Type.ToLower(), Math.Round(DataY[^1], 4)));
|
graph.Add(new KeyValuePair<string, JsonNode?>(DataX[^1] + Type.ToLower(), Math.Round(DataY[^1], 4)));
|
||||||
}
|
}
|
||||||
return graph;
|
return graph;
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Diagnostics.Contracts;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Elwig.Helpers;
|
using Elwig.Helpers;
|
||||||
|
using Elwig.Helpers.Billing;
|
||||||
using Elwig.Models;
|
using Elwig.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using ScottPlot;
|
using ScottPlot;
|
||||||
using ScottPlot.Plottable;
|
using ScottPlot.Plottable;
|
||||||
|
|
||||||
@@ -69,14 +65,14 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PaymentVar paymentVar = paymentVars[0];
|
PaymentVar paymentVar = paymentVars[0];
|
||||||
var data = JToken.Parse(paymentVar.Data);
|
var data = JsonNode.Parse(paymentVar.Data).AsObject();
|
||||||
|
|
||||||
var auszahlungsSorten = data["AuszahlungSorten"];
|
var auszahlungsSorten = data["AuszahlungSorten"]?.AsObject();
|
||||||
if (auszahlungsSorten == null) {
|
if (auszahlungsSorten == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var Graphs = auszahlungsSorten["Kurven"];
|
var Graphs = auszahlungsSorten["Kurven"]?.AsArray();
|
||||||
|
|
||||||
if (Graphs == null) {
|
if (Graphs == null) {
|
||||||
return;
|
return;
|
||||||
@@ -86,7 +82,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
foreach (var graph in Graphs) {
|
foreach (var graph in Graphs) {
|
||||||
GraphsList.Add(new Graph("Oe", i, graph, ParseContracts(auszahlungsSorten, i - 1), 50, 140));
|
GraphsList.Add(new Graph("Oe", i, graph?.AsObject(), ParseContracts(auszahlungsSorten, i - 1), 50, 140));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,17 +94,15 @@ namespace Elwig.Windows {
|
|||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String ParseContracts(JToken auszahlungsSorten, int num) {
|
private String ParseContracts(JsonObject auszahlungsSorten, int num) {
|
||||||
List<string> contracts = new();
|
List<string> contracts = new();
|
||||||
|
|
||||||
foreach (var sorte in auszahlungsSorten.Children().OfType<JToken>()) {
|
foreach (var sorte in auszahlungsSorten) {
|
||||||
if (((JProperty)sorte).Name == "Kurven") {
|
if (sorte.Key == "Kurven") continue;
|
||||||
continue;
|
foreach (var attribut in sorte.Value.AsObject()) {
|
||||||
}
|
foreach (var bindung in attribut.Value.AsObject()) {
|
||||||
foreach (var attribut in sorte.Values().OfType<JToken>()) {
|
if ((int)bindung.Value.AsValue() == num) {
|
||||||
foreach (var bindung in attribut.Values().OfType<JProperty>()) {
|
contracts.Add($"{sorte.Key}/{attribut.Key}/{bindung.Key}");
|
||||||
if ((int)(bindung).Value == num) {
|
|
||||||
contracts.Add($"{((JProperty)sorte).Name}/{((JProperty)attribut).Name}/{bindung.Name}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,15 +119,14 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PaymentVar paymentVar = paymentVars[0];
|
PaymentVar paymentVar = paymentVars[0];
|
||||||
var data = JToken.Parse(paymentVar.Data);
|
var data = JsonNode.Parse(paymentVar.Data).AsObject();
|
||||||
|
|
||||||
var auszahlungsSorten = data["AuszahlungSorten"];
|
var auszahlungsSorten = data["AuszahlungSorten"]?.AsObject();
|
||||||
if (auszahlungsSorten == null) {
|
if (auszahlungsSorten == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var Graphs = auszahlungsSorten["Kurven"];
|
var Graphs = auszahlungsSorten["Kurven"]?.AsObject();
|
||||||
|
|
||||||
if (Graphs == null) {
|
if (Graphs == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -141,26 +134,24 @@ namespace Elwig.Windows {
|
|||||||
int i = 1;
|
int i = 1;
|
||||||
foreach (var graph in Graphs) {
|
foreach (var graph in Graphs) {
|
||||||
if (i == num) {
|
if (i == num) {
|
||||||
graph.Remove();
|
Graphs.Remove(graph.Key);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var sorte in auszahlungsSorten.Children().OfType<JToken>()) {
|
foreach (var sorte in auszahlungsSorten) {
|
||||||
if (((JProperty)sorte).Name == "Kurven") {
|
if (sorte.Key == "Kurven") continue;
|
||||||
continue;
|
foreach (var attribut in sorte.Value.AsObject()) {
|
||||||
}
|
var bindungen = attribut.Value.AsObject();
|
||||||
foreach (var attribut in sorte.Values().OfType<JToken>()) {
|
foreach (var bindung in bindungen) {
|
||||||
List<JProperty> itemsToRemove = new();
|
int v = (int)bindung.Value;
|
||||||
foreach (var bindung in attribut.Values().OfType<JProperty>()) {
|
if (v == num - 1) {
|
||||||
if ((int)bindung.Value == num - 1) {
|
bindungen.Remove(bindung.Key);
|
||||||
itemsToRemove.Add(bindung);
|
} else if (v > num - 1) {
|
||||||
} else if ((int)bindung.Value > num - 1) {
|
bindungen[bindung.Key] = v - 1;
|
||||||
bindung.Value = (int)bindung.Value - 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemsToRemove.ForEach(i => i.Remove());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -671,23 +662,22 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PaymentVar paymentVar = paymentVars[0];
|
PaymentVar paymentVar = paymentVars[0];
|
||||||
var data = JToken.Parse(paymentVar.Data);
|
var data = JsonNode.Parse(paymentVar.Data).AsObject();
|
||||||
|
|
||||||
var auszahlungsSorten = data["AuszahlungSorten"];
|
var auszahlungsSorten = data["AuszahlungSorten"];
|
||||||
if (auszahlungsSorten == null) {
|
if (auszahlungsSorten == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var Graphs = auszahlungsSorten["Kurven"];
|
var Graphs = auszahlungsSorten["Kurven"].AsArray();
|
||||||
|
|
||||||
if (Graphs == null) {
|
if (Graphs == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsEditing) {
|
if (IsEditing) {
|
||||||
((JArray)Graphs)[g.Num - 1] = g.ToJson();
|
Graphs[g.Num - 1] = g.ToJson();
|
||||||
} else if(IsCreating) {
|
} else if(IsCreating) {
|
||||||
((JArray)Graphs).Add(g.ToJson());
|
Graphs.Add(g.ToJson());
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user