Payment.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.Payment.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.Payment.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 Supplier { get; set; }
  25. [Obsolete("Replaced by Supplier")]
  26. public SupplierLink SupplierLink
  27. {
  28. get => Supplier;
  29. set { }
  30. }
  31. [EntityRelationship(DeleteAction.SetNull)]
  32. public PaymentTypeLink PaymentType { get; set; }
  33. [Obsolete("Replaced by PaymentType")]
  34. public PaymentTypeLink PaymentTypeLink
  35. {
  36. get => PaymentType;
  37. set { }
  38. }
  39. [MemoEditor]
  40. public string Notes { get; set; }
  41. [CurrencyEditor(Editable = Editable.Hidden)]
  42. [Aggregate(typeof(PaymentTotal))]
  43. public double Total { get; set; }
  44. public override string ToString()
  45. {
  46. return string.Format("{0:dd MMM yy}: {1} (${2:F2})", Date, PaymentType.Description, Total);
  47. }
  48. }
  49. }