Exemplo n.º 1
0
        //private void CheckIfDJournalIsBalanced(List<CashierTotal> ppt)
        //{
        //  var balanced = CashierTotal.IsDjournalBalanced(ppt);
        //  if (balanced)
        //  {
        //    Error.Add("Djournal is " + balancedText);
        //    var keys = String.Join(", \n", CashierTotal.GetOutOfBalanceCashierIds(DJournalDate));
        //    Error.Add("The following keys have issues:\n" + keys);
        //  }
        //}

        private void CheckIfDJournalIsBalanced()
        {
            var balanced = CashierTotal.IsDjournalBalanced(ProcessedPaymentTotals, GUTotals, GLAccountTotals);

            if (!balanced)
            {
                var key_list = CashierTotal.GetOutOfBalanceCashierIds(DJournalDate);


                if (key_list.Count > 0)
                {
                    var keys = String.Join(", \n", key_list);

                    var errorString = new StringBuilder();
                    errorString.Append($"The DJournal for ")
                    .Append(this.DJournalDate.ToShortDateString())
                    .Append(" is out of balance.")
                    .AppendLine()
                    .Append("The following keys have issues:")
                    .AppendLine()
                    .Append(keys)
                    .AppendLine();


                    Error.Add(errorString.ToString());
                }
                else
                {
                    Error.Add($@"The Djournal for
          {this.DJournalDate.ToShortDateString()} is out of balance. 
          There may be an issue with the total payments, total charges, or the GU amounts.");
                }
            }
            else
            {
                CanDJournalBeFinalized = true;
            }
        }
Exemplo n.º 2
0
        public DJournal(DateTime dateToProcess, UserAccess ua, bool finalize = false)
        {
            DJournalDate = dateToProcess;
            //check for dates not finalized after initial finalize date
            this.ProcessedPaymentTotals = CashierTotal.ProcessPaymentTypeTotals(dateToProcess);
            this.GUTotals        = CashierTotal.GetGUTotals(dateToProcess);
            this.GLAccountTotals = Account.GetGLAccountTotals(dateToProcess);
            var tempCd = CashierDetailData.Get(dateToProcess);

            string[] ImpactFeePaymentTypes =
            {
                "IFCR",
                "IFEX",
                "IFWS",
                "IFWR",
                "IFSCR",
                "IFS2",
                "IFS3",
                "MFS1",
                "MFS2",
                "MFS4",
                "MFS7",
                "MFS10"
            };
            this.CashierData = (from c in tempCd
                                where !ImpactFeePaymentTypes.Contains(c.PaymentType)
                                select c).ToList();
            this.ImpactFeeData = (from c in tempCd
                                  where ImpactFeePaymentTypes.Contains(c.PaymentType)
                                  select c).ToList();

            CheckIfDJournalIsBalanced();

            if (!CanDJournalBeFinalized)
            {
                CheckCatCodesAgainstGL();
            }

            CanDJournalBeFinalized = false;
            //
            Log = DJournalLog.Get(dateToProcess);
            var NextDateToFinalize = LastDateFinalized().AddDays(1);
            var rolloutDate        = DateTime.Parse("8/23/2018");

            if (dateToProcess < rolloutDate && !Log.IsCreated && !finalize)
            {
                Log.DJournalDate = dateToProcess;
                Log.FinalizedOn  = rolloutDate;
                Log.CreatedBy    = "Prior to Claypay";
            }
            if (finalize)
            {
                if (Log.IsCreated)
                {
                    Error.Add($"{dateToProcess.ToShortDateString()} has already been finalized.");
                }
                if (!ua.djournal_access)
                {
                    Error.Add("DJournal was not finalized. User does not have the correct level of access.");
                }
                if (DJournalDate.Date != NextDateToFinalize.Date)
                {
                    Error.Add("The dates must be finalized in order.  You must finalize " + NextDateToFinalize.ToShortDateString() + "next.");
                }
                if (NextDateToFinalize.Date == DateTime.Now.Date)
                {
                    Error.Add("You must wait until tomorrow to finalize today.");
                }
            }


            // in order for the Djournal to be able to be finalized, the following must be true
            // 1) it can't already be finalized
            // 2) The date be be prior to today
            // 3) The date must be one day later than the most recent date finalized
            // 4) The user must have DJournal access.
            // 5) No errors can be present
            CanDJournalBeFinalized =
                !Log.IsCreated &&                               // 1
                DJournalDate.Date < DateTime.Now.Date &&        // 2
                NextDateToFinalize.Date == DJournalDate.Date && // 3
                ua.djournal_access &&                           // 4
                Error.Count == 0;                               // 5

            if (finalize && CanDJournalBeFinalized)
            {
                if (DJournalLog.Create(dateToProcess, ua.user_name) != -1)
                {
                    CanDJournalBeFinalized = false; // It just was finalized
                    Log = DJournalLog.Get(dateToProcess);
                }
                else
                {
                    Error.Add($"There was an issue saving the DJournal log for {dateToProcess.ToShortDateString()}.");
                }
            }
        }