Ejemplo n.º 1
0
        public override PXSelectBase <INLotSerialStatus> GetSerialStatusCmd(PXCache sender, ARTran row, PXResult <InventoryItem, INLotSerClass> item)
        {
            PXSelectBase <INLotSerialStatus> cmd = new PXSelectJoin <INLotSerialStatus, InnerJoin <INLocation, On <INLocation.locationID, Equal <INLotSerialStatus.locationID> >,
                                                                                                   InnerJoin <INSiteLotSerial, On <INSiteLotSerial.inventoryID, Equal <INLotSerialStatus.inventoryID>,
                                                                                                                                   And <INSiteLotSerial.siteID, Equal <INLotSerialStatus.siteID>, And <INSiteLotSerial.lotSerialNbr, Equal <INLotSerialStatus.lotSerialNbr> > > > > >,
                                                                     Where <INLotSerialStatus.inventoryID, Equal <Current <INLotSerialStatus.inventoryID> >,
                                                                            And <INLotSerialStatus.siteID, Equal <Current <INLotSerialStatus.siteID> >,
                                                                                 And <INLotSerialStatus.qtyOnHand, Greater <decimal0>,
                                                                                      And <INSiteLotSerial.qtyHardAvail, Greater <decimal0> > > > > >(sender.Graph);

            if (row.SubItemID != null)
            {
                cmd.WhereAnd <Where <INLotSerialStatus.subItemID, Equal <Current <INLotSerialStatus.subItemID> > > >();
            }
            if (row.LocationID != null)
            {
                cmd.WhereAnd <Where <INLotSerialStatus.locationID, Equal <Current <INLotSerialStatus.locationID> > > >();
            }
            else
            {
                cmd.WhereAnd <Where <INLocation.salesValid, Equal <boolTrue> > >();
            }
            if (string.IsNullOrEmpty(row.LotSerialNbr) == false)
            {
                cmd.WhereAnd <Where <INLotSerialStatus.lotSerialNbr, Equal <Current <INLotSerialStatus.lotSerialNbr> > > >();
            }

            switch (((INLotSerClass)item).LotSerIssueMethod)
            {
            case INLotSerIssueMethod.FIFO:
                cmd.OrderByNew <OrderBy <Asc <INLocation.pickPriority, Asc <INLotSerialStatus.receiptDate, Asc <INLotSerialStatus.lotSerialNbr> > > > >();
                break;

            case INLotSerIssueMethod.LIFO:
                cmd.OrderByNew <OrderBy <Asc <INLocation.pickPriority, Desc <INLotSerialStatus.receiptDate, Asc <INLotSerialStatus.lotSerialNbr> > > > >();
                break;

            case INLotSerIssueMethod.Expiration:
                cmd.OrderByNew <OrderBy <Asc <INLocation.pickPriority, Asc <INLotSerialStatus.expireDate, Asc <INLotSerialStatus.lotSerialNbr> > > > >();
                break;

            case INLotSerIssueMethod.Sequential:
                cmd.OrderByNew <OrderBy <Asc <INLocation.pickPriority, Asc <INLotSerialStatus.lotSerialNbr> > > >();
                break;

            case INLotSerIssueMethod.UserEnterable:
                if (string.IsNullOrEmpty(row.LotSerialNbr))
                {
                    cmd.WhereAnd <Where <boolTrue, Equal <boolFalse> > >();
                }
                break;

            default:
                throw new PXException();
            }

            return(cmd);
        }