refactoring the haircut messaging

This commit is contained in:
Paul Schneider 2017-06-02 21:34:18 +02:00
commit 8ec60de3f3
12 changed files with 199 additions and 80 deletions

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Yavsc.Billing;
using Yavsc.Models.Billing;
@ -11,5 +12,11 @@ namespace Yavsc.Helpers
public static decimal Addition(this List<CommandLine> items) => items.Select(i=>((IBillItem)i)).ToList().Addition();
public static string GetBillText(this IBillable query) {
string total = query.GetBillItems().Addition().ToString("C", CultureInfo.CurrentUICulture);
string bill = string.Join("\n", query.GetBillItems().Select(l=> $"{l.Name} {l.Description} : {l.UnitaryCost} € " + ((l.Count != 1) ? "*"+l.Count.ToString() : ""))) +
$"\n\nTotal: {total}";
return bill;
}
}
}