Beispiel #1
0
        public void ReconcileAndAddTransactions_Should_ReconcileAndAddTransactions()
        {
            //Given
            IEnumerable <OfxDocument> ofxDocuments = new List <OfxDocument>()
            {
                new OfxDocument()
                {
                    BankID       = "0341",
                    AccountID    = "7037300576",
                    AccountType  = "CHECKING",
                    Transactions = new List <OfxTransaction>()
                    {
                        new OfxTransaction()
                        {
                            TransType   = TransType.Debit,
                            DatePosted  = new DateTime(2021, 01, 02),
                            TransAmount = -102.19m,
                            Memo        = "RSHOP-SUPERMERCAD-03/02"
                        },
                        new OfxTransaction()
                        {
                            TransType   = TransType.Credit,
                            DatePosted  = new DateTime(2021, 01, 02),
                            TransAmount = 16766.28m,
                            Memo        = "TED 399.1934NIBO SOF CUR"
                        }
                    }
                },
                new OfxDocument()
                {
                    BankID       = "0341",
                    AccountID    = "7037300576",
                    AccountType  = "CHECKING",
                    Transactions = new List <OfxTransaction>()
                    {
                        new OfxTransaction()
                        {
                            TransType   = TransType.Credit,
                            DatePosted  = new DateTime(2021, 01, 02),
                            TransAmount = 16766.28m,
                            Memo        = "TED 399.1934NIBO SOF CUR"
                        }
                    }
                }
            };

            //When
            var bankAccount = _bankReconciliationService.ReconcileAndAddTransactions(ofxDocuments);

            //Then
            var expectedTransactionsCount = 2;

            Assert.Equal(expectedTransactionsCount, bankAccount.Transactions.Count);
        }
Beispiel #2
0
        public ActionResult Reconcile(IFormCollection formCollection)
        {
            try
            {
                //Should be tested. IFormFileCollection should be in Core Framework?
                var ofxDocuments = new List <OfxDocument>();
                foreach (var file in formCollection.Files)
                {
                    var stream      = file.OpenReadStream();
                    var ofxDocument = OfxDocumentParser.Parse(stream);
                    ofxDocuments.Add(ofxDocument);
                }
                var bankAccount = _bankReconciliationService.ReconcileAndAddTransactions(ofxDocuments);

                return(View(nameof(Reconcile), bankAccount));
            }
            catch
            {
                return(View());
            }
        }