void ModelBackendOneFile::removeTransaction(const QString& _isbn) { qDebug() << Q_FUNC_INFO; QString path = _privatePartition + QDir::separator() + TRANSACTIONS_DATA_FILE; QFile file(QDir::cleanPath(path)); if(file.open(QFile::ReadOnly)) { QXmlStreamReader xml(&file); xml.readNext(); //Skip first tag xml.readNext(); if(xml.name() == "transactions") { while (!xml.atEnd() && !xml.hasError()) { xml.readNext(); if (xml.name() == "transaction" && xml.isStartElement()) { QString isbn = xml.attributes().value("isbn").toString(); bool filed = (bool)xml.attributes().value("filed").toString().toInt(); if(isbn != _isbn) m_transactions->insert(_isbn, filed); } } } file.close(); } writeTransactions(); m_transactions->clear(); }
void Store::addTransaction(const Transaction & t) { transactions.push_back(t); Cost cost = 0; for (const Product* i : t.products) { cost += i->getCost(); } t.getCustomer().setTotalCost(t.getCustomer().getTotalCost() + cost); writeCustomers(); writeTransactions(); }
void Store::save() { writeCustomers(); //writeProducts(); writeTransactions(); }
void MyMoneyStorageXML::writeFile(QIODevice* qf, IMyMoneySerialize* storage) { Q_CHECK_PTR(qf); Q_CHECK_PTR(storage); if (!storage) { return; } m_storage = storage; // qDebug("XMLWRITER: Starting file write"); m_doc = new QDomDocument("KMYMONEY-FILE"); Q_CHECK_PTR(m_doc); QDomProcessingInstruction instruct = m_doc->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\""); m_doc->appendChild(instruct); QDomElement mainElement = m_doc->createElement("KMYMONEY-FILE"); m_doc->appendChild(mainElement); QDomElement fileInfo = m_doc->createElement("FILEINFO"); writeFileInformation(fileInfo); mainElement.appendChild(fileInfo); QDomElement userInfo = m_doc->createElement("USER"); writeUserInformation(userInfo); mainElement.appendChild(userInfo); QDomElement institutions = m_doc->createElement("INSTITUTIONS"); writeInstitutions(institutions); mainElement.appendChild(institutions); QDomElement payees = m_doc->createElement("PAYEES"); writePayees(payees); mainElement.appendChild(payees); QDomElement tags = m_doc->createElement("TAGS"); writeTags(tags); mainElement.appendChild(tags); QDomElement accounts = m_doc->createElement("ACCOUNTS"); writeAccounts(accounts); mainElement.appendChild(accounts); QDomElement transactions = m_doc->createElement("TRANSACTIONS"); writeTransactions(transactions); mainElement.appendChild(transactions); QDomElement keyvalpairs = writeKeyValuePairs(m_storage->pairs()); mainElement.appendChild(keyvalpairs); QDomElement schedules = m_doc->createElement("SCHEDULES"); writeSchedules(schedules); mainElement.appendChild(schedules); QDomElement equities = m_doc->createElement("SECURITIES"); writeSecurities(equities); mainElement.appendChild(equities); QDomElement currencies = m_doc->createElement("CURRENCIES"); writeCurrencies(currencies); mainElement.appendChild(currencies); QDomElement prices = m_doc->createElement("PRICES"); writePrices(prices); mainElement.appendChild(prices); QDomElement reports = m_doc->createElement("REPORTS"); writeReports(reports); mainElement.appendChild(reports); QDomElement budgets = m_doc->createElement("BUDGETS"); writeBudgets(budgets); mainElement.appendChild(budgets); QDomElement onlineJobs = m_doc->createElement("ONLINEJOBS"); writeOnlineJobs(onlineJobs); mainElement.appendChild(onlineJobs); QTextStream stream(qf); stream.setCodec("UTF-8"); stream << m_doc->toString(); delete m_doc; m_doc = 0; //hides the progress bar. signalProgress(-1, -1); // this seems to be nonsense, but it clears the dirty flag // as a side-effect. m_storage->setLastModificationDate(m_storage->lastModificationDate()); m_storage = 0; }