Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/mymoneyschedule.cpp
Context not available. | |||||
38 | #include "mymoneystoragenames.h" | 38 | #include "mymoneystoragenames.h" | ||
---|---|---|---|---|---|
39 | 39 | | |||
40 | using namespace MyMoneyStorageNodes; | 40 | using namespace MyMoneyStorageNodes; | ||
41 | using namespace eMyMoney; | ||||
41 | 42 | | |||
42 | static IMyMoneyProcessingCalendar* processingCalendarPtr = 0; | 43 | static IMyMoneyProcessingCalendar* processingCalendarPtr = 0; | ||
43 | 44 | | |||
Context not available. | |||||
45 | MyMoneyObject() | 46 | MyMoneyObject() | ||
46 | { | 47 | { | ||
47 | // Set up the default values | 48 | // Set up the default values | ||
48 | m_occurrence = OCCUR_ANY; | 49 | m_occurrence = Schedule::Occurrence::Any; | ||
49 | m_occurrenceMultiplier = 1; | 50 | m_occurrenceMultiplier = 1; | ||
50 | m_type = TYPE_ANY; | 51 | m_type = Schedule::Type::Any; | ||
51 | m_paymentType = STYPE_ANY; | 52 | m_paymentType = Schedule::PaymentType::Any; | ||
52 | m_fixed = false; | 53 | m_fixed = false; | ||
53 | m_autoEnter = false; | 54 | m_autoEnter = false; | ||
54 | m_startDate = QDate(); | 55 | m_startDate = QDate(); | ||
55 | m_endDate = QDate(); | 56 | m_endDate = QDate(); | ||
56 | m_lastPayment = QDate(); | 57 | m_lastPayment = QDate(); | ||
57 | m_weekendOption = MoveNothing; | 58 | m_weekendOption = Schedule::WeekendOption::MoveNothing; | ||
58 | } | 59 | } | ||
59 | 60 | | |||
60 | MyMoneySchedule::MyMoneySchedule(const QString& name, typeE type, | 61 | MyMoneySchedule::MyMoneySchedule(const QString& name, Schedule::Type type, | ||
61 | occurrenceE occurrence, int occurrenceMultiplier, | 62 | Schedule::Occurrence occurrence, int occurrenceMultiplier, | ||
62 | paymentTypeE paymentType, | 63 | Schedule::PaymentType paymentType, | ||
63 | const QDate& /* startDate */, | 64 | const QDate& /* startDate */, | ||
64 | const QDate& endDate, | 65 | const QDate& endDate, | ||
65 | bool fixed, bool autoEnter) : | 66 | bool fixed, bool autoEnter) : | ||
Context not available. | |||||
77 | m_startDate = QDate(); | 78 | m_startDate = QDate(); | ||
78 | m_endDate = endDate; | 79 | m_endDate = endDate; | ||
79 | m_lastPayment = QDate(); | 80 | m_lastPayment = QDate(); | ||
80 | m_weekendOption = MoveNothing; | 81 | m_weekendOption = Schedule::WeekendOption::MoveNothing; | ||
81 | } | 82 | } | ||
82 | 83 | | |||
83 | MyMoneySchedule::MyMoneySchedule(const QDomElement& node) : | 84 | MyMoneySchedule::MyMoneySchedule(const QDomElement& node) : | ||
Context not available. | |||||
91 | m_endDate = stringToDate(node.attribute(getAttrName(anEndDate))); | 92 | m_endDate = stringToDate(node.attribute(getAttrName(anEndDate))); | ||
92 | m_lastPayment = stringToDate(node.attribute(getAttrName(anLastPayment))); | 93 | m_lastPayment = stringToDate(node.attribute(getAttrName(anLastPayment))); | ||
93 | 94 | | |||
94 | m_type = static_cast<MyMoneySchedule::typeE>(node.attribute(getAttrName(anType)).toInt()); | 95 | m_type = static_cast<Schedule::Type>(node.attribute(getAttrName(anType)).toInt()); | ||
95 | m_paymentType = static_cast<MyMoneySchedule::paymentTypeE>(node.attribute(getAttrName(anPaymentType)).toInt()); | 96 | m_paymentType = static_cast<Schedule::PaymentType>(node.attribute(getAttrName(anPaymentType)).toInt()); | ||
96 | m_occurrence = static_cast<MyMoneySchedule::occurrenceE>(node.attribute(getAttrName(anOccurence)).toInt()); // krazy:exclude=spelling | 97 | m_occurrence = static_cast<Schedule::Occurrence>(node.attribute(getAttrName(anOccurence)).toInt()); // krazy:exclude=spelling | ||
97 | m_occurrenceMultiplier = node.attribute(getAttrName(anOccurenceMultiplier), "1").toInt(); // krazy:exclude=spelling | 98 | m_occurrenceMultiplier = node.attribute(getAttrName(anOccurenceMultiplier), "1").toInt(); // krazy:exclude=spelling | ||
98 | // Convert to compound occurrence | 99 | // Convert to compound occurrence | ||
99 | simpleToCompoundOccurrence(m_occurrenceMultiplier, m_occurrence); | 100 | simpleToCompoundOccurrence(m_occurrenceMultiplier, m_occurrence); | ||
100 | m_autoEnter = static_cast<bool>(node.attribute(getAttrName(anAutoEnter)).toInt()); | 101 | m_autoEnter = static_cast<bool>(node.attribute(getAttrName(anAutoEnter)).toInt()); | ||
101 | m_fixed = static_cast<bool>(node.attribute(getAttrName(anFixed)).toInt()); | 102 | m_fixed = static_cast<bool>(node.attribute(getAttrName(anFixed)).toInt()); | ||
102 | m_weekendOption = static_cast<MyMoneySchedule::weekendOptionE>(node.attribute(getAttrName(anWeekendOption)).toInt()); | 103 | m_weekendOption = static_cast<Schedule::WeekendOption>(node.attribute(getAttrName(anWeekendOption)).toInt()); | ||
103 | 104 | | |||
104 | // read in the associated transaction | 105 | // read in the associated transaction | ||
105 | QDomNodeList nodeList = node.elementsByTagName(nodeNames[nnTransaction]); | 106 | QDomNodeList nodeList = node.elementsByTagName(nodeNames[nnTransaction]); | ||
Context not available. | |||||
154 | setId(id); | 155 | setId(id); | ||
155 | } | 156 | } | ||
156 | 157 | | |||
157 | MyMoneySchedule::occurrenceE MyMoneySchedule::occurrence() const | 158 | Schedule::Occurrence MyMoneySchedule::occurrence() const | ||
158 | { | 159 | { | ||
159 | MyMoneySchedule::occurrenceE occ = m_occurrence; | 160 | Schedule::Occurrence occ = m_occurrence; | ||
160 | int mult = m_occurrenceMultiplier; | 161 | int mult = m_occurrenceMultiplier; | ||
161 | compoundToSimpleOccurrence(mult, occ); | 162 | compoundToSimpleOccurrence(mult, occ); | ||
162 | return occ; | 163 | return occ; | ||
Context not available. | |||||
167 | m_startDate = date; | 168 | m_startDate = date; | ||
168 | } | 169 | } | ||
169 | 170 | | |||
170 | void MyMoneySchedule::setPaymentType(paymentTypeE type) | 171 | void MyMoneySchedule::setPaymentType(Schedule::PaymentType type) | ||
171 | { | 172 | { | ||
172 | m_paymentType = type; | 173 | m_paymentType = type; | ||
173 | } | 174 | } | ||
Context not available. | |||||
270 | return adjustedDate(nextDueDate(), weekendOption()); | 271 | return adjustedDate(nextDueDate(), weekendOption()); | ||
271 | } | 272 | } | ||
272 | 273 | | |||
273 | QDate MyMoneySchedule::adjustedDate(QDate date, weekendOptionE option) const | 274 | QDate MyMoneySchedule::adjustedDate(QDate date, Schedule::WeekendOption option) const | ||
274 | { | 275 | { | ||
275 | if (!date.isValid() || option == MyMoneySchedule::MoveNothing || isProcessingDate(date)) | 276 | if (!date.isValid() || option == Schedule::WeekendOption::MoveNothing || isProcessingDate(date)) | ||
276 | return date; | 277 | return date; | ||
277 | 278 | | |||
278 | int step = 1; | 279 | int step = 1; | ||
279 | if (option == MyMoneySchedule::MoveBefore) | 280 | if (option == Schedule::WeekendOption::MoveBefore) | ||
280 | step = -1; | 281 | step = -1; | ||
281 | 282 | | |||
282 | while (!isProcessingDate(date)) | 283 | while (!isProcessingDate(date)) | ||
Context not available. | |||||
318 | m_name = nm; | 319 | m_name = nm; | ||
319 | } | 320 | } | ||
320 | 321 | | |||
321 | void MyMoneySchedule::setOccurrence(occurrenceE occ) | 322 | void MyMoneySchedule::setOccurrence(Schedule::Occurrence occ) | ||
322 | { | 323 | { | ||
323 | MyMoneySchedule::occurrenceE occ2 = occ; | 324 | Schedule::Occurrence occ2 = occ; | ||
324 | int mult = 1; | 325 | int mult = 1; | ||
325 | simpleToCompoundOccurrence(mult, occ2); | 326 | simpleToCompoundOccurrence(mult, occ2); | ||
326 | setOccurrencePeriod(occ2); | 327 | setOccurrencePeriod(occ2); | ||
327 | setOccurrenceMultiplier(mult); | 328 | setOccurrenceMultiplier(mult); | ||
328 | } | 329 | } | ||
329 | 330 | | |||
330 | void MyMoneySchedule::setOccurrencePeriod(occurrenceE occ) | 331 | void MyMoneySchedule::setOccurrencePeriod(Schedule::Occurrence occ) | ||
331 | { | 332 | { | ||
332 | m_occurrence = occ; | 333 | m_occurrence = occ; | ||
333 | } | 334 | } | ||
Context not available. | |||||
337 | m_occurrenceMultiplier = occmultiplier < 1 ? 1 : occmultiplier; | 338 | m_occurrenceMultiplier = occmultiplier < 1 ? 1 : occmultiplier; | ||
338 | } | 339 | } | ||
339 | 340 | | |||
340 | void MyMoneySchedule::setType(typeE type) | 341 | void MyMoneySchedule::setType(Schedule::Type type) | ||
341 | { | 342 | { | ||
342 | m_type = type; | 343 | m_type = type; | ||
343 | } | 344 | } | ||
Context not available. | |||||
358 | if (id_check && !m_id.isEmpty()) | 359 | if (id_check && !m_id.isEmpty()) | ||
359 | throw MYMONEYEXCEPTION("ID for schedule not empty when required"); | 360 | throw MYMONEYEXCEPTION("ID for schedule not empty when required"); | ||
360 | 361 | | |||
361 | if (m_occurrence == OCCUR_ANY) | 362 | if (m_occurrence == Schedule::Occurrence::Any) | ||
362 | throw MYMONEYEXCEPTION("Invalid occurrence type for schedule"); | 363 | throw MYMONEYEXCEPTION("Invalid occurrence type for schedule"); | ||
363 | 364 | | |||
364 | if (m_type == TYPE_ANY) | 365 | if (m_type == Schedule::Type::Any) | ||
365 | throw MYMONEYEXCEPTION("Invalid type for schedule"); | 366 | throw MYMONEYEXCEPTION("Invalid type for schedule"); | ||
366 | 367 | | |||
367 | if (!nextDueDate().isValid()) | 368 | if (!nextDueDate().isValid()) | ||
368 | throw MYMONEYEXCEPTION("Invalid next due date for schedule"); | 369 | throw MYMONEYEXCEPTION("Invalid next due date for schedule"); | ||
369 | 370 | | |||
370 | if (m_paymentType == STYPE_ANY) | 371 | if (m_paymentType == Schedule::PaymentType::Any) | ||
371 | throw MYMONEYEXCEPTION("Invalid payment type for schedule"); | 372 | throw MYMONEYEXCEPTION("Invalid payment type for schedule"); | ||
372 | 373 | | |||
373 | if (m_transaction.splitCount() == 0) | 374 | if (m_transaction.splitCount() == 0) | ||
Context not available. | |||||
375 | 376 | | |||
376 | // Check the payment types | 377 | // Check the payment types | ||
377 | switch (m_type) { | 378 | switch (m_type) { | ||
378 | case TYPE_BILL: | 379 | case Schedule::Type::Bill: | ||
379 | if (m_paymentType == STYPE_DIRECTDEPOSIT || m_paymentType == STYPE_MANUALDEPOSIT) | 380 | if (m_paymentType == Schedule::PaymentType::DirectDeposit || m_paymentType == Schedule::PaymentType::ManualDeposit) | ||
380 | throw MYMONEYEXCEPTION("Invalid payment type for bills"); | 381 | throw MYMONEYEXCEPTION("Invalid payment type for bills"); | ||
381 | break; | 382 | break; | ||
382 | 383 | | |||
383 | case TYPE_DEPOSIT: | 384 | case Schedule::Type::Deposit: | ||
384 | if (m_paymentType == STYPE_DIRECTDEBIT || m_paymentType == STYPE_WRITECHEQUE) | 385 | if (m_paymentType == Schedule::PaymentType::DirectDebit || m_paymentType == Schedule::PaymentType::WriteChecque) | ||
385 | throw MYMONEYEXCEPTION("Invalid payment type for deposits"); | 386 | throw MYMONEYEXCEPTION("Invalid payment type for deposits"); | ||
386 | break; | 387 | break; | ||
387 | 388 | | |||
388 | case TYPE_ANY: | 389 | case Schedule::Type::Any: | ||
389 | throw MYMONEYEXCEPTION("Invalid type ANY"); | 390 | throw MYMONEYEXCEPTION("Invalid type ANY"); | ||
390 | break; | 391 | break; | ||
391 | 392 | | |||
392 | case TYPE_TRANSFER: | 393 | case Schedule::Type::Transfer: | ||
393 | // if (m_paymentType == STYPE_DIRECTDEPOSIT || m_paymentType == STYPE_MANUALDEPOSIT) | 394 | // if (m_paymentType == DirectDeposit || m_paymentType == ManualDeposit) | ||
394 | // return false; | 395 | // return false; | ||
395 | break; | 396 | break; | ||
396 | 397 | | |||
397 | case TYPE_LOANPAYMENT: | 398 | case Schedule::Type::LoanPayment: | ||
398 | break; | 399 | break; | ||
399 | } | 400 | } | ||
400 | } | 401 | } | ||
Context not available. | |||||
411 | 412 | | |||
412 | QDate MyMoneySchedule::nextPaymentDate(const bool& adjust, const QDate& refDate) const | 413 | QDate MyMoneySchedule::nextPaymentDate(const bool& adjust, const QDate& refDate) const | ||
413 | { | 414 | { | ||
414 | weekendOptionE option(adjust ? weekendOption() : | 415 | Schedule::WeekendOption option(adjust ? weekendOption() : | ||
415 | MyMoneySchedule::MoveNothing); | 416 | Schedule::WeekendOption::MoveNothing); | ||
416 | 417 | | |||
417 | QDate adjEndDate(adjustedDate(m_endDate, option)); | 418 | QDate adjEndDate(adjustedDate(m_endDate, option)); | ||
418 | 419 | | |||
Context not available. | |||||
428 | if (paymentDate.isValid() && | 429 | if (paymentDate.isValid() && | ||
429 | (paymentDate <= refDate || m_recordedPayments.contains(dueDate))) { | 430 | (paymentDate <= refDate || m_recordedPayments.contains(dueDate))) { | ||
430 | switch (m_occurrence) { | 431 | switch (m_occurrence) { | ||
431 | case OCCUR_ONCE: | 432 | case Schedule::Occurrence::Once: | ||
432 | // If the lastPayment is already set or the payment should have been | 433 | // If the lastPayment is already set or the payment should have been | ||
433 | // prior to the reference date then invalidate the payment date. | 434 | // prior to the reference date then invalidate the payment date. | ||
434 | if (m_lastPayment.isValid() || paymentDate <= refDate) | 435 | if (m_lastPayment.isValid() || paymentDate <= refDate) | ||
435 | paymentDate = QDate(); | 436 | paymentDate = QDate(); | ||
436 | break; | 437 | break; | ||
437 | 438 | | |||
438 | case OCCUR_DAILY: { | 439 | case Schedule::Occurrence::Daily: { | ||
439 | int step = m_occurrenceMultiplier; | 440 | int step = m_occurrenceMultiplier; | ||
440 | do { | 441 | do { | ||
441 | dueDate = dueDate.addDays(step); | 442 | dueDate = dueDate.addDays(step); | ||
Context not available. | |||||
446 | } | 447 | } | ||
447 | break; | 448 | break; | ||
448 | 449 | | |||
449 | case OCCUR_WEEKLY: { | 450 | case Schedule::Occurrence::Weekly: { | ||
450 | int step = 7 * m_occurrenceMultiplier; | 451 | int step = 7 * m_occurrenceMultiplier; | ||
451 | do { | 452 | do { | ||
452 | dueDate = dueDate.addDays(step); | 453 | dueDate = dueDate.addDays(step); | ||
Context not available. | |||||
457 | } | 458 | } | ||
458 | break; | 459 | break; | ||
459 | 460 | | |||
460 | case OCCUR_EVERYHALFMONTH: | 461 | case Schedule::Occurrence::EveryHalfMonth: | ||
461 | do { | 462 | do { | ||
462 | dueDate = addHalfMonths(dueDate, m_occurrenceMultiplier); | 463 | dueDate = addHalfMonths(dueDate, m_occurrenceMultiplier); | ||
463 | paymentDate = adjustedDate(dueDate, option); | 464 | paymentDate = adjustedDate(dueDate, option); | ||
Context not available. | |||||
466 | m_recordedPayments.contains(dueDate))); | 467 | m_recordedPayments.contains(dueDate))); | ||
467 | break; | 468 | break; | ||
468 | 469 | | |||
469 | case OCCUR_MONTHLY: | 470 | case Schedule::Occurrence::Monthly: | ||
470 | do { | 471 | do { | ||
471 | dueDate = dueDate.addMonths(m_occurrenceMultiplier); | 472 | dueDate = dueDate.addMonths(m_occurrenceMultiplier); | ||
472 | fixDate(dueDate); | 473 | fixDate(dueDate); | ||
Context not available. | |||||
476 | m_recordedPayments.contains(dueDate))); | 477 | m_recordedPayments.contains(dueDate))); | ||
477 | break; | 478 | break; | ||
478 | 479 | | |||
479 | case OCCUR_YEARLY: | 480 | case Schedule::Occurrence::Yearly: | ||
480 | do { | 481 | do { | ||
481 | dueDate = dueDate.addYears(m_occurrenceMultiplier); | 482 | dueDate = dueDate.addYears(m_occurrenceMultiplier); | ||
482 | fixDate(dueDate); | 483 | fixDate(dueDate); | ||
Context not available. | |||||
486 | m_recordedPayments.contains(dueDate))); | 487 | m_recordedPayments.contains(dueDate))); | ||
487 | break; | 488 | break; | ||
488 | 489 | | |||
489 | case OCCUR_ANY: | 490 | case Schedule::Occurrence::Any: | ||
490 | default: | 491 | default: | ||
491 | paymentDate = QDate(); | 492 | paymentDate = QDate(); | ||
492 | break; | 493 | break; | ||
Context not available. | |||||
503 | QDate paymentDate(nextDueDate()); | 504 | QDate paymentDate(nextDueDate()); | ||
504 | QList<QDate> theDates; | 505 | QList<QDate> theDates; | ||
505 | 506 | | |||
506 | weekendOptionE option(weekendOption()); | 507 | Schedule::WeekendOption option(weekendOption()); | ||
507 | 508 | | |||
508 | QDate endDate(_endDate); | 509 | QDate endDate(_endDate); | ||
509 | if (willEnd() && m_endDate < endDate) { | 510 | if (willEnd() && m_endDate < endDate) { | ||
Context not available. | |||||
521 | QDate date(adjustedDate(paymentDate, option)); | 522 | QDate date(adjustedDate(paymentDate, option)); | ||
522 | 523 | | |||
523 | switch (m_occurrence) { | 524 | switch (m_occurrence) { | ||
524 | case OCCUR_ONCE: | 525 | case Schedule::Occurrence::Once: | ||
525 | if (start_date >= _startDate && start_date <= endDate) | 526 | if (start_date >= _startDate && start_date <= endDate) | ||
526 | theDates.append(start_date); | 527 | theDates.append(start_date); | ||
527 | break; | 528 | break; | ||
528 | 529 | | |||
529 | case OCCUR_DAILY: | 530 | case Schedule::Occurrence::Daily: | ||
530 | while (date.isValid() && (date <= endDate)) { | 531 | while (date.isValid() && (date <= endDate)) { | ||
531 | if (date >= _startDate) | 532 | if (date >= _startDate) | ||
532 | theDates.append(date); | 533 | theDates.append(date); | ||
Context not available. | |||||
535 | } | 536 | } | ||
536 | break; | 537 | break; | ||
537 | 538 | | |||
538 | case OCCUR_WEEKLY: { | 539 | case Schedule::Occurrence::Weekly: { | ||
539 | int step = 7 * m_occurrenceMultiplier; | 540 | int step = 7 * m_occurrenceMultiplier; | ||
540 | while (date.isValid() && (date <= endDate)) { | 541 | while (date.isValid() && (date <= endDate)) { | ||
541 | if (date >= _startDate) | 542 | if (date >= _startDate) | ||
Context not available. | |||||
546 | } | 547 | } | ||
547 | break; | 548 | break; | ||
548 | 549 | | |||
549 | case OCCUR_EVERYHALFMONTH: | 550 | case Schedule::Occurrence::EveryHalfMonth: | ||
550 | while (date.isValid() && (date <= endDate)) { | 551 | while (date.isValid() && (date <= endDate)) { | ||
551 | if (date >= _startDate) | 552 | if (date >= _startDate) | ||
552 | theDates.append(date); | 553 | theDates.append(date); | ||
Context not available. | |||||
555 | } | 556 | } | ||
556 | break; | 557 | break; | ||
557 | 558 | | |||
558 | case OCCUR_MONTHLY: | 559 | case Schedule::Occurrence::Monthly: | ||
559 | while (date.isValid() && (date <= endDate)) { | 560 | while (date.isValid() && (date <= endDate)) { | ||
560 | if (date >= _startDate) | 561 | if (date >= _startDate) | ||
561 | theDates.append(date); | 562 | theDates.append(date); | ||
Context not available. | |||||
565 | } | 566 | } | ||
566 | break; | 567 | break; | ||
567 | 568 | | |||
568 | case OCCUR_YEARLY: | 569 | case Schedule::Occurrence::Yearly: | ||
569 | while (date.isValid() && (date <= endDate)) { | 570 | while (date.isValid() && (date <= endDate)) { | ||
570 | if (date >= _startDate) | 571 | if (date >= _startDate) | ||
571 | theDates.append(date); | 572 | theDates.append(date); | ||
Context not available. | |||||
575 | } | 576 | } | ||
576 | break; | 577 | break; | ||
577 | 578 | | |||
578 | case OCCUR_ANY: | 579 | case Schedule::Occurrence::Any: | ||
579 | default: | 580 | default: | ||
580 | break; | 581 | break; | ||
581 | } | 582 | } | ||
Context not available. | |||||
657 | return paymentDate; | 658 | return paymentDate; | ||
658 | 659 | | |||
659 | switch (m_occurrence) { | 660 | switch (m_occurrence) { | ||
660 | case OCCUR_ONCE: | 661 | case Schedule::Occurrence::Once: | ||
661 | break; | 662 | break; | ||
662 | 663 | | |||
663 | case OCCUR_DAILY: | 664 | case Schedule::Occurrence::Daily: | ||
664 | while (counter++ < transactions) | 665 | while (counter++ < transactions) | ||
665 | paymentDate = paymentDate.addDays(m_occurrenceMultiplier); | 666 | paymentDate = paymentDate.addDays(m_occurrenceMultiplier); | ||
666 | break; | 667 | break; | ||
667 | 668 | | |||
668 | case OCCUR_WEEKLY: { | 669 | case Schedule::Occurrence::Weekly: { | ||
669 | int step = 7 * m_occurrenceMultiplier; | 670 | int step = 7 * m_occurrenceMultiplier; | ||
670 | while (counter++ < transactions) | 671 | while (counter++ < transactions) | ||
671 | paymentDate = paymentDate.addDays(step); | 672 | paymentDate = paymentDate.addDays(step); | ||
672 | } | 673 | } | ||
673 | break; | 674 | break; | ||
674 | 675 | | |||
675 | case OCCUR_EVERYHALFMONTH: | 676 | case Schedule::Occurrence::EveryHalfMonth: | ||
676 | paymentDate = addHalfMonths(paymentDate, m_occurrenceMultiplier * (transactions - 1)); | 677 | paymentDate = addHalfMonths(paymentDate, m_occurrenceMultiplier * (transactions - 1)); | ||
677 | break; | 678 | break; | ||
678 | 679 | | |||
679 | case OCCUR_MONTHLY: | 680 | case Schedule::Occurrence::Monthly: | ||
680 | while (counter++ < transactions) | 681 | while (counter++ < transactions) | ||
681 | paymentDate = paymentDate.addMonths(m_occurrenceMultiplier); | 682 | paymentDate = paymentDate.addMonths(m_occurrenceMultiplier); | ||
682 | break; | 683 | break; | ||
683 | 684 | | |||
684 | case OCCUR_YEARLY: | 685 | case Schedule::Occurrence::Yearly: | ||
685 | while (counter++ < transactions) | 686 | while (counter++ < transactions) | ||
686 | paymentDate = paymentDate.addYears(m_occurrenceMultiplier); | 687 | paymentDate = paymentDate.addYears(m_occurrenceMultiplier); | ||
687 | break; | 688 | break; | ||
688 | 689 | | |||
689 | case OCCUR_ANY: | 690 | case Schedule::Occurrence::Any: | ||
690 | default: | 691 | default: | ||
691 | break; | 692 | break; | ||
692 | } | 693 | } | ||
Context not available. | |||||
718 | } | 719 | } | ||
719 | 720 | | |||
720 | // Check to see if its a once off payment | 721 | // Check to see if its a once off payment | ||
721 | if (m_occurrence == MyMoneySchedule::OCCUR_ONCE) | 722 | if (m_occurrence == Schedule::Occurrence::Once) | ||
722 | return true; | 723 | return true; | ||
723 | 724 | | |||
724 | return false; | 725 | return false; | ||
Context not available. | |||||
741 | m_recordedPayments.append(date); | 742 | m_recordedPayments.append(date); | ||
742 | } | 743 | } | ||
743 | 744 | | |||
744 | void MyMoneySchedule::setWeekendOption(const weekendOptionE option) | 745 | void MyMoneySchedule::setWeekendOption(const Schedule::WeekendOption option) | ||
745 | { | 746 | { | ||
746 | // make sure only valid values are used. Invalid defaults to MoveNothing. | 747 | // make sure only valid values are used. Invalid defaults to MoveNothing. | ||
747 | switch (option) { | 748 | switch (option) { | ||
748 | case MoveBefore: | 749 | case Schedule::WeekendOption::MoveBefore: | ||
749 | case MoveAfter: | 750 | case Schedule::WeekendOption::MoveAfter: | ||
750 | m_weekendOption = option; | 751 | m_weekendOption = option; | ||
751 | break; | 752 | break; | ||
752 | 753 | | |||
753 | default: | 754 | default: | ||
754 | m_weekendOption = MoveNothing; | 755 | m_weekendOption = Schedule::WeekendOption::MoveNothing; | ||
755 | break; | 756 | break; | ||
756 | } | 757 | } | ||
757 | } | 758 | } | ||
Context not available. | |||||
773 | writeBaseXML(document, el); | 774 | writeBaseXML(document, el); | ||
774 | 775 | | |||
775 | el.setAttribute(getAttrName(anName), m_name); | 776 | el.setAttribute(getAttrName(anName), m_name); | ||
776 | el.setAttribute(getAttrName(anType), m_type); | 777 | el.setAttribute(getAttrName(anType), (int)m_type); | ||
777 | el.setAttribute(getAttrName(anOccurence), m_occurrence); // krazy:exclude=spelling | 778 | el.setAttribute(getAttrName(anOccurence), (int)m_occurrence); // krazy:exclude=spelling | ||
778 | el.setAttribute(getAttrName(anOccurenceMultiplier), m_occurrenceMultiplier); | 779 | el.setAttribute(getAttrName(anOccurenceMultiplier), m_occurrenceMultiplier); | ||
779 | el.setAttribute(getAttrName(anPaymentType), m_paymentType); | 780 | el.setAttribute(getAttrName(anPaymentType), (int)m_paymentType); | ||
780 | el.setAttribute(getAttrName(anStartDate), dateToString(m_startDate)); | 781 | el.setAttribute(getAttrName(anStartDate), dateToString(m_startDate)); | ||
781 | el.setAttribute(getAttrName(anEndDate), dateToString(m_endDate)); | 782 | el.setAttribute(getAttrName(anEndDate), dateToString(m_endDate)); | ||
782 | el.setAttribute(getAttrName(anFixed), m_fixed); | 783 | el.setAttribute(getAttrName(anFixed), m_fixed); | ||
783 | el.setAttribute(getAttrName(anAutoEnter), m_autoEnter); | 784 | el.setAttribute(getAttrName(anAutoEnter), m_autoEnter); | ||
784 | el.setAttribute(getAttrName(anLastPayment), dateToString(m_lastPayment)); | 785 | el.setAttribute(getAttrName(anLastPayment), dateToString(m_lastPayment)); | ||
785 | el.setAttribute(getAttrName(anWeekendOption), m_weekendOption); | 786 | el.setAttribute(getAttrName(anWeekendOption), (int)m_weekendOption); | ||
786 | 787 | | |||
787 | //store the payment history for this scheduled task. | 788 | //store the payment history for this scheduled task. | ||
788 | QList<QDate> payments = recordedPayments(); | 789 | QList<QDate> payments = recordedPayments(); | ||
Context not available. | |||||
811 | return occurrenceToString(occurrenceMultiplier(), occurrencePeriod()); | 812 | return occurrenceToString(occurrenceMultiplier(), occurrencePeriod()); | ||
812 | } | 813 | } | ||
813 | 814 | | |||
814 | QString MyMoneySchedule::occurrenceToString(occurrenceE occurrence) | 815 | QString MyMoneySchedule::occurrenceToString(Schedule::Occurrence occurrence) | ||
815 | { | 816 | { | ||
816 | QString occurrenceString = I18N_NOOP2("Frequency of schedule", "Any"); | 817 | QString occurrenceString = I18N_NOOP2("Frequency of schedule", "Any"); | ||
817 | 818 | | |||
818 | if (occurrence == MyMoneySchedule::OCCUR_ONCE) | 819 | if (occurrence == Schedule::Occurrence::Once) | ||
819 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Once"); | 820 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Once"); | ||
820 | else if (occurrence == MyMoneySchedule::OCCUR_DAILY) | 821 | else if (occurrence == Schedule::Occurrence::Daily) | ||
821 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Daily"); | 822 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Daily"); | ||
822 | else if (occurrence == MyMoneySchedule::OCCUR_WEEKLY) | 823 | else if (occurrence == Schedule::Occurrence::Weekly) | ||
823 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Weekly"); | 824 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Weekly"); | ||
824 | else if (occurrence == MyMoneySchedule::OCCUR_FORTNIGHTLY) | 825 | else if (occurrence == Schedule::Occurrence::Fortnightly) | ||
825 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Fortnightly"); | 826 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Fortnightly"); | ||
826 | else if (occurrence == MyMoneySchedule::OCCUR_EVERYOTHERWEEK) | 827 | else if (occurrence == Schedule::Occurrence::EveryOtherWeek) | ||
827 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every other week"); | 828 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every other week"); | ||
828 | else if (occurrence == MyMoneySchedule::OCCUR_EVERYHALFMONTH) | 829 | else if (occurrence == Schedule::Occurrence::EveryHalfMonth) | ||
829 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every half month"); | 830 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every half month"); | ||
830 | else if (occurrence == MyMoneySchedule::OCCUR_EVERYTHREEWEEKS) | 831 | else if (occurrence == Schedule::Occurrence::EveryThreeWeeks) | ||
831 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every three weeks"); | 832 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every three weeks"); | ||
832 | else if (occurrence == MyMoneySchedule::OCCUR_EVERYFOURWEEKS) | 833 | else if (occurrence == Schedule::Occurrence::EveryFourWeeks) | ||
833 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every four weeks"); | 834 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every four weeks"); | ||
834 | else if (occurrence == MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS) | 835 | else if (occurrence == Schedule::Occurrence::EveryThirtyDays) | ||
835 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every thirty days"); | 836 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every thirty days"); | ||
836 | else if (occurrence == MyMoneySchedule::OCCUR_MONTHLY) | 837 | else if (occurrence == Schedule::Occurrence::Monthly) | ||
837 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Monthly"); | 838 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Monthly"); | ||
838 | else if (occurrence == MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS) | 839 | else if (occurrence == Schedule::Occurrence::EveryEightWeeks) | ||
839 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every eight weeks"); | 840 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every eight weeks"); | ||
840 | else if (occurrence == MyMoneySchedule::OCCUR_EVERYOTHERMONTH) | 841 | else if (occurrence == Schedule::Occurrence::EveryOtherMonth) | ||
841 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every two months"); | 842 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every two months"); | ||
842 | else if (occurrence == MyMoneySchedule::OCCUR_EVERYTHREEMONTHS) | 843 | else if (occurrence == Schedule::Occurrence::EveryThreeMonths) | ||
843 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every three months"); | 844 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every three months"); | ||
844 | else if (occurrence == MyMoneySchedule::OCCUR_QUARTERLY) | 845 | else if (occurrence == Schedule::Occurrence::Quarterly) | ||
845 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Quarterly"); | 846 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Quarterly"); | ||
846 | else if (occurrence == MyMoneySchedule::OCCUR_EVERYFOURMONTHS) | 847 | else if (occurrence == Schedule::Occurrence::EveryFourMonths) | ||
847 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every four months"); | 848 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every four months"); | ||
848 | else if (occurrence == MyMoneySchedule::OCCUR_TWICEYEARLY) | 849 | else if (occurrence == Schedule::Occurrence::TwiceYearly) | ||
849 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Twice yearly"); | 850 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Twice yearly"); | ||
850 | else if (occurrence == MyMoneySchedule::OCCUR_YEARLY) | 851 | else if (occurrence == Schedule::Occurrence::Yearly) | ||
851 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Yearly"); | 852 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Yearly"); | ||
852 | else if (occurrence == MyMoneySchedule::OCCUR_EVERYOTHERYEAR) | 853 | else if (occurrence == Schedule::Occurrence::EveryOtherYear) | ||
853 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every other year"); | 854 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every other year"); | ||
854 | return occurrenceString; | 855 | return occurrenceString; | ||
855 | } | 856 | } | ||
856 | 857 | | |||
857 | QString MyMoneySchedule::occurrenceToString(int mult, occurrenceE type) | 858 | QString MyMoneySchedule::occurrenceToString(int mult, Schedule::Occurrence type) | ||
858 | { | 859 | { | ||
859 | QString occurrenceString = I18N_NOOP2("Frequency of schedule", "Any"); | 860 | QString occurrenceString = I18N_NOOP2("Frequency of schedule", "Any"); | ||
860 | 861 | | |||
861 | if (type == MyMoneySchedule::OCCUR_ONCE) | 862 | if (type == Schedule::Occurrence::Once) | ||
862 | switch (mult) { | 863 | switch (mult) { | ||
863 | case 1: | 864 | case 1: | ||
864 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Once"); | 865 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Once"); | ||
Context not available. | |||||
866 | default: | 867 | default: | ||
867 | occurrenceString = I18N_NOOP2("Frequency of schedule", QString("%1 times").arg(mult)); | 868 | occurrenceString = I18N_NOOP2("Frequency of schedule", QString("%1 times").arg(mult)); | ||
868 | } | 869 | } | ||
869 | else if (type == MyMoneySchedule::OCCUR_DAILY) | 870 | else if (type == Schedule::Occurrence::Daily) | ||
870 | switch (mult) { | 871 | switch (mult) { | ||
871 | case 1: | 872 | case 1: | ||
872 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Daily"); | 873 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Daily"); | ||
Context not available. | |||||
877 | default: | 878 | default: | ||
878 | occurrenceString = I18N_NOOP2("Frequency of schedule", QString("Every %1 days").arg(mult)); | 879 | occurrenceString = I18N_NOOP2("Frequency of schedule", QString("Every %1 days").arg(mult)); | ||
879 | } | 880 | } | ||
880 | else if (type == MyMoneySchedule::OCCUR_WEEKLY) | 881 | else if (type == Schedule::Occurrence::Weekly) | ||
881 | switch (mult) { | 882 | switch (mult) { | ||
882 | case 1: | 883 | case 1: | ||
883 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Weekly"); | 884 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Weekly"); | ||
Context not available. | |||||
897 | default: | 898 | default: | ||
898 | occurrenceString = I18N_NOOP2("Frequency of schedule", QString("Every %1 weeks").arg(mult)); | 899 | occurrenceString = I18N_NOOP2("Frequency of schedule", QString("Every %1 weeks").arg(mult)); | ||
899 | } | 900 | } | ||
900 | else if (type == MyMoneySchedule::OCCUR_EVERYHALFMONTH) | 901 | else if (type == Schedule::Occurrence::EveryHalfMonth) | ||
901 | switch (mult) { | 902 | switch (mult) { | ||
902 | case 1: | 903 | case 1: | ||
903 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every half month"); | 904 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Every half month"); | ||
Context not available. | |||||
905 | default: | 906 | default: | ||
906 | occurrenceString = I18N_NOOP2("Frequency of schedule", QString("Every %1 half months").arg(mult)); | 907 | occurrenceString = I18N_NOOP2("Frequency of schedule", QString("Every %1 half months").arg(mult)); | ||
907 | } | 908 | } | ||
908 | else if (type == MyMoneySchedule::OCCUR_MONTHLY) | 909 | else if (type == Schedule::Occurrence::Monthly) | ||
909 | switch (mult) { | 910 | switch (mult) { | ||
910 | case 1: | 911 | case 1: | ||
911 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Monthly"); | 912 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Monthly"); | ||
Context not available. | |||||
925 | default: | 926 | default: | ||
926 | occurrenceString = I18N_NOOP2("Frequency of schedule", QString("Every %1 months").arg(mult)); | 927 | occurrenceString = I18N_NOOP2("Frequency of schedule", QString("Every %1 months").arg(mult)); | ||
927 | } | 928 | } | ||
928 | else if (type == MyMoneySchedule::OCCUR_YEARLY) | 929 | else if (type == Schedule::Occurrence::Yearly) | ||
929 | switch (mult) { | 930 | switch (mult) { | ||
930 | case 1: | 931 | case 1: | ||
931 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Yearly"); | 932 | occurrenceString = I18N_NOOP2("Frequency of schedule", "Yearly"); | ||
Context not available. | |||||
939 | return occurrenceString; | 940 | return occurrenceString; | ||
940 | } | 941 | } | ||
941 | 942 | | |||
942 | QString MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::occurrenceE type) | 943 | QString MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence type) | ||
943 | { | 944 | { | ||
944 | QString occurrenceString = I18N_NOOP2("Schedule occurrence period", "Any"); | 945 | QString occurrenceString = I18N_NOOP2("Schedule occurrence period", "Any"); | ||
945 | 946 | | |||
946 | if (type == MyMoneySchedule::OCCUR_ONCE) | 947 | if (type == Schedule::Occurrence::Once) | ||
947 | occurrenceString = I18N_NOOP2("Schedule occurrence period", "Once"); | 948 | occurrenceString = I18N_NOOP2("Schedule occurrence period", "Once"); | ||
948 | else if (type == MyMoneySchedule::OCCUR_DAILY) | 949 | else if (type == Schedule::Occurrence::Daily) | ||
949 | occurrenceString = I18N_NOOP2("Schedule occurrence period", "Day"); | 950 | occurrenceString = I18N_NOOP2("Schedule occurrence period", "Day"); | ||
950 | else if (type == MyMoneySchedule::OCCUR_WEEKLY) | 951 | else if (type == Schedule::Occurrence::Weekly) | ||
951 | occurrenceString = I18N_NOOP2("Schedule occurrence period", "Week"); | 952 | occurrenceString = I18N_NOOP2("Schedule occurrence period", "Week"); | ||
952 | else if (type == MyMoneySchedule::OCCUR_EVERYHALFMONTH) | 953 | else if (type == Schedule::Occurrence::EveryHalfMonth) | ||
953 | occurrenceString = I18N_NOOP2("Schedule occurrence period", "Half-month"); | 954 | occurrenceString = I18N_NOOP2("Schedule occurrence period", "Half-month"); | ||
954 | else if (type == MyMoneySchedule::OCCUR_MONTHLY) | 955 | else if (type == Schedule::Occurrence::Monthly) | ||
955 | occurrenceString = I18N_NOOP2("Schedule occurrence period", "Month"); | 956 | occurrenceString = I18N_NOOP2("Schedule occurrence period", "Month"); | ||
956 | else if (type == MyMoneySchedule::OCCUR_YEARLY) | 957 | else if (type == Schedule::Occurrence::Yearly) | ||
957 | occurrenceString = I18N_NOOP2("Schedule occurrence period", "Year"); | 958 | occurrenceString = I18N_NOOP2("Schedule occurrence period", "Year"); | ||
958 | return occurrenceString; | 959 | return occurrenceString; | ||
959 | } | 960 | } | ||
960 | 961 | | |||
961 | QString MyMoneySchedule::scheduleTypeToString(MyMoneySchedule::typeE type) | 962 | QString MyMoneySchedule::scheduleTypeToString(Schedule::Type type) | ||
962 | { | 963 | { | ||
963 | QString text; | 964 | QString text; | ||
964 | 965 | | |||
965 | switch (type) { | 966 | switch (type) { | ||
966 | case MyMoneySchedule::TYPE_BILL: | 967 | case Schedule::Type::Bill: | ||
967 | text = I18N_NOOP2("Scheduled transaction type", "Bill"); | 968 | text = I18N_NOOP2("Scheduled transaction type", "Bill"); | ||
968 | break; | 969 | break; | ||
969 | case MyMoneySchedule::TYPE_DEPOSIT: | 970 | case Schedule::Type::Deposit: | ||
970 | text = I18N_NOOP2("Scheduled transaction type", "Deposit"); | 971 | text = I18N_NOOP2("Scheduled transaction type", "Deposit"); | ||
971 | break; | 972 | break; | ||
972 | case MyMoneySchedule::TYPE_TRANSFER: | 973 | case Schedule::Type::Transfer: | ||
973 | text = I18N_NOOP2("Scheduled transaction type", "Transfer"); | 974 | text = I18N_NOOP2("Scheduled transaction type", "Transfer"); | ||
974 | break; | 975 | break; | ||
975 | case MyMoneySchedule::TYPE_LOANPAYMENT: | 976 | case Schedule::Type::LoanPayment: | ||
976 | text = I18N_NOOP2("Scheduled transaction type", "Loan payment"); | 977 | text = I18N_NOOP2("Scheduled transaction type", "Loan payment"); | ||
977 | break; | 978 | break; | ||
978 | case MyMoneySchedule::TYPE_ANY: | 979 | case Schedule::Type::Any: | ||
979 | default: | 980 | default: | ||
980 | text = I18N_NOOP2("Scheduled transaction type", "Unknown"); | 981 | text = I18N_NOOP2("Scheduled transaction type", "Unknown"); | ||
981 | } | 982 | } | ||
Context not available. | |||||
983 | } | 984 | } | ||
984 | 985 | | |||
985 | 986 | | |||
986 | QString MyMoneySchedule::paymentMethodToString(MyMoneySchedule::paymentTypeE paymentType) | 987 | QString MyMoneySchedule::paymentMethodToString(Schedule::PaymentType paymentType) | ||
987 | { | 988 | { | ||
988 | QString text; | 989 | QString text; | ||
989 | 990 | | |||
990 | switch (paymentType) { | 991 | switch (paymentType) { | ||
991 | case MyMoneySchedule::STYPE_DIRECTDEBIT: | 992 | case Schedule::PaymentType::DirectDebit: | ||
992 | text = I18N_NOOP2("Scheduled Transaction payment type", "Direct debit"); | 993 | text = I18N_NOOP2("Scheduled Transaction payment type", "Direct debit"); | ||
993 | break; | 994 | break; | ||
994 | case MyMoneySchedule::STYPE_DIRECTDEPOSIT: | 995 | case Schedule::PaymentType::DirectDeposit: | ||
995 | text = I18N_NOOP2("Scheduled Transaction payment type", "Direct deposit"); | 996 | text = I18N_NOOP2("Scheduled Transaction payment type", "Direct deposit"); | ||
996 | break; | 997 | break; | ||
997 | case MyMoneySchedule::STYPE_MANUALDEPOSIT: | 998 | case Schedule::PaymentType::ManualDeposit: | ||
998 | text = I18N_NOOP2("Scheduled Transaction payment type", "Manual deposit"); | 999 | text = I18N_NOOP2("Scheduled Transaction payment type", "Manual deposit"); | ||
999 | break; | 1000 | break; | ||
1000 | case MyMoneySchedule::STYPE_OTHER: | 1001 | case Schedule::PaymentType::Other: | ||
1001 | text = I18N_NOOP2("Scheduled Transaction payment type", "Other"); | 1002 | text = I18N_NOOP2("Scheduled Transaction payment type", "Other"); | ||
1002 | break; | 1003 | break; | ||
1003 | case MyMoneySchedule::STYPE_WRITECHEQUE: | 1004 | case Schedule::PaymentType::WriteChecque: | ||
1004 | text = I18N_NOOP2("Scheduled Transaction payment type", "Write check"); | 1005 | text = I18N_NOOP2("Scheduled Transaction payment type", "Write check"); | ||
1005 | break; | 1006 | break; | ||
1006 | case MyMoneySchedule::STYPE_STANDINGORDER: | 1007 | case Schedule::PaymentType::StandingOrder: | ||
1007 | text = I18N_NOOP2("Scheduled Transaction payment type", "Standing order"); | 1008 | text = I18N_NOOP2("Scheduled Transaction payment type", "Standing order"); | ||
1008 | break; | 1009 | break; | ||
1009 | case MyMoneySchedule::STYPE_BANKTRANSFER: | 1010 | case Schedule::PaymentType::BankTransfer: | ||
1010 | text = I18N_NOOP2("Scheduled Transaction payment type", "Bank transfer"); | 1011 | text = I18N_NOOP2("Scheduled Transaction payment type", "Bank transfer"); | ||
1011 | break; | 1012 | break; | ||
1012 | case MyMoneySchedule::STYPE_ANY: | 1013 | case Schedule::PaymentType::Any: | ||
1013 | text = I18N_NOOP2("Scheduled Transaction payment type", "Any (Error)"); | 1014 | text = I18N_NOOP2("Scheduled Transaction payment type", "Any (Error)"); | ||
1014 | break; | 1015 | break; | ||
1015 | } | 1016 | } | ||
1016 | return text; | 1017 | return text; | ||
1017 | } | 1018 | } | ||
1018 | 1019 | | |||
1019 | QString MyMoneySchedule::weekendOptionToString(MyMoneySchedule::weekendOptionE weekendOption) | 1020 | QString MyMoneySchedule::weekendOptionToString(Schedule::WeekendOption weekendOption) | ||
1020 | { | 1021 | { | ||
1021 | QString text; | 1022 | QString text; | ||
1022 | 1023 | | |||
1023 | switch (weekendOption) { | 1024 | switch (weekendOption) { | ||
1024 | case MyMoneySchedule::MoveBefore: | 1025 | case Schedule::WeekendOption::MoveBefore: | ||
1025 | text = I18N_NOOP("Change the date to the previous processing day"); | 1026 | text = I18N_NOOP("Change the date to the previous processing day"); | ||
1026 | break; | 1027 | break; | ||
1027 | case MyMoneySchedule::MoveAfter: | 1028 | case Schedule::WeekendOption::MoveAfter: | ||
1028 | text = I18N_NOOP("Change the date to the next processing day"); | 1029 | text = I18N_NOOP("Change the date to the next processing day"); | ||
1029 | break; | 1030 | break; | ||
1030 | case MyMoneySchedule::MoveNothing: | 1031 | case Schedule::WeekendOption::MoveNothing: | ||
1031 | text = I18N_NOOP("Do Nothing"); | 1032 | text = I18N_NOOP("Do Nothing"); | ||
1032 | break; | 1033 | break; | ||
1033 | } | 1034 | } | ||
Context not available. | |||||
1064 | #endif | 1065 | #endif | ||
1065 | } | 1066 | } | ||
1066 | 1067 | | |||
1067 | int MyMoneySchedule::eventsPerYear(MyMoneySchedule::occurrenceE occurrence) | 1068 | int MyMoneySchedule::eventsPerYear(Schedule::Occurrence occurrence) | ||
1068 | { | 1069 | { | ||
1069 | int rc = 0; | 1070 | int rc = 0; | ||
1070 | 1071 | | |||
1071 | switch (occurrence) { | 1072 | switch (occurrence) { | ||
1072 | case MyMoneySchedule::OCCUR_DAILY: | 1073 | case Schedule::Occurrence::Daily: | ||
1073 | rc = 365; | 1074 | rc = 365; | ||
1074 | break; | 1075 | break; | ||
1075 | case MyMoneySchedule::OCCUR_WEEKLY: | 1076 | case Schedule::Occurrence::Weekly: | ||
1076 | rc = 52; | 1077 | rc = 52; | ||
1077 | break; | 1078 | break; | ||
1078 | case MyMoneySchedule::OCCUR_FORTNIGHTLY: | 1079 | case Schedule::Occurrence::Fortnightly: | ||
1079 | rc = 26; | 1080 | rc = 26; | ||
1080 | break; | 1081 | break; | ||
1081 | case MyMoneySchedule::OCCUR_EVERYOTHERWEEK: | 1082 | case Schedule::Occurrence::EveryOtherWeek: | ||
1082 | rc = 26; | 1083 | rc = 26; | ||
1083 | break; | 1084 | break; | ||
1084 | case MyMoneySchedule::OCCUR_EVERYHALFMONTH: | 1085 | case Schedule::Occurrence::EveryHalfMonth: | ||
1085 | rc = 24; | 1086 | rc = 24; | ||
1086 | break; | 1087 | break; | ||
1087 | case MyMoneySchedule::OCCUR_EVERYTHREEWEEKS: | 1088 | case Schedule::Occurrence::EveryThreeWeeks: | ||
1088 | rc = 17; | 1089 | rc = 17; | ||
1089 | break; | 1090 | break; | ||
1090 | case MyMoneySchedule::OCCUR_EVERYFOURWEEKS: | 1091 | case Schedule::Occurrence::EveryFourWeeks: | ||
1091 | rc = 13; | 1092 | rc = 13; | ||
1092 | break; | 1093 | break; | ||
1093 | case MyMoneySchedule::OCCUR_MONTHLY: | 1094 | case Schedule::Occurrence::Monthly: | ||
1094 | case MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS: | 1095 | case Schedule::Occurrence::EveryThirtyDays: | ||
1095 | rc = 12; | 1096 | rc = 12; | ||
1096 | break; | 1097 | break; | ||
1097 | case MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS: | 1098 | case Schedule::Occurrence::EveryEightWeeks: | ||
1098 | rc = 6; | 1099 | rc = 6; | ||
1099 | break; | 1100 | break; | ||
1100 | case MyMoneySchedule::OCCUR_EVERYOTHERMONTH: | 1101 | case Schedule::Occurrence::EveryOtherMonth: | ||
1101 | rc = 6; | 1102 | rc = 6; | ||
1102 | break; | 1103 | break; | ||
1103 | case MyMoneySchedule::OCCUR_EVERYTHREEMONTHS: | 1104 | case Schedule::Occurrence::EveryThreeMonths: | ||
1104 | case MyMoneySchedule::OCCUR_QUARTERLY: | 1105 | case Schedule::Occurrence::Quarterly: | ||
1105 | rc = 4; | 1106 | rc = 4; | ||
1106 | break; | 1107 | break; | ||
1107 | case MyMoneySchedule::OCCUR_EVERYFOURMONTHS: | 1108 | case Schedule::Occurrence::EveryFourMonths: | ||
1108 | rc = 3; | 1109 | rc = 3; | ||
1109 | break; | 1110 | break; | ||
1110 | case MyMoneySchedule::OCCUR_TWICEYEARLY: | 1111 | case Schedule::Occurrence::TwiceYearly: | ||
1111 | rc = 2; | 1112 | rc = 2; | ||
1112 | break; | 1113 | break; | ||
1113 | case MyMoneySchedule::OCCUR_YEARLY: | 1114 | case Schedule::Occurrence::Yearly: | ||
1114 | rc = 1; | 1115 | rc = 1; | ||
1115 | break; | 1116 | break; | ||
1116 | default: | 1117 | default: | ||
Context not available. | |||||
1120 | return rc; | 1121 | return rc; | ||
1121 | } | 1122 | } | ||
1122 | 1123 | | |||
1123 | int MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::occurrenceE occurrence) | 1124 | int MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence occurrence) | ||
1124 | { | 1125 | { | ||
1125 | int rc = 0; | 1126 | int rc = 0; | ||
1126 | 1127 | | |||
1127 | switch (occurrence) { | 1128 | switch (occurrence) { | ||
1128 | case MyMoneySchedule::OCCUR_DAILY: | 1129 | case Schedule::Occurrence::Daily: | ||
1129 | rc = 1; | 1130 | rc = 1; | ||
1130 | break; | 1131 | break; | ||
1131 | case MyMoneySchedule::OCCUR_WEEKLY: | 1132 | case Schedule::Occurrence::Weekly: | ||
1132 | rc = 7; | 1133 | rc = 7; | ||
1133 | break; | 1134 | break; | ||
1134 | case MyMoneySchedule::OCCUR_FORTNIGHTLY: | 1135 | case Schedule::Occurrence::Fortnightly: | ||
1135 | rc = 14; | 1136 | rc = 14; | ||
1136 | break; | 1137 | break; | ||
1137 | case MyMoneySchedule::OCCUR_EVERYOTHERWEEK: | 1138 | case Schedule::Occurrence::EveryOtherWeek: | ||
1138 | rc = 14; | 1139 | rc = 14; | ||
1139 | break; | 1140 | break; | ||
1140 | case MyMoneySchedule::OCCUR_EVERYHALFMONTH: | 1141 | case Schedule::Occurrence::EveryHalfMonth: | ||
1141 | rc = 15; | 1142 | rc = 15; | ||
1142 | break; | 1143 | break; | ||
1143 | case MyMoneySchedule::OCCUR_EVERYTHREEWEEKS: | 1144 | case Schedule::Occurrence::EveryThreeWeeks: | ||
1144 | rc = 21; | 1145 | rc = 21; | ||
1145 | break; | 1146 | break; | ||
1146 | case MyMoneySchedule::OCCUR_EVERYFOURWEEKS: | 1147 | case Schedule::Occurrence::EveryFourWeeks: | ||
1147 | rc = 28; | 1148 | rc = 28; | ||
1148 | break; | 1149 | break; | ||
1149 | case MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS: | 1150 | case Schedule::Occurrence::EveryThirtyDays: | ||
1150 | rc = 30; | 1151 | rc = 30; | ||
1151 | break; | 1152 | break; | ||
1152 | case MyMoneySchedule::OCCUR_MONTHLY: | 1153 | case Schedule::Occurrence::Monthly: | ||
1153 | rc = 30; | 1154 | rc = 30; | ||
1154 | break; | 1155 | break; | ||
1155 | case MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS: | 1156 | case Schedule::Occurrence::EveryEightWeeks: | ||
1156 | rc = 56; | 1157 | rc = 56; | ||
1157 | break; | 1158 | break; | ||
1158 | case MyMoneySchedule::OCCUR_EVERYOTHERMONTH: | 1159 | case Schedule::Occurrence::EveryOtherMonth: | ||
1159 | rc = 60; | 1160 | rc = 60; | ||
1160 | break; | 1161 | break; | ||
1161 | case MyMoneySchedule::OCCUR_EVERYTHREEMONTHS: | 1162 | case Schedule::Occurrence::EveryThreeMonths: | ||
1162 | case MyMoneySchedule::OCCUR_QUARTERLY: | 1163 | case Schedule::Occurrence::Quarterly: | ||
1163 | rc = 90; | 1164 | rc = 90; | ||
1164 | break; | 1165 | break; | ||
1165 | case MyMoneySchedule::OCCUR_EVERYFOURMONTHS: | 1166 | case Schedule::Occurrence::EveryFourMonths: | ||
1166 | rc = 120; | 1167 | rc = 120; | ||
1167 | break; | 1168 | break; | ||
1168 | case MyMoneySchedule::OCCUR_TWICEYEARLY: | 1169 | case Schedule::Occurrence::TwiceYearly: | ||
1169 | rc = 180; | 1170 | rc = 180; | ||
1170 | break; | 1171 | break; | ||
1171 | case MyMoneySchedule::OCCUR_YEARLY: | 1172 | case Schedule::Occurrence::Yearly: | ||
1172 | rc = 360; | 1173 | rc = 360; | ||
1173 | break; | 1174 | break; | ||
1174 | default: | 1175 | default: | ||
Context not available. | |||||
1232 | * @param multiplier Returned by reference. Adjusted multiplier | 1233 | * @param multiplier Returned by reference. Adjusted multiplier | ||
1233 | * @param occurrence Returned by reference. Occurrence type | 1234 | * @param occurrence Returned by reference. Occurrence type | ||
1234 | */ | 1235 | */ | ||
1235 | void MyMoneySchedule::simpleToCompoundOccurrence(int& multiplier, occurrenceE& occurrence) | 1236 | void MyMoneySchedule::simpleToCompoundOccurrence(int& multiplier, Schedule::Occurrence& occurrence) | ||
1236 | { | 1237 | { | ||
1237 | occurrenceE newOcc = occurrence; | 1238 | Schedule::Occurrence newOcc = occurrence; | ||
1238 | int newMulti = 1; | 1239 | int newMulti = 1; | ||
1239 | if (occurrence == MyMoneySchedule::OCCUR_ONCE || | 1240 | if (occurrence == Schedule::Occurrence::Once || | ||
1240 | occurrence == MyMoneySchedule::OCCUR_DAILY || | 1241 | occurrence == Schedule::Occurrence::Daily || | ||
1241 | occurrence == MyMoneySchedule::OCCUR_WEEKLY || | 1242 | occurrence == Schedule::Occurrence::Weekly || | ||
1242 | occurrence == MyMoneySchedule::OCCUR_EVERYHALFMONTH || | 1243 | occurrence == Schedule::Occurrence::EveryHalfMonth || | ||
1243 | occurrence == MyMoneySchedule::OCCUR_MONTHLY || | 1244 | occurrence == Schedule::Occurrence::Monthly || | ||
1244 | occurrence == MyMoneySchedule::OCCUR_YEARLY) { // Already a base occurrence and multiplier | 1245 | occurrence == Schedule::Occurrence::Yearly) { // Already a base occurrence and multiplier | ||
1245 | } else if (occurrence == MyMoneySchedule::OCCUR_FORTNIGHTLY || | 1246 | } else if (occurrence == Schedule::Occurrence::Fortnightly || | ||
1246 | occurrence == MyMoneySchedule::OCCUR_EVERYOTHERWEEK) { | 1247 | occurrence == Schedule::Occurrence::EveryOtherWeek) { | ||
1247 | newOcc = MyMoneySchedule::OCCUR_WEEKLY; | 1248 | newOcc = Schedule::Occurrence::Weekly; | ||
1248 | newMulti = 2; | 1249 | newMulti = 2; | ||
1249 | } else if (occurrence == MyMoneySchedule::OCCUR_EVERYTHREEWEEKS) { | 1250 | } else if (occurrence == Schedule::Occurrence::EveryThreeWeeks) { | ||
1250 | newOcc = MyMoneySchedule::OCCUR_WEEKLY; | 1251 | newOcc = Schedule::Occurrence::Weekly; | ||
1251 | newMulti = 3; | 1252 | newMulti = 3; | ||
1252 | } else if (occurrence == MyMoneySchedule::OCCUR_EVERYFOURWEEKS) { | 1253 | } else if (occurrence == Schedule::Occurrence::EveryFourWeeks) { | ||
1253 | newOcc = MyMoneySchedule::OCCUR_WEEKLY; | 1254 | newOcc = Schedule::Occurrence::Weekly; | ||
1254 | newMulti = 4; | 1255 | newMulti = 4; | ||
1255 | } else if (occurrence == MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS) { | 1256 | } else if (occurrence == Schedule::Occurrence::EveryThirtyDays) { | ||
1256 | newOcc = MyMoneySchedule::OCCUR_DAILY; | 1257 | newOcc = Schedule::Occurrence::Daily; | ||
1257 | newMulti = 30; | 1258 | newMulti = 30; | ||
1258 | } else if (occurrence == MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS) { | 1259 | } else if (occurrence == Schedule::Occurrence::EveryEightWeeks) { | ||
1259 | newOcc = MyMoneySchedule::OCCUR_WEEKLY; | 1260 | newOcc = Schedule::Occurrence::Weekly; | ||
1260 | newMulti = 8; | 1261 | newMulti = 8; | ||
1261 | } else if (occurrence == MyMoneySchedule::OCCUR_EVERYOTHERMONTH) { | 1262 | } else if (occurrence == Schedule::Occurrence::EveryOtherMonth) { | ||
1262 | newOcc = MyMoneySchedule::OCCUR_MONTHLY; | 1263 | newOcc = Schedule::Occurrence::Monthly; | ||
1263 | newMulti = 2; | 1264 | newMulti = 2; | ||
1264 | } else if (occurrence == MyMoneySchedule::OCCUR_EVERYTHREEMONTHS || | 1265 | } else if (occurrence == Schedule::Occurrence::EveryThreeMonths || | ||
1265 | occurrence == MyMoneySchedule::OCCUR_QUARTERLY) { | 1266 | occurrence == Schedule::Occurrence::Quarterly) { | ||
1266 | newOcc = MyMoneySchedule::OCCUR_MONTHLY; | 1267 | newOcc = Schedule::Occurrence::Monthly; | ||
1267 | newMulti = 3; | 1268 | newMulti = 3; | ||
1268 | } else if (occurrence == MyMoneySchedule::OCCUR_EVERYFOURMONTHS) { | 1269 | } else if (occurrence == Schedule::Occurrence::EveryFourMonths) { | ||
1269 | newOcc = MyMoneySchedule::OCCUR_MONTHLY; | 1270 | newOcc = Schedule::Occurrence::Monthly; | ||
1270 | newMulti = 4; | 1271 | newMulti = 4; | ||
1271 | } else if (occurrence == MyMoneySchedule::OCCUR_TWICEYEARLY) { | 1272 | } else if (occurrence == Schedule::Occurrence::TwiceYearly) { | ||
1272 | newOcc = MyMoneySchedule::OCCUR_MONTHLY; | 1273 | newOcc = Schedule::Occurrence::Monthly; | ||
1273 | newMulti = 6; | 1274 | newMulti = 6; | ||
1274 | } else if (occurrence == MyMoneySchedule::OCCUR_EVERYOTHERYEAR) { | 1275 | } else if (occurrence == Schedule::Occurrence::EveryOtherYear) { | ||
1275 | newOcc = MyMoneySchedule::OCCUR_YEARLY; | 1276 | newOcc = Schedule::Occurrence::Yearly; | ||
1276 | newMulti = 2; | 1277 | newMulti = 2; | ||
1277 | } else { // Unknown | 1278 | } else { // Unknown | ||
1278 | newOcc = MyMoneySchedule::OCCUR_ANY; | 1279 | newOcc = Schedule::Occurrence::Any; | ||
1279 | newMulti = 1; | 1280 | newMulti = 1; | ||
1280 | } | 1281 | } | ||
1281 | if (newOcc != occurrence) { | 1282 | if (newOcc != occurrence) { | ||
Context not available. | |||||
1290 | * @param multiplier Returned by reference. Adjusted multiplier | 1291 | * @param multiplier Returned by reference. Adjusted multiplier | ||
1291 | * @param occurrence Returned by reference. Occurrence type | 1292 | * @param occurrence Returned by reference. Occurrence type | ||
1292 | */ | 1293 | */ | ||
1293 | void MyMoneySchedule::compoundToSimpleOccurrence(int& multiplier, occurrenceE& occurrence) | 1294 | void MyMoneySchedule::compoundToSimpleOccurrence(int& multiplier, Schedule::Occurrence& occurrence) | ||
1294 | { | 1295 | { | ||
1295 | occurrenceE newOcc = occurrence; | 1296 | Schedule::Occurrence newOcc = occurrence; | ||
1296 | if (occurrence == MyMoneySchedule::OCCUR_ONCE) { // Nothing to do | 1297 | if (occurrence == Schedule::Occurrence::Once) { // Nothing to do | ||
1297 | } else if (occurrence == MyMoneySchedule::OCCUR_DAILY) { | 1298 | } else if (occurrence == Schedule::Occurrence::Daily) { | ||
1298 | switch (multiplier) { | 1299 | switch (multiplier) { | ||
1299 | case 1: | 1300 | case 1: | ||
1300 | break; | 1301 | break; | ||
1301 | case 30: | 1302 | case 30: | ||
1302 | newOcc = MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS; | 1303 | newOcc = Schedule::Occurrence::EveryThirtyDays; | ||
1303 | break; | 1304 | break; | ||
1304 | } | 1305 | } | ||
1305 | } else if (newOcc == MyMoneySchedule::OCCUR_WEEKLY) { | 1306 | } else if (newOcc == Schedule::Occurrence::Weekly) { | ||
1306 | switch (multiplier) { | 1307 | switch (multiplier) { | ||
1307 | case 1: | 1308 | case 1: | ||
1308 | break; | 1309 | break; | ||
1309 | case 2: | 1310 | case 2: | ||
1310 | newOcc = MyMoneySchedule::OCCUR_EVERYOTHERWEEK; | 1311 | newOcc = Schedule::Occurrence::EveryOtherWeek; | ||
1311 | break; | 1312 | break; | ||
1312 | case 3: | 1313 | case 3: | ||
1313 | newOcc = MyMoneySchedule::OCCUR_EVERYTHREEWEEKS; | 1314 | newOcc = Schedule::Occurrence::EveryThreeWeeks; | ||
1314 | break; | 1315 | break; | ||
1315 | case 4: | 1316 | case 4: | ||
1316 | newOcc = MyMoneySchedule::OCCUR_EVERYFOURWEEKS; | 1317 | newOcc = Schedule::Occurrence::EveryFourWeeks; | ||
1317 | break; | 1318 | break; | ||
1318 | case 8: | 1319 | case 8: | ||
1319 | newOcc = MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS; | 1320 | newOcc = Schedule::Occurrence::EveryEightWeeks; | ||
1320 | break; | 1321 | break; | ||
1321 | } | 1322 | } | ||
1322 | } else if (occurrence == MyMoneySchedule::OCCUR_MONTHLY) | 1323 | } else if (occurrence == Schedule::Occurrence::Monthly) | ||
1323 | switch (multiplier) { | 1324 | switch (multiplier) { | ||
1324 | case 1: | 1325 | case 1: | ||
1325 | break; | 1326 | break; | ||
1326 | case 2: | 1327 | case 2: | ||
1327 | newOcc = MyMoneySchedule::OCCUR_EVERYOTHERMONTH; | 1328 | newOcc = Schedule::Occurrence::EveryOtherMonth; | ||
1328 | break; | 1329 | break; | ||
1329 | case 3: | 1330 | case 3: | ||
1330 | newOcc = MyMoneySchedule::OCCUR_EVERYTHREEMONTHS; | 1331 | newOcc = Schedule::Occurrence::EveryThreeMonths; | ||
1331 | break; | 1332 | break; | ||
1332 | case 4: | 1333 | case 4: | ||
1333 | newOcc = MyMoneySchedule::OCCUR_EVERYFOURMONTHS; | 1334 | newOcc = Schedule::Occurrence::EveryFourMonths; | ||
1334 | break; | 1335 | break; | ||
1335 | case 6: | 1336 | case 6: | ||
1336 | newOcc = MyMoneySchedule::OCCUR_TWICEYEARLY; | 1337 | newOcc = Schedule::Occurrence::TwiceYearly; | ||
1337 | break; | 1338 | break; | ||
1338 | } | 1339 | } | ||
1339 | else if (occurrence == MyMoneySchedule::OCCUR_EVERYHALFMONTH) | 1340 | else if (occurrence == Schedule::Occurrence::EveryHalfMonth) | ||
1340 | switch (multiplier) { | 1341 | switch (multiplier) { | ||
1341 | case 1: | 1342 | case 1: | ||
1342 | break; | 1343 | break; | ||
1343 | } | 1344 | } | ||
1344 | else if (occurrence == MyMoneySchedule::OCCUR_YEARLY) { | 1345 | else if (occurrence == Schedule::Occurrence::Yearly) { | ||
1345 | switch (multiplier) { | 1346 | switch (multiplier) { | ||
1346 | case 1: | 1347 | case 1: | ||
1347 | break; | 1348 | break; | ||
1348 | case 2: | 1349 | case 2: | ||
1349 | newOcc = MyMoneySchedule::OCCUR_EVERYOTHERYEAR; | 1350 | newOcc = Schedule::Occurrence::EveryOtherYear; | ||
1350 | break; | 1351 | break; | ||
1351 | } | 1352 | } | ||
1352 | } | 1353 | } | ||
Context not available. |