示例#1
0
文件: Data.cs 项目: briddums/Budget
        public void GenerateBudget()
        {
            budget = new List <Payment>();

            // Generate a years worth of data; this will make the Average function in the report more accurate
            var budgetEndDt = StartDt.AddYears(2).AddDays(-1);

            // Loop through each payment item
            foreach (Payment payment in payments)
            {
                // Increment the dates on this payment until we land in the current budget period
                while (payment.Date < StartDt)
                {
                    payment.NextDate();
                }

                // Add this payment to the budget, increment the date and repeat if required
                while (payment.Date <= budgetEndDt)
                {
                    /* Only add if amount is non-negative.  Paid bills will have an amount of 0
                     * Need to add clones because classes are reference objects */
                    if (payment.Amount > 0)
                    {
                        budget.Add(payment.Clone());
                    }
                    payment.NextDate();
                }
            }

            // Sort budget by Date by Name
            budget = budget.OrderBy(p => p.Date).ThenBy(p => p.Name).ToList();
        }
示例#2
0
        // Run the report
        public void Run()
        {
            var outputFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                          $"budget {StartDt.ToString("yyyy-MM").ToLower()}.txt");

            using (sw = new StreamWriter(outputFile))
            {
                if (ShowAveragePerCheck)
                {
                    WriteAverage();
                }

                if (byPayPeriod)
                {
                    RunByPayPeriod();
                }
                else
                {
                    RunByMonth();
                }
            }
        }
示例#3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (EventSn != 0L)
            {
                hash ^= EventSn.GetHashCode();
            }
            if (EventType != 0)
            {
                hash ^= EventType.GetHashCode();
            }
            if (EventValue.Length != 0)
            {
                hash ^= EventValue.GetHashCode();
            }
            if (StartDt.Length != 0)
            {
                hash ^= StartDt.GetHashCode();
            }
            if (EndDt.Length != 0)
            {
                hash ^= EndDt.GetHashCode();
            }
            if (Checked != false)
            {
                hash ^= Checked.GetHashCode();
            }
            if (IAmString.Length != 0)
            {
                hash ^= IAmString.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#4
0
        public void RunByPayPeriod()
        {
            // Two periods per month; 1 - 15, 1 - end of month
            double total     = 0;
            var    periodEnd = StartDt.AddDays(14);     // 1st + 14 days = 15th

            foreach (Payment payment in Budget)
            {
                // Skip any budget items that are beyond the end of the period for this report
                if (payment.Date > EndDt)
                {
                    continue;
                }

                if (payment.Date > periodEnd)
                {
                    WriteFooter(total);     // write out period footer
                    total = 0;              // reset total for next period

                    // TODO: write out period header

                    if (periodEnd.Day == 15)
                    {
                        // Need to get end of month, so we revert to the 1st, add a month, and subtract a day
                        periodEnd = periodEnd.AddDays(-14).AddMonths(1).AddDays(-1);
                    }
                    else
                    {
                        periodEnd = periodEnd.AddDays(14);
                    }
                }

                total += payment.Amount;
                WritePayment(payment);
            }

            WriteFooter(total);     // Write out final period footer
        }