Exemple #1
0
        protected virtual void INTran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if (e.Operation.Command() == PXDBOperation.Delete)
            {
                return;
            }

            INTran row = (INTran)e.Row;

            InventoryItem item      = (InventoryItem)PXSelectorAttribute.Select <INTran.inventoryID>(sender, row);
            INLotSerClass itemclass =
                (INLotSerClass)PXSelectorAttribute.Select <InventoryItem.lotSerClassID>(this.Caches[typeof(InventoryItem)], item);

            PXPersistingCheck check =
                ((INTran)e.Row).InvtMult != 0 && (
                    (item != null && item.ValMethod == INValMethod.Specific) ||
                    (itemclass != null &&
                     itemclass.LotSerTrack != INLotSerTrack.NotNumbered &&
                     itemclass.LotSerAssign == INLotSerAssign.WhenReceived &&
                     ((INTran)e.Row).Qty != 0m))
                                 ? PXPersistingCheck.NullOrBlank
                                 : PXPersistingCheck.Nothing;


            PXDefaultAttribute.SetPersistingCheck <INTran.subID>(sender, e.Row, PXPersistingCheck.Null);
            PXDefaultAttribute.SetPersistingCheck <INTran.locationID>(sender, e.Row, PXPersistingCheck.Null);
            PXDefaultAttribute.SetPersistingCheck <INTran.lotSerialNbr>(sender, e.Row, check);

            if (adjustment.Current != null && adjustment.Current.OrigModule != INRegister.origModule.PI && item != null && item.ValMethod == INValMethod.FIFO && ((INTran)e.Row).OrigRefNbr == null)
            {
                bool dropShipPO = false;
                if (row != null && row.POReceiptNbr != null && row.POReceiptLineNbr != null)
                {
                    PO.POReceiptLine pOReceiptLine = PXSelect <PO.POReceiptLine, Where <PO.POReceiptLine.receiptNbr, Equal <Required <PO.POReceiptLine.receiptNbr> >, And <PO.POReceiptLine.lineNbr, Equal <Required <PO.POReceiptLine.lineNbr> > > > > .Select(this, row.POReceiptNbr, row.POReceiptLineNbr);

                    dropShipPO = pOReceiptLine != null && (pOReceiptLine.LineType == PO.POLineType.GoodsForDropShip || pOReceiptLine.LineType == PO.POLineType.NonStockForDropShip);
                }
                if (!dropShipPO && sender.RaiseExceptionHandling <INTran.origRefNbr>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(INTran.origRefNbr).Name)))
                {
                    throw new PXRowPersistingException(typeof(INTran.origRefNbr).Name, null, ErrorMessages.FieldIsEmpty, typeof(INTran.origRefNbr).Name);
                }
            }

            if (item != null && item.ValMethod == INValMethod.Standard && row.TranType == INTranType.Adjustment && row.InvtMult != 0 && row.BaseQty == 0m && row.TranCost != 0m)
            {
                if (sender.RaiseExceptionHandling <INTran.tranCost>(e.Row, row.TranCost, new PXSetPropertyException(Messages.StandardCostNoCostOnlyAdjust)))
                {
                    throw new PXRowPersistingException(typeof(INTran.tranCost).Name, row.TranCost, Messages.StandardCostNoCostOnlyAdjust);
                }
            }
        }
        protected virtual void INTran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            INTran row = (INTran)e.Row;

            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Update)
            {
                if (!string.IsNullOrEmpty(row.POReceiptNbr))
                {
                    if (PXDBQuantityAttribute.Round((decimal)(row.Qty + row.OrigQty)) > 0m)
                    {
                        sender.RaiseExceptionHandling <INTran.qty>(row, row.Qty, new PXSetPropertyException(CS.Messages.Entry_LE, -row.OrigQty));
                    }
                    else if (PXDBQuantityAttribute.Round((decimal)(row.Qty + row.OrigQty)) < 0m)
                    {
                        sender.RaiseExceptionHandling <INTran.qty>(row, row.Qty, new PXSetPropertyException(CS.Messages.Entry_GE, -row.OrigQty));
                    }
                }
            }

            if (((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert || (e.Operation & PXDBOperation.Command) == PXDBOperation.Update))
            {
                if (row.Qty == 0 && row.TranCost > 0)
                {
                    if (row.POReceiptNbr != null && row.POReceiptLineNbr != null && row.POReceiptType != null)
                    {
                        PO.POReceiptLine poreceiptline = new PO.POReceiptLine();
                        poreceiptline.ReceiptType = row.POReceiptType;
                        poreceiptline.LineNbr     = row.POReceiptLineNbr;
                        poreceiptline.ReceiptNbr  = row.POReceiptNbr;
                        throw
                            new PXErrorContextProcessingException(this, poreceiptline, new PXSetPropertyException(Messages.ZeroQtyWhenNonZeroCost));
                    }
                    sender.RaiseExceptionHandling <INTran.qty>(row, row.Qty,
                                                               new PXSetPropertyException(Messages.ZeroQtyWhenNonZeroCost));
                }
                CheckForSingleLocation(sender, row);
                CheckSplitsForSameTask(sender, row);
                CheckLocationTaskRule(sender, row);
            }
        }
Exemple #3
0
        protected virtual void INLocation_TaskID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            ///TODO: Redo this using Plans and Status tables once we have them in version 7.0

            INLocation row = e.Row as INLocation;

            if (row == null)
            {
                return;
            }

            PO.POReceiptLine unreleasedPO = PXSelect <PO.POReceiptLine,
                                                      Where <PO.POReceiptLine.taskID, Equal <Required <PO.POReceiptLine.taskID> >,
                                                             And <PO.POReceiptLine.released, Equal <False>,
                                                                  And <PO.POReceiptLine.locationID, Equal <Required <INLocation.locationID> > > > > > .SelectWindowed(this, 0, 1, row.TaskID, row.LocationID);

            if (unreleasedPO != null)
            {
                PMTask task = PXSelect <PMTask, Where <PMTask.taskID, Equal <Required <PMTask.taskID> > > > .Select(this, row.TaskID ?? e.NewValue);

                if (task != null)
                {
                    e.NewValue = task.TaskCD;
                }

                throw new PXSetPropertyException(Messages.TaskUsedInPO);
            }

            SO.SOShipLine unreleasedSO = PXSelect <SO.SOShipLine,
                                                   Where <SO.SOShipLine.taskID, Equal <Required <SO.SOShipLine.taskID> >,
                                                          And <SO.SOShipLine.released, Equal <False>,
                                                               And <SO.SOShipLine.locationID, Equal <Required <INLocation.locationID> > > > > > .SelectWindowed(this, 0, 1, row.TaskID, row.LocationID);

            if (unreleasedSO != null)
            {
                PMTask task = PXSelect <PMTask, Where <PMTask.taskID, Equal <Required <PMTask.taskID> > > > .Select(this, row.TaskID ?? e.NewValue);

                if (task != null)
                {
                    e.NewValue = task.TaskCD;
                }

                throw new PXSetPropertyException(Messages.TaskUsedInSO);
            }

            INLocationStatus locationStatus = PXSelect <INLocationStatus, Where <INLocationStatus.siteID, Equal <Required <INLocationStatus.siteID> >,
                                                                                 And <INLocationStatus.locationID, Equal <Required <INLocationStatus.locationID> >,
                                                                                      And <INLocationStatus.qtyOnHand, NotEqual <decimal0> > > > > .SelectWindowed(this, 0, 1, row.SiteID, row.LocationID);

            if (locationStatus != null)
            {
                PMTask task = PXSelect <PMTask, Where <PMTask.taskID, Equal <Required <PMTask.taskID> > > > .Select(this, row.TaskID ?? e.NewValue);

                if (task != null)
                {
                    e.NewValue = task.TaskCD;
                }

                throw new PXSetPropertyException(Messages.TaskUsedInIN);
            }
        }