123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq.Expressions;
- using InABox.Core;
- namespace Comal.Classes
- {
- public class QuoteExTax : CoreAggregate<Quote, QuoteProposal, double>
- {
- public override Expression<Func<QuoteProposal, double>> Aggregate => x => x.ProposalExTax;
- public override AggregateCalculation Calculation => AggregateCalculation.Sum;
- public override Dictionary<Expression<Func<QuoteProposal, object>>, Expression<Func<Quote, object>>> Links =>
- new Dictionary<Expression<Func<QuoteProposal, object>>, Expression<Func<Quote, object>>> ()
- {
- { QuoteProposal => QuoteProposal.Quote.ID, Quote => Quote.ID }
- };
- public override Filter<QuoteProposal> Filter => new Filter<QuoteProposal>(x => x.Default).IsEqualTo(true);
- }
- public class QuoteTax : CoreAggregate<Quote, QuoteProposal, double>
- {
- public override Expression<Func<QuoteProposal, double>> Aggregate => x => x.ProposalTax;
- public override AggregateCalculation Calculation => AggregateCalculation.Sum;
- public override Dictionary<Expression<Func<QuoteProposal, object>>, Expression<Func<Quote, object>>> Links =>
- new Dictionary<Expression<Func<QuoteProposal, object>>, Expression<Func<Quote, object>>>()
- {
- { QuoteProposal => QuoteProposal.Quote.ID, Quote => Quote.ID }
- };
- public override Filter<QuoteProposal> Filter => new Filter<QuoteProposal>(x => x.Default).IsEqualTo(true);
- }
- public class QuoteIncTax : CoreAggregate<Quote, QuoteProposal, double>
- {
- public override Expression<Func<QuoteProposal, double>> Aggregate => x => x.ProposalIncTax;
- public override AggregateCalculation Calculation => AggregateCalculation.Sum;
- public override Dictionary<Expression<Func<QuoteProposal, object>>, Expression<Func<Quote, object>>> Links =>
- new Dictionary<Expression<Func<QuoteProposal, object>>, Expression<Func<Quote, object>>>()
- {
- { QuoteProposal => QuoteProposal.Quote.ID, Quote => Quote.ID }
- };
- public override Filter<QuoteProposal> Filter => new Filter<QuoteProposal>(x => x.Default).IsEqualTo(true);
- }
- [UserTracking("Quote Management")]
- public class Quote : Entity, IRemotable, IPersistent, IStringAutoIncrement<Quote>, ILicense<QuotesManagementLicense>, IScannable
- {
- [UniqueCodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
- [EditorSequence(0)]
- public string Number { get; set; }
- [TextBoxEditor]
- [EditorSequence(1)]
- public string Title { get; set; }
- [EditorSequence(2)]
- public CustomerLink Customer { get; set; }
- [EditorSequence(3)]
- public ContactLink Contact { get; set; }
- [EditorSequence(4)]
- public Address SiteAddress { get; set; }
- [EditorSequence(5)]
- public AccountLink Account { get; set; }
-
- [DoubleEditor(Editable = Editable.Hidden)]
- [EditorSequence(6)]
- [Aggregate(typeof(QuoteExTax))]
- public double ExTax { get; set; }
- [DoubleEditor(Editable = Editable.Hidden)]
- [EditorSequence(7)]
- [Aggregate(typeof(QuoteTax))]
- public double Tax { get; set; }
- [DoubleEditor(Editable = Editable.Hidden)]
- [EditorSequence(8)]
- [Aggregate(typeof(QuoteIncTax))]
- public double IncTax { get; set; }
- [EditorSequence(9)]
- public QuoteStatusLink Status { get; set; }
- #region Management
- [DateEditor]
- [EditorSequence("Management", 1)]
- public DateTime ReceivedDate { get; set; }
- [DateEditor]
- [EditorSequence("Management", 2)]
- public DateTime DueDate { get; set; }
- [DateEditor]
- [EditorSequence("Management", 3)]
- public DateTime QuoteDate { get; set; }
- [DateEditor]
- [EditorSequence("Management", 4)]
- public DateTime ArchivedDate { get; set; }
- [EditorSequence("Management", 5)]
- public EmployeeLink Salesperson { get; set; }
- #endregion
- #region Notes
- [NotesEditor]
- [EditorSequence("Notes", 1)]
- public string[] Notes { get; set; }
- #endregion
- public Expression<Func<Quote, string>> AutoIncrementField()
- {
- return x => x.Number;
- }
- public Filter<Quote> AutoIncrementFilter()
- {
- return null;
- }
- public string AutoIncrementFormat()
- {
- return "{0:D6}";
- }
- protected override void Init()
- {
- base.Init();
- Status = new QuoteStatusLink();
- Customer = new CustomerLink();
- Contact = new ContactLink();
- Account = new AccountLink();
- SiteAddress = new Address();
- Salesperson = new EmployeeLink();
- Customer.Account.PropertyChanged += Account_PropertyChanged;
- Customer.Delivery.PropertyChanged += Delivery_PropertyChanged;
- }
- private void Delivery_PropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- var value = CoreUtils.GetPropertyValue(Customer.Delivery, e.PropertyName);
- CoreUtils.SetPropertyValue(SiteAddress, e.PropertyName, value);
- }
- private void Account_PropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName.Equals("ID"))
- Account.ID = Customer.Account.ID;
- else if (e.PropertyName.Equals("Code"))
- Account.Code = Customer.Account.Code;
- else if (e.PropertyName.Equals("Name"))
- Account.Name = Customer.Account.Name;
- }
- }
- }
|