Пример #1
0
        protected virtual void SOLine_InventoryID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            if (!e.ExternalCall)
            {
                e.Cancel = true;
            }
            SOLine tran = (SOLine)e.Row;

            if (tran == null)
            {
                return;
            }
            if (Base.Document.Current == null)
            {
                return;
            }
            if (e.NewValue == null)
            {
                return;
            }

            string              value  = Rutrots.Current?.RUTROTType;
            InventoryItem       item   = (InventoryItem)InventoryItem.Select((int)e.NewValue);
            InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <InventoryItem, InventoryItemRUTROT>(item);

            if (!RUTROTHelper.IsItemMatchRUTROTType(value, item, itemRR, itemRR?.IsRUTROTDeductible == true))
            {
                sender.RaiseExceptionHandling <SOLine.inventoryID>(tran, item.InventoryCD, new PXSetPropertyException <SOLine.inventoryID>(RUTROTMessages.LineDoesNotMatchDoc));
                e.NewValue = item.InventoryCD;
                throw new PXSetPropertyException <SOLine.inventoryID>(RUTROTMessages.LineDoesNotMatchDoc);
            }
        }
Пример #2
0
        public virtual void SOLine_IsRUTROTDeductible_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            SOLine tran = (SOLine)e.Row;

            if (tran == null)
            {
                return;
            }
            if (Base.Document.Current == null)
            {
                return;
            }
            if (e.NewValue == null || (bool)e.NewValue == false)
            {
                return;
            }

            string              value  = Rutrots.Current?.RUTROTType;
            InventoryItem       item   = (InventoryItem)InventoryItem.Select(tran.InventoryID);
            InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <InventoryItem, InventoryItemRUTROT>(item);

            if (!RUTROTHelper.IsItemMatchRUTROTType(value, item, itemRR, (bool)e.NewValue))
            {
                sender.RaiseExceptionHandling <SOLineRUTROT.isRUTROTDeductible>(tran, false, new PXSetPropertyException <SOLineRUTROT.isRUTROTDeductible>(RUTROTMessages.LineDoesNotMatchDoc));
                e.NewValue = false;
                throw new PXSetPropertyException <SOLineRUTROT.isRUTROTDeductible>(RUTROTMessages.LineDoesNotMatchDoc);
            }
        }
Пример #3
0
        protected virtual void RUTROT_RUTROTType_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            DocExt document = RUTROTHelper.GetExtensionNullable <Doc, DocExt>(Document.Current);
            RUTROT rutrot   = (RUTROT)e.Row;

            if (document != null && document.IsRUTROTDeductible == true)
            {
                string value = (string)e.NewValue;
                foreach (Tran tran in Transactions.Select())
                {
                    TranExt tranRR = RUTROTHelper.GetExtensionNullable <Tran, TranExt>(tran);
                    if (tranRR.GetInventoryID() != null)
                    {
                        InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(Base, tranRR.GetInventoryID());

                        InventoryItemRUTROT itemRR = PXCache <InventoryItem> .GetExtension <InventoryItemRUTROT>(item);

                        if (!RUTROTHelper.IsItemMatchRUTROTType(value, item, itemRR, itemRR?.IsRUTROTDeductible == true))
                        {
                            sender.RaiseExceptionHandling <RUTROT.rUTROTType>(rutrot, rutrot.RUTROTType, new PXSetPropertyException <RUTROT.rUTROTType>(RUTROTMessages.LineDoesNotMatchDoc));
                            e.NewValue = rutrot.RUTROTType;
                            break;
                        }
                    }
                }
            }
        }
Пример #4
0
        public void UpdateTranDeductibleFromInventory(IRUTROTableLine line, IRUTROTable document)
        {
            if (line == null)
            {
                return;
            }

            InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(Base, line.GetInventoryID());

            InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <InventoryItem, InventoryItemRUTROT>(item);

            if (itemRR == null)
            {
                return;
            }

            if (document?.IsRUTROTDeductible == true)
            {
                line.IsRUTROTDeductible = itemRR.IsRUTROTDeductible == true;
            }
            else
            {
                line.IsRUTROTDeductible = false;
            }

            if (itemRR.RUTROTItemType != null)
            {
                line.RUTROTItemType = itemRR.RUTROTItemType;
            }
            if (itemRR.RUTROTWorkTypeID != null)
            {
                line.RUTROTWorkTypeID = itemRR.RUTROTWorkTypeID;
            }
        }
        protected virtual void InventoryItem_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            InventoryItem item = e.Row as InventoryItem;

            if (item == null)
            {
                return;
            }
            InventoryItemRUTROT itemRR = PXCache <InventoryItem> .GetExtension <InventoryItemRUTROT>(item);

            Branch       branch   = Base.CurrentBranch.SelectSingle(PXAccess.GetBranchID());
            BranchRUTROT branchRR = RUTROTHelper.GetExtensionNullable <Branch, BranchRUTROT>(branch);

            bool allowRUTROT       = branchRR?.AllowsRUTROT == true;
            bool isOtherCostOrNull = itemRR.RUTROTItemType == null || itemRR.RUTROTItemType == RUTROTItemTypes.OtherCost;

            PXUIFieldAttribute.SetVisible <InventoryItemRUTROT.isRUTROTDeductible>(sender, item, allowRUTROT);
            PXUIFieldAttribute.SetVisible <InventoryItemRUTROT.isRUTROTDeductible>(Base.Item.Cache, item, allowRUTROT);
            PXUIFieldAttribute.SetVisible <InventoryItemRUTROT.rUTROTItemType>(Base.Item.Cache, item, allowRUTROT);
            PXUIFieldAttribute.SetVisible <InventoryItemRUTROT.rUTROTType>(Base.Item.Cache, item, allowRUTROT);
            PXUIFieldAttribute.SetVisible <InventoryItemRUTROT.rUTROTWorkTypeID>(Base.Item.Cache, item, allowRUTROT);

            PXUIFieldAttribute.SetEnabled <InventoryItemRUTROT.rUTROTWorkTypeID>(sender, item, !isOtherCostOrNull && itemRR.IsRUTROTDeductible == true);
            PXUIFieldAttribute.SetEnabled <InventoryItemRUTROT.rUTROTItemType>(sender, item, itemRR.IsRUTROTDeductible == true);
            PXUIFieldAttribute.SetEnabled <InventoryItemRUTROT.rUTROTType>(sender, item, itemRR.IsRUTROTDeductible == true);
            if (!isOtherCostOrNull && !RUTROTHelper.IsUpToDateWorkType(itemRR.RUTROTWorkTypeID, this.Base.Accessinfo.BusinessDate ?? DateTime.Now, this.Base))
            {
                sender.RaiseExceptionHandling <InventoryItemRUTROT.rUTROTWorkTypeID>(item, itemRR.RUTROTWorkTypeID, new PXSetPropertyException(RUTROTMessages.ObsoleteWorkTypeWarning, PXErrorLevel.Warning));
            }
            else
            {
                sender.RaiseExceptionHandling <InventoryItemRUTROT.rUTROTWorkTypeID>(item, itemRR.RUTROTWorkTypeID, null);
            }
        }
Пример #6
0
        protected virtual void InventoryItem_RUTROTType_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            InventoryItem       row    = (InventoryItem)e.Row;
            InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <InventoryItem, InventoryItemRUTROT>(row);

            if (row != null && itemRR?.RUTROTType != (string)e.OldValue)
            {
                sender.SetValueExt <InventoryItemRUTROT.rUTROTWorkTypeID>(row, null);
            }
        }
        private static void CheckProperUnitOfMeasure(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            InventoryItem       row    = (InventoryItem)e.Row;
            InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <InventoryItem, InventoryItemRUTROT>(row);

            if (row != null && itemRR?.RUTROTItemType == RUTROTItemTypes.Service)
            {
                sender.RaiseExceptionHandling <InventoryItemRUTROT.rUTROTItemType>(row, itemRR.RUTROTItemType, new PXSetPropertyException(RUTROTMessages.ServiceMustBeHour, PXErrorLevel.Warning));
            }
        }
Пример #8
0
        protected virtual void InventoryItem_RUTROTItemType_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            InventoryItem       row    = (InventoryItem)e.Row;
            InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <InventoryItem, InventoryItemRUTROT>(row);

            if (row != null && itemRR?.RUTROTItemType == RUTROTItemTypes.OtherCost)
            {
                sender.SetValueExt <InventoryItemRUTROT.rUTROTWorkTypeID>(row, null);
            }
            CheckProperUnitOfMeasure(sender, e);
        }
Пример #9
0
        protected virtual void InventoryItem_IsRUTROTDeductible_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            InventoryItem row = (InventoryItem)e.Row;

            if (row == null)
            {
                return;
            }
            InventoryItemRUTROT itemRR = PXCache <InventoryItem> .GetExtension <InventoryItemRUTROT>(row);

            if (itemRR.RUTROTType == null)
            {
                sender.SetDefaultExt <InventoryItemRUTROT.rUTROTType>(row);
            }
        }
        protected virtual void ARTran_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            var row = (ARTran)e.Row;

            if (row == null)
            {
                return;
            }

            IN.InventoryItem item = PXSelect <IN.InventoryItem, Where <IN.InventoryItem.inventoryID, Equal <Required <IN.InventoryItem.inventoryID> > > > .Select(Base, row.InventoryID);

            InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <IN.InventoryItem, InventoryItemRUTROT>(item);

            Base.Transactions.Cache.SetValueExt <ARTranRUTROT.isRUTROTDeductible>(e.Row, itemRR?.IsRUTROTDeductible ?? false);
        }
Пример #11
0
        protected virtual void RUTROT_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            RUTROT rutrot = (RUTROT)e.Row;
            DocExt doc    = RUTROTHelper.GetExtensionNullable <Doc, DocExt>(Document.Current);

            bool         treatAsError = doc?.GetDocumentHold() != true;
            PXErrorLevel errorLevel   = treatAsError ? PXErrorLevel.Error : PXErrorLevel.Warning;

            if (WarnOnDeductionExceedsAllowance(doc, rutrot, errorLevel) && treatAsError)
            {
                sender.RaiseExceptionHandling <RUTROT.curyTotalAmt>(rutrot, rutrot.CuryTotalAmt,
                                                                    new PXSetPropertyException(rutrot.CuryAllowedAmt == 0.0m ? RUTROTMessages.PeopleAreRequiredForDeduction : RUTROTMessages.DeductibleExceedsAllowance, PXErrorLevel.Error));
            }

            if (WarnUndistributedAmount(doc, rutrot, errorLevel, currencyinfo.Current ?? currencyinfo.SelectSingle()) && treatAsError)
            {
                sender.RaiseExceptionHandling <RUTROT.curyTotalAmt>(rutrot, rutrot.CuryTotalAmt,
                                                                    new PXSetPropertyException(RUTROTMessages.UndistributedAmount, PXErrorLevel.Error));
            }

            if (doc != null && doc.IsRUTROTDeductible == true)
            {
                foreach (Tran tran in Transactions.Select())
                {
                    TranExt tranRR = RUTROTHelper.GetExtensionNullable <Tran, TranExt>(tran);
                    if (tranRR.GetInventoryID() != null)
                    {
                        InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(Base, tranRR.GetInventoryID());

                        InventoryItemRUTROT itemRR = PXCache <InventoryItem> .GetExtension <InventoryItemRUTROT>(item);

                        if (!RUTROTHelper.IsItemMatchRUTROTType(rutrot.RUTROTType, item, itemRR, itemRR?.IsRUTROTDeductible == true))
                        {
                            var exception = new PXSetPropertyException(RUTROTMessages.LineDoesNotMatchDoc, PXErrorLevel.RowError);
                            Transactions.Cache.RaiseExceptionHandling(RUTROTHelper.IsRUTROTDeductible, tran, tranRR.IsRUTROTDeductible, exception);
                            throw exception;
                        }
                    }
                }
            }
        }
Пример #12
0
        public void CheckRUTROTLine(PXCache sender, IRUTROTable document, IRUTROTableLine line, RUTROT rutrot)
        {
            if (line != null && document != null && rutrot != null)
            {
                if (document.IsRUTROTDeductible == true)
                {
                    if (line.GetInventoryID() != null)
                    {
                        string        value = rutrot.RUTROTType;
                        InventoryItem item  = (InventoryItem)PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(Base, line.GetInventoryID());

                        InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <InventoryItem, InventoryItemRUTROT>(item);
                        if (!RUTROTHelper.IsItemMatchRUTROTType(value, item, itemRR, itemRR?.IsRUTROTDeductible == true))
                        {
                            Base.Transactions.Cache.RaiseExceptionHandling <SOLine.inventoryID>(line, item.InventoryCD, new PXSetPropertyException <SOLine.inventoryID>(RUTROTMessages.LineDoesNotMatchDoc));
                            throw new PXSetPropertyException <SOLine.inventoryID>(RUTROTMessages.LineDoesNotMatchDoc);
                        }
                    }
                }
            }
        }
Пример #13
0
 public static bool IsItemMatchRUTROTType(string rutrotType, InventoryItem item, InventoryItemRUTROT itemRR, bool isRUTROTDeductible)
 {
     return(!(item != null && !String.IsNullOrEmpty(itemRR.RUTROTType) && !String.IsNullOrEmpty(rutrotType) && itemRR.RUTROTType != rutrotType && isRUTROTDeductible));
 }