Commit a098e28e authored by Thomas Baumgart's avatar Thomas Baumgart
Browse files

Added option to invert amounts during OFX import

FEATURE: 416279
FIXED-IN: 5.0.9
(cherry picked from commit 74a6554d)
parent 7e998bab
......@@ -107,6 +107,8 @@ KOnlineBankingStatus::KOnlineBankingStatus(const MyMoneyAccount& acc, QWidget *p
m_timestampOffsetSign->setCurrentIndex(offset < 0 ? 1 : 0);
m_timestampOffset->setTime(QTime::fromMSecsSinceStartOfDay(qAbs(offset)*60*1000));
m_invertAmount->setChecked(settings.value("kmmofx-invertamount").toLower() == QStringLiteral("yes"));
QString key = OFX_PASSWORD_KEY(settings.value("url"), settings.value("uniqueId"));
QString pwd;
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>638</width>
<height>368</height>
<height>392</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
......@@ -383,7 +383,7 @@
<property name="title">
<string>Import options</string>
</property>
<layout class="QGridLayout" name="gridLayout_3" rowstretch="2,0,0">
<layout class="QGridLayout" name="gridLayout_3" rowstretch="2,0,0,0">
<item row="0" column="1">
<widget class="QComboBox" name="m_preferredPayee">
<item>
......@@ -468,6 +468,23 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Invert sign of transaction amount</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="m_invertAmount">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Check this if you need to invert the sign of imported transaction amounts, e.g. if you need to reverse charges and payments because your institution provides them inverted.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......@@ -492,16 +509,16 @@
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>KLed</class>
<extends>QWidget</extends>
<header>kled.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
<customwidget>
<class>KLed</class>
<extends>QWidget</extends>
<header>kled.h</header>
</customwidget>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>598</width>
<height>170</height>
<height>184</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
......@@ -113,6 +113,23 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Invert sign of transaction amount</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="m_invertAmount">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Check this if you need to invert the sign of imported transaction amounts, e.g. if you need to reverse charges and payments because your institution provides them inverted.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -74,7 +74,7 @@ typedef enum {
class OFXImporter::Private
{
public:
Private() : m_valid(false), m_preferName(PreferId), m_uniqueIdSource(UniqueIdUnknown), m_walletIsOpen(false), m_statusDlg(0), m_wallet(0),
Private() : m_valid(false), m_preferName(PreferId), m_uniqueIdSource(UniqueIdUnknown), m_walletIsOpen(false), m_invertAmount(false), m_statusDlg(0), m_wallet(0),
m_updateStartDate(QDate(1900,1,1)), m_timestampOffset(0) {}
bool m_valid;
......@@ -85,6 +85,7 @@ public:
} m_preferName;
UniqueTransactionIdSource m_uniqueIdSource;
bool m_walletIsOpen;
bool m_invertAmount;
QList<MyMoneyStatement> m_statementlist;
QList<MyMoneyStatement::Security> m_securitylist;
QString m_fatalerror;
......@@ -183,6 +184,7 @@ void OFXImporter::slotImportFile()
d->m_preferName = static_cast<OFXImporter::Private::NamePreference>(option->m_preferName->currentIndex());
d->m_uniqueIdSource = static_cast<UniqueTransactionIdSource>(option->m_uniqueIdSource->currentIndex());
d->m_timestampOffset = d->constructTimeOffset(option->m_timestampOffset, option->m_timestampOffsetSign);
d->m_invertAmount = option->m_invertAmount->isChecked();
if (url.isValid()) {
const QString filename(url.toLocalFile());
......@@ -338,6 +340,9 @@ int OFXImporter::ofxTransactionCallback(struct OfxTransactionData data, void * p
if (data.amount_valid) {
t.m_amount = MyMoneyMoney(data.amount, 1000);
if (pofx->d->m_invertAmount) {
t.m_amount = -t.m_amount;
}
}
if (data.check_number_valid) {
......@@ -826,6 +831,11 @@ MyMoneyKeyValueContainer OFXImporter::onlineBankingSettings(const MyMoneyKeyValu
} else {
kvp.setValue(QStringLiteral("kmmofx-timestampOffset"), QString::number(offset));
}
if (d->m_statusDlg->m_invertAmount->isChecked()) {
kvp.setValue(QStringLiteral("kmmofx-invertamount"), QStringLiteral("yes"));
} else {
kvp.deletePair(QStringLiteral("kmmofx-invertamount"));
}
// get rid of pre 4.6 values
kvp.deletePair(QStringLiteral("kmmofx-preferPayeeid"));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment