BusinessDocument: Add DateFrom to be used for ShowDateAndLocation
All checks were successful
Test / Run tests (push) Successful in 2m0s
All checks were successful
Test / Run tests (push) Successful in 2m0s
This commit is contained in:
@@ -22,6 +22,7 @@ namespace Elwig.Documents {
|
||||
public bool IncludeSender = false;
|
||||
public bool UseBillingAddress = false;
|
||||
public bool ShowDateAndLocation = false;
|
||||
public DateOnly? DateFrom;
|
||||
protected Table? Aside;
|
||||
|
||||
public string Address {
|
||||
@@ -47,11 +48,12 @@ namespace Elwig.Documents {
|
||||
return NewAsideCell(new KernedParagraph(text, 10), colspan, isName);
|
||||
}
|
||||
|
||||
public BusinessDocument(string title, Member m, bool includeSender = false) :
|
||||
public BusinessDocument(string title, Member m, DateOnly? dateFrom, bool includeSender = false) :
|
||||
base(title) {
|
||||
Member = m;
|
||||
Location = App.BranchLocation;
|
||||
IncludeSender = includeSender;
|
||||
DateFrom = dateFrom;
|
||||
}
|
||||
|
||||
protected override void BeforeRenderBody(iText.Layout.Document doc, PdfDocument pdf) {
|
||||
@@ -105,7 +107,7 @@ namespace Elwig.Documents {
|
||||
}
|
||||
}
|
||||
|
||||
doc.Add(new KernedParagraph(ShowDateAndLocation ? $"{Location}, am {Date:dd.MM.yyyy}" : "", 12).SetTextAlignment(TextAlignment.RIGHT).SetVerticalAlignment(VerticalAlignment.MIDDLE).SetHeight(24).SetMargin(0));
|
||||
doc.Add(new KernedParagraph(ShowDateAndLocation ? $"{Location}, am {DateFrom ?? Date:dd.MM.yyyy}" : "", 12).SetTextAlignment(TextAlignment.RIGHT).SetVerticalAlignment(VerticalAlignment.MIDDLE).SetHeight(24).SetMargin(0));
|
||||
doc.Add(new KernedParagraph(Title, 12).SetFont(BF).SetMargins(0, 0, 12, 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace Elwig.Documents {
|
||||
private CreditNoteDeliveryData? _data;
|
||||
private Dictionary<string, UnderDelivery>? _underDeliveries;
|
||||
|
||||
public CreditNote(PaymentMember p, BillingData? billingData = null, CreditNoteDeliveryData? data = null, Dictionary<string, UnderDelivery>? underDeliveries = null) :
|
||||
base($"{Name} {(p.Credit != null ? $"Nr. {p.Credit.Year}/{p.Credit.TgNr:000}" : p.Member.FullName)} – {p.Variant.Name}", p.Member) {
|
||||
public CreditNote(PaymentMember p, DateOnly? dateFrom, BillingData? billingData = null, CreditNoteDeliveryData? data = null, Dictionary<string, UnderDelivery>? underDeliveries = null) :
|
||||
base($"{Name} {(p.Credit != null ? $"Nr. {p.Credit.Year}/{p.Credit.TgNr:000}" : p.Member.FullName)} – {p.Variant.Name}", p.Member, dateFrom) {
|
||||
UseBillingAddress = true;
|
||||
ShowDateAndLocation = true;
|
||||
Payment = p;
|
||||
@@ -58,12 +58,12 @@ namespace Elwig.Documents {
|
||||
ConsiderCustomModifiers = billingData.ConsiderCustomModifiers;
|
||||
}
|
||||
|
||||
public static async Task<CreditNote> Initialize(int year, int avnr, int mgnr, BillingData? billingData = null, CreditNoteDeliveryData? data = null, Dictionary<string, UnderDelivery>? underDeliveries = null) {
|
||||
public static async Task<CreditNote> Initialize(int year, int avnr, int mgnr, DateOnly? dateFrom, BillingData? billingData = null, CreditNoteDeliveryData? data = null, Dictionary<string, UnderDelivery>? underDeliveries = null) {
|
||||
using var ctx = new AppDbContext();
|
||||
var p = await ctx.MemberPayments
|
||||
.Where(p => p.Year == year && p.AvNr == avnr && p.MgNr == mgnr)
|
||||
.SingleAsync();
|
||||
return new CreditNote(p, billingData, data, underDeliveries);
|
||||
return new CreditNote(p, dateFrom, billingData, data, underDeliveries);
|
||||
}
|
||||
|
||||
protected override async Task LoadData(AppDbContext ctx) {
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace Elwig.Documents {
|
||||
public Dictionary<string, MemberBucket> MemberBuckets = [];
|
||||
public List<MemberStat> MemberStats = [];
|
||||
|
||||
public DeliveryConfirmation(int year, Member m, DeliveryConfirmationDeliveryData? data = null) :
|
||||
base($"{Name} {year}", m) {
|
||||
public DeliveryConfirmation(int year, Member m, DateOnly? dateFrom, DeliveryConfirmationDeliveryData? data = null) :
|
||||
base($"{Name} {year}", m, dateFrom) {
|
||||
_year = year;
|
||||
ShowDateAndLocation = true;
|
||||
UseBillingAddress = true;
|
||||
|
||||
@@ -29,14 +29,12 @@ namespace Elwig.Documents {
|
||||
public int DisplayStats = App.Client.ModeDeliveryNoteStats;
|
||||
|
||||
public DeliveryNote(Delivery d) :
|
||||
base($"{Name} Nr. {d.LsNr}", d.Member) {
|
||||
base($"{Name} Nr. {d.LsNr}", d.Member, DateOnly.FromDateTime(d.ModifiedAt)) {
|
||||
UseBillingAddress = true;
|
||||
ShowDateAndLocation = true;
|
||||
Delivery = d;
|
||||
Text = App.Client.TextDeliveryNote;
|
||||
DocumentId = d.LsNr;
|
||||
Date = DateOnly.FromDateTime(d.ModifiedAt);
|
||||
IsDoublePaged = true;
|
||||
}
|
||||
|
||||
public static async Task<DeliveryNote> Initialize(int year, int did) {
|
||||
|
||||
@@ -49,14 +49,12 @@ namespace Elwig.Documents {
|
||||
public bool IsPreview = false;
|
||||
private iText.Layout.Document? _doc;
|
||||
|
||||
public int CurrentNextSeason;
|
||||
public string? DocumentId;
|
||||
public string Title;
|
||||
public string Author;
|
||||
public DateOnly Date;
|
||||
|
||||
public Document(string title) {
|
||||
CurrentNextSeason = Utils.CurrentNextSeason;
|
||||
Title = title;
|
||||
Author = App.Client.NameFull;
|
||||
Date = DateOnly.FromDateTime(Utils.Today);
|
||||
|
||||
@@ -6,7 +6,7 @@ using iText.Layout;
|
||||
namespace Elwig.Documents {
|
||||
public class Letterhead : BusinessDocument {
|
||||
public Letterhead(Member m) :
|
||||
base($"Briefkopf {m.FullName}", m, true) {
|
||||
base($"Briefkopf {m.FullName}", m, null, includeSender: true) {
|
||||
}
|
||||
|
||||
protected override void RenderBody(iText.Layout.Document doc, PdfDocument pdf) {
|
||||
|
||||
@@ -23,7 +23,8 @@ namespace Elwig.Documents {
|
||||
public List<AreaCom> ActiveAreaCommitments = [];
|
||||
|
||||
public MemberDataSheet(Member m) :
|
||||
base($"{Name} {m.AdministrativeName}", m) {
|
||||
base($"{Name} {m.AdministrativeName}", m, DateOnly.FromDateTime(m.ModifiedAt)) {
|
||||
ShowDateAndLocation = true;
|
||||
DocumentId = $"{Name} {m.MgNr}";
|
||||
}
|
||||
|
||||
|
||||
@@ -413,7 +413,7 @@ namespace Elwig.Services {
|
||||
await b.CalculateBuckets();
|
||||
App.HintContextChange();
|
||||
|
||||
using var doc = new DeliveryConfirmation(year, m);
|
||||
using var doc = new DeliveryConfirmation(year, m, null);
|
||||
await Utils.ExportDocument(doc, mode, emailData: (m, $"{DeliveryConfirmation.Name} {year}", $"Im Anhang finden Sie die Anlieferungsbestätigung {year}"));
|
||||
} catch (Exception exc) {
|
||||
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
@@ -426,7 +426,7 @@ namespace Elwig.Services {
|
||||
Mouse.OverrideCursor = Cursors.Wait;
|
||||
await Task.Run(async () => {
|
||||
try {
|
||||
using var doc = await CreditNote.Initialize(year, avnr, m.MgNr);
|
||||
using var doc = await CreditNote.Initialize(year, avnr, m.MgNr, null);
|
||||
await Utils.ExportDocument(doc, mode, emailData: (m, $"{CreditNote.Name} {doc.Payment.Variant.Name}", $"Im Anhang finden Sie die Traubengutschrift {doc.Payment.Variant.Name}"));
|
||||
} catch (Exception exc) {
|
||||
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
|
||||
@@ -756,14 +756,14 @@ namespace Elwig.Windows {
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
return [new GeneratedDoc(new DeliveryConfirmation(year, m, data) { Date = postalDate })];
|
||||
return [new GeneratedDoc(new DeliveryConfirmation(year, m, postalDate, data) { Date = postalDate })];
|
||||
} else if (doc.Type == DocType.CreditNote) {
|
||||
var details = ((int, int))doc.Details!;
|
||||
var year = details.Item1;
|
||||
var avnr = details.Item2;
|
||||
var data = cnData[(year, avnr)];
|
||||
try {
|
||||
return [new GeneratedDoc(new CreditNote(data.Item2[m.MgNr], data.Item3, data.Item1[m.MgNr]) { Date = postalDate })];
|
||||
return [new GeneratedDoc(new CreditNote(data.Item2[m.MgNr], postalDate, data.Item3, data.Item1[m.MgNr]) { Date = postalDate })];
|
||||
} catch (Exception) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Tests.UnitTests.DocumentTests {
|
||||
|
||||
[Test]
|
||||
public async Task Test_01_VirtualCreditNote() {
|
||||
using var doc = await CreditNote.Initialize(2020, 1, 101);
|
||||
using var doc = await CreditNote.Initialize(2020, 1, 101, null);
|
||||
var text = await Utils.GeneratePdfText(doc);
|
||||
Assert.Multiple(() => {
|
||||
Assert.That(text, Contains.Substring("""
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Tests.UnitTests.DocumentTests {
|
||||
using var ctx = new AppDbContext();
|
||||
var m = await ctx.FetchMembers(101).SingleAsync();
|
||||
var data = await DeliveryConfirmationDeliveryData.ForMember(ctx.DeliveryParts, 2020, m!);
|
||||
using var doc = new DeliveryConfirmation(2020, m!, data);
|
||||
using var doc = new DeliveryConfirmation(2020, m!, null, data);
|
||||
var text = await Utils.GeneratePdfText(doc);
|
||||
Assert.Multiple(() => {
|
||||
Assert.That(text, Contains.Substring("""
|
||||
|
||||
Reference in New Issue
Block a user