Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/plugins/sql/mymoneystoragesql.cpp
Context not available. | |||||
45 | { | 45 | { | ||
---|---|---|---|---|---|
46 | try { | 46 | try { | ||
47 | close(true); | 47 | close(true); | ||
48 | } catch (const MyMoneyException& e) { | 48 | } catch (const MyMoneyException &e) { | ||
49 | qDebug() << "Caught Exception in MMStorageSql dtor: " << e.what(); | 49 | qDebug() << "Caught Exception in MMStorageSql dtor: " << e.what(); | ||
50 | } | 50 | } | ||
51 | Q_D(MyMoneyStorageSql); | 51 | Q_D(MyMoneyStorageSql); | ||
Context not available. | |||||
279 | { | 279 | { | ||
280 | Q_D(MyMoneyStorageSql); | 280 | Q_D(MyMoneyStorageSql); | ||
281 | if (d->m_commitUnitStack.isEmpty()) { | 281 | if (d->m_commitUnitStack.isEmpty()) { | ||
282 | if (!transaction()) throw MYMONEYEXCEPTION(d->buildError(QSqlQuery(), callingFunction, "starting commit unit") + ' ' + callingFunction); | 282 | if (!transaction()) throw MYMONEYEXCEPTION(d->buildError(QSqlQuery(), callingFunction, "starting commit unit")); | ||
283 | } | 283 | } | ||
284 | d->m_commitUnitStack.push(callingFunction); | 284 | d->m_commitUnitStack.push(callingFunction); | ||
285 | } | 285 | } | ||
Context not available. | |||||
294 | // as value of this method. | 294 | // as value of this method. | ||
295 | bool rc = true; | 295 | bool rc = true; | ||
296 | if (d->m_commitUnitStack.isEmpty()) { | 296 | if (d->m_commitUnitStack.isEmpty()) { | ||
297 | throw MYMONEYEXCEPTION("Empty commit unit stack while trying to commit"); | 297 | throw MYMONEYEXCEPTION_CSTRING("Empty commit unit stack while trying to commit"); | ||
298 | } | 298 | } | ||
299 | 299 | | |||
300 | if (callingFunction != d->m_commitUnitStack.top()) | 300 | if (callingFunction != d->m_commitUnitStack.top()) | ||
Context not available. | |||||
366 | QVariantList kvpList; | 366 | QVariantList kvpList; | ||
367 | kvpList << inst.id(); | 367 | kvpList << inst.id(); | ||
368 | d->deleteKeyValuePairs("OFXSETTINGS", kvpList); | 368 | d->deleteKeyValuePairs("OFXSETTINGS", kvpList); | ||
369 | QSqlQuery q(*this); | 369 | QSqlQuery query(*this); | ||
370 | q.prepare(d->m_db.m_tables["kmmInstitutions"].deleteString()); | 370 | query.prepare(d->m_db.m_tables["kmmInstitutions"].deleteString()); | ||
371 | q.bindValue(":id", inst.id()); | 371 | query.bindValue(":id", inst.id()); | ||
372 | if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Institution"))); // krazy:exclude=crashy | 372 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Institution")); // krazy:exclude=crashy | ||
373 | --d->m_institutions; | 373 | --d->m_institutions; | ||
374 | d->writeFileInfo(); | 374 | d->writeFileInfo(); | ||
375 | } | 375 | } | ||
Context not available. | |||||
378 | { | 378 | { | ||
379 | Q_D(MyMoneyStorageSql); | 379 | Q_D(MyMoneyStorageSql); | ||
380 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | 380 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | ||
381 | QSqlQuery q(*this); | 381 | QSqlQuery query(*this); | ||
382 | q.prepare(d->m_db.m_tables["kmmPayees"].insertString()); | 382 | query.prepare(d->m_db.m_tables["kmmPayees"].insertString()); | ||
383 | d->writePayee(payee, q); | 383 | d->writePayee(payee, query); | ||
384 | ++d->m_payees; | 384 | ++d->m_payees; | ||
385 | 385 | | |||
386 | QVariantList identIds; | 386 | QVariantList identIds; | ||
Context not available. | |||||
392 | // note: this changes ident | 392 | // note: this changes ident | ||
393 | addPayeeIdentifier(ident); | 393 | addPayeeIdentifier(ident); | ||
394 | identIds.append(ident.idString()); | 394 | identIds.append(ident.idString()); | ||
395 | } catch (payeeIdentifier::empty&) { | 395 | } catch (const payeeIdentifier::empty &) { | ||
396 | } | 396 | } | ||
397 | } | 397 | } | ||
398 | 398 | | |||
Context not available. | |||||
407 | order << i; | 407 | order << i; | ||
408 | payeeIdList << payee.id(); | 408 | payeeIdList << payee.id(); | ||
409 | } | 409 | } | ||
410 | q.prepare("INSERT INTO kmmPayeesPayeeIdentifier (payeeId, identifierId, userOrder) VALUES(?, ?, ?)"); | 410 | query.prepare("INSERT INTO kmmPayeesPayeeIdentifier (payeeId, identifierId, userOrder) VALUES(?, ?, ?)"); | ||
411 | q.bindValue(0, payeeIdList); | 411 | query.bindValue(0, payeeIdList); | ||
412 | q.bindValue(1, identIds); | 412 | query.bindValue(1, identIds); | ||
413 | q.bindValue(2, order); | 413 | query.bindValue(2, order); | ||
414 | if (!q.execBatch()) | 414 | if (!query.execBatch()) | ||
415 | throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("writing payee's identifiers"))); // krazy:exclude=crashy | 415 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("writing payee's identifiers")); // krazy:exclude=crashy | ||
416 | } | 416 | } | ||
417 | 417 | | |||
418 | d->writeFileInfo(); | 418 | d->writeFileInfo(); | ||
Context not available. | |||||
422 | { | 422 | { | ||
423 | Q_D(MyMoneyStorageSql); | 423 | Q_D(MyMoneyStorageSql); | ||
424 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | 424 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | ||
425 | QSqlQuery q(*this); | 425 | QSqlQuery query(*this); | ||
426 | q.prepare(d->m_db.m_tables["kmmPayees"].updateString()); | 426 | query.prepare(d->m_db.m_tables["kmmPayees"].updateString()); | ||
427 | d->writePayee(payee, q); | 427 | d->writePayee(payee, query); | ||
428 | 428 | | |||
429 | // Get a list of old identifiers first | 429 | // Get a list of old identifiers first | ||
430 | q.prepare("SELECT identifierId FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?"); | 430 | query.prepare("SELECT identifierId FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?"); | ||
431 | q.bindValue(0, payee.id()); | 431 | query.bindValue(0, payee.id()); | ||
432 | if (!q.exec()) | 432 | if (!query.exec()) | ||
433 | throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("modifying payee's identifiers (getting old values failed)"))); // krazy:exclude=crashy | 433 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("modifying payee's identifiers (getting old values failed)")); // krazy:exclude=crashy | ||
434 | 434 | | |||
435 | QStringList oldIdentIds; | 435 | QStringList oldIdentIds; | ||
436 | oldIdentIds.reserve(q.numRowsAffected()); | 436 | oldIdentIds.reserve(query.numRowsAffected()); | ||
437 | while (q.next()) | 437 | while (query.next()) | ||
438 | oldIdentIds << q.value(0).toString(); | 438 | oldIdentIds << query.value(0).toString(); | ||
439 | 439 | | |||
440 | // Add new and modify old payeeIdentifiers | 440 | // Add new and modify old payeeIdentifiers | ||
441 | foreach (payeeIdentifier ident, payee.payeeIdentifiers()) { | 441 | foreach (payeeIdentifier ident, payee.payeeIdentifiers()) { | ||
Context not available. | |||||
460 | } | 460 | } | ||
461 | 461 | | |||
462 | // Update relation table | 462 | // Update relation table | ||
463 | q.prepare("DELETE FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?"); | 463 | query.prepare("DELETE FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?"); | ||
464 | q.bindValue(0, payee.id()); | 464 | query.bindValue(0, payee.id()); | ||
465 | if (!q.exec()) | 465 | if (!query.exec()) | ||
466 | throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("modifying payee's identifiers (delete from mapping table)"))); // krazy:exclude=crashy | 466 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("modifying payee's identifiers (delete from mapping table)")); // krazy:exclude=crashy | ||
467 | 467 | | |||
468 | // Get list again because modifiyPayeeIdentifier which is used above may change the id | 468 | // Get list again because modifiyPayeeIdentifier which is used above may change the id | ||
469 | QList<payeeIdentifier> idents(payee.payeeIdentifiers()); | 469 | QList<payeeIdentifier> idents(payee.payeeIdentifiers()); | ||
Context not available. | |||||
485 | } | 485 | } | ||
486 | } | 486 | } | ||
487 | 487 | | |||
488 | q.prepare("INSERT INTO kmmPayeesPayeeIdentifier (payeeId, userOrder, identifierId) VALUES(?, ?, ?)"); | 488 | query.prepare("INSERT INTO kmmPayeesPayeeIdentifier (payeeId, userOrder, identifierId) VALUES(?, ?, ?)"); | ||
489 | q.bindValue(0, payeeIdList); | 489 | query.bindValue(0, payeeIdList); | ||
490 | q.bindValue(1, order); | 490 | query.bindValue(1, order); | ||
491 | q.bindValue(2, identIdList); | 491 | query.bindValue(2, identIdList); | ||
492 | if (!q.execBatch()) | 492 | if (!query.execBatch()) | ||
493 | throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("writing payee's identifiers during modify"))); // krazy:exclude=crashy | 493 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("writing payee's identifiers during modify")); // krazy:exclude=crashy | ||
494 | 494 | | |||
495 | d->writeFileInfo(); | 495 | d->writeFileInfo(); | ||
496 | } | 496 | } | ||
Context not available. | |||||
509 | { | 509 | { | ||
510 | Q_D(MyMoneyStorageSql); | 510 | Q_D(MyMoneyStorageSql); | ||
511 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | 511 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | ||
512 | QSqlQuery q(*this); | 512 | QSqlQuery query(*this); | ||
513 | 513 | | |||
514 | // Get identifiers first so we know which to delete | 514 | // Get identifiers first so we know which to delete | ||
515 | q.prepare("SELECT identifierId FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?"); | 515 | query.prepare("SELECT identifierId FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?"); | ||
516 | q.bindValue(0, payee.id()); | 516 | query.bindValue(0, payee.id()); | ||
517 | if (!q.exec()) | 517 | if (!query.exec()) | ||
518 | throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("removing payee's identifiers (getting old values failed)"))); // krazy:exclude=crashy | 518 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("removing payee's identifiers (getting old values failed)")); // krazy:exclude=crashy | ||
519 | 519 | | |||
520 | QStringList identIds; | 520 | QStringList identIds; | ||
521 | while (q.next()) | 521 | while (query.next()) | ||
522 | identIds << q.value(0).toString(); | 522 | identIds << query.value(0).toString(); | ||
523 | 523 | | |||
524 | QMap<QString, payeeIdentifier> idents = fetchPayeeIdentifiers(identIds); | 524 | QMap<QString, payeeIdentifier> idents = fetchPayeeIdentifiers(identIds); | ||
525 | foreach (payeeIdentifier ident, idents) { | 525 | foreach (payeeIdentifier ident, idents) { | ||
Context not available. | |||||
527 | } | 527 | } | ||
528 | 528 | | |||
529 | // Delete entries from mapping table | 529 | // Delete entries from mapping table | ||
530 | q.prepare("DELETE FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?"); | 530 | query.prepare("DELETE FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?"); | ||
531 | q.bindValue(0, payee.id()); | 531 | query.bindValue(0, payee.id()); | ||
532 | if (!q.exec()) | 532 | if (!query.exec()) | ||
533 | throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("removing payee's identifiers (delete from mapping table)"))); // krazy:exclude=crashy | 533 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("removing payee's identifiers (delete from mapping table)")); // krazy:exclude=crashy | ||
534 | 534 | | |||
535 | // Delete payee | 535 | // Delete payee | ||
536 | q.prepare(d->m_db.m_tables["kmmPayees"].deleteString()); | 536 | query.prepare(d->m_db.m_tables["kmmPayees"].deleteString()); | ||
537 | q.bindValue(":id", payee.id()); | 537 | query.bindValue(":id", payee.id()); | ||
538 | if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Payee"))); // krazy:exclude=crashy | 538 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Payee")); // krazy:exclude=crashy | ||
539 | --d->m_payees; | 539 | --d->m_payees; | ||
540 | 540 | | |||
541 | d->writeFileInfo(); | 541 | d->writeFileInfo(); | ||
Context not available. | |||||
567 | { | 567 | { | ||
568 | Q_D(MyMoneyStorageSql); | 568 | Q_D(MyMoneyStorageSql); | ||
569 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | 569 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | ||
570 | QSqlQuery q(*this); | 570 | QSqlQuery query(*this); | ||
571 | q.prepare(d->m_db.m_tables["kmmTags"].deleteString()); | 571 | query.prepare(d->m_db.m_tables["kmmTags"].deleteString()); | ||
572 | q.bindValue(":id", tag.id()); | 572 | query.bindValue(":id", tag.id()); | ||
573 | if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Tag"))); // krazy:exclude=crashy | 573 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Tag")); // krazy:exclude=crashy | ||
574 | --d->m_tags; | 574 | --d->m_tags; | ||
575 | d->writeFileInfo(); | 575 | d->writeFileInfo(); | ||
576 | } | 576 | } | ||
Context not available. | |||||
620 | kvpList << acc.id(); | 620 | kvpList << acc.id(); | ||
621 | d->deleteKeyValuePairs("ACCOUNT", kvpList); | 621 | d->deleteKeyValuePairs("ACCOUNT", kvpList); | ||
622 | d->deleteKeyValuePairs("ONLINEBANKING", kvpList); | 622 | d->deleteKeyValuePairs("ONLINEBANKING", kvpList); | ||
623 | QSqlQuery q(*this); | 623 | QSqlQuery query(*this); | ||
624 | q.prepare(d->m_db.m_tables["kmmAccounts"].deleteString()); | 624 | query.prepare(d->m_db.m_tables["kmmAccounts"].deleteString()); | ||
625 | q.bindValue(":id", acc.id()); | 625 | query.bindValue(":id", acc.id()); | ||
626 | if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Account"))); // krazy:exclude=crashy | 626 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Account")); // krazy:exclude=crashy | ||
627 | --d->m_accounts; | 627 | --d->m_accounts; | ||
628 | d->writeFileInfo(); | 628 | d->writeFileInfo(); | ||
629 | } | 629 | } | ||
Context not available. | |||||
656 | Q_D(MyMoneyStorageSql); | 656 | Q_D(MyMoneyStorageSql); | ||
657 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | 657 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | ||
658 | // remove the splits of the old tx from the count table | 658 | // remove the splits of the old tx from the count table | ||
659 | QSqlQuery q(*this); | 659 | QSqlQuery query(*this); | ||
660 | q.prepare("SELECT accountId FROM kmmSplits WHERE transactionId = :txId;"); | 660 | query.prepare("SELECT accountId FROM kmmSplits WHERE transactionId = :txId;"); | ||
661 | q.bindValue(":txId", tx.id()); | 661 | query.bindValue(":txId", tx.id()); | ||
662 | if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, "retrieving old splits")); | 662 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("retrieving old splits")); | ||
663 | while (q.next()) { | 663 | while (query.next()) { | ||
664 | QString id = q.value(0).toString(); | 664 | QString id = query.value(0).toString(); | ||
665 | --d->m_transactionCountMap[id]; | 665 | --d->m_transactionCountMap[id]; | ||
666 | } | 666 | } | ||
667 | // add the transaction and splits | 667 | // add the transaction and splits | ||
668 | q.prepare(d->m_db.m_tables["kmmTransactions"].updateString()); | 668 | query.prepare(d->m_db.m_tables["kmmTransactions"].updateString()); | ||
669 | d->writeTransaction(tx.id(), tx, q, "N"); | 669 | d->writeTransaction(tx.id(), tx, query, "N"); | ||
670 | QList<MyMoneyAccount> aList; | 670 | QList<MyMoneyAccount> aList; | ||
671 | // for each split account, update lastMod date, balance, txCount | 671 | // for each split account, update lastMod date, balance, txCount | ||
672 | foreach (const MyMoneySplit& it_s, tx.splits()) { | 672 | foreach (const MyMoneySplit& it_s, tx.splits()) { | ||
Context not available. | |||||
763 | QVariantList kvpList; | 763 | QVariantList kvpList; | ||
764 | kvpList << sec.id(); | 764 | kvpList << sec.id(); | ||
765 | d->deleteKeyValuePairs("SECURITY", kvpList); | 765 | d->deleteKeyValuePairs("SECURITY", kvpList); | ||
766 | QSqlQuery q(*this); | 766 | QSqlQuery query(*this); | ||
767 | q.prepare(d->m_db.m_tables["kmmSecurities"].deleteString()); | 767 | query.prepare(d->m_db.m_tables["kmmSecurities"].deleteString()); | ||
768 | q.bindValue(":id", kvpList); | 768 | query.bindValue(":id", kvpList); | ||
769 | if (!q.execBatch()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Security"))); | 769 | if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Security")); | ||
770 | --d->m_securities; | 770 | --d->m_securities; | ||
771 | d->writeFileInfo(); | 771 | d->writeFileInfo(); | ||
772 | } | 772 | } | ||
Context not available. | |||||
779 | // the app always calls addPrice, whether or not there is already one there | 779 | // the app always calls addPrice, whether or not there is already one there | ||
780 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | 780 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | ||
781 | bool newRecord = false; | 781 | bool newRecord = false; | ||
782 | QSqlQuery q(*this); | 782 | QSqlQuery query(*this); | ||
783 | QString s = d->m_db.m_tables["kmmPrices"].selectAllString(false); | 783 | QString s = d->m_db.m_tables["kmmPrices"].selectAllString(false); | ||
784 | s += " WHERE fromId = :fromId AND toId = :toId AND priceDate = :priceDate;"; | 784 | s += " WHERE fromId = :fromId AND toId = :toId AND priceDate = :priceDate;"; | ||
785 | q.prepare(s); | 785 | query.prepare(s); | ||
786 | q.bindValue(":fromId", p.from()); | 786 | query.bindValue(":fromId", p.from()); | ||
787 | q.bindValue(":toId", p.to()); | 787 | query.bindValue(":toId", p.to()); | ||
788 | q.bindValue(":priceDate", p.date().toString(Qt::ISODate)); | 788 | query.bindValue(":priceDate", p.date().toString(Qt::ISODate)); | ||
789 | if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("finding Price"))); // krazy:exclude=crashy | 789 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("finding Price")); // krazy:exclude=crashy | ||
790 | if (q.next()) { | 790 | if (query.next()) { | ||
791 | q.prepare(d->m_db.m_tables["kmmPrices"].updateString()); | 791 | query.prepare(d->m_db.m_tables["kmmPrices"].updateString()); | ||
792 | } else { | 792 | } else { | ||
793 | q.prepare(d->m_db.m_tables["kmmPrices"].insertString()); | 793 | query.prepare(d->m_db.m_tables["kmmPrices"].insertString()); | ||
794 | ++d->m_prices; | 794 | ++d->m_prices; | ||
795 | newRecord = true; | 795 | newRecord = true; | ||
796 | } | 796 | } | ||
797 | q.bindValue(":fromId", p.from()); | 797 | query.bindValue(":fromId", p.from()); | ||
798 | q.bindValue(":toId", p.to()); | 798 | query.bindValue(":toId", p.to()); | ||
799 | q.bindValue(":priceDate", p.date().toString(Qt::ISODate)); | 799 | query.bindValue(":priceDate", p.date().toString(Qt::ISODate)); | ||
800 | q.bindValue(":price", p.rate(QString()).toString()); | 800 | query.bindValue(":price", p.rate(QString()).toString()); | ||
801 | const MyMoneySecurity sec = d->m_storage->security(p.to()); | 801 | const MyMoneySecurity sec = d->m_storage->security(p.to()); | ||
802 | q.bindValue(":priceFormatted", | 802 | query.bindValue(":priceFormatted", | ||
803 | p.rate(QString()).formatMoney("", sec.pricePrecision())); | 803 | p.rate(QString()).formatMoney("", sec.pricePrecision())); | ||
804 | q.bindValue(":priceSource", p.source()); | 804 | query.bindValue(":priceSource", p.source()); | ||
805 | if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("writing Price"))); // krazy:exclude=crashy | 805 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("writing Price")); // krazy:exclude=crashy | ||
806 | 806 | | |||
807 | if (newRecord) d->writeFileInfo(); | 807 | if (newRecord) d->writeFileInfo(); | ||
808 | } | 808 | } | ||
Context not available. | |||||
811 | { | 811 | { | ||
812 | Q_D(MyMoneyStorageSql); | 812 | Q_D(MyMoneyStorageSql); | ||
813 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | 813 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | ||
814 | QSqlQuery q(*this); | 814 | QSqlQuery query(*this); | ||
815 | q.prepare(d->m_db.m_tables["kmmPrices"].deleteString()); | 815 | query.prepare(d->m_db.m_tables["kmmPrices"].deleteString()); | ||
816 | q.bindValue(":fromId", p.from()); | 816 | query.bindValue(":fromId", p.from()); | ||
817 | q.bindValue(":toId", p.to()); | 817 | query.bindValue(":toId", p.to()); | ||
818 | q.bindValue(":priceDate", p.date().toString(Qt::ISODate)); | 818 | query.bindValue(":priceDate", p.date().toString(Qt::ISODate)); | ||
819 | if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Price"))); // krazy:exclude=crashy | 819 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Price")); // krazy:exclude=crashy | ||
820 | --d->m_prices; | 820 | --d->m_prices; | ||
821 | d->writeFileInfo(); | 821 | d->writeFileInfo(); | ||
822 | } | 822 | } | ||
Context not available. | |||||
847 | { | 847 | { | ||
848 | Q_D(MyMoneyStorageSql); | 848 | Q_D(MyMoneyStorageSql); | ||
849 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | 849 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | ||
850 | QSqlQuery q(*this); | 850 | QSqlQuery query(*this); | ||
851 | q.prepare(d->m_db.m_tables["kmmCurrencies"].deleteString()); | 851 | query.prepare(d->m_db.m_tables["kmmCurrencies"].deleteString()); | ||
852 | q.bindValue(":ISOcode", sec.id()); | 852 | query.bindValue(":ISOcode", sec.id()); | ||
853 | if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Currency"))); // krazy:exclude=crashy | 853 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Currency")); // krazy:exclude=crashy | ||
854 | --d->m_currencies; | 854 | --d->m_currencies; | ||
855 | d->writeFileInfo(); | 855 | d->writeFileInfo(); | ||
856 | } | 856 | } | ||
Context not available. | |||||
880 | { | 880 | { | ||
881 | Q_D(MyMoneyStorageSql); | 881 | Q_D(MyMoneyStorageSql); | ||
882 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | 882 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | ||
883 | QSqlQuery q(*this); | 883 | QSqlQuery query(*this); | ||
884 | q.prepare("DELETE FROM kmmReportConfig WHERE id = :id"); | 884 | query.prepare("DELETE FROM kmmReportConfig WHERE id = :id"); | ||
885 | q.bindValue(":id", rep.id()); | 885 | query.bindValue(":id", rep.id()); | ||
886 | if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Report"))); // krazy:exclude=crashy | 886 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Report")); // krazy:exclude=crashy | ||
887 | --d->m_reports; | 887 | --d->m_reports; | ||
888 | d->writeFileInfo(); | 888 | d->writeFileInfo(); | ||
889 | } | 889 | } | ||
Context not available. | |||||
913 | { | 913 | { | ||
914 | Q_D(MyMoneyStorageSql); | 914 | Q_D(MyMoneyStorageSql); | ||
915 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | 915 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | ||
916 | QSqlQuery q(*this); | 916 | QSqlQuery query(*this); | ||
917 | q.prepare(d->m_db.m_tables["kmmBudgetConfig"].deleteString()); | 917 | query.prepare(d->m_db.m_tables["kmmBudgetConfig"].deleteString()); | ||
918 | q.bindValue(":id", bud.id()); | 918 | query.bindValue(":id", bud.id()); | ||
919 | if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Budget"))); // krazy:exclude=crashy | 919 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Budget")); // krazy:exclude=crashy | ||
920 | --d->m_budgets; | 920 | --d->m_budgets; | ||
921 | d->writeFileInfo(); | 921 | d->writeFileInfo(); | ||
922 | } | 922 | } | ||
Context not available. | |||||
925 | { | 925 | { | ||
926 | Q_D(MyMoneyStorageSql); | 926 | Q_D(MyMoneyStorageSql); | ||
927 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | 927 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | ||
928 | QSqlQuery q(*this); | 928 | QSqlQuery query(*this); | ||
929 | q.prepare("INSERT INTO kmmOnlineJobs (id, type, jobSend, bankAnswerDate, state, locked) VALUES(:id, :type, :jobSend, :bankAnswerDate, :state, :locked);"); | 929 | query.prepare("INSERT INTO kmmOnlineJobs (id, type, jobSend, bankAnswerDate, state, locked) VALUES(:id, :type, :jobSend, :bankAnswerDate, :state, :locked);"); | ||
930 | d->writeOnlineJob(job, q); | 930 | d->writeOnlineJob(job, query); | ||
931 | if (!q.exec()) | 931 | if (!query.exec()) | ||
932 | throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("writing onlineJob"))); // krazy:exclude=crashy | 932 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("writing onlineJob")); // krazy:exclude=crashy | ||
933 | ++d->m_onlineJobs; | 933 | ++d->m_onlineJobs; | ||
934 | 934 | | |||
935 | try { | 935 | try { | ||
Context not available. | |||||
958 | 958 | | |||
959 | d->writeOnlineJob(job, query); | 959 | d->writeOnlineJob(job, query); | ||
960 | if (!query.exec()) | 960 | if (!query.exec()) | ||
961 | throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("writing onlineJob"))); // krazy:exclude=crashy | 961 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("writing onlineJob")); // krazy:exclude=crashy | ||
962 | 962 | | |||
963 | try { | 963 | try { | ||
964 | // Modify online task | 964 | // Modify online task | ||
Context not available. | |||||
982 | } catch (onlineJob::emptyTask&) { | 982 | } catch (onlineJob::emptyTask&) { | ||
983 | } | 983 | } | ||
984 | 984 | | |||
985 | QSqlQuery q(*this); | 985 | QSqlQuery query(*this); | ||
986 | q.prepare(d->m_db.m_tables["kmmOnlineJobs"].deleteString()); | 986 | query.prepare(d->m_db.m_tables["kmmOnlineJobs"].deleteString()); | ||
987 | q.bindValue(":id", job.id()); | 987 | query.bindValue(":id", job.id()); | ||
988 | if (!q.exec()) | 988 | if (!query.exec()) | ||
989 | throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting onlineJob"))); // krazy:exclude=crashy | 989 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting onlineJob")); // krazy:exclude=crashy | ||
990 | --d->m_onlineJobs; | 990 | --d->m_onlineJobs; | ||
991 | } | 991 | } | ||
992 | 992 | | |||
Context not available. | |||||
1004 | 1004 | | |||
1005 | try { | 1005 | try { | ||
1006 | d->insertStorableObject(*ident.data(), ident.idString()); | 1006 | d->insertStorableObject(*ident.data(), ident.idString()); | ||
1007 | } catch (payeeIdentifier::empty&) { | 1007 | } catch (const payeeIdentifier::empty &) { | ||
1008 | } | 1008 | } | ||
1009 | } | 1009 | } | ||
1010 | 1010 | | |||
Context not available. | |||||
1013 | Q_D(MyMoneyStorageSql); | 1013 | Q_D(MyMoneyStorageSql); | ||
1014 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | 1014 | MyMoneyDbTransaction t(*this, Q_FUNC_INFO); | ||
1015 | 1015 | | |||
1016 | QSqlQuery q(*this); | 1016 | QSqlQuery query(*this); | ||
1017 | q.prepare("SELECT type FROM kmmPayeeIdentifier WHERE id = ?"); | 1017 | query.prepare("SELECT type FROM kmmPayeeIdentifier WHERE id = ?"); | ||
1018 | q.bindValue(0, ident.idString()); | 1018 | query.bindValue(0, ident.idString()); | ||
1019 | if (!q.exec() || !q.next()) | 1019 | if (!query.exec() || !query.next()) | ||
1020 | throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("modifying payeeIdentifier"))); // krazy:exclude=crashy | 1020 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("modifying payeeIdentifier")); // krazy:exclude=crashy | ||
1021 | 1021 | | |||
1022 | bool typeChanged = (q.value(0).toString() != ident.iid()); | 1022 | bool typeChanged = (query.value(0).toString() != ident.iid()); | ||
1023 | 1023 | | |||
1024 | if (typeChanged) { | 1024 | if (typeChanged) { | ||
1025 | // Delete old identifier if type changed | 1025 | // Delete old identifier if type changed | ||
1026 | const payeeIdentifier oldIdent(fetchPayeeIdentifier(ident.idString())); | 1026 | const payeeIdentifier oldIdent(fetchPayeeIdentifier(ident.idString())); | ||
1027 | try { | 1027 | try { | ||
1028 | d->deleteStorableObject(*oldIdent.data(), ident.idString()); | 1028 | d->deleteStorableObject(*oldIdent.data(), ident.idString()); | ||
1029 | } catch (payeeIdentifier::empty&) { | 1029 | } catch (const payeeIdentifier::empty &) { | ||
1030 | // Note: this should not happen because the ui does not offer a way to change | 1030 | // Note: this should not happen because the ui does not offer a way to change | ||
1031 | // the type of an payeeIdentifier if it was not correctly loaded. | 1031 | // the type of an payeeIdentifier if it was not correctly loaded. | ||
1032 | throw MYMONEYEXCEPTION(QLatin1String("Could not modify payeeIdentifier '") | 1032 | throw MYMONEYEXCEPTION((QString::fromLatin1("Could not modify payeeIdentifier '") | ||
1033 | + ident.idString() | 1033 | + ident.idString() | ||
1034 | + QLatin1String("' because type changed and could not remove identifier of old type. Maybe a plugin is missing?") | 1034 | + QLatin1String("' because type changed and could not remove identifier of old type. Maybe a plugin is missing?")) | ||
1035 | ); // krazy:exclude=crashy | 1035 | ); // krazy:exclude=crashy | ||
1036 | } | 1036 | } | ||
1037 | } | 1037 | } | ||
1038 | 1038 | | |||
1039 | q.prepare("UPDATE kmmPayeeIdentifier SET type = :type WHERE id = :id"); | 1039 | query.prepare("UPDATE kmmPayeeIdentifier SET type = :type WHERE id = :id"); | ||
1040 | d->writePayeeIdentifier(ident, q); | 1040 | d->writePayeeIdentifier(ident, query); | ||
1041 | 1041 | | |||
1042 | try { | 1042 | try { | ||
1043 | if (typeChanged) | 1043 | if (typeChanged) | ||
1044 | d->insertStorableObject(*ident.data(), ident.idString()); | 1044 | d->insertStorableObject(*ident.data(), ident.idString()); | ||
1045 | else | 1045 | else | ||
1046 | d->updateStorableObject(*ident.data(), ident.idString()); | 1046 | d->updateStorableObject(*ident.data(), ident.idString()); | ||
1047 | } catch (payeeIdentifier::empty&) { | 1047 | } catch (const payeeIdentifier::empty &) { | ||
1048 | } | 1048 | } | ||
1049 | } | 1049 | } | ||
1050 | 1050 | | |||
Context not available. | |||||
1057 | // of row in kmmPayeeIdentifier | 1057 | // of row in kmmPayeeIdentifier | ||
1058 | try { | 1058 | try { | ||
1059 | d->deleteStorableObject(*ident.data(), ident.idString()); | 1059 | d->deleteStorableObject(*ident.data(), ident.idString()); | ||
1060 | } catch (payeeIdentifier::empty&) { | 1060 | } catch (const payeeIdentifier::empty &) { | ||
1061 | } | 1061 | } | ||
1062 | 1062 | | |||
1063 | QSqlQuery q(*this); | 1063 | QSqlQuery query(*this); | ||
1064 | q.prepare(d->m_db.m_tables["kmmPayeeIdentifier"].deleteString()); | 1064 | query.prepare(d->m_db.m_tables["kmmPayeeIdentifier"].deleteString()); | ||
1065 | q.bindValue(":id", ident.idString()); | 1065 | query.bindValue(":id", ident.idString()); | ||
1066 | if (!q.exec()) | 1066 | if (!query.exec()) | ||
1067 | throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting payeeIdentifier"))); // krazy:exclude=crashy | 1067 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting payeeIdentifier")); // krazy:exclude=crashy | ||
1068 | --d->m_payeeIdentifier; | 1068 | --d->m_payeeIdentifier; | ||
1069 | } | 1069 | } | ||
1070 | 1070 | | |||
Context not available. | |||||
1120 | } | 1120 | } | ||
1121 | } | 1121 | } | ||
1122 | 1122 | | |||
1123 | if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Institution"))); // krazy:exclude=crashy | 1123 | if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString::fromLatin1("reading Institution"))); // krazy:exclude=crashy | ||
1124 | int idCol = t.fieldNumber("id"); | 1124 | int idCol = t.fieldNumber("id"); | ||
1125 | int nameCol = t.fieldNumber("name"); | 1125 | int nameCol = t.fieldNumber("name"); | ||
1126 | int managerCol = t.fieldNumber("manager"); | 1126 | int managerCol = t.fieldNumber("manager"); | ||
Context not available. | |||||
1142 | inst.setTelephone(GETSTRING(telephoneCol)); | 1142 | inst.setTelephone(GETSTRING(telephoneCol)); | ||
1143 | // get list of subaccounts | 1143 | // get list of subaccounts | ||
1144 | sq.bindValue(":id", iid); | 1144 | sq.bindValue(":id", iid); | ||
1145 | if (!sq.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Institution AccountList"))); // krazy:exclude=crashy | 1145 | if (!sq.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Institution AccountList")); // krazy:exclude=crashy | ||
1146 | QStringList aList; | 1146 | QStringList aList; | ||
1147 | while (sq.next()) aList.append(sq.value(0).toString()); | 1147 | while (sq.next()) aList.append(sq.value(0).toString()); | ||
1148 | foreach (const QString& it, aList) | 1148 | foreach (const QString& it, aList) | ||
Context not available. | |||||
1231 | } | 1231 | } | ||
1232 | 1232 | | |||
1233 | if (!query.exec()) | 1233 | if (!query.exec()) | ||
1234 | throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Payee"))); // krazy:exclude=crashy | 1234 | throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString::fromLatin1("reading Payee"))); // krazy:exclude=crashy | ||
1235 | const QSqlRecord record = query.record(); | 1235 | const QSqlRecord record = query.record(); | ||
1236 | const int idCol = record.indexOf("id"); | 1236 | const int idCol = record.indexOf("id"); | ||
1237 | const int nameCol = record.indexOf("name"); | 1237 | const int nameCol = record.indexOf("name"); | ||
Context not available. | |||||
1349 | } | 1349 | } | ||
1350 | } | 1350 | } | ||
1351 | if (!query.exec()) | 1351 | if (!query.exec()) | ||
1352 | throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading onlineJobs"))); // krazy:exclude=crashy | 1352 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading onlineJobs")); // krazy:exclude=crashy | ||
1353 | 1353 | | |||
1354 | // Create onlineJobs | 1354 | // Create onlineJobs | ||
1355 | int progress = 0; | 1355 | int progress = 0; | ||
Context not available. | |||||
1392 | QMap<QString, payeeIdentifier> list = fetchPayeeIdentifiers(QStringList(id)); | 1392 | QMap<QString, payeeIdentifier> list = fetchPayeeIdentifiers(QStringList(id)); | ||
1393 | QMap<QString, payeeIdentifier>::const_iterator iter = list.constFind(id); | 1393 | QMap<QString, payeeIdentifier>::const_iterator iter = list.constFind(id); | ||
1394 | if (iter == list.constEnd()) | 1394 | if (iter == list.constEnd()) | ||
1395 | throw MYMONEYEXCEPTION(QLatin1String("payeeIdentifier with id '") + id + QLatin1String("' not found.")); // krazy:exclude=crashy | 1395 | throw MYMONEYEXCEPTION(QString::fromLatin1("payeeIdentifier with id '%1' not found").arg(id)); // krazy:exclude=crashy | ||
1396 | return *iter; | 1396 | return *iter; | ||
1397 | } | 1397 | } | ||
1398 | 1398 | | |||
Context not available. | |||||
1415 | } | 1415 | } | ||
1416 | } | 1416 | } | ||
1417 | if (!query.exec()) | 1417 | if (!query.exec()) | ||
1418 | throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading payee identifiers"))); // krazy:exclude=crashy | 1418 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading payee identifiers")); // krazy:exclude=crashy | ||
1419 | 1419 | | |||
1420 | QMap<QString, payeeIdentifier> identList; | 1420 | QMap<QString, payeeIdentifier> identList; | ||
1421 | 1421 | | |||
Context not available. | |||||
1459 | whereClause += ')'; | 1459 | whereClause += ')'; | ||
1460 | query.prepare(t.selectAllString(false) + whereClause); | 1460 | query.prepare(t.selectAllString(false) + whereClause); | ||
1461 | } | 1461 | } | ||
1462 | if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Tag"))); // krazy:exclude=crashy | 1462 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Tag")); // krazy:exclude=crashy | ||
1463 | int idCol = t.fieldNumber("id"); | 1463 | int idCol = t.fieldNumber("id"); | ||
1464 | int nameCol = t.fieldNumber("name"); | 1464 | int nameCol = t.fieldNumber("name"); | ||
1465 | int notesCol = t.fieldNumber("notes"); | 1465 | int notesCol = t.fieldNumber("notes"); | ||
Context not available. | |||||
1538 | } | 1538 | } | ||
1539 | } | 1539 | } | ||
1540 | 1540 | | |||
1541 | if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Account"))); // krazy:exclude=crashy | 1541 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Account")); // krazy:exclude=crashy | ||
1542 | if (!sq.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading subAccountList"))); // krazy:exclude=crashy | 1542 | if (!sq.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading subAccountList")); // krazy:exclude=crashy | ||
1543 | 1543 | | |||
1544 | // Reserve enough space for all values. Approximate it with the size of the | 1544 | // Reserve enough space for all values. Approximate it with the size of the | ||
1545 | // idList in case the db doesn't support reporting the size of the | 1545 | // idList in case the db doesn't support reporting the size of the | ||
Context not available. | |||||
1666 | } | 1666 | } | ||
1667 | 1667 | | |||
1668 | if (!query.exec()) // krazy:exclude=crashy | 1668 | if (!query.exec()) // krazy:exclude=crashy | ||
1669 | throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("fetching balance"))); | 1669 | throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("fetching balance")); | ||
1670 | QString id; | 1670 | QString id; | ||
1671 | QString oldId; | 1671 | QString oldId; | ||
1672 | MyMoneyMoney temp; | 1672 | MyMoneyMoney temp; | ||
Context not available. | |||||
1721 | const MyMoneyDbTable& t = d->m_db.m_tables["kmmTransactions"]; | 1721 | const MyMoneyDbTable& t = d->m_db.m_tables["kmmTransactions"]; | ||
1722 | QSqlQuery query(*const_cast <MyMoneyStorageSql*>(this)); | 1722 | QSqlQuery query(*const_cast <MyMoneyStorageSql*>(this)); | ||
1723 | query.prepare(t.selectAllString(false) + whereClause + " ORDER BY id;"); | 1723 | query.prepare(t.selectAllString(false) + whereClause + " ORDER BY id;"); | ||
1724 | if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Transaction"))); // krazy:exclude=crashy | 1724 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Transaction")); // krazy:exclude=crashy | ||
1725 | const MyMoneyDbTable& ts = d->m_db.m_tables["kmmSplits"]; | 1725 | const MyMoneyDbTable& ts = d->m_db.m_tables["kmmSplits"]; | ||
1726 | whereClause = " WHERE txType = 'N' "; | 1726 | whereClause = " WHERE txType = 'N' "; | ||
1727 | if (! tidList.isEmpty()) { | 1727 | if (! tidList.isEmpty()) { | ||
Context not available. | |||||
2078 | } | 2078 | } | ||
2079 | } | 2079 | } | ||
2080 | 2080 | | |||
2081 | if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Schedules"))); // krazy:exclude=crashy | 2081 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Schedules")); // krazy:exclude=crashy | ||
2082 | int idCol = t.fieldNumber("id"); | 2082 | int idCol = t.fieldNumber("id"); | ||
2083 | int nameCol = t.fieldNumber("name"); | 2083 | int nameCol = t.fieldNumber("name"); | ||
2084 | int typeCol = t.fieldNumber("type"); | 2084 | int typeCol = t.fieldNumber("type"); | ||
Context not available. | |||||
2164 | 2164 | | |||
2165 | // read in the recorded payments | 2165 | // read in the recorded payments | ||
2166 | sq.bindValue(":id", s.id()); | 2166 | sq.bindValue(":id", s.id()); | ||
2167 | if (!sq.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading schedule payment history"))); // krazy:exclude=crashy | 2167 | if (!sq.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading schedule payment history")); // krazy:exclude=crashy | ||
2168 | while (sq.next()) s.recordPayment(sq.value(0).toDate()); | 2168 | while (sq.next()) s.recordPayment(sq.value(0).toDate()); | ||
2169 | 2169 | | |||
2170 | sList[s.id()] = s; | 2170 | sList[s.id()] = s; | ||
Context not available. | |||||
2196 | const MyMoneyDbTable& t = d->m_db.m_tables["kmmSecurities"]; | 2196 | const MyMoneyDbTable& t = d->m_db.m_tables["kmmSecurities"]; | ||
2197 | QSqlQuery query(*const_cast <MyMoneyStorageSql*>(this)); | 2197 | QSqlQuery query(*const_cast <MyMoneyStorageSql*>(this)); | ||
2198 | query.prepare(t.selectAllString(false) + " ORDER BY id;"); | 2198 | query.prepare(t.selectAllString(false) + " ORDER BY id;"); | ||
2199 | if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Securities"))); // krazy:exclude=crashy | 2199 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Securities")); // krazy:exclude=crashy | ||
2200 | int idCol = t.fieldNumber("id"); | 2200 | int idCol = t.fieldNumber("id"); | ||
2201 | int nameCol = t.fieldNumber("name"); | 2201 | int nameCol = t.fieldNumber("name"); | ||
2202 | int symbolCol = t.fieldNumber("symbol"); | 2202 | int symbolCol = t.fieldNumber("symbol"); | ||
Context not available. | |||||
2351 | } | 2351 | } | ||
2352 | } | 2352 | } | ||
2353 | 2353 | | |||
2354 | if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Prices"))); // krazy:exclude=crashy | 2354 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Prices")); // krazy:exclude=crashy | ||
2355 | static const int fromIdCol = t.fieldNumber("fromId"); | 2355 | static const int fromIdCol = t.fieldNumber("fromId"); | ||
2356 | static const int toIdCol = t.fieldNumber("toId"); | 2356 | static const int toIdCol = t.fieldNumber("toId"); | ||
2357 | static const int priceDateCol = t.fieldNumber("priceDate"); | 2357 | static const int priceDateCol = t.fieldNumber("priceDate"); | ||
Context not available. | |||||
2413 | } | 2413 | } | ||
2414 | } | 2414 | } | ||
2415 | 2415 | | |||
2416 | if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Currencies"))); // krazy:exclude=crashy | 2416 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Currencies")); // krazy:exclude=crashy | ||
2417 | int ISOcodeCol = t.fieldNumber("ISOcode"); | 2417 | int ISOcodeCol = t.fieldNumber("ISOcode"); | ||
2418 | int nameCol = t.fieldNumber("name"); | 2418 | int nameCol = t.fieldNumber("name"); | ||
2419 | int typeCol = t.fieldNumber("type"); | 2419 | int typeCol = t.fieldNumber("type"); | ||
Context not available. | |||||
2459 | const MyMoneyDbTable& t = d->m_db.m_tables["kmmReportConfig"]; | 2459 | const MyMoneyDbTable& t = d->m_db.m_tables["kmmReportConfig"]; | ||
2460 | QSqlQuery query(*const_cast <MyMoneyStorageSql*>(this)); | 2460 | QSqlQuery query(*const_cast <MyMoneyStorageSql*>(this)); | ||
2461 | query.prepare(t.selectAllString(true)); | 2461 | query.prepare(t.selectAllString(true)); | ||
2462 | if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading reports"))); // krazy:exclude=crashy | 2462 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading reports")); // krazy:exclude=crashy | ||
2463 | int xmlCol = t.fieldNumber("XML"); | 2463 | int xmlCol = t.fieldNumber("XML"); | ||
2464 | QMap<QString, MyMoneyReport> rList; | 2464 | QMap<QString, MyMoneyReport> rList; | ||
2465 | while (query.next()) { | 2465 | while (query.next()) { | ||
Context not available. | |||||
2501 | queryString += ';'; | 2501 | queryString += ';'; | ||
2502 | 2502 | | |||
2503 | query.prepare(queryString); | 2503 | query.prepare(queryString); | ||
2504 | if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading budgets"))); // krazy:exclude=crashy | 2504 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading budgets")); // krazy:exclude=crashy | ||
2505 | QMap<QString, MyMoneyBudget> budgets; | 2505 | QMap<QString, MyMoneyBudget> budgets; | ||
2506 | int xmlCol = t.fieldNumber("XML"); | 2506 | int xmlCol = t.fieldNumber("XML"); | ||
2507 | while (query.next()) { | 2507 | while (query.next()) { | ||
Context not available. | |||||
2816 | whereClause += ')'; | 2816 | whereClause += ')'; | ||
2817 | query.prepare(t.selectAllString(false) + whereClause); | 2817 | query.prepare(t.selectAllString(false) + whereClause); | ||
2818 | } | 2818 | } | ||
2819 | if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading CostCenter"))); // krazy:exclude=crashy | 2819 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading CostCenter")); // krazy:exclude=crashy | ||
2820 | const int idCol = t.fieldNumber("id"); | 2820 | const int idCol = t.fieldNumber("id"); | ||
2821 | const int nameCol = t.fieldNumber("name"); | 2821 | const int nameCol = t.fieldNumber("name"); | ||
2822 | 2822 | | |||
Context not available. |