📄 lxaccount.cc
字号:
// ****************************************************************************// // LxBank - home-banking for Linux using the HBCI standard// // Author: Franz Zimmermann 83043 Bad Aibling// // Copyright (C) 2002-2003 Franz Zimmermann - arafang@users.sourceforge.net// // This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.// // This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.// // You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.// // ***************************************************************************//// $Name: $//// $State: Exp $//// $Log: LxAccount.cc,v $// Revision 1.22 2003/05/08 02:39:53 arafang// Error checking of money transfer improved. Use library ktoblzcheck to validate account id's.//// Revision 1.21 2003/04/12 00:38:56 arafang// Fix problems with assignment QString to string//// Revision 1.20 2003/04/07 22:44:38 arafang// Put all calls of executeQueue into try/catch clause. Check status of jobs in get accounts.//// Revision 1.19 2003/04/04 23:40:37 arafang// Strip whitespace from recipient's account id and BLZ. Validater added to date// field of money transfer form.//// Revision 1.18 2003/03/26 22:24:35 arafang// Add method to check outgoing money transfers syntactically.//// Revision 1.17 2003/03/18 01:52:24 arafang// Fix handling of account balance if it is debit.//// Revision 1.16 2003/02/08 15:25:20 franz// Mail address changed.//// Revision 1.15 2003/02/08 11:45:19 franz// Money transfer (single mode) works.//// Revision 1.14 2003/02/04 00:42:27 franz// Account config split into three parts:// o account_config// o account_current_remittances_config// o account_processed_remittances_config//// Revision 1.13 2003/02/03 23:06:10 franz// Class LxRemittance adapted to needs of HBCI. Remittances saved on Account// config. LxRemittanceWorkDialog and constructor of class LxRemittance improved// to avoid possible core dumps with QString method latin1 and class QStringList.// Make checks in LxAccount::updateBalanceAndAccStmt weather a job has been// performed successfully or not.//// Revision 1.12 2003/01/29 22:41:30 franz// Account config file introduced. Saving starting balance and last account// statement date.// Started to adapt class LxRemittance to needs of HBCI.//// Revision 1.11 2003/01/26 23:09:41 franz// LxAccountSelectDialog: New method to delete accounts (remove).// Class LxAccountStmtPrint adapted to new account statement view layout.// Account update implemented.//// Revision 1.10 2003/01/18 15:36:09 franz// New class LxAccountStmtView implemented.//// Revision 1.9 2003/01/17 00:56:42 franz// Getting account statements work.//// Revision 1.8 2003/01/03 17:15:32 franz// LxUserAddWizard able to create a DDV-Card user.//// Revision 1.7 2003/01/02 15:04:45 franz// Started to use the openHBCI lib.//// Revision 1.6 2002/09/20 20:44:32 franz// Worked on LxTextEdit.// Two digit year numbers are now considered by class LxRemittance as:// o year 20xx if it is <= 80// o year 19xx if it is > 80//// Revision 1.5 2002/07/04 23:18:31 franz// Optimize performance of class LxAccount.// Add account close function.//// Revision 1.4 2002/07/02 23:09:45 franz// Now the accounts from the global accounts list are used within the program//// Revision 1.3 2002/06/02 22:03:19 franz// Remittance view lists improved.// Remittance work dialogs implemented.//// Revision 1.2 2002/05/05 18:31:35 franz// Started with the implementatation of remittance views.//// Revision 1.1 2002/04/23 22:13:15 franz// File LxAccountStmtList.h renamed to LxAccount.h// File LxAccountStmtList.cc renamed to LxAccount.cc//// Revision 1.2 2002/04/22 23:53:16 franz// Account open dialog implemented. This dialog presents a list of all// existing accounts. The information where the account data files are// located is stored in the LxBank resource directory '~/.LxBank' in the// file 'accounts.dat'.//// Revision 1.1 2002/04/07 23:20:47 franz// Worked on account view window.//////#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <math.h>#include <stream.h>#include <strstream.h>#include <sstream>#include "LxAccount.h"// #include <qfile.h> // #include <qfileinfo.h> // #include <qtextstream.h> #include <qptrlist.h>#include <qstring.h> #include <qstringlist.h> #include <qdatetime.h> #include <qregexp.h>#define LXBANK_CONFIG_MODE (\ PARSER_FLAGS_SKIP_BLANKS | \ PARSER_FLAGS_CUT_BLANKS | \ PARSER_FLAGS_REMOVE_QUOTATION_MARKS | \ CONFIG_MODE_QUOTED_VALUES | \ CONFIG_MODE_UNIQUE_VARS | \ CONFIG_MODE_RETURN_ON_ERROR | \ CONFIG_MODE_WRITE_GROUP_NAME | \ CONFIG_MODE_IGNORE_GROUP_CASE | \ CONFIG_MODE_IGNORE_VAR_CASE | \ CONFIG_MODE_ALLOW_EMPTY_VALUES | \ CONFIG_MODE_ONE_VALUE_PER_LINE | \ CONFIG_MODE_BACKSLASH_CONTINUATION )LxAccountStmt::LxAccountStmt (int num, QString srtKey, double previousSaldo, const HBCI::Transaction &tr) : number(num){ // sort key: 000000001234 datumSortKey = srtKey; // Transaction booking date HBCI::Date bookingDate = tr.date(); int year = bookingDate.year(); int month = bookingDate.month(); int day = bookingDate.day(); if (year > 0 && month >= 1 && month <= 12 && day >= 1 && day <= 31){ datum.setYMD ( year, month, day ); }else{ datum.setYMD ( 0, 1, 1 ); } // Transaction valuta date HBCI::Date valutaDate = tr.valutaDate(); year = valutaDate.year(); month = valutaDate.month(); day = valutaDate.day(); if (year > 0 && month >= 1 && month <= 12 && day >= 1 && day <= 31){ valuta.setYMD ( year, month, day ); }else{ valuta.setYMD ( 0, 1, 1 ); } valutaSortKey = valutaDate.toString().c_str(); // BLZ of other institut otherBank = tr.otherBankCode().c_str(); otherBankSortKey = otherBank; // Account-Id of other institut otherAccountId = tr.otherAccountId().c_str(); otherAccountIdSortKey.sprintf("%012d", otherAccountId.toInt() ); // Transaction code code = tr.primanota().c_str(); codeSortKey.sprintf("%05d", codeSortKey.toInt() ); // Transaction value const HBCI::Value &value = tr.value(); umsatz = value.getValue(); // remaining fields are text list<string> txt; list<string>::iterator iter; const list<string> &desc = tr.description(); const list<string> &oNam = tr.otherName(); list<string>::const_iterator citer; txt.push_back(tr.transactionText()); for( citer = oNam.begin(); citer != oNam.end(); ++citer ){ txt.push_back( *citer ); } for( citer = desc.begin(); citer != desc.end(); ++citer ){ txt.push_back( *citer ); } for( iter = txt.begin(); iter != txt.end(); ++iter ){ BuchungsText.append( iter->c_str() ); } saldo = previousSaldo + umsatz;}void LxAccountStmt::setUmsatzSortKey (int base, int digits, double mf){ umsatzSortKey.sprintf("%0*d", digits, base + (int)ceil(umsatz*mf) );}void LxAccountStmt::setSaldoSortKey (int base, int digits, double mf){ saldoSortKey.sprintf("%0*d", digits, base + (int)ceil(saldo*mf) );}LxRemittance::LxRemittance (LxAccount *acc, const HBCI::Transaction &tr, RemittanceStatus sta ) : number(0), status(sta), account(acc), hbciTransaction(tr), tan("00000"), amount(0.0), amountStr(""), currency(""), receiver(""), receiverAccountNo(""), receiverBLZ(""), numberSortKey(""), dateSortKey(""), amountSortKey(""), recAccNoSortKey(""){ setupFromTransaction ();}LxRemittance::LxRemittance (LxAccount *acc, const QString& dat, const QString& ta, const QString& am, const QString& cur, const QString& rec, const QString& recaccno, const QString& recblz, const QString& txt1, const QString& txt2) : number(0), status(current), account(acc), tan("00000"), amount(0.0), amountStr("\0"), currency("\0"), receiver("\0"), receiverAccountNo("\0"), receiverBLZ("\0"), numberSortKey("\0"), dateSortKey("\0"), amountSortKey("\0"), recAccNoSortKey("\0"){ setupDataMembers (dat, am, cur, rec, recaccno, recblz, txt1, txt2); setupTransaction ();}LxRemittance::LxRemittance (LxAccount *acc, const QString& exdat, const QString& dat, const QString& ta, const QString& am, const QString& cur, const QString& rec, const QString& recaccno, const QString& recblz, const QString& txt1, const QString& txt2) : number(0), status(processed), account(acc), tan("00000"), amount(0.0), amountStr("\0"), currency("\0"), receiver("\0"), receiverAccountNo("\0"), receiverBLZ("\0"), numberSortKey("\0"), dateSortKey("\0"), amountSortKey("\0"), recAccNoSortKey("\0"){ setupDataMembers (dat, am, cur, rec, recaccno, recblz, txt1, txt2, exdat); setupTransaction ();}void LxRemittance::setupDataMembers (const QString& dat, const QString& am, const QString& cur, const QString& rec, const QString& recaccno, const QString& recblz, const QString& txt1, const QString& txt2, const QString& exdat){ int year, month, day; QStringList dateFields; if ( status == processed ){ // execution date should come in format dd.mm.yyyy dateFields = QStringList::split('.', dat); year = dateFields[2].toInt(); month = dateFields[1].toInt(); day = dateFields[0].toInt(); year = checkYear(year); dateOfExecution.setYMD ( year, month, day ); } // date should come in format dd.mm.yyyy dateFields = QStringList::split('.', dat); year = dateFields[2].toInt(); month = dateFields[1].toInt(); day = dateFields[0].toInt(); year = checkYear(year); if ( QDate::isValid ( year, month, day ) ){ date.setYMD ( year, month, day ); }else{ date = QDate::currentDate (); } // currency if ( cur.isNull()){ currency = account->getCurrency(); }else{ currency = cur; } string ams; if ( am.isEmpty()){ // amount value // Fix me // amount string amountStr = "\0"; // amount sort key amountSortKey = " "; }else{ // amount value ams = am.latin1(); // string need to be checked; Fix me ams += ":"; ams += currency.latin1(); HBCI::Value val ( ams ); amount = val.getValue(); // amount string amountStr.sprintf( "%.2f", amount ); amountStr.replace ( QRegExp("\\."), "," ); // replace decimal point by decimal comma // amount sort key amountSortKey.sprintf("%012d", (int)(amount * 100.0) ); } // receiver if ( !rec.isNull()){ receiver = rec; } // receiver account no if ( !recaccno.isNull()){ receiverAccountNo = recaccno.stripWhiteSpace (); } // receiver account number sort key recAccNoSortKey.sprintf("%010d", receiverAccountNo.toInt() ); // receiver bank code if ( !recblz.isNull()){ receiverBLZ = recblz.stripWhiteSpace (); } // text lines, should not longer than 27?? char, Fix me if ( !(txt1.isNull()) ){ text.append( txt1.left(27) ); }else if ( !(txt2.isNull()) ){ QString tmp("\0"); text.append( tmp ); } if ( !(txt2.isNull()) ){ text.append( txt2.left(27) ); }}int LxRemittance::checkYear(int y){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -