void CheckFields(PaymentReason PaymentReason)
 {
     if (string.IsNullOrWhiteSpace(PaymentReason.Reason))
     {
         throw new NotNullException("Ödeme Sebebi");
     }
 }
        /// <summary>
        /// Возвращает строковое представление причины оплаты
        /// </summary>
        public static String GetString(this PaymentReason reason)
        {
            string s;

            switch (reason)
            {
            case PaymentReason.Parking:
                s = "Оплата парковки";
                break;

            case PaymentReason.Fine:
                s = "Штраф";
                break;

            case PaymentReason.ECash:
                s = "Пополнение электронного кошелька";
                break;

            case PaymentReason.Any:
                s = "Произвольный платеж";
                break;

            case PaymentReason.Refund:
                s = "Возврат денег";
                break;

            default:
                s = reason.ToString();
                break;
            }

            return(s);
        }
        public bool Add(PaymentReason PaymentReason)
        {
            CheckFields(PaymentReason);
            int result = _paymentReasonManagement.Insert(PaymentReason);

            return(result > 0);
        }
Exemplo n.º 4
0
        private void btnAddPaymentReason_Click(object sender, EventArgs e)
        {
            currentPay        = new PaymentReason();
            currentPay.Reason = txtAddPaymentReason.Text;
            PaymentReasonType = _paymentReasonController.GetPaymentReasons();

            foreach (PaymentReason item in PaymentReasonType)
            {
                if (txtAddPaymentReason.Text == item.Reason)
                {
                    throw new PaymentReasonException();
                }
            }
            try
            {
                bool result = _paymentReasonController.Add(currentPay);

                if (result)
                {
                    MessageBox.Show("Ödeme nedeni ekleme başarılı");
                    FillList();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        public PaymentReason GetPaymentReasonByID(int PaymentReasonID)
        {
            string query = "SELECT * FROM [PaymentReason] WHERE PaymentReasonID = @reasonID";

            h.AddParametersToCommand(new List <SqlParameter>()
            {
                new SqlParameter()
                {
                    ParameterName = "@reasonID",
                    Value         = PaymentReasonID
                }
            });

            PaymentReason currentPaymentReason = new PaymentReason();
            SqlDataReader reader = h.MyExecuteReader(query);

            reader.Read();

            currentPaymentReason.ReasonID = (int)reader["ReasonID"];
            currentPaymentReason.Reason   = reader["Reason"].ToString();

            reader.Close();

            return(currentPaymentReason);
        }
        public bool Update(PaymentReason PaymentReason)
        {
            CheckFields(PaymentReason);
            int result = _paymentReasonManagement.Update(PaymentReason);

            return(result > 0);
        }
Exemplo n.º 7
0
        public int Update(PaymentReason PaymentReason)
        {
            string query = "UPDATE [PaymentReason] SET Reason = @reason  WHERE ReasonID=@reasonID";
            List <SqlParameter> parameters = GetParameters(PaymentReason, true);

            h.AddParametersToCommand(parameters);
            return(h.MyExecuteQuery(query));
        }
 /// <summary>
 /// Возвращает строковое представление данных платежа
 /// </summary>
 public override string ToString()
 {
     return(String.Format("\r\nAmount = {0:C}\r\n PayType = {1}\r\n Type = {2}\r\n CurrencyType = {3}\r\n" +
                          "CardNumber = {4:X}\r\n TimeIn = {5}\r\n TimeOut = {5}\r\n Paid = {7:C}\r\n" +
                          "ECash = {8:C}",
                          Amount, PaymentReason.GetString(), Type, PaymentType, CardId,
                          TimeEntry, TimeExit, Payment, ECash));
 }
Exemplo n.º 9
0
        public int Insert(PaymentReason paymentReason)
        {
            string query = "INSERT INTO [PaymentReason](Reason) VALUES(@reason)";
            List <SqlParameter> parameters = GetParameters(paymentReason, true);

            h.AddParametersToCommand(parameters);
            return(h.MyExecuteQuery(query));
        }
Exemplo n.º 10
0
        private void btnUpdatePayReason_Click(object sender, EventArgs e)
        {
            currentPay          = new PaymentReason();
            currentPay.ReasonID = (int)dgvPaymentReasons.SelectedRows[0].Cells[0].Value;

            currentPay.Reason = txtUpdatePayReason.Text;
            _paymentReasonController.Update(currentPay);
            FillList();
        }
Exemplo n.º 11
0
        List <SqlParameter> GetParameters(PaymentReason paymentReason, bool isInsert)
        {
            List <SqlParameter> parameters = new List <SqlParameter>();

            if (isInsert)
            {
                parameters.Add(new SqlParameter("@reasonID", paymentReason.ReasonID));
            }
            parameters.Add(new SqlParameter("@reason", paymentReason.Reason));

            return(parameters);
        }
 public PaymentDocument(double amount, PaymentReason paymentReason, DocumentType documentType, PaymentType paymentType,
                        int cardId, DateTime timeEntry, DateTime timeExit, double payment, double debt, double eCash)
 {
     Amount        = amount;
     PaymentReason = paymentReason;
     Type          = documentType;
     PaymentType   = paymentType;
     CardId        = cardId;
     TimeEntry     = timeEntry;
     TimeExit      = timeExit;
     Payment       = payment;
     Debt          = debt;
     ECash         = eCash;
 }
Exemplo n.º 13
0
        public List <PaymentReason> GetAllPaymentReasons()
        {
            List <PaymentReason> PaymentReasons = new List <PaymentReason>();
            string query = "SELECT * FROM [PaymentReason]";

            PaymentReason currentPaymentReason;
            SqlDataReader reader = h.MyExecuteReader(query);

            while (reader.Read())
            {
                currentPaymentReason          = new PaymentReason();
                currentPaymentReason.Reason   = reader["Reason"].ToString();
                currentPaymentReason.ReasonID = (int)reader["ReasonID"];

                PaymentReasons.Add(currentPaymentReason);
            }
            reader.Close();

            return(PaymentReasons);
        }
Exemplo n.º 14
0
        public async Task MakePaymentTest(PaymentReason paymentReason, decimal difference)
        {
            // Arrange
            var userId            = _seeder.PaymentUser.Id;
            var userOpenSumBefore = (await _seeder.CreateUserService().GetOpenAmountAsync(userId));
            var nearbyTime        = DateTime.Now;

            // Act
            var paymentCreatedResponse =
                await _seeder.CreateUserService().MakePaymentAsync(userId, 10m, paymentReason);

            var openSumAfter = (await _seeder.CreateUserService().GetOpenAmountAsync(userId));

            // Assert
            openSumAfter.Should().Be(userOpenSumBefore + difference);
            openSumAfter.Should().Be(paymentCreatedResponse.OpenAmount);
            var payment = paymentCreatedResponse.Payment;

            payment.Should().NotBeNull();
            payment.CreatedAt.Should().BeAfter(nearbyTime).And.BeBefore(DateTime.Now);
            payment.Reason.Should().Be(paymentReason);
            payment.ApplicationUserId.Should().Be(userId);
            payment.Amount.Should().Be(paymentReason == PaymentReason.Payout ? -10m : 10m);
        }
Exemplo n.º 15
0
 public async Task Add(int userId, decimal amount, PaymentReason reason)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 16
0
 public async Task <ApplicationUser> Update(string id, decimal amount, PaymentReason reason)
 {
     return(await _userServiceImplementation.Update(id, amount, reason));
 }
Exemplo n.º 17
0
        public void Pay(string email, int dayValue, int nightValue, decimal cost,
                        PaymentReason paymentReason, string description, bool isWithoutCheck)
        {
            if (Customer.Value == null)
            {
                throw new Exception("Отсутствует плательщик");
            }

            var errors = new List <string>();

            if (cost <= 0)
            {
                errors.Add($"Сумма платежа должна быть положительна ({cost})");
            }

            if (!Customer.Value.IsNormative() && dayValue < Customer.Value.DayValue)
            {
                errors.Add($"Новое показание дневного счетчика меньше предыдущего ({dayValue} < {Customer.Value.DayValue})");
            }

            if (!Customer.Value.IsNormative() && Customer.Value.IsTwoTariff() && nightValue < Customer.Value.NightValue)
            {
                errors.Add($"Новое показание ночного счетчика меньше меньше предыдущего ({nightValue} < {Customer.Value.NightValue})");
            }

            if (paymentReason == null)
            {
                errors.Add("Основание для оплаты не задано");
            }

            var isEmailChange = !string.IsNullOrEmpty(email) && Customer.Value.Email != email;

            if (isEmailChange)
            {
                if (!StringUtils.IsValidEmail(email))
                {
                    errors.Add("Адрес электронной почты имеет не верный формат");
                }
            }

            if (errors.Count > 0)
            {
                throw new IncorrectDataException(errors);
            }

            if (isEmailChange)
            {
                Log.Info($"Изменение email плательщика за электроэнергию с {Customer.Value.Email} на {email}");
                Customer.Value.Email = email;
                RepositoriesFactory.Get <EnergyCustomer>().Update(Customer.Value);
            }

            var operationName = $"Платеж за электроэнергию: email={email}, dayValue={dayValue}; nightValue={nightValue}; cost={cost}; paymentReason={paymentReason.Name}; description={description}, isWithoutCheck={isWithoutCheck}";

            Log.Info($"Старт -> {operationName}");

            if (isWithoutCheck || TryPrintChecks(cost, Customer.Value.Department.Code, Customer.Value.Number, Customer.Value.Name, paymentReason.Name, Customer.Value.Email))
            {
                var payment = new EnergyCustomerPayment
                {
                    CustomerId    = Customer.Value.Id,
                    NewDayValue   = dayValue,
                    NewNightValue = nightValue,
                    Cost          = cost,
                    ReasonId      = paymentReason.Id,
                    CreateDate    = DateTime.Now,
                    Description   = description,
                    FiscalNumber  = 0 // TODO: Fill fiscal
                };

                RepositoriesFactory.Get <EnergyCustomerPayment>().Add(payment);

                Log.Info($"Успешно завершено -> {operationName}");
            }
            else
            {
                Log.Info($"Не произведено -> {operationName}");
                throw new Exception("Платеж не произведен");
            }
        }
Exemplo n.º 18
0
        public async Task <PaymentCreatedResponse> MakePaymentAsync(Guid userId, decimal amount, PaymentReason reason)
        {
            await EnsureExists(userId);

            if (reason == PaymentReason.Payout)
            {
                amount *= -1;
            }
            var payment = new Payment
            {
                Amount = amount, Reason = reason, CreatedAt = DateTime.Now, ApplicationUserId = userId
            };
            await Context.Payments.AddAsync(payment);

            await Context.SaveChangesAsync();

            return(new PaymentCreatedResponse(payment, await GetOpenAmountAsync(userId)));
        }
        public bool Delete(PaymentReason PaymentReason)
        {
            int result = _paymentReasonManagement.Delete(PaymentReason.ReasonID);

            return(result > 0);
        }