Billing: Fixes
This commit is contained in:
		@@ -12,6 +12,8 @@ using System.Text;
 | 
			
		||||
using System.Numerics;
 | 
			
		||||
using Elwig.Models.Entities;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using ScottPlot.TickGenerators.TimeUnits;
 | 
			
		||||
using Elwig.Helpers.Billing;
 | 
			
		||||
 | 
			
		||||
namespace Elwig.Helpers {
 | 
			
		||||
    public static partial class Utils {
 | 
			
		||||
@@ -359,5 +361,27 @@ namespace Elwig.Helpers {
 | 
			
		||||
            }
 | 
			
		||||
            return output.OrderByDescending(l => l.Count());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static List<string> GetAttributeVarieties(AppDbContext ctx, int year, bool withSlash = false) {
 | 
			
		||||
            return ctx.DeliveryParts
 | 
			
		||||
               .Where(d => d.Year == year)
 | 
			
		||||
               .Select(d => $"{d.SortId}{(withSlash ? "/" : "")}{d.AttrId}")
 | 
			
		||||
               .Distinct()
 | 
			
		||||
               .ToList()
 | 
			
		||||
               .Union(ctx.WineVarieties.Select(v => v.SortId))
 | 
			
		||||
               .ToList();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static List<ContractSelection> GetContractsForYear(AppDbContext ctx, int year) {
 | 
			
		||||
            return ctx.DeliveryParts
 | 
			
		||||
                .Where(p => p.Year == year)
 | 
			
		||||
                .Select(d => new ContractSelection(d.Variant, d.Attribute))
 | 
			
		||||
                .Distinct()
 | 
			
		||||
                .ToList()
 | 
			
		||||
                .Union(ctx.WineVarieties.Select(v => new ContractSelection(v, null)))
 | 
			
		||||
                .DistinctBy(c => c.Listing)
 | 
			
		||||
                .Order()
 | 
			
		||||
                .ToList();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user