Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/dialogs/investactivities.cpp
Show First 20 Lines • Show All 449 Lines • ▼ Show 20 Line(s) | 437 | { | |||
---|---|---|---|---|---|
450 | setLabelText("shares-label", i18n("Shares")); | 450 | setLabelText("shares-label", i18n("Shares")); | ||
451 | if (dynamic_cast<QLabel*>(haveWidget("price-label"))) | 451 | if (dynamic_cast<QLabel*>(haveWidget("price-label"))) | ||
452 | setLabelText("price-label", priceLabel()); | 452 | setLabelText("price-label", priceLabel()); | ||
453 | setLabelText("total-label", i18nc("Total value", "Total")); | 453 | setLabelText("total-label", i18nc("Total value", "Total")); | ||
454 | } | 454 | } | ||
455 | 455 | | |||
456 | bool Sell::isComplete(QString& reason) const | 456 | bool Sell::isComplete(QString& reason) const | ||
457 | { | 457 | { | ||
458 | Q_D(const Activity); | ||||
459 | | ||||
458 | auto rc = Activity::isComplete(reason); | 460 | auto rc = Activity::isComplete(reason); | ||
459 | rc &= haveAssetAccount(); | | |||
460 | rc &= haveFees(true); | 461 | rc &= haveFees(true); | ||
461 | rc &= haveInterest(true); | 462 | rc &= haveInterest(true); | ||
462 | rc &= haveShares(); | 463 | rc &= haveShares(); | ||
463 | rc &= havePrice(); | 464 | rc &= havePrice(); | ||
465 | | ||||
466 | // Allow a sell operation to be saved without specifying a brokerage | ||||
467 | // account, when the proceeds equal the fees. This will handle sales | ||||
468 | // made solely to cover annual account fees, where there is no money | ||||
ostroffjh: Perhaps reword to say "Allow a sell operation to be saved without specifying a brokerage… | |||||
469 | // transferred. | ||||
470 | if (rc) { | ||||
471 | if (!d->m_parent->totalAmount().isZero()) { | ||||
472 | rc &= haveAssetAccount(); | ||||
473 | } | ||||
474 | } | ||||
464 | return rc; | 475 | return rc; | ||
465 | } | 476 | } | ||
466 | 477 | | |||
467 | bool Sell::createTransaction(MyMoneyTransaction& t, MyMoneySplit& s0, MyMoneySplit& assetAccountSplit, QList<MyMoneySplit>& feeSplits, QList<MyMoneySplit>& m_feeSplits, QList<MyMoneySplit>& interestSplits, QList<MyMoneySplit>& m_interestSplits, MyMoneySecurity& security, MyMoneySecurity& currency) | 478 | bool Sell::createTransaction(MyMoneyTransaction& t, MyMoneySplit& s0, MyMoneySplit& assetAccountSplit, QList<MyMoneySplit>& feeSplits, QList<MyMoneySplit>& m_feeSplits, QList<MyMoneySplit>& interestSplits, QList<MyMoneySplit>& m_interestSplits, MyMoneySecurity& security, MyMoneySecurity& currency) | ||
468 | { | 479 | { | ||
469 | Q_D(Activity); | 480 | Q_D(Activity); | ||
470 | Q_UNUSED(m_interestSplits); | 481 | Q_UNUSED(m_interestSplits); | ||
471 | Q_UNUSED(security); | 482 | Q_UNUSED(security); | ||
Show All 39 Lines | 520 | if (!feeAccountWidget || !feeAmountWidget || | |||
511 | return false; | 522 | return false; | ||
512 | 523 | | |||
513 | auto interestAccountWidget = dynamic_cast<KMyMoneyCategory*>(haveWidget("interest-account")); | 524 | auto interestAccountWidget = dynamic_cast<KMyMoneyCategory*>(haveWidget("interest-account")); | ||
514 | auto interestAmountWidget = dynamic_cast<KMyMoneyEdit*>(haveWidget("interest-amount")); | 525 | auto interestAmountWidget = dynamic_cast<KMyMoneyEdit*>(haveWidget("interest-amount")); | ||
515 | if (!interestAccountWidget || !interestAmountWidget || | 526 | if (!interestAccountWidget || !interestAmountWidget || | ||
516 | !createCategorySplits(t, interestAccountWidget, interestAmountWidget, MyMoneyMoney::MINUS_ONE, interestSplits, m_interestSplits)) | 527 | !createCategorySplits(t, interestAccountWidget, interestAmountWidget, MyMoneyMoney::MINUS_ONE, interestSplits, m_interestSplits)) | ||
517 | return false; | 528 | return false; | ||
518 | 529 | | |||
530 | const auto total = sumSplits(s0, feeSplits, interestSplits); | ||||
531 | if (!total.isZero()) { | ||||
519 | createAssetAccountSplit(assetAccountSplit, s0); | 532 | createAssetAccountSplit(assetAccountSplit, s0); | ||
520 | | ||||
521 | MyMoneyMoney total = sumSplits(s0, feeSplits, interestSplits); | | |||
522 | assetAccountSplit.setValue(-total); | 533 | assetAccountSplit.setValue(-total); | ||
523 | 534 | | |||
524 | if (!d->m_parent->setupPrice(t, assetAccountSplit)) | 535 | if (!d->m_parent->setupPrice(t, assetAccountSplit)) | ||
525 | return false; | 536 | return false; | ||
537 | } | ||||
526 | 538 | | |||
527 | return true; | 539 | return true; | ||
528 | } | 540 | } | ||
529 | 541 | | |||
530 | Div::Div(InvestTransactionEditor* editor) : | 542 | Div::Div(InvestTransactionEditor* editor) : | ||
531 | Activity(editor) | 543 | Activity(editor) | ||
532 | { | 544 | { | ||
533 | } | 545 | } | ||
▲ Show 20 Lines • Show All 447 Lines • Show Last 20 Lines |
Perhaps reword to say "Allow a sell operation to be saved without specifying a brokerage account, when the proceeds equal the fees . This will handle sales made solely to cover annual account fees, where there is no money transferred." (I tried entering with "//" but all but one of them got removed.)