private void _AppendBalance(FinAcctBalResp aBal, StringBuilder sb) { FinAcct aAcct = aBal.Account; SwiftBalance aCurrentBal = aBal.CurrentBal; SwiftBalance aPendingBal = aBal.IncludingPendingTransBal; if (aCurrentBal != null) { sb.AppendFormat("BOOKED;{0};{1};{2};{3};{4}", aAcct.BankCode, aAcct.AcctNo, aCurrentBal.Date.ToString(SwiftDateFormat.StandardDate), aCurrentBal.Currency, SwiftAmt.Format(aCurrentBal.DecValue, ',', 2)); sb.Append(Environment.NewLine); } if (aPendingBal != null) { sb.AppendFormat("FORWARD;{0};{1};{2};{3};{4}", aAcct.BankCode, aAcct.AcctNo, aPendingBal.Date.ToString(SwiftDateFormat.StandardDate), aPendingBal.Currency, SwiftAmt.Format(aPendingBal.DecValue, ',', 2)); sb.Append(Environment.NewLine); } }
IList <Statement> DownloadStatement() { log.DebugFormat("Download {0}", AccountId); FinContact contact = FinContactFolder.Default.FindContact(AccountId); List <Statement> s = new List <Statement>(); foreach (FinAcctInfo aAcctInfo in contact.UPD) { try { FinAcct acct = aAcctInfo.Acct; log.DebugFormat("Downloading account {0}/{1}", acct.BankCode, acct.AcctNo); FinService service = new FinService(contact, acct.BankCode, acct.AcctNo, acct.Currency); service.LogOn(Password); FinAcctMvmtsSpecifiedPeriod aAcctMvmts = service.DownloadStatement(SwiftDate.NullDate); service.LogOff(); if (aAcctMvmts != null) { s.Add(ToStatement(acct, aAcctMvmts.BookedTrans)); } } catch (Exception e) { log.Error("Error while downloading " + AccountId, e); } } return(s); }
Statement ToStatement(FinAcct acct, SwiftStatementReader aStmtReader) { Statement s = new Statement(); s.Payments = new List <Payment>(); SwiftStatement aMT940 = SwiftStatement.ReadMT940(aStmtReader, true); s.ClosingBalance = aMT940.ClosingBalance.DecValue; s.AccountIdentification = aMT940.AccountIdentification; foreach (SwiftStatementLine sl in aMT940.StatementLines) { s.Payments.Add(ToPayment(acct, sl)); } return(s); }
protected override FinOrder OnCreateOrder(FinService aService) { // Egal was der Aufrufer eingestellt hat. Als Auftragskonto stellen wir das Konto // der Bankverbindung ein. Debug.Assert(m_aXmlDocument.DocumentElement != null, "m_aXmlDocument.DocumentElement != null"); XmlElement xmlOrderingCustAcct = m_aXmlDocument.DocumentElement["OrderingCustAcct"]; if (xmlOrderingCustAcct == null) { xmlOrderingCustAcct = m_aXmlDocument.CreateElement("OrderingCustAcct"); Debug.Assert(m_aXmlDocument.DocumentElement != null, "m_aXmlDocument.DocumentElement != null"); m_aXmlDocument.DocumentElement.PrependChild(xmlOrderingCustAcct); } FinAcct aAcct = aService.GetAcct(); XmlElement xml = m_aXmlDocument.CreateElement("AcctNo"); xml.InnerText = aAcct.AcctNo; xmlOrderingCustAcct.AppendChild(xml); if (aAcct.SubAcctCharacteristic != null) { xml = m_aXmlDocument.CreateElement("SubAcctCharacteristic"); xml.InnerText = aAcct.SubAcctCharacteristic; xmlOrderingCustAcct.AppendChild(xml); } XmlElement xmlBankID = m_aXmlDocument.CreateElement("BankID"); xmlOrderingCustAcct.AppendChild(xmlBankID); xml = m_aXmlDocument.CreateElement("CountryCode"); xml.InnerText = aAcct.CountryCode; xmlBankID.AppendChild(xml); xml = m_aXmlDocument.CreateElement("BankCode"); xml.InnerText = aAcct.BankCode; xmlBankID.AppendChild(xml); FinXmlOrderBuilder aXmlOrderBuilder = new FinXmlOrderBuilder(aService.Contact, m_aSyntax); return(aXmlOrderBuilder.Build(m_aXmlDocument.DocumentElement)); }
Payment ToPayment(FinAcct account, SwiftStatementLine s) { Payment p = new Payment(); p.Currency = s.Currency; p.Value = (double)s.DecValue; p.EntryDate = s.EntryDate.ToDateTime(); p.ValueDate = s.ValueDate.ToDateTime(); p.EntryText = s.EntryText; p.Name = new string[] { s.PayeePayerName1, s.PayeePayerName2 }.JoinLines(); p.AcctNo = s.PayeePayerAcctNo; p.BankCode = s.PayeePayerBankCode; p.Purpose = s.PaymtPurpose.JoinLines(); p.OwnAcctNo = account.AcctNo; p.OwnBankCode = account.BankCode; return(p); }
Statement ToStatement(FinAcct acct, SwiftStatementReader aStmtReader) { Statement s = new Statement(); s.Payments = new List<Payment>(); SwiftStatement aMT940 = SwiftStatement.ReadMT940(aStmtReader, true); s.ClosingBalance = aMT940.ClosingBalance.DecValue; s.AccountIdentification = aMT940.AccountIdentification; foreach (SwiftStatementLine sl in aMT940.StatementLines) { s.Payments.Add(ToPayment(acct, sl)); } return s; }
Payment ToPayment(FinAcct account, SwiftStatementLine s) { Payment p = new Payment(); p.Currency = s.Currency; p.Value = (double) s.DecValue; p.EntryDate = s.EntryDate.ToDateTime(); p.ValueDate = s.ValueDate.ToDateTime(); p.EntryText = s.EntryText; p.Name = new string[] { s.PayeePayerName1, s.PayeePayerName2 }.JoinLines(); p.AcctNo = s.PayeePayerAcctNo; p.BankCode = s.PayeePayerBankCode; p.Purpose = s.PaymtPurpose.JoinLines(); p.OwnAcctNo = account.AcctNo; p.OwnBankCode = account.BankCode; return p; }
protected override FinOrder OnCreateOrder(FinService aService) { FinAcct aAcct = aService.GetAcct(); // Depending on the type of the SEPA document a suitable HBCI segment type is // determined. This is done with the help of a very convenient property of the // SepaDocument class. FinSepaOrderBuilder aSepaOrderBuilder = null; switch (m_aSepaDoc.HbciSegmentType) { case "HKCCS": aSepaOrderBuilder = new FinSepaSingRemittBuilder(aService.Contact); break; case "HKCSE": aSepaOrderBuilder = new FinSepaSubmitPostdatedSingRemittBuilder(aService.Contact); break; case "HKCCM": aSepaOrderBuilder = new FinSepaMultRemittBuilder(aService.Contact); break; case "HKCME": aSepaOrderBuilder = new FinSepaSubmitPostdatedMultRemittBuilder(aService.Contact); break; case "HKDSE": aSepaOrderBuilder = new FinSepaSubmitPostdatedSingDirDebBuilder(aService.Contact); break; case "HKDSC": aSepaOrderBuilder = new FinSepaSubmitPostdatedCor1SingDirDebBuilder(aService.Contact); break; case "HKBSE": aSepaOrderBuilder = new FinSepaSubmitPostdatedBusinessSingDirDebBuilder(aService.Contact); break; case "HKDME": aSepaOrderBuilder = new FinSepaSubmitPostdatedMultDirDebBuilder(aService.Contact); break; case "HKDMC": aSepaOrderBuilder = new FinSepaSubmitPostdatedCor1MultDirDebBuilder(aService.Contact); break; case "HKBME": aSepaOrderBuilder = new FinSepaSubmitPostdatedBusinessMultDirDebBuilder(aService.Contact); break; } // If no suitable segment type could be determined, or the required segment type is // not supported by the bank, then bail out. if (aSepaOrderBuilder == null) { Io.Error.Write("Keine HBCI-Auftragsart für SEPA-Dokument bekannt!"); return(null); } if (!aSepaOrderBuilder.IsSupported) { Io.Error.Write("HBCI-Auftragsart " + m_aSepaDoc.HbciSegmentType + " von Bank nicht unterstützt!"); return(null); } if (aSepaOrderBuilder.FindSepaFormat(m_aSepaDoc.MessageInfo.PainIdentifier) == null) { Io.Error.Write("SEPA-Format " + m_aSepaDoc.MessageInfo.PainIdentifier + " von Bank nicht unterstützt!"); return(null); } return(aSepaOrderBuilder.Build(aAcct, m_aSepaDoc)); }