| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Linq.Expressions;
 
- using InABox.Core;
 
- namespace Comal.Classes
 
- {
 
-     public class CustomerSales : CoreAggregate<Customer, InvoiceLine, double>
 
-     {
 
-         public override Expression<Func<InvoiceLine, double>> Aggregate => x => x.IncTax;
 
-         public override AggregateCalculation Calculation => AggregateCalculation.Sum;
 
-         public override Dictionary<Expression<Func<InvoiceLine, object>>, Expression<Func<Customer, object>>> Links =>
 
-             new Dictionary<Expression<Func<InvoiceLine, object>>, Expression<Func<Customer, object>>>()
 
-             {
 
-                 { InvoiceLine => InvoiceLine.InvoiceLink.CustomerLink.ID, Customer => Customer.ID }
 
-             };
 
-     }
 
-     public class CustomerReceipts : CoreAggregate<Customer, InvoiceReceipt, double>
 
-     {
 
-         public override Expression<Func<InvoiceReceipt, double>> Aggregate => x => x.Amount;
 
-         public override AggregateCalculation Calculation => AggregateCalculation.Sum;
 
-         public override Dictionary<Expression<Func<InvoiceReceipt, object>>, Expression<Func<Customer, object>>> Links =>
 
-             new Dictionary<Expression<Func<InvoiceReceipt, object>>, Expression<Func<Customer, object>>>()
 
-             {
 
-                 { InvoiceReceipt => InvoiceReceipt.InvoiceLink.CustomerLink.ID, Customer => Customer.ID }
 
-             };
 
-     }
 
-     public class CustomerSites : CoreAggregate<Customer, Customer, Guid>
 
-     {
 
-         public override Expression<Func<Customer, Guid>> Aggregate => x => x.ID;
 
-         public override AggregateCalculation Calculation => AggregateCalculation.Count;
 
-         public override Dictionary<Expression<Func<Customer, object>>, Expression<Func<Customer, object>>> Links =>
 
-             new Dictionary<Expression<Func<Customer, object>>, Expression<Func<Customer, object>>>()
 
-             {
 
-                 { Customer => Customer.Account.ID, Customer => Customer.ID }
 
-             };
 
-     }
 
-     public class CustomerBalance : IFormula<Customer, double>
 
-     {
 
-         public Expression<Func<Customer, double>> Value => x => x.TotalSales;
 
-         public Expression<Func<Customer, double>>[] Modifiers => new Expression<Func<Customer, double>>[] { x => x.TotalReceipts };
 
-         public FormulaOperator Operator => FormulaOperator.Subtract;
 
-         public FormulaType Type => FormulaType.Virtual;
 
-     }
 
-     [UserTracking(typeof(Job))]
 
-     public class Customer : Entity, IPersistent, IRemotable, ISchedulable, ILicense<ProjectManagementLicense>, IExportable, IImportable, IMergeable
 
-     {
 
-         [EditorSequence(1)]
 
-         [UniqueCodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
 
-         public string Code { get; set; }
 
-         [EditorSequence(2)]
 
-         public string Name { get; set; }
 
-         [EditorSequence(3)]
 
-         public Address Delivery { get; set; }
 
-         [EditorSequence(5)]
 
-         public string Contact { get; set; }
 
-         [EditorSequence(6)]
 
-         [TextBoxEditor]
 
-         public string Email { get; set; }
 
-         [EditorSequence("Accounts", 1)]
 
-         [Caption("Bill To")]
 
-         public AccountLink Account { get; set; }
 
-         [EditorSequence("Accounts", 2)]
 
-         public Address Postal { get; set; }
 
-         [EditorSequence("Accounts", 3)]
 
-         [Caption("# Sites")]
 
-         [IntegerEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
 
-         [Aggregate(typeof(CustomerSites))]
 
-         public int Sites { get; set; }
 
-         [EditorSequence("Accounts", 4)]
 
-         [CurrencyEditor(Editable = Editable.Disabled, Summary = Summary.Sum)]
 
-         [Aggregate(typeof(CustomerSales))]
 
-         public double TotalSales { get; set; }
 
-         [EditorSequence("Accounts", 5)]
 
-         [CurrencyEditor(Editable = Editable.Disabled, Summary = Summary.Sum)]
 
-         [Aggregate(typeof(CustomerReceipts))]
 
-         public double TotalReceipts { get; set; }
 
-         [EditorSequence("Accounts", 6)]
 
-         [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
 
-         [Formula(typeof(CustomerBalance))]
 
-         public double Balance { get; set; }
 
-         [NullEditor]
 
-         [Aggregate(typeof(ActiveSchedules))]
 
-         public int ActiveSchedules { get; set; }
 
-         protected override void Init()
 
-         {
 
-             base.Init();
 
-             Delivery = new Address();
 
-             Postal = new Address();
 
-             Account = new AccountLink();
 
-         }
 
-         public override string ToString()
 
-         {
 
-             return Name;
 
-         }
 
-         protected override void DoPropertyChanged(string name, object before, object after)
 
-         {
 
-             base.DoPropertyChanged(name, before, after);
 
-         }
 
-     }
 
- }
 
 
  |