public override bool AppliesTo(Transaction transaction, BankOperation operation)
        {
            if (transaction.Type == TransactionType.Deposit)
            {
                return(false);
            }
            var cardTransaction = transaction as CardTransaction;

            if (cardTransaction == null)
            {
                return(false);
            }
            var userCard = _userCardRepository.Find(cardTransaction.Card.Id);

            if (userCard == null)
            {
                return(false);
            }
            var query = DbQuery.For <CardTransaction>()
                        .FilterBy(Specs.ForCardTransaction.Withdrawals && !Specs.ForCardTransaction.Failed && Specs.ForCardTransaction.ForToday(userCard.Id, _schedule.TimeZone));
            var transactionsForToday = _cardTransactionRepository.Query(query);
            var countForToday        = transactionsForToday.Count;
            var amountForToday       = transactionsForToday
                                       .Sum(x => - x.AccountAmount);
            var countLimit = _settings.IsLocalLocation(transaction.Location)
                ? userCard.Settings.Limits.OperationsPerDayLocal
                : userCard.Settings.Limits.OperationsPerDayAbroad;
            var amountLimit = _settings.IsLocalLocation(transaction.Location)
                ? userCard.Settings.Limits.AmountPerDayLocal
                : userCard.Settings.Limits.AmountPerDayAbroad;

            return(countForToday > countLimit || amountForToday > amountLimit);
        }
        public override bool AppliesTo(Transaction transaction, BankOperation operation)
        {
            var userAccount = transaction.Account as UserAccount;

            if (userAccount == null)
            {
                return(false);
            }
            if (operation != null)
            {
                var userOperation = _userBankOperationRepository.Find(operation.Id);
                if (userOperation != null && userOperation.User.UserName == "chuck")
                {
                    return(false);
                }
            }
            if (userAccount.Owner.UserName == "chuck")
            {
                var amount = transaction.TransactionAmount;
                if (transaction.Currency.ISOName != "USD")
                {
                    amount = _converter.Convert(new Money(transaction.Currency, amount), "USD").Amount;
                }
                if ((transaction.Type == TransactionType.Withdrawal && amount < -10) ||
                    (transaction.Type == TransactionType.Deposit && amount < 100))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 3
0
 public override bool AppliesTo(Transaction transaction, BankOperation operation)
 {
     var userAccount = transaction.Account as UserAccount;
     if (userAccount == null)
     {
         return false;
     }
     if (operation != null)
     {
         var userOperation = _userBankOperationRepository.Find(operation.Id);
         if (userOperation != null && userOperation.User.UserName == "chuck")
         {
             return false;
         }
     }
     if (userAccount.Owner.UserName == "chuck")
     {
         var amount = transaction.TransactionAmount;
         if (transaction.Currency.ISOName != "USD")
         {
             amount = _converter.Convert(new Money(transaction.Currency, amount), "USD").Amount;
         }
         if ((transaction.Type == TransactionType.Withdrawal && amount < -10)
             || (transaction.Type == TransactionType.Deposit && amount < 100))
         {
             return true;
         }
     }
     return false;
 }
Esempio n. 4
0
 public override bool AppliesTo(Transaction transaction, BankOperation operation)
 {
     if (transaction.Type == TransactionType.Deposit)
     {
         return false;
     }
     var cardTransaction = transaction as CardTransaction;
     if (cardTransaction == null)
     {
         return false;
     }
     var userCard = _userCardRepository.Find(cardTransaction.Card.Id);
     if (userCard == null)
     {
         return false;
     }
     var query = DbQuery.For<CardTransaction>()
         .FilterBy(Specs.ForCardTransaction.Withdrawals && !Specs.ForCardTransaction.Failed && Specs.ForCardTransaction.ForToday(userCard.Id, _schedule.TimeZone));
     var transactionsForToday = _cardTransactionRepository.Query(query);
     var countForToday = transactionsForToday.Count;
     var amountForToday = transactionsForToday
         .Sum(x => -x.AccountAmount);
     var countLimit = _settings.IsLocalLocation(transaction.Location)
         ? userCard.Settings.Limits.OperationsPerDayLocal
         : userCard.Settings.Limits.OperationsPerDayAbroad;
     var amountLimit = _settings.IsLocalLocation(transaction.Location)
         ? userCard.Settings.Limits.AmountPerDayLocal
         : userCard.Settings.Limits.AmountPerDayAbroad;
     return countForToday > countLimit || amountForToday > amountLimit;
 }
Esempio n. 5
0
 public TransactionProcessorCommand(Guid operationId, Transaction transaction, BankOperation bankOperation)
 {
     Argument.NotNull(transaction, "transaction");
     OperationId   = operationId;
     Transaction   = transaction;
     BankOperation = bankOperation;
 }
Esempio n. 6
0
        public UserBankOperation(BankOperation operation, User user)
        {
            Argument.NotNull(operation, "operation");
            Argument.NotNull(user, "user");

            Operation = operation;
            User = user;
            OperationId = operation.Id;
        }
Esempio n. 7
0
        public IActionResult Transfer([FromBody] BankOperation bankOperation)
        {
            if (bankOperation == null || bankOperation.Amount < _bankingService.GetBankOperationMinAmoun())
            {
                return(BadRequest(OperationDetails.Error("Transfer error")));
            }

            bankOperation.SenderId = _userIdentityService.GetUserId(User.Claims);
            var result = _bankingService.Transfer(bankOperation);

            return(result.Succeeded == true ? (IActionResult)Ok(result) : BadRequest(result));
        }
Esempio n. 8
0
        public override bool AppliesTo(Transaction transaction, BankOperation operation)
        {
            var cardTransaction = transaction as CardTransaction;

            if (cardTransaction == null)
            {
                return(false);
            }
            var userCard = _userCardRepository.Find(cardTransaction.Card.Id);

            return(userCard != null && userCard.IsExpired);
        }
Esempio n. 9
0
        public void GivenValidDescription_WhenParsed_OperationIsFilledWithData()
        {
            //Given
            string description = "           sdafasdfsa     ";
            var operation = new BankOperation();

            //When
            this.innaOperacja.Match(operation, description);

            //Then
            Assert.AreEqual("sdafasdfsa", operation.Description);
            Assert.AreEqual("INNA OPERACJA", operation.Type.Name);
        }
Esempio n. 10
0
        public void Match(BankOperation operation, string description)
        {
            var match = Regex.Match(description, Pattern);
            if (!match.Success)
            {
                _next.Match(operation, description);
                return;
            }

            operation.Type = _repositoryHelper.GetOrAddOperationType(Type);
            operation.CounterAccount = match.Groups[1].Value.Trim().Replace(" ", string.Empty);
            operation.Description = match.Groups[2].Value.Trim();
        }
Esempio n. 11
0
        public void GivenValidDescriptionOutgoing_WhenParsed_OperationIsFilledWithData()
        {
            //Given
            string description = "PRZELEW OBCIĄŻENIOWY asadfasfdsaf   01 2345 6789 0123 4567 8901 2347 Abc 1 Asadfasdf ";
            var operation = new BankOperation();

            //When
            this.przelewWychodzacy.Match(operation, description);

            //Then
            Assert.AreEqual("asadfasfdsaf", operation.Description);
            Assert.AreEqual("PRZELEW DO INNEGO BANKU", operation.Type.Name);
            Assert.AreEqual("01234567890123456789012347", operation.CounterAccount);
        }
Esempio n. 12
0
        public void GivenValidDescription_WhenParsed_OperationIsFilledWithData()
        {
            //Given
            string description = "PRZELEW NA RACHUNEK NUMER 12 3456 7890 1234 5678 9012 3456 Abc ";
            var operation = new BankOperation();

            //When
            this.przelew.Match(operation, description);

            //Then
            Assert.AreEqual("Abc", operation.Description);
            Assert.AreEqual("PRZELEW", operation.Type.Name);
            Assert.AreEqual("12345678901234567890123456", operation.CounterAccount);
        }
Esempio n. 13
0
 public override bool AppliesTo(Transaction transaction, BankOperation operation)
 {
     if (transaction.Type == TransactionType.Deposit)
     {
         return false;
     }
     var cardTransaction = transaction as CardTransaction;
     if (cardTransaction == null)
     {
         return false;
     }
     var userCard = _userCardRepository.Find(cardTransaction.Card.Id);
     return userCard != null && userCard.Settings.Blocked;
 }
Esempio n. 14
0
        public void GivenValidDescriptionIncomming_WhenParsed_OperationIsFilledWithData()
        {
            //Given
            string description = "PRZELEW UZNANIOWY (NADANO 01-10-2016) ABC WYPŁATA 01 10 2016    ABC. Z O.O.   UL.ABC 1 11-111 WARSZAWA  01 2345 6789 0123 4567 8901 2345 ABC CR/Aaaa ";
            var operation = new BankOperation();

            //When
            this.przelewPrzychodzacy.Match(operation, description);

            //Then
            Assert.AreEqual("ABC WYPŁATA 01 10 2016    ABC. Z O.O.   UL.ABC 1 11-111 WARSZAWA  01 2345 6789 0123 4567 8901 2345 ABC CR/Aaaa", operation.Description);
            Assert.AreEqual("PRZELEW PRZYCHODZĄCY", operation.Type.Name);
            Assert.AreEqual(new DateTime(2016, 10, 1), operation.OrderDate);
            Assert.AreEqual("01234567890123456789012345", operation.CounterAccount);
        }
        public override bool AppliesTo(Transaction transaction, BankOperation operation)
        {
            if (transaction.Type == TransactionType.Deposit)
            {
                return(false);
            }
            var cardTransaction = transaction as CardTransaction;

            if (cardTransaction == null)
            {
                return(false);
            }
            var userCard = _userCardRepository.Find(cardTransaction.Card.Id);

            return(userCard != null && userCard.Settings.Blocked);
        }
Esempio n. 16
0
        public void GivenValidDescription_WhenParsed_OperationIsFilledWithDataAndCardIsAdded()
        {
            //Given
            string description = "OPERACJA KARTĄ ZLOTA 123456XXXXXX7890 000001 WYPL ATA GOTÓWKI A111 BANK1 SA   10.11PLN D=04.10.2016  ";
            var operation = new BankOperation();

            //When
            this.parser.Match(operation, description);

            //Then
            Assert.AreEqual("WYPŁATA KARTĄ Z BANKOMATU A111 BANK1 SA", operation.Description);
            Assert.AreEqual("WYPŁATA KARTĄ Z BANKOMATU", operation.Type.Name);
            Assert.AreEqual(new DateTime(2016, 10, 4), operation.OrderDate);
            cardRepo.Verify(repo => repo.Add(
                It.Is<Card>(card =>
                card.CardNumber == "123456XXXXXX7890")));
            Assert.AreEqual("123456XXXXXX7890", operation.Card.CardNumber);
        }
Esempio n. 17
0
        public void GivenBankOperationXmlRepository_WhenElementAdded_ThenNextIdAssigned()
        {
            //Given
            var repo = new BankOperationXmlRepository(
                new Mock<IRepository<BankAccount, string>>().Object,
                new Mock<IRepository<BankOperationType, string>>().Object,
                new Mock<IRepository<BankStatement, int>>().Object);

            //When
            var bo1 = new BankOperation();
            var bo2 = new BankOperation();
            repo.Add(bo1);
            repo.Add(bo2);

            //Then
            Assert.AreEqual(1, bo1.Id);
            Assert.AreEqual(2, bo2.Id);
        }
Esempio n. 18
0
        public void GivenValidDescription_WhenParsed_OperationIsFilledWithDataAndCardIsAdded()
        {
            //Given
            string description = "OPERACJA KARTĄ ZLOTA 123456XXXXXX7891 000002 TRAN SAKCJA BEZGOTOWKOWA SKLEP SPOZYWCZY   23.00PLN D=04.10.2016   ";
            var operation = new BankOperation();

            //When
            this.parser.Match(operation, description);

            //Then
            Assert.AreEqual("SKLEP SPOZYWCZY", operation.Description);
            Assert.AreEqual("TRANSAKCJA KARTĄ PŁATNICZĄ", operation.Type.Name);
            Assert.AreEqual(new DateTime(2016, 10, 4), operation.OrderDate);
            cardRepo.Verify(repo => repo.Add(
                It.Is<Card>(card =>
                card.CardNumber == "123456XXXXXX7891")));
            Assert.AreEqual("123456XXXXXX7891", operation.Card.CardNumber);
        }
Esempio n. 19
0
        public CheckResult GetStatus(
            BankOperation boToCheck,
            IEnumerable<BankOperation> existing)
        {
            BankOperation existingOperation = existing.FirstOrDefault(a =>
                    a.OrderDate == boToCheck.OrderDate &&
                    a.ExecutionDate == boToCheck.ExecutionDate &&
                    a.Amount == boToCheck.Amount &&
                    a.EndingBalance == boToCheck.EndingBalance &&
                    DescriptionsAreEqual(a.Description, boToCheck.Description));

            if (existingOperation == null)
            {
                return new CheckResult() { Status = CheckStatus.New };
            }
            if (existingOperation.Cleared == false && boToCheck.Cleared == true)
            {
                return new CheckResult() { Status = CheckStatus.ExistingUncleared, ExistingOperation = existingOperation };
            }
            return new CheckResult() { Status = CheckStatus.Existing, ExistingOperation = existingOperation };
        }
Esempio n. 20
0
        public IEnumerable<BankOperation> Parse(Stream stream)
        {
            List<BankOperation> operations = new List<BankOperation>();
            using (var reader = new CsvReader(new StreamReader(stream, Encoding.Default), true, ';'))
            {
                while (reader.ReadNextRecord())
                {
                    BankOperation operation = new BankOperation();
                    operation.BankAccount = _repositoryHelper.GetOrAddAccount("BGZBNPParibas");
                    operation.ExecutionDate = _parseHelper.ParseDate(reader[0], "yyyy-MM-dd");
                    operation.OrderDate = operation.ExecutionDate;
                    operation.Amount = _parseHelper.ParseDecimalInvariant(reader[1]);
                    operation.EndingBalance = _parseHelper.ParseDecimalInvariant(reader[3]);
                    _fillDescription.Match(operation, reader[2]);
                    operation.Title = _parseHelper.GetFirstNCharacters(operation.Description, 30);
                    operations.Add(operation);
                }
            }

            return operations;
        }
Esempio n. 21
0
        public void OnNavigatedTo(ClassificationDefinition selected, BankOperation templateOperation)
        {
            if (selected == null)
            {
                EditMode = EditMode.Add;
                ClassificationDefinition newDefinition = new ClassificationDefinition();
                ClassificationRule newRule = new ClassificationRule();
                newDefinition.Rules.Add(newRule);

                if (templateOperation != null)
                {
                    newDefinition.Category = templateOperation.Category;
                    newDefinition.SubCategory = templateOperation.SubCategory;
                    newRule.RegularExpression = templateOperation.Description;
                    newRule.Account = templateOperation.BankAccount.Number;
                    newRule.CounterAccount = templateOperation.CounterAccount;
                }

                Data = newDefinition;
            }
            else
            {
                EditMode = EditMode.Edit;
                Data = _definitionsRepository.Get(selected.Id);
            }
        }
Esempio n. 22
0
 public abstract string GetErrorMessage(Transaction transaction, BankOperation operation);
 internal BankOperationProcessorCommand(Guid operationId, BankOperation bankOperation)
 {
     Argument.NotNull(bankOperation, "bankOperation");
     OperationId   = operationId;
     BankOperation = bankOperation;
 }
        public ActionResult SaveBankReceipt(BankReceipt bankReceipt)
        {
            RBACUser rUser = new RBACUser(Session["UserName"].ToString());

            if (!rUser.HasPermission("BankReceipt_Insert"))
            {
                return(Json("X", JsonRequestBehavior.AllowGet));
            }
            List <BankOperationVModel> CashOPVM = new List <BankOperationVModel>();
            var gset = _gsetService.All().LastOrDefault();

            try
            {
                var IfExit = _BankReceiptAppService.All().Where(x => x.BReceiptNo == bankReceipt.BReceiptNo).FirstOrDefault();
                if (IfExit == null)
                {
                    if (!string.IsNullOrEmpty(bankReceipt.purAccode) && bankReceipt.purAccode.Trim() != "Select Purpose")
                    {
                        bankReceipt.BranchCode   = Session["BranchCode"].ToString();
                        bankReceipt.bankAccode   = Session["BankAccode"].ToString();
                        bankReceipt.FinYear      = Session["FinYear"].ToString();
                        bankReceipt.NewChart     = _NewChartService.All().ToList().FirstOrDefault(x => x.Accode == bankReceipt.purAccode.Trim());
                        bankReceipt.bankNewChart = _NewChartService.All().ToList().FirstOrDefault(x => x.Accode == bankReceipt.bankAccode.Trim());


                        var           openBal       = GetOpenBal(bankReceipt.BReceiptDate);
                        var           rcecBal       = GetAllRemittances(bankReceipt.BReceiptDate, bankReceipt.BranchCode, bankReceipt.bankAccode).Sum(x => x.Amount);
                        var           payTotal      = GetAllPayment(bankReceipt.BReceiptDate, bankReceipt.BranchCode, bankReceipt.bankAccode).Sum(x => x.Amount);
                        var           closBal       = openBal + rcecBal - payTotal;
                        BankOperation bankOperation = new BankOperation(bankReceipt.BReceiptDate, openBal, bankReceipt.Amount, 0.0, closBal, bankReceipt.BranchCode, bankReceipt.FinYear, false, bankReceipt.bankAccode);


                        //cashReceipt.Customer = _CustomerService.All().ToList().FirstOrDefault(x => x.CustCode == cashReceipt.CustCode);
                        //BankOperation bankOperation = new BankOperation(bankReceipt.BReceiptDate, 0.0, 0.0, 0.0, 0.0, bankReceipt.BranchCode, bankReceipt.FinYear, false, bankReceipt.bankAccode);
                        var isAlreadySaved = _BankOperationService.All().ToList().FirstOrDefault(x => x.TrDate.ToString("MM-dd-yyyy") == bankReceipt.BReceiptDate.ToString("MM-dd-yyyy") && x.BranchCode == bankReceipt.BranchCode && x.bankAccode == bankReceipt.bankAccode);

                        if (isAlreadySaved == null)
                        {
                            using (var transaction = new TransactionScope())
                            {
                                try
                                {
                                    _BankOperationService.Add(bankOperation);
                                    _BankOperationService.Save();

                                    _BankReceiptAppService.Add(bankReceipt);
                                    _BankReceiptAppService.Save();

                                    //insert to provision
                                    LoadDropDown.journalVoucherSave("BR", "I", bankReceipt.BReceiptNo, bankReceipt.VoucherNo, bankReceipt.FinYear, "01", bankReceipt.BranchCode, bankReceipt.BReceiptDate, bankReceipt.bankAccode, Session["UserName"].ToString());

                                    TransactionLogService.SaveTransactionLog(_transactionLogService, "BankReceipt", "Save", bankReceipt.BReceiptNo, User.Identity.Name);
                                    CashOPVM = GetAllRemittances(bankReceipt.BReceiptDate, bankReceipt.BranchCode, bankReceipt.bankAccode);
                                    transaction.Complete();
                                }
                                catch (Exception)
                                {
                                    transaction.Dispose();
                                    return(Json("0", JsonRequestBehavior.AllowGet));
                                }
                            }
                            return(Json(CashOPVM, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            var rcecBals = GetAllRemittances(bankReceipt.BReceiptDate, bankReceipt.BranchCode, bankReceipt.bankAccode).Sum(x => x.Amount);
                            isAlreadySaved.RecTotal = rcecBals + bankReceipt.Amount;
                            isAlreadySaved.CloseBal = isAlreadySaved.OpenBal + isAlreadySaved.RecTotal - isAlreadySaved.PayTotal;

                            using (var transaction = new TransactionScope())
                            {
                                try
                                {
                                    _BankOperationService.Update(isAlreadySaved);
                                    _BankReceiptAppService.Save();

                                    _BankReceiptAppService.Add(bankReceipt);
                                    _BankReceiptAppService.Save();
                                    var sysSet = _sysSetService.All().FirstOrDefault();
                                    if (sysSet.CashRule == "O")
                                    {
                                        LoadDropDown.journalVoucherSave("BR", "I", bankReceipt.BReceiptNo, bankReceipt.VoucherNo, bankReceipt.FinYear, "01", bankReceipt.BranchCode, bankReceipt.BReceiptDate, bankReceipt.bankAccode, Session["UserName"].ToString());
                                    }
                                    //insert to provision
                                    LoadDropDown.BankRecalculate(bankReceipt.BReceiptDate, Convert.ToDecimal(bankReceipt.Amount), Session["ProjCode"].ToString(), bankReceipt.BranchCode, bankReceipt.FinYear, bankReceipt.bankAccode);
                                    TransactionLogService.SaveTransactionLog(_transactionLogService, "BankReceipt", "Save", bankReceipt.BReceiptNo, User.Identity.Name);
                                    CashOPVM = GetAllRemittances(bankReceipt.BReceiptDate, bankReceipt.BranchCode, bankReceipt.bankAccode);
                                    transaction.Complete();
                                }
                                catch (Exception)
                                {
                                    transaction.Dispose();
                                    return(Json("0", JsonRequestBehavior.AllowGet));
                                }
                            }

                            return(Json(CashOPVM, JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        return(Json("0", JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json("1", JsonRequestBehavior.AllowGet));
                }
            }

            catch (Exception)
            {
                return(Json("0", JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 25
0
 protected override DateTime? PostponeDateOrNull(BankOperation operation)
 {
     return null;
 }
 public abstract bool CanProcess(BankOperation operation);
 /// <summary>
 /// Execute operation, save it and save account operation balance afterwards
 /// </summary>
 /// <param name="operation">operation to execute and save</param>
 /// <param name="account">account to save</param>
 public void ExecuteAndSave(BankOperation operation, IPublicAccount account)
 {
     operation.Execute();
     _dataInserter.SaveOperation(operation);
     _dataInserter.SaveAccountBalance(account);
 }
 public bool CanProcess(Transaction transaction, BankOperation operation)
 {
     return(true);
 }
 public override string GetErrorMessage(Transaction transaction, BankOperation operation)
 {
     return(Messages.CardLimitsExceeded);
 }
 public override string GetErrorMessage(Transaction transaction, BankOperation operation)
 {
     return(Messages.AccountExpired);
 }
 public override bool AppliesTo(Transaction transaction, BankOperation operation)
 {
     return(transaction.Account.IsExpired);
 }
 public override string GetErrorMessage(Transaction transaction, BankOperation operation)
 {
     return(Messages.CardBlocked);
 }
Esempio n. 33
0
 public abstract bool CanProcess(BankOperation operation);
Esempio n. 34
0
 public TransactionName ForOperation(BankOperation operation)
 {
     Argument.NotNull(operation, "operation");
     return new TransactionName(operation.Category.Code, operation.Category.Name);
 }
 public override bool CanProcess(BankOperation operation)
 {
     return(operation.Category.Code.StartsWith("PAYMENT") && operation is CardPayment);
 }
Esempio n. 36
0
 /// <summary>
 /// does nothing
 /// </summary>
 /// <param name="operation">anything (ignored)</param>
 public void SaveOperation(BankOperation operation)
 {
 }
Esempio n. 37
0
 private void InitPropertyWithTestData(PropertyInfo propertyInfo, BankOperation operation, int propertyNumber, int operationNumber)
 {
     var valueToSet = GetDefaultTestValueForProperty(propertyInfo.PropertyType, propertyNumber, operationNumber);
     propertyInfo.SetValue(operation, valueToSet);
 }
Esempio n. 38
0
 public override string GetErrorMessage(Transaction transaction, BankOperation operation)
 {
     return Messages.AccountExpired;
 }
 protected abstract DateTime?PostponeDateOrNull(BankOperation operation);
Esempio n. 40
0
 protected abstract DateTime? PostponeDateOrNull(BankOperation operation);
Esempio n. 41
0
 public override bool AppliesTo(Transaction transaction, BankOperation operation)
 {
     return transaction.Account.IsExpired;
 }
Esempio n. 42
0
 private void AddNew(BankStatement statement, BankOperation item)
 {
     _operationRepository.Add(item);
     statement.Operations.Add(item);
     statement.New++;
 }
Esempio n. 43
0
 public override string GetErrorMessage(Transaction transaction, BankOperation operation)
 {
     return(Messages.ChuckNorrisPolicy);
 }
Esempio n. 44
0
 public abstract DateTime GetPostDateUtc(Transaction transaction, BankOperation operation);
Esempio n. 45
0
        /// <summary>
        /// <see cref="IBankDataInserter.SaveOperation"/>
        /// </summary>
        public void SaveOperation(BankOperation operation)
        {
            var accountId = _indexesFinder.GetAccountId(operation.AccountNumber.InnerNumber);

            _dataSaver.SaveOperationToHistory(accountId, operation.OperationRecord);
        }
        public ActionResult BankOperation(BankOperation bankOperation, string errMsg)
        {
            if (bankOperation.bankAccode == null)
            {
                bankOperation.bankAccode = Session["BankAccode"].ToString();
                var bankInfo = _newChartService.All().ToList().FirstOrDefault(x => x.Accode == bankOperation.bankAccode);
                ViewBag.bankAccode    = bankInfo.AcName;
                Session["BankAccode"] = bankInfo.Accode;
            }
            else
            {
                var bankInfo = _newChartService.All().ToList().FirstOrDefault(x => x.Accode == bankOperation.bankAccode);
                ViewBag.bankAccode    = bankInfo.AcName;
                Session["BankAccode"] = bankInfo.Accode;
            }
            List <NewChart> charts = _newChartService.All().ToList().Where(x => x.Accode.Substring(0, 1) == "1" || x.Accode.Substring(0, 1) == "3" || x.Accode.Substring(0, 1) == "2").ToList();
            // List<NewChart> charts = _newChartService.All().ToList().Where(x => x.Accode.Substring(0, 1) == "3").ToList();
            List <NewChart> finalList = new List <NewChart>();

            foreach (var chart in charts)
            {
                bool key = true;
                foreach (var temp in charts)
                {
                    if (chart == temp)
                    {
                    }
                    else
                    {
                        if (chart.Accode == temp.ParentAcCode)
                        {
                            key = false;
                        }
                    }
                }
                if (key)
                {
                    finalList.Add(chart);
                }
            }
            ViewBag.brPurAccode = new SelectList(finalList, "Accode", "AcName");

            List <NewChart> echarts    = _newChartService.All().ToList().Where(x => x.Accode.Substring(0, 1) == "1" || x.Accode.Substring(0, 1) == "2" || x.Accode.Substring(0, 1) == "4").ToList();
            List <NewChart> efinalList = new List <NewChart>();

            foreach (var chart in echarts)
            {
                bool key = true;
                foreach (var temp in echarts)
                {
                    if (chart == temp)
                    {
                    }
                    else
                    {
                        if (chart.Accode == temp.ParentAcCode)
                        {
                            key = false;
                        }
                    }
                }
                if (key)
                {
                    efinalList.Add(chart);
                }
            }
            ViewBag.purAccode = new SelectList(efinalList, "Accode", "AcName");
            ViewBag.SubCode   = new SelectList(_subsidiaryService.All().ToList(), "SubCode", "SubName");
            ViewBag.bankCode  = new SelectList(_BankInfoService.All().ToList(), "BankCode", "BankName");
            DateTime datetime = DateTime.Now;

            ViewBag.Date = datetime.ToString("dd/MM/yyyy");
            string branchCode = Session["BranchCode"].ToString();
            string bankAccode = Session["BankAccode"].ToString();

            //ViewBag.OpenBal = GetOpenBal(DateTime.Now, bankAccode);
            ViewBag.OpenBal = GetOpenBal(datetime);

            ViewBag.GLProvition  = Counter("BOR", "PV");
            ViewBag.GLEntries    = CountVoucherMain("BOR", "MV", datetime);
            ViewBag.GLProvitionB = Counter("BOP", "PV");
            ViewBag.GLEntriesB   = CountVoucherMain("BOP", "MV", datetime);

            var bank = new List <BankOperationVModel>();

            bank = GetAllRemittances(datetime, branchCode, bankAccode);
            GetAllPayment(datetime, branchCode, bankAccode).ForEach(x => bank.Add(x));
            ViewBag.Items = bank;
            ViewBag.JobNo = LoadDropDown.LoadJobInfo();
            //By Farhad For Remittance button/popup will be show/hide.
            var sysSet = _sysSetService.All().ToList().FirstOrDefault();

            ViewBag.MrConv           = sysSet.MRConv;
            ViewBag.MaintJob         = sysSet.MaintJob;
            Session["MaintLot"]      = sysSet.MaintLot;
            ViewBag.MaintLot         = sysSet.MaintLot;
            ViewBag.HasRemittance    = sysSet.HasRemittance;
            ViewBag.IsSubsidiaryCtrl = sysSet.IsSubsidiaryCtrl;
            if (sysSet.IsSubsidiaryCtrl == true)
            {
                ViewBag.brSubCode = LoadDropDown.LoadSubsidiaryByPurpuse("", _subsidiaryService, _subsidiaryCtrlService);
            }
            else
            {
                ViewBag.brSubCode = LoadDropDown.LoadSubsidiary(_subsidiaryService);
            }
            ViewBag.errMsg = errMsg;
            //For us Culture Ex: 0.00
            const string culture = "en-US";
            CultureInfo  ci      = CultureInfo.GetCultureInfo(culture);

            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
            return(View());
        }
Esempio n. 47
0
 /// <summary>
 /// does nothing
 /// </summary>
 /// <param name="account">anything (ignored)</param>
 /// <param name="operation">anything (ignored)</param>
 public void SaveOperation(IPublicAccount account, BankOperation operation)
 {
 }
Esempio n. 48
0
 public override string GetErrorMessage(Transaction transaction, BankOperation operation)
 {
     return Messages.ChuckNorrisPolicy;
 }
Esempio n. 49
0
 public override string GetErrorMessage(Transaction transaction, BankOperation operation)
 {
     return Messages.CardLimitsExceeded;
 }
Esempio n. 50
0
 public abstract bool AppliesTo(Transaction transaction, BankOperation operation);
Esempio n. 51
0
 public TransactionName ForOperation(BankOperation operation)
 {
     Argument.NotNull(operation, "operation");
     return(new TransactionName(operation.Category.Code, operation.Category.Name));
 }
Esempio n. 52
0
 public abstract DateTime GetScheduledDateUtc(Transaction transaction, BankOperation operation);
Esempio n. 53
0
        public ActionResult SavePayment(Payment payment)
        {
            RBACUser rUser = new RBACUser(Session["UserName"].ToString());

            if (!rUser.HasPermission("BankPayment_Insert"))
            {
                return(Json("X", JsonRequestBehavior.AllowGet));
            }
            List <BankOperationVModel> CashOPVM = new List <BankOperationVModel>();
            var gset = _gsetService.All().LastOrDefault();

            try
            {
                var IfExit = _paymentService.All().Where(x => x.PayCode == payment.PayCode).FirstOrDefault();
                if (IfExit == null)
                {
                    payment.BranchCode = Session["BranchCode"].ToString();
                    payment.FinYear    = Session["FinYear"].ToString();
                    payment.bankAccode = Session["BankAccode"].ToString();


                    var openBal  = GetOpenBal(payment.PayDate);
                    var rcecBal  = GetAllRemittances(payment.PayDate, payment.BranchCode, payment.bankAccode).Sum(x => x.Amount);
                    var payTotal = GetAllPayment(payment.PayDate, payment.BranchCode, payment.bankAccode).Sum(x => x.Amount);
                    var closBal  = openBal + rcecBal - payTotal;

                    BankOperation bankOperation = new BankOperation(payment.PayDate, openBal, 0.0, payment.Amount, closBal, payment.BranchCode, payment.FinYear, false, payment.bankAccode);
                    // BankOperation bankOperation = new BankOperation(payment.PayDate, 0.0, 0.0, 0.0, 0.0, payment.BranchCode, payment.FinYear, false, payment.bankAccode);
                    var isAlreadySaved = _bankOperationService.All().ToList().FirstOrDefault(x => x.TrDate.ToString("MM-dd-yyyy") == payment.PayDate.ToString("MM-dd-yyyy") && x.BranchCode == payment.BranchCode && x.bankAccode == payment.bankAccode);

                    if (isAlreadySaved == null)
                    {
                        using (var transaction = new TransactionScope())
                        {
                            try
                            {
                                _bankOperationService.Add(bankOperation);
                                _bankOperationService.Save();
                                _paymentService.Add(payment);
                                _paymentService.Save();
                                //Insert to provision
                                LoadDropDown.journalVoucherSave("BP", "I", payment.PayCode, payment.VoucherNo, payment.FinYear, "01", payment.BranchCode, payment.PayDate, payment.bankAccode, Session["UserName"].ToString());
                                TransactionLogService.SaveTransactionLog(_transactionLogService, "Payment", "Save", payment.PayCode, User.Identity.Name);
                                CashOPVM = GetAllPayment(payment.PayDate, payment.BranchCode, payment.bankAccode);
                                transaction.Complete();
                            }
                            catch (Exception)
                            {
                                transaction.Dispose();
                                return(Json("0", JsonRequestBehavior.AllowGet));
                            }
                        }
                        return(Json(CashOPVM, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        var payTotals = GetAllPayment(payment.PayDate, payment.BranchCode, payment.bankAccode).Sum(x => x.Amount);
                        isAlreadySaved.PayTotal = payTotals + payment.Amount;
                        isAlreadySaved.CloseBal = isAlreadySaved.OpenBal + isAlreadySaved.RecTotal - isAlreadySaved.PayTotal;
                        using (var transaction = new TransactionScope())
                        {
                            try
                            {
                                _bankOperationService.Update(isAlreadySaved);
                                _bankOperationService.Save();
                                _paymentService.Add(payment);
                                _paymentService.Save();
                                //Insert to provision
                                LoadDropDown.journalVoucherSave("BP", "I", payment.PayCode, payment.VoucherNo, payment.FinYear, "01", payment.BranchCode, payment.PayDate, payment.bankAccode, Session["UserName"].ToString());
                                var sysSet = _sysSetService.All().FirstOrDefault();
                                if (sysSet.CashRule == "O")
                                {
                                    LoadDropDown.BankRecalculate(payment.PayDate, Convert.ToDecimal(payment.Amount), Session["ProjCode"].ToString(), payment.BranchCode, payment.FinYear, payment.bankAccode);
                                }
                                TransactionLogService.SaveTransactionLog(_transactionLogService, "Payment", "Save", payment.PayCode, User.Identity.Name);
                                CashOPVM = GetAllPayment(payment.PayDate, payment.BranchCode, payment.bankAccode);
                                transaction.Complete();
                            }
                            catch (Exception)
                            {
                                transaction.Dispose();
                                return(Json("0", JsonRequestBehavior.AllowGet));
                            }
                        }

                        return(Json(CashOPVM, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json("1", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                return(Json("0", JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 54
0
        private void CheckOperation(BankOperation operation, BankAccount account, BankOperationType opType)
        {
            Assert.AreEqual(account.Id, operation.BankAccount.Id);
            Assert.AreEqual(opType.Id, operation.Type.Id);
            var properties = GetPropertiesForAutoInitialization();

            for (int propertyNumber = 0; propertyNumber < properties.Length; propertyNumber++)
            {
                var property = properties[propertyNumber];
                var expectedValue = GetDefaultTestValueForProperty(property.PropertyType, propertyNumber + 1, operation.Id);
                var currentValue = properties[propertyNumber].GetValue(operation);
                Assert.AreNotEqual(GetDefaultValue(property.PropertyType), currentValue,
                    string.Format("Property {0} has unexpected default value", property.Name));
                Assert.AreEqual(expectedValue, currentValue,
                    string.Format("Property {0} has unexpected value. Expected {1}, Current {2}.", property.Name, expectedValue, currentValue));
            }
        }
        public ActionResult SaveDepositToBank(Deposit deposit)
        {
            RBACUser rUser = new RBACUser(Session["UserName"].ToString());

            if (!rUser.HasPermission("BankDeposit_Insert"))
            {
                return(Json("X", JsonRequestBehavior.AllowGet));
            }
            List <CashOperationVModel> CashOPVM = new List <CashOperationVModel>();

            try
            {
                var IfExit = _DepositToBankService.All().Where(x => x.DepositNo == deposit.DepositNo).FirstOrDefault();
                if (IfExit == null)
                {
                    if (!string.IsNullOrEmpty(deposit.bankAccode) && deposit.bankAccode.Trim() != "Select Bank A/C")
                    {
                        deposit.BranchCode = Session["BranchCode"].ToString();
                        var GCa = _AcBrService.All().Where(s => s.BranchCode == deposit.BranchCode && s.Ca_Ba == "Ca").Select(x => x.Accode).FirstOrDefault();
                        if (GCa == null)
                        {
                            var gset = _gsetService.All().LastOrDefault();
                            GCa = gset.GCa;
                        }

                        deposit.FinYear  = Session["FinYear"].ToString();
                        deposit.NewChart = _NewChartService.All().ToList().FirstOrDefault(x => x.Accode == deposit.bankAccode.Trim());
                        //cashReceipt.Customer = _CustomerService.All().ToList().FirstOrDefault(x => x.CustCode == cashReceipt.CustCode);
                        CashOperation cashOperation   = new CashOperation(deposit.DepositDate, 0.0, 0.0, 0.0, 0.0, "", DateTime.Now, false, deposit.FinYear, false, deposit.BranchCode);
                        var           isAlreadyClosed = _CashOperationService.All().ToList().FirstOrDefault(x => x.BranchCode == deposit.BranchCode && x.TrDate.ToString("MM-dd-yyyy") == deposit.DepositDate.ToString("MM-dd-yyyy"));


                        var           openBal       = GetOpenBal(deposit.DepositDate, deposit.bankAccode);
                        var           rcecBal       = GetAllRemittances(deposit.DepositDate, deposit.BranchCode, deposit.bankAccode).Sum(x => x.Amount);
                        var           payTotal      = GetAllPayment(deposit.DepositDate, deposit.BranchCode, deposit.bankAccode).Sum(x => x.Amount);
                        var           closBal       = openBal + rcecBal - payTotal;
                        BankOperation bankOperation = new BankOperation(deposit.DepositDate, openBal, deposit.Amount, 0.0, closBal, deposit.BranchCode, deposit.FinYear, false, deposit.bankAccode);

                        var sysSet = _sysSetService.All().FirstOrDefault();


                        var isAlreadySaved = _BankOperationService.All().ToList().FirstOrDefault(x => x.TrDate.ToString("MM-dd-yyyy") == deposit.DepositDate.ToString("MM-dd-yyyy") && x.BranchCode == deposit.BranchCode && x.bankAccode == deposit.bankAccode);

                        if (isAlreadyClosed == null || isAlreadySaved == null)
                        {
                            using (var transaction = new TransactionScope())
                            {
                                try
                                {
                                    _CashOperationService.Add(cashOperation);
                                    _CashOperationService.Save();
                                    _BankOperationService.Add(bankOperation);
                                    _BankOperationService.Save();
                                    _DepositToBankService.Add(deposit);
                                    _DepositToBankService.Save();
                                    TransactionLogService.SaveTransactionLog(_transactionLogService, "Deposit To Bank", "Save", deposit.DepositNo, Session["UserName"].ToString());
                                    LoadDropDown.journalVoucherSave("BD", "I", deposit.DepositNo, deposit.VoucherNo, deposit.FinYear, "01", deposit.BranchCode, deposit.DepositDate, GCa, Session["UserName"].ToString());
                                    CashOPVM = GetAllExpenseAndDeposit(deposit.DepositDate, deposit.BranchCode);
                                    transaction.Complete();
                                }
                                catch (Exception)
                                {
                                    transaction.Dispose();
                                    return(Json("0", JsonRequestBehavior.AllowGet));
                                }
                                return(Json(CashOPVM, JsonRequestBehavior.AllowGet));
                            }
                        }
                        else if (isAlreadyClosed != null && sysSet.CashRule == "O" ? true : isAlreadyClosed.IsClosed == false)
                        {
                            var rcecBals = GetAllRemittances(deposit.DepositDate, deposit.BranchCode, deposit.bankAccode).Sum(x => x.Amount);
                            isAlreadySaved.RecTotal = rcecBals + deposit.Amount;
                            isAlreadySaved.CloseBal = isAlreadySaved.OpenBal + isAlreadySaved.RecTotal - isAlreadySaved.PayTotal;

                            using (var transaction = new TransactionScope())
                            {
                                try
                                {
                                    _BankOperationService.Update(isAlreadySaved);
                                    _BankReceiptAppService.Save();
                                    _DepositToBankService.Add(deposit);
                                    _DepositToBankService.Save();
                                    TransactionLogService.SaveTransactionLog(_transactionLogService, "Deposit To Bank", "Save", deposit.DepositNo, Session["UserName"].ToString());
                                    LoadDropDown.journalVoucherSave("BD", "I", deposit.DepositNo, deposit.VoucherNo, deposit.FinYear, "01", deposit.BranchCode, deposit.DepositDate, GCa, Session["UserName"].ToString());
                                    if (sysSet.CashRule == "O")
                                    {
                                        LoadDropDown.CashRecalculate(Session["ProjCode"].ToString(), deposit.BranchCode, deposit.FinYear, Convert.ToDecimal(deposit.Amount), deposit.DepositDate);
                                    }
                                    CashOPVM = GetAllExpenseAndDeposit(deposit.DepositDate, deposit.BranchCode);
                                    transaction.Complete();
                                }
                                catch (Exception)
                                {
                                    transaction.Dispose();
                                    return(Json("0", JsonRequestBehavior.AllowGet));
                                }
                                return(Json(CashOPVM, JsonRequestBehavior.AllowGet));
                            }
                        }
                        else
                        {
                            return(Json("2", JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        return(Json("1", JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json("3", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json("0", JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 56
0
        private BankOperation InitOperationWithTestData(
            int id,
            BankAccount account,
            BankOperationType operationType,
            Card card)
        {
            var operation = new BankOperation()
            {
                Id = 1,
                BankAccount = account,
                Type = operationType,
                Card = card
            };

            var properties = GetPropertiesForAutoInitialization();

            for (int propertyNumber = 0; propertyNumber < properties.Length; propertyNumber++)
            {
                InitPropertyWithTestData(properties[propertyNumber], operation, propertyNumber + 1, id);
            }

            return operation;
        }
 protected override DateTime?PostponeDateOrNull(BankOperation operation)
 {
     return(null);
 }
Esempio n. 58
0
 public BankAccountCommand(BankAccount bankAccount, BankOperation operation, double amount)
 {
     _bankAccount = bankAccount;
     _operation   = operation;
     _amount      = amount;
 }
Esempio n. 59
0
 public abstract bool AppliesTo(Transaction transaction, BankOperation operation);
Esempio n. 60
0
 public override string GetErrorMessage(Transaction transaction, BankOperation operation)
 {
     return Messages.CardBlocked;
 }