Exemplo n.º 1
0
        public virtual void When(IPhysicalInventoryStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.DocumentStatusId = e.DocumentStatusId;

            this.WarehouseId = e.WarehouseId;

            this.LocatorIdPattern = e.LocatorIdPattern;

            this.ProductIdPattern = e.ProductIdPattern;

            this.Posted = (e.Posted != null && e.Posted.HasValue) ? e.Posted.Value : default(bool);

            this.Processed = (e.Processed != null && e.Processed.HasValue) ? e.Processed.Value : default(bool);

            this.Processing = e.Processing;

            this.DocumentTypeId = e.DocumentTypeId;

            this.MovementDate = e.MovementDate;

            this.Description = e.Description;

            this.IsApproved = (e.IsApproved != null && e.IsApproved.HasValue) ? e.IsApproved.Value : default(bool);

            this.ApprovalAmount = (e.ApprovalAmount != null && e.ApprovalAmount.HasValue) ? e.ApprovalAmount.Value : default(decimal);

            this.IsQuantityUpdated = (e.IsQuantityUpdated != null && e.IsQuantityUpdated.HasValue) ? e.IsQuantityUpdated.Value : default(bool);

            this.ReversalDocumentNumber = e.ReversalDocumentNumber;

            this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;

            foreach (IPhysicalInventoryLineStateCreated innerEvent in e.PhysicalInventoryLineEvents)
            {
                IPhysicalInventoryLineState innerState = this.PhysicalInventoryLines.Get(innerEvent.GlobalId.InventoryItemId, true);
                innerState.Mutate(innerEvent);
            }
        }
Exemplo n.º 2
0
        public virtual void When(IPhysicalInventoryStateMergePatched e)
        {
            ThrowOnWrongEvent(e);

            if (e.DocumentStatusId == null)
            {
                if (e.IsPropertyDocumentStatusIdRemoved)
                {
                    this.DocumentStatusId = default(string);
                }
            }
            else
            {
                this.DocumentStatusId = e.DocumentStatusId;
            }

            if (e.WarehouseId == null)
            {
                if (e.IsPropertyWarehouseIdRemoved)
                {
                    this.WarehouseId = default(string);
                }
            }
            else
            {
                this.WarehouseId = e.WarehouseId;
            }

            if (e.LocatorIdPattern == null)
            {
                if (e.IsPropertyLocatorIdPatternRemoved)
                {
                    this.LocatorIdPattern = default(string);
                }
            }
            else
            {
                this.LocatorIdPattern = e.LocatorIdPattern;
            }

            if (e.ProductIdPattern == null)
            {
                if (e.IsPropertyProductIdPatternRemoved)
                {
                    this.ProductIdPattern = default(string);
                }
            }
            else
            {
                this.ProductIdPattern = e.ProductIdPattern;
            }

            if (e.Posted == null)
            {
                if (e.IsPropertyPostedRemoved)
                {
                    this.Posted = default(bool);
                }
            }
            else
            {
                this.Posted = (e.Posted != null && e.Posted.HasValue) ? e.Posted.Value : default(bool);
            }

            if (e.Processed == null)
            {
                if (e.IsPropertyProcessedRemoved)
                {
                    this.Processed = default(bool);
                }
            }
            else
            {
                this.Processed = (e.Processed != null && e.Processed.HasValue) ? e.Processed.Value : default(bool);
            }

            if (e.Processing == null)
            {
                if (e.IsPropertyProcessingRemoved)
                {
                    this.Processing = default(string);
                }
            }
            else
            {
                this.Processing = e.Processing;
            }

            if (e.DocumentTypeId == null)
            {
                if (e.IsPropertyDocumentTypeIdRemoved)
                {
                    this.DocumentTypeId = default(string);
                }
            }
            else
            {
                this.DocumentTypeId = e.DocumentTypeId;
            }

            if (e.MovementDate == null)
            {
                if (e.IsPropertyMovementDateRemoved)
                {
                    this.MovementDate = default(DateTime?);
                }
            }
            else
            {
                this.MovementDate = e.MovementDate;
            }

            if (e.Description == null)
            {
                if (e.IsPropertyDescriptionRemoved)
                {
                    this.Description = default(string);
                }
            }
            else
            {
                this.Description = e.Description;
            }

            if (e.IsApproved == null)
            {
                if (e.IsPropertyIsApprovedRemoved)
                {
                    this.IsApproved = default(bool);
                }
            }
            else
            {
                this.IsApproved = (e.IsApproved != null && e.IsApproved.HasValue) ? e.IsApproved.Value : default(bool);
            }

            if (e.ApprovalAmount == null)
            {
                if (e.IsPropertyApprovalAmountRemoved)
                {
                    this.ApprovalAmount = default(decimal);
                }
            }
            else
            {
                this.ApprovalAmount = (e.ApprovalAmount != null && e.ApprovalAmount.HasValue) ? e.ApprovalAmount.Value : default(decimal);
            }

            if (e.IsQuantityUpdated == null)
            {
                if (e.IsPropertyIsQuantityUpdatedRemoved)
                {
                    this.IsQuantityUpdated = default(bool);
                }
            }
            else
            {
                this.IsQuantityUpdated = (e.IsQuantityUpdated != null && e.IsQuantityUpdated.HasValue) ? e.IsQuantityUpdated.Value : default(bool);
            }

            if (e.ReversalDocumentNumber == null)
            {
                if (e.IsPropertyReversalDocumentNumberRemoved)
                {
                    this.ReversalDocumentNumber = default(string);
                }
            }
            else
            {
                this.ReversalDocumentNumber = e.ReversalDocumentNumber;
            }

            if (e.Active == null)
            {
                if (e.IsPropertyActiveRemoved)
                {
                    this.Active = default(bool);
                }
            }
            else
            {
                this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);
            }


            this.UpdatedBy = e.CreatedBy;
            this.UpdatedAt = e.CreatedAt;


            foreach (IPhysicalInventoryLineEvent innerEvent in e.PhysicalInventoryLineEvents)
            {
                IPhysicalInventoryLineState innerState = this.PhysicalInventoryLines.Get(innerEvent.GlobalId.InventoryItemId);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IPhysicalInventoryLineStateRemoved;
                if (removed != null)
                {
                    this.PhysicalInventoryLines.Remove(innerState);
                }
            }
        }