protected virtual IEnumerable lines() { if (Vendor.Current == null || Vendor.Current.VendorLocationID == null) { yield break; } using (ReadOnlyScope scope = new ReadOnlyScope(Lines.Cache)) { bool reset = !Bidding.Cache.IsDirty; PXResultset <RQRequisitionLineBidding> list = PXSelectJoin <RQRequisitionLineBidding, LeftJoin <RQBidding, On <RQBidding.reqNbr, Equal <RQRequisitionLineBidding.reqNbr>, And <RQBidding.lineNbr, Equal <RQRequisitionLineBidding.lineNbr>, And <RQBidding.vendorID, Equal <Current <RQBiddingVendor.vendorID> >, And <RQBidding.vendorLocationID, Equal <Current <RQBiddingVendor.vendorLocationID> > > > > > >, Where <RQRequisitionLineBidding.reqNbr, Equal <Current <RQBiddingVendor.reqNbr> > > > .Select(this); if (reset) { Lines.Cache.Clear(); } foreach (PXResult <RQRequisitionLineBidding, RQBidding> item in list) { RQRequisitionLineBidding result = PrepareRQRequisitionLineBiddingInViewDelegate(item); yield return(result); } } }
internal void InvokeConfiguration(BuildContext.BaseBuildContext context) { using (var scope = new ReadOnlyScope(this)) { InvokeConfigurationInternal(context); } }
protected virtual IEnumerable filteredItems([PXString] string action) { // MailRecipients.View.RequestRefresh(); if (!String.Equals(Operations.Current.Action, action, StringComparison.OrdinalIgnoreCase)) { FilteredItems.Cache.Clear(); } Operations.Current.Action = action; var mailListID = MailLists.Current.With(ml => ml.MarketingListID); //Dinamic) if (MailLists.Current.With(ml => ml.IsDynamic == true)) { return(CRSubscriptionsSelect.Select(this, mailListID)); } using (ReadOnlyScope s = new ReadOnlyScope(this.Caches <CRMarketingList>())) { CRSubscriptionsSelect.MergeFilters(this, mailListID); } //Remove if (string.Equals(Operations.Current.Action, REMOVE_ACTION, StringComparison.OrdinalIgnoreCase)) { return(this.QuickSelect(RemoveItems.View.BqlSelect, PXView.Filters)); } return(this.QuickSelect(FilteredItems.View.BqlSelect, PXView.Filters)); }
public virtual void RowUpdated(PXCache sender, PXRowUpdatedEventArgs e) { if (_Required && sender.GetValue(e.Row, _FieldOrdinal) == null) { using (ReadOnlyScope rs = new ReadOnlyScope(sender.Graph.Caches[_RecordType])) { object record = sender.Graph.Caches[_RecordType].Insert(); object recordID = sender.Graph.Caches[_RecordType].GetValue(record, _RecordID); sender.SetValue(e.Row, _FieldOrdinal, recordID); } } }
protected virtual void FillPaymentDetails(IPaymentTypeDetailMaster account) { if (account != null) { if (!string.IsNullOrEmpty(account.VPaymentMethodID)) { PaymentMethod paymentTypeDef = PXSelect <PaymentMethod, Where <PaymentMethod.paymentMethodID, Equal <Required <PaymentMethod.paymentMethodID> > > > .Select(this, account.VPaymentMethodID); if (paymentTypeDef != null) { List <PaymentMethodDetail> toAdd = new List <PaymentMethodDetail>(); foreach (PaymentMethodDetail it in this.PaymentTypeDetails.Select(account.VPaymentMethodID)) { VendorPaymentMethodDetail detail = null; foreach (VendorPaymentMethodDetail iPDet in this.PaymentDetails.Select(account.BAccountID, account.LocationID, account.VPaymentMethodID)) { if (iPDet.DetailID == it.DetailID) { detail = iPDet; break; } } if (detail == null) { toAdd.Add(it); } } using (ReadOnlyScope rs = new ReadOnlyScope(this.PaymentDetails.Cache)) { foreach (PaymentMethodDetail it in toAdd) { VendorPaymentMethodDetail detail = new VendorPaymentMethodDetail(); detail.BAccountID = account.BAccountID; detail.LocationID = account.LocationID; detail.PaymentMethodID = account.VPaymentMethodID; detail.DetailID = it.DetailID; detail = this.PaymentDetails.Insert(detail); } if (toAdd.Count > 0) { this.PaymentDetails.View.RequestRefresh(); } } } } } }
private void ActivateAllOpportunityClassProbabilities() { if (OpportunityClass.Current == null) { return; } using (ReadOnlyScope scope = new ReadOnlyScope(OpportunityClassActiveProbabilities.Cache)) { string classID = OpportunityClass.Current.CROpportunityClassID; foreach (CROpportunityProbability probability in OpportunityProbabilities.Select()) { OpportunityClassActiveProbabilities.Insert(new CROpportunityClassProbability() { ClassID = classID, StageID = probability.StageCode }); } } }
private void InitOpportunityProbabilities() { using (ReadOnlyScope scope = new ReadOnlyScope(OpportunityProbabilities.Cache)) { OpportunityProbabilities.Insert(new CROpportunityProbability() { StageCode = "L", Name = Messages.StageProspect, Probability = 0, SortOrder = 0 }); OpportunityProbabilities.Insert(new CROpportunityProbability() { StageCode = "N", Name = Messages.StageNurture, Probability = 5, SortOrder = 5 }); OpportunityProbabilities.Insert(new CROpportunityProbability() { StageCode = "P", Name = Messages.StageQualify, Probability = 10, SortOrder = 10 }); OpportunityProbabilities.Insert(new CROpportunityProbability() { StageCode = "Q", Name = Messages.StageDevelop, Probability = 20, SortOrder = 20 }); OpportunityProbabilities.Insert(new CROpportunityProbability() { StageCode = "V", Name = Messages.StageSolution, Probability = 40, SortOrder = 40 }); OpportunityProbabilities.Insert(new CROpportunityProbability() { StageCode = "A", Name = Messages.StageProof, Probability = 60, SortOrder = 60 }); OpportunityProbabilities.Insert(new CROpportunityProbability() { StageCode = "R", Name = Messages.StageClose, Probability = 80, SortOrder = 80 }); OpportunityProbabilities.Insert(new CROpportunityProbability() { StageCode = "W", Name = Messages.StageDeploy, Probability = 100, SortOrder = 100 }); } }
protected virtual void MergeDetailsWithDefinition(string aPaymentType) { if (aPaymentType != this.mergedPaymentType) { List <PaymentMethodDetail> toAdd = new List <PaymentMethodDetail>(); foreach (PaymentMethodDetail it in this.PMDetails.Select(aPaymentType)) { PaymentTypeInstanceDetail detail = null; foreach (PaymentTypeInstanceDetail iPDet in this.Details.Select()) { if (iPDet.DetailID == it.DetailID) { detail = iPDet; break; } } if (detail == null) { toAdd.Add(it); } } using (ReadOnlyScope rs = new ReadOnlyScope(this.Details.Cache)) { foreach (PaymentMethodDetail it in toAdd) { PaymentTypeInstanceDetail detail = new PaymentTypeInstanceDetail(); detail.DetailID = it.DetailID; detail = this.Details.Insert(detail); } if (toAdd.Count > 0) { this.Details.View.RequestRefresh(); } } this.mergedPaymentType = aPaymentType; } }
protected virtual void FillPaymentDetails(IPaymentTypeDetailMaster account) { if (account != null) { if (!string.IsNullOrEmpty(account.VPaymentMethodID)) { PaymentMethod paymentTypeDef = PXSelect<PaymentMethod, Where<PaymentMethod.paymentMethodID, Equal<Required<PaymentMethod.paymentMethodID>>>>.Select(this, account.VPaymentMethodID); if (paymentTypeDef != null) { List<PaymentMethodDetail> toAdd = new List<PaymentMethodDetail>(); foreach (PaymentMethodDetail it in this.PaymentTypeDetails.Select(account.VPaymentMethodID)) { VendorPaymentMethodDetail detail = null; foreach (VendorPaymentMethodDetail iPDet in this.PaymentDetails.Select(account.BAccountID, account.LocationID, account.VPaymentMethodID)) { if (iPDet.DetailID == it.DetailID) { detail = iPDet; break; } } if (detail == null) { toAdd.Add(it); } } using (ReadOnlyScope rs = new ReadOnlyScope(this.PaymentDetails.Cache)) { foreach (PaymentMethodDetail it in toAdd) { VendorPaymentMethodDetail detail = new VendorPaymentMethodDetail(); detail.BAccountID = account.BAccountID; detail.LocationID = account.LocationID; detail.PaymentMethodID = account.VPaymentMethodID; detail.DetailID = it.DetailID; detail = this.PaymentDetails.Insert(detail); } if (toAdd.Count > 0) { this.PaymentDetails.View.RequestRefresh(); } } } } } }
protected virtual IEnumerable filteredItems([PXString] string action) { // MailRecipients.View.RequestRefresh(); if (!String.Equals(Operations.Current.Action, action, StringComparison.OrdinalIgnoreCase)) { FilteredItems.Cache.Clear(); } Operations.Current.Action = action; var mailListID = MailLists.Current.With(ml => ml.MarketingListID); //Dinamic) if (MailLists.Current.With(ml => ml.IsDynamic == true)) { return(CRSubscriptionsSelect.Select(this, mailListID)); } using (ReadOnlyScope s = new ReadOnlyScope(this.Caches <CRMarketingList>())) { CRSubscriptionsSelect.MergeFilters(this, mailListID); } //Remove if (string.Equals(Operations.Current.Action, REMOVE_ACTION, StringComparison.OrdinalIgnoreCase)) { return(this.QuickSelect(RemoveItems.View.BqlSelect, PXView.Filters)); } //Add var command = FilteredItems.View.BqlSelect; if (MailLists.Current.With(ml => ml.NoCall == true)) { command = command.WhereAnd( typeof(Where <Contact.noCall, IsNull, Or <Contact.noCall, NotEqual <True> > >)); } if (MailLists.Current.With(ml => ml.NoEMail == true)) { command = command.WhereAnd( typeof(Where <Contact.noEMail, IsNull, Or <Contact.noEMail, NotEqual <True> > >)); } if (MailLists.Current.With(ml => ml.NoFax == true)) { command = command.WhereAnd( typeof(Where <Contact.noFax, IsNull, Or <Contact.noFax, NotEqual <True> > >)); } if (MailLists.Current.With(ml => ml.NoMail == true)) { command = command.WhereAnd( typeof(Where <Contact.noMail, IsNull, Or <Contact.noMail, NotEqual <True> > >)); } if (MailLists.Current.With(ml => ml.NoMarketing == true)) { command = command.WhereAnd( typeof(Where <Contact.noMarketing, IsNull, Or <Contact.noMarketing, NotEqual <True> > >)); } if (MailLists.Current.With(ml => ml.NoMassMail == true)) { command = command.WhereAnd( typeof(Where <Contact.noMassMail, IsNull, Or <Contact.noMassMail, NotEqual <True> > >)); } return(this.QuickSelect(command, PXView.Filters)); }
protected virtual IEnumerable lines() { if (Vendor.Current == null || Vendor.Current.VendorLocationID == null) { yield break; } using (ReadOnlyScope scope = new ReadOnlyScope(this.Lines.Cache)) { bool reset = !Bidding.Cache.IsDirty; PXResultset <RQRequisitionLineBidding> list = PXSelectJoin <RQRequisitionLineBidding, LeftJoin <RQBidding, On <RQBidding.reqNbr, Equal <RQRequisitionLineBidding.reqNbr>, And <RQBidding.lineNbr, Equal <RQRequisitionLineBidding.lineNbr>, And <RQBidding.vendorID, Equal <Current <RQBiddingVendor.vendorID> >, And <RQBidding.vendorLocationID, Equal <Current <RQBiddingVendor.vendorLocationID> > > > > > >, Where <RQRequisitionLineBidding.reqNbr, Equal <Current <RQBiddingVendor.reqNbr> > > > .Select(this); if (reset) { this.Lines.Cache.Clear(); } foreach (PXResult <RQRequisitionLineBidding, RQBidding> item in list) { RQRequisitionLineBidding result = item; RQBidding bidding = item; bidding = Bidding.Locate(bidding) ?? item; result = (RQRequisitionLineBidding)this.Lines.Cache.CreateCopy(result); result.QuoteNumber = bidding.QuoteNumber; result.QuoteQty = bidding.QuoteQty ?? 0m; result.CuryInfoID = Vendor.Current.CuryInfoID; result.CuryQuoteUnitCost = bidding.CuryQuoteUnitCost ?? 0m; result.QuoteUnitCost = bidding.QuoteUnitCost ?? 0m; result.CuryQuoteExtCost = bidding.CuryQuoteExtCost ?? 0m; result.QuoteExtCost = bidding.QuoteExtCost ?? 0m; result.MinQty = bidding.MinQty ?? 0m; if (bidding.CuryQuoteUnitCost == null && result.InventoryID != null) { POItemCostManager.ItemCost cost = POItemCostManager.Fetch(this, Vendor.Current.VendorID, Vendor.Current.VendorLocationID, null, (string)Vendor.GetValueExt <RQBiddingVendor.curyID>(Vendor.Current), result.InventoryID, result.SubItemID, null, result.UOM); result.CuryQuoteUnitCost = cost.Convert <RQRequisitionLineBidding.inventoryID, RQRequisitionLineBidding.curyInfoID>(this, result, result.UOM);; } if (result.CuryQuoteUnitCost == null) { result.CuryQuoteUnitCost = 0m; } result = this.Lines.Insert(result) ?? (RQRequisitionLineBidding)this.Lines.Cache.Locate(result); yield return(result); } } }
protected virtual decimal ConvertAmt(string from, string to, string rateType, DateTime effectiveDate, decimal amount) { if (from == to) { return(amount); } decimal result = amount; PXCache curyCache = CarrierRatesDummyCuryInfo.Cache; using (var rs = new ReadOnlyScope(curyCache)) { if (from == Base.Accessinfo.BaseCuryID) { CurrencyInfo ci = new CurrencyInfo(); ci.CuryRateTypeID = rateType; ci.CuryID = to; ci = (CurrencyInfo)curyCache.Insert(ci); ci.SetCuryEffDate(curyCache, effectiveDate); curyCache.Update(ci); PXCurrencyAttribute.CuryConvCury(curyCache, ci, amount, out result); curyCache.Delete(ci); } else if (to == Base.Accessinfo.BaseCuryID) { CurrencyInfo ci = new CurrencyInfo(); ci.CuryRateTypeID = rateType; ci.CuryID = from; ci = (CurrencyInfo)curyCache.Insert(ci); ci.SetCuryEffDate(curyCache, effectiveDate); curyCache.Update(ci); PXCurrencyAttribute.CuryConvBase(curyCache, ci, amount, out result); curyCache.Delete(ci); } else { CurrencyInfo ciFrom = new CurrencyInfo(); ciFrom.CuryRateTypeID = rateType; ciFrom.CuryID = from; ciFrom = (CurrencyInfo)curyCache.Insert(ciFrom); ciFrom.SetCuryEffDate(curyCache, effectiveDate); curyCache.Update(ciFrom); decimal inBase; PXCurrencyAttribute.CuryConvBase(curyCache, ciFrom, amount, out inBase, true); CurrencyInfo ciTo = new CurrencyInfo(); ciTo.CuryRateTypeID = rateType; ciTo.CuryID = to; ciTo = (CurrencyInfo)curyCache.Insert(ciTo); ciTo.SetCuryEffDate(curyCache, effectiveDate); curyCache.Update(ciFrom); PXCurrencyAttribute.CuryConvCury(curyCache, ciTo, inBase, out result, true); curyCache.Delete(ciFrom); curyCache.Delete(ciTo); } } return(result); }
public override void DefaultContact <TContact, TContactID>(PXCache sender, object documentRow, object contactRow) { PXView view = null; object parm = null; BqlCommand select; if (sender.GetValue <FSManufacturer.contactID>(documentRow) != null) { parm = sender.GetValue <FSManufacturer.contactID>(documentRow); select = BqlCommand.CreateInstance(typeof( Select2 <Contact, LeftJoin <FSContact, On < FSContact.bAccountID, Equal <Contact.bAccountID>, And <FSContact.bAccountContactID, Equal <Contact.contactID>, And <FSContact.revisionID, Equal <Contact.revisionID>, And <FSContact.isDefaultContact, Equal <boolTrue> > > > > >, Where < Contact.contactID, Equal <Required <FSManufacturer.contactID> > > >)); view = sender.Graph.TypedViews.GetView(select, false); } else if (sender.GetValue <FSManufacturer.locationID>(documentRow) != null) { parm = sender.GetValue <FSManufacturer.locationID>(documentRow); select = BqlCommand.CreateInstance(typeof( Select2 <Contact, LeftJoin <Location, On < Location.locationID, Equal <Required <FSManufacturer.locationID> > >, LeftJoin <FSContact, On < FSContact.bAccountID, Equal <Contact.bAccountID>, And <FSContact.bAccountContactID, Equal <Contact.contactID>, And <FSContact.revisionID, Equal <Contact.revisionID>, And <FSContact.isDefaultContact, Equal <boolTrue> > > > > > >, Where < Contact.contactID, Equal <Location.defContactID> > >)); view = sender.Graph.TypedViews.GetView(select, false); } if (view != null) { int startRow = -1; int totalRows = 0; bool contactFound = false; foreach (PXResult res in view.Select(new object[] { documentRow }, new [] { parm }, null, null, null, null, ref startRow, 1, ref totalRows)) { contactFound = DefaultContact <TContact, TContactID>(sender, FieldName, documentRow, contactRow, res); break; } if (!contactFound && !_Required) { ClearRecord(sender, documentRow); } } else { ClearRecord(sender, documentRow); if (_Required && sender.GetValue(documentRow, _FieldOrdinal) == null) { using (ReadOnlyScope rs = new ReadOnlyScope(sender.Graph.Caches[_RecordType])) { object record = sender.Graph.Caches[_RecordType].Insert(); object recordID = sender.Graph.Caches[_RecordType].GetValue(record, _RecordID); sender.SetValue(documentRow, _FieldOrdinal, recordID); } } } }
public override void DefaultAddress <TAddress, TAddressID>(PXCache sender, object documentRow, object addressRow) { PXView view = null; object parm = null; FSSrvOrdType fsSrvOrdTypeRow = null; bool isBranchLocation = false; BqlCommand select; if (sender.Graph is ServiceOrderEntry) { fsSrvOrdTypeRow = ((ServiceOrderEntry)sender.Graph).ServiceOrderTypeSelected.Current; } else if (sender.Graph is AppointmentEntry) { fsSrvOrdTypeRow = ((AppointmentEntry)sender.Graph).ServiceOrderTypeSelected.Current; } if (fsSrvOrdTypeRow != null && fsSrvOrdTypeRow.AppAddressSource == ID.SrvOrdType_AppAddressSource.BRANCH_LOCATION && sender.GetValue <FSServiceOrder.branchLocationID>(documentRow) != null) { parm = sender.GetValue <FSServiceOrder.branchLocationID>(documentRow); select = BqlCommand.CreateInstance(typeof( Select2 <FSBLOCAddress, InnerJoin <FSBranchLocation, On < FSBranchLocation.branchLocationAddressID, Equal <FSBLOCAddress.addressID> > >, Where < FSBranchLocation.branchLocationID, Equal <Required <FSBranchLocation.branchLocationID> > > >)); view = sender.Graph.TypedViews.GetView(select, false); isBranchLocation = true; } else if (fsSrvOrdTypeRow != null && fsSrvOrdTypeRow.AppAddressSource == ID.SrvOrdType_AppAddressSource.CUSTOMER_CONTACT && sender.GetValue <FSServiceOrder.contactID>(documentRow) != null) { parm = sender.GetValue <FSServiceOrder.contactID>(documentRow); select = BqlCommand.CreateInstance(typeof( Select2 <Address, LeftJoin <Contact, On < Contact.defAddressID, Equal <Address.addressID> >, LeftJoin <FSAddress, On < FSAddress.bAccountID, Equal <Contact.bAccountID>, And <FSAddress.bAccountAddressID, Equal <Address.addressID>, And <FSAddress.revisionID, Equal <Address.revisionID>, And <FSAddress.isDefaultAddress, Equal <boolTrue> > > > > > >, Where < Contact.contactID, Equal <Required <FSServiceOrder.contactID> > > >)); view = sender.Graph.TypedViews.GetView(select, false); } else if (fsSrvOrdTypeRow != null && fsSrvOrdTypeRow.AppAddressSource == ID.SrvOrdType_AppAddressSource.BUSINESS_ACCOUNT && sender.GetValue <FSServiceOrder.locationID>(documentRow) != null) { parm = sender.GetValue <FSServiceOrder.locationID>(documentRow); select = BqlCommand.CreateInstance(typeof( Select2 <Address, LeftJoin <Contact, On < Contact.defAddressID, Equal <Address.addressID> >, LeftJoin <Location, On < Location.locationID, Equal <Required <FSManufacturer.locationID> > >, LeftJoin <FSAddress, On < FSAddress.bAccountID, Equal <Contact.bAccountID>, And <FSAddress.bAccountAddressID, Equal <Address.addressID>, And <FSAddress.revisionID, Equal <Address.revisionID>, And <FSAddress.isDefaultAddress, Equal <boolTrue> > > > > > > >, Where < Address.addressID, Equal <Location.defAddressID> > >)); view = sender.Graph.TypedViews.GetView(select, false); } if (view != null) { int startRow = -1; int totalRows = 0; bool addressFound = false; foreach (PXResult res in view.Select(new object[] { documentRow }, new[] { parm }, null, null, null, null, ref startRow, 1, ref totalRows)) { if (isBranchLocation) { addressFound = DefaultBLOCAddress <FSBLOCAddress, FSBLOCAddress.addressID>(sender, FieldName, documentRow, addressRow, res); } else { addressFound = DefaultAddress <TAddress, TAddressID>(sender, FieldName, documentRow, addressRow, res); } break; } if (!addressFound && !_Required) { this.ClearRecord(sender, documentRow); } } else { ClearRecord(sender, documentRow); if (_Required && sender.GetValue(documentRow, _FieldOrdinal) == null) { using (ReadOnlyScope rs = new ReadOnlyScope(sender.Graph.Caches[_RecordType])) { object record = sender.Graph.Caches[_RecordType].Insert(); object recordID = sender.Graph.Caches[_RecordType].GetValue(record, _RecordID); sender.SetValue(documentRow, _FieldOrdinal, recordID); } } } }
public override IEnumerable adjustments() { CurrencyInfo inv_info = PXSelect<CurrencyInfo, Where<CurrencyInfo.curyInfoID, Equal<Current<ARInvoice.curyInfoID>>>>.Select(this); foreach (PXResult<ARAdjust, ARPayment, CurrencyInfo> res in Adjustments_Raw.Select()) { ARPayment payment = PXCache<ARPayment>.CreateCopy(res); ARAdjust adj = (ARAdjust)res; CurrencyInfo pay_info = (CurrencyInfo)res; ARAdjust other = PXSelectGroupBy<ARAdjust, Where<ARAdjust.adjgDocType, Equal<Required<ARAdjust.adjgDocType>>, And<ARAdjust.adjgRefNbr, Equal<Required<ARAdjust.adjgRefNbr>>, And<ARAdjust.released, Equal<False>, And<Where<ARAdjust.adjdDocType, NotEqual<Required<ARAdjust.adjdDocType>>, Or<ARAdjust.adjdRefNbr, NotEqual<Required<ARAdjust.adjdRefNbr>>>>>>>>, Aggregate<GroupBy<ARAdjust.adjgDocType, GroupBy<ARAdjust.adjgRefNbr, Sum<ARAdjust.curyAdjgAmt, Sum<ARAdjust.adjAmt>>>>>>.Select(this, adj.AdjgDocType, adj.AdjgRefNbr, adj.AdjdDocType, adj.AdjdRefNbr); if (other != null && other.AdjdRefNbr != null) { payment.CuryDocBal -= other.CuryAdjgAmt; payment.DocBal -= other.AdjAmt; } decimal CuryDocBal; if (string.Equals(pay_info.CuryID, inv_info.CuryID)) { CuryDocBal = (decimal)payment.CuryDocBal; } else { PXDBCurrencyAttribute.CuryConvCury(Adjustments.Cache, inv_info, (decimal)payment.DocBal, out CuryDocBal); } if (adj.Released == false) { if (adj.CuryAdjdAmt > CuryDocBal) { //if reconsidered need to calc RGOL adj.CuryDocBal = CuryDocBal; adj.CuryAdjdAmt = 0m; } else { adj.CuryDocBal = CuryDocBal - adj.CuryAdjdAmt; } } yield return res; } if (Document.Current != null && (Document.Current.DocType == ARDocType.Invoice || Document.Current.DocType == ARDocType.DebitMemo) && Document.Current.Released == false) { using (ReadOnlyScope rs = new ReadOnlyScope(Adjustments.Cache, Document.Cache, arbalances.Cache)) { //same as ARInvoiceEntry but without released constraint and with hold constraint foreach (PXResult<AR.ARPayment, CurrencyInfo, ARAdjust> res in PXSelectReadonly2<ARPayment, InnerJoin<CurrencyInfo, On<CurrencyInfo.curyInfoID, Equal<ARPayment.curyInfoID>>, LeftJoin<ARAdjust, On<ARAdjust.adjgDocType, Equal<ARPayment.docType>, And<ARAdjust.adjgRefNbr, Equal<ARPayment.refNbr>, And<ARAdjust.adjNbr, Equal<ARPayment.lineCntr>, And<ARAdjust.released, Equal<False>, And<ARAdjust.hold, Equal<False>, And<ARAdjust.voided, Equal<False>, And<Where<ARAdjust.adjdDocType, NotEqual<Current<ARInvoice.docType>>, Or<ARAdjust.adjdRefNbr, NotEqual<Current<ARInvoice.refNbr>>>>>>>>>>>>>, Where<ARPayment.customerID, Equal<Current<ARInvoice.customerID>>, And2<Where<ARPayment.docType, Equal<ARDocType.payment>, Or<ARPayment.docType, Equal<ARDocType.prepayment>, Or<ARPayment.docType, Equal<ARDocType.creditMemo>>>>, And<ARPayment.docDate, LessEqual<Current<ARInvoice.docDate>>, And<ARPayment.finPeriodID, LessEqual<Current<ARInvoice.finPeriodID>>, And<ARPayment.openDoc, Equal<boolTrue>, And<ARAdjust.adjdRefNbr, IsNull>>>>>>>.Select(this)) { ARPayment payment = PXCache<ARPayment>.CreateCopy(res); ARAdjust adj = new ARAdjust(); CurrencyInfo pay_info = (CurrencyInfo)res; adj.CustomerID = Document.Current.CustomerID; adj.AdjdDocType = Document.Current.DocType; adj.AdjdRefNbr = Document.Current.RefNbr; adj.AdjdBranchID = Document.Current.BranchID; adj.AdjgDocType = payment.DocType; adj.AdjgRefNbr = payment.RefNbr; adj.AdjgBranchID = payment.BranchID; adj.AdjNbr = payment.LineCntr; ARAdjust other = PXSelectGroupBy<ARAdjust, Where<ARAdjust.adjgDocType, Equal<Required<ARAdjust.adjgDocType>>, And<ARAdjust.adjgRefNbr, Equal<Required<ARAdjust.adjgRefNbr>>, And<ARAdjust.released, Equal<False>, And<Where<ARAdjust.adjdDocType, NotEqual<Required<ARAdjust.adjdDocType>>, Or<ARAdjust.adjdRefNbr, NotEqual<Required<ARAdjust.adjdRefNbr>>>>>>>>, Aggregate<GroupBy<ARAdjust.adjgDocType, GroupBy<ARAdjust.adjgRefNbr, Sum<ARAdjust.curyAdjgAmt, Sum<ARAdjust.adjAmt>>>>>>.Select(this, adj.AdjgDocType, adj.AdjgRefNbr, adj.AdjdDocType, adj.AdjdRefNbr); if (other != null && other.AdjdRefNbr != null) { payment.CuryDocBal -= other.CuryAdjgAmt; payment.DocBal -= other.AdjAmt; } if (Adjustments.Cache.Locate(adj) == null) { adj.AdjgCuryInfoID = payment.CuryInfoID; adj.AdjdOrigCuryInfoID = Document.Current.CuryInfoID; //if LE constraint is removed from payment selection this must be reconsidered adj.AdjdCuryInfoID = Document.Current.CuryInfoID; decimal CuryDocBal; if (string.Equals(pay_info.CuryID, inv_info.CuryID)) { CuryDocBal = (decimal)payment.CuryDocBal; } else { PXDBCurrencyAttribute.CuryConvCury(Adjustments.Cache, inv_info, (decimal)payment.DocBal, out CuryDocBal); } adj.CuryDocBal = CuryDocBal; yield return new PXResult<ARAdjust, AR.ARPayment>(Adjustments.Insert(adj), payment); } } } } }