Added print option for calculation details.
Now the calculation details show more information.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[Setup]
|
||||
AppName=MietRechner
|
||||
AppVersion=2.1
|
||||
AppVersion=2.2
|
||||
WizardStyle=modern
|
||||
DefaultDirName={autopf}\MietRechner
|
||||
DefaultGroupName=MietRechner
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using UCalc.Data;
|
||||
|
||||
namespace UCalc.Controls
|
||||
{
|
||||
public class PrintableBilling : PrintableDocument<Tuple<Billing, IEnumerable<Tenant>>>
|
||||
{
|
||||
public PrintableBilling(Billing billing, IEnumerable<Tenant> tenants) : base(
|
||||
new Tuple<Billing, IEnumerable<Tenant>>(billing, tenants))
|
||||
{
|
||||
}
|
||||
|
||||
protected override void FillFlowDocument(FlowDocument document, Tuple<Billing, IEnumerable<Tenant>> args)
|
||||
{
|
||||
var (billing, tenants) = args;
|
||||
|
||||
foreach (var tenant in tenants)
|
||||
{
|
||||
var result = BillingCalculator.CalculateForTenant(billing, tenant);
|
||||
AddPagesForTenant(document, billing, tenant, result);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddPagesForTenant(FlowDocument document, Billing billing, Tenant tenant,
|
||||
TenantCalculationResult result)
|
||||
{
|
||||
var section = new Section {BreakPageBefore = true, FontSize = Constants.PrintDefaultFontSize};
|
||||
document.Blocks.Add(section);
|
||||
|
||||
var table = new Table {CellSpacing = 0};
|
||||
section.Blocks.Add(table);
|
||||
table.Columns.Add(new TableColumn {Width = new GridLength(1, GridUnitType.Star)});
|
||||
table.Columns.Add(new TableColumn {Width = new GridLength(1, GridUnitType.Star)});
|
||||
|
||||
var rowGroup = new TableRowGroup();
|
||||
table.RowGroups.Add(rowGroup);
|
||||
|
||||
void AddCost(string name, decimal amount, bool isLast = false)
|
||||
{
|
||||
var row2 = new TableRow();
|
||||
rowGroup.Rows.Add(row2);
|
||||
|
||||
if (isLast)
|
||||
{
|
||||
row2.Background = Brushes.LightGray;
|
||||
}
|
||||
|
||||
var cell2 = new TableCell
|
||||
{BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1, 1, 0, isLast ? 1 : 0)};
|
||||
row2.Cells.Add(cell2);
|
||||
|
||||
cell2.Blocks.Add(new Paragraph(new Run(name)) {Padding = new Thickness(6)});
|
||||
|
||||
cell2 = new TableCell
|
||||
{
|
||||
BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1, 1, 1, isLast ? 1 : 0),
|
||||
TextAlignment = TextAlignment.Right
|
||||
};
|
||||
row2.Cells.Add(cell2);
|
||||
|
||||
cell2.Blocks.Add(new Paragraph(new Run($"{amount.CeilToString()} €")) {Padding = new Thickness(6)});
|
||||
}
|
||||
|
||||
void AddTextLeftRight(string leftText, string rightText)
|
||||
{
|
||||
var row2 = new TableRow();
|
||||
rowGroup.Rows.Add(row2);
|
||||
|
||||
var cell2 = new TableCell();
|
||||
row2.Cells.Add(cell2);
|
||||
|
||||
cell2.Blocks.Add(new Paragraph(new Run(leftText)));
|
||||
|
||||
cell2 = new TableCell
|
||||
{
|
||||
TextAlignment = TextAlignment.Right
|
||||
};
|
||||
row2.Cells.Add(cell2);
|
||||
|
||||
cell2.Blocks.Add(new Paragraph(new Run(rightText)));
|
||||
}
|
||||
|
||||
AddTextLeftRight(
|
||||
$"{billing.Landlord.Name}\n" +
|
||||
$"{billing.Landlord.Address.Street} {billing.Landlord.Address.HouseNumber}\n" +
|
||||
$"{billing.Landlord.Address.Postcode} {billing.Landlord.Address.City}\n" +
|
||||
$"Telefon: {billing.Landlord.Phone}" +
|
||||
(string.IsNullOrEmpty(billing.Landlord.MailAddress) ? "" : $"\nEmail: {billing.Landlord.MailAddress}"),
|
||||
DateTime.Now.ToString(Constants.DateFormat)
|
||||
);
|
||||
|
||||
AddLineBreaks(rowGroup, 2);
|
||||
|
||||
AddText(
|
||||
rowGroup,
|
||||
$"{tenant.Salutation.AsString()} {tenant.Name}\n" +
|
||||
$"{billing.House.Address.Street} {billing.House.Address.HouseNumber}\n" +
|
||||
$"{billing.House.Address.Postcode} {billing.House.Address.City}"
|
||||
);
|
||||
|
||||
AddLineBreaks(rowGroup, 4);
|
||||
|
||||
AddText(rowGroup, $"{tenant.Salutation.AsString()} {tenant.Name}");
|
||||
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
|
||||
var startDate = billing.StartDate;
|
||||
if (tenant.EntryDate.HasValue && tenant.EntryDate.Value > startDate)
|
||||
{
|
||||
startDate = tenant.EntryDate.Value;
|
||||
}
|
||||
|
||||
var endDate = billing.EndDate;
|
||||
if (tenant.DepartureDate.HasValue && tenant.DepartureDate.Value < endDate)
|
||||
{
|
||||
endDate = tenant.DepartureDate.Value;
|
||||
}
|
||||
|
||||
AddText(
|
||||
rowGroup,
|
||||
$"Nebenkostenabrechnung vom {startDate.ToString(Constants.DateFormat)} zum {endDate.ToString(Constants.DateFormat)}",
|
||||
Constants.PrintSubjectFontSize
|
||||
);
|
||||
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
|
||||
if (!string.IsNullOrEmpty(tenant.CustomMessage1))
|
||||
{
|
||||
AddText(rowGroup, tenant.CustomMessage1);
|
||||
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
}
|
||||
|
||||
foreach (var (cost, costResult) in result.Costs)
|
||||
{
|
||||
AddCost(cost.Name, costResult.TotalAmount);
|
||||
}
|
||||
|
||||
AddCost("Zwischensumme", result.SubTotalAmount);
|
||||
AddCost("Bereits gezahlt", tenant.PaidRent);
|
||||
AddCost(result.TotalAmount > 0 ? "Einmalige Nachzahlung" : "Einmalige Rückzahlung", result.TotalAmount,
|
||||
true);
|
||||
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
|
||||
if (result.TotalAmount > 0)
|
||||
{
|
||||
AddText(
|
||||
rowGroup,
|
||||
$"Bitte überweisen Sie den einmaligen Betrag von {result.TotalAmount.CeilToString()} € auf das untenstehende Konto."
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddText(
|
||||
rowGroup,
|
||||
$"Der einmalige Betrag von {(result.TotalAmount * -1).CeilToString()} € wird in den nächsten Tagen auf Ihr Konto überwiesen."
|
||||
);
|
||||
}
|
||||
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
|
||||
if (!string.IsNullOrEmpty(tenant.CustomMessage2))
|
||||
{
|
||||
AddText(rowGroup, tenant.CustomMessage2);
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
}
|
||||
|
||||
AddText(rowGroup, "Kontoverbindung:");
|
||||
AddText(rowGroup, $"IBAN: {billing.Landlord.BankAccount.Iban}");
|
||||
AddText(rowGroup, $"BIC: {billing.Landlord.BankAccount.Bic}");
|
||||
AddText(rowGroup, $"Name der Bank: {billing.Landlord.BankAccount.BankName}");
|
||||
|
||||
AddLineBreaks(rowGroup, 2);
|
||||
|
||||
AddText(rowGroup, "Mit freundlichen Grüßen");
|
||||
|
||||
if (result.Costs.Any(t => t.Key.DisplayInBill))
|
||||
{
|
||||
AddPagesForTenantDetails(document, result);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddPagesForTenantDetails(FlowDocument document, TenantCalculationResult result)
|
||||
{
|
||||
var section = new Section {BreakPageBefore = true, FontSize = Constants.PrintDefaultFontSize};
|
||||
document.Blocks.Add(section);
|
||||
|
||||
var table = new Table {CellSpacing = 0};
|
||||
section.Blocks.Add(table);
|
||||
table.Columns.Add(new TableColumn {Width = new GridLength(1, GridUnitType.Star)});
|
||||
table.Columns.Add(new TableColumn {Width = new GridLength(1, GridUnitType.Star)});
|
||||
|
||||
var rowGroup = new TableRowGroup();
|
||||
table.RowGroups.Add(rowGroup);
|
||||
|
||||
AddText(rowGroup, "Details zur Berechnung:");
|
||||
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
|
||||
foreach (var (cost, costResult) in result.Costs)
|
||||
{
|
||||
if (!cost.DisplayInBill)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
AddText(rowGroup, costResult.Details);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Packaging;
|
||||
@@ -8,11 +7,9 @@ using System.Printing;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Xps.Packaging;
|
||||
using System.Windows.Xps.Serialization;
|
||||
using Microsoft.Win32;
|
||||
using UCalc.Data;
|
||||
|
||||
namespace UCalc.Controls
|
||||
{
|
||||
@@ -23,7 +20,7 @@ namespace UCalc.Controls
|
||||
}
|
||||
}
|
||||
|
||||
public class PrintableDocument : IDisposable
|
||||
public abstract class PrintableDocument<T> : IDisposable
|
||||
{
|
||||
private static readonly Uri DocUri = new Uri($"pack://mietrechner{new Guid()}.xps");
|
||||
private readonly Package _package;
|
||||
@@ -31,12 +28,12 @@ namespace UCalc.Controls
|
||||
private readonly FixedDocumentSequence _previewDocument;
|
||||
private XpsDocument _fixedDocument;
|
||||
|
||||
public PrintableDocument(Billing billing, IEnumerable<Tenant> tenants)
|
||||
protected PrintableDocument(T args)
|
||||
{
|
||||
_package = Package.Open(new MemoryStream(), FileMode.Create, FileAccess.ReadWrite);
|
||||
PackageStore.AddPackage(DocUri, _package);
|
||||
|
||||
_flowDocument = CreateFlowDocument(billing, tenants);
|
||||
_flowDocument = CreateFlowDocument(args);
|
||||
_previewDocument = CreatePreview(_flowDocument);
|
||||
}
|
||||
|
||||
@@ -127,11 +124,7 @@ namespace UCalc.Controls
|
||||
|
||||
xpsDocument.Close();
|
||||
|
||||
var process = new Process();
|
||||
process.StartInfo = new ProcessStartInfo(path)
|
||||
{
|
||||
UseShellExecute = true
|
||||
};
|
||||
var process = new Process {StartInfo = new ProcessStartInfo(path) {UseShellExecute = true}};
|
||||
process.Start();
|
||||
}
|
||||
}
|
||||
@@ -193,7 +186,7 @@ namespace UCalc.Controls
|
||||
public override IDocumentPaginatorSource Source => _paginator.Source;
|
||||
}
|
||||
|
||||
private static FlowDocument CreateFlowDocument(Billing billing, IEnumerable<Tenant> tenants)
|
||||
private FlowDocument CreateFlowDocument(T args)
|
||||
{
|
||||
var size = GetPrinterMediaSize();
|
||||
if (!size.HasValue)
|
||||
@@ -209,16 +202,13 @@ namespace UCalc.Controls
|
||||
ColumnWidth = double.PositiveInfinity
|
||||
};
|
||||
|
||||
foreach (var tenant in tenants)
|
||||
{
|
||||
var result = BillingCalculator.CalculateForTenant(billing, tenant);
|
||||
AddPagesForTenant(document, billing, tenant, result);
|
||||
}
|
||||
|
||||
FillFlowDocument(document, args);
|
||||
return document;
|
||||
}
|
||||
|
||||
private static void AddLineBreaks(TableRowGroup rowGroup, int count)
|
||||
protected abstract void FillFlowDocument(FlowDocument flowDocument, T args);
|
||||
|
||||
protected static void AddLineBreaks(TableRowGroup rowGroup, int count)
|
||||
{
|
||||
var row = new TableRow();
|
||||
rowGroup.Rows.Add(row);
|
||||
@@ -229,7 +219,7 @@ namespace UCalc.Controls
|
||||
{FontSize = Constants.PrintNewlineFontSize}));
|
||||
}
|
||||
|
||||
private static void AddText(TableRowGroup rowGroup, string text, double? fontSize = null,
|
||||
protected static void AddText(TableRowGroup rowGroup, string text, double? fontSize = null,
|
||||
bool alignRight = false)
|
||||
{
|
||||
var row = new TableRow();
|
||||
@@ -251,193 +241,5 @@ namespace UCalc.Controls
|
||||
paragraph.FontSize = fontSize.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddPagesForTenant(FlowDocument document, Billing billing, Tenant tenant,
|
||||
TenantCalculationResult result)
|
||||
{
|
||||
var section = new Section {BreakPageBefore = true, FontSize = Constants.PrintDefaultFontSize};
|
||||
document.Blocks.Add(section);
|
||||
|
||||
var table = new Table {CellSpacing = 0};
|
||||
section.Blocks.Add(table);
|
||||
table.Columns.Add(new TableColumn {Width = new GridLength(1, GridUnitType.Star)});
|
||||
table.Columns.Add(new TableColumn {Width = new GridLength(1, GridUnitType.Star)});
|
||||
|
||||
var rowGroup = new TableRowGroup();
|
||||
table.RowGroups.Add(rowGroup);
|
||||
|
||||
void AddCost(string name, decimal amount, bool isLast = false)
|
||||
{
|
||||
var row2 = new TableRow();
|
||||
rowGroup.Rows.Add(row2);
|
||||
|
||||
if (isLast)
|
||||
{
|
||||
row2.Background = Brushes.LightGray;
|
||||
}
|
||||
|
||||
var cell2 = new TableCell
|
||||
{BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1, 1, 0, isLast ? 1 : 0)};
|
||||
row2.Cells.Add(cell2);
|
||||
|
||||
cell2.Blocks.Add(new Paragraph(new Run(name)) {Padding = new Thickness(6)});
|
||||
|
||||
cell2 = new TableCell
|
||||
{
|
||||
BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1, 1, 1, isLast ? 1 : 0),
|
||||
TextAlignment = TextAlignment.Right
|
||||
};
|
||||
row2.Cells.Add(cell2);
|
||||
|
||||
cell2.Blocks.Add(new Paragraph(new Run($"{amount.CeilToString()} €")) {Padding = new Thickness(6)});
|
||||
}
|
||||
|
||||
void AddTextLeftRight(string leftText, string rightText)
|
||||
{
|
||||
var row2 = new TableRow();
|
||||
rowGroup.Rows.Add(row2);
|
||||
|
||||
var cell2 = new TableCell();
|
||||
row2.Cells.Add(cell2);
|
||||
|
||||
cell2.Blocks.Add(new Paragraph(new Run(leftText)));
|
||||
|
||||
cell2 = new TableCell
|
||||
{
|
||||
TextAlignment = TextAlignment.Right
|
||||
};
|
||||
row2.Cells.Add(cell2);
|
||||
|
||||
cell2.Blocks.Add(new Paragraph(new Run(rightText)));
|
||||
}
|
||||
|
||||
AddTextLeftRight(
|
||||
$"{billing.Landlord.Name}\n" +
|
||||
$"{billing.Landlord.Address.Street} {billing.Landlord.Address.HouseNumber}\n" +
|
||||
$"{billing.Landlord.Address.Postcode} {billing.Landlord.Address.City}\n" +
|
||||
$"Telefon: {billing.Landlord.Phone}" +
|
||||
(string.IsNullOrEmpty(billing.Landlord.MailAddress) ? "" : $"\nEmail: {billing.Landlord.MailAddress}"),
|
||||
DateTime.Now.ToString(Constants.DateFormat)
|
||||
);
|
||||
|
||||
AddLineBreaks(rowGroup, 2);
|
||||
|
||||
AddText(
|
||||
rowGroup,
|
||||
$"{tenant.Salutation.AsString()} {tenant.Name}\n" +
|
||||
$"{billing.House.Address.Street} {billing.House.Address.HouseNumber}\n" +
|
||||
$"{billing.House.Address.Postcode} {billing.House.Address.City}"
|
||||
);
|
||||
|
||||
AddLineBreaks(rowGroup, 4);
|
||||
|
||||
AddText(rowGroup, $"{tenant.Salutation.AsString()} {tenant.Name}");
|
||||
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
|
||||
var startDate = billing.StartDate;
|
||||
if (tenant.EntryDate.HasValue && tenant.EntryDate.Value > startDate)
|
||||
{
|
||||
startDate = tenant.EntryDate.Value;
|
||||
}
|
||||
|
||||
var endDate = billing.EndDate;
|
||||
if (tenant.DepartureDate.HasValue && tenant.DepartureDate.Value < endDate)
|
||||
{
|
||||
endDate = tenant.DepartureDate.Value;
|
||||
}
|
||||
|
||||
AddText(
|
||||
rowGroup,
|
||||
$"Nebenkostenabrechnung vom {startDate.ToString(Constants.DateFormat)} zum {endDate.ToString(Constants.DateFormat)}",
|
||||
Constants.PrintSubjectFontSize
|
||||
);
|
||||
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
|
||||
if (!string.IsNullOrEmpty(tenant.CustomMessage1))
|
||||
{
|
||||
AddText(rowGroup, tenant.CustomMessage1);
|
||||
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
}
|
||||
|
||||
foreach (var (cost, costResult) in result.Costs)
|
||||
{
|
||||
AddCost(cost.Name, costResult.TotalAmount);
|
||||
}
|
||||
|
||||
AddCost("Zwischensumme", result.SubTotalAmount);
|
||||
AddCost("Bereits gezahlt", tenant.PaidRent);
|
||||
AddCost(result.TotalAmount > 0 ? "Einmalige Nachzahlung" : "Einmalige Rückzahlung", result.TotalAmount,
|
||||
true);
|
||||
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
|
||||
if (result.TotalAmount > 0)
|
||||
{
|
||||
AddText(
|
||||
rowGroup,
|
||||
$"Bitte überweisen Sie den einmaligen Betrag von {result.TotalAmount.CeilToString()} € auf das untenstehende Konto."
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddText(
|
||||
rowGroup,
|
||||
$"Der einmalige Betrag von {(result.TotalAmount * -1).CeilToString()} € wird in den nächsten Tagen auf Ihr Konto überwiesen."
|
||||
);
|
||||
}
|
||||
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
|
||||
if (!string.IsNullOrEmpty(tenant.CustomMessage2))
|
||||
{
|
||||
AddText(rowGroup, tenant.CustomMessage2);
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
}
|
||||
|
||||
AddText(rowGroup, "Kontoverbindung:");
|
||||
AddText(rowGroup, $"IBAN: {billing.Landlord.BankAccount.Iban}");
|
||||
AddText(rowGroup, $"BIC: {billing.Landlord.BankAccount.Bic}");
|
||||
AddText(rowGroup, $"Name der Bank: {billing.Landlord.BankAccount.BankName}");
|
||||
|
||||
AddLineBreaks(rowGroup, 2);
|
||||
|
||||
AddText(rowGroup, "Mit freundlichen Grüßen");
|
||||
|
||||
if (result.Costs.Any(t => t.Key.DisplayInBill))
|
||||
{
|
||||
AddPagesForTenantDetails(document, result);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddPagesForTenantDetails(FlowDocument document, TenantCalculationResult result)
|
||||
{
|
||||
var section = new Section {BreakPageBefore = true, FontSize = Constants.PrintDefaultFontSize};
|
||||
document.Blocks.Add(section);
|
||||
|
||||
var table = new Table {CellSpacing = 0};
|
||||
section.Blocks.Add(table);
|
||||
table.Columns.Add(new TableColumn {Width = new GridLength(1, GridUnitType.Star)});
|
||||
table.Columns.Add(new TableColumn {Width = new GridLength(1, GridUnitType.Star)});
|
||||
|
||||
var rowGroup = new TableRowGroup();
|
||||
table.RowGroups.Add(rowGroup);
|
||||
|
||||
AddText(rowGroup, "Details zur Berechnung:");
|
||||
|
||||
AddLineBreaks(rowGroup, 1);
|
||||
|
||||
foreach (var (cost, costResult) in result.Costs)
|
||||
{
|
||||
if (!cost.DisplayInBill)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
AddText(rowGroup, costResult.Details);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
|
||||
namespace UCalc.Controls
|
||||
{
|
||||
public class PrintableTextBox : PrintableDocument<TextBox>
|
||||
{
|
||||
public PrintableTextBox(TextBox textBox) : base(textBox)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void FillFlowDocument(FlowDocument document, TextBox textBox)
|
||||
{
|
||||
var section = new Section {BreakPageBefore = true, FontSize = Constants.PrintDefaultFontSize};
|
||||
document.Blocks.Add(section);
|
||||
|
||||
var table = new Table {CellSpacing = 0};
|
||||
section.Blocks.Add(table);
|
||||
table.Columns.Add(new TableColumn {Width = new GridLength(1, GridUnitType.Star)});
|
||||
|
||||
var rowGroup = new TableRowGroup();
|
||||
table.RowGroups.Add(rowGroup);
|
||||
|
||||
AddText(rowGroup, textBox.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -603,6 +603,23 @@ namespace UCalc.Data
|
||||
var details = new StringBuilder();
|
||||
var detailsLandlord = new StringBuilder();
|
||||
|
||||
var startDate = billing.StartDate;
|
||||
if (tenant.EntryDate.HasValue && startDate < tenant.EntryDate.Value)
|
||||
{
|
||||
startDate = tenant.EntryDate.Value;
|
||||
}
|
||||
|
||||
var endDate = billing.EndDate;
|
||||
if (tenant.DepartureDate.HasValue && endDate < tenant.DepartureDate.Value)
|
||||
{
|
||||
endDate = tenant.DepartureDate.Value;
|
||||
}
|
||||
|
||||
detailsLandlord.Append(
|
||||
$"Berechnungsdetails für {tenant.Name} vom {startDate.ToString(Constants.DateFormat)} zum {endDate.ToString(Constants.DateFormat)}\n"
|
||||
);
|
||||
detailsLandlord.Append($"Stand {DateTime.Now.ToString(Constants.DateFormat)}\n\n");
|
||||
|
||||
decimal totalAmount = 0;
|
||||
|
||||
foreach (var cost in billing.Costs)
|
||||
@@ -647,6 +664,10 @@ namespace UCalc.Data
|
||||
var tenantResults = billing.Tenants.Select(tenant => CalculateForTenant(billing, tenant)).ToList();
|
||||
|
||||
decimal landlordAmount = 0;
|
||||
str.Append(
|
||||
$"Kostenübersicht vom {billing.StartDate.ToString(Constants.DateFormat)} zum {billing.EndDate.ToString(Constants.DateFormat)}\n"
|
||||
);
|
||||
str.Append($"Stand {DateTime.Now.ToString(Constants.DateFormat)}\n\n");
|
||||
|
||||
foreach (var cost in billing.Costs)
|
||||
{
|
||||
|
||||
@@ -19,6 +19,33 @@
|
||||
Width="180"
|
||||
Foreground="{x:Static local:Constants.SubMainColor}" />
|
||||
|
||||
<controls:HighlightButton
|
||||
HighlightForeground="{x:Static local:Constants.SubMainColor}"
|
||||
HighlightBackground="{x:Static local:Constants.MainColor}"
|
||||
DockPanel.Dock="Right"
|
||||
Margin="6, 0, 0, 0"
|
||||
ToolTip="Gezeigten Text drucken"
|
||||
Click="OnPrintTextClick">
|
||||
|
||||
<Viewbox Width="16"
|
||||
Height="16"
|
||||
Margin="4, 4, 4, 4"
|
||||
Stretch="Uniform">
|
||||
<Canvas Width="512" Height="512">
|
||||
<Canvas.RenderTransform>
|
||||
<TranslateTransform X="0" Y="0" />
|
||||
</Canvas.RenderTransform>
|
||||
<Path>
|
||||
<Path.Data>
|
||||
<PathGeometry
|
||||
Figures="M448 192V77.25c0-8.49-3.37-16.62-9.37-22.63L393.37 9.37c-6-6-14.14-9.37-22.63-9.37H96C78.33 0 64 14.33 64 32v160c-35.35 0-64 28.65-64 64v112c0 8.84 7.16 16 16 16h48v96c0 17.67 14.33 32 32 32h320c17.67 0 32-14.33 32-32v-96h48c8.84 0 16-7.16 16-16V256c0-35.35-28.65-64-64-64zm-64 256H128v-96h256v96zm0-224H128V64h192v48c0 8.84 7.16 16 16 16h48v96zm48 72c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24z"
|
||||
FillRule="NonZero" />
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</controls:HighlightButton>
|
||||
|
||||
<ComboBox
|
||||
ItemsSource="{Binding Path=Items, RelativeSource={RelativeSource AncestorType=pages:DetailsPage}}"
|
||||
SelectionChanged="OnSelectedTenantChanged"
|
||||
@@ -43,7 +70,7 @@
|
||||
IsReadOnly="True"
|
||||
BorderThickness="0"
|
||||
FontSize="13"
|
||||
Foreground="{x:Static local:Constants.SubMainColor}"/>
|
||||
Foreground="{x:Static local:Constants.SubMainColor}" />
|
||||
</DockPanel>
|
||||
|
||||
</Page>
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using UCalc.Controls;
|
||||
using UCalc.Data;
|
||||
using UCalc.Models;
|
||||
|
||||
@@ -71,5 +73,11 @@ namespace UCalc.Pages
|
||||
|
||||
CalculationTextBox.Text = result.DetailsForLandlord;
|
||||
}
|
||||
|
||||
private void OnPrintTextClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
using var printable = new PrintableTextBox(CalculationTextBox);
|
||||
printable.Print(TenantComboBox.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace UCalc.Pages
|
||||
|
||||
private void OnAboutClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("MietRechner Version 2.1\n\nCopyright © 2020-2021 by Tobias Erbshäußer", "Über MietRechner",
|
||||
MessageBox.Show("MietRechner Version 2.2\n\nCopyright © 2020-2021 by Tobias Erbshäußer", "Über MietRechner",
|
||||
MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,16 +54,16 @@ namespace UCalc
|
||||
|
||||
public partial class PrintWindow
|
||||
{
|
||||
public Billing Billing { get; }
|
||||
private readonly Billing _billing;
|
||||
public IReadOnlyList<TenantMenuItem> TenantMenuItems { get; }
|
||||
private PrintableDocument _document;
|
||||
private PrintableBilling _document;
|
||||
|
||||
|
||||
public PrintWindow(Model model)
|
||||
{
|
||||
Billing = model.Dump();
|
||||
_billing = model.Dump();
|
||||
TenantMenuItems = new[] {new TenantMenuItem(null, false), new TenantMenuItem(null, true)}.Concat(
|
||||
Billing.Tenants.Select(tenant => new TenantMenuItem(tenant, false))).ToList();
|
||||
_billing.Tenants.Select(tenant => new TenantMenuItem(tenant, false))).ToList();
|
||||
|
||||
foreach (var item in TenantMenuItems)
|
||||
{
|
||||
@@ -86,8 +86,8 @@ namespace UCalc
|
||||
{
|
||||
_document?.Dispose();
|
||||
|
||||
_document = new PrintableDocument(
|
||||
Billing,
|
||||
_document = new PrintableBilling(
|
||||
_billing,
|
||||
TenantMenuItems.Where(item => item.Selected).Select(item => item.Tenant)
|
||||
);
|
||||
_document.PreviewIn(Viewer);
|
||||
@@ -96,14 +96,8 @@ namespace UCalc
|
||||
private void OnPrintClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_document.Print(
|
||||
$"MietRechner Abrechnung {Billing.StartDate.ToString(Constants.DateFormat)} - {Billing.EndDate.ToString(Constants.DateFormat)}"
|
||||
$"MietRechner Abrechnung {_billing.StartDate.ToString(Constants.DateFormat)} - {_billing.EndDate.ToString(Constants.DateFormat)}"
|
||||
);
|
||||
|
||||
/*PrintDialog printDialog = new PrintDialog();
|
||||
if (printDialog.ShowDialog() == true)
|
||||
{
|
||||
printDialog.PrintQueue.AddJob("test", "C:\\test.xps", false);
|
||||
}*/
|
||||
}
|
||||
|
||||
private void OnSelectedTenantChanged(object sender, PropertyChangedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user