MyMoneyTransaction KMyMoneyUtils::scheduledTransaction(const MyMoneySchedule& schedule) { MyMoneyTransaction t = schedule.transaction(); try { if (schedule.type() == MyMoneySchedule::TYPE_LOANPAYMENT) { calculateAutoLoan(schedule, t, QMap<QString, MyMoneyMoney>()); } } catch (const MyMoneyException &e) { qDebug("Unable to load schedule details for '%s' during transaction match: %s", qPrintable(schedule.name()), qPrintable(e.what())); } t.clearId(); t.setEntryDate(QDate()); return t; }
void KMyMoneyBriefSchedule::loadSchedule() { try { if (m_index < m_scheduleList.count()) { MyMoneySchedule sched = m_scheduleList[m_index]; m_indexLabel->setText(i18n("%1 of %2") .arg(QString::number(m_index+1)) .arg(QString::number(m_scheduleList.count()))); m_name->setText(sched.name()); m_type->setText(KMyMoneyUtils::scheduleTypeToString(sched.type())); m_account->setText(sched.account().name()); QString text; MyMoneyMoney amount = sched.transaction().splitByAccount(sched.account().id()).value(); amount = amount.abs(); if (sched.willEnd()) { int transactions = sched.paymentDates(m_date, sched.endDate()).count()-1; text = i18n("Payment on %1 for %2 with %3 transactions remaining occuring %4.") .arg(KGlobal::locale()->formatDate(m_date, true)) .arg(amount.formatMoney(sched.account().fraction())) .arg(QString::number(transactions)) .arg(i18n(sched.occurenceToString())); } else { text = i18n("Payment on %1 for %2 occuring %4.") .arg(KGlobal::locale()->formatDate(m_date, true)) .arg(amount.formatMoney(sched.account().fraction())) .arg(i18n(sched.occurenceToString())); } if (m_date < QDate::currentDate()) { if (sched.isOverdue()) { QDate startD = (sched.lastPayment().isValid()) ? sched.lastPayment() : sched.startDate(); if (m_date.isValid()) startD = m_date; int days = startD.daysTo(QDate::currentDate()); int transactions = sched.paymentDates(startD, QDate::currentDate()).count(); text += "<br><font color=red>"; text += i18n("%1 days overdue (%2 occurences).") .arg(QString::number(days)) .arg(QString::number(transactions)); text += "</color>"; } } m_details->setText(text); m_prevButton->setEnabled(true); m_nextButton->setEnabled(true); m_skipButton->setEnabled(sched.occurencePeriod() != MyMoneySchedule::OCCUR_ONCE); if (m_index == 0) m_prevButton->setEnabled(false); if (m_index == (m_scheduleList.count()-1)) m_nextButton->setEnabled(false); } } catch (MyMoneyException *e) { delete e; } }