Beispiel #1
0
        private void ValidateDeadline(DebtorTransDirectDebit rec)
        {
            if (err)
            {
                return;
            }

            DateTime deadline = new DateTime(rec._PaymentDate.Year, rec._PaymentDate.Month, rec._PaymentDate.Day - 1, DirectDebitPaymentHelper.DEADLINE_TIMEOFDAY, 0, 0);

            deadline = DirectDebitBankHolidays.AdjustBankDay(comp._CountryId, deadline, false);

            if (todayDateTime >= deadline)
            {
                //TODO:Kan erstattes af en linje når Enum for Status bliver oprettet
                switch (rec._PaymentStatus)
                {
                case PaymentStatusLevel.None:
                    rec._ErrorInfo = string.Format("'Sent payment' not possible (Deadline {0}", deadline.ToString("dd-MM-yyyy kl. HH:mm"));
                    break;

                case PaymentStatusLevel.Resend:
                    rec._ErrorInfo = string.Format("'Resend payment' not possible (Deadline {0}", deadline.ToString("dd-MM-yyyy kl. HH:mm"));
                    break;

                case PaymentStatusLevel.StopPayment:
                    rec._ErrorInfo = string.Format("'Stop payment' not possible (Deadline {0}", deadline.ToString("dd-MM-yyyy kl. HH:mm"));
                    break;
                }
            }
        }
Beispiel #2
0
        private void ValidateBankholiday(DebtorTransDirectDebit rec)
        {
            if (err)
            {
                return;
            }

            if (!DirectDebitBankHolidays.IsBankDay(comp._CountryId, rec.PaymentDate))
            {
                rec._ErrorInfo = String.Format("Payment date {0} is not a bank day", rec._PaymentDate.ToString("dd-MM-yyyy"));
                err            = true;
            }
        }
Beispiel #3
0
        public static void ChangeStatus(Company comp, DebtorTransDirectDebit rec, PaymentStatusLevel changeToStatus)
        {
            var statusInfoTxt = rec._StatusInfo;

            if (changeToStatus == PaymentStatusLevel.None)
            {
                if (rec._PaymentStatus != PaymentStatusLevel.Sent && rec._PaymentStatus != PaymentStatusLevel.Processed && rec._PaymentStatus != PaymentStatusLevel.PaymentReceived && rec._PaymentStatus != changeToStatus)
                {
                    statusInfoTxt      = string.Format("({0}) Status changed '{1}'->{2}\n{3}", DateTime.Now.ToString("dd.MM.yy HH:mm"), rec._PaymentStatus, changeToStatus, statusInfoTxt);
                    rec._PaymentStatus = changeToStatus;
                    rec._SendTime      = DateTime.MinValue;
                }
                else
                {
                    rec._ErrorInfo = string.Format("Change status from '{0}'->'{1}' not possible", rec._PaymentStatus, changeToStatus);
                }
            }
            else if (changeToStatus == PaymentStatusLevel.Resend)
            {
                if (rec._PaymentStatus != PaymentStatusLevel.Sent && rec._PaymentStatus != PaymentStatusLevel.Processed && rec._PaymentStatus != PaymentStatusLevel.PaymentReceived && rec._PaymentStatus != changeToStatus)
                {
                    statusInfoTxt      = string.Format("({0}) Status changed '{1}'->{2}\n{3}", DateTime.Now.ToString("dd.MM.yy HH:mm"), rec._PaymentStatus, changeToStatus, statusInfoTxt);
                    rec._PaymentStatus = changeToStatus;
                    rec._SendTime      = DateTime.MinValue;
                }
                else
                {
                    rec._ErrorInfo = string.Format("Change status from '{0}'->'{1}' not possible", rec._PaymentStatus, changeToStatus);
                }
            }
            else if (changeToStatus == PaymentStatusLevel.StopPayment)
            {
                if (rec._PaymentStatus == PaymentStatusLevel.Sent)
                {
                    var      today    = BasePage.GetSystemDefaultDate();
                    DateTime deadline = new DateTime(rec._PaymentDate.Year, rec._PaymentDate.Month, rec._PaymentDate.Day - 1, DirectDebitPaymentHelper.DEADLINE_TIMEOFDAY, 0, 0);
                    deadline = DirectDebitBankHolidays.AdjustBankDay(comp._CountryId, deadline, false);

                    if (today >= deadline)
                    {
                        rec._ErrorInfo = string.Format("'Stop Payment' not possible (Deadline {0}", deadline.ToString("dd-MM-yyyy kl. HH:mm"));
                        rec.NotifyErrorSet();
                    }
                    else
                    {
                        statusInfoTxt      = string.Format("({0}) Status changed '{1}'->{2}\n{3}", DateTime.Now.ToString("dd.MM.yy HH:mm"), rec._PaymentStatus, changeToStatus, statusInfoTxt);
                        rec._PaymentStatus = changeToStatus;
                        rec._SendTime      = DateTime.MinValue;
                    }
                }
                else
                {
                    rec._ErrorInfo = string.Format("Change status from '{0}'->'{1}' not possible", rec._PaymentStatus, changeToStatus);
                }
            }
            else if (changeToStatus == PaymentStatusLevel.OnHold)
            {
                if (rec._PaymentStatus != PaymentStatusLevel.Sent && rec._PaymentStatus != PaymentStatusLevel.Processed && rec._PaymentStatus != PaymentStatusLevel.PaymentReceived && rec._PaymentStatus != changeToStatus)
                {
                    statusInfoTxt      = string.Format("({0}) Status changed '{1}'->{2}\n{3}", DateTime.Now.ToString("dd.MM.yy HH:mm"), rec._PaymentStatus, changeToStatus, statusInfoTxt);
                    rec._PaymentStatus = changeToStatus;
                    rec._SendTime      = DateTime.MinValue;
                }
                else
                {
                    rec._ErrorInfo = string.Format("Change status from '{0}'->'{1}' not possible", rec._PaymentStatus, changeToStatus);
                }
            }

            while (statusInfoTxt != null && statusInfoTxt.Length > 1000)
            {
                statusInfoTxt = statusInfoTxt.Remove(statusInfoTxt.TrimEnd().LastIndexOf("\n"));
            }

            rec._StatusInfo = statusInfoTxt;
            rec.NotifyErrorSet();
        }