private PXResultset <JointPayeePayment> GetJointPayeePayments(string documentType, string referenceNumber)
        {
            var query = new PXSelectJoin <JointPayeePayment,
                                          InnerJoin <JointPayee, On <JointPayee.jointPayeeId, Equal <JointPayeePayment.jointPayeeId> >,
                                                     LeftJoin <Vendor, On <Vendor.bAccountID, Equal <JointPayee.jointPayeeInternalId> > > >,
                                          Where <JointPayeePayment.paymentDocType, Equal <Required <JointPayeePayment.paymentDocType> >,
                                                 And <JointPayeePayment.paymentRefNbr, Equal <Required <JointPayeePayment.paymentRefNbr> >,
                                                      And <JointPayeePayment.jointAmountToPay, Greater <decimal0> > > > >(paymentEntry);

            return(query.Select(documentType, referenceNumber));
        }
Ejemplo n.º 2
0
 protected virtual void PoOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs arguments,
                                            PXRowSelected baseHandler)
 {
     if (!(arguments.Row is POOrder))
     {
         return;
     }
     baseHandler(cache, arguments);
     ComplianceDocuments.Select();
     ComplianceDocuments.AllowInsert = !Base.Document.Cache.Inserted.Any_();
 }
Ejemplo n.º 3
0
        public IEnumerable branches()
        {
            foreach (PXResult <Branch, Ledger> res in PXSelectJoin <Branch, InnerJoin <Ledger, On <Ledger.ledgerID, Equal <Branch.ledgerID> > >, Where <Ledger.consolAllowed, Equal <True>, And <Ledger.postInterCompany, Equal <True>, And <Where <Ledger.defBranchID, IsNull, Or <Branch.branchID, NotEqual <Ledger.defBranchID> > > > > > > .Select(this))
            {
                Branch result = res;
                Ledger ledger = res;
                result.LedgerCD = ledger.LedgerCD;

                yield return(result);
            }
        }
Ejemplo n.º 4
0
 protected virtual void ArPayment_RowSelected(PXCache cache, PXRowSelectedEventArgs arguments,
                                              PXRowSelected baseHandler)
 {
     if (arguments.Row is ARPayment)
     {
         baseHandler(cache, arguments);
         Base.Document.Cache.AllowUpdate = true;
         ComplianceDocuments.Select();
         ComplianceDocuments.AllowInsert = !Base.Document.Cache.Inserted.Any_();
     }
 }
        protected virtual void TaxBucketLine_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            foreach (PXResult <TaxReportLine, TaxBucketLine> res in PXSelectJoin <TaxReportLine, LeftJoin <TaxBucketLine, On <TaxBucketLine.vendorID, Equal <TaxReportLine.vendorID>, And <TaxBucketLine.lineNbr, Equal <TaxReportLine.lineNbr> > > >, Where <TaxReportLine.vendorID, Equal <Required <TaxReportLine.vendorID> >, And <TaxReportLine.tempLineNbr, Equal <Required <TaxReportLine.tempLineNbr> > > > > .Select(this, ((TaxBucketLine)e.Row).VendorID, ((TaxBucketLine)e.Row).LineNbr))
            {
                TaxBucketLine new_bucket = PXCache <TaxBucketLine> .CreateCopy((TaxBucketLine)e.Row);

                new_bucket.LineNbr = ((TaxReportLine)res).LineNbr;
                BucketLine.Cache.Insert(new_bucket);
            }
            BucketLine.Cache.Current = e.Row;
        }
Ejemplo n.º 6
0
        public virtual IEnumerable contracts()
        {
            ExpiringContractFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <Contract> select = new PXSelectJoin <Contract
                                                                   , InnerJoin <ContractBillingSchedule, On <Contract.contractID, Equal <ContractBillingSchedule.contractID> >
                                                                                , InnerJoin <Customer, On <Customer.bAccountID, Equal <Contract.customerID> > > >,
                                                                   Where <Contract.baseType, Equal <CTPRType.contract>,
                                                                          And <Contract.expireDate, LessEqual <Current <ExpiringContractFilter.endDate> >,
                                                                               And <Contract.expireDate, GreaterEqual <Current <ExpiringContractFilter.beginDate> >,
                                                                                    And <Contract.status, NotEqual <Contract.status.canceled> > > > > >(this);

                if (filter.ShowAutoRenewable != true)
                {
                    select.WhereAnd <Where <Contract.autoRenew, Equal <False>, Or <Contract.autoRenew, IsNull> > >();
                }

                if (!string.IsNullOrEmpty(filter.CustomerClassID))
                {
                    select.WhereAnd <Where <Customer.customerClassID, Equal <Current <ExpiringContractFilter.customerClassID> > > >();
                }

                if (filter.TemplateID != null)
                {
                    select.WhereAnd <Where <Contract.templateID, Equal <Current <ExpiringContractFilter.templateID> > > >();
                }

                /*
                 * Expiring Contracts has a hierarchical structure and we need to show only the latest expiring node hidding
                 * all of its original contracts
                 */
                foreach (PXResult <Contract> result in select.Select())
                {
                    bool skipItem = false;
                    if (((Contract)result).Type == Contract.type.Expiring)
                    {
                        Contract child = PXSelect <Contract, Where <Contract.originalContractID, Equal <Required <Contract.originalContractID> > > > .Select(this, ((Contract)result).ContractID);

                        skipItem = child != null;
                    }

                    if (!skipItem)
                    {
                        yield return(result);
                    }
                }
            }
            else
            {
                yield break;
            }
        }
Ejemplo n.º 7
0
 public static PXResultset <CustomerPaymentMethodDetail> GetAllCustomersCardsInProcCenter(PXGraph graph, int?BAccountID, string CCProcessingCenterID)
 {
     return(PXSelectJoin <CustomerPaymentMethodDetail,
                          InnerJoin <PaymentMethodDetail, On <CustomerPaymentMethodDetail.paymentMethodID, Equal <PaymentMethodDetail.paymentMethodID>,
                                                              And <CustomerPaymentMethodDetail.detailID, Equal <PaymentMethodDetail.detailID> > >,
                                     InnerJoin <CustomerPaymentMethod,
                                                On <CustomerPaymentMethodDetail.pMInstanceID, Equal <CustomerPaymentMethod.pMInstanceID> > > >,
                          Where <CustomerPaymentMethod.bAccountID, Equal <Required <CustomerPaymentMethod.bAccountID> >,
                                 And <CustomerPaymentMethod.cCProcessingCenterID, Equal <Required <CustomerPaymentMethod.cCProcessingCenterID> >,
                                      And <PaymentMethodDetail.isCCProcessingID, Equal <True> > > > > .Select(graph, BAccountID, CCProcessingCenterID));
 }
Ejemplo n.º 8
0
        public virtual int?GetLaborClass(PMTimeActivity activity)
        {
            CRCase refCase = PXSelectJoin <CRCase,
                                           InnerJoin <CRActivityLink,
                                                      On <CRActivityLink.refNoteID, Equal <CRCase.noteID> > >,
                                           Where <CRActivityLink.noteID, Equal <Required <PMTimeActivity.refNoteID> > > > .Select(graph, activity.RefNoteID);

            EPEmployee employee = PXSelect <EPEmployee> .Search <EPEmployee.userID>(graph, activity.OwnerID);

            return(GetLaborClass(activity, employee, refCase));
        }
        protected virtual IEnumerable result()
        {
            PXSelectBase <CABankTran> cmd = new PXSelectJoin <CABankTran, LeftJoin <CABankTranMatch,
                                                                                    On <CABankTranMatch.tranID, Equal <CABankTran.tranID>,
                                                                                        And <CABankTranMatch.tranType, Equal <CABankTran.tranType> > >,
                                                                                    LeftJoin <CATran, On <CATran.tranID, Equal <CABankTranMatch.cATranID> > > >,
                                                              Where <CABankTran.cashAccountID, Equal <Current <Filter.cashAccountID> >,
                                                                     And <CABankTran.tranDate, GreaterEqual <Current <Filter.startDate> >,
                                                                          And <CABankTran.tranDate, LessEqual <Current <Filter.endDate> >,
                                                                               And <CABankTran.tranType, Equal <Current <Filter.tranType> >,
                                                                                    And <CABankTran.processed, Equal <True>,
                                                                                         And <Where <CABankTran.headerRefNbr, Equal <Current <Filter.headerRefNbr> >, Or <Current <Filter.headerRefNbr>, IsNull> > > > > > > > >(this);

            foreach (PXResult <CABankTran, CABankTranMatch, CATran> res in cmd.Select())
            {
                CABankTran      tran  = (CABankTran)res;
                CABankTranMatch match = (CABankTranMatch)res;
                tran.MatchedToInvoice = CABankTranStatus.IsMatchedToInvoice(tran, match);
                CATran catran = (CATran)res;
                if (catran.OrigModule == null)
                {
                    catran.OrigModule = match.DocModule;
                }
                if (catran.OrigTranType == null)
                {
                    catran.OrigTranType = match.DocType;
                }
                if (catran.OrigRefNbr == null)
                {
                    catran.OrigRefNbr = match.DocRefNbr;
                }
                if (catran.ReferenceID == null)
                {
                    catran.ReferenceID = tran.BAccountID;
                }
                if (catran.OrigModule == null)
                {
                    catran.OrigModule = match.DocModule;
                }
                if (catran.OrigTranType == null)
                {
                    catran.OrigTranType = match.DocType;
                }
                if (catran.OrigRefNbr == null)
                {
                    catran.OrigRefNbr = match.DocRefNbr;
                }
                if (catran.ReferenceID == null)
                {
                    catran.ReferenceID = tran.BAccountID;
                }
                yield return(res);
            }
        }
 protected virtual IAddressBase GetToAddress(APInvoice invoice)
 {
     return
         (PXSelectJoin <Branch,
                        InnerJoin <BAccountR, On <BAccountR.bAccountID, Equal <Branch.bAccountID> >,
                                   InnerJoin <Address, On <Address.addressID, Equal <BAccountR.defAddressID> > > >,
                        Where <Branch.branchID, Equal <Required <Branch.branchID> > > >
          .Select(Base, invoice.BranchID)
          .RowCast <Address>()
          .FirstOrDefault());
 }
        protected virtual void _(Events.RowDeleting <KNSIKCRelationship> e)
        {
            if (!(e.Row is KNSIKCRelationship row))
            {
                return;
            }

            if (RelatedConfigurableItems.Select().Any())
            {
                throw new PXException(KCMessages.RelatedConfigurableItemExistsException);
            }
        }
Ejemplo n.º 12
0
        //TODO: need optimizae DB requests
        internal static bool?IsFromInternalUser(PXGraph graph, CRSMEmail message)
        {
            var @from = EmailParser.ParseAddresses(message.MailFrom).FirstOrDefault().With(_ => _?.Address).With(_ => _?.Trim());

            PXSelect <Users,
                      Where2 <
                          Where <Users.guest, Equal <False>, Or <Users.guest, IsNull> >,
                          And <Users.email, Equal <Required <Users.email> > > > >
            .Clear(graph);

            var users = PXSelect <Users,
                                  Where2 <
                                      Where <Users.guest, Equal <False>, Or <Users.guest, IsNull> >,
                                      And <Users.email, Equal <Required <Users.email> > > > >
                        .Select(graph, @from);

            bool disabledUser = users.Count > 0 && users.RowCast <Users>().All(_ => _.State == Users.state.Disabled);

            if (disabledUser)
            {
                return(null);
            }

            PXSelectJoin <EPEmployee,
                          LeftJoin <Contact,
                                    On <Contact.contactID, Equal <EPEmployee.defContactID> > >,
                          Where <
                              EPEmployee.userID, IsNotNull,
                              And <Contact.eMail, Equal <Required <Contact.eMail> > > > >
            .Clear(graph);

            var employees = PXSelectJoin <EPEmployee,
                                          LeftJoin <Contact,
                                                    On <Contact.contactID, Equal <EPEmployee.defContactID> > >,
                                          Where <
                                              EPEmployee.userID, IsNotNull,
                                              And <Contact.eMail, Equal <Required <Contact.eMail> > > > >
                            .Select(graph, @from);

            bool disabledEmployee = employees.Count > 0 && employees.RowCast <EPEmployee>().All(_ => _.Status == BAccount.status.Inactive || !(_.RouteEmails ?? false));

            if (disabledEmployee)
            {
                return(null);
            }

            if (users.Count > 0 || employees.Count > 0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 13
0
        private void UpdateOriginalSingleSchedule(ARRegister originalDocument, decimal amount)
        {
            foreach (PXResult <ARTran, InventoryItem, INComponent, DRDeferredCode> item in ARTransactionWithItems.Select())
            {
                ARTran         artran        = item;
                InventoryItem  inventoryItem = item;
                INComponent    component     = item;
                DRDeferredCode deferredCode  = item;

                UpdateOriginalSchedule(artran, deferredCode, amount, originalDocument.DocDate, originalDocument.FinPeriodID, originalDocument.CustomerID, originalDocument.CustomerLocationID);
            }
        }
        public virtual IEnumerable Unmatch(PXAdapter adapter)
        {
            CABankTran detail = Details.Current;

            if (detail.DocumentMatched == true)
            {
                if (detail.Processed == true)
                {
                    if (Details.Ask(Messages.ClearMatch, Messages.UnmatchTranMsg, MessageButtons.OKCancel) == WebDialogResult.Cancel)
                    {
                        return(adapter.Get());
                    }
                    detail.Processed = false;
                }
                foreach (CABankTranMatch match in TranMatch.Select(detail.TranID))
                {
                    if (match.DocModule == GL.BatchModule.AP && match.DocType == CATranType.CABatch)
                    {
                        foreach (CATran tran in CATransInBatch.Select(match.DocRefNbr))
                        {
                            if (tran != null && tran.TranID != null && tran.ReconNbr == null)
                            {
                                tran.ClearDate = null;
                                tran.Cleared   = false;
                                CATransInBatch.Update(tran);
                            }
                        }
                    }
                    else
                    {
                        CATran tran = CATrans.Select(match.CATranID);
                        if (tran != null && tran.TranID != null && tran.ReconNbr == null)
                        {
                            tran.ClearDate = null;
                            tran.Cleared   = false;
                            CATrans.Update(tran);
                        }
                    }
                    TranMatch.Delete(match);
                }
                foreach (var adj in TranAdj.Select(detail.TranID))
                {
                    TranAdj.Delete(adj);
                }
                foreach (var split in CABankTranSplits.Select(detail.TranID))
                {
                    CABankTranSplits.Delete(split);
                }
                CABankTransactionsMaint.ClearFields(detail);
                Details.Update(detail);
            }
            return(adapter.Get());
        }
Ejemplo n.º 15
0
        public static int?FetchLocation(PXGraph graph, int?vendorID, int?itemID, int?subItemID, int?siteID)
        {
            BAccountR company = PXSelectJoin <BAccountR,
                                              InnerJoin <Branch, On <Branch.bAccountID, Equal <BAccountR.bAccountID> > >,
                                              Where <BAccountR.bAccountID, Equal <Required <BAccountR.bAccountID> > > > .Select(graph, vendorID);

            if (company != null)
            {
                return(company.DefLocationID);
            }

            var rec = (PXResult <INItemSiteSettings, POVendorInventory>)
                      PXSelectJoin <INItemSiteSettings,
                                    LeftJoin <POVendorInventory,
                                              On <POVendorInventory.inventoryID, Equal <INItemSiteSettings.inventoryID>,
                                                  And <POVendorInventory.active, Equal <boolTrue>,
                                                       And <POVendorInventory.vendorID, Equal <Required <Vendor.bAccountID> >,
                                                            And <Where <POVendorInventory.subItemID, Equal <Required <POVendorInventory.subItemID> >,
                                                                        Or <POVendorInventory.subItemID, Equal <INItemSiteSettings.defaultSubItemID>,
                                                                            Or <POVendorInventory.subItemID, IsNull,
                                                                                Or <Where <Required <POVendorInventory.subItemID>, IsNull,
                                                                                           And <POVendorInventory.subItemID, Equal <True> > > > > > > > > > > >,
                                    Where <INItemSiteSettings.inventoryID, Equal <Required <INItemSiteSettings.inventoryID> >,
                                           And <INItemSiteSettings.siteID, Equal <Required <INItemSiteSettings.siteID> > > >,
                                    OrderBy <Asc <POVendorInventory.lastPrice,
                                                  Asc <Switch <Case <Where <POVendorInventory.subItemID, Equal <INItemSiteSettings.defaultSubItemID> >, boolTrue>, boolFalse>,
                                                       Asc <Switch <Case <Where <POVendorInventory.vendorLocationID, IsNull>, boolTrue>, boolFalse> > > > > >
                      .SelectWindowed(graph, 0, 1, vendorID, subItemID, subItemID, itemID, siteID);

            if (rec == null)
            {
                return(null);
            }
            POVendorInventory  i    = rec;
            INItemSiteSettings site = rec;

            if (i.VendorLocationID != null)
            {
                return(i.VendorLocationID);
            }

            Vendor vendor = PXSelectReadonly <Vendor, Where <Vendor.bAccountID, Equal <Required <Vendor.bAccountID> > > > .Select(graph, vendorID);

            if (site.PreferredVendorID == vendorID)
            {
                return(site.PreferredVendorLocationID ?? (vendor != null ? vendor.DefLocationID : null));
            }
            if (vendor != null && vendor.BAccountID == vendorID)
            {
                return(vendor.DefLocationID);
            }
            return(null);
        }
Ejemplo n.º 16
0
 private IEnumerable <Recipient> EnumerateRecipientsForLeads(EntityHelper helper)
 {
     // emails only for selected (should be cached)
     foreach (var(contact, lead) in Leads
              .Select()
              .ToList()
              .Select(i => (contact: i.GetItem <Contact>(), lead: i.GetItem <CRLead>()))
              .Where(i => i.contact.Selected == true))
     {
         yield return(Recipient.SmartCreate(helper, contact, lead: lead));
     }
 }
Ejemplo n.º 17
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)
        {
            InventoryItem     item        = null;
            INItemCost        cost        = null;
            POVendorInventory vendorPrice = null;

            foreach (PXResult <InventoryItem, INItemCost, POVendorInventory> r in
                     PXSelectJoin <InventoryItem,
                                   LeftJoin <INItemCost, On <INItemCost.inventoryID, Equal <InventoryItem.inventoryID> >,
                                             LeftJoin <POVendorInventory,
                                                       On <POVendorInventory.inventoryID, Equal <InventoryItem.inventoryID>,
                                                           And <POVendorInventory.active, Equal <boolTrue>,
                                                                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> >, boolTrue>, boolFalse>,
                                            Asc <Switch <Case <Where <POVendorInventory.subItemID, Equal <InventoryItem.defaultSubItemID> >, boolTrue>, boolFalse>,
                                                 Asc <Switch <Case <Where <POVendorInventory.vendorLocationID, IsNull>, boolTrue>, boolFalse>,
                                                      Asc <InventoryItem.inventoryCD> > > > > >
                     .Select(graph, vendorID, curyID, subItemID, subItemID, uom, vendorLocationID, inventoryID))
            {
                item        = r;
                cost        = r;
                vendorPrice = r;
                if (vendorPrice != null)
                {
                    break;
                }
            }
            if (vendorPrice != null && vendorPrice.VendorID != null)
            {
                Decimal price = vendorPrice.LastPrice ?? 0m;
                if (price != 0m)
                {
                    return(new ItemCost(item, vendorPrice.PurchaseUnit, curyID, price, false));
                }
            }

            return
                ((onlyVendor ? null : FetchLastCost(graph, item, docDate)) ??
                 (onlyVendor ? null : FetchSiteLastCost(graph, item, cost, siteID)) ??
                 new ItemCost(item, 0));
        }
        private IEnumerable <ComplianceDocument> GetRelatedComplianceDocuments(
            string adjustmentReferenceNumber, string adjustmentDocumentType)
        {
            var query = new PXSelectJoin <ComplianceDocument,
                                          InnerJoin <ComplianceDocumentReference,
                                                     On <ComplianceDocumentReference.complianceDocumentReferenceId, Equal <ComplianceDocument.billID> > >,
                                          Where <ComplianceDocumentReference.type, Equal <Required <APInvoice.docType> >,
                                                 And <ComplianceDocumentReference.referenceNumber, Equal <Required <APInvoice.refNbr> >,
                                                      And <ComplianceDocument.linkToPayment, Equal <True> > > > >(graph);

            return(query.Select(adjustmentDocumentType, adjustmentReferenceNumber).FirstTableItems.ToList());
        }
Ejemplo n.º 19
0
        protected virtual IEnumerable insert(PXAdapter adapter)
        {
            GLWorkBook wb = WorkBook.Select();

            if (wb.SingleOpenVoucherBatch == true)
            {
                int unreleasedCount = PXSelect <GLVoucherBatch,
                                                Where <GLVoucherBatch.workBookID, Equal <Required <GLWorkBook.workBookID> >,
                                                       And <GLVoucherBatch.released, Equal <False> > > > .Select(this, wb.WorkBookID).Count;

                if (unreleasedCount > 0)
                {
                    throw new PXException(Messages.OnlyOneUnreleasedBatchAllowed);
                }
            }
            if (BatchCreation.View.Answer == WebDialogResult.None)
            {
                BatchCreation.Cache.Clear();
            }
            if (BatchCreation.AskExt() == WebDialogResult.OK)
            {
                if (VoucherBatches.Current != null)
                {
                    VoucherBatches.Cache.RaiseExceptionHandling <GLVoucherBatch.voucherBatchNbr>(VoucherBatches.Current, VoucherBatches.Current.VoucherBatchNbr, null);
                }
                GLVoucherBatch batch = new GLVoucherBatch();
                batch.Descr = BatchCreation.Current.BatchDescription;
                Numbering numbering        = Numbering.Select();
                bool      isManualNumberig = numbering != null && numbering.UserNumbering == true;
                if (isManualNumberig)
                {
                    batch.VoucherBatchNbr = BatchCreation.Current.VoucherBatchNbr;
                }
                batch = VoucherBatches.Insert(batch);
                this.VoucherBatches.Current = batch;
                Save.Press();
                editRecord.Press();
            }
            return(adapter.Get());
        }
Ejemplo n.º 20
0
        protected virtual void Users_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            Users   oldRow = e.OldRow as Users;
            Users   row    = e.Row as Users;
            Contact c      = PXSelect <Contact, Where <Contact.userID, Equal <Current <Users.pKID> > > > .SelectSingleBound(this, new object[] { row });

            if (row == null || oldRow == null || row.Guest == oldRow.Guest || c == null)
            {
                return;
            }

            c.UserID = null;
            contact.Update(c);

            EPEmployee emp = Employee.Select(c.ContactID);

            if (emp != null)
            {
                emp = PXCache <EPEmployee> .CreateCopy(emp);

                emp.UserID = null;
                Employee.Update(emp);
            }

            foreach (EPCompanyTreeMember member in Members.View.SelectMultiBound(new[] { e.Row }))
            {
                Members.Delete(member);
            }
        }
        protected virtual void WZTask_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            WZTask row = e.Row as WZTask;

            if (row == null)
            {
                return;
            }

            if (this.Actions.Contains("CancelClose"))
            {
                this.Actions["CancelClose"].SetTooltip(Messages.BackToScenario);
            }

            PXUIFieldAttribute.SetEnabled <WZTask.details>(Tasks.Cache, row, false);
            PXUIFieldAttribute.SetEnabled <WZTask.assignedTo>(Tasks.Cache, row, false);
            bool canBeComplete = row.Status == WizardTaskStatusesAttribute._ACTIVE || row.Status == WizardTaskStatusesAttribute._OPEN;
            bool canBeReopened = row.Status == WizardTaskStatusesAttribute._COMPLETED;

            markAsComplete.SetEnabled(canBeComplete);
            skip.SetVisible(false);
            if (row.IsOptional == true)
            {
                skip.SetVisible(true);
                skip.SetEnabled(!(row.Status == WizardTaskStatusesAttribute._SKIPPED || row.Status == WizardTaskStatusesAttribute._COMPLETED));
            }


            startTask.SetEnabled(row.Status == WizardTaskStatusesAttribute._OPEN);

            SubTasks.AllowUpdate     = false;
            Predecessors.AllowUpdate = false;
            Successors.AllowUpdate   = false;

            var predecessors = Predecessors.Select();
            var successors   = Successors.Select();
            var subTasks     = SubTasks.Select();

            if (predecessors.Count == 0)
            {
                Predecessors.Cache.AllowSelect = false;
            }
            if (successors.Count == 0)
            {
                Successors.Cache.AllowSelect = false;
            }
            if (subTasks.Count == 0)
            {
                SubTasks.Cache.AllowSelect = false;
            }
            goToScreen.SetVisible(row.ScreenID != null);
        }
Ejemplo n.º 22
0
        public virtual IEnumerable ViewAllocationRule(PXAdapter adapter)
        {
            AllocationMaint graph = CreateInstance <AllocationMaint>();
            PMAllocation    row   = PXSelectJoin <
                PMAllocation
                , InnerJoin <PMAllocationSourceTran, On <PMAllocation.allocationID, Equal <PMAllocationSourceTran.allocationID> > >
                , Where <PMAllocationSourceTran.tranID, Equal <Required <PMTran.refNbr> > >
                > .Select(this, source.Current.TranID);

            graph.Allocations.Current = row;
            PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
            return(adapter.Get());
        }
Ejemplo n.º 23
0
        public PXResultset <ARTaxTran> RetrieveARTaxTransactions(string orderType, string orderNbr)
        {
            var taxTrans =
                PXSelectJoin <ARTaxTran,
                              InnerJoin <SOOrderShipment,
                                         On <ARTaxTran.refNbr, Equal <SOOrderShipment.invoiceNbr>,
                                             And <ARTaxTran.tranType, Equal <SOOrderShipment.invoiceType> > > >,
                              Where <SOOrderShipment.orderType, Equal <Required <SOOrderShipment.orderType> >,
                                     And <SOOrderShipment.orderNbr, Equal <Required <SOOrderShipment.orderNbr> > > > >
                .Select(_graph, orderType, orderNbr);

            return(taxTrans);
        }
Ejemplo n.º 24
0
		private static bool IsProcessingCenterDeprecated(PXGraph graph, int? pmInstanceID)
		{
			const string DeprecatedProcessingCenterTypeName = "PX.CCProcessing.AuthorizeNetTokenizedProcessing";
			if (pmInstanceID == null)
			{
				return false;
			}
			CCProcessingCenter processingCenter = (CCProcessingCenter)PXSelectJoin<CCProcessingCenter, 
					InnerJoin<CustomerPaymentMethod, On<CCProcessingCenter.processingCenterID, Equal<CustomerPaymentMethod.cCProcessingCenterID>>>,
					Where<CustomerPaymentMethod.pMInstanceID, Equal<Required<CustomerPaymentMethod.pMInstanceID>>>>
				.Select(graph, pmInstanceID);
			return string.Equals(processingCenter?.ProcessingTypeName, DeprecatedProcessingCenterTypeName);
		}
Ejemplo n.º 25
0
        /// <summary>
        /// Add the Employee(s) info as a recipient(s) in the Email template generated by Appointment.
        /// </summary>
        private static void AddEmployeeStaffRecipient(AppointmentEntry graphAppointmentEntry,
                                                      int?bAccountID,
                                                      string type,
                                                      NotificationRecipient recSetup,
                                                      RecipientList recipients)
        {
            NotificationRecipient recipient = null;
            Contact contactRow = null;

            if (type == BAccountType.EmployeeType)
            {
                contactRow = PXSelectJoin <Contact,
                                           InnerJoin <BAccount,
                                                      On <
                                                          BAccount.parentBAccountID, Equal <Contact.bAccountID>,
                                                          And <BAccount.defContactID, Equal <Contact.contactID> > > >,
                                           Where <
                                               BAccount.bAccountID, Equal <Required <BAccount.bAccountID> >,
                                               And <
                                                   BAccount.type, Equal <Required <BAccount.type> > > > >
                             .Select(graphAppointmentEntry, bAccountID, type);
            }
            else if (type == BAccountType.VendorType)
            {
                contactRow = PXSelectJoin <Contact,
                                           InnerJoin <BAccount,
                                                      On <
                                                          Contact.contactID, Equal <BAccount.defContactID> > >,
                                           Where <
                                               BAccount.bAccountID, Equal <Required <BAccount.bAccountID> >,
                                               And <
                                                   BAccount.type, Equal <Required <BAccount.type> > > > >
                             .Select(graphAppointmentEntry, bAccountID, type);
            }

            if (contactRow != null && contactRow.EMail != null)
            {
                recipient = new NotificationRecipient()
                {
                    Active = true,
                    Email  = contactRow.EMail,
                    Hidden = recSetup.Hidden,
                    Format = recSetup.Format
                };

                if (recipient != null)
                {
                    recipients.Add(recipient);
                }
            }
        }
Ejemplo n.º 26
0
        public IEnumerable masterView()
        {
            MasterTable mt = new MasterTable();

            if (PXView.Filters != null && PXView.Filters.Length > 0)
            {
                PhoneCallerAudit pca = new PhoneCallerAudit();

                for (int i = 0; i < PXView.Filters.Length; i++)
                {
                    var fr = PXView.Filters[i];
                    if (fr.DataField == "PhoneNbr")
                    {
                        pca.PhoneNubmer = fr.Value.ToString();

                        mt.PhoneNbr = pca.PhoneNubmer;
                    }
                    if (fr.DataField == "CallerID")
                    {
                        pca.CallerID = fr.Value.ToString();
                        mt.CallerID  = pca.CallerID;
                    }
                }
                PXResultset <BAccount> resultset = PXSelectJoin <BAccount,
                                                                 InnerJoin <Contact, On <Contact.bAccountID, Equal <BAccount.bAccountID> > >,
                                                                 Where <Contact.phone1, Equal <Required <Contact.phone1> > > > .Select(this, pca.PhoneNubmer);

                if (resultset.Count > 0)
                {
                    PXResult <BAccount, Contact> res = (PXResult <BAccount, Contact>)resultset[0];
                    Contact  contact = res;
                    BAccount bacct   = res;
                    pca.ContactID = contact.ContactID;
                    if (bacct != null)
                    {
                        mt.AcctName = bacct.AcctName;
                    }
                }
                if (savingRequired)
                {
                    Audit.Insert(pca);
                    //Caches[typeof(PhoneCallerAudit)].Persist(PXDBOperation.Insert);
                    Save.Press();
                    savingRequired = false;
                }
            }
            List <MasterTable> result = new List <MasterTable>();

            result.Add(mt);
            return(result);
        }
Ejemplo n.º 27
0
        protected virtual void PaymentMethod_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
        {
            PaymentMethod row    = (PaymentMethod)e.Row;
            PaymentMethod oldRow = (PaymentMethod)e.OldRow;

            if (oldRow.PaymentType != row.PaymentType)
            {
                foreach (PaymentMethodDetail iDet in this.Details.Select())
                {
                    this.Details.Cache.Delete(iDet);
                }
                if (row.PaymentType == PaymentMethodType.CreditCard)
                {
                    this.fillCreditCardDefaults();
                }
                row.ARIsOnePerCustomer = row.PaymentType == PaymentMethodType.CashOrCheck;
            }

            if ((oldRow.UseForAR != row.UseForAR) && row.UseForAR.GetValueOrDefault(false) == false)
            {
                row.ARIsProcessingRequired = false;

                foreach (PaymentMethodAccount pma in CashAccounts.Select())
                {
                    pma.UseForAR = pma.ARIsDefault = pma.ARIsDefaultForRefund = false;
                    CashAccounts.Update(pma);
                }
            }

            if ((oldRow.UseForAP != row.UseForAP) && row.UseForAP.GetValueOrDefault(false) == false)
            {
                foreach (PaymentMethodAccount pma in CashAccounts.Select())
                {
                    pma.UseForAP = pma.APIsDefault = false;
                    CashAccounts.Update(pma);
                }
            }
        }
Ejemplo n.º 28
0
        protected virtual void Users_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            Contact c = (Contact)contact.View.SelectSingleBound(new object[] { e.Row });

            if (c != null)
            {
                c.UserID = null;
                contact.Update(c);

                EPEmployee emp = Employee.Select(c.ContactID);
                if (emp != null)
                {
                    emp = PXCache <EPEmployee> .CreateCopy(emp);

                    emp.UserID = null;
                    Employee.Update(emp);
                }
            }
            foreach (EPCompanyTreeMember member in Members.View.SelectMultiBound(new[] { e.Row }))
            {
                Members.Delete(member);
            }
        }
Ejemplo n.º 29
0
        protected virtual IEnumerable defaultCompanyContact()
        {
            List <int> branches = PXAccess.GetMasterBranchID(Accessinfo.BranchID);

            foreach (PXResult <Branch, BAccountR, Contact> res in PXSelectJoin <Branch,
                                                                                LeftJoin <BAccountR, On <Branch.bAccountID, Equal <BAccountR.bAccountID> >,
                                                                                          LeftJoin <Contact, On <BAccountR.defContactID, Equal <Contact.contactID> > > >,
                                                                                Where <Branch.branchID, Equal <Required <Branch.branchID> > > > .Select(this, branches != null ? (int?)branches[0] : null))
            {
                yield return((Contact)res);

                break;
            }
        }
        protected virtual CR.Standalone.Location GetBranchLocation(POOrder order)
        {
            PXSelectBase <Branch> select = new PXSelectJoin
                                           <Branch, InnerJoin <BAccountR, On <BAccountR.bAccountID, Equal <Branch.bAccountID> >,
                                                               InnerJoin <CR.Standalone.Location, On <CR.Standalone.Location.bAccountID, Equal <BAccountR.bAccountID>, And <CR.Standalone.Location.locationID, Equal <BAccountR.defLocationID> > > > >,
                                            Where <Branch.branchID, Equal <Required <Branch.branchID> > > >(Base);

            foreach (PXResult <Branch, BAccountR, CR.Standalone.Location> res in select.Select(order.BranchID))
            {
                return((CR.Standalone.Location)res);
            }

            return(null);
        }
Ejemplo n.º 31
0
		protected override void ApplyAvalaraTax(ARInvoice invoice, GetTaxResult result)
		{
			TaxZone taxZone = (TaxZone)taxzone.View.SelectSingleBound(new object[] { invoice });
			AP.Vendor vendor = PXSelect<AP.Vendor, Where<AP.Vendor.bAccountID, Equal<Required<AP.Vendor.bAccountID>>>>.Select(this, taxZone.TaxVendorID);

			if (vendor == null)
				throw new PXException("Tax Vendor is required but not found for the External TaxZone.");

			Dictionary<string, ARTaxTran> existingRows = new Dictionary<string, ARTaxTran>();
			foreach (PXResult<ARTaxTran, Tax> res in Taxes.View.SelectMultiBound(new object[] { invoice }))
			{
				ARTaxTran taxTran = (ARTaxTran)res;
				existingRows.Add(taxTran.TaxID.Trim().ToUpperInvariant(), taxTran);
			}

			this.Views.Caches.Add(typeof(Tax));

			bool requireControlTotal = ARSetup.Current.RequireControlTotal == true;

			if (invoice.Hold != true)
				ARSetup.Current.RequireControlTotal = false;

			try
			{

				for (int i = 0; i < result.TaxSummary.Count; i++)
				{
					string taxID = result.TaxSummary[i].TaxName.ToUpperInvariant();

					//Insert Tax if not exists - just for the selectors sake
					Tax tx = PXSelect<Tax, Where<Tax.taxID, Equal<Required<Tax.taxID>>>>.Select(this, taxID);
					if (tx == null)
					{
						tx = new Tax();
						tx.TaxID = taxID;
						//tx.Descr = string.Format("Avalara {0} {1}%", taxID, Convert.ToDecimal(result.TaxSummary[i].Rate)*100);
						tx.Descr = string.Format("Avalara {0}", taxID);
						tx.TaxType = CSTaxType.Sales;
						tx.TaxCalcType = CSTaxCalcType.Doc;
						tx.TaxCalcLevel = CSTaxCalcLevel.CalcOnItemAmt;
						tx.TaxApplyTermsDisc = CSTaxTermsDiscount.ToTaxableAmount;
						tx.SalesTaxAcctID = vendor.SalesTaxAcctID;
						tx.SalesTaxSubID = vendor.SalesTaxSubID;
						tx.ExpenseAccountID = vendor.TaxExpenseAcctID;
						tx.ExpenseSubID = vendor.TaxExpenseSubID;
						tx.TaxVendorID = taxZone.TaxVendorID;

						this.Caches[typeof(Tax)].Insert(tx);
					}

					ARTaxTran existing = null;
					existingRows.TryGetValue(taxID, out existing);

					if (existing != null)
					{
						existing.TaxAmt = Math.Abs(result.TaxSummary[i].Tax);
						existing.CuryTaxAmt = Math.Abs(result.TaxSummary[i].Tax);
						existing.TaxableAmt = Math.Abs(result.TaxSummary[i].Taxable);
						existing.CuryTaxableAmt = Math.Abs(result.TaxSummary[i].Taxable);
						existing.TaxRate = Convert.ToDecimal(result.TaxSummary[i].Rate);

						Taxes.Update(existing);
						existingRows.Remove(existing.TaxID.Trim().ToUpperInvariant());
					}
					else
					{
						ARTaxTran tax = new ARTaxTran();
						tax.Module = BatchModule.AR;
						tax.TranType = invoice.DocType;
						tax.RefNbr = invoice.RefNbr;
						tax.TaxID = taxID;
						tax.TaxAmt = Math.Abs(result.TaxSummary[i].Tax);
						tax.CuryTaxAmt = Math.Abs(result.TaxSummary[i].Tax);
						tax.TaxableAmt = Math.Abs(result.TaxSummary[i].Taxable);
						tax.CuryTaxableAmt = Math.Abs(result.TaxSummary[i].Taxable);
						tax.TaxRate = Convert.ToDecimal(result.TaxSummary[i].Rate);
						tax.TaxType = "S";
						tax.TaxBucketID = 0;
						tax.AccountID = vendor.SalesTaxAcctID;
						tax.SubID = vendor.SalesTaxSubID;

						Taxes.Insert(tax);
					}
				}

				foreach (ARTaxTran taxTran in existingRows.Values)
				{
					Taxes.Delete(taxTran);
				}

				SOInvoice soInvoice = PXSelect<SOInvoice, Where<SOInvoice.docType, Equal<Required<SOInvoice.docType>>, And<SOInvoice.refNbr, Equal<Required<SOInvoice.refNbr>>>>>.Select(this, invoice.DocType, invoice.RefNbr);

				invoice.CuryTaxTotal = Math.Abs(result.TotalTax);
				Document.Cache.SetValueExt<ARInvoice.isTaxSaved>(invoice, true);
			}
			finally
			{
				ARSetup.Current.RequireControlTotal = requireControlTotal;
			}


			if (invoice.ApplyPaymentWhenTaxAvailable == true)
			{
				PXSelectBase<ARAdjust> select = new PXSelectJoin<ARAdjust,
					InnerJoin<ARPayment, On<ARAdjust.adjgDocType, Equal<ARPayment.docType>, And<ARAdjust.adjgRefNbr, Equal<ARPayment.refNbr>>>>,
					Where<ARAdjust.adjdDocType, Equal<Required<ARInvoice.docType>>,
					And<ARAdjust.adjdRefNbr, Equal<Required<ARInvoice.refNbr>>>>>(this);


				foreach (PXResult<ARAdjust, ARPayment> res in select.Select(invoice.DocType, invoice.RefNbr))
				{
					ARAdjust row = (ARAdjust)res;
					ARPayment payment = (ARPayment)res;

					ARAdjust copy = PXCache<ARAdjust>.CreateCopy(row);
					copy.CuryAdjdAmt = Math.Min(copy.CuryAdjdAmt.GetValueOrDefault(), invoice.CuryDocBal.GetValueOrDefault());
					Adjustments.Update(copy);
				}
			}

		}
Ejemplo n.º 32
0
		protected virtual IEnumerable GetRecords()
		{
			bool ar = true;
			PXCache cache = this._Graph.Caches[BqlCommand.GetItemType(moduleField)];
			string docType = ARDocType.Invoice;

			if (cache.Current != null )
			{
				docType = (string)cache.GetValue(cache.Current, docTypeField.Name);
				string module = (string)cache.GetValue(cache.Current, moduleField.Name);
				if (module == BatchModule.AP)
					ar = false;
			}

			if (ar)
			{
				PXSelectBase<ARInvoice> select = new 
					PXSelectJoin<ARInvoice, 
					InnerJoin<BAccount, On<BAccount.bAccountID, Equal<ARInvoice.customerID>>>,
					Where<ARInvoice.docType, Equal<Required<ARInvoice.docType>>>>(this._Graph);
				foreach (PXResult<ARInvoice, BAccount> res in select.Select(docType))
				{
					ARInvoice doc = (ARInvoice)res;
					BAccount customer = (BAccount)res;


					string status = null;
					ARDocStatus.ListAttribute x = new ARDocStatus.ListAttribute();
					if (x.ValueLabelDic.ContainsKey(doc.Status))
					{
						status = x.ValueLabelDic[doc.Status];
					}
					

					DRDocumentRecord record = new DRDocumentRecord();
					record.BAccountCD = customer.AcctCD;
					record.RefNbr = doc.RefNbr;
					record.Status = status;
					record.FinPeriodID = doc.FinPeriodID;
					record.DocType = doc.DocType;
					record.DocDate = doc.DocDate;
					record.LocationID = doc.CustomerLocationID;
					record.CuryOrigDocAmt = doc.CuryOrigDocAmt;
					record.CuryID = doc.CuryID;

					yield return record;
				}
			}
			else
			{
				PXSelectBase<APInvoice> select = new
					PXSelectJoin<APInvoice,
					InnerJoin<BAccount, On<BAccount.bAccountID, Equal<APInvoice.vendorID>>>,
					Where<APInvoice.docType, Equal<Required<APInvoice.docType>>>>(this._Graph);
				foreach (PXResult<APInvoice, BAccount> res in select.Select(docType))
				{
					APInvoice doc = (APInvoice)res;
					BAccount customer = (BAccount)res;

					string status = null;
					APDocStatus.ListAttribute x = new APDocStatus.ListAttribute();
					if (x.ValueLabelDic.ContainsKey(doc.Status))
					{
						status = x.ValueLabelDic[doc.Status];
					}

					DRDocumentRecord record = new DRDocumentRecord();
					record.BAccountCD = customer.AcctCD;
					record.RefNbr = doc.RefNbr;
					record.Status = status;
					record.FinPeriodID = doc.FinPeriodID;
					record.DocType = doc.DocType;
					record.DocDate = doc.DocDate;
					record.LocationID = doc.VendorLocationID;
					record.CuryOrigDocAmt = doc.CuryOrigDocAmt;
					record.CuryID = doc.CuryID;

					yield return record;
				}
			}
		}
Ejemplo n.º 33
0
		protected virtual IEnumerable GetRecords()
		{
			bool useOnlyExisting = false;
			PXCache cache = this._Graph.Caches[typeof(DRScheduleDetail)];
			if (cache.Current != null && cache.GetStatus(cache.Current) != PXEntryStatus.Inserted)
			{
				useOnlyExisting = true;
			}


			if (useOnlyExisting)
			{
				PXSelectBase<DRScheduleDetail> select = new PXSelectJoin<DRScheduleDetail,
					LeftJoin<InventoryItem, On<DRScheduleDetail.componentID, Equal<InventoryItem.inventoryID>>>, Where<DRScheduleDetail.scheduleID, Equal<Current<DRScheduleDetail.scheduleID>>>>(this._Graph);

				foreach (PXResult<DRScheduleDetail, InventoryItem> res in select.Select())
				{
					InventoryItem item = (InventoryItem)res;

					if (item.InventoryID != null)
						yield return item;
				}

			}
			else
			{
				foreach (InventoryItem item in PXSelect<InventoryItem>.Select(this._Graph))
				{
					yield return item;
				}
			}

		}
Ejemplo n.º 34
0
		public virtual List<CSBox> GetBoxesByCarrierID(string carrierID)
		{
			List<CSBox> list = new List<CSBox>();
			if (string.IsNullOrEmpty(carrierID))
			{
				foreach (CSBox box in PXSelect<CSBox, Where<CSBox.maxWeight, Greater<decimal0>>>.Select(graph))
				{
					list.Add(box);
				}
			}
			else
			{
				PXSelectBase<CSBox> select = new PXSelectJoin<CSBox,
					InnerJoin<CarrierPackage, On<CSBox.boxID, Equal<CarrierPackage.boxID>>>,
					Where<CarrierPackage.carrierID, Equal<Required<CarrierPackage.carrierID>>,
					And<CSBox.maxWeight, Greater<decimal0>>>, OrderBy<Asc<CSBox.maxWeight>>>(graph);

				foreach (CSBox box in select.Select(carrierID))
				{
					list.Add(box);
				}
			}

			return list;
		}