public virtual IEnumerable documents() { PendingInvoiceFilter filter = Filter.Current; Dictionary <CashAcctKey, PendingPaymentSummary> result = new Dictionary <CashAcctKey, PendingPaymentSummary>(); if (filter == null && !filter.PayDate.HasValue) { return(result.Values); } PXSelectBase <APInvoice> sel = new PXSelectJoin <APInvoice, InnerJoin <CurrencyInfo, On <CurrencyInfo.curyInfoID, Equal <APInvoice.curyInfoID> >, InnerJoin <CashAccount, On <CashAccount.cashAccountID, Equal <APInvoice.payAccountID> >, LeftJoin <APAdjust, On <APInvoice.docType, Equal <APAdjust.adjdDocType>, And <APInvoice.refNbr, Equal <APAdjust.adjdRefNbr>, And <APAdjust.released, Equal <BitOff> > > >, CrossJoin <APSetup> > > >, Where <Where2 <Where <APInvoice.paySel, Equal <BitOn>, Or <APSetup.requireApprovePayments, Equal <False> > >, And2 <Where <APInvoice.released, Equal <True>, Or <APInvoice.prebooked, Equal <True> > >, And <APInvoice.openDoc, Equal <BitOn> > > > >, OrderBy < Asc <APInvoice.docType, Asc <APInvoice.refNbr> > > >(this); /*if(filter.CuryID != null) * { * sel.WhereAnd<Where<APInvoice.curyID, Equal<Current<PendingInvoiceFilter.curyID>>>>(); * }*/ if (filter.PayDate != null) { sel.WhereAnd <Where <APInvoice.payDate, LessEqual <Current <PendingInvoiceFilter.payDate> > > >(); } if (filter.PayAccountID != null) { sel.WhereAnd <Where <APInvoice.payAccountID, Equal <Current <PendingInvoiceFilter.payAccountID> > > >(); } if (filter.PayTypeID != null) { sel.WhereAnd <Where <APInvoice.payTypeID, Equal <Current <PendingInvoiceFilter.payTypeID> > > >(); } APInvoiceKey lastInvoice = null; foreach (PXResult <APInvoice, CurrencyInfo, CashAccount, APAdjust> it in sel.Select()) { APInvoice inv = (APInvoice)it; CashAccount acct = (CashAccount)it; APAdjust adjust = (APAdjust)it; CurrencyInfo info = it; CurrencyInfo_CuryInfoID.StoreCached(new PXCommandKey(new object[] { info.CuryInfoID }, null, null, null, 0, 1, null, false, null), new List <object> { info }); if (adjust.AdjdDocType != null) { continue; //Skip invoices, having unreleased payments } APInvoiceKey invNbr = new APInvoiceKey(inv.DocType, inv.RefNbr); if (lastInvoice != null && lastInvoice.CompareTo(invNbr) == 0) { continue; //Skip multiple entries for invoice } //inv.DocCount = it.RowCount; lastInvoice = invNbr; CashAcctKey key = new CashAcctKey(inv.PayAccountID.Value, inv.PayTypeID); PendingPaymentSummary res = null; if (!result.ContainsKey(key)) { res = new PendingPaymentSummary(); res.PayAccountID = inv.PayAccountID; res.PayTypeID = inv.PayTypeID; res.CuryID = acct.CuryID; result[key] = res; //Assign new CyrrencyInfo - to do conersion correctly. RateTypeID must be taken from the Cash Account CurrencyInfo new_info = new CurrencyInfo(); new_info.CuryID = res.CuryID; new_info.CuryRateTypeID = acct.CuryRateTypeID; new_info.CuryEffDate = filter.PayDate; new_info = this.CurrencyInfo_CuryInfoID.Insert(new_info); res.CuryInfoID = new_info.CuryInfoID; } else { res = result[key]; } APAdjust adj = new APAdjust(); adj.VendorID = inv.VendorID; adj.AdjdDocType = inv.DocType; adj.AdjdRefNbr = inv.RefNbr; adj.AdjgDocType = APDocType.Check; adj.AdjgRefNbr = AutoNumberAttribute.GetNewNumberSymbol <APPayment.refNbr>(Caches[typeof(APPayment)], new APPayment { DocType = APDocType.Check }); try { PaymentEntry.CalcBalances <APInvoice, APAdjust>(this.CurrencyInfo_CuryInfoID, res.CuryInfoID, filter.PayDate, inv, adj); } catch (PXRateIsNotDefinedForThisDateException ex) { Documents.Cache.RaiseExceptionHandling <PendingPaymentSummary.curyID>(res, res.CuryID, new PXSetPropertyException(ex.Message, PXErrorLevel.RowError)); } Aggregate(res, new PXResult <APAdjust, APInvoice>(adj, inv), filter.PayDate); } return(result.Values); }
protected virtual void _(Events.RowSelected <FLXProject> e) { string newNumberSymbol = AutoNumberAttribute.GetNewNumberSymbol <FLXProject.projectNbr>(e.Cache, (object)e.Row); this.CreateSubProj.SetEnabled(e.Row.ProjectNbr != newNumberSymbol && string.IsNullOrEmpty(e.Row.OrigProjNbr)); }