diff --git a/kmymoney/mymoney/mymoneyobject.h b/kmymoney/mymoney/mymoneyobject.h --- a/kmymoney/mymoney/mymoneyobject.h +++ b/kmymoney/mymoney/mymoneyobject.h @@ -84,7 +84,7 @@ * @param document reference to QDomDocument * @param parent reference to QDomElement parent node */ - virtual void writeXML(QDomDocument& document, QDomElement& parent) const = 0; + virtual void writeXML(QDomDocument &document, QDomElement &parent) const; bool operator == (const MyMoneyObject& right) const; diff --git a/kmymoney/mymoney/mymoneyobject.cpp b/kmymoney/mymoney/mymoneyobject.cpp --- a/kmymoney/mymoney/mymoneyobject.cpp +++ b/kmymoney/mymoney/mymoneyobject.cpp @@ -74,3 +74,8 @@ Q_D(MyMoneyObject); d->m_id.clear(); } + +void MyMoneyObject::writeXML(QDomDocument &, QDomElement &) const +{ + +} diff --git a/kmymoney/mymoney/mymoneyschedule.h b/kmymoney/mymoney/mymoneyschedule.h --- a/kmymoney/mymoney/mymoneyschedule.h +++ b/kmymoney/mymoney/mymoneyschedule.h @@ -508,8 +508,6 @@ void recordPayment(const QDate&); QList recordedPayments() const; - void writeXML(QDomDocument& document, QDomElement& parent) const final override; - /** * This method checks if a reference to the given object exists. It returns, * a @p true if the object is referencing the one requested by the diff --git a/kmymoney/mymoney/mymoneyschedule.cpp b/kmymoney/mymoney/mymoneyschedule.cpp --- a/kmymoney/mymoney/mymoneyschedule.cpp +++ b/kmymoney/mymoney/mymoneyschedule.cpp @@ -24,8 +24,6 @@ // QT Includes #include -#include -#include #include // ---------------------------------------------------------------------------- @@ -869,43 +867,6 @@ } } -void MyMoneySchedule::writeXML(QDomDocument& document, QDomElement& parent) const -{ - auto el = document.createElement(nodeNames[nnScheduleTX]); - - Q_D(const MyMoneySchedule); - d->writeBaseXML(document, el); - - el.setAttribute(d->getAttrName(Schedule::Attribute::Name), d->m_name); - el.setAttribute(d->getAttrName(Schedule::Attribute::Type), (int)d->m_type); - el.setAttribute(d->getAttrName(Schedule::Attribute::Occurrence), (int)d->m_occurrence); - el.setAttribute(d->getAttrName(Schedule::Attribute::OccurrenceMultiplier), d->m_occurrenceMultiplier); - el.setAttribute(d->getAttrName(Schedule::Attribute::PaymentType), (int)d->m_paymentType); - el.setAttribute(d->getAttrName(Schedule::Attribute::StartDate), MyMoneyUtils::dateToString(d->m_startDate)); - el.setAttribute(d->getAttrName(Schedule::Attribute::EndDate), MyMoneyUtils::dateToString(d->m_endDate)); - el.setAttribute(d->getAttrName(Schedule::Attribute::Fixed), d->m_fixed); - el.setAttribute(d->getAttrName(Schedule::Attribute::LastDayInMonth), d->m_lastDayInMonth); - el.setAttribute(d->getAttrName(Schedule::Attribute::AutoEnter), d->m_autoEnter); - el.setAttribute(d->getAttrName(Schedule::Attribute::LastPayment), MyMoneyUtils::dateToString(d->m_lastPayment)); - el.setAttribute(d->getAttrName(Schedule::Attribute::WeekendOption), (int)d->m_weekendOption); - - //store the payment history for this scheduled task. - QList payments = recordedPayments(); - QList::ConstIterator it; - QDomElement paymentsElement = document.createElement(d->getElName(Schedule::Element::Payments)); - for (it = payments.constBegin(); it != payments.constEnd(); ++it) { - QDomElement paymentEntry = document.createElement(d->getElName(Schedule::Element::Payment)); - paymentEntry.setAttribute(d->getAttrName(Schedule::Attribute::Date), MyMoneyUtils::dateToString(*it)); - paymentsElement.appendChild(paymentEntry); - } - el.appendChild(paymentsElement); - - //store the transaction data for this task. - d->m_transaction.writeXML(document, el); - - parent.appendChild(el); -} - bool MyMoneySchedule::hasReferenceTo(const QString& id) const { Q_D(const MyMoneySchedule); diff --git a/kmymoney/mymoney/mymoneysplit.h b/kmymoney/mymoney/mymoneysplit.h --- a/kmymoney/mymoney/mymoneysplit.h +++ b/kmymoney/mymoney/mymoneysplit.h @@ -86,8 +86,6 @@ */ MyMoneySplit operator-() const; - void writeXML(QDomDocument& document, QDomElement& parent) const override; - /** * This method checks if a reference to the given object exists. It returns, * a @p true if the object is referencing the one requested by the diff --git a/kmymoney/mymoney/mymoneysplit.cpp b/kmymoney/mymoney/mymoneysplit.cpp --- a/kmymoney/mymoney/mymoneysplit.cpp +++ b/kmymoney/mymoney/mymoneysplit.cpp @@ -24,9 +24,6 @@ // ---------------------------------------------------------------------------- // QT Includes -#include -#include - // ---------------------------------------------------------------------------- // KDE Includes @@ -375,42 +372,6 @@ return MyMoneyMoney::ONE; } -void MyMoneySplit::writeXML(QDomDocument& document, QDomElement& parent) const -{ - Q_D(const MyMoneySplit); - auto el = document.createElement(d->getElName(Split::Element::Split)); - - d->writeBaseXML(document, el); - - el.setAttribute(d->getAttrName(Split::Attribute::Payee), d->m_payee); - //el.setAttribute(getAttrName(Split::Attribute::Tag), m_tag); - el.setAttribute(d->getAttrName(Split::Attribute::ReconcileDate), MyMoneyUtils::dateToString(d->m_reconcileDate)); - el.setAttribute(d->getAttrName(Split::Attribute::Action), d->m_action); - el.setAttribute(d->getAttrName(Split::Attribute::ReconcileFlag), (int)d->m_reconcileFlag); - el.setAttribute(d->getAttrName(Split::Attribute::Value), d->m_value.toString()); - el.setAttribute(d->getAttrName(Split::Attribute::Shares), d->m_shares.toString()); - if (!d->m_price.isZero()) - el.setAttribute(d->getAttrName(Split::Attribute::Price), d->m_price.toString()); - el.setAttribute(d->getAttrName(Split::Attribute::Memo), d->m_memo); - // No need to write the split id as it will be re-assigned when the file is read - // el.setAttribute(getAttrName(Split::Attribute::ID), split.id()); - el.setAttribute(d->getAttrName(Split::Attribute::Account), d->m_account); - el.setAttribute(d->getAttrName(Split::Attribute::Number), d->m_number); - el.setAttribute(d->getAttrName(Split::Attribute::BankID), d->m_bankID); - if(!d->m_costCenter.isEmpty()) - el.setAttribute(d->getAttrName(Split::Attribute::CostCenter), d->m_costCenter); - - for (int i = 0; i < d->m_tagList.count(); i++) { - QDomElement sel = document.createElement(d->getElName(Split::Element::Tag)); - sel.setAttribute(d->getAttrName(Split::Attribute::ID), d->m_tagList[i]); - el.appendChild(sel); - } - - MyMoneyKeyValueContainer::writeXML(document, el); - - parent.appendChild(el); -} - bool MyMoneySplit::hasReferenceTo(const QString& id) const { Q_D(const MyMoneySplit); diff --git a/kmymoney/mymoney/mymoneytransaction.h b/kmymoney/mymoney/mymoneytransaction.h --- a/kmymoney/mymoney/mymoneytransaction.h +++ b/kmymoney/mymoney/mymoneytransaction.h @@ -241,8 +241,6 @@ */ static QString firstSplitID(); - void writeXML(QDomDocument& document, QDomElement& parent) const override; - /** * This method checks if a reference to the given object exists. It returns, * a @p true if the object is referencing the one requested by the diff --git a/kmymoney/mymoney/mymoneytransaction.cpp b/kmymoney/mymoney/mymoneytransaction.cpp --- a/kmymoney/mymoney/mymoneytransaction.cpp +++ b/kmymoney/mymoney/mymoneytransaction.cpp @@ -27,8 +27,6 @@ // QT Includes #include -#include -#include #include // ---------------------------------------------------------------------------- @@ -400,27 +398,6 @@ deletePair("Imported"); } -void MyMoneyTransaction::writeXML(QDomDocument& document, QDomElement& parent) const -{ - Q_D(const MyMoneyTransaction); - auto el = document.createElement(nodeNames[nnTransaction]); - - d->writeBaseXML(document, el); - el.setAttribute(d->getAttrName(Transaction::Attribute::PostDate), MyMoneyUtils::dateToString(d->m_postDate)); - el.setAttribute(d->getAttrName(Transaction::Attribute::Memo), d->m_memo); - el.setAttribute(d->getAttrName(Transaction::Attribute::EntryDate), MyMoneyUtils::dateToString(d->m_entryDate)); - el.setAttribute(d->getAttrName(Transaction::Attribute::Commodity), d->m_commodity); - - auto splits = document.createElement(d->getElName(Transaction::Element::Splits)); - foreach (const auto split, d->m_splits) - split.writeXML(document, splits); - el.appendChild(splits); - - MyMoneyKeyValueContainer::writeXML(document, el); - - parent.appendChild(el); -} - bool MyMoneyTransaction::hasReferenceTo(const QString& id) const { Q_D(const MyMoneyTransaction); diff --git a/kmymoney/mymoney/tests/mymoneyschedule-test.h b/kmymoney/mymoney/tests/mymoneyschedule-test.h --- a/kmymoney/mymoney/tests/mymoneyschedule-test.h +++ b/kmymoney/mymoney/tests/mymoneyschedule-test.h @@ -32,7 +32,6 @@ void testCopyConstructor(); void testAssignmentConstructor(); void testAddHalfMonths(); - void testWriteXML(); void testAdjustedNextDueDate(); void testModifyNextDueDate(); void testDaysBetweenEvents(); diff --git a/kmymoney/mymoney/tests/mymoneyschedule-test.cpp b/kmymoney/mymoney/tests/mymoneyschedule-test.cpp --- a/kmymoney/mymoney/tests/mymoneyschedule-test.cpp +++ b/kmymoney/mymoney/tests/mymoneyschedule-test.cpp @@ -275,138 +275,6 @@ QCOMPARE(s.dateAfter(5).toString(format), QLatin1String("2007-06-30")); } -void MyMoneyScheduleTest::testWriteXML() -{ - MyMoneySchedule sch("A Name", - Schedule::Type::Bill, - Schedule::Occurrence::Weekly, 123, - Schedule::PaymentType::DirectDebit, - QDate::currentDate(), - QDate(), - true, - true); - - sch.setLastPayment(QDate::currentDate()); - sch.recordPayment(QDate::currentDate()); - sch.d_func()->setId("SCH0001"); - - MyMoneyTransaction t; - t.setPostDate(QDate(2001, 12, 28)); - t.setEntryDate(QDate(2003, 9, 29)); - t.d_func()->setId("T000000000000000001"); - t.setMemo("Wohnung:Miete"); - t.setCommodity("EUR"); - t.setValue("key", "value"); - - MyMoneySplit s; - s.setPayeeId("P000001"); - s.setShares(MyMoneyMoney(96379, 100)); - s.setValue(MyMoneyMoney(96379, 100)); - s.setAccountId("A000076"); - s.setBankID("SPID1"); - s.setReconcileFlag(eMyMoney::Split::State::Reconciled); - t.addSplit(s); - - s.setPayeeId("P000001"); - s.setShares(MyMoneyMoney(-96379, 100)); - s.setValue(MyMoneyMoney(-96379, 100)); - s.setAccountId("A000276"); - s.setBankID("SPID2"); - s.setReconcileFlag(eMyMoney::Split::State::Cleared); - s.clearId(); - t.addSplit(s); - - sch.setTransaction(t); - - QDomDocument doc("TEST"); - QDomElement el = doc.createElement("SCHEDULE-CONTAINER"); - doc.appendChild(el); - sch.writeXML(doc, el); - - QCOMPARE(doc.doctype().name(), QLatin1String("TEST")); - QDomElement scheduleContainer = doc.documentElement(); - QVERIFY(scheduleContainer.isElement()); - QCOMPARE(scheduleContainer.tagName(), QLatin1String("SCHEDULE-CONTAINER")); - QCOMPARE(scheduleContainer.childNodes().size(), 1); - QVERIFY(scheduleContainer.childNodes().at(0).isElement()); - - QDomElement schedule = scheduleContainer.childNodes().at(0).toElement(); - QCOMPARE(schedule.tagName(), QLatin1String("SCHEDULED_TX")); - QCOMPARE(schedule.attribute("id"), QLatin1String("SCH0001")); - QCOMPARE(schedule.attribute("paymentType"), QLatin1String("1")); - QCOMPARE(schedule.attribute("autoEnter"), QLatin1String("1")); - QCOMPARE(schedule.attribute("occurenceMultiplier"), QLatin1String("123")); // krazy:exclude=spelling - QCOMPARE(schedule.attribute("startDate"), QDate::currentDate().toString(Qt::ISODate)); - QCOMPARE(schedule.attribute("lastPayment"), QDate::currentDate().toString(Qt::ISODate)); - QCOMPARE(schedule.attribute("occurenceMultiplier"), QLatin1String("123")); // krazy:exclude=spelling - QCOMPARE(schedule.attribute("occurence"), QLatin1String("4")); // krazy:exclude=spelling - QCOMPARE(schedule.attribute("type"), QLatin1String("1")); - QCOMPARE(schedule.attribute("name"), QLatin1String("A Name")); - QCOMPARE(schedule.attribute("fixed"), QLatin1String("1")); - QCOMPARE(schedule.attribute("endDate"), QString()); - QCOMPARE(schedule.childNodes().size(), 2); - - QVERIFY(schedule.childNodes().at(0).isElement()); - QDomElement payments = schedule.childNodes().at(0).toElement(); - - QVERIFY(schedule.childNodes().at(1).isElement()); - QDomElement transaction = schedule.childNodes().at(1).toElement(); - QCOMPARE(transaction.tagName(), QLatin1String("TRANSACTION")); - QCOMPARE(transaction.attribute("id"), QString()); - QCOMPARE(transaction.attribute("postdate"), QLatin1String("2001-12-28")); - QCOMPARE(transaction.attribute("commodity"), QLatin1String("EUR")); - QCOMPARE(transaction.attribute("memo"), QLatin1String("Wohnung:Miete")); - QCOMPARE(transaction.attribute("entrydate"), QLatin1String("2003-09-29")); - QCOMPARE(transaction.childNodes().size(), 2); - - QVERIFY(transaction.childNodes().at(0).isElement()); - QDomElement splits = transaction.childNodes().at(0).toElement(); - QCOMPARE(splits.tagName(), QLatin1String("SPLITS")); - QCOMPARE(splits.childNodes().size(), 2); - QVERIFY(splits.childNodes().at(0).isElement()); - QDomElement split1 = splits.childNodes().at(0).toElement(); - QCOMPARE(split1.tagName(), QLatin1String("SPLIT")); - QCOMPARE(split1.attribute("id"), QLatin1String("S0001")); - QCOMPARE(split1.attribute("payee"), QLatin1String("P000001")); - QCOMPARE(split1.attribute("reconcileflag"), QLatin1String("2")); - QCOMPARE(split1.attribute("shares"), QLatin1String("96379/100")); - QCOMPARE(split1.attribute("reconciledate"), QString()); - QCOMPARE(split1.attribute("action"), QString()); - QCOMPARE(split1.attribute("bankid"), QString()); - QCOMPARE(split1.attribute("account"), QLatin1String("A000076")); - QCOMPARE(split1.attribute("number"), QString()); - QCOMPARE(split1.attribute("value"), QLatin1String("96379/100")); - QCOMPARE(split1.attribute("memo"), QString()); - QCOMPARE(split1.childNodes().size(), 0); - - QVERIFY(splits.childNodes().at(1).isElement()); - QDomElement split2 = splits.childNodes().at(1).toElement(); - QCOMPARE(split2.tagName(), QLatin1String("SPLIT")); - QCOMPARE(split2.attribute("id"), QLatin1String("S0002")); - QCOMPARE(split2.attribute("payee"), QLatin1String("P000001")); - QCOMPARE(split2.attribute("reconcileflag"), QLatin1String("1")); - QCOMPARE(split2.attribute("shares"), QLatin1String("-96379/100")); - QCOMPARE(split2.attribute("reconciledate"), QString()); - QCOMPARE(split2.attribute("action"), QString()); - QCOMPARE(split2.attribute("bankid"), QString()); - QCOMPARE(split2.attribute("account"), QLatin1String("A000276")); - QCOMPARE(split2.attribute("number"), QString()); - QCOMPARE(split2.attribute("value"), QLatin1String("-96379/100")); - QCOMPARE(split2.attribute("memo"), QString()); - QCOMPARE(split2.childNodes().size(), 0); - - QDomElement keyValuePairs = transaction.childNodes().at(1).toElement(); - QCOMPARE(keyValuePairs.tagName(), QLatin1String("KEYVALUEPAIRS")); - QCOMPARE(keyValuePairs.childNodes().size(), 1); - - QVERIFY(keyValuePairs.childNodes().at(0).isElement()); - QDomElement keyValuePair1 = keyValuePairs.childNodes().at(0).toElement(); - QCOMPARE(keyValuePair1.tagName(), QLatin1String("PAIR")); - QCOMPARE(keyValuePair1.attribute("key"), QLatin1String("key")); - QCOMPARE(keyValuePair1.attribute("value"), QLatin1String("value")); - QCOMPARE(keyValuePair1.childNodes().size(), 0); -} - void MyMoneyScheduleTest::testAdjustedNextDueDate() { MyMoneySchedule s; diff --git a/kmymoney/mymoney/tests/mymoneytransaction-test.h b/kmymoney/mymoney/tests/mymoneytransaction-test.h --- a/kmymoney/mymoney/tests/mymoneytransaction-test.h +++ b/kmymoney/mymoney/tests/mymoneytransaction-test.h @@ -51,7 +51,6 @@ void testIsLoanPayment(); //void testAddDuplicateAccount(); //void testModifyDuplicateAccount(); - void testWriteXML(); void testAutoCalc(); void testHasReferenceTo(); void testIsStockSplit(); diff --git a/kmymoney/mymoney/tests/mymoneytransaction-test.cpp b/kmymoney/mymoney/tests/mymoneytransaction-test.cpp --- a/kmymoney/mymoney/tests/mymoneytransaction-test.cpp +++ b/kmymoney/mymoney/tests/mymoneytransaction-test.cpp @@ -411,88 +411,6 @@ } #endif -void MyMoneyTransactionTest::testWriteXML() -{ - MyMoneyTransaction t; - t.setPostDate(QDate(2001, 12, 28)); - t.setEntryDate(QDate(2003, 9, 29)); - t.d_func()->setId("T000000000000000001"); - t.setMemo("Wohnung:Miete"); - t.setCommodity("EUR"); - t.setValue("key", "value"); - - MyMoneySplit s; - s.setPayeeId("P000001"); - QList tagIdList; - tagIdList << "G000001"; - s.setTagIdList(tagIdList); - s.setShares(MyMoneyMoney(96379, 100)); - s.setValue(MyMoneyMoney(96379, 100)); - s.setAction(MyMoneySplit::actionName(eMyMoney::Split::Action::Withdrawal)); - s.setAccountId("A000076"); - s.setReconcileFlag(eMyMoney::Split::State::Reconciled); - s.setBankID("SPID"); - t.addSplit(s); - - QDomDocument doc("TEST"); - QDomElement el = doc.createElement("TRANSACTION-CONTAINER"); - doc.appendChild(el); - t.writeXML(doc, el); - - QCOMPARE(doc.doctype().name(), QLatin1String("TEST")); - QDomElement transactionContainer = doc.documentElement(); - QVERIFY(transactionContainer.isElement()); - QCOMPARE(transactionContainer.tagName(), QLatin1String("TRANSACTION-CONTAINER")); - QVERIFY(transactionContainer.childNodes().size() == 1); - QVERIFY(transactionContainer.childNodes().at(0).isElement()); - - QDomElement transaction = transactionContainer.childNodes().at(0).toElement(); - QCOMPARE(transaction.tagName(), QLatin1String("TRANSACTION")); - QCOMPARE(transaction.attribute("id"), QLatin1String("T000000000000000001")); - QCOMPARE(transaction.attribute("postdate"), QLatin1String("2001-12-28")); - QCOMPARE(transaction.attribute("commodity"), QLatin1String("EUR")); - QCOMPARE(transaction.attribute("memo"), QLatin1String("Wohnung:Miete")); - QCOMPARE(transaction.attribute("entrydate"), QLatin1String("2003-09-29")); - QCOMPARE(transaction.childNodes().size(), 2); - - QVERIFY(transaction.childNodes().at(0).isElement()); - QDomElement splits = transaction.childNodes().at(0).toElement(); - QCOMPARE(splits.tagName(), QLatin1String("SPLITS")); - QCOMPARE(splits.childNodes().size(), 1); - QVERIFY(splits.childNodes().at(0).isElement()); - QDomElement split = splits.childNodes().at(0).toElement(); - QCOMPARE(split.tagName(), QLatin1String("SPLIT")); - QCOMPARE(split.attribute("id"), QLatin1String("S0001")); - QCOMPARE(split.attribute("payee"), QLatin1String("P000001")); - QCOMPARE(split.attribute("reconcileflag"), QLatin1String("2")); - QCOMPARE(split.attribute("shares"), QLatin1String("96379/100")); - QCOMPARE(split.attribute("reconciledate"), QString()); - QCOMPARE(split.attribute("action"), QLatin1String("Withdrawal")); - QCOMPARE(split.attribute("bankid"), QLatin1String("SPID")); - QCOMPARE(split.attribute("account"), QLatin1String("A000076")); - QCOMPARE(split.attribute("number"), QString()); - QCOMPARE(split.attribute("value"), QLatin1String("96379/100")); - QCOMPARE(split.attribute("memo"), QString()); - QCOMPARE(split.childNodes().size(), 1); - - QVERIFY(split.childNodes().at(0).isElement()); - QDomElement tag = split.childNodes().at(0).toElement(); - QCOMPARE(tag.tagName(), QLatin1String("TAG")); - QCOMPARE(tag.attribute("id"), QLatin1String("G000001")); - QCOMPARE(tag.childNodes().size(), 0); - - QDomElement keyValuePairs = transaction.childNodes().at(1).toElement(); - QCOMPARE(keyValuePairs.tagName(), QLatin1String("KEYVALUEPAIRS")); - QCOMPARE(keyValuePairs.childNodes().size(), 1); - - QVERIFY(keyValuePairs.childNodes().at(0).isElement()); - QDomElement keyValuePair1 = keyValuePairs.childNodes().at(0).toElement(); - QCOMPARE(keyValuePair1.tagName(), QLatin1String("PAIR")); - QCOMPARE(keyValuePair1.attribute("key"), QLatin1String("key")); - QCOMPARE(keyValuePair1.attribute("value"), QLatin1String("value")); - QCOMPARE(keyValuePair1.childNodes().size(), 0); -} - void MyMoneyTransactionTest::testHasReferenceTo() { MyMoneyTransaction t; diff --git a/kmymoney/plugins/xml/mymoneystoragexml.cpp b/kmymoney/plugins/xml/mymoneystoragexml.cpp --- a/kmymoney/plugins/xml/mymoneystoragexml.cpp +++ b/kmymoney/plugins/xml/mymoneystoragexml.cpp @@ -164,6 +164,7 @@ static MyMoneyReport readReport(const QDomElement &node); static MyMoneyBudget readBudget(const QDomElement &node); static MyMoneySchedule readSchedule(const QDomElement &node); + static void writeSchedule(const MyMoneySchedule &schedule, QDomDocument &document, QDomElement &parent); static onlineJob readOnlineJob(const QDomElement &node); static MyMoneyCostCenter readCostCenter(const QDomElement &node); }; @@ -1246,6 +1247,42 @@ return schedule; } +void MyMoneyXmlContentHandler::writeSchedule(const MyMoneySchedule &schedule, QDomDocument &document, QDomElement &parent) +{ + auto el = document.createElement(nodeName(Node::ScheduleTX)); + + writeBaseXML(schedule.id(), document, el); + + el.setAttribute(attributeName(Attribute::Schedule::Name), schedule.name()); + el.setAttribute(attributeName(Attribute::Schedule::Type), (int)schedule.type()); + el.setAttribute(attributeName(Attribute::Schedule::Occurrence), (int)schedule.occurrence()); + el.setAttribute(attributeName(Attribute::Schedule::OccurrenceMultiplier), schedule.occurrenceMultiplier()); + el.setAttribute(attributeName(Attribute::Schedule::PaymentType), (int)schedule.paymentType()); + el.setAttribute(attributeName(Attribute::Schedule::StartDate), MyMoneyUtils::dateToString(schedule.startDate())); + el.setAttribute(attributeName(Attribute::Schedule::EndDate), MyMoneyUtils::dateToString(schedule.endDate())); + el.setAttribute(attributeName(Attribute::Schedule::Fixed), schedule.isFixed()); + el.setAttribute(attributeName(Attribute::Schedule::LastDayInMonth), schedule.lastDayInMonth()); + el.setAttribute(attributeName(Attribute::Schedule::AutoEnter), schedule.autoEnter()); + el.setAttribute(attributeName(Attribute::Schedule::LastPayment), MyMoneyUtils::dateToString(schedule.lastPayment())); + el.setAttribute(attributeName(Attribute::Schedule::WeekendOption), (int)schedule.weekendOption()); + + //store the payment history for this scheduled task. + QList payments = schedule.recordedPayments(); + QList::ConstIterator it; + QDomElement paymentsElement = document.createElement(elementName(Element::Schedule::Payments)); + for (it = payments.constBegin(); it != payments.constEnd(); ++it) { + QDomElement paymentEntry = document.createElement(elementName(Element::Schedule::Payment)); + paymentEntry.setAttribute(attributeName(Attribute::Schedule::Date), MyMoneyUtils::dateToString(*it)); + paymentsElement.appendChild(paymentEntry); + } + el.appendChild(paymentsElement); + + //store the transaction data for this task. + writeTransaction(schedule.transaction(), document, el); + + parent.appendChild(el); +} + onlineJob MyMoneyXmlContentHandler::readOnlineJob(const QDomElement &node) { onlineJob oJob(node.attribute(attributeName(Attribute::Account::ID))); @@ -1658,7 +1695,7 @@ void MyMoneyStorageXML::writeSchedule(QDomElement& scheduledTx, const MyMoneySchedule& tx) { - tx.writeXML(*m_doc, scheduledTx); + MyMoneyXmlContentHandler::writeSchedule(tx, *m_doc, scheduledTx); } void MyMoneyStorageXML::writeSecurities(QDomElement& equities) diff --git a/kmymoney/plugins/xml/tests/mymoneyxmlcontenthandler-test.cpp b/kmymoney/plugins/xml/tests/mymoneyxmlcontenthandler-test.cpp --- a/kmymoney/plugins/xml/tests/mymoneyxmlcontenthandler-test.cpp +++ b/kmymoney/plugins/xml/tests/mymoneyxmlcontenthandler-test.cpp @@ -267,7 +267,7 @@ QDomDocument doc("TEST"); QDomElement el = doc.createElement("TRANSACTION-CONTAINER"); doc.appendChild(el); - t.writeXML(doc, el); + MyMoneyXmlContentHandler::writeTransaction(t, doc, el); QCOMPARE(doc.doctype().name(), QLatin1String("TEST")); QDomElement transactionContainer = doc.documentElement(); @@ -1045,7 +1045,7 @@ QDomDocument doc("TEST"); QDomElement el = doc.createElement("SCHEDULE-CONTAINER"); doc.appendChild(el); - sch.writeXML(doc, el); + MyMoneyXmlContentHandler::writeSchedule(sch, doc, el); QCOMPARE(doc.doctype().name(), QLatin1String("TEST")); QDomElement scheduleContainer = doc.documentElement();