public virtual void APHistoryFilter_VendorClassID_ExceptionHandling(PXCache cache, PXExceptionHandlingEventArgs e) { APHistoryFilter header = e.Row as APHistoryFilter; if (header != null) { e.Cancel = true; header.VendorClassID = null; } }
protected virtual IEnumerable history() { APHistoryFilter header = Filter.Current; if (header == null) { yield break; } if (header.Period == null) { PXSelectBase <Vendor> sel = new PXSelectJoinGroupBy <Vendor, LeftJoin <APHistory, On <APHistory.vendorID, Equal <Vendor.bAccountID> > >, Aggregate < Sum <APHistory.finPtdCrAdjustments, Sum <APHistory.finPtdDiscTaken, Sum <APHistory.finPtdDrAdjustments, Sum <APHistory.finPtdPayments, Sum <APHistory.finPtdPurchases, Sum <APHistory.finPtdRGOL, Sum <APHistory.tranPtdCrAdjustments, Sum <APHistory.tranPtdDiscTaken, Sum <APHistory.tranPtdDrAdjustments, Sum <APHistory.tranPtdPayments, Sum <APHistory.tranPtdPurchases, Sum <APHistory.tranPtdRGOL, GroupBy <Vendor.bAccountID> > > > > > > > > > > > > > >(this); if (header.APAcctID != null) { sel.WhereAnd <Where <Vendor.aPAcctID, Equal <Current <APHistoryFilter.aPAcctID> > > >(); } if (header.APSubID != null) { sel.WhereAnd <Where <Vendor.aPSubID, Equal <Current <APHistoryFilter.aPSubID> > > >(); } bool foreign = false; if (header.CuryID != null) { sel.WhereAnd <Where <Vendor.curyID, Equal <Current <APHistoryFilter.curyID> > > >(); GL.Company company = PXSelect <GL.Company> .Select(this); foreign = (company == null || company.BaseCuryID != header.CuryID); if (foreign) { PXUIFieldAttribute.SetVisible <APHistoryResult.rGOL>(History.Cache, null, false); } } if (header.CashAcctID != null) { sel.WhereAnd <Where <Vendor.cashAcctID, Equal <Current <APHistoryFilter.cashAcctID> > > >(); } if (header.PaymentTypeID != null) { sel.WhereAnd <Where <Vendor.paymentTypeID, Equal <Current <APHistoryFilter.paymentTypeID> > > >(); } if (header.VendorClassID != null) { sel.WhereAnd <Where <Vendor.vendorClassID, Equal <Current <APHistoryFilter.vendorClassID> > > >(); } if (header.Status != null) { sel.WhereAnd <Where <Vendor.status, Equal <Current <APHistoryFilter.status> > > >(); } foreach (PXResult <Vendor, APHistory> record in sel.Select()) { Vendor vendor = record; APHistory history = record; APHistoryResult res = new APHistoryResult(); res.AcctCD = vendor.AcctCD; res.AcctName = vendor.AcctName; if (header.ByFinancialPeriod != true) { if (!foreign) { res.Purchases = history.TranPtdPurchases ?? 0m; res.Payments = history.TranPtdPayments ?? 0m; res.Discount = history.TranPtdDiscTaken ?? 0m; res.RGOL = history.TranPtdRGOL ?? 0m; res.CrAdjustments = history.TranPtdCrAdjustments ?? 0m; res.DrAdjustments = history.TranPtdDrAdjustments ?? 0m; res.Balance = res.Purchases - res.Payments - res.Discount + res.RGOL - res.DrAdjustments + res.CrAdjustments; } else { res.Purchases = history.TranPtdPurchases ?? 0m; res.Payments = history.TranPtdPayments ?? 0m; res.Discount = history.TranPtdDiscTaken ?? 0m; res.RGOL = 0m; res.CrAdjustments = history.TranPtdCrAdjustments ?? 0m; res.DrAdjustments = history.TranPtdDrAdjustments ?? 0m; res.Balance = res.Purchases - res.Payments - res.Discount - res.DrAdjustments + res.CrAdjustments; } } else { if (!foreign) { res.Purchases = history.FinPtdPurchases ?? 0m; res.Payments = history.FinPtdPayments ?? 0m; res.Discount = history.FinPtdDiscTaken ?? 0m; res.RGOL = history.FinPtdRGOL ?? 0m; res.CrAdjustments = history.FinPtdCrAdjustments ?? 0m; res.DrAdjustments = history.FinPtdDrAdjustments ?? 0m; res.Balance = res.Purchases - res.Payments - res.Discount + res.RGOL - res.DrAdjustments + res.CrAdjustments; } else { res.Purchases = history.FinPtdPurchases ?? 0m; res.Payments = history.FinPtdPayments ?? 0m; res.Discount = history.FinPtdDiscTaken ?? 0m; res.RGOL = 0m; res.CrAdjustments = history.FinPtdCrAdjustments ?? 0m; res.DrAdjustments = history.FinPtdDrAdjustments ?? 0m; res.Balance = res.Purchases - res.Payments - res.Discount - res.DrAdjustments + res.CrAdjustments; } } if (res.Balance != 0m || header.ShowWithBalanceOnly != true) { yield return(res); } } } else { PXSelectBase <Vendor> sel = new PXSelectJoinGroupBy <Vendor, LeftJoin <APHistory, On <APHistory.vendorID, Equal <Vendor.bAccountID>, And <APHistory.finPeriodID, Equal <Current <APHistoryFilter.period> > > > >, Aggregate < Sum <APHistory.finBegBalance, Sum <APHistory.finYtdBalance, Sum <APHistory.finPtdCrAdjustments, Sum <APHistory.finPtdDiscTaken, Sum <APHistory.finPtdDrAdjustments, Sum <APHistory.finPtdPayments, Sum <APHistory.finPtdPurchases, Sum <APHistory.finPtdRGOL, Sum <APHistory.tranBegBalance, Sum <APHistory.tranYtdBalance, Sum <APHistory.tranPtdCrAdjustments, Sum <APHistory.tranPtdDiscTaken, Sum <APHistory.tranPtdDrAdjustments, Sum <APHistory.tranPtdPayments, Sum <APHistory.tranPtdPurchases, Sum <APHistory.tranPtdRGOL, GroupBy <Vendor.bAccountID> > > > > > > > > > > > > > > > > > >(this); PXUIFieldAttribute.SetVisible <APHistoryResult.balance>(History.Cache, null, false); PXUIFieldAttribute.SetVisible <APHistoryResult.begBalance>(History.Cache, null); PXUIFieldAttribute.SetVisible <APHistoryResult.endBalance>(History.Cache, null); if (header.APAcctID != null) { sel.WhereAnd <Where <Vendor.aPAcctID, Equal <Current <APHistoryFilter.aPAcctID> > > >(); } if (header.APSubID != null) { sel.WhereAnd <Where <Vendor.aPSubID, Equal <Current <APHistoryFilter.aPSubID> > > >(); } bool foreign = false; if (header.CuryID != null) { sel.WhereAnd <Where <Vendor.curyID, Equal <Current <APHistoryFilter.curyID> > > >(); GL.Company company = PXSelect <GL.Company> .Select(this); foreign = (company == null || company.BaseCuryID != header.CuryID); if (foreign) { PXUIFieldAttribute.SetVisible <APHistoryResult.rGOL>(History.Cache, null, false); } } if (header.CashAcctID != null) { sel.WhereAnd <Where <Vendor.cashAcctID, Equal <Current <APHistoryFilter.cashAcctID> > > >(); } if (header.PaymentTypeID != null) { sel.WhereAnd <Where <Vendor.paymentTypeID, Equal <Current <APHistoryFilter.paymentTypeID> > > >(); } if (header.VendorClassID != null) { sel.WhereAnd <Where <Vendor.vendorClassID, Equal <Current <APHistoryFilter.vendorClassID> > > >(); } if (header.Status != null) { sel.WhereAnd <Where <Vendor.status, Equal <Current <APHistoryFilter.status> > > >(); } foreach (PXResult <Vendor, APHistory> record in sel.Select()) { Vendor vendor = record; APHistory history = record; APHistoryResult res = new APHistoryResult(); res.AcctCD = vendor.AcctCD; res.AcctName = vendor.AcctName; if (header.ByFinancialPeriod != true) { if (!foreign) { res.Purchases = history.TranPtdPurchases ?? 0m; res.Payments = history.TranPtdPayments ?? 0m; res.Discount = history.TranPtdDiscTaken ?? 0m; res.RGOL = history.TranPtdRGOL ?? 0m; res.CrAdjustments = history.TranPtdCrAdjustments ?? 0m; res.DrAdjustments = history.TranPtdDrAdjustments ?? 0m; res.BegBalance = history.TranBegBalance ?? 0m; res.EndBalance = res.BegBalance + res.Purchases - res.Payments - res.Discount + res.RGOL - res.DrAdjustments + res.CrAdjustments; } else { res.Purchases = history.TranPtdPurchases ?? 0m; res.Payments = history.TranPtdPayments ?? 0m; res.Discount = history.TranPtdDiscTaken ?? 0m; res.RGOL = 0m; res.CrAdjustments = history.TranPtdCrAdjustments ?? 0m; res.DrAdjustments = history.TranPtdDrAdjustments ?? 0m; res.BegBalance = history.TranBegBalance ?? 0m; res.EndBalance = res.BegBalance + res.Purchases - res.Payments - res.Discount - res.DrAdjustments + res.CrAdjustments; } } else { if (!foreign) { res.Purchases = history.FinPtdPurchases ?? 0m; res.Payments = history.FinPtdPayments ?? 0m; res.Discount = history.FinPtdDiscTaken ?? 0m; res.RGOL = history.FinPtdRGOL ?? 0m; res.CrAdjustments = history.FinPtdCrAdjustments ?? 0m; res.DrAdjustments = history.FinPtdDrAdjustments ?? 0m; res.BegBalance = history.FinBegBalance ?? 0m; res.EndBalance = res.BegBalance + res.Purchases - res.Payments - res.Discount + res.RGOL - res.DrAdjustments + res.CrAdjustments; } else { res.Purchases = history.FinPtdPurchases ?? 0m; res.Payments = history.FinPtdPayments ?? 0m; res.Discount = history.FinPtdDiscTaken ?? 0m; res.RGOL = 0m; res.CrAdjustments = history.FinPtdCrAdjustments ?? 0m; res.DrAdjustments = history.FinPtdDrAdjustments ?? 0m; res.BegBalance = history.FinBegBalance ?? 0m; res.EndBalance = res.BegBalance + res.Purchases - res.Payments - res.Discount - res.DrAdjustments + res.CrAdjustments; } } if (res.Balance != 0m || header.ShowWithBalanceOnly != true) { yield return(res); } } } }