private void update(CATran tran, CADailySummary summary, int sign)
 {
     if (tran.Cleared == true)
     {
         if (tran.Released == true)
         {
             summary.AmtReleasedClearedCr += (tran.CuryCreditAmt * sign);
             summary.AmtReleasedClearedDr += (tran.CuryDebitAmt * sign);
         }
         else
         {
             summary.AmtUnreleasedClearedCr += (tran.CuryCreditAmt * sign);
             summary.AmtUnreleasedClearedDr += (tran.CuryDebitAmt * sign);
         }
     }
     else
     {
         if (tran.Released == true)
         {
             summary.AmtReleasedUnclearedCr += (tran.CuryCreditAmt * sign);
             summary.AmtReleasedUnclearedDr += (tran.CuryDebitAmt * sign);
         }
         else
         {
             summary.AmtUnreleasedUnclearedCr += (tran.CuryCreditAmt * sign);
             summary.AmtUnreleasedUnclearedDr += (tran.CuryDebitAmt * sign);
         }
     }
 }
        public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            CASetup caSetup = PXSelect <CASetup> .Select(sender.Graph);

            decimal?result        = 0m;
            object  cashAccountID = sender.GetValue(e.Row, _CashAccount);

            CADailySummary caBalance = PXSelectGroupBy <CADailySummary,
                                                        Where <CADailySummary.cashAccountID, Equal <Required <CADailySummary.cashAccountID> > >,
                                                        Aggregate <Sum <CADailySummary.amtReleasedClearedCr,
                                                                        Sum <CADailySummary.amtReleasedClearedDr,
                                                                             Sum <CADailySummary.amtReleasedUnclearedCr,
                                                                                  Sum <CADailySummary.amtReleasedUnclearedDr,
                                                                                       Sum <CADailySummary.amtUnreleasedClearedCr,
                                                                                            Sum <CADailySummary.amtUnreleasedClearedDr,
                                                                                                 Sum <CADailySummary.amtUnreleasedUnclearedCr,
                                                                                                      Sum <CADailySummary.amtUnreleasedUnclearedDr> > > > > > > > > > .
                                       Select(sender.Graph, cashAccountID);

            if ((caBalance != null) && (caBalance.CashAccountID != null))
            {
                result = caBalance.AmtReleasedClearedDr - caBalance.AmtReleasedClearedCr;

                if ((bool)caSetup.CalcBalDebitClearedUnreleased)
                {
                    result += caBalance.AmtUnreleasedClearedDr;
                }
                if ((bool)caSetup.CalcBalCreditClearedUnreleased)
                {
                    result -= caBalance.AmtUnreleasedClearedCr;
                }
                if ((bool)caSetup.CalcBalDebitUnclearedReleased)
                {
                    result += caBalance.AmtReleasedUnclearedDr;
                }
                if ((bool)caSetup.CalcBalCreditUnclearedReleased)

                {
                    result -= caBalance.AmtReleasedUnclearedCr;
                }
                if ((bool)caSetup.CalcBalDebitUnclearedUnreleased)
                {
                    result += caBalance.AmtUnreleasedUnclearedDr;
                }
                if ((bool)caSetup.CalcBalCreditUnclearedUnreleased)
                {
                    result -= caBalance.AmtUnreleasedUnclearedCr;
                }
            }
            e.ReturnValue = result;
            e.Cancel      = true;
        }
Ejemplo n.º 3
0
        public virtual void RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            CATran tran = (CATran)e.Row;

            if (tran.CashAccountID != null && tran.TranDate != null)
            {
                CADailySummary summary = new CADailySummary();
                summary.CashAccountID = tran.CashAccountID;
                summary.TranDate      = tran.TranDate;
                summary = (CADailySummary)sender.Graph.Caches[typeof(CADailySummary)].Insert(summary);
                update(tran, summary, -1);
            }
        }
Ejemplo n.º 4
0
        protected virtual IEnumerable filter()
        {
            PXCache cache = Caches[typeof(CAEnqFilter)];

            if (cache != null)
            {
                CAEnqFilter filter = cache.Current as CAEnqFilter;
                if (filter != null)
                {
                    if (filter.StartDate == null || filter.EndDate == null)
                    {
                        DateTime?startDate;
                        DateTime?endDate;

                        GetRange((DateTime)this.Accessinfo.BusinessDate, casetup.Current.DateRangeDefault, filter.AccountID, out startDate, out endDate);
                        filter.StartDate = startDate;
                        filter.EndDate   = endDate;
                    }
                    if (filter.AccountID != null && filter.StartDate != null)
                    {
                        CADailySummary begBal = PXSelectGroupBy <CADailySummary,
                                                                 Where <CADailySummary.cashAccountID, Equal <Required <CAEnqFilter.accountID> >,
                                                                        And <CADailySummary.tranDate, Less <Required <CAEnqFilter.startDate> > > >,
                                                                 Aggregate <Sum <CADailySummary.amtReleasedClearedCr,
                                                                                 Sum <CADailySummary.amtReleasedClearedDr,
                                                                                      Sum <CADailySummary.amtReleasedUnclearedCr,
                                                                                           Sum <CADailySummary.amtReleasedUnclearedDr,
                                                                                                Sum <CADailySummary.amtUnreleasedClearedCr,
                                                                                                     Sum <CADailySummary.amtUnreleasedClearedDr,
                                                                                                          Sum <CADailySummary.amtUnreleasedUnclearedCr,
                                                                                                               Sum <CADailySummary.amtUnreleasedUnclearedDr,
                                                                                                                    GroupBy <CADailySummary.cashAccountID> > > > > > > > > > >
                                                .Select(this, filter.AccountID, filter.StartDate);

                        if ((begBal == null) || (begBal.CashAccountID == null))
                        {
                            filter.BegBal        = (decimal)0.0;
                            filter.BegClearedBal = (decimal)0.0;
                        }
                        else
                        {
                            filter.BegBal = begBal.AmtReleasedClearedDr -
                                            begBal.AmtReleasedClearedCr +
                                            begBal.AmtReleasedUnclearedDr -
                                            begBal.AmtReleasedUnclearedCr;

                            filter.BegClearedBal = begBal.AmtReleasedClearedDr -
                                                   begBal.AmtReleasedClearedCr;

                            if (filter.IncludeUnreleased == true)
                            {
                                filter.BegBal += begBal.AmtUnreleasedClearedDr -
                                                 begBal.AmtUnreleasedClearedCr +
                                                 begBal.AmtUnreleasedUnclearedDr -
                                                 begBal.AmtUnreleasedUnclearedCr;

                                filter.BegClearedBal += begBal.AmtUnreleasedClearedDr -
                                                        begBal.AmtUnreleasedClearedCr;
                            }
                        }
                        filter.DebitTotal         = 0m;
                        filter.CreditTotal        = 0m;
                        filter.DebitClearedTotal  = 0m;
                        filter.CreditClearedTotal = 0m;
                        int startRow  = 0;
                        int totalRows = 0;
                        foreach (PXResult <CATranExt> res in CATranListRecords.View.Select(PXView.Currents, PXView.Parameters, new object[0], new string[0], new bool[0], CATranListRecords.View.GetExternalFilters(), ref startRow, 0, ref totalRows))
                        {
                            CATranExt tran = (CATranExt)res;
                            filter.DebitTotal         += tran.CuryDebitAmt;
                            filter.CreditTotal        += tran.CuryCreditAmt;
                            filter.DebitClearedTotal  += tran.CuryClearedDebitAmt;
                            filter.CreditClearedTotal += tran.CuryClearedCreditAmt;
                        }
                        filter.EndBal        = filter.BegBal + filter.DebitTotal - filter.CreditTotal;
                        filter.EndClearedBal = filter.BegClearedBal + filter.DebitClearedTotal - filter.CreditClearedTotal;
                    }
                }
            }
            yield return(cache.Current);

            cache.IsDirty = false;
        }