Beispiel #1
0
        void ProceedImport()
        {
            List <string> paths = _iOutput.FilePathProvider.GetFilePaths();

            if (paths.IsNullObj())
            {
                return;
            }

            List <FileData>             fileDatas = new List <FileData>();
            FileTransactionDataProvider provider  = new FileTransactionDataProvider();

            foreach (string path in paths)
            {
                provider.FilePath = path;
                FileData fileData = provider.GetTransactionData();
                fileDatas.Add(fileData);
            }

            GetTransactionsAction.Data getTransactionData = new GetTransactionsAction.Data()
            {
                FileDatas = fileDatas,
                Parsers   = _import.GetParsers(),
            };
            GetTransactionsAction getTransaction = new GetTransactionsAction();

            GetTransactionsAction.Result getTransactionResult = getTransaction.Execute(getTransactionData);

            var transactions = getTransactionResult.Reports.SelectMany(r => r.Transactions).ToList();

            AttachRulesAction.Data attachRulesData = new AttachRulesAction.Data
            {
                Transactions = transactions,
                Categories   = _repository.Categories.Item
            };

            AttachRulesAction attachRulesAction = new AttachRulesAction();

            attachRulesAction.Execute(attachRulesData);

            TransactionManager       transactionManager = new TransactionManager();
            List <TransactionReport> reports            = transactionManager.GetMonthReports(transactions);

            transactionManager.RemoveInternalTransactions(reports);

            _repository.Reports.Item.Reports = reports;
            _iOutput.ShowReports(reports);
        }
Beispiel #2
0
        public static List <TransactionReport> GetMonthReports()
        {
            ImportImpl       import          = new ImportImpl();
            TestDataProvider ingDataProvider = new TestDataProvider(Resources._2018_06_All, "\n");
            FileData         ingFileData     = ingDataProvider.GetTransactionData();

            TestDataProvider mobileDataProvider = new TestDataProvider(Resources.czerwiec_2016_Maciek, "\n");
            FileData         mobileFileData     = mobileDataProvider.GetTransactionData();

            List <FileData> filedataCollection = new List <FileData>()
            {
                ingFileData, mobileFileData
            };

            GetTransactionsAction.Data getTransactionData = new GetTransactionsAction.Data()
            {
                Parsers   = import.GetParsers(),
                FileDatas = filedataCollection
            };

            GetTransactionsAction getTransaction = new GetTransactionsAction();

            GetTransactionsAction.Result getTransactionResult = getTransaction.Execute(getTransactionData);

            var allTransactions = getTransactionResult.Reports.
                                  SelectMany(r => r.Transactions).ToList();


            AttachRulesAction.Data attachRulesData = new AttachRulesAction.Data
            {
                Transactions = allTransactions
                               /*Rules = GetTestRules()*/
            };

            AttachRulesAction attachRulesAction = new AttachRulesAction();

            attachRulesAction.Execute(attachRulesData);

            TransactionManager       transactionManager = new TransactionManager();
            List <TransactionReport> reports            = transactionManager.GetMonthReports(allTransactions);

            transactionManager.RemoveInternalTransactions(reports);

            return(reports);
        }