Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/storage/mymoneystoragesql.cpp
Context not available. | |||||
63 | #include "mymoneytransaction.h" | 63 | #include "mymoneytransaction.h" | ||
---|---|---|---|---|---|
64 | #include "mymoneyutils.h" | 64 | #include "mymoneyutils.h" | ||
65 | #include "payeeidentifier/payeeidentifierdata.h" | 65 | #include "payeeidentifier/payeeidentifierdata.h" | ||
66 | #include "mymoneyenums.h" | ||||
66 | 67 | | |||
67 | using namespace eMyMoney; | 68 | using namespace eMyMoney; | ||
68 | 69 | | |||
Context not available. | |||||
1483 | // If the above failed, assume that the database is empty and create | 1484 | // If the above failed, assume that the database is empty and create | ||
1484 | // the standard accounts by hand before writing them. | 1485 | // the standard accounts by hand before writing them. | ||
1485 | MyMoneyAccount acc_l; | 1486 | MyMoneyAccount acc_l; | ||
1486 | acc_l.setAccountType(MyMoneyAccount::Liability); | 1487 | acc_l.setAccountType(eMyMoney::Account::Liability); | ||
1487 | acc_l.setName("Liability"); | 1488 | acc_l.setName("Liability"); | ||
1488 | MyMoneyAccount liability(STD_ACC_LIABILITY, acc_l); | 1489 | MyMoneyAccount liability(STD_ACC_LIABILITY, acc_l); | ||
1489 | 1490 | | |||
1490 | MyMoneyAccount acc_a; | 1491 | MyMoneyAccount acc_a; | ||
1491 | acc_a.setAccountType(MyMoneyAccount::Asset); | 1492 | acc_a.setAccountType(eMyMoney::Account::Asset); | ||
1492 | acc_a.setName("Asset"); | 1493 | acc_a.setName("Asset"); | ||
1493 | MyMoneyAccount asset(STD_ACC_ASSET, acc_a); | 1494 | MyMoneyAccount asset(STD_ACC_ASSET, acc_a); | ||
1494 | 1495 | | |||
1495 | MyMoneyAccount acc_e; | 1496 | MyMoneyAccount acc_e; | ||
1496 | acc_e.setAccountType(MyMoneyAccount::Expense); | 1497 | acc_e.setAccountType(eMyMoney::Account::Expense); | ||
1497 | acc_e.setName("Expense"); | 1498 | acc_e.setName("Expense"); | ||
1498 | MyMoneyAccount expense(STD_ACC_EXPENSE, acc_e); | 1499 | MyMoneyAccount expense(STD_ACC_EXPENSE, acc_e); | ||
1499 | 1500 | | |||
1500 | MyMoneyAccount acc_i; | 1501 | MyMoneyAccount acc_i; | ||
1501 | acc_i.setAccountType(MyMoneyAccount::Income); | 1502 | acc_i.setAccountType(eMyMoney::Account::Income); | ||
1502 | acc_i.setName("Income"); | 1503 | acc_i.setName("Income"); | ||
1503 | MyMoneyAccount income(STD_ACC_INCOME, acc_i); | 1504 | MyMoneyAccount income(STD_ACC_INCOME, acc_i); | ||
1504 | 1505 | | |||
1505 | MyMoneyAccount acc_q; | 1506 | MyMoneyAccount acc_q; | ||
1506 | acc_q.setAccountType(MyMoneyAccount::Equity); | 1507 | acc_q.setAccountType(eMyMoney::Account::Equity); | ||
1507 | acc_q.setName("Equity"); | 1508 | acc_q.setName("Equity"); | ||
1508 | MyMoneyAccount equity(STD_ACC_EQUITY, acc_q); | 1509 | MyMoneyAccount equity(STD_ACC_EQUITY, acc_q); | ||
1509 | 1510 | | |||
Context not available. | |||||
1643 | else | 1644 | else | ||
1644 | openingDateList << a.openingDate().toString(Qt::ISODate); | 1645 | openingDateList << a.openingDate().toString(Qt::ISODate); | ||
1645 | accountNumberList << a.number(); | 1646 | accountNumberList << a.number(); | ||
1646 | accountTypeList << a.accountType(); | 1647 | accountTypeList << (int)a.accountType(); | ||
1647 | accountTypeStringList << MyMoneyAccount::accountTypeToString(a.accountType()); | 1648 | accountTypeStringList << MyMoneyAccount::accountTypeToString(a.accountType()); | ||
1648 | if (a.accountType() == MyMoneyAccount::Stock) | 1649 | if (a.accountType() == eMyMoney::Account::Stock) | ||
1649 | isStockAccountList << "Y"; | 1650 | isStockAccountList << "Y"; | ||
1650 | else | 1651 | else | ||
1651 | isStockAccountList << "N"; | 1652 | isStockAccountList << "N"; | ||
Context not available. | |||||
2134 | { | 2135 | { | ||
2135 | q.bindValue(":id", sch.id()); | 2136 | q.bindValue(":id", sch.id()); | ||
2136 | q.bindValue(":name", sch.name()); | 2137 | q.bindValue(":name", sch.name()); | ||
2137 | q.bindValue(":type", sch.type()); | 2138 | q.bindValue(":type", (int)sch.type()); | ||
2138 | q.bindValue(":typeString", MyMoneySchedule::scheduleTypeToString(sch.type())); | 2139 | q.bindValue(":typeString", MyMoneySchedule::scheduleTypeToString(sch.type())); | ||
2139 | q.bindValue(":occurence", sch.occurrencePeriod()); // krazy:exclude=spelling | 2140 | q.bindValue(":occurence", (int)sch.occurrencePeriod()); // krazy:exclude=spelling | ||
2140 | q.bindValue(":occurenceMultiplier", sch.occurrenceMultiplier()); | 2141 | q.bindValue(":occurenceMultiplier", sch.occurrenceMultiplier()); | ||
2141 | q.bindValue(":occurenceString", sch.occurrenceToString()); | 2142 | q.bindValue(":occurenceString", sch.occurrenceToString()); | ||
2142 | q.bindValue(":paymentType", sch.paymentType()); | 2143 | q.bindValue(":paymentType", (int)sch.paymentType()); | ||
2143 | q.bindValue(":paymentTypeString", MyMoneySchedule::paymentMethodToString(sch.paymentType())); | 2144 | q.bindValue(":paymentTypeString", MyMoneySchedule::paymentMethodToString(sch.paymentType())); | ||
2144 | q.bindValue(":startDate", sch.startDate().toString(Qt::ISODate)); | 2145 | q.bindValue(":startDate", sch.startDate().toString(Qt::ISODate)); | ||
2145 | q.bindValue(":endDate", sch.endDate().toString(Qt::ISODate)); | 2146 | q.bindValue(":endDate", sch.endDate().toString(Qt::ISODate)); | ||
Context not available. | |||||
2155 | } | 2156 | } | ||
2156 | q.bindValue(":lastPayment", sch.lastPayment()); | 2157 | q.bindValue(":lastPayment", sch.lastPayment()); | ||
2157 | q.bindValue(":nextPaymentDue", sch.nextDueDate().toString(Qt::ISODate)); | 2158 | q.bindValue(":nextPaymentDue", sch.nextDueDate().toString(Qt::ISODate)); | ||
2158 | q.bindValue(":weekendOption", sch.weekendOption()); | 2159 | q.bindValue(":weekendOption", (int)sch.weekendOption()); | ||
2159 | q.bindValue(":weekendOptionString", MyMoneySchedule::weekendOptionToString(sch.weekendOption())); | 2160 | q.bindValue(":weekendOptionString", MyMoneySchedule::weekendOptionToString(sch.weekendOption())); | ||
2160 | if (!q.exec()) throw MYMONEYEXCEPTION(buildError(q, Q_FUNC_INFO, QString("writing Schedules"))); // krazy:exclude=crashy | 2161 | if (!q.exec()) throw MYMONEYEXCEPTION(buildError(q, Q_FUNC_INFO, QString("writing Schedules"))); // krazy:exclude=crashy | ||
2161 | 2162 | | |||
Context not available. | |||||
3604 | acc.setLastModified(GETDATE(lastModifiedCol)); | 3605 | acc.setLastModified(GETDATE(lastModifiedCol)); | ||
3605 | acc.setOpeningDate(GETDATE(openingDateCol)); | 3606 | acc.setOpeningDate(GETDATE(openingDateCol)); | ||
3606 | acc.setNumber(GETSTRING(accountNumberCol)); | 3607 | acc.setNumber(GETSTRING(accountNumberCol)); | ||
3607 | acc.setAccountType(static_cast<MyMoneyAccount::accountTypeE>(GETINT(accountTypeCol))); | 3608 | acc.setAccountType(static_cast<eMyMoney::Account>(GETINT(accountTypeCol))); | ||
3608 | acc.setName(GETSTRING(accountNameCol)); | 3609 | acc.setName(GETSTRING(accountNameCol)); | ||
3609 | acc.setDescription(GETSTRING(descriptionCol)); | 3610 | acc.setDescription(GETSTRING(descriptionCol)); | ||
3610 | acc.setCurrencyId(GETSTRING(currencyIdCol)); | 3611 | acc.setCurrencyId(GETSTRING(currencyIdCol)); | ||
Context not available. | |||||
3848 | return txMap; | 3849 | return txMap; | ||
3849 | } | 3850 | } | ||
3850 | 3851 | | |||
3851 | int MyMoneyStorageSql::splitState(const MyMoneyTransactionFilter::stateOptionE& state) const | 3852 | int MyMoneyStorageSql::splitState(const eMyMoney::TransactionFilter::State& state) const | ||
3852 | { | 3853 | { | ||
3853 | int rc = MyMoneySplit::NotReconciled; | 3854 | int rc = MyMoneySplit::NotReconciled; | ||
3854 | 3855 | | |||
3855 | switch (state) { | 3856 | switch (state) { | ||
3856 | default: | 3857 | default: | ||
3857 | case MyMoneyTransactionFilter::notReconciled: | 3858 | case eMyMoney::TransactionFilter::State::NotReconciled: | ||
3858 | break; | 3859 | break; | ||
3859 | 3860 | | |||
3860 | case MyMoneyTransactionFilter::cleared: | 3861 | case eMyMoney::TransactionFilter::State::Cleared: | ||
3861 | rc = MyMoneySplit::Cleared; | 3862 | rc = MyMoneySplit::Cleared; | ||
3862 | break; | 3863 | break; | ||
3863 | 3864 | | |||
3864 | case MyMoneyTransactionFilter::reconciled: | 3865 | case eMyMoney::TransactionFilter::State::Reconciled: | ||
3865 | rc = MyMoneySplit::Reconciled; | 3866 | rc = MyMoneySplit::Reconciled; | ||
3866 | break; | 3867 | break; | ||
3867 | 3868 | | |||
3868 | case MyMoneyTransactionFilter::frozen: | 3869 | case eMyMoney::TransactionFilter::State::Frozen: | ||
3869 | rc = MyMoneySplit::Frozen; | 3870 | rc = MyMoneySplit::Frozen; | ||
3870 | break; | 3871 | break; | ||
3871 | } | 3872 | } | ||
Context not available. | |||||
4002 | QString statesClause = ""; | 4003 | QString statesClause = ""; | ||
4003 | foreach (int it, splitStates) { | 4004 | foreach (int it, splitStates) { | ||
4004 | statesClause.append(QString(" %1 '%2'").arg(itemConnector) | 4005 | statesClause.append(QString(" %1 '%2'").arg(itemConnector) | ||
4005 | .arg(splitState(MyMoneyTransactionFilter::stateOptionE(it)))); | 4006 | .arg(splitState(eMyMoney::TransactionFilter::State(it)))); | ||
4006 | itemConnector = ','; | 4007 | itemConnector = ','; | ||
4007 | } | 4008 | } | ||
4008 | if (!statesClause.isEmpty()) { | 4009 | if (!statesClause.isEmpty()) { | ||
Context not available. | |||||
4205 | 4206 | | |||
4206 | QString sId = GETSTRING(idCol); | 4207 | QString sId = GETSTRING(idCol); | ||
4207 | s.setName(GETSTRING(nameCol)); | 4208 | s.setName(GETSTRING(nameCol)); | ||
4208 | s.setType(static_cast<MyMoneySchedule::typeE>(GETINT(typeCol))); | 4209 | s.setType(static_cast<eMyMoney::Schedule::Type>(GETINT(typeCol))); | ||
4209 | s.setOccurrencePeriod(static_cast<MyMoneySchedule::occurrenceE>(GETINT(occurenceCol))); | 4210 | s.setOccurrencePeriod(static_cast<eMyMoney::Schedule::Occurrence>(GETINT(occurenceCol))); | ||
4210 | s.setOccurrenceMultiplier(GETINT(occurenceMultiplierCol)); | 4211 | s.setOccurrenceMultiplier(GETINT(occurenceMultiplierCol)); | ||
4211 | s.setPaymentType(static_cast<MyMoneySchedule::paymentTypeE>(GETINT(paymentTypeCol))); | 4212 | s.setPaymentType(static_cast<eMyMoney::Schedule::PaymentType>(GETINT(paymentTypeCol))); | ||
4212 | s.setStartDate(GETDATE(startDateCol)); | 4213 | s.setStartDate(GETDATE(startDateCol)); | ||
4213 | s.setEndDate(GETDATE(endDateCol)); | 4214 | s.setEndDate(GETDATE(endDateCol)); | ||
4214 | boolChar = GETSTRING(fixedCol); s.setFixed(boolChar == "Y"); | 4215 | boolChar = GETSTRING(fixedCol); s.setFixed(boolChar == "Y"); | ||
4215 | boolChar = GETSTRING(autoEnterCol); s.setAutoEnter(boolChar == "Y"); | 4216 | boolChar = GETSTRING(autoEnterCol); s.setAutoEnter(boolChar == "Y"); | ||
4216 | s.setLastPayment(GETDATE(lastPaymentCol)); | 4217 | s.setLastPayment(GETDATE(lastPaymentCol)); | ||
4217 | s.setWeekendOption(static_cast<MyMoneySchedule::weekendOptionE>(GETINT(weekendOptionCol))); | 4218 | s.setWeekendOption(static_cast<eMyMoney::Schedule::WeekendOption>(GETINT(weekendOptionCol))); | ||
4218 | QDate nextPaymentDue = GETDATE(nextPaymentDueCol); | 4219 | QDate nextPaymentDue = GETDATE(nextPaymentDueCol); | ||
4219 | 4220 | | |||
4220 | // convert simple occurrence to compound occurrence | 4221 | // convert simple occurrence to compound occurrence | ||
4221 | int mult = s.occurrenceMultiplier(); | 4222 | int mult = s.occurrenceMultiplier(); | ||
4222 | MyMoneySchedule::occurrenceE occ = s.occurrencePeriod(); | 4223 | eMyMoney::Schedule::Occurrence occ = s.occurrencePeriod(); | ||
4223 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 4224 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
4224 | s.setOccurrencePeriod(occ); | 4225 | s.setOccurrencePeriod(occ); | ||
4225 | s.setOccurrenceMultiplier(mult); | 4226 | s.setOccurrenceMultiplier(mult); | ||
Context not available. |