123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using System;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using System.Runtime.InteropServices;
- using InABox.Core;
- namespace Comal.Classes
- {
- public class SupplierOrderBalance : CoreAggregate<Supplier, PurchaseOrderItem, double>
- {
- public override Expression<Func<PurchaseOrderItem, double>> Aggregate => x => x.Balance;
- public override AggregateCalculation Calculation => AggregateCalculation.Sum;
- public override Dictionary<Expression<Func<PurchaseOrderItem, object>>, Expression<Func<Supplier, object>>> Links =>
- new Dictionary<Expression<Func<PurchaseOrderItem, object>>, Expression<Func<Supplier, object>>>()
- {
- { PurchaseOrderItem => PurchaseOrderItem.PurchaseOrderLink.SupplierLink.ID, Supplier => Supplier.ID }
- };
- }
- public class SupplierTotalBills : CoreAggregate<Supplier, BillLine, double>
- {
- public override Expression<Func<BillLine, double>> Aggregate => x => x.IncTax;
- public override AggregateCalculation Calculation => AggregateCalculation.Sum;
- public override Dictionary<Expression<Func<BillLine, object>>, Expression<Func<Supplier, object>>> Links =>
- new Dictionary<Expression<Func<BillLine, object>>, Expression<Func<Supplier, object>>>()
- {
- { BillLine => BillLine.BillLink.SupplierLink.ID, Supplier => Supplier.ID }
- };
- }
- public class SupplierTotalPayments : CoreAggregate<Supplier, BillPayment, double>
- {
- public override Expression<Func<BillPayment, double>> Aggregate => x => x.Amount;
- public override AggregateCalculation Calculation => AggregateCalculation.Sum;
- public override Dictionary<Expression<Func<BillPayment, object>>, Expression<Func<Supplier, object>>> Links =>
- new Dictionary<Expression<Func<BillPayment, object>>, Expression<Func<Supplier, object>>>()
- {
- { BillPayment => BillPayment.BillLink.SupplierLink.ID, Supplier => Supplier.ID }
- };
- }
- public class SupplierBalance : IFormula<Supplier, double>
- {
- public Expression<Func<Supplier, double>> Value => x => x.TotalBills;
- public Expression<Func<Supplier, double>>[] Modifiers => new Expression<Func<Supplier, double>>[] { x => x.TotalPayments };
- public FormulaOperator Operator => FormulaOperator.Subtract;
- public FormulaType Type => FormulaType.Virtual;
- }
- [UserTracking(typeof(Bill))]
- public class Supplier : Entity, IPersistent, IRemotable, ILicense<CoreLicense>, IExportable, IImportable, IMergeable
- {
- [UniqueCodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
- [EditorSequence(1)]
- public string Code { get; set; }
- [TextBoxEditor]
- [EditorSequence(2)]
- public string Name { get; set; }
-
- [EditorSequence(3)]
- public String ABN { get; set; }
- [TextBoxEditor]
- [EditorSequence(4)]
- public string Email { get; set; } = "";
-
- [EditorSequence(5)]
- public StockLocationLink DefaultLocation { get; set; }
-
- [EditorSequence(6)]
- public SupplierCategoryLink Category { get; set; }
- [EditorSequence("Delivery",1)]
- public Address Delivery { get; set; }
-
- [EditorSequence("Accounts",2)]
- public Address Postal { get; set; }
- [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
- [Aggregate(typeof(SupplierOrderBalance))]
- public double OrderBalance { get; set; }
- [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
- [Aggregate(typeof(SupplierTotalBills))]
- public double TotalBills { get; set; }
- [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
- [Aggregate(typeof(SupplierTotalPayments))]
- public double TotalPayments { get; set; }
- [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
- [Formula(typeof(SupplierBalance))]
- public double Balance { get; set; }
-
- public override string ToString()
- {
- return string.Format("{0}: {1}", Code, Name);
- }
- }
- }
|