Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/mymoneysplit.cpp
Context not available. | |||||
347 | { | 347 | { | ||
---|---|---|---|---|---|
348 | Q_D(const MyMoneySplit); | 348 | Q_D(const MyMoneySplit); | ||
349 | auto rc = false; | 349 | auto rc = false; | ||
350 | if (isMatched()) { | 350 | if (isMatched()) | ||
351 | rc = matchedTransaction().hasReferenceTo(id); | 351 | rc = matchedTransactionIDs().contains(id); | ||
352 | } | 352 | | ||
353 | for (int i = 0; i < d->m_tagList.size(); i++) | 353 | for (int i = 0; i < d->m_tagList.size(); i++) | ||
354 | if (id == d->m_tagList[i]) | 354 | if (id == d->m_tagList[i]) | ||
355 | return true; | 355 | return true; | ||
Context not available. | |||||
362 | return d->m_isMatched; | 362 | return d->m_isMatched; | ||
363 | } | 363 | } | ||
364 | 364 | | |||
365 | void MyMoneySplit::addMatch(const MyMoneyTransaction& _t) | 365 | void MyMoneySplit::addMatch() | ||
366 | { | 366 | { | ||
367 | Q_D(MyMoneySplit); | 367 | Q_D(MyMoneySplit); | ||
368 | // now we allow matching of two manual transactions | | |||
369 | d->m_matchedTransaction = _t; | | |||
370 | d->m_matchedTransaction.clearId(); | | |||
371 | d->m_isMatched = true; | 368 | d->m_isMatched = true; | ||
372 | } | 369 | } | ||
373 | 370 | | |||
374 | void MyMoneySplit::removeMatch() | 371 | void MyMoneySplit::removeMatch() | ||
375 | { | 372 | { | ||
376 | Q_D(MyMoneySplit); | 373 | Q_D(MyMoneySplit); | ||
377 | d->m_matchedTransaction = MyMoneyTransaction(); | | |||
378 | d->m_isMatched = false; | 374 | d->m_isMatched = false; | ||
379 | } | 375 | } | ||
380 | 376 | | |||
381 | MyMoneyTransaction MyMoneySplit::matchedTransaction() const | 377 | QString MyMoneySplit::matchedTransaction() const | ||
382 | { | 378 | { | ||
383 | Q_D(const MyMoneySplit); | 379 | Q_D(const MyMoneySplit); | ||
384 | if (d->m_isMatched) | 380 | if (d->m_isMatched) | ||
385 | return d->m_matchedTransaction; | 381 | return MyMoneyKeyValueContainer::value("kmm-match-transaction").split(';').last(); | ||
382 | | ||||
383 | return QString(); | ||||
384 | } | ||||
386 | 385 | | |||
387 | return MyMoneyTransaction(); | 386 | QStringList MyMoneySplit::matchedTransactionIDs() const | ||
387 | { | ||||
388 | Q_D(const MyMoneySplit); | ||||
389 | if (d->m_isMatched) | ||||
390 | return MyMoneyKeyValueContainer::value("kmm-match-transaction").split(';'); | ||||
391 | return QStringList(); | ||||
388 | } | 392 | } | ||
389 | 393 | | |||
390 | bool MyMoneySplit::replaceId(const QString& newId, const QString& oldId) | 394 | bool MyMoneySplit::replaceId(const QString& newId, const QString& oldId) | ||
Context not available. | |||||
404 | } | 408 | } | ||
405 | 409 | | |||
406 | if (isMatched()) { | 410 | if (isMatched()) { | ||
407 | MyMoneyTransaction t = matchedTransaction(); | 411 | auto oldList = MyMoneyKeyValueContainer::value("kmm-match-transaction").split(';'); | ||
408 | if (t.replaceId(newId, oldId)) { | 412 | auto newList = oldList; | ||
409 | removeMatch(); | 413 | for (auto &item : newList) | ||
410 | addMatch(t); | 414 | item = item.replace(oldId, newId); | ||
415 | if (newList != oldList) { | ||||
416 | MyMoneyKeyValueContainer::setValue("kmm-match-transaction", newList.join(';')); | ||||
411 | changed = true; | 417 | changed = true; | ||
412 | } | 418 | } | ||
413 | } | 419 | } | ||
Context not available. |