예제 #1
0
        protected virtual ScanLine FindLine(ScanHeader header, Func <ScanLine, bool> search)
        {
            var existLines = LinesView.SelectMain().Where(t =>
                                                          t.InventoryID == header.InventoryID &&
                                                          t.SiteID == header.SiteID &&
                                                          t.ToSiteID == header.ToSiteID
                                                          //&& t.LocationID == (header.LocationID ?? t.LocationID)
                                                          && t.ReasonCode == (header.ReasonCode ?? t.ReasonCode) &&
                                                          t.UOM == header.UOM &&
                                                          (search == null || search(t)));

            ScanLine existLine = null;

            if (IsLotSerialRequired && SplitsView != null)
            {
                foreach (var line in existLines)
                {
                    LinesView.Current = line;
                    if (SplitsView.SelectMain().Any(t => (t.LotSerialNbr ?? "") == (header.LotSerialNbr ?? "")))
                    {
                        existLine = line;
                        break;
                    }
                }
            }
            else
            {
                existLine = existLines.FirstOrDefault();
            }
            return(existLine);
        }
        protected override void SyncWithDocumentCart(ScanHeader header, ScanLine line, INCartSplit cartSplit, decimal?qty)
        {
            INRegisterCart registerCart = RegisterCart.Current;

            if (registerCart == null)
            {
                registerCart = RegisterCart.Insert();
            }

            RegisterCart.Cache.SetValue <INRegisterCart.docType>(registerCart, Register.DocType);
            RegisterCart.Cache.SetValue <INRegisterCart.refNbr>(registerCart, Register.RefNbr);

            SyncWithDocumentCartLine(header, line, cartSplit, qty);

            if (IsEmptyCart)
            {
                RegisterCart.Delete(registerCart);
            }
        }
예제 #3
0
        protected virtual void ConfirmCartIn()
        {
            WMSFlowStatus Implementation()
            {
                WMSFlowStatus status;

                if (!ValidateConfirmation(out status))
                {
                    return(status);
                }

                ScanHeader header        = CurrentHeader;
                bool       isSerialItem  = header.LotSerTrack == INLotSerTrack.SerialNumbered;
                var        userLotSerial = header.LotSerialNbr;

                TScanDocument doc       = SyncWithDocument(header);
                ScanLine      existLine = FindFixedLineFromCart(header);

                if (!SyncWithLines(header, header.Qty, ref existLine, out status))
                {
                    return(status);
                }

                INCartSplit cartSplit = SyncWithCart(header, header.Qty);

                SyncWithDocumentCart(header, existLine, cartSplit, header.Qty);

                Report(Msg.InventoryAdded, LinesView.Cache.GetValueExt <ScanLine.inventoryID>(existLine), header.Qty, header.UOM);

                OnCartInConfirmed();

                return(WMSFlowStatus.Ok.WithPostAction(() => SetQtyOverridable(!isSerialItem)));
            }

            using (var ts = new PXTransactionScope())
            {
                var res = ExecuteAndCompleteFlow(Implementation);
                if (res.IsError == false)
                {
                    ts.Complete();
                }
            }
        }
        protected virtual void SyncWithDocumentCartLine(ScanHeader header, ScanLine line, INCartSplit cartSplit, decimal?qty)
        {
            bool emptyLine = line.Qty.GetValueOrDefault() == 0;

            INRegisterCartLine docCartLine = RegisterCartLines.Search <INRegisterCartLine.lineNbr>(line.LineNbr);

            if (docCartLine == null)
            {
                if (qty <= 0)
                {
                    throw new PXArgumentException(nameof(qty));
                }
                docCartLine = RegisterCartLines.Insert();
                RegisterCartLines.Cache.SetValue <INRegisterCartLine.cartSplitLineNbr>(docCartLine, cartSplit.SplitLineNbr);
            }
            docCartLine      = (INRegisterCartLine)RegisterCartLines.Cache.CreateCopy(docCartLine);
            docCartLine.Qty += qty;
            RegisterCartLines.Cache.Update(docCartLine);

            if (docCartLine.Qty == 0)
            {
                RegisterCartLines.Delete(docCartLine);
            }
        }
예제 #5
0
        protected virtual void MoveToCart()
        {
            WMSFlowStatus Implementation()
            {
                WMSFlowStatus status;

                if (!ValidateConfirmation(out status))
                {
                    return(status);
                }

                ScanHeader header       = CurrentHeader;
                bool       isSerialItem = header.LotSerTrack == INLotSerTrack.SerialNumbered;
                decimal?   confirmQty   = header.Qty;

                ScanLine existLine = FindLineFromDocument(header);

                if (existLine == null)
                {
                    return(LineMissingStatus());
                }

                if (!SyncWithLines(CurrentHeader, -confirmQty, ref existLine, out status))
                {
                    return(status);
                }

                HeaderSetter.Set(x => x.LocationID, existLine.LocationID);
                HeaderSetter.Set(x => x.ToLocationID, existLine.LocationID);
                HeaderSetter.Set(x => x.SiteID, existLine.SiteID);
                HeaderSetter.Set(x => x.LotSerialNbr, existLine.LotSerialNbr);
                HeaderSetter.Set(x => x.ReasonCode, existLine.ReasonCode);
                HeaderSetter.Set(x => x.ExpireDate, existLine.ExpireDate);
                HeaderSetter.Set(x => x.SubItemID, existLine.SubItemID);

                //put item to the cart
                existLine = FindFixedLineFromCart(CurrentHeader);
                if (!SyncWithLines(CurrentHeader, confirmQty, ref existLine, out status))
                {
                    return(status);
                }

                INCartSplit cartSplit = SyncWithCart(CurrentHeader, confirmQty);

                SyncWithDocumentCart(CurrentHeader, existLine, cartSplit, confirmQty);

                Report(Msg.InventoryRemoved, LinesView.Cache.GetValueExt <ScanLine.inventoryID>(existLine), confirmQty);

                OnMovedToCart();

                return(WMSFlowStatus.Ok.WithPostAction(() => SetQtyOverridable(!isSerialItem)));
            };
            using (var ts = new PXTransactionScope())
            {
                var res = ExecuteAndCompleteFlow(Implementation);
                if (res.IsError == false)
                {
                    ts.Complete();
                }
            }
        }
예제 #6
0
        protected virtual bool SyncWithLines(ScanHeader header, decimal?qty, ref ScanLine line, out WMSFlowStatus flowStatus)
        {
            var      linesCache     = LinesView.Cache;
            Action   rollbackAction = null;
            ScanLine existLine      = line;

            if (existLine != null)
            {
                decimal?newQty = existLine.Qty + qty;

                var backup = linesCache.CreateCopy(existLine) as ScanLine;
                if (newQty == 0)
                {
                    //remove
                    linesCache.SetValueExt <ScanLine.qty>(existLine, newQty);
                    existLine      = (ScanLine)linesCache.Delete(existLine);
                    rollbackAction = () =>
                    {
                        linesCache.Insert(backup);
                    };
                }
                else
                {
                    if (CurrentHeader.LotSerTrack == INLotSerTrack.SerialNumbered && newQty != 1)
                    {
                        flowStatus = WMSFlowStatus.Fail(Msg.SerialItemNotComplexQty);
                        return(false);
                    }

                    linesCache.SetValueExt <ScanLine.qty>(existLine, newQty);
                    linesCache.SetValueExt <ScanLine.lotSerialNbr>(existLine, null);
                    existLine = (ScanLine)linesCache.Update(existLine);

                    linesCache.SetValueExt <INTran.lotSerialNbr>(existLine, header.LotSerialNbr);
                    existLine = (ScanLine)linesCache.Update(existLine);

                    rollbackAction = () =>
                    {
                        linesCache.Delete(existLine);
                        linesCache.Insert(backup);
                    };
                }
            }
            else
            {
                if (qty < 0)
                {
                    flowStatus = LineMissingStatus();
                    return(false);
                }
                existLine = (ScanLine)linesCache.Insert();
                linesCache.SetValueExt <ScanLine.inventoryID>(existLine, header.InventoryID);
                linesCache.SetValueExt <ScanLine.siteID>(existLine, header.SiteID);
                linesCache.SetValueExt <ScanLine.toSiteID>(existLine, header.ToSiteID);
                linesCache.SetValueExt <ScanLine.locationID>(existLine, header.LocationID);
                linesCache.SetValueExt <ScanLine.toLocationID>(existLine, header.ToLocationID);
                linesCache.SetValueExt <ScanLine.uOM>(existLine, header.UOM);
                linesCache.SetValueExt <ScanLine.reasonCode>(existLine, header.ReasonCode);
                existLine = (ScanLine)linesCache.Update(existLine);

                linesCache.SetValueExt <INTran.qty>(existLine, qty);
                existLine = (ScanLine)linesCache.Update(existLine);

                linesCache.SetValueExt <INTran.lotSerialNbr>(existLine, header.LotSerialNbr);
                existLine = (ScanLine)linesCache.Update(existLine);

                rollbackAction = () => linesCache.Delete(existLine);
            }

            if (!VerifyConfirmedLine(header, existLine, rollbackAction, out flowStatus))
            {
                return(false);
            }

            flowStatus = WMSFlowStatus.Ok;
            line       = existLine;
            return(true);
        }
예제 #7
0
 protected virtual bool VerifyConfirmedLine(ScanHeader header, ScanLine line, Action rollbackAction, out WMSFlowStatus flowStatus)
 => EnsureSplitsLotSerial(header.LotSerialNbr, header, rollbackAction, out flowStatus) &&
 (header.Remove == true || EnsureSplitsLocation(header.LocationID, header, rollbackAction, out flowStatus));
예제 #8
0
 protected decimal?GetCartQty(ScanLine line) => GetCartQty(LinesView.Cache.GetMain(line) as TScanLine);
예제 #9
0
 protected virtual void SyncWithDocumentCart(ScanHeader header, ScanLine line, INCartSplit cartSplit, decimal?qty)
 => SyncWithDocumentCart(HeaderView.Cache.GetMain(header) as TWMSHeader, LinesView.Cache.GetMain(line) as TScanLine, cartSplit, qty);