123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- 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, IPostable,
- IPostableFragment<Bill>, IPostableFragment<PurchaseOrder>
- {
- [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; } = "";
- [TextBoxEditor]
- [EditorSequence(5)]
- public string Telephone { get; set; } = "";
-
- [EditorSequence(6)]
- public SupplierStockLocationLink DefaultLocation { get; set; }
-
- [EditorSequence(7)]
- public SupplierCategoryLink Category { get; set; }
- [EditorSequence(8)]
- public SupplierStatusLink SupplierStatus { get; set; }
- [EditorSequence("Delivery",1)]
- public Address Delivery { get; set; }
-
- [EditorSequence("Accounts",2)]
- public Address Postal { get; set; }
-
- [EditorSequence("Accounts",3)]
- public ForeignCurrencyLink Currency { get; set; }
-
- [EditorSequence("Accounts", 4)]
- [LookupDefinition(typeof(AccountsPayablePaymentTermsLookup<Supplier>))]
- public PaymentTermsLink Terms { get; set; }
-
- [EditorSequence("Accounts", 5)]
- [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
- [Aggregate(typeof(SupplierOrderBalance))]
- public double OrderBalance { get; set; }
- [EditorSequence("Accounts", 6)]
- [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
- [Aggregate(typeof(SupplierTotalBills))]
- public double TotalBills { get; set; }
- [EditorSequence("Accounts", 7)]
- [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
- [Aggregate(typeof(SupplierTotalPayments))]
- public double TotalPayments { get; set; }
- [EditorSequence("Accounts", 8)]
- [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
- [Formula(typeof(SupplierBalance))]
- public double Balance { get; set; }
- [NullEditor]
- public DateTime Posted { get; set; }
- [NullEditor]
- [RequiredColumn]
- public PostedStatus PostedStatus { get; set; }
- [NullEditor]
- public string PostedNote { get; set; }
- [NullEditor]
- public string PostedReference { get; set; }
- public override string ToString()
- {
- return string.Format("{0}: {1}", Code, Name);
- }
-
- }
- }
|