41 lines
1.8 KiB
C#
41 lines
1.8 KiB
C#
using Elwig.Helpers;
|
||
using Elwig.Models;
|
||
using Microsoft.EntityFrameworkCore;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
|
||
namespace Elwig.Documents {
|
||
public class CreditNote : BusinessDocument {
|
||
|
||
public Credit Credit;
|
||
public string? Text;
|
||
public string CurrencySymbol;
|
||
public string[] BinNames;
|
||
public int Precision;
|
||
public IEnumerable<DeliveryPart> Parts;
|
||
|
||
public CreditNote(Credit c, AppDbContext ctx) : base($"Traubengutschrift Nr. {c.TgId} – {c.Payment.Variant.Name}", c.Member) {
|
||
UseBillingAddress = true;
|
||
ShowDateAndLocation = true;
|
||
Credit = c;
|
||
Aside = Aside.Replace("</table>", "") +
|
||
$"<thead><tr><th colspan='2'>Gutschrift</th></tr></thead><tbody>" +
|
||
$"<tr><th>TG-Nr.</th><td>{c.TgId}</td></tr>" +
|
||
$"<tr><th>Überw. am</th><td>{c.Payment.Variant.TransferDate:dd.MM.yyyy}</td></tr>" +
|
||
$"<tr><th>Datum/Zeit</th><td>{c.ModifiedTimestamp:dd.MM.yyyy} / {c.ModifiedTimestamp:HH:mm}</td></tr>" +
|
||
$"</tbody></table>";
|
||
Text = App.Client.TextDeliveryNote;
|
||
DocumentId = $"Tr.-Gutschr. {c.TgId}";
|
||
CurrencySymbol = c.Payment.Variant.Season.Currency.Symbol ?? c.Payment.Variant.Season.Currency.Code;
|
||
BinNames = new string[0]; // FIXME
|
||
Precision = c.Payment.Variant.Season.Precision;
|
||
Parts = ctx.DeliveryParts.FromSql($"""
|
||
SELECT p.*
|
||
FROM v_delivery v
|
||
JOIN delivery_part p ON (p.year, p.did, p.dpnr) = (v.year, v.did, v.dpnr)
|
||
WHERE (v.year, v.mgnr) = ({c.Year}, {c.Member.MgNr})
|
||
ORDER BY sortid, attribute_prio DESC, COALESCE(attrid, '~'), kmw DESC, date, time, dpnr
|
||
""").ToList();
|
||
}
|
||
}}
|