Add Deliveries
This commit is contained in:
@ -3,16 +3,21 @@ using Elwig.Models;
|
||||
namespace Elwig.Documents {
|
||||
public abstract class BusinessDocument : Document {
|
||||
|
||||
public Member Member;
|
||||
|
||||
public BusinessDocument(string title, Member m) : base(title) {
|
||||
Member = m;
|
||||
}
|
||||
|
||||
public Member Member { get; set; }
|
||||
|
||||
public string Address {
|
||||
get {
|
||||
// TODO Name/Rechnungsadresse
|
||||
return $"{Member.GivenName} {Member.FamilyName}\n{Member.Address}";
|
||||
var b = Member.BillingAddress;
|
||||
var plz = (b == null) ? Member.PostalDest.AtPlz : b.PostalDest.AtPlz;
|
||||
if (b != null) {
|
||||
return $"{b.Name}\n{b.Address}\n{plz.Plz} {plz.Dest}";
|
||||
} else {
|
||||
return $"{Member.Name}\n{Member.Address}\n{plz.Plz} {plz.Dest}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
32
Elwig/Documents/DeliveryNote.cshtml
Normal file
32
Elwig/Documents/DeliveryNote.cshtml
Normal file
@ -0,0 +1,32 @@
|
||||
@using RazorLight
|
||||
@inherits TemplatePage<Elwig.Documents.DeliveryNote>
|
||||
@model Elwig.Documents.DeliveryNote
|
||||
@{ Layout = "BusinessDocument"; }
|
||||
|
||||
<h1>Traubenübernahmeschein Nr. @Model.Delivery.LsNr</h1>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td rowspan="2">Sorte</td>
|
||||
<td rowspan="2">Qualitätsstufe</td>
|
||||
<td colspan="2">Gradation</td>
|
||||
<td>Gewicht</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>°KMW</td>
|
||||
<td>°Oe</td>
|
||||
<td>kg</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var part in Model.Delivery.Parts.OrderBy(p => p.DPNr)) {
|
||||
<tr>
|
||||
<td>@part.Variant.Name</td>
|
||||
<td>@part.Quality.Name</td>
|
||||
<td>@part.Kmw</td>
|
||||
<td>@part.Oe</td>
|
||||
<td>@part.Weight</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
12
Elwig/Documents/DeliveryNote.cshtml.cs
Normal file
12
Elwig/Documents/DeliveryNote.cshtml.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Elwig.Models;
|
||||
|
||||
namespace Elwig.Documents {
|
||||
public class DeliveryNote : BusinessDocument {
|
||||
|
||||
public Delivery Delivery;
|
||||
|
||||
public DeliveryNote(Delivery d) : base($"Lieferschein {d.LsNr}", d.Member) {
|
||||
Delivery = d;
|
||||
}
|
||||
}
|
||||
}
|
@ -5,8 +5,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de-AT">
|
||||
<head>
|
||||
<title>@Model.Title</title>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>@Model.Title</title>
|
||||
<meta charset="UTF-8"/>
|
||||
<script>
|
||||
window.PagedConfig = { auto: false };
|
||||
if (!navigator.webdriver) {
|
||||
|
@ -43,8 +43,10 @@ namespace Elwig.Documents {
|
||||
string name;
|
||||
if (this is BusinessLetter) {
|
||||
name = "BusinessLetter";
|
||||
} else if (this is DeliveryNote) {
|
||||
name = "DeliveryNote";
|
||||
} else {
|
||||
throw new InvalidOperationException();
|
||||
throw new InvalidOperationException("Invalid document object");
|
||||
}
|
||||
return await Html.CompileRenderAsync(name, this);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ namespace Elwig.Documents {
|
||||
await e.CompileTemplateAsync("Document");
|
||||
await e.CompileTemplateAsync("BusinessDocument");
|
||||
await e.CompileTemplateAsync("BusinessLetter");
|
||||
await e.CompileTemplateAsync("DeliveryNote");
|
||||
|
||||
Engine = e;
|
||||
evtHandler();
|
||||
|
@ -136,6 +136,11 @@ footer {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
@page {
|
||||
size: A4;
|
||||
margin: 25mm 0 35mm 0;
|
||||
|
@ -27,11 +27,14 @@ namespace Elwig.Helpers {
|
||||
public DbSet<AreaComParcel> AreaCommitmentParcels { get; set; }
|
||||
public DbSet<AreaComAttr> AreaCommitmentAttributes { get; set; }
|
||||
public DbSet<Contract> Contracts { get; set; }
|
||||
public DbSet<WineOrigin> WineOrigins { get; set; }
|
||||
public DbSet<WineAttr> WineAttributes { get; set; }
|
||||
public DbSet<WineCult> WineCultivations { get; set; }
|
||||
public DbSet<WineQual> WineQualities { get; set; }
|
||||
public DbSet<WineVar> WineVarieties { get; set; }
|
||||
public DbSet<Season> Seasons { get; set; }
|
||||
public DbSet<Delivery> Deliveries { get; set; }
|
||||
public DbSet<DeliveryPart> DeliveryParts { get; set; }
|
||||
|
||||
private readonly StreamWriter? LogFile = null;
|
||||
|
||||
|
76
Elwig/Models/Delivery.cs
Normal file
76
Elwig/Models/Delivery.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elwig.Models {
|
||||
[Table("delivery"), PrimaryKey("Year", "DId"), Index("DateString", "ZwstId", "LNr", IsUnique = true), Index("LsNr", IsUnique = true)]
|
||||
public class Delivery {
|
||||
[Column("year")]
|
||||
public int Year { get; set; }
|
||||
|
||||
[Column("did")]
|
||||
public int DId { get; set; }
|
||||
|
||||
[Column("date")]
|
||||
public string DateString { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateOnly Date {
|
||||
get {
|
||||
return DateOnly.ParseExact(DateString, "yyyy-MM-dd");
|
||||
}
|
||||
set {
|
||||
DateString = value.ToString("yyyy-MM-dd");
|
||||
}
|
||||
}
|
||||
|
||||
[Column("time")]
|
||||
public string TimeString { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public TimeOnly Time {
|
||||
get {
|
||||
return TimeOnly.ParseExact(TimeString, "HH:mm:ss");
|
||||
}
|
||||
set {
|
||||
TimeString = value.ToString("HH:mm:ss");
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public DateTime DateTime {
|
||||
get {
|
||||
return Date.ToDateTime(Time);
|
||||
}
|
||||
set {
|
||||
Date = DateOnly.FromDateTime(value);
|
||||
Time = TimeOnly.FromDateTime(value);
|
||||
}
|
||||
}
|
||||
|
||||
[Column("zwstid")]
|
||||
public string ZwstId { get; set; }
|
||||
|
||||
[ForeignKey("ZwstId")]
|
||||
public virtual Branch Branch { get; private set; }
|
||||
|
||||
[Column("lnr")]
|
||||
public int LNr { get; set; }
|
||||
|
||||
[Column("lsnr")]
|
||||
public string LsNr { get; set; }
|
||||
|
||||
[Column("mgnr")]
|
||||
public int MgNr { get; set; }
|
||||
|
||||
[ForeignKey("MgNr")]
|
||||
public virtual Member Member { get; private set; }
|
||||
|
||||
[Column("comment")]
|
||||
public string? Comment { get; set; }
|
||||
|
||||
[InverseProperty("Delivery")]
|
||||
public virtual ISet<DeliveryPart> Parts { get; private set; }
|
||||
}
|
||||
}
|
96
Elwig/Models/DeliveryPart.cs
Normal file
96
Elwig/Models/DeliveryPart.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using Elwig.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elwig.Models {
|
||||
[Table("delivery_part"), PrimaryKey("Year", "DId", "DPNr")]
|
||||
public class DeliveryPart {
|
||||
[Column("year")]
|
||||
public int Year { get; set; }
|
||||
|
||||
[Column("did")]
|
||||
public int DId { get; set; }
|
||||
|
||||
[ForeignKey("Year, DId")]
|
||||
public virtual Delivery Delivery { get; private set; }
|
||||
|
||||
[Column("dpnr")]
|
||||
public int DPNr { get; set; }
|
||||
|
||||
[Column("sortid")]
|
||||
public string SortId { get; set; }
|
||||
|
||||
[ForeignKey("SortId")]
|
||||
public virtual WineVar Variant { get; private set; }
|
||||
|
||||
[Column("weight")]
|
||||
public int Weight { get; set; }
|
||||
|
||||
[Column("kmw")]
|
||||
public double Kmw { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public double Oe {
|
||||
get {
|
||||
return Utils.KmwToOe(Kmw);
|
||||
}
|
||||
set {
|
||||
Kmw = Utils.OeToKmw(value);
|
||||
}
|
||||
}
|
||||
|
||||
[Column("qualid")]
|
||||
public string QualId { get; set; }
|
||||
|
||||
[ForeignKey("QualId")]
|
||||
public virtual WineQual Quality { get; private set; }
|
||||
|
||||
[Column("hkid")]
|
||||
public string HkId { get; set; }
|
||||
|
||||
[ForeignKey("HkId")]
|
||||
public virtual WineOrigin Origin { get; private set; }
|
||||
|
||||
[Column("kgnr")]
|
||||
public int KgNr { get; set; }
|
||||
|
||||
[ForeignKey("KgNr")]
|
||||
public virtual WbKg Kg { get; private set; }
|
||||
|
||||
[Column("rdnr")]
|
||||
public int? RdNr { get; set; }
|
||||
|
||||
[ForeignKey("KgNr, RdNr")]
|
||||
public virtual WbRd? Rd { get; private set; }
|
||||
|
||||
[Column("gerebelt")]
|
||||
public bool IsGerebelt { get; set; }
|
||||
|
||||
[Column("manual_weighing")]
|
||||
public bool ManualWeighing { get; set; }
|
||||
|
||||
[Column("spl_check")]
|
||||
public bool SplCheck { get; set; }
|
||||
|
||||
[Column("hand_picked")]
|
||||
public bool? IsHandPicked { get; set; }
|
||||
|
||||
[Column("lesewagen")]
|
||||
public bool? IsLesewagen { get; set; }
|
||||
|
||||
[Column("temperature")]
|
||||
public double? Temperature { get; set; }
|
||||
|
||||
[Column("acid")]
|
||||
public double? Acid { get; set; }
|
||||
|
||||
[Column("scale_id")]
|
||||
public string? ScaleId { get; set; }
|
||||
|
||||
[Column("weighing_id")]
|
||||
public string? WeighingId { get; set; }
|
||||
|
||||
[Column("comment")]
|
||||
public string? Comment { get; set; }
|
||||
}
|
||||
}
|
@ -35,6 +35,15 @@ namespace Elwig.Models {
|
||||
[Column("suffix")]
|
||||
public string? Suffix { get; set; }
|
||||
|
||||
public string Name =>
|
||||
(Prefix != null ? Prefix + " " : "") +
|
||||
GivenName + " " +
|
||||
(MiddleName != null ? MiddleName + " " : "") +
|
||||
FamilyName +
|
||||
(Suffix != null ? " " + Suffix : "");
|
||||
|
||||
public string ShortName => GivenName + " " + FamilyName;
|
||||
|
||||
[Column("birthday")]
|
||||
public string? Birthday { get; set; }
|
||||
|
||||
@ -153,6 +162,9 @@ namespace Elwig.Models {
|
||||
[InverseProperty("Member")]
|
||||
public virtual BillingAddr? BillingAddress { get; private set; }
|
||||
|
||||
[InverseProperty("Member")]
|
||||
public virtual ISet<Delivery> Deliveries { get; private set; }
|
||||
|
||||
public int SearchScore(IEnumerable<string> keywords) {
|
||||
keywords = keywords.Where(s => s.Length >= 2 || (s.Length > 0 && s.All(c => char.IsAsciiDigit(c))));
|
||||
if (!keywords.Any())
|
||||
|
22
Elwig/Models/WineOrigin.cs
Normal file
22
Elwig/Models/WineOrigin.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elwig.Models {
|
||||
[Table("wine_origin"), PrimaryKey("HkId"), Index("Name", IsUnique = true)]
|
||||
public class WineOrigin {
|
||||
[Column("hkid")]
|
||||
public string HkId { get; private set; }
|
||||
|
||||
[Column("parent_hkid")]
|
||||
public string? ParentHkId { get; private set; }
|
||||
|
||||
[ForeignKey("ParentHkId")]
|
||||
public virtual WineOrigin? Parent { get; private set; }
|
||||
|
||||
[Column("name")]
|
||||
public string Name { get; private set; }
|
||||
|
||||
[Column("blnr")]
|
||||
public int? BlNr { get; private set; }
|
||||
}
|
||||
}
|
@ -33,9 +33,9 @@ namespace Elwig.Windows {
|
||||
|
||||
private void Button4_Click(object sender, RoutedEventArgs evt) {
|
||||
Utils.RunBackground("PDF Generation", async () => {
|
||||
using var letter = new BusinessLetter("Test Dokument", Context.Members.First());
|
||||
await letter.Generate();
|
||||
letter.Show();
|
||||
using var doc = new DeliveryNote(Context.Deliveries.OrderBy(d => d.Year).ThenBy(d => d.DId).Last());
|
||||
await doc.Generate();
|
||||
doc.Show();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
mkdir "C:\ProgramData\Elwig\resources""
|
||||
curl -s -L "https://unpkg.com/pagedjs/dist/paged.polyfill.js" -o "C:\ProgramData\Elwig\resources\paged.polyfill.js"
|
||||
copy /y "Documents\style.css" "C:\ProgramData\Elwig\resources\style.css"
|
||||
copy /y Documents\*.cshtml "C:\ProgramData\Elwig\resources"
|
||||
copy /b /y "Documents\style.css" "C:\ProgramData\Elwig\resources\style.css"
|
||||
copy /b /y Documents\*.cshtml "C:\ProgramData\Elwig\resources"
|
||||
|
Reference in New Issue
Block a user