| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 | using System;using InABox.Core;namespace Comal.Classes{    public class BillLineLink : EntityLink<BillLine>    {        [NullEditor]        public override Guid ID { get; set; }    }    [UserTracking(typeof(Bill))]    public class BillLine : Entity, IPersistent, IRemotable, IOneToMany<Bill>, ITaxable, ILicense<AccountsPayableLicense>, IPostableFragment<Bill>    {        [EntityRelationship(DeleteAction.Cascade)]        [NullEditor]        public BillLink BillLink { get; set; }        [EntityRelationship(DeleteAction.SetNull)]        [EditorSequence(1)]        public PurchaseOrderItemLink OrderItem { get; set; }        [EditorSequence(2)]        public ProductLink Product { get; set; }        [MemoEditor]        [EditorSequence(2)]        public string Description { get; set; }                [EditorSequence(3)]        public PurchaseGLCodeLink PurchaseGL { get; set; }                [EditorSequence(4)]        public CostCentreLink CostCentre { get; set; }        [CurrencyEditor(Summary = Summary.Sum)]        [EditorSequence(5)]        public double ExTax { get; set; }        [RequiredColumn]        [EditorSequence(6)]        public TaxCodeLink TaxCode { get; set; }        [DoubleEditor(Editable = Editable.Hidden)]        public double TaxRate { get; set; }        [CurrencyEditor(Summary = Summary.Sum)]        public double Tax { get; set; }        [CurrencyEditor(Summary = Summary.Sum)]        [EditorSequence(7)]        public double IncTax { get; set; }        [EditorSequence(8)]        public JobLink Job { get; set; }        [NullEditor]        public string PostedReference { get; set; }        static BillLine()        {                        LinkedProperties.Register<BillLine, PurchaseOrderItemLink, double>(x => x.OrderItem, x => x.ExTax,                x => x.ExTax);            LinkedProperties.Register<BillLine, PurchaseGLCodeLink, Guid>(x => x.OrderItem.PurchaseGL, x => x.ID,                x => x.PurchaseGL.ID);                        LinkedProperties.Register<BillLine, CostCentreLink, Guid>(x => x.OrderItem.CostCentre, x => x.ID,                x => x.CostCentre.ID);                        LinkedProperties.Register<BillLine, TaxCodeLink, Guid>(x => x.OrderItem.TaxCode, x => x.ID,                x => x.TaxCode.ID);                        LinkedProperties.Register<BillLine, TaxCodeLink, String>(x => x.OrderItem.TaxCode, x => x.Code,                x => x.TaxCode.Code);                        LinkedProperties.Register<BillLine, TaxCodeLink, String>(x => x.OrderItem.TaxCode, x => x.Description,                x => x.TaxCode.Description);                        LinkedProperties.Register<BillLine, TaxCodeLink, double>(x => x.OrderItem.TaxCode, x => x.Rate,                x => x.TaxCode.Rate);                                    LinkedProperties.Register<BillLine, PurchaseOrderItemLink, double>(x => x.OrderItem, x => x.Tax,                x => x.Tax);                        LinkedProperties.Register<BillLine, PurchaseOrderItemLink, double>(x => x.OrderItem, x => x.IncTax,                x => x.IncTax);            LinkedProperties.Register<BillLine, TaxCodeLink, double>(x => x.TaxCode, x => x.Rate, x => x.TaxRate);            LinkedProperties.Register<BillLine, PurchaseGLCodeLink, Guid>(x => x.Product.PurchaseGL, x => x.ID, x => x.PurchaseGL.ID);            LinkedProperties.Register<BillLine, CostCentreLink, Guid>(x => x.Product.CostCentre, x => x.ID, x => x.CostCentre.ID);            LinkedProperties.Register<BillLine, TaxCodeLink, Guid>(x => x.Product.TaxCode, x => x.ID, x => x.TaxCode.ID);            LinkedProperties.Register<BillLine, TaxCodeLink, string>(x => x.Product.TaxCode, x => x.Code, x => x.TaxCode.Code);            LinkedProperties.Register<BillLine, TaxCodeLink, string>(x => x.Product.TaxCode, x => x.Description, x => x.TaxCode.Description);            LinkedProperties.Register<BillLine, TaxCodeLink, double>(x => x.Product.TaxCode, x => x.Rate, x => x.TaxCode.Rate);        }        private static readonly Column<BillLine> OrderItemColumn = new Column<BillLine>(x => x.OrderItem.ID);        private static readonly Column<BillLine> ProductColumn = new Column<BillLine>(x => x.Product.ID);        private static readonly Column<BillLine> JobColumn = new Column<BillLine>(x => x.Job.ID);        protected override void DoPropertyChanged(string name, object? before, object? after)        {            base.DoPropertyChanged(name, before, after);            if (OrderItemColumn.IsEqualTo(name) && after is Guid orderItemID && orderItemID != Guid.Empty)            {                Product.ID = Guid.Empty;                Product.Clear();                Job.ID = Guid.Empty;                Job.Clear();            }            else if((ProductColumn.IsEqualTo(name) && after is Guid productID && productID != Guid.Empty)                || (JobColumn.IsEqualTo(name) && after is Guid jobID && jobID != Guid.Empty))            {                OrderItem.ID = Guid.Empty;                OrderItem.Clear();            }        }    }}
 |