Ejemplo n.º 1
0
        public void GetLog(DateTime dateToProcess)
        {
            this.Log = DJournalLog.Get(dateToProcess);

            if (this.Log == null)
            {
                this.Error.Add($"There was an error validating the DJournalLog for {dateToProcess.ToShortDateString()}.");
            }
        }
Ejemplo 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()}.");
                }
            }
        }