Payment.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq.Expressions;
  4. using InABox.Core;
  5. namespace Comal.Classes
  6. {
  7. public class PaymentTotal : CoreAggregate<Payment, BillPayment, double>
  8. {
  9. public override Expression<Func<BillPayment, double>> Aggregate => x => x.Amount;
  10. public Expression<Func<BillPayment, Guid>> Link => x => x.PaymentLink.ID;
  11. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  12. public override Dictionary<Expression<Func<BillPayment, object>>, Expression<Func<Payment, object>>> Links =>
  13. new Dictionary<Expression<Func<BillPayment, object>>, Expression<Func<Payment, object>>>()
  14. {
  15. { BillPayment => BillPayment.PaymentLink.ID, Payment => Payment.ID }
  16. };
  17. }
  18. [UserTracking(typeof(Bill))]
  19. public class Payment : Entity, IPersistent, IRemotable, ILicense<AccountsPayableLicense>
  20. {
  21. [DateEditor]
  22. public DateTime Date { get; set; }
  23. [EditorSequence(1)]
  24. public SupplierLink SupplierLink { get; set; }
  25. [EntityRelationship(DeleteAction.SetNull)]
  26. public PaymentTypeLink PaymentTypeLink { get; set; }
  27. [MemoEditor]
  28. public string Notes { get; set; }
  29. [CurrencyEditor(Editable = Editable.Hidden)]
  30. [Aggregate(typeof(PaymentTotal))]
  31. public double Total { get; set; }
  32. public override string ToString()
  33. {
  34. return string.Format("{0:dd MMM yy}: {1} (${2:F2})", Date, PaymentTypeLink.Description, Total);
  35. }
  36. }
  37. }