Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/mymoneytransaction.cpp
Context not available. | |||||
51 | { | 51 | { | ||
---|---|---|---|---|---|
52 | Q_D(MyMoneyTransaction); | 52 | Q_D(MyMoneyTransaction); | ||
53 | if (nodeNames[nnTransaction] != node.tagName()) | 53 | if (nodeNames[nnTransaction] != node.tagName()) | ||
54 | throw MYMONEYEXCEPTION("Node was not TRANSACTION"); | 54 | throw MYMONEYEXCEPTION_CSTRING("Node was not TRANSACTION"); | ||
55 | 55 | | |||
56 | d->m_nextSplitID = 1; | 56 | d->m_nextSplitID = 1; | ||
57 | 57 | | |||
Context not available. | |||||
241 | void MyMoneyTransaction::addSplit(MyMoneySplit &split) | 241 | void MyMoneyTransaction::addSplit(MyMoneySplit &split) | ||
242 | { | 242 | { | ||
243 | if (!split.id().isEmpty()) | 243 | if (!split.id().isEmpty()) | ||
244 | throw MYMONEYEXCEPTION("Cannot add split with assigned id (" + split.id() + ')'); | 244 | throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot add split with assigned id '%1'").arg(split.id())); | ||
245 | 245 | | |||
246 | if (split.accountId().isEmpty()) | 246 | if (split.accountId().isEmpty()) | ||
247 | throw MYMONEYEXCEPTION("Cannot add split that does not contain an account reference"); | 247 | throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot add split that does not contain an account reference")); | ||
248 | 248 | | |||
249 | Q_D(MyMoneyTransaction); | 249 | Q_D(MyMoneyTransaction); | ||
250 | MyMoneySplit newSplit(d->nextSplitID(), split); | 250 | MyMoneySplit newSplit(d->nextSplitID(), split); | ||
Context not available. | |||||
258 | // This is the other version which allows having more splits referencing | 258 | // This is the other version which allows having more splits referencing | ||
259 | // the same account. | 259 | // the same account. | ||
260 | if (split.accountId().isEmpty()) | 260 | if (split.accountId().isEmpty()) | ||
261 | throw MYMONEYEXCEPTION("Cannot modify split that does not contain an account reference"); | 261 | throw MYMONEYEXCEPTION_CSTRING("Cannot modify split that does not contain an account reference"); | ||
262 | 262 | | |||
263 | Q_D(MyMoneyTransaction); | 263 | Q_D(MyMoneyTransaction); | ||
264 | for (auto& it_split : d->m_splits) { | 264 | for (auto& it_split : d->m_splits) { | ||
Context not available. | |||||
267 | return; | 267 | return; | ||
268 | } | 268 | } | ||
269 | } | 269 | } | ||
270 | throw MYMONEYEXCEPTION(QString("Invalid split id '%1'").arg(split.id())); | 270 | throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid split id '%1'").arg(split.id())); | ||
271 | } | 271 | } | ||
272 | 272 | | |||
273 | void MyMoneyTransaction::removeSplit(const MyMoneySplit& split) | 273 | void MyMoneyTransaction::removeSplit(const MyMoneySplit& split) | ||
Context not available. | |||||
280 | } | 280 | } | ||
281 | } | 281 | } | ||
282 | 282 | | |||
283 | throw MYMONEYEXCEPTION(QString("Invalid split id '%1'").arg(split.id())); | 283 | throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid split id '%1'").arg(split.id())); | ||
284 | } | 284 | } | ||
285 | 285 | | |||
286 | void MyMoneyTransaction::removeSplits() | 286 | void MyMoneyTransaction::removeSplits() | ||
Context not available. | |||||
297 | if (split.payeeId() == payeeId) | 297 | if (split.payeeId() == payeeId) | ||
298 | return split; | 298 | return split; | ||
299 | } | 299 | } | ||
300 | throw MYMONEYEXCEPTION(QString("Split not found for payee '%1'").arg(QString(payeeId))); | 300 | throw MYMONEYEXCEPTION(QString::fromLatin1("Split not found for payee '%1'").arg(QString(payeeId))); | ||
301 | } | 301 | } | ||
302 | 302 | | |||
303 | MyMoneySplit MyMoneyTransaction::splitByAccount(const QString& accountId, const bool match) const | 303 | MyMoneySplit MyMoneyTransaction::splitByAccount(const QString& accountId, const bool match) const | ||
Context not available. | |||||
308 | (match == false && split.accountId() != accountId)) | 308 | (match == false && split.accountId() != accountId)) | ||
309 | return split; | 309 | return split; | ||
310 | } | 310 | } | ||
311 | throw MYMONEYEXCEPTION(QString("Split not found for account %1%2").arg(match ? "" : "!").arg(QString(accountId))); | 311 | throw MYMONEYEXCEPTION(QString::fromLatin1("Split not found for account %1%2").arg(match ? "" : "!").arg(QString(accountId))); | ||
312 | } | 312 | } | ||
313 | 313 | | |||
314 | MyMoneySplit MyMoneyTransaction::splitByAccount(const QStringList& accountIds, const bool match) const | 314 | MyMoneySplit MyMoneyTransaction::splitByAccount(const QStringList& accountIds, const bool match) const | ||
Context not available. | |||||
319 | (match == false && !accountIds.contains(split.accountId()))) | 319 | (match == false && !accountIds.contains(split.accountId()))) | ||
320 | return split; | 320 | return split; | ||
321 | } | 321 | } | ||
322 | throw MYMONEYEXCEPTION(QString("Split not found for account %1%1...%2").arg(match ? "" : "!").arg(accountIds.front(), accountIds.back())); | 322 | throw MYMONEYEXCEPTION(QString::fromLatin1("Split not found for account %1%1...%2").arg(match ? "" : "!").arg(accountIds.front(), accountIds.back())); | ||
323 | } | 323 | } | ||
324 | 324 | | |||
325 | MyMoneySplit MyMoneyTransaction::splitById(const QString& splitId) const | 325 | MyMoneySplit MyMoneyTransaction::splitById(const QString& splitId) const | ||
Context not available. | |||||
329 | if (split.id() == splitId) | 329 | if (split.id() == splitId) | ||
330 | return split; | 330 | return split; | ||
331 | } | 331 | } | ||
332 | throw MYMONEYEXCEPTION(QString("Split not found for id '%1'").arg(QString(splitId))); | 332 | throw MYMONEYEXCEPTION(QString::fromLatin1("Split not found for id '%1'").arg(QString(splitId))); | ||
333 | } | 333 | } | ||
334 | 334 | | |||
335 | QString MyMoneyTransaction::firstSplitID() | 335 | QString MyMoneyTransaction::firstSplitID() | ||
Context not available. | |||||
358 | if (split.isAmortizationSplit()) | 358 | if (split.isAmortizationSplit()) | ||
359 | return true; | 359 | return true; | ||
360 | } | 360 | } | ||
361 | } catch (const MyMoneyException &) { | 361 | } catch (const std::exception &) { | ||
362 | } | 362 | } | ||
363 | return false; | 363 | return false; | ||
364 | } | 364 | } | ||
Context not available. |