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