Ejemplo n.º 1
0
        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.SOShipmentNbr))
                {
                    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))
            {
                CheckForSingleLocation(sender, row);
                CheckSplitsForSameTask(sender, row);
                CheckLocationTaskRule(sender, row);
            }
        }
        protected virtual void ContractDetail_Qty_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            ContractDetail row  = (ContractDetail)e.Row;
            ContractItem   item = PXSelect <ContractItem, Where <ContractItem.contractItemID, Equal <Required <ContractDetail.contractItemID> > > > .Select(this, row.ContractItemID);

            if (item != null && (item.MaxQty < (decimal?)e.NewValue || item.MinQty > (decimal?)e.NewValue))
            {
                throw new PXSetPropertyException(Messages.QtyErrorWithParameters, PXDBQuantityAttribute.Round(item.MinQty ?? 0m), PXDBQuantityAttribute.Round(item.MaxQty ?? 0m));
            }
        }
Ejemplo n.º 3
0
        protected virtual void EPExpenseClaimDetails_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            EPExpenseClaimDetails row = (EPExpenseClaimDetails)e.Row;

            if (!string.IsNullOrEmpty(row.RefNbr) && e.Operation != PXDBOperation.Delete)
            {
                EPExpenseClaim claim = CurrentClaim.SelectSingle(row.RefNbr);
                if (claim != null &&
                    epsetup.Current.AllowMixedTaxSettingInClaims == false)
                {
                    if (claim.TaxZoneID != CurrentClaimDetails.Current.TaxZoneID)
                    {
                        cache.RaiseExceptionHandling <EPExpenseClaimDetails.taxZoneID>(row,
                                                                                       row.TaxZoneID,
                                                                                       new PXSetPropertyException(Messages.TaxZoneNotMatch, row.ClaimDetailID, claim.RefNbr));
                    }
                    if (claim.TaxCalcMode != row.TaxCalcMode)
                    {
                        cache.RaiseExceptionHandling <EPExpenseClaimDetails.taxCalcMode>(row,
                                                                                         row.TaxCalcMode,
                                                                                         new PXSetPropertyException(Messages.TaxCalcModeNotMatch, row.ClaimDetailID, claim.RefNbr));
                    }
                }
            }
            if (row != null && e.Operation != PXDBOperation.Delete)
            {
                if (row.Hold == false)
                {
                    if (!epsetup.Current.NonTaxableTipItem.HasValue && (row.CuryTipAmt ?? 0) != 0)
                    {
                        cache.RaiseExceptionHandling <EPExpenseClaimDetails.curyTipAmt>(row,
                                                                                        row.CuryTipAmt,
                                                                                        new PXSetPropertyException(Messages.TipItemIsNotDefined));
                    }
                    if (glsetup.Current.RoundingLimit < Math.Abs(row.TaxRoundDiff ?? 0m))
                    {
                        throw new PXException(AP.Messages.RoundingAmountTooBig, currencyinfo?.Current?.BaseCuryID, row.TaxRoundDiff,
                                              PXDBQuantityAttribute.Round(this.glsetup.Current.RoundingLimit));
                    }
                }
                if (row.CuryTipAmt > 0 && row.CuryExtCost < 0 || row.CuryTipAmt < 0 && row.CuryExtCost > 0)
                {
                    cache.RaiseExceptionHandling <EPExpenseClaimDetails.curyTipAmt>(row,
                                                                                    row.CuryTipAmt,
                                                                                    new PXSetPropertyException(Messages.TipSign));
                }
            }
        }
        public static void X_Duration_FieldUpdated <DAC, Qty>(PXCache cache, PXFieldUpdatedEventArgs e, int?duration)
            where DAC : class, IBqlTable, IFSSODetBase, new()
            where Qty : class, IBqlField
        {
            if (e.Row == null)
            {
                return;
            }

            var row = (DAC)e.Row;

            if (row.LineType == ID.LineType_All.SERVICE && row.BillingRule == ID.BillingRule.TIME &&
                row.IsPrepaid == false)
            {
                cache.SetValueExt <Qty>(e.Row, PXDBQuantityAttribute.Round(decimal.Divide((decimal)(duration ?? 0), 60)));
            }
        }
Ejemplo n.º 5
0
        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(sender, (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(sender, (decimal)(row.Qty + row.OrigQty)) < 0m)
                    {
                        sender.RaiseExceptionHandling <INTran.qty>(row, row.Qty, new PXSetPropertyException(CS.Messages.Entry_GE, -row.OrigQty));
                    }
                }
            }
        }
        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);
            }
        }
Ejemplo n.º 7
0
        public virtual void OrderAvailabilityCheck(PXCache sender, ARTran row, bool onPersist = false)
        {
            if (row.InvtMult == 0 || row.SOOrderType == null && row.SOOrderNbr == null && row.SOOrderLineNbr == null || row.Released == true)
            {
                return;
            }

            if (row.LineType == SOLineType.MiscCharge)
            {
                RaiseAvailabilityException(sender, row, typeof(ARTran.inventoryID), Messages.NonStockNoShipCantBeInvoicedDirectly, onPersist,
                                           sender.GetValueExt <ARTran.inventoryID>(row));
            }

            var res = GetLinkedSOLine(row);

            if (res == null)
            {
                RaiseAvailabilityException(sender, row, typeof(ARTran.sOOrderNbr), Messages.SOLineNotFound, onPersist);
            }

            SOLine      line      = res;
            SOOrderType orderType = res;

            if (orderType.OrderType == null || orderType.RequireShipping == false || orderType.ARDocType == ARDocType.NoUpdate)
            {
                RaiseAvailabilityException(sender, row, typeof(ARTran.sOOrderType), Messages.SOTypeCantBeInvoicedDirectly, onPersist,
                                           sender.GetValueExt <ARTran.sOOrderType>(row));
            }

            if (line.Completed == true)
            {
                RaiseAvailabilityException(sender, row, typeof(ARTran.sOOrderNbr), Messages.CompletedSOLineCantBeInvoicedDirectly, onPersist);
            }

            if (line.CustomerID != row.CustomerID)
            {
                RaiseAvailabilityException(sender, row, typeof(ARTran.sOOrderNbr), Messages.CustomerDiffersInvoiceAndSO, onPersist);
            }

            if (line.POCreate == true)
            {
                RaiseAvailabilityException(sender, row, typeof(ARTran.sOOrderNbr), Messages.SOLineMarkedForPOCantBeInvoicedDirectly, onPersist);
            }

            if (line.InventoryID != row.InventoryID)
            {
                RaiseAvailabilityException(sender, row, typeof(ARTran.inventoryID), Messages.InventoryItemDiffersInvoiceAndSO, onPersist);
            }

            int arTranInvtMult = Math.Sign((row.InvtMult * row.Qty) ?? 0m);

            if (arTranInvtMult != 0)
            {
                int soLineInvtMult = (line.Operation == SOOperation.Receipt) ? 1 : -1;
                if (soLineInvtMult != arTranInvtMult)
                {
                    RaiseAvailabilityException(sender, row, typeof(ARTran.qty), Messages.OperationDiffersInvoiceAndSO, onPersist);
                }
            }

            decimal absQty = Math.Abs(row.BaseQty ?? 0m);

            if (PXDBQuantityAttribute.Round((decimal)(line.BaseOrderQty * line.CompleteQtyMax / 100m - line.BaseShippedQty - absQty)) < 0m)
            {
                RaiseAvailabilityException(sender, row, typeof(ARTran.qty), Messages.OrderCheck_QtyNegative, onPersist,
                                           sender.GetValueExt <ARTran.inventoryID>(row), sender.GetValueExt <ARTran.subItemID>(row),
                                           sender.GetValueExt <ARTran.sOOrderType>(row), sender.GetValueExt <ARTran.sOOrderNbr>(row));
            }
        }