Exemple #1
0
        public virtual bool PrepareImportRow(string viewName, IDictionary keys, IDictionary values)
        {
            if (string.Compare(viewName, "VendorCatalogue", true) == 0)
            {
                string inventoryCD = (string)values[_inventoryID];

                var r = (PXResult <InventoryItem, INSubItem>)
                        PXSelectReadonly2 <InventoryItem,
                                           LeftJoin <INSubItem,
                                                     On <INSubItem.subItemCD, Equal <Required <INSubItem.subItemCD> >,
                                                         Or <Where <Required <INSubItem.subItemCD>, IsNull,
                                                                    And <INSubItem.subItemID, Equal <InventoryItem.defaultSubItemID> > > > > >,
                                           Where <InventoryItem.inventoryCD, Equal <Required <InventoryItem.inventoryCD> > > > .Select(this,
                                                                                                                                       values[_subItemID], values[_subItemID], inventoryCD);

                InventoryItem item    = r;
                INSubItem     subitem = r;
                if (item != null && item.InventoryID != null)
                {
                    string uom = (string)values[_uOM] ?? item.PurchaseUnit;

                    if (values[_subItemID] == null)
                    {
                        values[_subItemID] = subitem.SubItemCD;
                    }

                    POVendorInventory old_row =
                        subitem.SubItemID != null
                                                        ? PXSelect <POVendorInventory,
                                                                    Where <POVendorInventory.vendorID, Equal <Required <POVendorInventory.vendorID> >,
                                                                           And <POVendorInventory.vendorLocationID, Equal <Required <POVendorInventory.vendorLocationID> >,
                                                                                And <POVendorInventory.inventoryID, Equal <Required <POVendorInventory.inventoryID> >,
                                                                                     And <POVendorInventory.purchaseUnit, Equal <Required <POVendorInventory.purchaseUnit> >,
                                                                                          And <Where <POVendorInventory.subItemID, Equal <Required <POVendorInventory.subItemID> > > > > > > > >
                        .SelectWindowed(this, 0, 1, this.BAccount.Current.BAccountID, this.BAccount.Current.LocationID, item.InventoryID, uom, subitem.SubItemID)
                                                        : PXSelect <POVendorInventory,
                                                                    Where <POVendorInventory.vendorID, Equal <Required <POVendorInventory.vendorID> >,
                                                                           And <POVendorInventory.vendorLocationID, Equal <Required <POVendorInventory.vendorLocationID> >,
                                                                                And <POVendorInventory.inventoryID, Equal <Required <POVendorInventory.inventoryID> >,
                                                                                     And <POVendorInventory.purchaseUnit, Equal <Required <POVendorInventory.purchaseUnit> >,
                                                                                          And <POVendorInventory.subItemID, IsNull> > > > > >
                        .SelectWindowed(this, 0, 1, this.BAccount.Current.BAccountID, this.BAccount.Current.LocationID, item.InventoryID, uom);

                    if (old_row != null)
                    {
                        if (values[_uOM] == null)
                        {
                            values[_uOM] = old_row.PurchaseUnit;
                        }

                        if (keys.Contains(_recordID))
                        {
                            keys[_recordID]   = old_row.RecordID;
                            values[_recordID] = old_row.RecordID;
                        }
                    }
                }
            }
            return(true);
        }
        protected virtual void INTran_TaskID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            INTran row = e.Row as INTran;

            if (row == null)
            {
                return;
            }

            if (PM.ProjectAttribute.IsPMVisible(BatchModule.IN))
            {
                if (row.LocationID != null)
                {
                    PXResultset <INLocation> result = PXSelectReadonly2 <INLocation,
                                                                         LeftJoin <PMTask, On <PMTask.projectID, Equal <INLocation.projectID>, And <PMTask.taskID, Equal <INLocation.taskID> > > >,
                                                                         Where <INLocation.siteID, Equal <Required <INLocation.siteID> >,
                                                                                And <INLocation.locationID, Equal <Required <INLocation.locationID> > > > > .Select(sender.Graph, row.SiteID, row.LocationID);

                    foreach (PXResult <INLocation, PMTask> res in result)
                    {
                        PMTask task = (PMTask)res;
                        if (task != null && task.TaskCD != null && task.VisibleInIN == true)
                        {
                            e.NewValue = task.TaskCD;
                            return;
                        }
                    }
                }
            }
        }
        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");
        }
        public static void ReleaseDoc(CABatch aDoc)
        {
            if ((bool)aDoc.Released || (bool)aDoc.Hold)
            {
                throw new PXException(CA.Messages.CABatchStatusIsNotValidForProcessing);
            }
            ARBatchUpdate be  = PXGraph.CreateInstance <ARBatchUpdate>();
            CABatch       doc = be.Document.Select(aDoc.BatchNbr);

            be.Document.Current = doc;
            if ((bool)doc.Released || (bool)doc.Hold)
            {
                throw new PXException(CA.Messages.CABatchStatusIsNotValidForProcessing);
            }

            ARPayment voided = PXSelectReadonly2 <ARPayment,
                                                  InnerJoin <CABatchDetail, On <CABatchDetail.origDocType, Equal <ARPayment.docType>,
                                                                                And <CABatchDetail.origRefNbr, Equal <ARPayment.refNbr>,
                                                                                     And <CABatchDetail.origModule, Equal <GL.BatchModule.moduleAR> > > > >,
                                                  Where <CABatchDetail.batchNbr, Equal <Required <CABatch.batchNbr> >,
                                                         And <ARPayment.voided, Equal <True> > > > .Select(be, doc.BatchNbr);

            if (voided != null && String.IsNullOrEmpty(voided.RefNbr) == false)
            {
                throw new PXException(CA.Messages.CABatchContainsVoidedPaymentsAndConnotBeReleased);
            }

            List <ARRegister>        unreleasedList   = new List <ARRegister>();
            PXSelectBase <ARPayment> selectUnreleased = new PXSelectReadonly2 <ARPayment,
                                                                               InnerJoin <CABatchDetail, On <CABatchDetail.origDocType, Equal <ARPayment.docType>,
                                                                                                             And <CABatchDetail.origRefNbr, Equal <ARPayment.refNbr>,
                                                                                                                  And <CABatchDetail.origModule, Equal <GL.BatchModule.moduleAR> > > > >,
                                                                               Where <CABatchDetail.batchNbr, Equal <Optional <CABatch.batchNbr> >,
                                                                                      And <ARPayment.released, Equal <boolFalse> > > >(be);

            foreach (ARPayment iPmt in selectUnreleased.Select(doc.BatchNbr))
            {
                if (iPmt.Released != true)
                {
                    unreleasedList.Add(iPmt);
                }
            }
            if (unreleasedList.Count > 0)
            {
                ARDocumentRelease.ReleaseDoc(unreleasedList, true);
            }

            selectUnreleased.View.Clear();
            ARPayment pmt = selectUnreleased.Select(doc.BatchNbr);

            if (pmt != null)
            {
                throw new PXException(CA.Messages.CABatchContainsUnreleasedPaymentsAndCannotBeReleased);
            }
            doc.Released   = true;
            doc.DateSeqNbr = CABatchEntry.GetNextDateSeqNbr(be, aDoc); //Nothing AP specific in this static function
            be.RecalcTotals();
            doc = be.Document.Update(doc);
            be.Actions.PressSave();
        }
        /// <summary>
        /// Gets the information of the Appointment and AppointmentInventoryItem using as reference the [appointmentID] and [appointmentInventoryItemID].
        /// </summary>
        private SharedClasses.AppointmentInventoryItemInfo GetAppointmentInventoryItemInfo(int?appointmentID, int?appDetID, int index)
        {
            PXResult <FSAppointment, FSServiceOrder, FSSrvOrdType, FSAppointmentInventoryItem, FSAppointmentDet> bqlResult =
                (PXResult <FSAppointment, FSServiceOrder, FSSrvOrdType, FSAppointmentInventoryItem, FSAppointmentDet>)
                PXSelectReadonly2 <FSAppointment,
                                   InnerJoin <FSServiceOrder,
                                              On <FSServiceOrder.sOID, Equal <FSAppointment.sOID>,
                                                  And <FSAppointment.appointmentID, Equal <Required <FSAppointment.appointmentID> > > >,
                                              InnerJoin <FSSrvOrdType,
                                                         On <FSSrvOrdType.srvOrdType, Equal <FSAppointment.srvOrdType> >,
                                                         InnerJoin <FSAppointmentInventoryItem,
                                                                    On <FSAppointmentInventoryItem.appointmentID, Equal <FSAppointment.appointmentID>,
                                                                        And <FSAppointmentInventoryItem.appDetID, Equal <Required <FSAppointmentInventoryItem.appDetID> > > >,
                                                                    InnerJoin <FSAppointmentDet,
                                                                               On <FSAppointmentDet.sODetID, Equal <FSAppointmentInventoryItem.sODetID> > > > > > >
                .Select(this, appointmentID, appDetID);

            SharedClasses.AppointmentInventoryItemInfo appointmentInfoToReturn = new SharedClasses.AppointmentInventoryItemInfo();

            if (bqlResult != null)
            {
                FSAppointment              fsAppointmentRow              = (FSAppointment)bqlResult;
                FSServiceOrder             fsServiceOrderRow             = (FSServiceOrder)bqlResult;
                FSSrvOrdType               fsSrvOrdTypeRow               = (FSSrvOrdType)bqlResult;
                FSAppointmentInventoryItem fsAppointmentInventoryItemRow = (FSAppointmentInventoryItem)bqlResult;
                FSAppointmentDet           fsAppointmentDetRow           = (FSAppointmentDet)bqlResult;

                appointmentInfoToReturn = new SharedClasses.AppointmentInventoryItemInfo(fsAppointmentRow, fsServiceOrderRow, fsSrvOrdTypeRow, fsAppointmentDetRow, fsAppointmentInventoryItemRow, index);
            }

            return(appointmentInfoToReturn);
        }
        protected int?GetInstanceId(V2.TranProfile input)
        {
            int?    instanceID = PaymentTranExtConstants.NewPaymentProfile;
            PXCache cpmCache   = Base.Caches[typeof(CustomerPaymentMethod)];

            cpmCache.ClearQueryCacheObsolete();
            PXSelectBase <CustomerPaymentMethod> query = new PXSelectReadonly2 <CustomerPaymentMethod,
                                                                                InnerJoin <CustomerPaymentMethodDetail, On <CustomerPaymentMethod.pMInstanceID, Equal <CustomerPaymentMethodDetail.pMInstanceID> >,
                                                                                           InnerJoin <PaymentMethodDetail, On <CustomerPaymentMethodDetail.detailID, Equal <PaymentMethodDetail.detailID>,
                                                                                                                               And <CustomerPaymentMethodDetail.paymentMethodID, Equal <PaymentMethodDetail.paymentMethodID> > > > >,
                                                                                Where <CustomerPaymentMethod.cCProcessingCenterID, Equal <Required <CustomerPaymentMethod.cCProcessingCenterID> >,
                                                                                       And <CustomerPaymentMethod.customerCCPID, Equal <Required <CustomerPaymentMethod.customerCCPID> >,
                                                                                            And <PaymentMethodDetail.isCCProcessingID, Equal <True>, And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards> > > > > >(Base);

            PXResultset <CustomerPaymentMethod> queryResult = query.Select(SelectedProcessingCenter, input.CustomerProfileId);

            foreach (PXResult <CustomerPaymentMethod, CustomerPaymentMethodDetail> item in queryResult)
            {
                CustomerPaymentMethodDetail checkCpmd = (CustomerPaymentMethodDetail)item;

                if (checkCpmd.Value == input.PaymentProfileId)
                {
                    instanceID = checkCpmd.PMInstanceID;
                    break;
                }
            }
            CustomerPaymentMethod cpm = NewCpm.Select();

            if (cpm != null && cpm.PMInstanceID != null && cpm.PMInstanceID >= 0)
            {
                instanceID = cpm.PMInstanceID.Value;
            }
            return(instanceID);
        }
Exemple #7
0
            private Dictionary <string, PXResult <Tax, TaxRev> > GetTaxRevisionList(PXGraph aGraph, DateTime aDocDate)
            {
                PXSelectBase <Tax> taxRevSelect = null;

                if (_aSalesOrPurchaseSwitch)
                {
                    taxRevSelect = new PXSelectReadonly2 <Tax,
                                                          InnerJoin <TaxRev, On <TaxRev.taxID, Equal <Tax.taxID>,
                                                                                 And <TaxRev.outdated, Equal <False>,
                                                                                      And <TaxRev.taxType, Equal <TaxType.sales>,
                                                                                           And <Tax.taxType, NotEqual <CSTaxType.withholding>,
                                                                                                And <Tax.taxType, NotEqual <CSTaxType.use>,
                                                                                                     And <Tax.reverseTax, Equal <False>,
                                                                                                          And <Tax.directTax, Equal <False>,
                                                                                                               And <Current <GLTranDoc.tranDate>, Between <TaxRev.startDate, TaxRev.endDate> > > > > > > > > > >(aGraph);
                }
                else
                {
                    taxRevSelect = new PXSelectReadonly2 <Tax,
                                                          InnerJoin <TaxRev, On <TaxRev.taxID, Equal <Tax.taxID>,
                                                                                 And <TaxRev.outdated, Equal <False>,
                                                                                      And <Tax.directTax, Equal <False>,
                                                                                           And2 <Where <TaxRev.taxType, Equal <TaxType.purchase>, And <Tax.reverseTax, Equal <False>,
                                                                                                                                                       Or <TaxRev.taxType, Equal <TaxType.sales>, And <Where <Tax.reverseTax, Equal <True>,
                                                                                                                                                                                                              Or <Tax.taxType, Equal <CSTaxType.use>, Or <Tax.taxType, Equal <CSTaxType.withholding> > > > > > > >,
                                                                                                 And <Required <TaxRev.startDate>, Between <TaxRev.startDate, TaxRev.endDate> > > > > > > >(aGraph);
                }

                Dictionary <string, PXResult <Tax, TaxRev> > tail = new Dictionary <string, PXResult <Tax, TaxRev> >();

                foreach (PXResult <Tax, TaxRev> record in taxRevSelect.Select(aDocDate))
                {
                    tail[((Tax)record).TaxID] = record;
                    Tax tax = record;
                    if (tax.TaxCalcType == CSTaxCalcType.Item)
                    {
                        switch (_enforcing)
                        {
                        case TaxCalcLevelEnforcing.EnforceCalcOnItemAmount:
                            if (tax.TaxCalcLevel == CSTaxCalcLevel.Inclusive)
                            {
                                tax.TaxCalcLevel = CSTaxCalcLevel.CalcOnItemAmt;
                            }
                            break;

                        case TaxCalcLevelEnforcing.EnforceInclusive:
                            if (tax.TaxCalcLevel == CSTaxCalcLevel.CalcOnItemAmt)
                            {
                                tax.TaxCalcLevel = CSTaxCalcLevel.Inclusive;
                            }
                            break;

                        case TaxCalcLevelEnforcing.None:
                            break;
                        }
                    }
                }
                return(tail);
            }
Exemple #8
0
            public void Prefetch(PXGraph parameter)
            {
                var reminderListViewInfo = new PXSelectReadonly2 <EPActivity,
                                                                  LeftJoin <EPView, On <EPView.noteID, Equal <EPActivity.noteID>, And <EPView.userID, Equal <Current <AccessInfo.userID> > > >, ReminderJoin>,
                                                                  ReminderListWhere,
                                                                  OrderBy <Asc <EPActivity.reminderDate> > >(parameter);

                _reminderList = reminderListViewInfo.Select().ToArray();
            }
Exemple #9
0
 public virtual PXResult <SOLine, SOOrderType> GetLinkedSOLine(ARTran row)
 {
     return((PXResult <SOLine, SOOrderType>) PXSelectReadonly2 <SOLine,
                                                                LeftJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOLine.orderType> > >,
                                                                Where <SOLine.orderType, Equal <Current <ARTran.sOOrderType> >,
                                                                       And <SOLine.orderNbr, Equal <Current <ARTran.sOOrderNbr> >,
                                                                            And <SOLine.lineNbr, Equal <Current <ARTran.sOOrderLineNbr> > > > > >
            .SelectSingleBound(_Graph, new[] { row }));
 }
Exemple #10
0
        public static bool RelatedForOrganizationGLHistoryExists(PXGraph graph, int?organizationID)
        {
            GLHistory history = PXSelectReadonly2 <GLHistory,
                                                   InnerJoin <Branch,
                                                              On <GLHistory.branchID, Equal <Branch.branchID> > >,
                                                   Where <Branch.organizationID, Equal <Required <Branch.organizationID> > > >
                                .SelectSingleBound(graph, null, organizationID);

            return(history != null);
        }
        private IEnumerable <Customer> GetCustomersWithSameCCPID(string processingCenterID, string customerCCPID)
        {
            PXSelectBase <Customer> query = new PXSelectReadonly2 <Customer,
                                                                   InnerJoin <CustomerProcessingCenterID, On <Customer.bAccountID, Equal <CustomerProcessingCenterID.bAccountID> > >,
                                                                   Where <CustomerProcessingCenterID.cCProcessingCenterID, Equal <Required <CustomerProcessingCenterID.cCProcessingCenterID> >,
                                                                          And <CustomerProcessingCenterID.customerCCPID, Equal <Required <CustomerProcessingCenterID.customerCCPID> > > > >(_Graph);
            PXResultset <Customer> customers = query.Select(processingCenterID, customerCCPID);

            return(customers.RowCast <Customer>());
        }
Exemple #12
0
        public virtual void CheckPartiallyReceiptedPOServices(PXCache sender, PXFieldUpdatedEventArgs e, string poOrderType)
        {
            POSetup row = (POSetup)e.Row;

            if (row != null)
            {
                PXResultset <POLine> partiallyReceiptedPOServices = PXSelectReadonly2 <POLine,
                                                                                       InnerJoin <IN.InventoryItem,
                                                                                                  On <POLine.FK.InventoryItem> >,
                                                                                       Where <POLine.orderType, Equal <Required <POLine.orderType> >,
                                                                                              And <POLine.lineType, Equal <POLineType.service>, And <POLine.completed, NotEqual <True>,
                                                                                                                                                     And <POLine.receivedQty, NotEqual <decimal0> > > > > > .SelectWindowed(this, 0, 1000, poOrderType);

                if (partiallyReceiptedPOServices.Count > 0)
                {
                    if (poOrderType == POOrderType.RegularOrder)
                    {
                        if (row.AddServicesFromNormalPOtoPR == true)
                        {
                            PXUIFieldAttribute.SetWarning <POSetup.addServicesFromNormalPOtoPR>(sender, row, Messages.PossibleOverbillingAPNormalPO);
                        }
                        else
                        {
                            PXUIFieldAttribute.SetWarning <POSetup.addServicesFromNormalPOtoPR>(sender, row, Messages.PossibleOverbillingPRNormalPO);
                        }
                    }
                    else
                    {
                        if (row.AddServicesFromDSPOtoPR == true)
                        {
                            PXUIFieldAttribute.SetWarning <POSetup.addServicesFromDSPOtoPR>(sender, row, Messages.PossibleOverbillingAPDSPO);
                        }
                        else
                        {
                            PXUIFieldAttribute.SetWarning <POSetup.addServicesFromDSPOtoPR>(sender, row, Messages.PossibleOverbillingPRDSPO);
                        }
                    }

                    string overbillingMessage = Messages.PossibleOverbillingTraceList + " \n";
                    int    i = 0;
                    foreach (PXResult <POLine, IN.InventoryItem> line in partiallyReceiptedPOServices)
                    {
                        POLine           poline = (POLine)line;
                        IN.InventoryItem item   = (IN.InventoryItem)line;
                        overbillingMessage += string.Format(Messages.PossibleOverbillingTraceMessage, (poOrderType == POOrderType.RegularOrder ? Messages.RegularOrder : Messages.DropShip), poline.OrderNbr, poline.LineNbr, item.InventoryCD) + "\n";
                        i++;
                        if (i >= 1000)
                        {
                            break;
                        }
                    }
                    PXTrace.WriteWarning(overbillingMessage);
                }
            }
        }
Exemple #13
0
        public virtual IEnumerable CloseRoute(PXAdapter adapter)
        {
            FSRouteDocument fsRouteDocumentRow = RouteRecords.Current;

            if (fsRouteDocumentRow != null)
            {
                if (AutomaticallyCloseRoute || WebDialogResult.Yes == RouteRecords.Ask(
                        TX.WebDialogTitles.CONFIRM_ROUTE_CLOSING,
                        TX.Messages.ASK_CONFIRM_ROUTE_CLOSING,
                        MessageButtons.YesNo))
                {
                    var fsAppointmentSet = PXSelectReadonly2 <FSAppointment,
                                                              InnerJoin <FSSrvOrdType,
                                                                         On <FSSrvOrdType.srvOrdType, Equal <FSAppointment.srvOrdType> >,
                                                                         InnerJoin <FSAppointmentInventoryItem,
                                                                                    On <FSAppointmentInventoryItem.appointmentID, Equal <FSAppointment.appointmentID> >,
                                                                                    LeftJoin <FSPostInfo,
                                                                                              On <FSPostInfo.postID, Equal <FSAppointmentInventoryItem.postID> > > > >,
                                                              Where <
                                                                  FSAppointmentInventoryItem.lineType, Equal <ListField_LineType_Pickup_Delivery.Pickup_Delivery>,
                                                                  And <FSAppointment.routeDocumentID, Equal <Current <FSRouteDocument.routeDocumentID> >,
                                                                       And <FSAppointment.status, NotEqual <ListField_Status_Appointment.Canceled>,
                                                                            And <FSSrvOrdType.enableINPosting, Equal <True>,
                                                                                 And <
                                                                                     Where <
                                                                                         FSPostInfo.postID, IsNull,
                                                                                         Or <FSPostInfo.iNPosted, Equal <False> > > > > > > > >
                                           .Select(this, fsRouteDocumentRow.RouteDocumentID);

                    if (fsAppointmentSet.Count != 0)
                    {
                        throw new PXException(TX.Error.ROUTE_DOCUMENT_APPOINTMENTS_NOT_POSTED);
                    }
                    else
                    {
                        string errorMessage = string.Empty;
                        if (CloseAppointmentsInRoute(ref errorMessage) == false)
                        {
                            throw new PXException(errorMessage);
                        }

                        this.SelectTimeStamp();
                        RouteRecords.Cache.AllowUpdate = true;
                        fsRouteDocumentRow.Status      = ID.Status_Route.CLOSED;
                        RouteRecords.Cache.SetStatus(fsRouteDocumentRow, PXEntryStatus.Updated);
                        Save.Press();
                    }
                }
            }

            return(adapter.Get());
        }
Exemple #14
0
        private void EnsureHistoryLoaded(RMDataSourcePM dsPM)
        {
            //Unlike RMReportReaderGL, there is no lazy loading for now, given the way PMHistory is structured we need to load whole project history to get balances for a given project
            //We could do lazy loading by project, but that would be slower if report including a large number of projects (ex: project profitability list)
            var key = 1;

            if (!_historyLoaded.Contains(key))
            {
                ProcessPMResultset(PXSelectReadonly2 <PMHistory,
                                                      InnerJoin <PMTask, On <PMHistory.projectTaskID, Equal <PMTask.taskID> > > > .Select(this.Base));
                _historyLoaded.Add(key);
            }
        }
Exemple #15
0
        private IEnumerable <PXResult <CustomerPaymentMethod, CustomerPaymentMethodDetail> > GetPaymentsProfilesByCustomer(string processingCenterID, string customerCCPID)
        {
            PXSelectBase <CustomerPaymentMethod> query = new PXSelectReadonly2 <CustomerPaymentMethod,
                                                                                InnerJoin <CustomerPaymentMethodDetail, On <CustomerPaymentMethod.pMInstanceID, Equal <CustomerPaymentMethodDetail.pMInstanceID> >,
                                                                                           InnerJoin <PaymentMethodDetail, On <CustomerPaymentMethodDetail.detailID, Equal <PaymentMethodDetail.detailID>,
                                                                                                                               And <CustomerPaymentMethodDetail.paymentMethodID, Equal <PaymentMethodDetail.paymentMethodID> > > > >,
                                                                                Where <CustomerPaymentMethod.cCProcessingCenterID, Equal <Required <CustomerPaymentMethod.cCProcessingCenterID> >,
                                                                                       And <CustomerPaymentMethod.customerCCPID, Equal <Required <CustomerPaymentMethod.customerCCPID> >,
                                                                                            And <PaymentMethodDetail.isCCProcessingID, Equal <True>,
                                                                                                 And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards> > > > > >(this);
            var result = query.Select(processingCenterID, customerCCPID).Select(i => (PXResult <CustomerPaymentMethod, CustomerPaymentMethodDetail>)i);

            return(result);
        }
Exemple #16
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
                     PXSelectReadonly2 <InventoryItem,
                                        LeftJoinSingleTable <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 = PXSetupOptional <INSetup> .Select(graph);

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

                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 = curyID;
                cache.Normalize();
                vendorPrice.Active    = true;
                vendorPrice.LastPrice = curyCost;
            }
        }
            public PXResultset <ARPayment> GetPrepaymentBySO(PXGraph graph)
            {
                if (SOID == null)
                {
                    return(null);
                }

                return(PXSelectReadonly2 <ARPayment,
                                          InnerJoin <FSAdjust,
                                                     On <ARPayment.docType, Equal <FSAdjust.adjgDocType>,
                                                         And <ARPayment.refNbr, Equal <FSAdjust.adjgRefNbr> > >,
                                                     InnerJoin <FSServiceOrder,
                                                                On <FSAdjust.adjdOrderType, Equal <FSServiceOrder.srvOrdType>,
                                                                    And <FSAdjust.adjdOrderNbr, Equal <FSServiceOrder.refNbr> > > > >,
                                          Where <FSServiceOrder.sOID, Equal <Required <FSServiceOrder.sOID> > > > .Select(graph, SOID));
            }
        /// <summary><see cref="InventoryByClassFilter.InventoryID"/> Updated</summary>
        protected virtual void InventoryByClassFilter_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            var row = (InventoryByClassFilter)e.Row;

            if (row?.InventoryID != null)
            {
                INItemClass current = PXSelectReadonly2 <INItemClass,
                                                         InnerJoin <InventoryItem, On <InventoryItem.FK.ItemClass> >,
                                                         Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > >
                                      .SelectWindowed(this, 0, 1, row.InventoryID);

                _allowToSyncTreeCurrentWithPrimaryViewCurrent  = true;
                _forbidToSyncTreeCurrentWithPrimaryViewCurrent = false;
                _keepInventoryFilter    = true;
                ItemClassFilter.Current = current;
            }
        }
        public virtual void Recalculate(InventoryItem template)
        {
            if (template == null)
            {
                throw new PXArgumentException(nameof(template));
            }
            if (template.InventoryID == null)
            {
                throw new PXArgumentException(nameof(template.InventoryID));
            }

            _template = template;

            DeleteOldRows();
            GetAttributes();

            _combinations         = new Dictionary <string[], int>(new StringArrayComparer());
            _numberOfCombination  = 0;
            _lastInventoryID      = null;
            _attributeValues      = new string[_templateAttributes.Keys.Count];
            _columnAttributeValue = null;
            _rowAttributeValue    = null;

            var select = new PXSelectReadonly2 <CSAnswers,
                                                InnerJoin <CSAttributeGroup, On <CSAnswers.attributeID, Equal <CSAttributeGroup.attributeID> >,
                                                           InnerJoin <InventoryItem, On <CSAnswers.refNoteID, Equal <InventoryItem.noteID>,
                                                                                         And <CSAttributeGroup.entityClassID, Equal <InventoryItem.itemClassID> > > > >,
                                                Where <CSAttributeGroup.isActive, Equal <True>,
                                                       And <CSAttributeGroup.entityType, Equal <Constants.DACName <InventoryItem> >,
                                                            And <CSAttributeGroup.attributeCategory, Equal <CSAttributeGroup.attributeCategory.variant>,
                                                                 And <InventoryItem.templateItemID, Equal <Required <InventoryItem.inventoryID> > > > > >,
                                                OrderBy <Asc <InventoryItem.inventoryID, Asc <CSAttributeGroup.sortOrder, Asc <CSAttributeGroup.attributeID> > > > >(_graph);

            int attributesAreFilled = 0;

            using (new PXFieldScope(select.View, typeof(InventoryItem.inventoryID), typeof(CSAnswers.attributeID), typeof(CSAnswers.value)))
            {
                foreach (PXResult <CSAnswers, CSAttributeGroup, InventoryItem> result in select.Select(_template.InventoryID))
                {
                    InventoryItem inventoryItem = result;
                    CSAnswers     answer        = result;

                    RecalculateItem(inventoryItem, answer, ref attributesAreFilled);
                }
            }
        }
        public virtual IEnumerable <AMBomOper> GetOperationsWithoutMaterial(string bomId, string revisionId)
        {
            foreach (AMBomOper bomOper in PXSelectReadonly2 <AMBomOper, LeftJoin <AMBomMatl, On <AMBomOper.bOMID, Equal <AMBomMatl.bOMID>,
                                                                                                 And <AMBomOper.revisionID, Equal <AMBomMatl.revisionID>,
                                                                                                      And <AMBomOper.operationID, Equal <AMBomMatl.operationID> > > > >,
                                                             Where <AMBomOper.bOMID, Equal <Required <AMBomOper.bOMID> >,
                                                                    And <AMBomOper.revisionID, Equal <Required <AMBomOper.revisionID> >,
                                                                         And <AMBomMatl.inventoryID, IsNull> > > > .Select(this, bomId, revisionId))
            {
                if (bomOper?.OperationID == null)
                {
                    continue;
                }

                yield return(bomOper);
            }
        }
Exemple #21
0
        protected virtual List <PXResult <CSAnswers, CSAttributeGroup, InventoryItem> > SelectInventoryWithAttributes()
        {
            var select = new PXSelectReadonly2 <CSAnswers,
                                                InnerJoin <CSAttributeGroup, On <CSAnswers.attributeID, Equal <CSAttributeGroup.attributeID> >,
                                                           InnerJoin <InventoryItem, On <CSAnswers.refNoteID, Equal <InventoryItem.noteID>,
                                                                                         And <CSAttributeGroup.entityClassID, Equal <InventoryItem.itemClassID> > > > >,
                                                Where <CSAttributeGroup.isActive, Equal <True>,
                                                       And <CSAttributeGroup.entityType, Equal <Constants.DACName <InventoryItem> >,
                                                            And <CSAttributeGroup.attributeCategory, Equal <CSAttributeGroup.attributeCategory.variant>,
                                                                 And <InventoryItem.templateItemID, Equal <Required <EntryHeader.templateItemID> > > > > >,
                                                OrderBy <Asc <InventoryItem.inventoryID, Asc <CSAnswers.attributeID> > > >(Base);

            using (new PXFieldScope(select.View, typeof(InventoryItem.inventoryID), typeof(CSAnswers.attributeID), typeof(CSAnswers.value)))
            {
                return(select.Select(GetTemplateID()).Cast <PXResult <CSAnswers, CSAttributeGroup, InventoryItem> >().ToList());
            }
        }
Exemple #22
0
        protected virtual void GenerateStatement(ARStatementCycle cycle, DateTime statementDate, bool clearExisting)
        {
            PXSelectBase <Customer> selectCustomer = new PXSelectJoin <Customer,
                                                                       InnerJoin <CustomerMaster, On <CustomerMaster.bAccountID, Equal <Customer.statementCustomerID> > >,
                                                                       Where <CustomerMaster.statementCycleId, Equal <Required <Customer.statementCycleId> > >,
                                                                       OrderBy <Asc <Customer.statementCustomerID> > >(this);

            var statementGraph = CreateInstance <StatementCreateBO>();

            var family = new List <Customer> {
            };

            foreach (Customer customer in selectCustomer.Select(cycle.StatementCycleId))
            {
                if (family.Any() == false || family.First().StatementCustomerID == customer.StatementCustomerID)
                {
                    family.Add(customer);
                }
                else
                {
                    GenerateStatementForCustomerFamily(statementGraph, cycle, family, statementDate, clearExisting);
                    family = new List <Customer> {
                        customer
                    };
                }
            }

            if (family.Any())
            {
                GenerateStatementForCustomerFamily(statementGraph, cycle, family, statementDate, clearExisting);
            }

            Customer leftToProcess = PXSelectReadonly2 <Customer,
                                                        InnerJoin <CustomerMaster, On <CustomerMaster.bAccountID, Equal <Customer.statementCustomerID> > >,
                                                        Where <CustomerMaster.statementCycleId, Equal <Required <Customer.statementCycleId> >,
                                                               And <Where <Customer.statementLastDate, IsNull,
                                                                           Or <Customer.statementLastDate, Less <Required <Customer.statementLastDate> > > > > > > .SelectWindowed(this, 0, 1, cycle.StatementCycleId, statementDate);

            if (leftToProcess == null)
            {
                cycle.LastStmtDate = statementDate;
                this.CyclesList.Update(cycle);
                this.Actions.PressSave();
            }
        }
Exemple #23
0
        public static ItemCost Fetch(PXGraph graph, int?vendorID, int?vendorLocationID, DateTime?docDate, string curyID, int?inventoryID, int?subItemID, int?siteID, string uom, bool onlyVendor)
        {
            PXSelectBase <InventoryItem> vendorCostSelect =
                new PXSelectReadonly2 <InventoryItem,
                                       LeftJoin <INItemCost, On <INItemCost.inventoryID, Equal <InventoryItem.inventoryID> >,
                                                 LeftJoin <POVendorInventory, On <
                                                               POVendorInventory.inventoryID, Equal <InventoryItem.inventoryID>,
                                                               And <POVendorInventory.active, Equal <True>,
                                                                    And <POVendorInventory.vendorID, Equal <Required <Vendor.bAccountID> >,
                                                                         And <POVendorInventory.curyID, Equal <Required <POVendorInventory.curyID> >,
                                                                              And2 <Where <POVendorInventory.subItemID, Equal <Required <POVendorInventory.subItemID> >,
                                                                                           Or <POVendorInventory.subItemID, Equal <InventoryItem.defaultSubItemID>,
                                                                                               Or <POVendorInventory.subItemID, IsNull,
                                                                                                   Or <Where <Required <POVendorInventory.subItemID>, IsNull,
                                                                                                              And <POVendorInventory.subItemID, Equal <True> > > > > > >,
                                                                                    And2 <Where <POVendorInventory.purchaseUnit, Equal <Required <POVendorInventory.purchaseUnit> > >,
                                                                                          And <Where <POVendorInventory.vendorLocationID, Equal <Required <POVendorInventory.vendorLocationID> >,
                                                                                                      Or <POVendorInventory.vendorLocationID, IsNull> > > > > > > > > > >,
                                       Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > >,
                                       OrderBy <
                                           Asc <Switch <Case <Where <POVendorInventory.purchaseUnit, Equal <InventoryItem.purchaseUnit> >, True>, False>,
                                                Asc <Switch <Case <Where <POVendorInventory.subItemID, Equal <InventoryItem.defaultSubItemID> >, True>, False>,
                                                     Asc <Switch <Case <Where <POVendorInventory.vendorLocationID, IsNull>, True>, False>,
                                                          Asc <InventoryItem.inventoryCD> > > > > >(graph);

            Func <string, PXResult <InventoryItem, INItemCost, POVendorInventory> > selectVendorCostByUOM =
                uomParam => vendorCostSelect
                .Select(vendorID, curyID, subItemID, subItemID, uomParam, vendorLocationID, inventoryID).AsEnumerable()
                .FirstOrDefault(r => r.GetItem <POVendorInventory>() != null)
                as PXResult <InventoryItem, INItemCost, POVendorInventory>;

            var vendorCostRow = selectVendorCostByUOM(uom);
            var item          = vendorCostRow.GetItem <InventoryItem>();

            Func <POVendorInventory, ItemCost> fetchVendorLastCost =
                vendorPrice => vendorPrice.LastPrice != null && vendorPrice.LastPrice != 0m
                                        ? new ItemCost(item, vendorPrice.PurchaseUnit, curyID, vendorPrice.LastPrice.Value, false)
                                        : null;

            return(fetchVendorLastCost(vendorCostRow.GetItem <POVendorInventory>())
                   ?? fetchVendorLastCost(selectVendorCostByUOM(item.BaseUnit).GetItem <POVendorInventory>())
                   ?? (onlyVendor ? null : FetchStdCost(graph, item, docDate))
                   ?? (onlyVendor ? null : FetchSiteLastCost(graph, item, siteID))
                   ?? new ItemCost(item, vendorCostRow.GetItem <INItemCost>()?.LastCost ?? 0));
        }
Exemple #24
0
        public virtual IEnumerable CancelInvoice(PXAdapter adapter)
        {
            if (Base.Document.Current == null)
            {
                return(adapter.Get());
            }
            Base.Save.Press();

            EnsureCanCancel(Base.Document.Current, false);

            var reverseArgs = new ReverseInvoiceArgs {
                ApplyToOriginalDocument = true
            };

            if (this.CancellationInvoiceCreationOnRelease)
            {
                var existingCorrectionInvoiceSet = (PXResult <ARInvoice, CurrencyInfo>)
                                                   PXSelectReadonly2 <ARInvoice,
                                                                      InnerJoin <CurrencyInfo, On <CurrencyInfo.curyInfoID, Equal <ARInvoice.curyInfoID> > >,
                                                                      Where <ARInvoice.origDocType, Equal <Current <ARInvoice.docType> >,
                                                                             And <ARInvoice.origRefNbr, Equal <Current <ARInvoice.refNbr> >,
                                                                                  And <ARInvoice.isCorrection, Equal <True> > > > >
                                                   .Select(Base);

                ARInvoice    existingCorrectionInvoice = existingCorrectionInvoiceSet;
                CurrencyInfo currencyInfo = existingCorrectionInvoiceSet;

                if (existingCorrectionInvoice == null)
                {
                    throw new RowNotFoundException(Base.Document.Cache, Base.Document.Current.DocType, Base.Document.Current.RefNbr);
                }
                reverseArgs.DateOption           = ReverseInvoiceArgs.CopyOption.Override;
                reverseArgs.DocumentDate         = existingCorrectionInvoice.DocDate;
                reverseArgs.DocumentFinPeriodID  = existingCorrectionInvoice.FinPeriodID;
                reverseArgs.CurrencyRateOption   = ReverseInvoiceArgs.CopyOption.Override;
                reverseArgs.CurrencyRate         = currencyInfo;
                reverseArgs.OverrideDocumentHold = false;
                using (new PXLocaleScope(Base.customer.Current.LocaleName))
                {
                    reverseArgs.OverrideDocumentDescr = PXMessages.LocalizeFormatNoPrefixNLA(Messages.CorrectionOfInvoice, Base.Document.Current.RefNbr);
                }
            }

            return(Base.ReverseDocumentAndApplyToReversalIfNeeded(adapter, reverseArgs));
        }
Exemple #25
0
        public Dictionary <string, CustomerCreditCard> GetUnsynchronizedPaymentProfiles()
        {
            Dictionary <string, CustomerCreditCard> paymentProfiles = GetPaymentProfilesFromService();
            PXSelectBase <CustomerPaymentMethod>    query           = new PXSelectReadonly2 <CustomerPaymentMethod,
                                                                                             InnerJoin <CustomerPaymentMethodDetail, On <CustomerPaymentMethod.pMInstanceID, Equal <CustomerPaymentMethodDetail.pMInstanceID> >,
                                                                                                        InnerJoin <PaymentMethodDetail, On <CustomerPaymentMethodDetail.detailID, Equal <PaymentMethodDetail.detailID>,
                                                                                                                                            And <CustomerPaymentMethodDetail.paymentMethodID, Equal <PaymentMethodDetail.paymentMethodID> > > > >,
                                                                                             Where <CustomerPaymentMethod.cCProcessingCenterID, Equal <Required <CustomerPaymentMethod.cCProcessingCenterID> >,
                                                                                                    And <PaymentMethodDetail.isCCProcessingID, Equal <True>,
                                                                                                         And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards> > > > >(graph);
            PXResultset <CustomerPaymentMethod> lines = query.Select(processingCenterId);

            foreach (PXResult <CustomerPaymentMethod, CustomerPaymentMethodDetail> line in lines)
            {
                FilterPaymentsProfilesFromService(paymentProfiles, line);
            }
            return(paymentProfiles);
        }
Exemple #26
0
        public static IEnumerable <ExternalTransaction> GetSOInvoiceExternalTrans(PXGraph graph, ARInvoice currentInvoice)
        {
            foreach (ExternalTransaction tran in PXSelectReadonly <ExternalTransaction,
                                                                   Where <ExternalTransaction.refNbr, Equal <Current <ARInvoice.refNbr> >,
                                                                          And <ExternalTransaction.docType, Equal <Current <ARInvoice.docType> > > >,
                                                                   OrderBy <Desc <ExternalTransaction.transactionID> > > .SelectMultiBound(graph, new object[] { currentInvoice }))
            {
                yield return(tran);
            }

            foreach (ExternalTransaction tran in PXSelectReadonly2 <ExternalTransaction,
                                                                    InnerJoin <SOOrderShipment, On <SOOrderShipment.orderNbr, Equal <ExternalTransaction.origRefNbr>,
                                                                                                    And <SOOrderShipment.orderType, Equal <ExternalTransaction.origDocType> > > >,
                                                                    Where <SOOrderShipment.invoiceNbr, Equal <Current <ARInvoice.refNbr> >,
                                                                           And <SOOrderShipment.invoiceType, Equal <Current <ARInvoice.docType> >,
                                                                                And <ExternalTransaction.refNbr, IsNull> > >,
                                                                    OrderBy <Desc <CCProcTran.tranNbr> > > .SelectMultiBound(graph, new object[] { currentInvoice }))
            {
                yield return(tran);
            }
        }
Exemple #27
0
        protected virtual void AppendTail <T, W>(PXGraph graph, List <object> ret, T record, object row, params object[] parameters) where T : class, ITaxDetail, PX.Data.IBqlTable, new()
            where W : IBqlWhere, new()
        {
            IComparer <Tax> taxByCalculationLevelComparer = GetTaxByCalculationLevelComparer();

            taxByCalculationLevelComparer.ThrowOnNull(nameof(taxByCalculationLevelComparer));

            PXSelectBase <Tax> select = new PXSelectReadonly2 <Tax,
                                                               LeftJoin <TaxRev, On <TaxRev.taxID, Equal <Tax.taxID>,
                                                                                     And <TaxRev.outdated, Equal <False>,
                                                                                          And <TaxRev.taxType, Equal <TaxType.sales>,
                                                                                               And <Tax.taxType, NotEqual <CSTaxType.withholding>,
                                                                                                    And <Tax.taxType, NotEqual <CSTaxType.use>,
                                                                                                         And <Tax.reverseTax, Equal <False>,
                                                                                                              And <Required <TaxRev.startDate>, Between <TaxRev.startDate, TaxRev.endDate> > > > > > > > >,
                                                               Where2 <Where <Tax.taxID, Equal <Required <Tax.taxID> > >, And <W> > >(graph);

            List <object> newParams = new List <object>();

            newParams.Add(this.GetDocDate(ParentCache(graph), row));
            newParams.Add(record.TaxID);

            if (parameters != null)
            {
                newParams.AddRange(parameters);
            }

            foreach (PXResult <Tax, TaxRev> line in select.View.SelectMultiBound(new object[] { row }, newParams.ToArray()))
            {
                int idx;
                for (idx = ret.Count;
                     (idx > 0) && taxByCalculationLevelComparer.Compare((PXResult <T, Tax, TaxRev>)ret[idx - 1], line) > 0;
                     idx--)
                {
                    ;
                }

                ret.Insert(idx, new PXResult <T, Tax, TaxRev>(record, (Tax)line, (TaxRev)line));
            }
        }
Exemple #28
0
        public override void Persist()
        {
            using (var ts = new PXTransactionScope())
            {
                foreach (INSite record in site.Cache.Deleted)
                {
                    PXDatabase.Delete <INSiteStatus>(
                        new PXDataFieldRestrict <INSiteStatus.siteID>(PXDbType.Int, 4, record.SiteID, PXComp.EQ),
                        new PXDataFieldRestrict <INSiteStatus.qtyOnHand>(PXDbType.Decimal, 8, 0m, PXComp.EQ),
                        new PXDataFieldRestrict <INSiteStatus.qtyAvail>(PXDbType.Decimal, 8, 0m, PXComp.EQ));

                    PXDatabase.Delete <INLocationStatus>(
                        new PXDataFieldRestrict <INLocationStatus.siteID>(PXDbType.Int, 4, record.SiteID, PXComp.EQ),
                        new PXDataFieldRestrict <INLocationStatus.qtyOnHand>(PXDbType.Decimal, 8, 0m, PXComp.EQ),
                        new PXDataFieldRestrict <INLocationStatus.qtyAvail>(PXDbType.Decimal, 8, 0m, PXComp.EQ));

                    PXDatabase.Delete <INLotSerialStatus>(
                        new PXDataFieldRestrict <INLotSerialStatus.siteID>(PXDbType.Int, 4, record.SiteID, PXComp.EQ),
                        new PXDataFieldRestrict <INLotSerialStatus.qtyOnHand>(PXDbType.Decimal, 8, 0m, PXComp.EQ),
                        new PXDataFieldRestrict <INLotSerialStatus.qtyAvail>(PXDbType.Decimal, 8, 0m, PXComp.EQ));

                    InventoryItem item =
                        PXSelectReadonly2 <InventoryItem,
                                           InnerJoin <INSiteStatus, On <INSiteStatus.FK.InventoryItem> >,
                                           Where <INSiteStatus.siteID, Equal <Required <INSiteStatus.siteID> > > >
                        .SelectWindowed(this, 0, 1, record.SiteID);

                    if (item?.InventoryCD != null)
                    {
                        throw new PXRowPersistingException(typeof(INSite.siteCD).Name, record, Messages.SiteUsageDeleted, item.InventoryCD.TrimEnd());
                    }
                }

                ts.Complete();
            }

            base.Persist();
            location.Cache.Clear();
        }
        protected virtual void GetAttributes()
        {
            CSAttributeGroup[] attributes = new PXSelectReadonly2 <CSAttributeGroup,
                                                                   InnerJoin <InventoryItem, On <CSAttributeGroup.entityClassID, Equal <InventoryItem.itemClassID> > >,
                                                                   Where <CSAttributeGroup.isActive, Equal <True>,
                                                                          And <CSAttributeGroup.entityType, Equal <Constants.DACName <InventoryItem> >,
                                                                               And <CSAttributeGroup.attributeCategory, Equal <CSAttributeGroup.attributeCategory.variant>,
                                                                                    And <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> >,
                                                                                         And <CSAttributeGroup.attributeID, NotIn3 <Required <InventoryItem.defaultColumnMatrixAttributeID>,
                                                                                                                                    Required <InventoryItem.defaultRowMatrixAttributeID> > > > > > >,
                                                                   OrderBy <Asc <CSAttributeGroup.sortOrder, Asc <CSAttributeGroup.attributeID> > > >(_graph)
                                            .SelectMain(_template.InventoryID, _template.DefaultColumnMatrixAttributeID, _template.DefaultRowMatrixAttributeID);

            _templateAttributes = new Dictionary <string, Attribute>(StringComparer.OrdinalIgnoreCase);
            for (int attributeIndex = 0; attributeIndex < attributes.Length; attributeIndex++)
            {
                var attribute = attributes[attributeIndex];
                _templateAttributes.Add(attribute.AttributeID, new Attribute()
                {
                    AttributeIndex = attributeIndex
                });
            }
        }
        protected virtual IEnumerable viewSegment(PXAdapter adapter)
        {
            var current = Detail.Current;

            if (current != null)
            {
                Segment row;
                if (current.Inherited == true)
                {
                    row = (Segment)PXSelectReadonly2 <Segment,
                                                      InnerJoin <Dimension, On <Dimension.parentDimensionID, Equal <Segment.dimensionID> > >,
                                                      Where <Dimension.dimensionID, Equal <Required <Dimension.dimensionID> >,
                                                             And <Segment.segmentID, Equal <Required <Segment.segmentID> > > > > .
                          Select(this, current.DimensionID, current.SegmentID);
                }
                else
                {
                    row = (Segment)PXSelectReadonly <Segment> .
                          Search <Segment.dimensionID, Segment.segmentID>(this, current.DimensionID, current.SegmentID);
                }
                PXRedirectHelper.TryRedirect(Caches[typeof(Segment)], row, string.Empty);
            }
            return(adapter.Get());
        }