Exemplo n.º 1
0
        protected virtual ICreateMovementLine DoCreateReversalMovementLine(IMovementLineState movementLine)
        {
            var reversalLine = new CreateMovementLine();

            //reversalLine.Organization = Context.Organization;
            //reversalLine.UpdatedBy = Context.User;
            //reversalLine.UpdateTime = now;
            //reversalLine.CreatedBy = Context.User;
            //reversalLine.CreationTime = now;
            //reversalLine.Processed = movementLine.Processed;//???
            reversalLine.ReversalLineNumber     = movementLine.LineNumber;//设置反转行
            reversalLine.ProductId              = movementLine.ProductId;
            reversalLine.LocatorIdFrom          = movementLine.LocatorIdFrom;
            reversalLine.LocatorIdTo            = movementLine.LocatorIdTo;
            reversalLine.AttributeSetInstanceId = movementLine.AttributeSetInstanceId;
            //reversalLine.AttributeSetInstanceTo = movementLine.AttributeSetInstanceTo;

            reversalLine.LineNumber = movementLine.LineNumber;

            //数量反转
            reversalLine.MovementQuantity = -movementLine.MovementQuantity;
            //reversalLine.TargetQuantity = -movementLine.TargetQuantity;
            //reversalLine.ConfirmedQuantity = -movementLine.ConfirmedQuantity;
            //reversalLine.ScrappedQuantity = -movementLine.ScrappedQuantity;

            return(reversalLine);
        }
Exemplo n.º 2
0
        public static TRemoveMovementLine ToRemoveMovementLine <TRemoveMovementLine>(this IMovementLineState state)
            where TRemoveMovementLine : IRemoveMovementLine, new()
        {
            var cmd = new TRemoveMovementLine();

            cmd.LineNumber = state.LineNumber;
            return(cmd);
        }
Exemplo n.º 3
0
        public virtual void When(IMovementStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.DocumentStatusId = e.DocumentStatusId;

            this.MovementDate = (e.MovementDate != null && e.MovementDate.HasValue) ? e.MovementDate.Value : default(DateTime);

            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.DateReceived = (e.DateReceived != null && e.DateReceived.HasValue) ? e.DateReceived.Value : default(DateTime);

            this.DocumentTypeId = e.DocumentTypeId;

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

            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.ShipperId = e.ShipperId;

            this.SalesRepresentativeId = e.SalesRepresentativeId;

            this.BusinessPartnerId = e.BusinessPartnerId;

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

            this.CreateFrom = e.CreateFrom;

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

            this.ReversalDocumentNumber = e.ReversalDocumentNumber;

            this.WarehouseIdFrom = e.WarehouseIdFrom;

            this.WarehouseIdTo = e.WarehouseIdTo;

            this.Description = e.Description;

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

            this.Deleted = false;

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

            foreach (IMovementLineStateCreated innerEvent in e.MovementLineEvents)
            {
                IMovementLineState innerState = this.MovementLines.Get(innerEvent.GlobalId.LineNumber, true);
                innerState.Mutate(innerEvent);
            }
        }
Exemplo n.º 4
0
        public IMovementLineState Get(MovementLineId id, bool nullAllowed)
        {
            IMovementLineState state = CurrentSession.Get <MovementLineState>(id);

            if (!nullAllowed && state == null)
            {
                state = new MovementLineState();
                (state as MovementLineState).MovementLineId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IMovementLineState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
Exemplo n.º 5
0
        public void Delete(IMovementLineState state)
        {
            IMovementLineState s = state;

            if (ReadOnlyProxyGenerator != null)
            {
                s = ReadOnlyProxyGenerator.GetTarget <IMovementLineState>(state);
            }
            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Delete(s);
        }
Exemplo n.º 6
0
        public static TCreateMovementLine ToCreateMovementLine <TCreateMovementLine>(this IMovementLineState state)
            where TCreateMovementLine : ICreateMovementLine, new()
        {
            var cmd = new TCreateMovementLine();

            cmd.LineNumber             = state.LineNumber;
            cmd.MovementQuantity       = state.MovementQuantity;
            cmd.ProductId              = state.ProductId;
            cmd.LocatorIdFrom          = state.LocatorIdFrom;
            cmd.LocatorIdTo            = state.LocatorIdTo;
            cmd.AttributeSetInstanceId = state.AttributeSetInstanceId;
            cmd.Processed              = state.Processed;
            cmd.ReversalLineNumber     = state.ReversalLineNumber;
            cmd.Active = ((IMovementLineStateProperties)state).Active;
            cmd.MovementDocumentNumber = state.MovementDocumentNumber;
            return(cmd);
        }
Exemplo n.º 7
0
        public static IMovementLineCommand ToCreateOrMergePatchMovementLine <TCreateMovementLine, TMergePatchMovementLine>(this IMovementLineState state)
            where TCreateMovementLine : ICreateMovementLine, new()
            where TMergePatchMovementLine : IMergePatchMovementLine, new()
        {
            bool bUnsaved = ((IMovementLineState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateMovementLine <TCreateMovementLine>());
            }
            else
            {
                return(state.ToMergePatchMovementLine <TMergePatchMovementLine>());
            }
        }
Exemplo n.º 8
0
 public virtual void Remove(IMovementLineState state)
 {
     this._removedMovementLineStates.Add(state.GlobalId, state);
 }
Exemplo n.º 9
0
 public virtual void AddToSave(IMovementLineState state)
 {
     this._loadedMovementLineStates[state.GlobalId] = state;
 }
Exemplo n.º 10
0
 public MovementLineStateDtoWrapper(IMovementLineState state)
 {
     this._state = state;
 }
Exemplo n.º 11
0
 public MovementLineStateDtoWrapper()
 {
     this._state = new MovementLineState();
 }
Exemplo n.º 12
0
        internal static ICreateInventoryItemEntry[] ConfirmMovementCreateInventoryItemEntryPair(IMovementState movement, IMovementLineState movementLine, decimal confirmedQty,
                                                                                                Func <long> nextEntrySeqId)
        {
            if (!movement.IsInTransit)
            {
                throw new ArgumentException("Movement is NOT In-Transit.");
            }
            ICreateInventoryItemEntry[] trxPair = new ICreateInventoryItemEntry[2];

            /////////////////////// From: ////////////////////////////
            int signum    = -1;
            var locIdFrom = WarehouseUtils.GetInTransitLocatorId(movement.WarehouseIdFrom);

            trxPair[0] = CreateInventoryItemEntry(movement, movementLine, locIdFrom, confirmedQty * signum, 2, nextEntrySeqId, true);

            /////////////////////// To:   ////////////////////////////
            signum     = 1;
            trxPair[1] = CreateInventoryItemEntry(movement, movementLine, movementLine.LocatorIdTo, confirmedQty * signum, 3, nextEntrySeqId);

            return(trxPair);
        }
Exemplo n.º 13
0
        internal static ICreateInventoryItemEntry[] CompleteMovementCreateInventoryItemEntryPair(IMovementState movement, IMovementLineState movementLine,
                                                                                                 Func <long> nextEntrySeqId)
        {
            ICreateInventoryItemEntry[] trxPair = new ICreateInventoryItemEntry[2];

            var quantity = movementLine.MovementQuantity;
            /////////////////////// From: ////////////////////////////
            int signum = -1;

            trxPair[0] = CreateInventoryItemEntry(movement, movementLine, movementLine.LocatorIdFrom, quantity * signum, 0, nextEntrySeqId);

            /////////////////////// To:   ////////////////////////////
            signum = 1;
            if (!movement.IsInTransit)
            {
                trxPair[1] = CreateInventoryItemEntry(movement, movementLine, movementLine.LocatorIdTo, quantity * signum, 1, nextEntrySeqId);
            }
            else
            {
                var locId = WarehouseUtils.GetInTransitLocatorId(movement.WarehouseIdFrom);
                trxPair[1] = CreateInventoryItemEntry(movement, movementLine, locId, quantity * signum, 1, nextEntrySeqId, true);
            }

            return(trxPair);
        }
Exemplo n.º 14
0
        public virtual void When(IMovementStateMergePatched e)
        {
            ThrowOnWrongEvent(e);

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

            if (e.MovementDate == null)
            {
                if (e.IsPropertyMovementDateRemoved)
                {
                    this.MovementDate = default(DateTime);
                }
            }
            else
            {
                this.MovementDate = (e.MovementDate != null && e.MovementDate.HasValue) ? e.MovementDate.Value : default(DateTime);
            }

            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.DateReceived == null)
            {
                if (e.IsPropertyDateReceivedRemoved)
                {
                    this.DateReceived = default(DateTime);
                }
            }
            else
            {
                this.DateReceived = (e.DateReceived != null && e.DateReceived.HasValue) ? e.DateReceived.Value : default(DateTime);
            }

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

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

            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.ShipperId == null)
            {
                if (e.IsPropertyShipperIdRemoved)
                {
                    this.ShipperId = default(string);
                }
            }
            else
            {
                this.ShipperId = e.ShipperId;
            }

            if (e.SalesRepresentativeId == null)
            {
                if (e.IsPropertySalesRepresentativeIdRemoved)
                {
                    this.SalesRepresentativeId = default(string);
                }
            }
            else
            {
                this.SalesRepresentativeId = e.SalesRepresentativeId;
            }

            if (e.BusinessPartnerId == null)
            {
                if (e.IsPropertyBusinessPartnerIdRemoved)
                {
                    this.BusinessPartnerId = default(string);
                }
            }
            else
            {
                this.BusinessPartnerId = e.BusinessPartnerId;
            }

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

            if (e.CreateFrom == null)
            {
                if (e.IsPropertyCreateFromRemoved)
                {
                    this.CreateFrom = default(string);
                }
            }
            else
            {
                this.CreateFrom = e.CreateFrom;
            }

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

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

            if (e.WarehouseIdFrom == null)
            {
                if (e.IsPropertyWarehouseIdFromRemoved)
                {
                    this.WarehouseIdFrom = default(string);
                }
            }
            else
            {
                this.WarehouseIdFrom = e.WarehouseIdFrom;
            }

            if (e.WarehouseIdTo == null)
            {
                if (e.IsPropertyWarehouseIdToRemoved)
                {
                    this.WarehouseIdTo = default(string);
                }
            }
            else
            {
                this.WarehouseIdTo = e.WarehouseIdTo;
            }

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

            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 (IMovementLineEvent innerEvent in e.MovementLineEvents)
            {
                IMovementLineState innerState = this.MovementLines.Get(innerEvent.GlobalId.LineNumber);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IMovementLineStateRemoved;
                if (removed != null)
                {
                    this.MovementLines.Remove(innerState);
                }
            }
        }
Exemplo n.º 15
0
        public static TMergePatchMovementLine ToMergePatchMovementLine <TMergePatchMovementLine>(this IMovementLineState state)
            where TMergePatchMovementLine : IMergePatchMovementLine, new()
        {
            var cmd = new TMergePatchMovementLine();

            cmd.LineNumber             = state.LineNumber;
            cmd.MovementQuantity       = state.MovementQuantity;
            cmd.ProductId              = state.ProductId;
            cmd.LocatorIdFrom          = state.LocatorIdFrom;
            cmd.LocatorIdTo            = state.LocatorIdTo;
            cmd.AttributeSetInstanceId = state.AttributeSetInstanceId;
            cmd.Processed              = state.Processed;
            cmd.ReversalLineNumber     = state.ReversalLineNumber;
            cmd.Active = ((IMovementLineStateProperties)state).Active;
            cmd.MovementDocumentNumber = state.MovementDocumentNumber;

            if (state.ProductId == null)
            {
                cmd.IsPropertyProductIdRemoved = true;
            }
            if (state.LocatorIdFrom == null)
            {
                cmd.IsPropertyLocatorIdFromRemoved = true;
            }
            if (state.LocatorIdTo == null)
            {
                cmd.IsPropertyLocatorIdToRemoved = true;
            }
            if (state.AttributeSetInstanceId == null)
            {
                cmd.IsPropertyAttributeSetInstanceIdRemoved = true;
            }
            if (state.ReversalLineNumber == null)
            {
                cmd.IsPropertyReversalLineNumberRemoved = true;
            }
            return(cmd);
        }
Exemplo n.º 16
0
        internal static ICreateInventoryItemEntry CreateInventoryItemEntry(IMovementState movement, IMovementLineState movementLine, string locatorId, decimal quantity, int lineSubSeqId,
                                                                           Func <long> nextEntrySeqId, bool usingInTransitQty = false)
        {
            var entry     = new CreateInventoryItemEntry();
            var invItemId = new InventoryItemId(movementLine.ProductId, locatorId, movementLine.AttributeSetInstanceId);

            entry.InventoryItemId = invItemId;
            entry.EntrySeqId      = nextEntrySeqId();
            if (!usingInTransitQty)
            {
                entry.OnHandQuantity = quantity;
            }
            else
            {
                entry.InTransitQuantity = quantity;
            }
            entry.Source = new InventoryItemSourceInfo(DocumentTypeIds.Movement, movement.DocumentNumber, movementLine.LineNumber, lineSubSeqId);
            return(entry);
        }
Exemplo n.º 17
0
 public void AddToSave(IMovementLineState state)
 {
     throw new NotSupportedException();
 }