public void ShouldManageMultipleTransactionsTransfer()
        {
            var transfert = new SepaDebitTransfer
            {
                CreationDate           = new DateTime(2013, 02, 17, 22, 38, 12),
                RequestedExecutionDate = new DateTime(2013, 02, 18),
                MessageIdentification  = "transferID",
                PaymentInfoId          = "paymentInfo",
                InitiatingParty        = new InitiatingParty()
                {
                    Name = "Me"
                },
                Creditor = Creditor
            };

            const decimal amount = 23.45m;
            var           trans  = CreateTransaction("Transaction Id 1", amount, "Transaction description");

            trans.EndToEndId = "multiple1";
            transfert.AddDebitTransfer(trans);

            const decimal amount2 = 12.56m;

            transfert.AddDebitTransfer(CreateTransaction("Transaction Id 2", amount2, "Transaction description 2"));


            const decimal amount3 = 27.35m;

            transfert.AddDebitTransfer(new SepaDebitTransferTransaction
            {
                Id     = "Transaction Id 3",
                Debtor = new SepaIbanData
                {
                    Bic  = "BANK_BIC",
                    Iban = "ACCOUNT_IBAN_SAMPLE",
                    Name = "NAME"
                },
                Amount = amount3,
                RemittanceInformation = "Transaction description 3"
            });

            const decimal total = (amount + amount2 + amount3) * 100;

            Assert.AreEqual(total, transfert.HeaderControlSumInCents);
            Assert.AreEqual(total, transfert.PaymentControlSumInCents);

            Assert.AreEqual(MULTIPLE_ROW_RESULT, transfert.AsXmlString());
        }
Esempio n. 2
0
        public void ShouldRejectTwoTransationsWithSameId()
        {
            SepaDebitTransfer transfert = GetOneTransactionDebitTransfert(100m);
            var debit = CreateTransaction("Transaction Id 1", 23.45m, "Transaction description 2");

            Assert.That(() => { transfert.AddDebitTransfer(debit); },
                        Throws.TypeOf <SepaRuleException>().With.Property("Message").Contains("must be unique in a transfer"));
        }
Esempio n. 3
0
        public void ShouldRejectNullTransactionTransfer()
        {
            var transfert = new SepaDebitTransfer();


            Assert.That(() => { transfert.AddDebitTransfer(null); },
                        Throws.TypeOf <ArgumentNullException>().With.Property("Message").Contains("transfer"));
        }
        public void ShouldValidateThePain00800103XmlSchema()
        {
            var transfert = new SepaDebitTransfer
            {
                CreationDate           = new DateTime(2013, 02, 17, 22, 38, 12),
                RequestedExecutionDate = new DateTime(2013, 02, 18),
                MessageIdentification  = "transferID",
                PaymentInfoId          = "paymentInfo",
                InitiatingParty        = new InitiatingParty()
                {
                    Name = "Me"
                },
                Creditor = Creditor,
                Schema   = SepaSchema.Pain00800103
            };

            const decimal amount = 23.45m;
            var           trans  = CreateTransaction("Transaction Id 1", amount, "Transaction description");

            trans.EndToEndId = "multiple1";
            transfert.AddDebitTransfer(trans);

            const decimal amount2 = 12.56m;

            transfert.AddDebitTransfer(CreateTransaction("Transaction Id 2", amount2, "Transaction description 2"));


            const decimal amount3 = 27.35m;

            transfert.AddDebitTransfer(new SepaDebitTransferTransaction
            {
                Id     = "Transaction Id 3",
                Debtor = new SepaIbanData
                {
                    Bic  = "BANK_BIC",
                    Iban = "ACCOUNT_IBAN_SAMPLE",
                    Name = "NAME"
                },
                Amount = amount3,
                RemittanceInformation = "Transaction description 3"
            });

            var validator = XmlValidator.GetValidator(transfert.Schema);

            validator.Validate(transfert.AsXmlString());
        }
Esempio n. 5
0
        public void ShouldKeepEndToEndIdIfSet()
        {
            const decimal amount = 23.45m;

            SepaDebitTransfer transfert = GetOneTransactionDebitTransfert(amount);

            var trans = CreateTransaction(null, amount, "Transaction description 2");

            trans.EndToEndId = "endToendId1";
            transfert.AddDebitTransfer(trans);

            trans            = CreateTransaction(null, amount, "Transaction description 3");
            trans.EndToEndId = "endToendId2";
            transfert.AddDebitTransfer(trans);

            string result = transfert.AsXmlString();

            Assert.True(result.Contains("<EndToEndId>endToendId1</EndToEndId>"));
            Assert.True(result.Contains("<EndToEndId>endToendId2</EndToEndId>"));
        }
Esempio n. 6
0
        public void ShouldRejectIfNoCreditor()
        {
            var transfert = new SepaDebitTransfer
            {
                MessageIdentification = "transferID",
                PaymentInfoId         = "paymentInfo",
                InitiatingPartyName   = "Me"
            };

            transfert.AddDebitTransfer(CreateTransaction("Transaction Id 1", 100m, "Transaction description"));
            transfert.AsXmlString();
        }
Esempio n. 7
0
        public void ShouldRejectIfNoCreditor()
        {
            var transfert = new SepaDebitTransfer
            {
                MessageIdentification = "transferID",
                PaymentInfoId         = "paymentInfo",
                InitiatingPartyName   = "Me"
            };

            transfert.AddDebitTransfer(CreateTransaction("Transaction Id 1", 100m, "Transaction description"));
            Assert.That(() => { transfert.AsXmlString(); },
                        Throws.TypeOf <SepaRuleException>().With.Property("Message").EqualTo("The creditor is mandatory."));
        }
Esempio n. 8
0
        public void ShouldAllowMultipleNullIdTransations()
        {
            const decimal amount = 23.45m;

            SepaDebitTransfer transfert = GetOneTransactionDebitTransfert(amount);

            transfert.AddDebitTransfer(new SepaDebitTransferTransaction
            {
                Id     = null,
                Debtor = new SepaIbanData
                {
                    Bic  = "AGRIFRPPXXX",
                    Iban = "FR1420041010050500013M02606",
                    Name = "THEIR_NAME"
                },
                Amount = amount,
                RemittanceInformation = "Transaction description 1",
                MandateIdentification = "mandate 1",
                DateOfSignature       = new DateTime(2010, 12, 7),
            });

            transfert.AddDebitTransfer(new SepaDebitTransferTransaction
            {
                Id     = null,
                Debtor = new SepaIbanData
                {
                    Bic  = "AGRIFRPPXXX",
                    Iban = "FR1420041010050500013M02606",
                    Name = "THEIR_NAME"
                },
                Amount = amount,
                RemittanceInformation = "Transaction description 2",
                MandateIdentification = "mandate 2",
                DateOfSignature       = new DateTime(2011, 12, 7),
            });
        }
        public void ShouldRejectNullTransactionTransfer()
        {
            var transfert = new SepaDebitTransfer();

            Assert.That(() => { transfert.AddDebitTransfer(null); },
                Throws.TypeOf<ArgumentNullException>().With.Property("Message").Contains("transfer"));
        }
Esempio n. 10
0
 public void ShouldRejectIfNoCreditor()
 {
     var transfert = new SepaDebitTransfer
         {
             MessageIdentification = "transferID",
             PaymentInfoId = "paymentInfo",
             InitiatingPartyName = "Me"
         };
     transfert.AddDebitTransfer(CreateTransaction("Transaction Id 1", 100m, "Transaction description"));
     Assert.That(() => { transfert.AsXmlString(); },
         Throws.TypeOf<SepaRuleException>().With.Property("Message").EqualTo("The creditor is mandatory."));
 }
Esempio n. 11
0
        public void ShouldManageMultipleTransactionsTransfer()
        {
            var transfert = new SepaDebitTransfer
                {
                    CreationDate = new DateTime(2013, 02, 17, 22, 38, 12),
                    RequestedExecutionDate = new DateTime(2013, 02, 18),
                    MessageIdentification = "transferID",
                    PaymentInfoId = "paymentInfo",
                    InitiatingPartyName = "Me",
                    Creditor = Creditor
                };

            const decimal amount = 23.45m;
            var trans = CreateTransaction("Transaction Id 1", amount, "Transaction description");
            trans.EndToEndId = "multiple1";
            transfert.AddDebitTransfer(trans);

            const decimal amount2 = 12.56m;
            transfert.AddDebitTransfer(CreateTransaction("Transaction Id 2", amount2, "Transaction description 2"));

            const decimal amount3 = 27.35m;
            transfert.AddDebitTransfer(new SepaDebitTransferTransaction
                {
                    Id = "Transaction Id 3",
                    Debtor = new SepaIbanData
                        {
                            Bic = "BANK_BIC",
                            Iban = "ACCOUNT_IBAN_SAMPLE",
                            Name = "NAME"
                        },
                    Amount = amount3,
                    RemittanceInformation = "Transaction description 3"
                });

            const decimal total = (amount + amount2 + amount3)*100;

            Assert.AreEqual(total, transfert.HeaderControlSumInCents);
            Assert.AreEqual(total, transfert.PaymentControlSumInCents);

            Assert.AreEqual(MULTIPLE_ROW_RESULT, transfert.AsXmlString());
        }
Esempio n. 12
0
        public void ShouldRejectTwoTransationsWithSameId()
        {
            SepaDebitTransfer transfert = GetOneTransactionDebitTransfert(100m);

            transfert.AddDebitTransfer(CreateTransaction("Transaction Id 1", 23.45m, "Transaction description 2"));
        }
Esempio n. 13
0
        public void ShouldRejectNullTransactionTransfer()
        {
            var transfert = new SepaDebitTransfer();

            transfert.AddDebitTransfer(null);
        }
        public void ShouldRejectNullTransactionTransfer()
        {
            var transfert = new SepaDebitTransfer();

            transfert.AddDebitTransfer(null);
        }
 public void ShouldRejectIfNoCreditor()
 {
     var transfert = new SepaDebitTransfer
         {
             MessageIdentification = "transferID",
             PaymentInfoId = "paymentInfo",
             InitiatingPartyName = "Me"
         };
     transfert.AddDebitTransfer(CreateTransaction("Transaction Id 1", 100m, "Transaction description"));
     transfert.AsXmlString();
 }
Esempio n. 16
0
        public void ShouldValidateThePain00800103XmlSchema()
        {
            var transfert = new SepaDebitTransfer
            {
                CreationDate = new DateTime(2013, 02, 17, 22, 38, 12),
                RequestedExecutionDate = new DateTime(2013, 02, 18),
                MessageIdentification = "transferID",
                PaymentInfoId = "paymentInfo",
                InitiatingPartyName = "Me",
                Creditor = Creditor,
                Schema = SepaSchema.Pain00800103
            };

            const decimal amount = 23.45m;
            var trans = CreateTransaction("Transaction Id 1", amount, "Transaction description");
            trans.EndToEndId = "multiple1";
            transfert.AddDebitTransfer(trans);

            const decimal amount2 = 12.56m;
            transfert.AddDebitTransfer(CreateTransaction("Transaction Id 2", amount2, "Transaction description 2"));

            const decimal amount3 = 27.35m;
            transfert.AddDebitTransfer(new SepaDebitTransferTransaction
            {
                Id = "Transaction Id 3",
                Debtor = new SepaIbanData
                {
                    Bic = "BANK_BIC",
                    Iban = "ACCOUNT_IBAN_SAMPLE",
                    Name = "NAME"
                },
                Amount = amount3,
                RemittanceInformation = "Transaction description 3"
            });

            var validator = XmlValidator.GetValidator(transfert.Schema);
            validator.Validate(transfert.AsXmlString());
        }
Esempio n. 17
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            int skipped = 0;

            pBar.MarqueeAnimationSpeed = 25;
            pBar.Visible = true;
            if (txtSource.Text.Equals("") | txtTarget.Text.Equals("") | txtCreditorBic.Text.Equals("") | txtCreditorID.Text.Equals("") | txtCreditorIBAN.Text.Equals("") | txtCreditorName.Text.Equals("") | cbDebtIBAN.SelectedIndex < 0 | cbDebtName1.SelectedIndex < 0 | (rbVariableAmount.Checked && cbAmount.SelectedIndex < 0) | txtUsage.Text.Equals(""))
            {
                pBar.MarqueeAnimationSpeed = 0;
                MessageBox.Show("Bitte überprüfen Sie ihre Eingaben!");
                return;
            }
            else if (!System.IO.File.Exists(txtSource.Text))
            {
                pBar.MarqueeAnimationSpeed = 0;
                MessageBox.Show("Auf die Quell-datei konnte nicht zugegriffen werden!");
                return;
            }
            try
            {
                SepaDebitTransfer transfer = new SepaDebitTransfer();

                SepaIbanData creditor = new SepaIbanData();
                creditor.Bic  = txtCreditorBic.Text;
                creditor.Iban = txtCreditorIBAN.Text;
                creditor.Name = NormalizeString(txtCreditorName.Text);

                transfer.Creditor = creditor;
                transfer.PersonId = txtCreditorID.Text;
                transfer.MessageIdentification  = dtDate.Value.Year.ToString() + dtDate.Value.Month.ToString() + dtDate.Value.Day.ToString() + "-" + txtCreditorName.Text;
                transfer.InitiatingPartyName    = txtCreditorName.Text;
                transfer.RequestedExecutionDate = dtDate.Value;



                StreamReader _sr  = new StreamReader(txtSource.Text);
                string       line = _sr.ReadLine();
                if (columnHeaders.Checked)
                {
                    line = _sr.ReadLine(); //Remove first line if there are headings
                }
                List <string> skippedCreditors = new List <string>();
                while (line != null)
                {
                    line = line.Replace("\"", "");
                    string[] debitorData = line.Split(';');
                    string   name        = "";
                    if (!debitorData[((Column)cbDebtIBAN.SelectedItem).Index].Equals("") && !debitorData[((Column)cbDebtName1.SelectedItem).Index].Equals("") && !debitorData[((Column)cbDebtIBAN.SelectedItem).Index].Equals(""))
                    {
                        SepaDebitTransferTransaction transaction = new SepaDebitTransferTransaction();
                        SepaIbanData debtor = new SepaIbanData();
                        debtor.Bic  = debitorData[((Column)cbDebtBIC.SelectedItem).Index];
                        debtor.Iban = debitorData[((Column)cbDebtIBAN.SelectedItem).Index];
                        if (cbDebtName2.SelectedIndex < 0)
                        {
                            name = debitorData[((Column)cbDebtName1.SelectedItem).Index];
                        }
                        else
                        {
                            name = debitorData[((Column)cbDebtName1.SelectedItem).Index] + " " + debitorData[((Column)cbDebtName2.SelectedItem).Index];
                        }
                        debtor.Name = Regex.Replace(NormalizeString(name), REGEX_PATTERN, String.Empty);
                        if (!debtor.IsValid)
                        {
                            skippedCreditors.Add(debtor.Name);
                        }
                        else
                        {
                            transaction.Debtor = debtor;
                            transaction.MandateIdentification = Regex.Replace(NormalizeString(ReplaceWithColumnValues(txtReference.Text, debitorData)).Replace(" ", ""), REGEX_PATTERN, String.Empty);
                            transaction.RemittanceInformation = Regex.Replace(NormalizeString(ReplaceWithColumnValues(txtUsage.Text, debitorData)), REGEX_PATTERN, String.Empty);
                            if (cbDtOfSgntr.SelectedIndex >= 0)
                            {
                                transaction.DateOfSignature = DateTime.Parse(debitorData[((Column)cbDtOfSgntr.SelectedItem).Index]);
                            }
                            if (rbFixedAmount.Checked)
                            {
                                transaction.Amount = numAmount.Value;
                            }
                            else if (rbVariableAmount.Checked)
                            {
                                transaction.Amount = (Decimal)ToDouble(debitorData[((Column)cbAmount.SelectedItem).Index]);
                            }
                            transfer.AddDebitTransfer(transaction);
                        }
                    }
                    else
                    {
                        skippedCreditors.Add(name);
                        skipped++;
                    }
                    line = _sr.ReadLine();
                }
                using (StreamWriter sw = new StreamWriter(new FileStream(txtTarget.Text, FileMode.Create), new System.Text.UTF8Encoding(false)))
                {
                    sw.Write(transfer.AsXmlString());
                }
                if (skippedCreditors.Count > 0)
                {
                    CreateErrorReport(skippedCreditors, txtTarget.Text + ".ErrorReport.txt");
                    MessageBox.Show("Es wurde erfolgreich eine SEPA-Datei erstellt! Dabei wurden jedoch " + skippedCreditors.Count.ToString() + " Datensätze übersprungen!\r\nEine Reportdatei wurde unter folgenden Pfad erstellt:\r\n" + txtTarget.Text + ".ErrorReport.txt", "Erfolgreich mit Warnungen!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("Es wurde erfolgreich eine SEPA-Datei erstellt!", "Erfolgreich!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception exc)
            {
                if (File.Exists(txtTarget.Text))
                {
                    System.IO.File.Delete(txtTarget.Text);
                }
                MessageBox.Show("Fehler: \r\n" + exc.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pBar.MarqueeAnimationSpeed = 0;
                pBar.Visible = false;
                MessageBox.Show("Fertig!\r\n Es wurden " + skipped.ToString() + " Datensätz übersprungen!");
            }
        }
Esempio n. 18
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            frmLogin            login          = new frmLogin();
            int                 GruppierungsID = 0; //<-------------------------------------WICHTIG!!
            List <NaMiMitglied> skipped        = new List <NaMiMitglied>();
            Connector           con            = new Connector();
            SaveFileDialog      sfd            = new SaveFileDialog();

            try
            {
                if (!isVaildInput())
                {
                    MessageBox.Show("Die angegebenen Daten sind unvollständig oder Falsch!", "Unvollständige oder Falsche Daten!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                sfd.Filter = "XML-Dateien|*.xml";
                if (sfd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                login.ShowDialog();
                if (login.Password.Equals("") || login.Mitgliedsnummer.Equals(""))
                {
                    MessageBox.Show("Es wurde keine Datei erstellt!", "Keine Eingaben ermittelt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (!con.Login(login.Mitgliedsnummer, login.Password))
                {
                    MessageBox.Show("Falscher Benutzername oder Falsches Kennwort!", "Fehler bei der Anmeldung", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                pbFortschritt.Visible = true;
                pbFortschritt.MarqueeAnimationSpeed = 25;

                GruppierungsID = con.GetRootGruppierung().id;

                Task <List <NaMiMitglied> > task = Task <List <NaMiMitglied> > .Factory.StartNew(() => GetAktiveMitglieder(con, GruppierungsID));

                while (task.Status != TaskStatus.RanToCompletion)
                {
                    Application.DoEvents();
                }

                Dictionary <string, int> mPIban = GetMitgliederPerIBAN(task.Result);

                SepaDebitTransfer transfer = new SepaDebitTransfer();

                SepaIbanData creditor = new SepaIbanData();
                creditor.Bic  = txtBIC.Text;
                creditor.Iban = txtIBAN.Text;
                creditor.Name = NormalizeString(txtName.Text);

                transfer.Creditor = creditor;
                transfer.RequestedExecutionDate = dTExecutionDate.Value;
                transfer.PersonId = txtGlaeubigerID.Text;
                transfer.MessageIdentification = creditor.Bic + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
                transfer.InitiatingPartyName   = creditor.Name;
                if (!creditor.IsValid)
                {
                    MessageBox.Show("Fehler ihre Bankdaten scheinen Ungültig zu sein!", "Fehler in den Bankdaten!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                List <string> transactions = new List <string>();
                transactions.Add("Debtor;IBAN;Mandatsreferenz;Verwendungszweck;Betrag");
                foreach (NaMiMitglied m in task.Result)
                {
                    if (!(m.kontoverbindung.iban == null || m.kontoverbindung.bic == null || m.kontoverbindung.kontoinhaber == null))
                    {
                        if (!(m.kontoverbindung.iban.Equals("") || m.kontoverbindung.bic.Equals("") || m.kontoverbindung.kontoinhaber.Equals("")))
                        {
                            SepaDebitTransferTransaction transaction = new SepaDebitTransferTransaction();
                            SepaIbanData debtor = new SepaIbanData();
                            debtor.Name = m.kontoverbindung.kontoinhaber.ToString();
                            debtor.Iban = m.kontoverbindung.iban.ToString();
                            debtor.Bic  = m.kontoverbindung.bic.ToString();
                            if (!debtor.IsValid)
                            {
                                skipped.Add(m);
                            }
                            else
                            {
                                transaction.Debtor = debtor;
                                transaction.MandateIdentification = NormalizeString(m.kontoverbindung.mitgliedsNummer.ToString() + m.vorname + m.nachname).Replace(" ", "");
                                transaction.RemittanceInformation = "DPSG Beitrag fuer " + NormalizeString(m.vorname) + " " + NormalizeString(m.nachname);
                                transaction.Amount = GetAmount(mPIban[transaction.Debtor.Iban], m);
                                transfer.AddDebitTransfer(transaction);
                                transactions.Add(String.Format("{0};{1};{2};{3};{4}", transaction.Debtor.Name, transaction.Debtor.Iban, transaction.MandateIdentification, transaction.RemittanceInformation, transaction.Amount.ToString()));
                            }
                        }
                        else
                        {
                            skipped.Add(m);
                        }
                    }
                }
                using (StreamWriter sw = new StreamWriter(new FileStream(sfd.FileName, FileMode.Create), new System.Text.UTF8Encoding(false)))
                {
                    sw.Write(transfer.AsXmlString());
                }
                using (StreamWriter sw = new StreamWriter(new FileStream(sfd.FileName + ".Transactions.csv", FileMode.Create), new System.Text.UTF8Encoding(false)))
                {
                    foreach (string line in transactions)
                    {
                        sw.WriteLine(line);
                    }
                }
                if (skipped.Count > 0)
                {
                    CreateErrorReport(skipped, sfd.FileName + ".ErrorReport.txt");
                    MessageBox.Show("Es wurde erfolgreich eine SEPA-Datei erstellt! Dabei wurden jedoch " + skipped.Count.ToString() + " Datensätze übersprungen!\r\nEine Reportdatei wurde unter folgenden Pfad erstellt:\r\n" + sfd.FileName + ".ErrorReport.txt", "Erfolgreich mit Warnungen!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("Es wurde erfolgreich eine SEPA-Datei erstellt!", "Erfolgreich!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (NaMiNotLoggedInException ex)
            {
                MessageBox.Show("Fehler:\r\n" + ex.Message, "Fehler: Nicht Eingeloggt!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (NaMiException <List <NaMiObjekt> > ex)
            {
                MessageBox.Show("Fehler:\r\n" + ex.Message, "Fehler im NaMiRequest!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (NaMiException <NaMiMitglied> ex)
            {
                MessageBox.Show("Fehler:\r\n" + ex.Message, "Fehler im NaMiRequest!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Fehler:\r\n" + ex.Message, "Unbekannter Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                con.Logout();
                pbFortschritt.Visible = false;
                pbFortschritt.MarqueeAnimationSpeed = 0;
            }
        }