Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/dialogs/investtransactioneditor.cpp
Show First 20 Lines • Show All 813 Lines • ▼ Show 20 Line(s) | |||||
814 | } | 814 | } | ||
815 | 815 | | |||
816 | bool InvestTransactionEditor::fixTransactionCommodity(const MyMoneyAccount& /* account */) | 816 | bool InvestTransactionEditor::fixTransactionCommodity(const MyMoneyAccount& /* account */) | ||
817 | { | 817 | { | ||
818 | return true; | 818 | return true; | ||
819 | } | 819 | } | ||
820 | 820 | | |||
821 | 821 | | |||
822 | void InvestTransactionEditor::totalAmount(MyMoneyMoney& amount) const | 822 | MyMoneyMoney InvestTransactionEditor::totalAmount() const | ||
823 | { | 823 | { | ||
824 | MyMoneyMoney amount; | ||||
825 | | ||||
824 | auto activityCombo = dynamic_cast<KMyMoneyActivityCombo*>(haveWidget("activity")); | 826 | auto activityCombo = dynamic_cast<KMyMoneyActivityCombo*>(haveWidget("activity")); | ||
825 | auto sharesEdit = dynamic_cast<KMyMoneyEdit*>(haveWidget("shares")); | 827 | auto sharesEdit = dynamic_cast<KMyMoneyEdit*>(haveWidget("shares")); | ||
826 | auto priceEdit = dynamic_cast<KMyMoneyEdit*>(haveWidget("price")); | 828 | auto priceEdit = dynamic_cast<KMyMoneyEdit*>(haveWidget("price")); | ||
827 | auto feesEdit = dynamic_cast<KMyMoneyEdit*>(haveWidget("fee-amount")); | 829 | auto feesEdit = dynamic_cast<KMyMoneyEdit*>(haveWidget("fee-amount")); | ||
828 | auto interestEdit = dynamic_cast<KMyMoneyEdit*>(haveWidget("interest-amount")); | 830 | auto interestEdit = dynamic_cast<KMyMoneyEdit*>(haveWidget("interest-amount")); | ||
829 | 831 | | |||
830 | if (!activityCombo || !sharesEdit || !priceEdit || | 832 | if (!activityCombo || !sharesEdit || !priceEdit || | ||
831 | !feesEdit || !interestEdit) | 833 | !feesEdit || !interestEdit) | ||
832 | return; | 834 | return amount; | ||
833 | 835 | | |||
834 | if (priceMode() == eDialogs::PriceMode::PricePerTransaction) | 836 | if (priceMode() == eDialogs::PriceMode::PricePerTransaction) | ||
835 | amount = priceEdit->value().abs(); | 837 | amount = priceEdit->value().abs(); | ||
836 | else | 838 | else | ||
837 | amount = sharesEdit->value().abs() * priceEdit->value().abs(); | 839 | amount = sharesEdit->value().abs() * priceEdit->value().abs(); | ||
838 | 840 | | |||
839 | if (feesEdit->isVisible()) { | 841 | if (feesEdit->isVisible()) { | ||
840 | MyMoneyMoney fee = feesEdit->value(); | 842 | MyMoneyMoney fee = feesEdit->value(); | ||
Show All 16 Lines | 858 | switch (activityCombo->activity()) { | |||
857 | case eMyMoney::Split::InvestmentTransactionType::BuyShares: | 859 | case eMyMoney::Split::InvestmentTransactionType::BuyShares: | ||
858 | factor = MyMoneyMoney::MINUS_ONE; | 860 | factor = MyMoneyMoney::MINUS_ONE; | ||
859 | break; | 861 | break; | ||
860 | default: | 862 | default: | ||
861 | break; | 863 | break; | ||
862 | } | 864 | } | ||
863 | amount += (interest * factor); | 865 | amount += (interest * factor); | ||
864 | } | 866 | } | ||
867 | return amount; | ||||
865 | } | 868 | } | ||
866 | 869 | | |||
867 | void InvestTransactionEditor::slotUpdateTotalAmount() | 870 | void InvestTransactionEditor::slotUpdateTotalAmount() | ||
868 | { | 871 | { | ||
869 | Q_D(InvestTransactionEditor); | 872 | Q_D(InvestTransactionEditor); | ||
870 | auto total = dynamic_cast<QLabel*>(haveWidget("total")); | 873 | auto total = dynamic_cast<QLabel*>(haveWidget("total")); | ||
871 | 874 | | |||
872 | if (total && total->isVisible()) { | 875 | if (total && total->isVisible()) { | ||
873 | MyMoneyMoney amount; | 876 | total->setText(totalAmount().convert(d->m_currency.smallestAccountFraction(), d->m_security.roundingMethod()) | ||
874 | totalAmount(amount); | | |||
875 | total->setText(amount.convert(d->m_currency.smallestAccountFraction(), d->m_security.roundingMethod()) | | |||
876 | .formatMoney(d->m_currency.tradingSymbol(), MyMoneyMoney::denomToPrec(d->m_currency.smallestAccountFraction()))); | 877 | .formatMoney(d->m_currency.tradingSymbol(), MyMoneyMoney::denomToPrec(d->m_currency.smallestAccountFraction()))); | ||
877 | } | 878 | } | ||
878 | } | 879 | } | ||
879 | 880 | | |||
880 | void InvestTransactionEditor::slotTransactionContainerGeometriesUpdated() | 881 | void InvestTransactionEditor::slotTransactionContainerGeometriesUpdated() | ||
881 | { | 882 | { | ||
882 | Q_D(InvestTransactionEditor); | 883 | Q_D(InvestTransactionEditor); | ||
883 | // when the geometries of the transaction container are updated some edit widgets that were | 884 | // when the geometries of the transaction container are updated some edit widgets that were | ||
▲ Show 20 Lines • Show All 312 Lines • Show Last 20 Lines |