📄 lxaccount.cc
字号:
LxRemittance *remittance; LxRemittance::RemittanceStatus rmType = rm->getStatus (); switch ( rmType ){ case LxRemittance::current: // update remittance from list index = currentRemittanceList.findRef ( rm ); remittance = currentRemittanceList.at ( index ); digits = (int)(log10((double)currentRemittanceList.count()) + 2.0); count = remittance->getNumber (); rmm->setNumberAndSortKey (count, digits); *remittance = *rmm; // save remittances to file err = saveCurrentRemittances (); // update the user interface emit updateCurrentRemittanceView( currentRemittanceList ); break; case LxRemittance::processed: // update remittance from list index = processedRemittanceList.findRef ( rm ); remittance = processedRemittanceList.at ( index ); digits = (int)(log10((double)processedRemittanceList.count()) + 2.0); count = remittance->getNumber (); rmm->setNumberAndSortKey (count, digits); *remittance = *rmm; // save remittances to file err = saveProcessedRemittances (); // update the user interface emit updateProcessedRemittanceView( processedRemittanceList ); break; }}void LxAccount::removeRemittance ( LxRemittance *rm ){// if ( !remittanceListsRead ){// setupRemittanceLists ( );// } HBCI::Error err; int count, digits; LxRemittance *remittance; LxRemittance::RemittanceStatus rmType = rm->getStatus (); switch ( rmType ){ case LxRemittance::current: // remove remittance from the list if ( currentRemittanceList.removeRef ( rm ) ){ digits = (int)(log10((double)currentRemittanceList.count()) + 2.0); for (remittance = currentRemittanceList.first(), count = 1; remittance != 0; remittance = currentRemittanceList.next(), ++count){ remittance->setNumberAndSortKey (count, digits); } // save remittances to file err = saveProcessedRemittances (); // update the user interface emit updateCurrentRemittanceView( currentRemittanceList ); } break; case LxRemittance::processed: // remove remittance from the list if ( processedRemittanceList.removeRef ( rm ) ){ digits = (int)(log10((double)processedRemittanceList.count()) + 2.0); for (remittance = processedRemittanceList.first(), count = 1; remittance != 0; remittance = processedRemittanceList.next(), ++count){ remittance->setNumberAndSortKey (count, digits); } // save remittances to file err = saveProcessedRemittances (); // update the user interface emit updateProcessedRemittanceView( processedRemittanceList ); } break; }}// void LxAccount::saveRemittances ()// {// QFile rmFile(remittanceFile);// if ( rmFile.open(IO_ReadOnly) ) { // file opened successfully// // get all comment lines// QStringList comments;// QTextStream rmTxt( &rmFile ); // use a text stream// QString txtLine, tl;// while ( !rmTxt.eof() ) { // until end of file...// tl = txtLine = rmTxt.readLine(); // line of text excluding '\n' // if ( !LxAccount::isDataLine (tl) ){// comments.append(txtLine);// }// }// rmFile.close();// if ( rmFile.open(IO_WriteOnly) ) { // file opened successfully// QTextStream rmOut( &rmFile ); // // write comments// QStringList::Iterator it;// for (it = comments.begin(); it != comments.end(); ++it){// rmOut << *it << '\n';// }// LxRemittance *remittance; // rmOut << '\n';// // write processed remittances// for (remittance = processedRemittanceList.first();// remittance != 0; remittance = processedRemittanceList.next() ){// remittance->write ( rmOut );// }// rmOut << '\n';// // write current remittances// for (remittance = currentRemittanceList.first();// remittance != 0; remittance = currentRemittanceList.next() ){// remittance->write ( rmOut );// }// rmFile.close();// }// }// }void LxRemittance::setupTransaction (){// const HBCI::Pointer<HBCI::Account> &hbciAccount = account->HBCIaccount(); // Our account hbciTransaction.setOurCountryCode ( account->getCountry() );// cerr << "\nLxRemittance::setupTransaction: BLZ = " << account->getBLZ() << endl; hbciTransaction.setOurBankCode ( account->getBLZ().latin1() ); hbciTransaction.setOurAccountId ( account->getAccountNo().latin1() ); hbciTransaction.setOurSuffix ( "00" );// cerr << "\nLxRemittance::setupTransaction: BLZ = " << account->getBLZ() << endl; // Date HBCI::Date tmpDate1(date.day(), date.month(), date.year()); hbciTransaction.setDate ( tmpDate1 ); if ( status == processed ){ HBCI::Date tmpDate2(dateOfExecution.day(), dateOfExecution.month(), dateOfExecution.year()); hbciTransaction.setValutaDate ( tmpDate2 ); }else{ hbciTransaction.setValutaDate ( tmpDate1 ); } // Value // HBCI::Value val(amount, (*hbciAccount).currency()); HBCI::Value val(amount, currency.latin1()); hbciTransaction.setValue ( val ); // Type of Transaction hbciTransaction.setTransactionKey ( "" ); // Reference String hbciTransaction.setCustomerReference ( "" ); hbciTransaction.setBankReference ( "" ); // Currency exchange HBCI::Value charge(0.0, ""); hbciTransaction.setOriginalValue ( charge ); hbciTransaction.setCharge ( charge ); // Transaction Description hbciTransaction.setTransactionCode ( 51 ); hbciTransaction.setTransactionText ( "" ); hbciTransaction.setPrimanota ( "" ); QStringList::Iterator it; for( it = text.begin(); it != text.end(); ++it ){ if ( (*it).isNull() ){ hbciTransaction.addDescription ( "" ); }else{ hbciTransaction.addDescription ( (*it).latin1() ); } } //Other account hbciTransaction.setOtherCountryCode ( 280 ); hbciTransaction.setOtherBankCode ( receiverBLZ.latin1() ); hbciTransaction.setOtherAccountId ( receiverAccountNo.latin1() ); hbciTransaction.setOtherSuffix ( "00" ); hbciTransaction.addOtherName ( receiver.latin1() );}void LxRemittance::setupFromTransaction (){ int year, month, day; // Date const HBCI::Date &tmpDate1 = hbciTransaction.date ( ); year = tmpDate1.year(); month = tmpDate1.month(); day = tmpDate1.day(); date.setYMD ( year, month, day ); // Date of execution if ( status == processed ){ const HBCI::Date &tmpDate2 = hbciTransaction.valutaDate ( ); year = tmpDate2.year(); month = tmpDate2.month(); day = tmpDate2.day(); dateOfExecution.setYMD ( year, month, day ); } // Amount const HBCI::Value &val = hbciTransaction.value ( ); 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) ); // Currency currency = val.getCurrency ( ).c_str(); // Text const list<string> &txt = hbciTransaction.description (); list<string>::const_iterator it; for( it = txt.begin(); it != txt.end(); ++it ){ text.append ( it->c_str() ); } // Receiver blz receiverBLZ = hbciTransaction.otherBankCode ( ).c_str(); // Receiver account no receiverAccountNo = hbciTransaction.otherAccountId ( ).c_str(); recAccNoSortKey.sprintf("%010d", receiverAccountNo.toInt() ); // Receiver name const list<string> &nam = hbciTransaction.otherName(); it = nam.begin(); receiver = it->c_str();}LxRemittance::CheckResult LxRemittance::check (QString &msg){ bool receiverAccNoSet = false, receiverBLZvalid = false; bool warnFlag = false; int errorFlag = 0; int bankCount; CheckResult retval; AccountNumberCheck::Result accCheckResult; QString txt("<ul>"), info(""), blzStr; // receiver: 1 < length < 24? if ( receiver.length() == 0 ){ txt += QObject::tr("<li>Recipient's name missing!</li>"); ++errorFlag; }else if ( receiver.length() > 27 ){ txt += QObject::tr("<li>Recipient's name to long! Only 27 characters allowed.</li>"); ++errorFlag; } // receiverAccountNo if ( receiverAccountNo.length() == 0 ){ txt += QObject::tr("<li>Recipient's account number missing!</li>"); ++errorFlag; }else{ receiverAccNoSet = true; } // receiverBLZ if ( receiverBLZ.length() == 0 ){ txt += QObject::tr("<li>Recipient's bank code missing!</li>"); ++errorFlag; }else if ( receiverBLZ.length() > 8 ){ // should never happend txt += QObject::tr("<li>Recipient's bank code ("); txt += receiverBLZ; txt += QObject::tr(") invalid!</li>"); ++errorFlag; }else if ( receiverBLZ.length() < 8 ){ txt += QObject::tr("<li>Recipient's bank code ("); txt += receiverBLZ; txt += QObject::tr(") invalid!</li>"); ++errorFlag; }else{ blzStr = receiverBLZ; blzStr.insert(6, " "); blzStr.insert(3, " "); receiverBLZvalid = true; } if ( receiverBLZvalid ){ // check for existing bank bankCount = account->checkForBank (receiverBLZ.toULong()); switch (bankCount){ case 0: info += QObject::tr("<li>No institute for bank code "); info += blzStr; info += QObject::tr(" found!</li>"); receiverBLZvalid = false; warnFlag = true; break; case 1: info += QObject::tr("<li>One institute for bank code "); info += blzStr; info += QObject::tr(" found!</li>"); break; default: info += "<li>"; info += QString::number(bankCount); info += QObject::tr(" institutes for bank code "); info += blzStr; info += QObject::tr(" found!</li>"); } } string methode; if ( receiverAccNoSet && receiverBLZvalid ){ // check for existing account accCheckResult = account->checkForAccount (receiverBLZ, receiverAccountNo, methode); switch (accCheckResult){ case AccountNumberCheck::OK: info += QObject::tr("<li>Recipient's account number ("); info += receiverAccountNo; info += QObject::tr(") is valid!</li>"); break; case AccountNumberCheck::UNKNOWN: if ( methode == "09" ){ info += QObject::tr("<li>Unable to check recipient's account number. No checksum methode provided by bank!</li>"); }else{ info += QObject::tr("<li>Unable to check recipient's account number. Checksum methode not supported!</li>"); } break; case AccountNumberCheck::ERROR: info += QObject::tr("<li>Recipient's account number ("); info += receiverAccountNo; info += QObject::tr(") is invalid!</li>"); warnFlag = true; break; case AccountNumberCheck::BANK_NOT_KNOWN: info += QObject::tr("<li>Unable to check recipient's account number. No institute with bank code "); info += blzStr; info += QObject::tr(" found!</li>"); } }else if ( receiverAccNoSet ){ info += QObject::tr("<li>Recipient's account number ("); info += receiverAccountNo; info += QObject::tr(") not checked!</li>"); } // amount: amount > 0,5EUR if ( amount < 0.01){ txt += QObject::tr("<li>Value to small! Must be greater then 0.01 "); txt += currency; txt += ".</li>"; ++errorFlag; } // text1 + 2: length < 27 QStringList::Iterator it; int lnum, plen; for( it = text.begin(), lnum = 1, plen = 0; it != text.end(); ++it, ++lnum ){ if ( !(*it).isNull() ){ plen += (*it).length(); if ( (*it).length() > 27 ){ txt += QObject::tr("<li>Purpose line "); txt += QString::number (lnum); txt += QObject::tr(" to long! Only 27 characters allowed.</li>"); ++errorFlag; } } } // text1 + 2: not defined if ( !plen ){ txt += QObject::tr("<li>Purpose is missing!</li>"); ++errorFlag; } // date: if ( !date.isValid () ){ txt += QObject::tr("<li>Date is invalid!</li>"); ++errorFlag; } // complete the message if ( errorFlag && warnFlag ){ msg = QObject::tr("<b>This money transfer cannot be processed due to the following errors:</b><br><br>"); msg += txt; msg += info; msg += "</ul>"; }else if ( errorFlag ){ if ( errorFlag == 1 ){ msg = QObject::tr("<b>This money transfer cannot be processed due to the following error:</b><br><br>"); msg += txt; msg += "</ul>"; }else if ( errorFlag > 1 ){ msg = QObject::tr("<b>This money transfer cannot be processed due to the following errors:</b><br><br>"); msg += txt; msg += "</ul>"; } }else if ( warnFlag ){ msg = QObject::tr("<b>This money transfer cannot not be processed for the following reason:</b><br><br>"); msg += "<ul>"; msg += info; msg += "</ul>"; }else{ msg = QObject::tr("<b>This money transfer is formal correct!</b><br><br>"); msg += QObject::tr("The check of the recipient's bank code and account number by" " \"KtoBlzCheck\" yields the following result:<br><br>"); msg += "<ul>"; msg += info; msg += "</ul>";// msg += QObject::tr("</ul><br>But be careful.");// msg += QObject::tr(" It cannot be guaranteed, that the check methods "// "provided by the banks give correct results under all circumstances.");// msg += QObject::tr("<br><br>For more information see www.bundesbank.de/zv/zv_pruefziffer.php"// " and/or sourceforge.net/projects/ktoblzcheck."); } // determine return value if ( errorFlag ){ retval = Error; }else if ( warnFlag ){ retval = Error; }else{ retval = Passed; } return retval;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -