Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/plugins/sql/mymoneystoragesql_p.h
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | |||||
79 | #include "mymoneydbdef.h" | 79 | #include "mymoneydbdef.h" | ||
80 | #include "mymoneydbdriver.h" | 80 | #include "mymoneydbdriver.h" | ||
81 | #include "payeeidentifierdata.h" | 81 | #include "payeeidentifierdata.h" | ||
82 | #include "payeeidentifier.h" | 82 | #include "payeeidentifier.h" | ||
83 | #include "payeeidentifiertyped.h" | 83 | #include "payeeidentifiertyped.h" | ||
84 | #include "payeeidentifier/ibanbic/ibanbic.h" | 84 | #include "payeeidentifier/ibanbic/ibanbic.h" | ||
85 | #include "payeeidentifier/nationalaccount/nationalaccount.h" | 85 | #include "payeeidentifier/nationalaccount/nationalaccount.h" | ||
86 | #include "onlinetasks/sepa/sepaonlinetransferimpl.h" | 86 | #include "onlinetasks/sepa/sepaonlinetransferimpl.h" | ||
87 | #include "xmlstoragehelper.h" | ||||
87 | #include "mymoneyenums.h" | 88 | #include "mymoneyenums.h" | ||
88 | #include "mymoneystoragenames.h" | | |||
89 | 89 | | |||
90 | using namespace eMyMoney; | 90 | using namespace eMyMoney; | ||
91 | using namespace MyMoneyStandardAccounts; | | |||
92 | 91 | | |||
93 | class FilterFail | 92 | class FilterFail | ||
94 | { | 93 | { | ||
95 | public: | 94 | public: | ||
96 | explicit FilterFail(const MyMoneyTransactionFilter& filter) : m_filter(filter) {} | 95 | explicit FilterFail(const MyMoneyTransactionFilter& filter) : m_filter(filter) {} | ||
97 | 96 | | |||
98 | inline bool operator()(const QPair<QString, MyMoneyTransaction>& transactionPair) { | 97 | inline bool operator()(const QPair<QString, MyMoneyTransaction>& transactionPair) { | ||
99 | return (*this)(transactionPair.second); | 98 | return (*this)(transactionPair.second); | ||
▲ Show 20 Lines • Show All 333 Lines • ▼ Show 20 Line(s) | 425 | try { | |||
433 | writeAccountList(stdList, query); | 432 | writeAccountList(stdList, query); | ||
434 | m_accounts += stdList.size(); | 433 | m_accounts += stdList.size(); | ||
435 | } catch (const MyMoneyException &) { | 434 | } catch (const MyMoneyException &) { | ||
436 | // If the above failed, assume that the database is empty and create | 435 | // If the above failed, assume that the database is empty and create | ||
437 | // the standard accounts by hand before writing them. | 436 | // the standard accounts by hand before writing them. | ||
438 | MyMoneyAccount acc_l; | 437 | MyMoneyAccount acc_l; | ||
439 | acc_l.setAccountType(Account::Type::Liability); | 438 | acc_l.setAccountType(Account::Type::Liability); | ||
440 | acc_l.setName("Liability"); | 439 | acc_l.setName("Liability"); | ||
441 | MyMoneyAccount liability(stdAccNames[stdAccLiability], acc_l); | 440 | MyMoneyAccount liability(MyMoneyAccount::stdAccName(eMyMoney::Account::Standard::Liability), acc_l); | ||
442 | 441 | | |||
443 | MyMoneyAccount acc_a; | 442 | MyMoneyAccount acc_a; | ||
444 | acc_a.setAccountType(Account::Type::Asset); | 443 | acc_a.setAccountType(Account::Type::Asset); | ||
445 | acc_a.setName("Asset"); | 444 | acc_a.setName("Asset"); | ||
446 | MyMoneyAccount asset(stdAccNames[stdAccAsset], acc_a); | 445 | MyMoneyAccount asset(MyMoneyAccount::stdAccName(eMyMoney::Account::Standard::Asset), acc_a); | ||
447 | 446 | | |||
448 | MyMoneyAccount acc_e; | 447 | MyMoneyAccount acc_e; | ||
449 | acc_e.setAccountType(Account::Type::Expense); | 448 | acc_e.setAccountType(Account::Type::Expense); | ||
450 | acc_e.setName("Expense"); | 449 | acc_e.setName("Expense"); | ||
451 | MyMoneyAccount expense(stdAccNames[stdAccExpense], acc_e); | 450 | MyMoneyAccount expense(MyMoneyAccount::stdAccName(eMyMoney::Account::Standard::Expense), acc_e); | ||
452 | 451 | | |||
453 | MyMoneyAccount acc_i; | 452 | MyMoneyAccount acc_i; | ||
454 | acc_i.setAccountType(Account::Type::Income); | 453 | acc_i.setAccountType(Account::Type::Income); | ||
455 | acc_i.setName("Income"); | 454 | acc_i.setName("Income"); | ||
456 | MyMoneyAccount income(stdAccNames[stdAccIncome], acc_i); | 455 | MyMoneyAccount income(MyMoneyAccount::stdAccName(eMyMoney::Account::Standard::Income), acc_i); | ||
457 | 456 | | |||
458 | MyMoneyAccount acc_q; | 457 | MyMoneyAccount acc_q; | ||
459 | acc_q.setAccountType(Account::Type::Equity); | 458 | acc_q.setAccountType(Account::Type::Equity); | ||
460 | acc_q.setName("Equity"); | 459 | acc_q.setName("Equity"); | ||
461 | MyMoneyAccount equity(stdAccNames[stdAccEquity], acc_q); | 460 | MyMoneyAccount equity(MyMoneyAccount::stdAccName(eMyMoney::Account::Standard::Equity), acc_q); | ||
462 | 461 | | |||
463 | QList<MyMoneyAccount> stdList; | 462 | QList<MyMoneyAccount> stdList; | ||
464 | stdList << asset; | 463 | stdList << asset; | ||
465 | stdList << liability; | 464 | stdList << liability; | ||
466 | stdList << expense; | 465 | stdList << expense; | ||
467 | stdList << income; | 466 | stdList << income; | ||
468 | stdList << equity; | 467 | stdList << equity; | ||
469 | writeAccountList(stdList, query); | 468 | writeAccountList(stdList, query); | ||
▲ Show 20 Lines • Show All 979 Lines • ▼ Show 20 Line(s) | 1427 | { | |||
1449 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL("writing Currencies"); // krazy:exclude=crashy | 1448 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL("writing Currencies"); // krazy:exclude=crashy | ||
1450 | } | 1449 | } | ||
1451 | 1450 | | |||
1452 | void writeReport(const MyMoneyReport& rep, QSqlQuery& query) | 1451 | void writeReport(const MyMoneyReport& rep, QSqlQuery& query) | ||
1453 | { | 1452 | { | ||
1454 | QDomDocument d; // create a dummy XML document | 1453 | QDomDocument d; // create a dummy XML document | ||
1455 | QDomElement e = d.createElement("REPORTS"); | 1454 | QDomElement e = d.createElement("REPORTS"); | ||
1456 | d.appendChild(e); | 1455 | d.appendChild(e); | ||
1457 | rep.writeXML(d, e); // write the XML to document | 1456 | MyMoneyXmlContentHandler2::writeReport(rep, d, e); // write the XML to document | ||
1458 | query.bindValue(":id", rep.id()); | 1457 | query.bindValue(":id", rep.id()); | ||
1459 | query.bindValue(":name", rep.name()); | 1458 | query.bindValue(":name", rep.name()); | ||
1460 | query.bindValue(":XML", d.toString()); | 1459 | query.bindValue(":XML", d.toString()); | ||
1461 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL("writing Reports"); // krazy:exclude=crashy | 1460 | if (!query.exec()) throw MYMONEYEXCEPTIONSQL("writing Reports"); // krazy:exclude=crashy | ||
1462 | } | 1461 | } | ||
1463 | 1462 | | |||
1464 | void writeBudget(const MyMoneyBudget& bud, QSqlQuery& query) | 1463 | void writeBudget(const MyMoneyBudget& bud, QSqlQuery& query) | ||
1465 | { | 1464 | { | ||
1466 | QDomDocument d; // create a dummy XML document | 1465 | QDomDocument d; // create a dummy XML document | ||
1467 | QDomElement e = d.createElement("BUDGETS"); | 1466 | QDomElement e = d.createElement("BUDGETS"); | ||
1468 | d.appendChild(e); | 1467 | d.appendChild(e); | ||
1469 | bud.writeXML(d, e); // write the XML to document | 1468 | MyMoneyXmlContentHandler2::writeBudget(bud, d, e); // write the XML to document | ||
1470 | query.bindValue(":id", bud.id()); | 1469 | query.bindValue(":id", bud.id()); | ||
1471 | query.bindValue(":name", bud.name()); | 1470 | query.bindValue(":name", bud.name()); | ||
1472 | query.bindValue(":start", bud.budgetStart()); | 1471 | query.bindValue(":start", bud.budgetStart()); | ||
1473 | query.bindValue(":XML", d.toString()); | 1472 | query.bindValue(":XML", d.toString()); | ||
1474 | if (!query.exec()) // krazy:exclude=crashy | 1473 | if (!query.exec()) // krazy:exclude=crashy | ||
1475 | throw MYMONEYEXCEPTIONSQL("writing Budgets"); // krazy:exclude=crashy | 1474 | throw MYMONEYEXCEPTIONSQL("writing Budgets"); // krazy:exclude=crashy | ||
1476 | } | 1475 | } | ||
1477 | 1476 | | |||
▲ Show 20 Lines • Show All 1648 Lines • Show Last 20 Lines |