[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [skrooge] /: KMyMoney exports does not need a check of integrity anymore
From: Stephane Mankowski <stephane () mankowski ! fr>
Date: 2013-08-31 16:43:07
Message-ID: E1VFoGR-0000Up-TE () scm ! kde ! org
[Download RAW message or body]
Git commit f359131a0091f10f4aac1a79cdc78941ff0fe461 by Stephane Mankowski.
Committed on 31/08/2013 at 16:42.
Pushed by smankowski into branch 'master'.
KMyMoney exports does not need a check of integrity anymore
M +1 -0 CHANGELOG
M +60 -37 plugins/import/skrooge_import_kmy/skgimportpluginkmy.cpp
M +3 -0 plugins/import/skrooge_import_kmy/skgimportpluginkmy.h
http://commits.kde.org/skrooge/f359131a0091f10f4aac1a79cdc78941ff0fe461
diff --git a/CHANGELOG b/CHANGELOG
index 81710b4..d3ba390 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,7 @@ skrooge (1.8.0)
*Correction bug 322306: Skrooge Crash using Forecast Schedule
*Correction bug 322069: Designer plugins should be unversioned .so files
*Correction bug 323380: Minor date bug when using the stock portfolio widgets
+ *Correction: KMyMoney exports does not need a check of integrity anymore
*Correction: Addition of all icons in size 256 and 512
*Correction: Block drop of a bookmark under an other bookmark
*Correction: Bad date format detection when the second value is 9 (example: \
3/9/04)
diff --git a/plugins/import/skrooge_import_kmy/skgimportpluginkmy.cpp \
b/plugins/import/skrooge_import_kmy/skgimportpluginkmy.cpp index 46d877f..a435b0c \
100644
--- a/plugins/import/skrooge_import_kmy/skgimportpluginkmy.cpp
+++ b/plugins/import/skrooge_import_kmy/skgimportpluginkmy.cpp
@@ -700,7 +700,7 @@ SKGError SKGImportPluginKmy::exportFile()
QDomElement institution = doc.createElement("INSTITUTION");
institutions.appendChild(institution);
- institution.setAttribute("id", obj.getUniqueID());
+ institution.setAttribute("id", getKmyUniqueIdentifier(obj));
institution.setAttribute("name", obj.getName());
institution.setAttribute("sortcode", obj.getNumber());
institution.setAttribute("manager", "");
@@ -723,7 +723,7 @@ SKGError SKGImportPluginKmy::exportFile()
QDomElement accountid = doc.createElement("ACCOUNTID");
accountids.appendChild(accountid);
- accountid.setAttribute("id", \
accounts.at(j).getUniqueID()); + \
accountid.setAttribute("id", getKmyUniqueIdentifier(accounts.at(j))); }
IFOKDO(err, m_importer->getDocument()->stepForward(i + 1))
}
@@ -748,7 +748,7 @@ SKGError SKGImportPluginKmy::exportFile()
payees.appendChild(payee);
payee.setAttribute("matchingenabled", "0");
- payee.setAttribute("id", payeeObject.getUniqueID());
+ payee.setAttribute("id", \
getKmyUniqueIdentifier(payeeObject));
payee.setAttribute("name", payeeObject.getName());
payee.setAttribute("email", "");
payee.setAttribute("reference", "");
@@ -896,14 +896,14 @@ SKGError SKGImportPluginKmy::exportFile()
QDomElement account = doc.createElement("ACCOUNT");
accounts.appendChild(account);
- account.setAttribute("id", obj.getUniqueID());
+ account.setAttribute("id", getKmyUniqueIdentifier(obj));
account.setAttribute("name", obj.getName());
account.setAttribute("number", obj.getNumber());
account.setAttribute("type", obj.getType() == \
SKGAccountObject::CREDITCARD ? "4" : (obj.getType() == SKGAccountObject::INVESTMENT ? \
"7" : (obj.getType() == SKGAccountObject::ASSETS ? "9" : (obj.getType() == \
SKGAccountObject::WALLET ? "3" : (obj.getType() == SKGAccountObject::LOAN ? "10" : \
"1")))));
SKGBankObject bank;
err = obj.getBank(bank);
- account.setAttribute("institution", bank.getUniqueID());
+ account.setAttribute("institution", \
getKmyUniqueIdentifier(bank));
account.setAttribute("parentaccount", "AStd::Asset");
account.setAttribute("lastmodified", "");
@@ -950,7 +950,7 @@ SKGError SKGImportPluginKmy::exportFile()
//Add it in asset
QDomElement subaccount = doc.createElement("SUBACCOUNT");
accountAsset.appendChild(subaccount);
- subaccount.setAttribute("id", obj.getUniqueID());
+ subaccount.setAttribute("id", getKmyUniqueIdentifier(obj));
IFOKDO(err, m_importer->getDocument()->stepForward(i + 1))
}
@@ -970,7 +970,7 @@ SKGError SKGImportPluginKmy::exportFile()
QDomElement account = doc.createElement("ACCOUNT");
accounts.appendChild(account);
- account.setAttribute("id", obj.getUniqueID());
+ account.setAttribute("id", getKmyUniqueIdentifier(obj));
account.setAttribute("name", obj.getName());
account.setAttribute("number", "");
account.setAttribute("type", obj.getCurrentAmount() < 0 ? \
"13" : "12"); @@ -980,15 +980,15 @@ SKGError SKGImportPluginKmy::exportFile()
SKGCategoryObject parentCat;
obj.getParentCategory(parentCat);
- QString parentId = (parentCat.getID() ? \
parentCat.getUniqueID() : (obj.getCurrentAmount() < 0 ? "AStd::Expense" : \
"AStd::Income")); + QString parentId = (parentCat.getID() ? \
getKmyUniqueIdentifier(parentCat) : (obj.getCurrentAmount() < 0 ? "AStd::Expense" : \
"AStd::Income")); if (parentId == "AStd::Expense") {
QDomElement subaccount = \
doc.createElement("SUBACCOUNT"); accountExpense.appendChild(subaccount);
- subaccount.setAttribute("id", obj.getUniqueID());
+ subaccount.setAttribute("id", \
getKmyUniqueIdentifier(obj)); } else if (parentId == "AStd::Income") {
QDomElement subaccount = \
doc.createElement("SUBACCOUNT"); accountIncome.appendChild(subaccount);
- subaccount.setAttribute("id", obj.getUniqueID());
+ subaccount.setAttribute("id", \
getKmyUniqueIdentifier(obj)); }
account.setAttribute("parentaccount", parentId);
@@ -1008,7 +1008,7 @@ SKGError SKGImportPluginKmy::exportFile()
QDomElement subaccount = \
doc.createElement("SUBACCOUNT"); subaccounts.appendChild(subaccount);
- subaccount.setAttribute("id", \
categories.at(j).getUniqueID()); + \
subaccount.setAttribute("id", getKmyUniqueIdentifier(categories.at(j))); }
IFOKDO(err, m_importer->getDocument()->stepForward(i + 1))
}
@@ -1021,7 +1021,7 @@ SKGError SKGImportPluginKmy::exportFile()
QDomElement transactions = doc.createElement("TRANSACTIONS");
root.appendChild(transactions);
- IFOKDO(err, m_importer->getDocument()->getObjects("v_operation", \
"t_template='N'", objects)) + IFOKDO(err, \
m_importer->getDocument()->getObjects("v_operation", "t_template='N' ORDER BY d_date \
DESC", objects)) nb = objects.count();
transactions.setAttribute("count", SKGServices::intToString(nb));
IFOK(err) {
@@ -1062,8 +1062,8 @@ SKGError SKGImportPluginKmy::exportFile()
QDomElement scheduled_tx = \
doc.createElement("SCHEDULED_TX"); schedules.appendChild(scheduled_tx);
- scheduled_tx.setAttribute("id", obj.getUniqueID());
- scheduled_tx.setAttribute("name", obj.getUniqueID());
+ scheduled_tx.setAttribute("id", \
getKmyUniqueIdentifier(obj)); + \
scheduled_tx.setAttribute("name", getKmyUniqueIdentifier(obj));
scheduled_tx.setAttribute("startDate", \
obj.getAttribute("d_date"));
scheduled_tx.setAttribute("lastPayment", \
obj.getAttribute("d_date")); bool autoEnter = false;
@@ -1129,7 +1129,7 @@ SKGError SKGImportPluginKmy::exportFile()
SKGBudgetObject obj(objects.at(i));
SKGCategoryObject cat;
obj.getCategory(cat);
- QString catId = cat.getUniqueID();
+ QString catId = getKmyUniqueIdentifier(cat);
int year = obj.getYear();
QString yearString = SKGServices::intToString(year);
int month = obj.getMonth();
@@ -1149,19 +1149,21 @@ SKGError SKGImportPluginKmy::exportFile()
}
QDomElement account = mapCatAccount[catId];
- if (account.isNull()) {
+ if (account.isNull() && !catId.isEmpty()) {
account = doc.createElement("ACCOUNT");
budget.appendChild(account);
account.setAttribute("budgetsubaccounts", "0");
account.setAttribute("id", catId);
mapCatAccount[catId] = account;
}
- account.setAttribute("budgetlevel", obj.getMonth() == 0 ? \
"yearly" : "monthbymonth"); + if (!account.isNull()) {
+ account.setAttribute("budgetlevel", obj.getMonth() == 0 \
? "yearly" : "monthbymonth");
- QDomElement period = doc.createElement("PERIOD");
- account.appendChild(period);
- period.setAttribute("amount", \
SKGImportPluginKmy::kmyValue(qAbs(obj.getBudgetedAmount())));
- period.setAttribute("start", yearString % '-' % \
(obj.getMonth() == 0 ? "01" : monthString) % "-01"); + \
QDomElement period = doc.createElement("PERIOD"); + \
account.appendChild(period); + \
period.setAttribute("amount", \
SKGImportPluginKmy::kmyValue(qAbs(obj.getBudgetedAmount()))); + \
period.setAttribute("start", yearString % '-' % (obj.getMonth() == 0 ? "01" : \
monthString) % "-01"); + }
IFOKDO(err, m_importer->getDocument()->stepForward(i + 1))
}
@@ -1310,7 +1312,7 @@ SKGError SKGImportPluginKmy::exportOperation(const \
SKGOperationObject& iOperatio {
SKGError err;
SKGTRACEINRC(2, "SKGImportPluginKmy::exportOperation", err);
- if (!m_opTreated.contains(iOperation.getUniqueID())) {
+ if (!m_opTreated.contains(getKmyUniqueIdentifier(iOperation))) {
QDomElement transaction = iDoc.createElement("TRANSACTION");
iTransaction.appendChild(transaction);
@@ -1318,7 +1320,7 @@ SKGError SKGImportPluginKmy::exportOperation(const \
SKGOperationObject& iOperatio iOperation.getUnit(unit);
QString date = iOperation.getAttribute("d_date");
- transaction.setAttribute("id", iOperation.getUniqueID());
+ transaction.setAttribute("id", getKmyUniqueIdentifier(iOperation));
transaction.setAttribute("entrydate", date);
transaction.setAttribute("postdate", date);
transaction.setAttribute("memo", iOperation.getComment());
@@ -1337,23 +1339,25 @@ SKGError SKGImportPluginKmy::exportOperation(const \
SKGOperationObject& iOperatio
SKGPayeeObject payeeObject;
iOperation.getPayee(payeeObject);
- QString payeeId = (payeeObject.getID() ? payeeObject.getUniqueID() : "");
+ QString payeeId = (payeeObject.getID() ? getKmyUniqueIdentifier(payeeObject) \
: ""); +
+ int indexSubOp = 1;
//Split for account
split.setAttribute("payee", payeeId);
split.setAttribute("reconciledate", "");
- split.setAttribute("id", iOperation.getUniqueID());
- QString shape2 = \
SKGImportPluginKmy::kmyValue(SKGServices::stringToDouble(iOperation.getAttribute("f_QUANTITY")));
- split.setAttribute("shares", shape2);
+ split.setAttribute("id", "S" % \
SKGServices::intToString(indexSubOp++).rightJustified(4, '0')); + double val2 \
= SKGServices::stringToDouble(iOperation.getAttribute("f_QUANTITY")); + \
split.setAttribute("shares", SKGImportPluginKmy::kmyValue(val2)); \
split.setAttribute("action", ""); split.setAttribute("bankid", "");
split.setAttribute("number", \
SKGServices::intToString(iOperation.getNumber())); \
split.setAttribute("reconcileflag", reconcileflag); split.setAttribute("memo", \
iOperation.getComment());
QString originalAmount = iOperation.getProperty("SKG_OP_ORIGINAL_AMOUNT");
- if (!originalAmount.isEmpty()) shape2 = \
SKGImportPluginKmy::kmyValue(SKGServices::stringToDouble(originalAmount));
- split.setAttribute("value", shape2);
- split.setAttribute("account", act.getUniqueID());
+ if (!originalAmount.isEmpty()) val2 = \
qAbs(SKGServices::stringToDouble(originalAmount)) * (val2 / qAbs(val2)); + \
split.setAttribute("value", SKGImportPluginKmy::kmyValue(val2)); + \
split.setAttribute("account", getKmyUniqueIdentifier(act));
SKGOperationObject obj2;
if (!err && iOperation.isTransfer(obj2)) {
@@ -1367,19 +1371,20 @@ SKGError SKGImportPluginKmy::exportOperation(const \
SKGOperationObject& iOperatio splits.appendChild(split2);
//Split for account
+ val2 = -val2;
split2.setAttribute("payee", payeeId);
split2.setAttribute("reconciledate", "");
- split2.setAttribute("id", obj2.getUniqueID());
+ split2.setAttribute("id", "S" % \
SKGServices::intToString(indexSubOp++).rightJustified(4, '0'));
split2.setAttribute("shares", \
SKGImportPluginKmy::kmyValue(SKGServices::stringToDouble(obj2.getAttribute("f_QUANTITY"))));
split2.setAttribute("action", "");
split2.setAttribute("bankid", "");
split2.setAttribute("number", \
SKGServices::intToString(obj2.getNumber())); split2.setAttribute("reconcileflag", \
reconcileflag2); split2.setAttribute("memo", obj2.getComment());
- split2.setAttribute("value", shape2);
- split2.setAttribute("account", act2.getUniqueID());
+ split2.setAttribute("value", SKGImportPluginKmy::kmyValue(val2));
+ split2.setAttribute("account", getKmyUniqueIdentifier(act2));
- m_opTreated.insert(obj2.getUniqueID());
+ m_opTreated.insert(getKmyUniqueIdentifier(obj2));
} else {
SKGObjectBase::SKGListSKGObjectBase subops;
IFOKDO(err, iOperation.getSubOperations(subops))
@@ -1393,7 +1398,7 @@ SKGError SKGImportPluginKmy::exportOperation(const \
SKGOperationObject& iOperatio subop.getCategory(cat);
split2.setAttribute("payee", payeeId);
split2.setAttribute("reconciledate", "");
- split2.setAttribute("id", subop.getUniqueID());
+ split2.setAttribute("id", "S" % \
SKGServices::intToString(indexSubOp++).rightJustified(4, '0'));
QString shape3 = SKGImportPluginKmy::kmyValue(-subop.getQuantity());
split2.setAttribute("shares", shape3);
split2.setAttribute("action", "");
@@ -1402,11 +1407,11 @@ SKGError SKGImportPluginKmy::exportOperation(const \
SKGOperationObject& iOperatio split2.setAttribute("reconcileflag", reconcileflag);
split2.setAttribute("memo", subop.getComment());
split2.setAttribute("value", shape3);
- split2.setAttribute("account", date == "0000-00-00" ? "AStd::Equity" \
: (cat.getID() ? cat.getUniqueID() : "")); + \
split2.setAttribute("account", date == "0000-00-00" ? "AStd::Equity" : (cat.getID() ? \
getKmyUniqueIdentifier(cat) : "")); }
}
- m_opTreated.insert(iOperation.getUniqueID());
+ m_opTreated.insert(getKmyUniqueIdentifier(iOperation));
}
return err;
}
@@ -1430,6 +1435,24 @@ double SKGImportPluginKmy::toKmyValue(const QString& iString)
return output;
}
+QString SKGImportPluginKmy::getKmyUniqueIdentifier(const SKGObjectBase& iObject)
+{
+ QString id;
+ if (iObject.getID() != 0) {
+ QString table = iObject.getRealTable();
+ if (table == "operation") {
+ //T000000000000003623
+ id = "T" % SKGServices::intToString(iObject.getID()).rightJustified(18, \
'0'); + } else if (table == "payee") {
+ //P000030
+ id = "P" % SKGServices::intToString(iObject.getID()).rightJustified(6, \
'0'); + } else {
+ id = iObject.getUniqueID();
+ }
+ }
+ return id;
+}
+
QString SKGImportPluginKmy::getMimeTypeFilter() const
{
return "*.kmy|" % i18nc("A file format", "KMyMoney document");
diff --git a/plugins/import/skrooge_import_kmy/skgimportpluginkmy.h \
b/plugins/import/skrooge_import_kmy/skgimportpluginkmy.h index bf42db0..cc0dd9b \
100644
--- a/plugins/import/skrooge_import_kmy/skgimportpluginkmy.h
+++ b/plugins/import/skrooge_import_kmy/skgimportpluginkmy.h
@@ -30,6 +30,7 @@ class SKGAccountObject;
class SKGCategoryObject;
class SKGOperationObject;
class SKGPayeeObject;
+class SKGObjectBase;
class QDomDocument;
class QDomElement;
@@ -93,6 +94,8 @@ private:
static QString kmyValue(double iValue);
static double toKmyValue(const QString& iString);
+ static QString getKmyUniqueIdentifier(const SKGObjectBase& iObject);
+
static QSet<QString> m_opTreated;
static QMap<QString, SKGUnitObject> m_mapIdUnit;
static QMap<QString, SKGAccountObject> m_mapIdAccount;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic