示例#1
0
        protected virtual void DaylightShift_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            DaylightShift row = e.Row as DaylightShift;

            if (row == null || row.Year == null || row.TimeZone == null || row.IsActive == true)
            {
                return;
            }

            DaylightSavingTime dts = GetDST(row.TimeZone, (int)row.Year);

            if ((dts != null && dts.IsActive &&
                 row.FromDate == dts.Start && row.ToDate == dts.End && row.Shift == (int)dts.DaylightOffset.TotalMinutes)
                ||
                (row.FromDate == null && row.ToDate == null && row.Shift == null))
            {
                DaylightShift savedRow = PXSelectReadonly <DaylightShift,
                                                           Where <DaylightShift.year, Equal <Current <DaylightShiftFilter.year> >,
                                                                  And <DaylightShift.timeZone, Equal <Required <DaylightShift.timeZone> > > > > .SelectWindowed(this, 0, 1, row.TimeZone);

                row.FromDate = savedRow.FromDate;
                row.ToDate   = savedRow.ToDate;
                row.Shift    = savedRow.Shift;
            }
        }
        public virtual bool IsApplicable(PXGraph graph, LandedCostCode aCode, POReceiptLine aLine)
        {
            bool transferinsidewarehouse = false;

            if (aLine.ReceiptType == POReceiptType.TransferReceipt)
            {
                INTran ortran = PXSelectReadonly <INTran, Where <INTran.tranType, Equal <Required <INTran.origTranType> >,
                                                                 And <INTran.refNbr, Equal <Required <INTran.origRefNbr> > > > >
                                .SelectWindowed(graph, 0, 1, aLine.OrigTranType, aLine.OrigRefNbr, aLine.OrigLineNbr);

                transferinsidewarehouse = (ortran == null || ortran.SiteID == aLine.SiteID);
            }

            if (transferinsidewarehouse == false)
            {
                HasApplicableTransfers = true;
            }

            //Memo - in this release, non-stock Items are not applicable for the landed cost. Review later.
            return(!transferinsidewarehouse &&
                   (aCode.AllocationMethod != LandedCostAllocationMethod.None && (aLine.LineType == POLineType.GoodsForInventory ||
                                                                                  aLine.LineType == POLineType.GoodsForReplenishment ||
                                                                                  aLine.LineType == POLineType.GoodsForSalesOrder ||
                                                                                  aLine.LineType == POLineType.GoodsForDropShip ||
                                                                                  aLine.LineType == POLineType.NonStock ||
                                                                                  aLine.LineType == POLineType.NonStockForDropShip ||
                                                                                  aLine.LineType == POLineType.NonStockForSalesOrder)));
        }
示例#3
0
 public static bool IsOrderSelfCaptured(PXGraph graph, SOOrder doc)
 {
     return(PXSelectReadonly <ExternalTransaction,
                              Where <ExternalTransaction.origDocType, Equal <Required <SOOrder.orderType> >, And <ExternalTransaction.origRefNbr, Equal <Required <SOOrder.orderNbr> >,
                                                                                                                  And <ExternalTransaction.origDocType, NotEqual <ExternalTransaction.docType>, And <ExternalTransaction.origRefNbr, NotEqual <ExternalTransaction.refNbr> > > > > >
            .SelectWindowed(graph, 0, 1, doc.OrderType, doc.OrderNbr).Count == 0);
 }
示例#4
0
            public override void SubstituteKeyFieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
            {
                //base.SubstituteKeyFieldUpdating(sender, e);

                InventoryItem inventoryItem = null;

                if (e.NewValue != null)
                {
                    inventoryItem = PXSelectReadonly <InventoryItem, Where <InventoryItem.inventoryCD, Equal <Required <InventoryItem.inventoryCD> > > > .SelectWindowed(sender.Graph, 0, 1, e.NewValue);

                    if (inventoryItem == null)
                    {
                        inventoryItem = InventoryItem.PK.Find(sender.Graph, (int?)e.NewValue);
                    }
                }
                if (inventoryItem != null)
                {
                    e.NewValue = inventoryItem.InventoryID;
                    e.Cancel   = true;
                }
                else if (e.NewValue != null)
                {
                    throw new PXSetPropertyException(PXMessages.LocalizeFormat(ErrorMessages.ValueDoesntExist, _FieldName, e.NewValue));
                }
            }
示例#5
0
        public virtual void CheckQtyFromPO(PXCache sender, APTran tran, Action <PXCache, APTran> baseMethod)
        {
            baseMethod(sender, tran);

            if (tran.TranType == APDocType.Prepayment && !string.IsNullOrEmpty(tran.PONbr) && tran.POLineNbr != null)
            {
                POLine poLine = PXSelectReadonly <POLine,
                                                  Where <POLine.orderType, Equal <Required <POLine.orderType> >, And <POLine.orderNbr, Equal <Required <POLine.orderNbr> >,
                                                                                                                      And <POLine.lineNbr, Equal <Required <POLine.lineNbr> > > > > >
                                .SelectWindowed(Base, 0, 1, tran.POOrderType, tran.PONbr, tran.POLineNbr);

                if (tran.Qty > poLine.OrderQty)
                {
                    sender.RaiseExceptionHandling <APTran.qty>(tran, tran.Qty, new PXSetPropertyException(Messages.PrepaidQtyCantExceedPOLine));
                }
                if ((poLine.CuryReqPrepaidAmt > poLine.CuryBilledAmt ? poLine.CuryReqPrepaidAmt : poLine.CuryBilledAmt)
                    + tran.CuryTranAmt + tran.CuryRetainageAmt
                    > poLine.CuryExtCost + poLine.CuryRetainageAmt)
                {
                    sender.RaiseExceptionHandling <APTran.curyTranAmt>(tran, tran.CuryTranAmt,
                                                                       new PXSetPropertyException(Messages.PrepaidAmtCantExceedPOLine));
                }
                else if (poLine.CuryReqPrepaidAmt + poLine.CuryBilledAmt
                         + tran.CuryTranAmt + tran.CuryRetainageAmt
                         > poLine.CuryExtCost + poLine.CuryRetainageAmt)
                {
                    sender.RaiseExceptionHandling <APTran.curyTranAmt>(tran, tran.CuryTranAmt,
                                                                       new PXSetPropertyException(Messages.PrepaidAmtMayExceedPOLine, PXErrorLevel.Warning, poLine.OrderNbr));
                }
            }
        }
        /// <summary>
        /// Allows to calculate the <c>RefNbr</c> sequence when trying to insert a new register.
        /// </summary>
        protected override bool SetRefNbr(PXCache cache, object row)
        {
            FSAppointment fsAppointmentRow = (FSAppointment)row;

            if (fsAppointmentRow.SOID == null || fsAppointmentRow.SOID < 0)
            {
                return(false);
            }

            FSAppointment fsAppointmentRow_tmp = PXSelectReadonly <FSAppointment,
                                                                   Where <
                                                                       FSAppointment.sOID, Equal <Current <FSAppointment.sOID> > >,
                                                                   OrderBy <
                                                                       Desc <FSAppointment.appointmentID> > >
                                                 .SelectWindowed(cache.Graph, 0, 1);

            string refNbr = string.Empty;

            if (fsAppointmentRow_tmp != null)
            {
                refNbr = fsAppointmentRow_tmp.RefNbr;
            }

            fsAppointmentRow.RefNbr = SharedFunctions.GetNextRefNbr(fsAppointmentRow.SORefNbr, refNbr);

            return(true);
        }
示例#7
0
        protected string PickAddressError <TFieldSource>(IAddressBase address)
            where TFieldSource : IBqlField
        {
            if (typeof(TFieldSource) == typeof(SOOrder.shipAddressID))
            {
                return(PXSelect <SOOrder, Where <SOOrder.shipAddressID, Equal <Required <Address.addressID> > > >
                       .SelectWindowed(Base, 0, 1, ((SOAddress)address).AddressID).First().GetItem <SOOrder>()
                       .With(e => PXMessages.LocalizeFormat(AR.Messages.AvalaraAddressSourceError, EntityHelper.GetFriendlyEntityName <SOOrder>(), new EntityHelper(Base).GetRowID(e))));
            }

            if (typeof(TFieldSource) == typeof(Vendor.defLocationID))
            {
                return(PXSelectReadonly2 <Vendor, InnerJoin <Location, On <Location.locationID, Equal <Vendor.defLocationID> > >, Where <Location.defAddressID, Equal <Required <Address.addressID> > > >
                       .SelectWindowed(Base, 0, 1, ((Address)address).AddressID).First().GetItem <Vendor>()
                       .With(e => PXMessages.LocalizeFormat(AR.Messages.AvalaraAddressSourceError, EntityHelper.GetFriendlyEntityName <Vendor>(), new EntityHelper(Base).GetRowID(e))));
            }

            if (typeof(TFieldSource) == typeof(INSite.addressID))
            {
                return(PXSelectReadonly <INSite, Where <INSite.addressID, Equal <Required <Address.addressID> > > >
                       .SelectWindowed(Base, 0, 1, ((Address)address).AddressID).First().GetItem <INSite>()
                       .With(e => PXMessages.LocalizeFormat(AR.Messages.AvalaraAddressSourceError, EntityHelper.GetFriendlyEntityName <INSite>(), new EntityHelper(Base).GetRowID(e))));
            }

            if (typeof(TFieldSource) == typeof(BAccountR.defAddressID))
            {
                return(PXSelectReadonly <BAccountR, Where <BAccountR.defAddressID, Equal <Required <Address.addressID> > > >
                       .SelectWindowed(Base, 0, 1, ((Address)address).AddressID).First().GetItem <BAccountR>()
                       .With(e => PXMessages.LocalizeFormat(AR.Messages.AvalaraAddressSourceError, EntityHelper.GetFriendlyEntityName <BAccountR>(), new EntityHelper(Base).GetRowID(e))));
            }

            throw new ArgumentOutOfRangeException("Unknown address source used");
        }
        protected virtual void INLotSerClass_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            INLotSerClass row = (INLotSerClass)e.Row;

            if (row != null)
            {
                INItemClass classUse = PXSelectReadonly <INItemClass,
                                                         Where <INItemClass.lotSerClassID, Equal <Required <INItemClass.lotSerClassID> > > > .
                                       SelectWindowed(this, 0, 1, row.LotSerClassID);

                InventoryItem itemUse = PXSelectReadonly <InventoryItem,
                                                          Where <InventoryItem.lotSerClassID, Equal <Required <InventoryItem.lotSerClassID> > > > .
                                        SelectWindowed(this, 0, 1, row.LotSerClassID);

                PXUIFieldAttribute.SetEnabled <INLotSerClass.lotSerTrack>(sender, row, classUse == null && itemUse == null);
                PXUIFieldAttribute.SetEnabled <INLotSerClass.lotSerTrackExpiration>(sender, row, classUse == null && itemUse == null);

                bool enable = row.LotSerTrack != INLotSerTrack.NotNumbered;

                this.lotsersegments.Cache.AllowInsert = enable;
                this.lotsersegments.Cache.AllowUpdate = enable;
                this.lotsersegments.Cache.AllowDelete = enable;

                PXUIFieldAttribute.SetEnabled <INLotSerClassLotSerNumVal.lotSerNumVal>(lotSerNumVal.Cache, lotSerNumVal.Current, enable && row.LotSerNumShared == true);
                PXUIFieldAttribute.SetEnabled <INLotSerClass.autoNextNbr>(sender, row, enable);
                PXUIFieldAttribute.SetEnabled <INLotSerClass.lotSerNumShared>(sender, row, enable);
                PXUIFieldAttribute.SetEnabled <INLotSerClass.requiredForDropship>(sender, row, row.LotSerTrack != INLotSerTrack.NotNumbered);
                PXUIFieldAttribute.SetEnabled <INLotSerClass.autoSerialMaxCount>(sender, row, enable && row.AutoNextNbr == true && row.LotSerTrack == INLotSerTrack.SerialNumbered);
                PXUIFieldAttribute.SetVisible <INLotSerClass.lotSerIssueMethod>(sender, row, row.LotSerAssign == INLotSerAssign.WhenReceived);
            }
        }
示例#9
0
        public virtual void CheckRelatedEmployeesDoNotExist(int?[] branchBAccountIDs)
        {
            if (branchBAccountIDs == null || branchBAccountIDs.IsEmpty())
            {
                return;
            }

            EPEmployee[] employees = PXSelectReadonly <EPEmployee,
                                                       Where <EPEmployee.parentBAccountID, In <Required <EPEmployee.parentBAccountID> > > >
                                     .SelectWindowed(Graph, 0, EntityCountInErrorMessage + 1, branchBAccountIDs)
                                     .RowCast <EPEmployee>()
                                     .ToArray();

            if (employees.Any())
            {
                IEnumerable <Branch> branches = PXSelectReadonly <Branch,
                                                                  Where <Branch.bAccountID, In <Required <Branch.bAccountID> > > >
                                                .Select(Graph, employees.Take(EntityCountInErrorMessage).Select(e => e.ParentBAccountID).ToArray())
                                                .RowCast <Branch>();

                throw new PXException(Messages.TheBranchOrBranchesCannotBeDeletedBecauseTheFollowingEmployeesAreAssigned,
                                      branches.Select(b => b.BranchCD.Trim()).ToArray().JoinIntoStringForMessage(),
                                      employees.Select(e => e.AcctCD.Trim()).ToArray().JoinIntoStringForMessage(EntityCountInErrorMessage));
            }
        }
示例#10
0
        protected virtual void Ledger_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            Ledger ledger = e.Row as Ledger;

            if (ledger != null && ledger.LedgerID.HasValue)
            {
                //Type and Currency are forbidden for changses for the used accounts
                bool hasHistory = GLUtility.IsLedgerHistoryExist(this, ledger.LedgerID);
                PXUIFieldAttribute.SetEnabled <Ledger.balanceType>(LedgerRecords.Cache, ledger, !hasHistory);
                PXUIFieldAttribute.SetEnabled <Ledger.baseCuryID>(LedgerRecords.Cache, ledger, !hasHistory && PXAccess.FeatureInstalled <FeaturesSet.multicurrency>());
            }

            if (ledger != null)
            {
                PXUIFieldAttribute.SetEnabled <Ledger.postInterCompany>(cache, e.Row, ledger.BalanceType == LedgerBalanceType.Actual && ledger.DefBranchID != null);
                PXUIFieldAttribute.SetEnabled <Ledger.defBranchID>(cache, e.Row, ledger.BalanceType == LedgerBalanceType.Actual);

                if (ledger.BalanceType == LedgerBalanceType.Actual && ledger.DefBranchID != null)
                {
                    using (new PXReadBranchRestrictedScope())
                    {
                        GLHistory hist = PXSelectReadonly <GLHistory, Where <GLHistory.ledgerID, Equal <Current <Ledger.ledgerID> >, And <GLHistory.branchID, Equal <Current <Ledger.defBranchID> > > > > .SelectWindowed(this, 0, 1);

                        PXResultset <GLHistory> hist2 = PXSelectGroupBy <GLHistory, Where <GLHistory.ledgerID, Equal <Current <Ledger.ledgerID> > >, Aggregate <GroupBy <GLHistory.branchID> > > .Select(this);

                        PXUIFieldAttribute.SetEnabled <Ledger.postInterCompany>(cache, e.Row, (hist2.Count <= 1));
                        PXUIFieldAttribute.SetEnabled <Ledger.defBranchID>(cache, e.Row, (hist == null));
                    }
                }
            }
        }
示例#11
0
        public static void Update(PXGraph graph, int?vendorID, int?vendorLocationID, string curyID, int?inventoryID, int?subItemID, string uom, decimal curyCost)
        {
            if (curyCost <= 0 || string.IsNullOrEmpty(uom) ||
                vendorID == null ||
                vendorLocationID == null)
            {
                return;
            }

            PXCache cache = graph.Caches[typeof(POVendorInventoryPriceUpdate)];

            foreach (PXResult <InventoryItem, Vendor, Company> r in
                     PXSelectJoin <InventoryItem,
                                   LeftJoin <Vendor,
                                             On <Vendor.bAccountID, Equal <Required <Vendor.bAccountID> > >,
                                             CrossJoin <Company> >,
                                   Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .
                     Select(graph, vendorID, inventoryID))
            {
                InventoryItem item    = r;
                Vendor        vendor  = r;
                Company       company = r;
                if (item.InventoryID == null || vendor.BAccountID == null ||
                    (item.StkItem == true && subItemID == null))
                {
                    continue;
                }
                INSetup setup = new PXSetup <INSetup>(graph).Current;

                int?savedSubItemID = item.StkItem == true ? subItemID : null;

                POVendorInventory existVendorPrice = PXSelectReadonly <POVendorInventory,
                                                                       Where <POVendorInventory.inventoryID, Equal <Required <POVendorInventory.inventoryID> >,
                                                                              And <POVendorInventory.subItemID, Equal <Required <POVendorInventory.subItemID> >,
                                                                                   And <POVendorInventory.purchaseUnit, Equal <Required <POVendorInventory.purchaseUnit> >,
                                                                                        And <POVendorInventory.vendorID, Equal <Required <POVendorInventory.vendorID> >,
                                                                                             And <POVendorInventory.vendorLocationID, Equal <Required <POVendorInventory.vendorLocationID> > > > > > > >
                                                     .SelectWindowed(graph, 0, 1, item.InventoryID, savedSubItemID, uom, vendorID, vendorLocationID);

                string priceCuryID = (existVendorPrice != null ? existVendorPrice.CuryID : vendor.CuryID) ?? company.BaseCuryID;

                POVendorInventoryPriceUpdate vendorPrice = (POVendorInventoryPriceUpdate)cache.CreateInstance();
                vendorPrice.InventoryID      = inventoryID;
                vendorPrice.SubItemID        = savedSubItemID;
                vendorPrice.VendorID         = vendorID;
                vendorPrice.VendorLocationID = vendorLocationID;
                vendorPrice.PurchaseUnit     = uom;
                vendorPrice = (POVendorInventoryPriceUpdate)cache.Insert(vendorPrice);
                if (item.StkItem != true)
                {
                    vendorPrice.SubItemID = savedSubItemID;
                }
                vendorPrice.CuryID = priceCuryID;
                cache.Normalize();
                vendorPrice.Active = true;
                Decimal cost = ConventCury(graph, vendor.CuryRateTypeID, curyID, curyCost, priceCuryID);
                vendorPrice.LastPrice = ConvertUOM(graph, item, uom, cost, item.PurchaseUnit);
            }
        }
示例#12
0
        private void DefaultEditableRow(DaylightShift row)
        {
            DaylightShift savedRow = PXSelectReadonly <DaylightShift,
                                                       Where <DaylightShift.year, Equal <Current <DaylightShiftFilter.year> >,
                                                              And <DaylightShift.timeZone, Equal <Required <DaylightShift.timeZone> > > > > .SelectWindowed(this, 0, 1, row.TimeZone);

            DateTime newDate = DateTime.UtcNow.Date;

            newDate = new DateTime((int)row.Year, newDate.Month, newDate.Day) + new TimeSpan(12, 0, 0);
            DateTime start = newDate;
            DateTime end   = newDate.AddDays(1D);
            int      shift = 60;

            DaylightSavingTime dts = GetDST(row.TimeZone, newDate.Year);

            if (dts != null && dts.IsActive)
            {
                start = dts.Start;
                end   = dts.End;
                shift = (int)dts.DaylightOffset.TotalMinutes;
            }

            if (savedRow != null)
            {
                row.Year = savedRow.Year;
                if (row.ToDate == null || row.ToDate == end)
                {
                    row.ToDate = savedRow.ToDate;
                }
                if (row.FromDate == null || row.FromDate == start)
                {
                    row.FromDate = savedRow.FromDate;
                }
                if (row.Shift == null || row.Shift == shift)
                {
                    row.Shift = savedRow.Shift;
                }
            }
            else
            {
                if (row.Year == null)
                {
                    row.Year = newDate.Year;
                }
                if (row.ToDate == null)
                {
                    row.ToDate = end;
                }
                if (row.FromDate == null)
                {
                    row.FromDate = start;
                }
                if (row.Shift == null)
                {
                    row.Shift = shift;
                }
            }
        }
示例#13
0
 private CurrencyRate getCuryRate(PXCache cache)
 {
     return(PXSelectReadonly <CurrencyRate,
                              Where <CurrencyRate.toCuryID, Equal <Required <CurrencyInfo.baseCuryID> >,
                                     And <CurrencyRate.fromCuryID, Equal <Required <CurrencyInfo.curyID> >,
                                          And <CurrencyRate.curyRateType, Equal <Required <CurrencyInfo.curyRateTypeID> >,
                                               And <CurrencyRate.curyEffDate, LessEqual <Required <CurrencyInfo.curyEffDate> > > > > >,
                              OrderBy <Desc <CurrencyRate.curyEffDate> > > .SelectWindowed(cache.Graph, 0, 1, BaseCuryID, CuryID, CuryRateTypeID, CuryEffDate));
 }
 private CurrencyRate getCuryRate(string from, string to, string curyRateType, DateTime curyEffDate)
 {
     return(PXSelectReadonly <CurrencyRate,
                              Where <CurrencyRate.toCuryID, Equal <Required <CurrencyRate.toCuryID> >,
                                     And <CurrencyRate.fromCuryID, Equal <Required <CurrencyRate.fromCuryID> >,
                                          And <CurrencyRate.curyRateType, Equal <Required <CurrencyRate.curyRateType> >,
                                               And <CurrencyRate.curyEffDate, LessEqual <Required <CurrencyRate.curyEffDate> > > > > >,
                              OrderBy <Desc <CurrencyRate.curyEffDate> > > .SelectWindowed(this, 0, 1, to, from, curyRateType, curyEffDate));
 }
示例#15
0
 protected virtual SOOrder FindCustomerOrderDuplicate(PXCache orderCache, string customerOrderNbr, SOOrder order)
 {
     return(PXSelectReadonly <SOOrder,
                              Where <SOOrder.orderType, Equal <Required <SOOrder.orderType> >,
                                     And <SOOrder.customerID, Equal <Required <SOOrder.customerID> >,
                                          And <SOOrder.customerOrderNbr, Equal <Required <SOOrder.customerOrderNbr> >,
                                               And <SOOrder.orderNbr, NotEqual <Required <SOOrder.orderNbr> > > > > > >
            .SelectWindowed(orderCache.Graph, 0, 1, order.OrderType, order.CustomerID, customerOrderNbr, order.OrderNbr));
 }
        public virtual void Branch_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            using (new PXReadBranchRestrictedScope())
            {
                GLHistory hist = PXSelectReadonly <GLHistory, Where <GLHistory.ledgerID, Equal <Current <Branch.ledgerID> >, And <GLHistory.branchID, Equal <Current <Branch.branchID> > > > > .SelectWindowed(this, 0, 1);

                PXUIFieldAttribute.SetEnabled <Branch.ledgerID>(sender, e.Row, (hist == null));
            }
        }
示例#17
0
        private void UpdatePhysicalQty()
        {
            INBarCodeItem item = AddByBarCode.Current;
            INPIHeader    d    = this.PIHeader.Current;

            this.SelectTimeStamp();

            using (PXTransactionScope sc = new PXTransactionScope())
            {
                INPIDetail detail =
                    PXSelectReadonly <INPIDetail,
                                      Where <INPIDetail.pIID, Equal <Current <INPIHeader.pIID> >,
                                             And <INPIDetail.inventoryID, Equal <Current <INBarCodeItem.inventoryID> >,
                                                  And <INPIDetail.subItemID, Equal <Current <INBarCodeItem.subItemID> >,
                                                       And <INPIDetail.locationID, Equal <Current <INBarCodeItem.locationID> >,
                                                            And <Where <INPIDetail.lotSerialNbr, IsNull,
                                                                        Or <INPIDetail.lotSerialNbr, Equal <Current <INBarCodeItem.lotSerialNbr> > > > > > > > > > .SelectWindowed(this, 0, 1);

                if (detail == null)
                {
                    INPIEntry entry = PXGraph.CreateInstance <INPIEntry>();
                    entry.PIHeader.Current = entry.PIHeader.Search <INPIHeader.pIID>(d.PIID);
                    detail = PXCache <INPIDetail> .CreateCopy(entry.PIDetail.Insert(new INPIDetail()));

                    detail.InventoryID = item.InventoryID;
                    detail             = PXCache <INPIDetail> .CreateCopy(entry.PIDetail.Update(detail));

                    detail.SubItemID    = item.SubItemID;
                    detail.LocationID   = item.LocationID;
                    detail.LotSerialNbr = item.LotSerialNbr;
                    detail.PhysicalQty  = item.Qty;
                    detail.ExpireDate   = item.ExpireDate;
                    entry.PIDetail.Update(detail);
                    entry.Save.Press();
                    this.PIHeader.View.RequestRefresh();
                }
                else
                {
                    detail = PXCache <INPIDetail> .CreateCopy(detail);

                    detail.PhysicalQty = detail.PhysicalQty.GetValueOrDefault() + item.Qty.GetValueOrDefault();
                    this.PIDetail.Update(detail);
                }
                sc.Complete();

                item.Description = PXMessages.LocalizeFormatNoPrefixNLA(Messages.PILineUpdated,
                                                                        AddByBarCode.GetValueExt <INBarCodeItem.inventoryID>(item).ToString().Trim(),
                                                                        Setup.Current.UseInventorySubItem == true ? ":" + AddByBarCode.GetValueExt <INBarCodeItem.subItemID>(item) : string.Empty,
                                                                        AddByBarCode.GetValueExt <INBarCodeItem.qty>(item),
                                                                        item.UOM,
                                                                        detail.LineNbr);
            }
            AddByBarCode.Reset(true);
            this.AddByBarCode.View.RequestRefresh();
            this.SelectTimeStamp();
        }
        protected virtual void INAvailabilityScheme_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            var itemClass = (INItemClass)PXSelectReadonly <INItemClass,
                                                           Where <INItemClass.availabilitySchemeID, Equal <Current <INAvailabilityScheme.availabilitySchemeID> > > > .SelectWindowed(this, 0, 1);

            if (itemClass != null)
            {
                throw new PXException(Messages.NotPossibleDeleteINAvailScheme);
            }
        }
        protected virtual void HasInventoryItemsInUse(INLotSerClass item)
        {
            InventoryItem inventoryUse = PXSelectReadonly <InventoryItem,
                                                           Where <InventoryItem.lotSerClassID, Equal <Required <InventoryItem.lotSerClassID> > > > .
                                         SelectWindowed(this, 0, 1, item.LotSerClassID);

            if (inventoryUse != null)
            {
                throw new PXSetPropertyException(Messages.LotSerAssignCannotBeChanged, inventoryUse.InventoryCD);
            }
        }
示例#20
0
        public IPXCurrencyRate GetRate(string fromCuryID, string toCuryID, string rateTypeID, DateTime?curyEffDate)
        {
            CurrencyRate c = PXSelectReadonly <CurrencyRate,
                                               Where <CurrencyRate.toCuryID, Equal <Required <CurrencyInfo.baseCuryID> >,
                                                      And <CurrencyRate.fromCuryID, Equal <Required <CurrencyInfo.curyID> >,
                                                           And <CurrencyRate.curyRateType, Equal <Required <CurrencyInfo.curyRateTypeID> >,
                                                                And <CurrencyRate.curyEffDate, LessEqual <Required <CurrencyInfo.curyEffDate> > > > > >,
                                               OrderBy <Desc <CurrencyRate.curyEffDate> > > .SelectWindowed(Graph, 0, 1, toCuryID, fromCuryID, rateTypeID, curyEffDate);

            return(c);
        }
        protected virtual OrganizationFinYear GenerateNextOrganizationFinYear(OrganizationFinYear year)
        {
            string        generatedYearNumber = $"{int.Parse(year.Year) + 1:0000}";
            MasterFinYear masterFinYear;

            while ((masterFinYear = FinPeriodRepository.FindMasterFinYearByID(generatedYearNumber, clearQueryCache: true)) == null)
            {
                MasterCalendarGraph.Clear();
                MasterCalendarGraph.GenerateCalendar(
                    FinPeriod.organizationID.MasterValue,
                    int.Parse(FinPeriodRepository.FindLastYear(FinPeriod.organizationID.MasterValue, clearQueryCache: true).Year),
                    int.Parse(generatedYearNumber));
            }

            short generatedFinPeriodsCount = (short)masterFinYear.FinPeriods;

            if (YearSetup.Current.HasAdjustmentPeriod == true)
            {
                generatedFinPeriodsCount--;
            }

            OrganizationFinPeriod lastNonAdjustmentOrgFinPeriod = this.FinPeriodRepository.FindLastNonAdjustmentOrganizationFinPeriodOfYear(year.OrganizationID, year.Year, clearQueryCache: true);
            int generatedMasterYearNumber = int.Parse(lastNonAdjustmentOrgFinPeriod.FinYear);

            List <MasterFinPeriod> masterFinPeriods;

            PXSelectBase <MasterFinPeriod> select = new PXSelectReadonly <
                MasterFinPeriod,
                Where <MasterFinPeriod.finPeriodID, Greater <Required <MasterFinPeriod.finPeriodID> >,
                       And <MasterFinPeriod.startDate, NotEqual <MasterFinPeriod.endDate> > >,
                OrderBy <
                    Asc <MasterFinPeriod.finPeriodID> > >(this);

            select.View.Clear();

            while ((masterFinPeriods = select
                                       .SelectWindowed(0, generatedFinPeriodsCount, lastNonAdjustmentOrgFinPeriod.MasterFinPeriodID)
                                       .RowCast <MasterFinPeriod>()
                                       .ToList()).Count < generatedFinPeriodsCount)
            {
                generatedMasterYearNumber++;
                MasterCalendarGraph.Clear();
                MasterCalendarGraph.GenerateCalendar(
                    FinPeriod.organizationID.MasterValue,
                    int.Parse(FinPeriodRepository.FindLastYear(FinPeriod.organizationID.MasterValue, clearQueryCache: true).Year),
                    generatedMasterYearNumber);
                select.View.Clear();
            }

            MasterFinPeriod startMasterFinPeriod = masterFinPeriods.First();

            return(GenerateSingleOrganizationFinYear((int)year.OrganizationID, masterFinYear, startMasterFinPeriod));
        }
        protected virtual bool HasTransactions(PaymentTypeInstance aRow)
        {
            PXEntryStatus status = this.PaymentTypeInstance.Cache.GetStatus(aRow);

            if (status == PXEntryStatus.Inserted && status == PXEntryStatus.InsertedDeleted)
            {
                return(false);
            }
            PTInstTran tran = PXSelectReadonly <PTInstTran, Where <PTInstTran.pTInstanceID, Equal <Required <PTInstTran.pTInstanceID> > > > .SelectWindowed(this, 0, 1, aRow.PTInstanceID);

            return(tran != null);
        }
        public virtual INTran GetOriginalInTran(PXGraph graph, string receiptNbr, int?lineNbr)
        {
            if (receiptNbr == null || lineNbr == null)
            {
                return(null);
            }

            return
                (PXSelectReadonly <INTran, Where <INTran.docType, NotEqual <INDocType.adjustment>,
                                                  And <INTran.docType, NotEqual <INDocType.transfer>,
                                                       And <INTran.pOReceiptNbr, Equal <Required <INTran.pOReceiptNbr> >,
                                                            And <INTran.pOReceiptLineNbr, Equal <Required <INTran.pOReceiptLineNbr> > > > > > > .SelectWindowed(graph, 0, 1, receiptNbr, lineNbr));
        }
示例#24
0
        protected virtual void INBarCodeItem_ExpireDate_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            INPIDetail exists =
                PXSelectReadonly <INPIDetail,
                                  Where <INPIDetail.pIID, Equal <Current <INPIHeader.pIID> >,
                                         And <INPIDetail.inventoryID, Equal <Current <INBarCodeItem.inventoryID> >,
                                              And <INPIDetail.lotSerialNbr, Equal <Current <INBarCodeItem.lotSerialNbr> > > > > > .SelectWindowed(this, 0, 1);

            if (exists != null)
            {
                e.NewValue = exists.ExpireDate;
                e.Cancel   = true;
            }
        }
示例#25
0
        private CurrencyRate getCuryRate(PXCache cache)
        {
            if (string.Equals(this.CuryID, this.BaseCuryID, StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            return(PXSelectReadonly <CurrencyRate,
                                     Where <CurrencyRate.toCuryID, Equal <Required <CurrencyInfo.baseCuryID> >,
                                            And <CurrencyRate.fromCuryID, Equal <Required <CurrencyInfo.curyID> >,
                                                 And <CurrencyRate.curyRateType, Equal <Required <CurrencyInfo.curyRateTypeID> >,
                                                      And <CurrencyRate.curyEffDate, LessEqual <Required <CurrencyInfo.curyEffDate> > > > > >,
                                     OrderBy <Desc <CurrencyRate.curyEffDate> > > .SelectWindowed(cache.Graph, 0, 1, BaseCuryID, CuryID, CuryRateTypeID, CuryEffDate));
        }
        public override object Evaluate(PXCache cache, object item, Dictionary <Type, object> pars)
        {
            Guid?userID = (Guid?)pars[typeof(UserID)];

            if (userID.HasValue)
            {
                MobileDevice device = PXSelectReadonly <MobileDevice, Where <MobileDevice.userID, Equal <Required <MobileDevice.userID> >,
                                                                             And <MobileDevice.enabled, Equal <True>,
                                                                                  And <MobileDevice.expiredToken, NotEqual <True> > > > >
                                      .SelectWindowed(cache.Graph, 0, 1, userID);

                return(device?.DeviceOS);
            }
            return(null);
        }
示例#27
0
        protected virtual void SOOrderType_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            SOOrderType ordertype = (SOOrderType)e.Row;

            SOOrderType link = references.SelectWindowed(0, 1, ordertype.OrderType);

            if (link != null)
            {
                throw new PXSetPropertyException(Messages.CannotDeleteTemplateOrderType, link.OrderType);
            }

            SOLine soTran = PXSelectReadonly <SOLine, Where <SOLine.orderType, Equal <Required <SOOrderType.orderType> > > > .SelectWindowed(this, 0, 1, ordertype.OrderType);

            if (soTran != null)
            {
                throw new PXSetPropertyException(Messages.CannotDeleteOrderType);
            }
        }
示例#28
0
        public override void FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            string uom = (string)e.NewValue;

            if (string.IsNullOrEmpty(uom))
            {
                return;
            }
            if (sender.Graph.Caches[typeof(INUnit)].Cached.Cast <INUnit>().Any(u => Equals(u.FromUnit, uom)))
            {
                return;
            }
            if (PXSelectReadonly <INUnit, Where <INUnit.fromUnit, Equal <Required <INUnit.fromUnit> > > > .SelectWindowed(sender.Graph, 0, 1, uom).Count > 0)
            {
                return;
            }

            base.FieldVerifying(sender, e);
        }
示例#29
0
        /// <summary>
        /// Allows to calculate the <c>RefNbr</c> sequence when trying to insert a new register.
        /// </summary>
        protected override bool SetRefNbr(PXCache cache, object row)
        {
            FSContractSchedule fsContractScheduleRow = (FSContractSchedule)row;

            if (fsContractScheduleRow.EntityID == null)
            {
                return(false);
            }

            FSServiceContract fsServiceContractRow = ServiceContractCore.ServiceContract_View.Select(cache.Graph, fsContractScheduleRow.EntityID);

            if (fsServiceContractRow == null)
            {
                return(false);
            }

            FSContractSchedule fsContractScheduleRow_tmp = PXSelectReadonly <FSContractSchedule,
                                                                             Where <
                                                                                 FSContractSchedule.entityID, Equal <Current <FSContractSchedule.entityID> >,
                                                                                 And <FSContractSchedule.entityType, Equal <FSContractSchedule.entityType.Contract> > >,
                                                                             OrderBy <
                                                                                 Desc <FSContractSchedule.scheduleID> > >
                                                           .SelectWindowed(cache.Graph, 0, 1);

            string refNbr = string.Empty;

            if (fsContractScheduleRow_tmp != null &&
                fsContractScheduleRow_tmp.RefNbr != null)
            {
                refNbr = fsContractScheduleRow_tmp.RefNbr;
            }

            if (refNbr.LastIndexOf("<NEW>") != -1)
            {
                refNbr = string.Empty;
            }

            fsContractScheduleRow.RefNbr = SharedFunctions.GetNextRefNbr(fsServiceContractRow.RefNbr, refNbr);

            return(true);
        }
示例#30
0
        protected virtual void CAEntryType_RowInserting(PXCache cache, PXRowInsertingEventArgs e)
        {
            CAEntryType row = (CAEntryType)e.Row;

            if (string.IsNullOrEmpty(row.EntryTypeId))
            {
                e.Cancel = true;
            }
            else
            {
                CAEntryType eType = PXSelectReadonly <CAEntryType,
                                                      Where <CAEntryType.entryTypeId, Equal <Optional <CAEntryType.entryTypeId> > > > .
                                    SelectWindowed(this, 0, 1, row.EntryTypeId);

                if (eType != null && eType != row)
                {
                    cache.RaiseExceptionHandling <CAEntryType.entryTypeId>(e.Row, row.EntryTypeId, new PXException(Messages.DuplicatedKeyForRow));
                    e.Cancel = true;
                }
            }
        }