using System; using System.Collections.Generic; using System.Linq.Expressions; using InABox.Core; namespace Comal.Classes { public class PaymentTotal : CoreAggregate { public override Expression> Aggregate => x => x.Amount; public Expression> Link => x => x.PaymentLink.ID; public override AggregateCalculation Calculation => AggregateCalculation.Sum; public override Dictionary>, Expression>> Links => new Dictionary>, Expression>>() { { BillPayment => BillPayment.PaymentLink.ID, Payment => Payment.ID } }; } [UserTracking(typeof(Bill))] public class Payment : Entity, IPersistent, IRemotable, ILicense { [DateEditor] public DateTime Date { get; set; } [EditorSequence(1)] public SupplierLink SupplierLink { get; set; } [EntityRelationship(DeleteAction.SetNull)] public PaymentTypeLink PaymentTypeLink { get; set; } [MemoEditor] public string Notes { get; set; } [CurrencyEditor(Editable = Editable.Hidden)] [Aggregate(typeof(PaymentTotal))] public double Total { get; set; } public override string ToString() { return string.Format("{0:dd MMM yy}: {1} (${2:F2})", Date, PaymentTypeLink.Description, Total); } } }