protected virtual IEnumerable addLocation(PXAdapter e)
        {
            if (this.LocationFilter.AskExt((graph, viewName) => graph.Views[viewName].Cache.Clear(), true) == WebDialogResult.OK)
            {
                var source =
                    this.LocationFilter.Current.EndLocationID == null
                                                ? PXSelect <INLocation,
                                                            Where <INLocation.siteID, Equal <Current <INPIClass.siteID> >,
                                                                   And <INLocation.locationCD, GreaterEqual <Required <INLocation.locationCD> > > > >
                    .Select(this,
                            this.LocationFilter.Cache.GetValueExt <INPILocationFilter.startLocationID>(
                                this.LocationFilter.Current).ToString())
                                                : PXSelect
                    <INLocation,
                     Where <INLocation.siteID, Equal <Current <INPIClass.siteID> >,
                            And <INLocation.locationCD, Between <Required <INLocation.locationCD>, Required <INLocation.locationCD> > > > >
                    .Select(this,
                            this.LocationFilter.Cache.GetValueExt <INPILocationFilter.startLocationID>(this.LocationFilter.Current).ToString(),
                            this.LocationFilter.Cache.GetValueExt <INPILocationFilter.endLocationID>(this.LocationFilter.Current).ToString());

                foreach (INLocation l in source)
                {
                    INPIClassLocation item = (INPIClassLocation)Locations.Cache.CreateInstance();
                    item.LocationID = l.LocationID;
                    Locations.Insert(item);
                }
            }
            return(e.Get());
        }
        protected virtual IEnumerable addItem(PXAdapter e)
        {
            if (this.InventoryFilter.AskExt((graph, viewName) => graph.Views[viewName].Cache.Clear(), true) == WebDialogResult.OK)
            {
                var source =
                    this.InventoryFilter.Current.EndInventoryID == null
                                                ? PXSelect <InventoryItem,
                                                            Where <InventoryItem.stkItem, Equal <boolTrue>,
                                                                   And <InventoryItem.itemStatus, NotEqual <InventoryItemStatus.inactive>,
                                                                        And <InventoryItem.itemStatus, NotEqual <InventoryItemStatus.markedForDeletion>,
                                                                             And <InventoryItem.inventoryCD, GreaterEqual <Required <InventoryItem.inventoryCD> > > > > > >
                    .Select(this,
                            this.InventoryFilter.Cache.GetValueExt <INPIInventoryFilter.startInventoryID>(
                                this.InventoryFilter.Current).ToString())
                                                : PXSelect <InventoryItem,
                                                            Where <InventoryItem.stkItem, Equal <boolTrue>,
                                                                   And <InventoryItem.itemStatus, NotEqual <InventoryItemStatus.inactive>,
                                                                        And <InventoryItem.itemStatus, NotEqual <InventoryItemStatus.markedForDeletion>,
                                                                             And <InventoryItem.inventoryCD, Between <Required <InventoryItem.inventoryCD>, Required <InventoryItem.inventoryCD> > > > > > >
                    .Select(this,
                            this.InventoryFilter.Cache.GetValueExt <INPIInventoryFilter.startInventoryID>(this.InventoryFilter.Current).ToString(),
                            this.InventoryFilter.Cache.GetValueExt <INPIInventoryFilter.endInventoryID>(this.InventoryFilter.Current).ToString());

                foreach (InventoryItem l in source)
                {
                    INPIClassItem item = (INPIClassItem)Items.Cache.CreateInstance();
                    if (Items.Locate(item) == null)
                    {
                        item.InventoryID = l.InventoryID;
                        Items.Insert(item);
                    }
                }
            }
            return(e.Get());
        }
Beispiel #3
0
        protected virtual IEnumerable addLocation(PXAdapter e)
        {
            if (this.LocationFilter.AskExt((graph, viewName) => graph.Views[viewName].Cache.Clear(), true) == WebDialogResult.OK)
            {
                var source =
                    this.LocationFilter.Current.EndLocationID == null
                                                ? PXSelectReadonly <INLocation,
                                                                    Where <INLocation.siteID, Equal <Current <INPIClass.siteID> >,
                                                                           And <INLocation.locationCD, GreaterEqual <Required <INLocation.locationCD> > > > >
                    .Select(this,
                            this.LocationFilter.Cache.GetValueExt <INPILocationFilter.startLocationID>(
                                this.LocationFilter.Current).ToString())
                                                : PXSelectReadonly
                    <INLocation,
                     Where <INLocation.siteID, Equal <Current <INPIClass.siteID> >,
                            And <INLocation.locationCD, Between <Required <INLocation.locationCD>, Required <INLocation.locationCD> > > > >
                    .Select(this,
                            this.LocationFilter.Cache.GetValueExt <INPILocationFilter.startLocationID>(this.LocationFilter.Current).ToString(),
                            this.LocationFilter.Cache.GetValueExt <INPILocationFilter.endLocationID>(this.LocationFilter.Current).ToString());

                HashSet <int?> existingLocations = PXSelect <INPIClassLocation,
                                                             Where <INPIClassLocation.pIClassID, Equal <Current <INPIClass.pIClassID> > > > .Select(this)
                                                   .Select(l => ((INPIClassLocation)l).LocationID)
                                                   .Where(l => l.HasValue)
                                                   .ToHashSet();

                foreach (INLocation l in source.RowCast <INLocation>().Where(s => !existingLocations.Contains(s.LocationID)))
                {
                    INPIClassLocation item = (INPIClassLocation)Locations.Cache.CreateInstance();
                    item.LocationID = l.LocationID;
                    Locations.Insert(item);
                }
            }
            return(e.Get());
        }
        private void InsertUpdateCustomerBillingSetup(PXCache cache, Customer customerRow, FSxCustomer fsxCustomerRow)
        {
            FSSetup fsSetupRow = PXSelect <FSSetup> .Select(Base);

            if (fsSetupRow != null &&
                fsSetupRow.CustomerMultipleBillingOptions == false)
            {
                FSCustomerBillingSetup fsCustomerBillingSetupRow = CustomerBillingCycles.Select();

                if (fsxCustomerRow.BillingCycleID == null)
                {
                    CustomerBillingCycles.Delete(fsCustomerBillingSetupRow);
                    return;
                }

                if (fsCustomerBillingSetupRow == null)
                {
                    fsCustomerBillingSetupRow            = CustomerBillingCycles.Insert(new FSCustomerBillingSetup());
                    fsCustomerBillingSetupRow.SrvOrdType = null;
                }

                fsCustomerBillingSetupRow.BillingCycleID     = fsxCustomerRow.BillingCycleID;
                fsCustomerBillingSetupRow.SendInvoicesTo     = fsxCustomerRow.SendInvoicesTo;
                fsCustomerBillingSetupRow.BillShipmentSource = fsxCustomerRow.BillShipmentSource;
                fsCustomerBillingSetupRow.FrequencyType      = ID.Frequency_Type.NONE;

                CustomerBillingCycles.Update(fsCustomerBillingSetupRow);
            }
        }
        private void InitBAccount(BAccount row)
        {
            //Inserting Address record
            if (row.DefAddressID == null)
            {
                var addressOldDirty = AddressCurrent.Cache.IsDirty;
                var addr            = (Address)AddressCurrent.Cache.CreateInstance();
                addr.BAccountID              = row.BAccountID;
                addr                         = AddressCurrent.Insert(addr);
                row.DefAddressID             = addr.AddressID;
                AddressCurrent.Cache.IsDirty = addressOldDirty;
            }

            // Inserting Default Contact record
            if (row.DefContactID == null)
            {
                var contactsOldDirty = Contacts.Cache.IsDirty;
                var contact          = (Contact)Contacts.Cache.CreateInstance();
                contact.ContactType    = ContactTypesAttribute.BAccountProperty;
                contact.BAccountID     = row.BAccountID;
                contact                = Contacts.Insert(contact);
                row.DefContactID       = contact.ContactID;
                Contacts.Cache.IsDirty = contactsOldDirty;
            }

            // Inserting delivery locaiton record
            if (row.DefLocationID == null)
            {
                var locationOldDirty = Locations.Cache.IsDirty;
                var location         = (Location)Locations.Cache.CreateInstance();
                location.BAccountID = row.BAccountID;
                // Location CD need to be formatted accorfing to segmented key mask prior inserting
                object cd = PXMessages.LocalizeNoPrefix(Messages.DefaultLocationCD);
                Locations.Cache.RaiseFieldUpdating <Location.locationCD>(location, ref cd);
                location.LocationCD = (string)cd;

                location.LocType = LocTypeList.CustomerLoc;
                switch (row.Type)
                {
                case BAccountType.VendorType:
                    location.LocType = LocTypeList.VendorLoc;
                    break;

                case BAccountType.CombinedType:
                    location.LocType = LocTypeList.CombinedLoc;
                    break;
                }
                location.Descr               = PXMessages.LocalizeNoPrefix(Messages.DefaultLocationDescription);
                location.IsDefault           = true;
                location.DefAddressID        = row.DefAddressID;
                location.IsAddressSameAsMain = true;
                location.DefContactID        = row.DefContactID;
                location.IsContactSameAsMain = true;
                location                = (Location)Locations.Cache.Insert(location);
                row.DefLocationID       = location.LocationID;
                Locations.Cache.IsDirty = locationOldDirty;
            }
        }
Beispiel #6
0
		protected virtual void FixedAsset_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
		{
			FixedAsset assetClass = (FixedAsset)e.Row;
			if (assetClass == null) return;

			if (assetClass.AssetCD != null)
			{
				foreach (FABookSettings settings in PXSelect<FABook>.Select(this).RowCast<FABook>().Select(book => new FABookSettings { BookID = book.BookID }))
				{
					DepreciationSettings.Insert(settings);
				}

				DepreciationSettings.Cache.IsDirty = false;
			}
		}
Beispiel #7
0
        protected virtual void ARInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            ARInvoice row = (ARInvoice)e.Row;

            if (row != null && !String.IsNullOrEmpty(row.DocType) &&
                !String.IsNullOrEmpty(row.RefNbr))
            {
                CCPayments.Insert(row);
                CCPayments.Update(row);
                CCPayments.Delete(row);

                CCPayments.View.Insert(row);
                CCPayments.View.Update(row);
                CCPayments.View.Delete(row);
            }
        }
        protected virtual void Carrier_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            Carrier row = e.Row as Carrier;

            if (row != null)
            {
                foreach (CSBox box in DefaultBoxes.Select())
                {
                    CarrierPackage package = new CarrierPackage();
                    package.CarrierID = row.CarrierID;
                    package.BoxID     = box.BoxID;

                    CarrierPackages.Insert(package);
                }
                CarrierPackages.Cache.IsDirty = false;
            }
        }
        protected virtual void ContractDetail_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            if (!IsImport)
            {
                ContractDetail row = e.Row as ContractDetail;
                if (row != null)
                {
                    ContractItem contractItem = PXSelect <ContractItem, Where <ContractItem.contractItemID, Equal <Required <ContractDetail.contractItemID> > > > .Select(this, row.ContractItemID);

                    if (contractItem != null && contractItem.Deposit == false && contractItem.DepositItemID != null)
                    {
                        ContractItem depositItem = PXSelect <ContractItem, Where <ContractItem.contractItemID, Equal <Required <ContractDetail.contractItemID> > > > .Select(this, contractItem.DepositItemID);

                        ContractDetail newDetail = new ContractDetail();
                        sender.SetValueExt <ContractDetail.contractItemID>(newDetail, depositItem.ContractItemID);
                        ContractDetails.Insert(newDetail);
                        ContractDetails.View.RequestRefresh();
                    }
                }
            }
        }
		private void DoConvert(CustomerPaymentMethod cpm, CCProcessingCenter newCCPC)
		{
			CCProcessingCenterPmntMethod newProcessingCenterPM = PXSelect<CCProcessingCenterPmntMethod,
				Where<CCProcessingCenterPmntMethod.paymentMethodID, Equal<Required<CCProcessingCenterPmntMethod.paymentMethodID>>,
				And<CCProcessingCenterPmntMethod.processingCenterID, Equal<Required<CCProcessingCenterPmntMethod.processingCenterID>>>>>.Select(this, cpm.PaymentMethodID, newCCPC.ProcessingCenterID);
			if (newProcessingCenterPM == null)
			{
				newProcessingCenterPM = (CCProcessingCenterPmntMethod)ProcessingCenterPM.Cache.CreateInstance();
				newProcessingCenterPM.PaymentMethodID = cpm.PaymentMethodID;
				newProcessingCenterPM.ProcessingCenterID = newCCPC.ProcessingCenterID;
				ProcessingCenterPM.Insert(newProcessingCenterPM);
			}

			CustomerPaymentMethod currCPM = (CustomerPaymentMethod)CustomerPM.Cache.CreateCopy(cpm);
			var oldCCProcessingCenterID = currCPM.CCProcessingCenterID;
			currCPM.CCProcessingCenterID = newCCPC.ProcessingCenterID;
			if (currCPM.CustomerCCPID == null)
			{
				CustomerPM.Cache.SetDefaultExt<CustomerPaymentMethod.customerCCPID>(currCPM);
			}
			currCPM.Selected = true;
			currCPM = CustomerPM.Update(currCPM);
			CustomerPM.Current = currCPM;

			PXResultset<PaymentMethodDetail> oldDetails = PMDetails.Select(currCPM.PaymentMethodID);
			foreach (PaymentMethodDetail oldDetail in oldDetails)
			{
				PaymentMethodDetail newDetail = (PaymentMethodDetail)PMDetails.Cache.CreateCopy(oldDetail);
				newDetail.ValidRegexp = null;
				PMDetails.Update(newDetail);
			}

			PaymentMethod CurrPM = PM.Select();
			PaymentMethodDetail CCPID = FindCCPID(CurrPM);

			if (CCPID == null)
			{
				using (PXTransactionScope ts = new PXTransactionScope())
				{
					PaymentMethodDetail res;
					CCPID = (PaymentMethodDetail)PMDetails.Cache.CreateInstance();
					CCPID.PaymentMethodID = currCPM.PaymentMethodID;
					CCPID.UseFor = PaymentMethodDetailUsage.UseForARCards;
					CCPID.DetailID = "CCPID";
					CCPID.Descr = Messages.PaymentProfileID;
					CCPID.IsCCProcessingID = true;
					CCPID.IsRequired = true;
					res = PMDetails.Insert(CCPID);
					if (res == null)
					{
						throw new PXException(Messages.CouldNotInsertPMDetail);
					}
					else
					{
						PMDetails.Cache.Persist(PXDBOperation.Insert);
					}
					ts.Complete();
				}
			}

			CCProcessingCenter procCenter = PXSelect<CCProcessingCenter,
				Where<CCProcessingCenter.processingCenterID, Equal<Required<CCProcessingCenter.processingCenterID>>>>
					.Select(this, oldCCProcessingCenterID);
			bool oldProcCenterSupportTokenizing = ProcCenterSupportTokenizing(oldCCProcessingCenterID);
			bool newProcCenterSupportTokenizing = ProcCenterSupportTokenizing(newCCPC.ProcessingCenterID);

			if (!oldProcCenterSupportTokenizing && newProcCenterSupportTokenizing)
			{
				CustomerPaymentMethodDetail newCCPIDPM = PXSelect<CustomerPaymentMethodDetail,
					Where<CustomerPaymentMethodDetail.pMInstanceID, Equal<Required<CustomerPaymentMethodDetail.pMInstanceID>>,
						And<CustomerPaymentMethodDetail.paymentMethodID, Equal<Required<CustomerPaymentMethodDetail.paymentMethodID>>,
						And<CustomerPaymentMethodDetail.detailID, Equal<Required<CustomerPaymentMethodDetail.detailID>>>>>>
							.Select(this, currCPM.PMInstanceID, currCPM.PaymentMethodID, CCPID.DetailID);
				if (newCCPIDPM != null)
				{
					newCCPIDPM.Value = null;
					CustomerPMDetails.Update(newCCPIDPM);
				}
				else
				{
					newCCPIDPM = new CustomerPaymentMethodDetail
					{
						PMInstanceID = currCPM.PMInstanceID,
						PaymentMethodID = currCPM.PaymentMethodID,
						DetailID = CCPID.DetailID
					};
					CustomerPMDetails.Insert(newCCPIDPM);
				}
				var graph = PXGraph.CreateInstance<CCCustomerInformationManagerGraph>();
				ICCPaymentProfileAdapter paymentProfile = new GenericCCPaymentProfileAdapter<CustomerPaymentMethod>(CustomerPM);
				ICCPaymentProfileDetailAdapter profileDetail = new GenericCCPaymentProfileDetailAdapter<CustomerPaymentMethodDetail,
					PaymentMethodDetail>(CustomerPMDetails, PMDetails);
				DateTime expiredDate;
				if (CheckCardIsExpired(currCPM, out expiredDate))
				{
					Customer cust =  new PXSelect<Customer, 
						Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>(this)
							.SelectSingle(currCPM.BAccountID);
					throw new PXException(AR.Messages.ERR_CCCreditCardHasExpired, expiredDate.ToString("d"), cust.AcctCD);
				}
				graph.GetOrCreatePaymentProfile(this, paymentProfile, profileDetail);
			}

			if (newProcCenterSupportTokenizing)
			{
				if (currCPM.CustomerCCPID == null)
				{
					currCPM.CustomerCCPID = cpm.CustomerCCPID;
				}
				CustomerProcessingCenterID newCustomerProcessingCenterID = new CustomerProcessingCenterID
				{
					CCProcessingCenterID = newCCPC.ProcessingCenterID,
					BAccountID = cpm.BAccountID,
					CustomerCCPID = currCPM.CustomerCCPID
				};
				AddCustomerProcessingCenterIfNeeded(newCustomerProcessingCenterID);
			}
			currCPM = CustomerPM.Update(currCPM);
		}
        public void ConvertCustomerPaymentMethod(CustomerPaymentMethod cpm, CCProcessingCenter newCCPC)
        {
            CCProcessingCenterPmntMethod newProcessingCenterPM = PXSelect <CCProcessingCenterPmntMethod,
                                                                           Where <CCProcessingCenterPmntMethod.paymentMethodID, Equal <Required <CCProcessingCenterPmntMethod.paymentMethodID> >,
                                                                                  And <CCProcessingCenterPmntMethod.processingCenterID, Equal <Required <CCProcessingCenterPmntMethod.processingCenterID> > > > > .Select(this, cpm.PaymentMethodID, newCCPC.ProcessingCenterID);

            if (newProcessingCenterPM == null)
            {
                newProcessingCenterPM = (CCProcessingCenterPmntMethod)ProcessingCenterPM.Cache.CreateInstance();
                newProcessingCenterPM.PaymentMethodID    = cpm.PaymentMethodID;
                newProcessingCenterPM.ProcessingCenterID = newCCPC.ProcessingCenterID;
                ProcessingCenterPM.Insert(newProcessingCenterPM);
            }

            CustomerPaymentMethod currCPM = (CustomerPaymentMethod)CustomerPM.Cache.CreateCopy(cpm);
            var oldCCProcessingCenterID   = currCPM.CCProcessingCenterID;

            currCPM.CCProcessingCenterID = newCCPC.ProcessingCenterID;
            if (currCPM.CustomerCCPID == null)
            {
                CustomerPM.Cache.SetDefaultExt <CustomerPaymentMethod.customerCCPID>(currCPM);
            }
            currCPM.Selected   = true;
            currCPM            = CustomerPM.Update(currCPM);
            CustomerPM.Current = currCPM;

            PXResultset <PaymentMethodDetail> oldDetails = PMDetails.Select(currCPM.PaymentMethodID);

            foreach (PaymentMethodDetail oldDetail in oldDetails)
            {
                PaymentMethodDetail newDetail = (PaymentMethodDetail)PMDetails.Cache.CreateCopy(oldDetail);
                newDetail.ValidRegexp = null;
                PMDetails.Update(newDetail);
            }

            PaymentMethod       CurrPM = PM.Select();
            PaymentMethodDetail CCPID  = FindCCPID(CurrPM);

            if (CCPID == null)
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    PaymentMethodDetail res;
                    CCPID = (PaymentMethodDetail)PMDetails.Cache.CreateInstance();
                    CCPID.PaymentMethodID  = currCPM.PaymentMethodID;
                    CCPID.UseFor           = PaymentMethodDetailUsage.UseForARCards;
                    CCPID.DetailID         = "CCPID";
                    CCPID.Descr            = Messages.PaymentProfileID;
                    CCPID.IsCCProcessingID = true;
                    CCPID.IsRequired       = true;
                    res = PMDetails.Insert(CCPID);
                    if (res == null)
                    {
                        throw new PXException(Messages.CouldNotInsertPMDetail);
                    }
                    else
                    {
                        PMDetails.Cache.Persist(PXDBOperation.Insert);
                    }
                    ts.Complete();
                }
            }

            CCProcessingCenter procCenter = PXSelect <CCProcessingCenter,
                                                      Where <CCProcessingCenter.processingCenterID, Equal <Required <CCProcessingCenter.processingCenterID> > > >
                                            .Select(this, oldCCProcessingCenterID);

            bool doesOldProcCenterSupportTokenizing = CCProcessingFeatureHelper.IsFeatureSupported(procCenter, CCProcessingFeature.ProfileManagement);
            bool doesNewProcCenterSupportTokenizing = CCProcessingFeatureHelper.IsFeatureSupported(newCCPC, CCProcessingFeature.ProfileManagement);

            if (!doesOldProcCenterSupportTokenizing && doesNewProcCenterSupportTokenizing)
            {
                CustomerPaymentMethodDetail newCCPIDPM = PXSelect <CustomerPaymentMethodDetail,
                                                                   Where <CustomerPaymentMethodDetail.pMInstanceID, Equal <Required <CustomerPaymentMethodDetail.pMInstanceID> >,
                                                                          And <CustomerPaymentMethodDetail.paymentMethodID, Equal <Required <CustomerPaymentMethodDetail.paymentMethodID> >,
                                                                               And <CustomerPaymentMethodDetail.detailID, Equal <Required <CustomerPaymentMethodDetail.detailID> > > > > >
                                                         .Select(this, currCPM.PMInstanceID, currCPM.PaymentMethodID, CCPID.DetailID);

                if (newCCPIDPM != null)
                {
                    newCCPIDPM.Value = null;
                    CustomerPMDetails.Update(newCCPIDPM);
                }
                else
                {
                    newCCPIDPM = new CustomerPaymentMethodDetail
                    {
                        PMInstanceID    = currCPM.PMInstanceID,
                        PaymentMethodID = currCPM.PaymentMethodID,
                        DetailID        = CCPID.DetailID
                    };
                    CustomerPMDetails.Insert(newCCPIDPM);
                }
                var graph = PXGraph.CreateInstance <CCCustomerInformationManagerGraph>();
                graph.GetOrCreatePaymentProfile(this, new GenericCustomerPaymentMethodAdaper <CustomerPaymentMethod>(CustomerPM),
                                                new GenericCustomerPaymentMethodDetailAdapter <CustomerPaymentMethodDetail>(CustomerPMDetails));
            }

            if (doesNewProcCenterSupportTokenizing)
            {
                if (currCPM.CustomerCCPID == null)
                {
                    currCPM.CustomerCCPID = cpm.CustomerCCPID;
                }
                CustomerProcessingCenterID newCustomerProcessingCenterID = new CustomerProcessingCenterID
                {
                    CCProcessingCenterID = newCCPC.ProcessingCenterID,
                    BAccountID           = cpm.BAccountID,
                    CustomerCCPID        = currCPM.CustomerCCPID
                };
                AddCustomerProcessingCenterIfNeeded(newCustomerProcessingCenterID);
            }
            currCPM = CustomerPM.Update(currCPM);
            this.Save.Press();
        }
Beispiel #12
0
        public void ConvertCustomerPaymentMethod(CustomerPaymentMethod cpm, CCProcessingCenter newCCPC)
        {
            CCProcessingCenterPmntMethod newProcessingCenterPM = PXSelect <CCProcessingCenterPmntMethod,
                                                                           Where <CCProcessingCenterPmntMethod.paymentMethodID, Equal <Required <CCProcessingCenterPmntMethod.paymentMethodID> >,
                                                                                  And <CCProcessingCenterPmntMethod.processingCenterID, Equal <Required <CCProcessingCenterPmntMethod.processingCenterID> > > > > .Select(this, cpm.PaymentMethodID, newCCPC.ProcessingCenterID);

            if (newProcessingCenterPM == null)
            {
                newProcessingCenterPM = (CCProcessingCenterPmntMethod)ProcessingCenterPM.Cache.CreateInstance();
                newProcessingCenterPM.PaymentMethodID    = cpm.PaymentMethodID;
                newProcessingCenterPM.ProcessingCenterID = newCCPC.ProcessingCenterID;
                ProcessingCenterPM.Insert(newProcessingCenterPM);
            }

            CustomerPaymentMethod currCPM = (CustomerPaymentMethod)CustomerPM.Cache.CreateCopy(cpm);

            currCPM.CCProcessingCenterID = newCCPC.ProcessingCenterID;
            CustomerPM.Cache.SetDefaultExt <CustomerPaymentMethod.customerCCPID>(currCPM);

            currCPM.Selected   = true;
            currCPM            = CustomerPM.Update(currCPM);
            CustomerPM.Current = currCPM;

            PXResultset <PaymentMethodDetail> oldDetails = PMDetails.Select(currCPM.PaymentMethodID);

            foreach (PaymentMethodDetail oldDetail in oldDetails)
            {
                PaymentMethodDetail newDetail = (PaymentMethodDetail)PMDetails.Cache.CreateCopy(oldDetail);
                newDetail.ValidRegexp = null;
                PMDetails.Update(newDetail);
            }

            PaymentMethod       CurrPM = PM.Select();
            PaymentMethodDetail CCPID  = FindCCPID(CurrPM);

            if (CCPID == null)
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    PaymentMethodDetail res;
                    CCPID = (PaymentMethodDetail)PMDetails.Cache.CreateInstance();
                    CCPID.PaymentMethodID  = currCPM.PaymentMethodID;
                    CCPID.UseFor           = PaymentMethodDetailUsage.UseForARCards;
                    CCPID.DetailID         = "CCPID";
                    CCPID.Descr            = "Payment Profile ID";
                    CCPID.IsCCProcessingID = true;
                    CCPID.IsRequired       = true;
                    res = PMDetails.Insert(CCPID);
                    if (res == null)
                    {
                        throw new PXException(Messages.CouldNotInsertPMDetail);
                    }
                    else
                    {
                        PMDetails.Cache.Persist(PXDBOperation.Insert);
                    }
                    ts.Complete();
                }
            }

            CustomerPaymentMethodDetail newCCPIDPM = PXSelect <CustomerPaymentMethodDetail, Where <CustomerPaymentMethodDetail.pMInstanceID, Equal <Required <CustomerPaymentMethodDetail.pMInstanceID> >,
                                                                                                   And <CustomerPaymentMethodDetail.paymentMethodID, Equal <Required <CustomerPaymentMethodDetail.paymentMethodID> >,
                                                                                                        And <CustomerPaymentMethodDetail.detailID, Equal <Required <CustomerPaymentMethodDetail.detailID> > > > > > .Select(this, currCPM.PMInstanceID, currCPM.PaymentMethodID, CCPID.DetailID);

            if (newCCPIDPM != null)
            {
                newCCPIDPM.Value = null;
                CustomerPMDetails.Update(newCCPIDPM);
            }
            else
            {
                newCCPIDPM = new CustomerPaymentMethodDetail();
                newCCPIDPM.PMInstanceID    = currCPM.PMInstanceID;
                newCCPIDPM.PaymentMethodID = currCPM.PaymentMethodID;
                newCCPIDPM.DetailID        = CCPID.DetailID;
                CustomerPMDetails.Insert(newCCPIDPM);
            }

            CustomerPaymentMethodMaint.SyncNewPMI(this, CustomerPM, CustomerPMDetails);
            currCPM.Converted = true;
            currCPM           = CustomerPM.Update(currCPM);
            this.Save.Press();
        }
Beispiel #13
0
        protected virtual void LoadPOOrdersByFilter()
        {
            var orderSelect = new PXSelect <POOrder,
                                            Where <POOrder.status, In3 <POOrderStatus.open, POOrderStatus.completed>,
                                                   And <POOrder.orderType, In3 <POOrderType.regularOrder, POOrderType.dropShip> > > >(Base);

            var filter = LoadOrders.Current;

            if (filter.BranchID != null)
            {
                orderSelect.WhereAnd <Where <POOrder.branchID, Equal <Current <LoadOrdersFilter.branchID> > > >();
            }

            if (filter.FromDate != null)
            {
                orderSelect.WhereAnd <Where <POOrder.orderDate, GreaterEqual <Current <LoadOrdersFilter.fromDate> > > >();
            }

            if (filter.ToDate != null)
            {
                orderSelect.WhereAnd <Where <POOrder.orderDate, LessEqual <Current <LoadOrdersFilter.toDate> > > >();
            }

            if (filter.StartOrderNbr != null)
            {
                orderSelect.WhereAnd <Where <POOrder.orderNbr, GreaterEqual <Current <LoadOrdersFilter.startOrderNbr> > > >();
            }

            if (filter.EndOrderNbr != null)
            {
                orderSelect.WhereAnd <Where <POOrder.orderNbr, LessEqual <Current <LoadOrdersFilter.endOrderNbr> > > >();
            }

            if (PXAccess.FeatureInstalled <FeaturesSet.vendorRelations>())
            {
                orderSelect.WhereAnd <Where <POOrder.payToVendorID, Equal <Current <APPayment.vendorID> > > >();
            }
            else
            {
                orderSelect.WhereAnd <Where <POOrder.vendorID, Equal <Current <APPayment.vendorID> > > >();
            }

            orderSelect.WhereAnd <Where <POOrder.curyUnprepaidTotal, Greater <decimal0> > >();

            if (filter.OrderBy == LoadOrdersFilter.orderBy.ByDate)
            {
                orderSelect.OrderByNew <OrderBy <Asc <POOrder.orderDate, Asc <POOrder.orderNbr> > > >();
            }
            else
            {
                orderSelect.OrderByNew <OrderBy <Asc <POOrder.orderNbr> > >();
            }

            var orders = orderSelect.SelectWindowed(0, filter.MaxNumberOfDocuments ?? 0, filter);

            foreach (POOrder order in orders)
            {
                var newAdjustment = new POAdjust()
                {
                    AdjgDocType   = Base.Document.Current.DocType,
                    AdjgRefNbr    = Base.Document.Current.RefNbr,
                    AdjdOrderType = order.OrderType,
                    AdjdOrderNbr  = order.OrderNbr,
                    AdjdDocType   = POAdjust.EmptyApDocType,
                    AdjdRefNbr    = string.Empty,
                    AdjNbr        = Base.Document.Current.AdjCntr
                };

                POAdjust oldAdjustment = new PXSelect <POAdjust,
                                                       Where <POAdjust.adjgDocType, Equal <Current <POAdjust.adjgDocType> >,
                                                              And <POAdjust.adjgRefNbr, Equal <Current <POAdjust.adjgRefNbr> >,
                                                                   And <POAdjust.adjdOrderType, Equal <Required <POAdjust.adjdOrderType> >,
                                                                        And <POAdjust.adjdOrderNbr, Equal <Required <POAdjust.adjdOrderNbr> >,
                                                                             And <POAdjust.released, Equal <False>,
                                                                                  And <POAdjust.isRequest, Equal <False> > > > > > > >(Base)
                                         .Select(newAdjustment.AdjdOrderType, newAdjustment.AdjdOrderNbr);

                if (oldAdjustment == null)
                {
                    newAdjustment = POAdjustments.Insert(newAdjustment);
                }
                else
                {
                    POAdjustments.Cache.RaiseFieldDefaulting <POAdjust.curyAdjgAmt>(oldAdjustment, out object newValue);
                    if ((decimal?)newValue < oldAdjustment.CuryAdjgAmt)
                    {
                        var copy = POAdjustments.Cache.CreateCopy(oldAdjustment);
                        POAdjustments.Cache.SetValueExt <POAdjust.curyAdjgAmt>(copy, newValue);
                        POAdjustments.Cache.Update(copy);
                    }
                }
            }
        }