Files
elwig/Elwig/Documents/DeliveryConfirmation.cshtml.cs

27 lines
991 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Elwig.Helpers;
using Elwig.Models;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
namespace Elwig.Documents {
public class DeliveryConfirmation : BusinessDocument {
public int Year;
public IEnumerable<DeliveryPart> Deliveries;
public DeliveryConfirmation(AppDbContext ctx, int year, Member m) : base($"Anlieferungsbestätigung {year} {m.Name}", m) {
Year = year;
DocumentId = $"Anl.-Best. {Year}/{m.MgNr}";
Deliveries = ctx.DeliveryParts.FromSqlRaw($"""
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) = ({Year}, {m.MgNr})
ORDER BY v.sortid, v.abgewertet ASC, LENGTH(v.attributes) DESC, COALESCE(v.attributes, '~'), v.kmw DESC, v.lsnr, v.dpnr
""")
.ToList();
}
}
}