コード例 #1
0
        public void ShouldKeepProvidedData()
        {
            const decimal amount = 100m;
            const string currency = "USD";
            const string id = "Batch1";
            const string endToEndId = "Batch1/Row2";
            const string remittanceInformation = "Sample";
            const string mandateId = "MyMandate";
            var signatureDate = new DateTime(2012, 12, 2);
            var seqType = SepaSequenceType.FIRST;

            var data = new SepaDebitTransferTransaction
                {
                    Debtor = iBanData,
                    Amount = amount,
                    Currency = currency,
                    Id = id,
                    EndToEndId = endToEndId,
                    RemittanceInformation = remittanceInformation,
                    DateOfSignature = signatureDate,
                    MandateIdentification = mandateId,
                    SequenceType = SepaSequenceType.FIRST
                };

            Assert.AreEqual(currency, data.Currency);
            Assert.AreEqual(amount, data.Amount);
            Assert.AreEqual(id, data.Id);
            Assert.AreEqual(endToEndId, data.EndToEndId);
            Assert.AreEqual(remittanceInformation, data.RemittanceInformation);
            Assert.AreEqual(Bic, data.Debtor.Bic);
            Assert.AreEqual(Iban, data.Debtor.Iban);
            Assert.AreEqual(Iban, data.Debtor.Iban);
            Assert.AreEqual(mandateId, data.MandateIdentification);
            Assert.AreEqual(signatureDate, data.DateOfSignature);
            Assert.AreEqual(seqType, data.SequenceType);

            var data2 = data.Clone() as SepaDebitTransferTransaction;

            Assert.NotNull(data2);
            Assert.AreEqual(currency, data2.Currency);
            Assert.AreEqual(amount, data2.Amount);
            Assert.AreEqual(id, data2.Id);
            Assert.AreEqual(endToEndId, data2.EndToEndId);
            Assert.AreEqual(remittanceInformation, data2.RemittanceInformation);
            Assert.AreEqual(Bic, data2.Debtor.Bic);
            Assert.AreEqual(Iban, data2.Debtor.Iban);
            Assert.AreEqual(mandateId, data2.MandateIdentification);
            Assert.AreEqual(signatureDate, data2.DateOfSignature);
            Assert.AreEqual(seqType, data2.SequenceType);
        }
コード例 #2
0
        public void ShouldKeepProvidedData()
        {
            const decimal amount                = 100m;
            const string  currency              = "USD";
            const string  id                    = "Batch1";
            const string  endToEndId            = "Batch1/Row2";
            const string  remittanceInformation = "Sample";
            const string  mandateId             = "MyMandate";
            var           signatureDate         = new DateTime(2012, 12, 2);
            var           seqType               = SepaSequenceType.FIRST;

            var data = new SepaDebitTransferTransaction
            {
                Debtor                = iBanData,
                Amount                = amount,
                Currency              = currency,
                Id                    = id,
                EndToEndId            = endToEndId,
                RemittanceInformation = remittanceInformation,
                DateOfSignature       = signatureDate,
                MandateIdentification = mandateId,
                SequenceType          = SepaSequenceType.FIRST
            };

            Assert.AreEqual(currency, data.Currency);
            Assert.AreEqual(amount, data.Amount);
            Assert.AreEqual(id, data.Id);
            Assert.AreEqual(endToEndId, data.EndToEndId);
            Assert.AreEqual(remittanceInformation, data.RemittanceInformation);
            Assert.AreEqual(Bic, data.Debtor.Bic);
            Assert.AreEqual(Iban, data.Debtor.Iban);
            Assert.AreEqual(Iban, data.Debtor.Iban);
            Assert.AreEqual(mandateId, data.MandateIdentification);
            Assert.AreEqual(signatureDate, data.DateOfSignature);
            Assert.AreEqual(seqType, data.SequenceType);

            var data2 = data.Clone() as SepaDebitTransferTransaction;

            Assert.NotNull(data2);
            Assert.AreEqual(currency, data2.Currency);
            Assert.AreEqual(amount, data2.Amount);
            Assert.AreEqual(id, data2.Id);
            Assert.AreEqual(endToEndId, data2.EndToEndId);
            Assert.AreEqual(remittanceInformation, data2.RemittanceInformation);
            Assert.AreEqual(Bic, data2.Debtor.Bic);
            Assert.AreEqual(Iban, data2.Debtor.Iban);
            Assert.AreEqual(mandateId, data2.MandateIdentification);
            Assert.AreEqual(signatureDate, data2.DateOfSignature);
            Assert.AreEqual(seqType, data2.SequenceType);
        }
コード例 #3
0
        public void ShouldUseADefaultSequenceType()
        {
            var transfert = new SepaDebitTransferTransaction();

            Assert.AreEqual(SepaSequenceType.OOFF, transfert.SequenceType);
        }
コード例 #4
0
        public void ShouldHaveADefaultCurrency()
        {
            var data = new SepaDebitTransferTransaction();

            Assert.AreEqual("EUR", data.Currency);
        }
コード例 #5
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!");
            }
        }
コード例 #6
0
 public void ShouldUseADefaultSequenceType()
 {
     var transfert = new SepaDebitTransferTransaction();
     Assert.AreEqual(SepaSequenceType.OOFF, transfert.SequenceType);
 }
コード例 #7
0
        public void ShouldHaveADefaultCurrency()
        {
            var data = new SepaDebitTransferTransaction();

            Assert.AreEqual("EUR", data.Currency);
        }
コード例 #8
0
ファイル: frmMain.cs プロジェクト: chschenk/NaMiSEPAGenerator
        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;
            }
        }