Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/tests/mymoneyschedule-test.cpp
Context not available. | |||||
29 | 29 | | |||
---|---|---|---|---|---|
30 | QTEST_GUILESS_MAIN(MyMoneyScheduleTest) | 30 | QTEST_GUILESS_MAIN(MyMoneyScheduleTest) | ||
31 | 31 | | |||
32 | using namespace eMyMoney; | ||||
33 | | ||||
32 | void MyMoneyScheduleTest::testEmptyConstructor() | 34 | void MyMoneyScheduleTest::testEmptyConstructor() | ||
33 | { | 35 | { | ||
34 | MyMoneySchedule s; | 36 | MyMoneySchedule s; | ||
35 | 37 | | |||
36 | QCOMPARE(s.id().isEmpty(), true); | 38 | QCOMPARE(s.id().isEmpty(), true); | ||
37 | QCOMPARE(s.m_occurrence, MyMoneySchedule::OCCUR_ANY); | 39 | QCOMPARE(s.m_occurrence, Schedule::Occurrence::Any); | ||
38 | QCOMPARE(s.m_type, MyMoneySchedule::TYPE_ANY); | 40 | QCOMPARE(s.m_type, Schedule::Type::Any); | ||
39 | QCOMPARE(s.m_paymentType, MyMoneySchedule::STYPE_ANY); | 41 | QCOMPARE(s.m_paymentType, Schedule::PaymentType::Any); | ||
40 | QCOMPARE(s.m_fixed, false); | 42 | QCOMPARE(s.m_fixed, false); | ||
41 | QCOMPARE(!s.m_startDate.isValid(), true); | 43 | QCOMPARE(!s.m_startDate.isValid(), true); | ||
42 | QCOMPARE(!s.m_endDate.isValid(), true); | 44 | QCOMPARE(!s.m_endDate.isValid(), true); | ||
Context not available. | |||||
49 | void MyMoneyScheduleTest::testConstructor() | 51 | void MyMoneyScheduleTest::testConstructor() | ||
50 | { | 52 | { | ||
51 | MyMoneySchedule s("A Name", | 53 | MyMoneySchedule s("A Name", | ||
52 | MyMoneySchedule::TYPE_BILL, | 54 | Schedule::Type::Bill, | ||
53 | MyMoneySchedule::OCCUR_WEEKLY, 1, | 55 | Schedule::Occurrence::Weekly, 1, | ||
54 | MyMoneySchedule::STYPE_DIRECTDEBIT, | 56 | Schedule::PaymentType::DirectDebit, | ||
55 | QDate::currentDate(), | 57 | QDate::currentDate(), | ||
56 | QDate(), | 58 | QDate(), | ||
57 | true, | 59 | true, | ||
58 | true); | 60 | true); | ||
59 | 61 | | |||
60 | QCOMPARE(s.type(), MyMoneySchedule::TYPE_BILL); | 62 | QCOMPARE(s.type(), Schedule::Type::Bill); | ||
61 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_WEEKLY); | 63 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Weekly); | ||
62 | QCOMPARE(s.occurrenceMultiplier(), 1); | 64 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
63 | QCOMPARE(s.paymentType(), MyMoneySchedule::STYPE_DIRECTDEBIT); | 65 | QCOMPARE(s.paymentType(), Schedule::PaymentType::DirectDebit); | ||
64 | QCOMPARE(s.startDate(), QDate()); | 66 | QCOMPARE(s.startDate(), QDate()); | ||
65 | QCOMPARE(s.willEnd(), false); | 67 | QCOMPARE(s.willEnd(), false); | ||
66 | QCOMPARE(s.isFixed(), true); | 68 | QCOMPARE(s.isFixed(), true); | ||
Context not available. | |||||
77 | s.setId("SCHED001"); | 79 | s.setId("SCHED001"); | ||
78 | QCOMPARE(s.id(), QLatin1String("SCHED001")); | 80 | QCOMPARE(s.id(), QLatin1String("SCHED001")); | ||
79 | 81 | | |||
80 | s.setType(MyMoneySchedule::TYPE_BILL); | 82 | s.setType(Schedule::Type::Bill); | ||
81 | QCOMPARE(s.type(), MyMoneySchedule::TYPE_BILL); | 83 | QCOMPARE(s.type(), Schedule::Type::Bill); | ||
82 | 84 | | |||
83 | s.setEndDate(QDate::currentDate()); | 85 | s.setEndDate(QDate::currentDate()); | ||
84 | QCOMPARE(s.endDate(), QDate::currentDate()); | 86 | QCOMPARE(s.endDate(), QDate::currentDate()); | ||
Context not available. | |||||
90 | MyMoneySchedule s; | 92 | MyMoneySchedule s; | ||
91 | 93 | | |||
92 | s.setId("SCHED001"); | 94 | s.setId("SCHED001"); | ||
93 | s.setType(MyMoneySchedule::TYPE_BILL); | 95 | s.setType(Schedule::Type::Bill); | ||
94 | 96 | | |||
95 | MyMoneySchedule s2(s); | 97 | MyMoneySchedule s2(s); | ||
96 | 98 | | |||
Context not available. | |||||
103 | MyMoneySchedule s; | 105 | MyMoneySchedule s; | ||
104 | 106 | | |||
105 | s.setId("SCHED001"); | 107 | s.setId("SCHED001"); | ||
106 | s.setType(MyMoneySchedule::TYPE_BILL); | 108 | s.setType(Schedule::Type::Bill); | ||
107 | 109 | | |||
108 | MyMoneySchedule s2 = s; | 110 | MyMoneySchedule s2 = s; | ||
109 | 111 | | |||
Context not available. | |||||
263 | void MyMoneyScheduleTest::testAddHalfMonths() | 265 | void MyMoneyScheduleTest::testAddHalfMonths() | ||
264 | { | 266 | { | ||
265 | // addHalfMonths is private | 267 | // addHalfMonths is private | ||
266 | // Test a Schedule with occurrence OCCUR_EVERYHALFMONTH using nextPayment | 268 | // Test a Schedule with occurrence EveryHalfMonth using nextPayment | ||
267 | MyMoneySchedule s; | 269 | MyMoneySchedule s; | ||
268 | s.setStartDate(QDate(2007, 1, 1)); | 270 | s.setStartDate(QDate(2007, 1, 1)); | ||
269 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYHALFMONTH); | 271 | s.setOccurrence(Schedule::Occurrence::EveryHalfMonth); | ||
270 | s.setNextDueDate(s.startDate()); | 272 | s.setNextDueDate(s.startDate()); | ||
271 | s.setLastPayment(s.startDate()); | 273 | s.setLastPayment(s.startDate()); | ||
272 | 274 | | |||
Context not available. | |||||
455 | // Add tests for each possible occurrence. | 457 | // Add tests for each possible occurrence. | ||
456 | // Check how paymentDates is meant to work | 458 | // Check how paymentDates is meant to work | ||
457 | // Build a list of expected dates and compare | 459 | // Build a list of expected dates and compare | ||
458 | // MyMoneySchedule::OCCUR_ONCE | 460 | // Schedule::Occurrence::Once | ||
459 | sch.setOccurrence(MyMoneySchedule::OCCUR_ONCE); | 461 | sch.setOccurrence(Schedule::Occurrence::Once); | ||
460 | startDate.setDate(2009, 1, 1); | 462 | startDate.setDate(2009, 1, 1); | ||
461 | endDate.setDate(2009, 12, 31); | 463 | endDate.setDate(2009, 12, 31); | ||
462 | sch.setStartDate(startDate); | 464 | sch.setStartDate(startDate); | ||
Context not available. | |||||
464 | list = sch.paymentDates(startDate, endDate); | 466 | list = sch.paymentDates(startDate, endDate); | ||
465 | QVERIFY(list.count() == 1); | 467 | QVERIFY(list.count() == 1); | ||
466 | QVERIFY(list[0] == QDate(2009, 1, 1)); | 468 | QVERIFY(list[0] == QDate(2009, 1, 1)); | ||
467 | // MyMoneySchedule::OCCUR_DAILY | 469 | // Schedule::Occurrence::Daily | ||
468 | sch.setOccurrence(MyMoneySchedule::OCCUR_DAILY); | 470 | sch.setOccurrence(Schedule::Occurrence::Daily); | ||
469 | startDate.setDate(2009, 1, 1); | 471 | startDate.setDate(2009, 1, 1); | ||
470 | endDate.setDate(2009, 1, 5); | 472 | endDate.setDate(2009, 1, 5); | ||
471 | sch.setStartDate(startDate); | 473 | sch.setStartDate(startDate); | ||
Context not available. | |||||
479 | // Would fall on Sunday so gets moved to 2nd. | 481 | // Would fall on Sunday so gets moved to 2nd. | ||
480 | QVERIFY(list[3] == QDate(2009, 1, 2)); | 482 | QVERIFY(list[3] == QDate(2009, 1, 2)); | ||
481 | QVERIFY(list[4] == QDate(2009, 1, 5)); | 483 | QVERIFY(list[4] == QDate(2009, 1, 5)); | ||
482 | // MyMoneySchedule::OCCUR_DAILY with multiplier 2 | 484 | // Schedule::Occurrence::Daily with multiplier 2 | ||
483 | sch.setOccurrenceMultiplier(2); | 485 | sch.setOccurrenceMultiplier(2); | ||
484 | list = sch.paymentDates(startDate.addDays(1), endDate); | 486 | list = sch.paymentDates(startDate.addDays(1), endDate); | ||
485 | QVERIFY(list.count() == 2); | 487 | QVERIFY(list.count() == 2); | ||
Context not available. | |||||
487 | QVERIFY(list[0] == QDate(2009, 1, 2)); | 489 | QVERIFY(list[0] == QDate(2009, 1, 2)); | ||
488 | QVERIFY(list[1] == QDate(2009, 1, 5)); | 490 | QVERIFY(list[1] == QDate(2009, 1, 5)); | ||
489 | sch.setOccurrenceMultiplier(1); | 491 | sch.setOccurrenceMultiplier(1); | ||
490 | // MyMoneySchedule::OCCUR_WEEKLY | 492 | // Schedule::Occurrence::Weekly | ||
491 | sch.setOccurrence(MyMoneySchedule::OCCUR_WEEKLY); | 493 | sch.setOccurrence(Schedule::Occurrence::Weekly); | ||
492 | startDate.setDate(2009, 1, 6); | 494 | startDate.setDate(2009, 1, 6); | ||
493 | endDate.setDate(2009, 2, 4); | 495 | endDate.setDate(2009, 2, 4); | ||
494 | sch.setStartDate(startDate); | 496 | sch.setStartDate(startDate); | ||
Context not available. | |||||
500 | QVERIFY(list[2] == QDate(2009, 1, 20)); | 502 | QVERIFY(list[2] == QDate(2009, 1, 20)); | ||
501 | QVERIFY(list[3] == QDate(2009, 1, 27)); | 503 | QVERIFY(list[3] == QDate(2009, 1, 27)); | ||
502 | QVERIFY(list[4] == QDate(2009, 2, 3)); | 504 | QVERIFY(list[4] == QDate(2009, 2, 3)); | ||
503 | // MyMoneySchedule::OCCUR_EVERYOTHERWEEK | 505 | // Schedule::Occurrence::EveryOtherWeek | ||
504 | sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERWEEK); | 506 | sch.setOccurrence(Schedule::Occurrence::EveryOtherWeek); | ||
505 | startDate.setDate(2009, 2, 5); | 507 | startDate.setDate(2009, 2, 5); | ||
506 | endDate.setDate(2009, 4, 3); | 508 | endDate.setDate(2009, 4, 3); | ||
507 | sch.setStartDate(startDate); | 509 | sch.setStartDate(startDate); | ||
Context not available. | |||||
513 | QVERIFY(list[2] == QDate(2009, 3, 5)); | 515 | QVERIFY(list[2] == QDate(2009, 3, 5)); | ||
514 | QVERIFY(list[3] == QDate(2009, 3, 19)); | 516 | QVERIFY(list[3] == QDate(2009, 3, 19)); | ||
515 | QVERIFY(list[4] == QDate(2009, 4, 2)); | 517 | QVERIFY(list[4] == QDate(2009, 4, 2)); | ||
516 | // MyMoneySchedule::OCCUR_FORTNIGHTLY | 518 | // Schedule::Occurrence::Fortnightly | ||
517 | sch.setOccurrence(MyMoneySchedule::OCCUR_FORTNIGHTLY); | 519 | sch.setOccurrence(Schedule::Occurrence::Fortnightly); | ||
518 | startDate.setDate(2009, 4, 4); | 520 | startDate.setDate(2009, 4, 4); | ||
519 | endDate.setDate(2009, 5, 31); | 521 | endDate.setDate(2009, 5, 31); | ||
520 | sch.setStartDate(startDate); | 522 | sch.setStartDate(startDate); | ||
Context not available. | |||||
531 | QVERIFY(list[2] == QDate(2009, 5, 15)); | 533 | QVERIFY(list[2] == QDate(2009, 5, 15)); | ||
532 | // Would fall on a Saturday so gets moved to 29th. | 534 | // Would fall on a Saturday so gets moved to 29th. | ||
533 | QVERIFY(list[3] == QDate(2009, 5, 29)); | 535 | QVERIFY(list[3] == QDate(2009, 5, 29)); | ||
534 | // MyMoneySchedule::OCCUR_EVERYHALFMONTH | 536 | // Schedule::Occurrence::EveryHalfMonth | ||
535 | sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYHALFMONTH); | 537 | sch.setOccurrence(Schedule::Occurrence::EveryHalfMonth); | ||
536 | startDate.setDate(2009, 6, 1); | 538 | startDate.setDate(2009, 6, 1); | ||
537 | endDate.setDate(2009, 8, 11); | 539 | endDate.setDate(2009, 8, 11); | ||
538 | sch.setStartDate(startDate); | 540 | sch.setStartDate(startDate); | ||
Context not available. | |||||
545 | QVERIFY(list[3] == QDate(2009, 7, 16)); | 547 | QVERIFY(list[3] == QDate(2009, 7, 16)); | ||
546 | // Would fall on a Saturday so gets moved to 31st. | 548 | // Would fall on a Saturday so gets moved to 31st. | ||
547 | QVERIFY(list[4] == QDate(2009, 7, 31)); | 549 | QVERIFY(list[4] == QDate(2009, 7, 31)); | ||
548 | // MyMoneySchedule::OCCUR_EVERYTHREEWEEKS | 550 | // Schedule::Occurrence::EveryThreeWeeks | ||
549 | sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS); | 551 | sch.setOccurrence(Schedule::Occurrence::EveryThreeWeeks); | ||
550 | startDate.setDate(2009, 8, 12); | 552 | startDate.setDate(2009, 8, 12); | ||
551 | endDate.setDate(2009, 11, 12); | 553 | endDate.setDate(2009, 11, 12); | ||
552 | sch.setStartDate(startDate); | 554 | sch.setStartDate(startDate); | ||
Context not available. | |||||
558 | QVERIFY(list[2] == QDate(2009, 9, 23)); | 560 | QVERIFY(list[2] == QDate(2009, 9, 23)); | ||
559 | QVERIFY(list[3] == QDate(2009, 10, 14)); | 561 | QVERIFY(list[3] == QDate(2009, 10, 14)); | ||
560 | QVERIFY(list[4] == QDate(2009, 11, 4)); | 562 | QVERIFY(list[4] == QDate(2009, 11, 4)); | ||
561 | // MyMoneySchedule::OCCUR_EVERYFOURWEEKS | 563 | // Schedule::Occurrence::EveryFourWeeks | ||
562 | sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYFOURWEEKS); | 564 | sch.setOccurrence(Schedule::Occurrence::EveryFourWeeks); | ||
563 | startDate.setDate(2009, 11, 13); | 565 | startDate.setDate(2009, 11, 13); | ||
564 | endDate.setDate(2010, 3, 13); | 566 | endDate.setDate(2010, 3, 13); | ||
565 | sch.setStartDate(startDate); | 567 | sch.setStartDate(startDate); | ||
Context not available. | |||||
571 | QVERIFY(list[2] == QDate(2010, 1, 8)); | 573 | QVERIFY(list[2] == QDate(2010, 1, 8)); | ||
572 | QVERIFY(list[3] == QDate(2010, 2, 5)); | 574 | QVERIFY(list[3] == QDate(2010, 2, 5)); | ||
573 | QVERIFY(list[4] == QDate(2010, 3, 5)); | 575 | QVERIFY(list[4] == QDate(2010, 3, 5)); | ||
574 | // MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS | 576 | // Schedule::Occurrence::EveryThirtyDays | ||
575 | sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS); | 577 | sch.setOccurrence(Schedule::Occurrence::EveryThirtyDays); | ||
576 | startDate.setDate(2010, 3, 19); | 578 | startDate.setDate(2010, 3, 19); | ||
577 | endDate.setDate(2010, 7, 19); | 579 | endDate.setDate(2010, 7, 19); | ||
578 | sch.setStartDate(startDate); | 580 | sch.setStartDate(startDate); | ||
Context not available. | |||||
586 | QVERIFY(list[3] == QDate(2010, 6, 17)); | 588 | QVERIFY(list[3] == QDate(2010, 6, 17)); | ||
587 | // Would fall on a Saturday so gets moved to 16th. | 589 | // Would fall on a Saturday so gets moved to 16th. | ||
588 | QVERIFY(list[4] == QDate(2010, 7, 16)); | 590 | QVERIFY(list[4] == QDate(2010, 7, 16)); | ||
589 | // MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS | 591 | // Schedule::Occurrence::EveryEightWeeks | ||
590 | sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS); | 592 | sch.setOccurrence(Schedule::Occurrence::EveryEightWeeks); | ||
591 | startDate.setDate(2010, 7, 26); | 593 | startDate.setDate(2010, 7, 26); | ||
592 | endDate.setDate(2011, 3, 26); | 594 | endDate.setDate(2011, 3, 26); | ||
593 | sch.setStartDate(startDate); | 595 | sch.setStartDate(startDate); | ||
Context not available. | |||||
599 | QVERIFY(list[2] == QDate(2010, 11, 15)); | 601 | QVERIFY(list[2] == QDate(2010, 11, 15)); | ||
600 | QVERIFY(list[3] == QDate(2011, 1, 10)); | 602 | QVERIFY(list[3] == QDate(2011, 1, 10)); | ||
601 | QVERIFY(list[4] == QDate(2011, 3, 7)); | 603 | QVERIFY(list[4] == QDate(2011, 3, 7)); | ||
602 | // MyMoneySchedule::OCCUR_EVERYOTHERMONTH | 604 | // Schedule::Occurrence::EveryOtherMonth | ||
603 | sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERMONTH); | 605 | sch.setOccurrence(Schedule::Occurrence::EveryOtherMonth); | ||
604 | startDate.setDate(2011, 3, 14); | 606 | startDate.setDate(2011, 3, 14); | ||
605 | endDate.setDate(2011, 11, 20); | 607 | endDate.setDate(2011, 11, 20); | ||
606 | sch.setStartDate(startDate); | 608 | sch.setStartDate(startDate); | ||
Context not available. | |||||
613 | QVERIFY(list[2] == QDate(2011, 7, 14)); | 615 | QVERIFY(list[2] == QDate(2011, 7, 14)); | ||
614 | QVERIFY(list[3] == QDate(2011, 9, 14)); | 616 | QVERIFY(list[3] == QDate(2011, 9, 14)); | ||
615 | QVERIFY(list[4] == QDate(2011, 11, 14)); | 617 | QVERIFY(list[4] == QDate(2011, 11, 14)); | ||
616 | // MyMoneySchedule::OCCUR_EVERYTHREEMONTHS | 618 | // Schedule::Occurrence::EveryThreeMonths | ||
617 | sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); | 619 | sch.setOccurrence(Schedule::Occurrence::EveryThreeMonths); | ||
618 | startDate.setDate(2011, 11, 15); | 620 | startDate.setDate(2011, 11, 15); | ||
619 | endDate.setDate(2012, 11, 19); | 621 | endDate.setDate(2012, 11, 19); | ||
620 | sch.setStartDate(startDate); | 622 | sch.setStartDate(startDate); | ||
Context not available. | |||||
626 | QVERIFY(list[2] == QDate(2012, 5, 15)); | 628 | QVERIFY(list[2] == QDate(2012, 5, 15)); | ||
627 | QVERIFY(list[3] == QDate(2012, 8, 15)); | 629 | QVERIFY(list[3] == QDate(2012, 8, 15)); | ||
628 | QVERIFY(list[4] == QDate(2012, 11, 15)); | 630 | QVERIFY(list[4] == QDate(2012, 11, 15)); | ||
629 | // MyMoneySchedule::OCCUR_QUARTERLY | 631 | // Schedule::Occurrence::Quarterly | ||
630 | sch.setOccurrence(MyMoneySchedule::OCCUR_QUARTERLY); | 632 | sch.setOccurrence(Schedule::Occurrence::Quarterly); | ||
631 | startDate.setDate(2012, 11, 20); | 633 | startDate.setDate(2012, 11, 20); | ||
632 | endDate.setDate(2013, 11, 23); | 634 | endDate.setDate(2013, 11, 23); | ||
633 | sch.setStartDate(startDate); | 635 | sch.setStartDate(startDate); | ||
Context not available. | |||||
639 | QVERIFY(list[2] == QDate(2013, 5, 20)); | 641 | QVERIFY(list[2] == QDate(2013, 5, 20)); | ||
640 | QVERIFY(list[3] == QDate(2013, 8, 20)); | 642 | QVERIFY(list[3] == QDate(2013, 8, 20)); | ||
641 | QVERIFY(list[4] == QDate(2013, 11, 20)); | 643 | QVERIFY(list[4] == QDate(2013, 11, 20)); | ||
642 | // MyMoneySchedule::OCCUR_EVERYFOURMONTHS | 644 | // Schedule::Occurrence::EveryFourMonths | ||
643 | sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYFOURMONTHS); | 645 | sch.setOccurrence(Schedule::Occurrence::EveryFourMonths); | ||
644 | startDate.setDate(2013, 11, 21); | 646 | startDate.setDate(2013, 11, 21); | ||
645 | endDate.setDate(2015, 3, 23); | 647 | endDate.setDate(2015, 3, 23); | ||
646 | sch.setStartDate(startDate); | 648 | sch.setStartDate(startDate); | ||
Context not available. | |||||
653 | QVERIFY(list[3] == QDate(2014, 11, 21)); | 655 | QVERIFY(list[3] == QDate(2014, 11, 21)); | ||
654 | // Would fall on a Saturday so gets moved to 20th. | 656 | // Would fall on a Saturday so gets moved to 20th. | ||
655 | QVERIFY(list[4] == QDate(2015, 3, 20)); | 657 | QVERIFY(list[4] == QDate(2015, 3, 20)); | ||
656 | // MyMoneySchedule::OCCUR_TWICEYEARLY | 658 | // Schedule::Occurrence::TwiceYearly | ||
657 | sch.setOccurrence(MyMoneySchedule::OCCUR_TWICEYEARLY); | 659 | sch.setOccurrence(Schedule::Occurrence::TwiceYearly); | ||
658 | startDate.setDate(2015, 3, 22); | 660 | startDate.setDate(2015, 3, 22); | ||
659 | endDate.setDate(2017, 3, 29); | 661 | endDate.setDate(2017, 3, 29); | ||
660 | sch.setStartDate(startDate); | 662 | sch.setStartDate(startDate); | ||
Context not available. | |||||
667 | QVERIFY(list[1] == QDate(2016, 3, 22)); | 669 | QVERIFY(list[1] == QDate(2016, 3, 22)); | ||
668 | QVERIFY(list[2] == QDate(2016, 9, 22)); | 670 | QVERIFY(list[2] == QDate(2016, 9, 22)); | ||
669 | QVERIFY(list[3] == QDate(2017, 3, 22)); | 671 | QVERIFY(list[3] == QDate(2017, 3, 22)); | ||
670 | // MyMoneySchedule::OCCUR_YEARLY | 672 | // Schedule::Occurrence::Yearly | ||
671 | sch.setOccurrence(MyMoneySchedule::OCCUR_YEARLY); | 673 | sch.setOccurrence(Schedule::Occurrence::Yearly); | ||
672 | startDate.setDate(2017, 3, 23); | 674 | startDate.setDate(2017, 3, 23); | ||
673 | endDate.setDate(2021, 3, 29); | 675 | endDate.setDate(2021, 3, 29); | ||
674 | sch.setStartDate(startDate); | 676 | sch.setStartDate(startDate); | ||
Context not available. | |||||
681 | QVERIFY(list[2] == QDate(2019, 3, 22)); | 683 | QVERIFY(list[2] == QDate(2019, 3, 22)); | ||
682 | QVERIFY(list[3] == QDate(2020, 3, 23)); | 684 | QVERIFY(list[3] == QDate(2020, 3, 23)); | ||
683 | QVERIFY(list[4] == QDate(2021, 3, 23)); | 685 | QVERIFY(list[4] == QDate(2021, 3, 23)); | ||
684 | // MyMoneySchedule::OCCUR_EVERYOTHERYEAR | 686 | // Schedule::Occurrence::EveryOtherYear | ||
685 | sch.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERYEAR); | 687 | sch.setOccurrence(Schedule::Occurrence::EveryOtherYear); | ||
686 | startDate.setDate(2021, 3, 24); | 688 | startDate.setDate(2021, 3, 24); | ||
687 | endDate.setDate(2029, 3, 30); | 689 | endDate.setDate(2029, 3, 30); | ||
688 | sch.setStartDate(startDate); | 690 | sch.setStartDate(startDate); | ||
Context not available. | |||||
703 | void MyMoneyScheduleTest::testWriteXML() | 705 | void MyMoneyScheduleTest::testWriteXML() | ||
704 | { | 706 | { | ||
705 | MyMoneySchedule sch("A Name", | 707 | MyMoneySchedule sch("A Name", | ||
706 | MyMoneySchedule::TYPE_BILL, | 708 | Schedule::Type::Bill, | ||
707 | MyMoneySchedule::OCCUR_WEEKLY, 123, | 709 | Schedule::Occurrence::Weekly, 123, | ||
708 | MyMoneySchedule::STYPE_DIRECTDEBIT, | 710 | Schedule::PaymentType::DirectDebit, | ||
709 | QDate::currentDate(), | 711 | QDate::currentDate(), | ||
710 | QDate(), | 712 | QDate(), | ||
711 | true, | 713 | true, | ||
Context not available. | |||||
927 | QVERIFY(sch.endDate() == QDate()); | 929 | QVERIFY(sch.endDate() == QDate()); | ||
928 | QVERIFY(sch.autoEnter() == true); | 930 | QVERIFY(sch.autoEnter() == true); | ||
929 | QVERIFY(sch.isFixed() == true); | 931 | QVERIFY(sch.isFixed() == true); | ||
930 | QVERIFY(sch.weekendOption() == MyMoneySchedule::MoveNothing); | 932 | QVERIFY(sch.weekendOption() == Schedule::WeekendOption::MoveNothing); | ||
931 | QVERIFY(sch.lastPayment() == QDate::currentDate()); | 933 | QVERIFY(sch.lastPayment() == QDate::currentDate()); | ||
932 | QVERIFY(sch.paymentType() == MyMoneySchedule::STYPE_DIRECTDEBIT); | 934 | QVERIFY(sch.paymentType() == Schedule::PaymentType::DirectDebit); | ||
933 | QVERIFY(sch.type() == MyMoneySchedule::TYPE_BILL); | 935 | QVERIFY(sch.type() == Schedule::Type::Bill); | ||
934 | QVERIFY(sch.name() == "A Name"); | 936 | QVERIFY(sch.name() == "A Name"); | ||
935 | QVERIFY(sch.occurrence() == MyMoneySchedule::OCCUR_WEEKLY); | 937 | QVERIFY(sch.occurrence() == Schedule::Occurrence::Weekly); | ||
936 | QVERIFY(sch.occurrenceMultiplier() == 1); | 938 | QVERIFY(sch.occurrenceMultiplier() == 1); | ||
937 | QVERIFY(sch.nextDueDate() == sch.lastPayment().addDays(7)); | 939 | QVERIFY(sch.nextDueDate() == sch.lastPayment().addDays(7)); | ||
938 | QVERIFY(sch.recordedPayments().count() == 1); | 940 | QVERIFY(sch.recordedPayments().count() == 1); | ||
Context not available. | |||||
953 | QVERIFY(sch.endDate() == QDate()); | 955 | QVERIFY(sch.endDate() == QDate()); | ||
954 | QVERIFY(sch.autoEnter() == true); | 956 | QVERIFY(sch.autoEnter() == true); | ||
955 | QVERIFY(sch.isFixed() == true); | 957 | QVERIFY(sch.isFixed() == true); | ||
956 | QVERIFY(sch.weekendOption() == MyMoneySchedule::MoveNothing); | 958 | QVERIFY(sch.weekendOption() == Schedule::WeekendOption::MoveNothing); | ||
957 | QVERIFY(sch.lastPayment() == QDate::currentDate()); | 959 | QVERIFY(sch.lastPayment() == QDate::currentDate()); | ||
958 | QVERIFY(sch.paymentType() == MyMoneySchedule::STYPE_DIRECTDEBIT); | 960 | QVERIFY(sch.paymentType() == Schedule::PaymentType::DirectDebit); | ||
959 | QVERIFY(sch.type() == MyMoneySchedule::TYPE_BILL); | 961 | QVERIFY(sch.type() == Schedule::Type::Bill); | ||
960 | QVERIFY(sch.name() == "A Name"); | 962 | QVERIFY(sch.name() == "A Name"); | ||
961 | QVERIFY(sch.occurrence() == MyMoneySchedule::OCCUR_WEEKLY); | 963 | QVERIFY(sch.occurrence() == Schedule::Occurrence::Weekly); | ||
962 | QVERIFY(sch.occurrenceMultiplier() == 1); | 964 | QVERIFY(sch.occurrenceMultiplier() == 1); | ||
963 | QVERIFY(sch.nextDueDate() == sch.lastPayment().addDays(7)); | 965 | QVERIFY(sch.nextDueDate() == sch.lastPayment().addDays(7)); | ||
964 | QVERIFY(sch.recordedPayments().count() == 1); | 966 | QVERIFY(sch.recordedPayments().count() == 1); | ||
Context not available. | |||||
1018 | QDate dueDate(2007, 9, 3); // start on a Monday | 1020 | QDate dueDate(2007, 9, 3); // start on a Monday | ||
1019 | for (int i = 0; i < 7; ++i) { | 1021 | for (int i = 0; i < 7; ++i) { | ||
1020 | s.setNextDueDate(dueDate); | 1022 | s.setNextDueDate(dueDate); | ||
1021 | s.setWeekendOption(MyMoneySchedule::MoveNothing); | 1023 | s.setWeekendOption(Schedule::WeekendOption::MoveNothing); | ||
1022 | QVERIFY(s.adjustedNextDueDate() == dueDate); | 1024 | QVERIFY(s.adjustedNextDueDate() == dueDate); | ||
1023 | 1025 | | |||
1024 | s.setWeekendOption(MyMoneySchedule::MoveBefore); | 1026 | s.setWeekendOption(Schedule::WeekendOption::MoveBefore); | ||
1025 | switch (i) { | 1027 | switch (i) { | ||
1026 | case 5: // Saturday | 1028 | case 5: // Saturday | ||
1027 | case 6: // Sunday | 1029 | case 6: // Sunday | ||
Context not available. | |||||
1032 | break; | 1034 | break; | ||
1033 | } | 1035 | } | ||
1034 | 1036 | | |||
1035 | s.setWeekendOption(MyMoneySchedule::MoveAfter); | 1037 | s.setWeekendOption(Schedule::WeekendOption::MoveAfter); | ||
1036 | switch (i) { | 1038 | switch (i) { | ||
1037 | case 5: // Saturday | 1039 | case 5: // Saturday | ||
1038 | case 6: // Sunday | 1040 | case 6: // Sunday | ||
Context not available. | |||||
1050 | { | 1052 | { | ||
1051 | MyMoneySchedule s; | 1053 | MyMoneySchedule s; | ||
1052 | s.setStartDate(QDate(2007, 1, 2)); | 1054 | s.setStartDate(QDate(2007, 1, 2)); | ||
1053 | s.setOccurrence(MyMoneySchedule::OCCUR_MONTHLY); | 1055 | s.setOccurrence(Schedule::Occurrence::Monthly); | ||
1054 | s.setNextDueDate(s.startDate().addMonths(1)); | 1056 | s.setNextDueDate(s.startDate().addMonths(1)); | ||
1055 | s.setLastPayment(s.startDate()); | 1057 | s.setLastPayment(s.startDate()); | ||
1056 | 1058 | | |||
Context not available. | |||||
1078 | 1080 | | |||
1079 | void MyMoneyScheduleTest::testDaysBetweenEvents() | 1081 | void MyMoneyScheduleTest::testDaysBetweenEvents() | ||
1080 | { | 1082 | { | ||
1081 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_ONCE), 0); | 1083 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Once), 0); | ||
1082 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_DAILY), 1); | 1084 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Daily), 1); | ||
1083 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_WEEKLY), 7); | 1085 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Weekly), 7); | ||
1084 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYOTHERWEEK), 14); | 1086 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryOtherWeek), 14); | ||
1085 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_FORTNIGHTLY), 14); | 1087 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Fortnightly), 14); | ||
1086 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYHALFMONTH), 15); | 1088 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryHalfMonth), 15); | ||
1087 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS), 21); | 1089 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryThreeWeeks), 21); | ||
1088 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYFOURWEEKS), 28); | 1090 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryFourWeeks), 28); | ||
1089 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS), 30); | 1091 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryThirtyDays), 30); | ||
1090 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_MONTHLY), 30); | 1092 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Monthly), 30); | ||
1091 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS), 56); | 1093 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryEightWeeks), 56); | ||
1092 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYOTHERMONTH), 60); | 1094 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryOtherMonth), 60); | ||
1093 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS), 90); | 1095 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryThreeMonths), 90); | ||
1094 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_QUARTERLY), 90); | 1096 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Quarterly), 90); | ||
1095 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYFOURMONTHS), 120); | 1097 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryFourMonths), 120); | ||
1096 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_TWICEYEARLY), 180); | 1098 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::TwiceYearly), 180); | ||
1097 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_YEARLY), 360); | 1099 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::Yearly), 360); | ||
1098 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(MyMoneySchedule::OCCUR_EVERYOTHERYEAR), 0); | 1100 | QCOMPARE(MyMoneySchedule::daysBetweenEvents(Schedule::Occurrence::EveryOtherYear), 0); | ||
1099 | } | 1101 | } | ||
1100 | 1102 | | |||
1101 | void MyMoneyScheduleTest::testEventsPerYear() | 1103 | void MyMoneyScheduleTest::testEventsPerYear() | ||
1102 | { | 1104 | { | ||
1103 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_ONCE), 0); | 1105 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Once), 0); | ||
1104 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_DAILY), 365); | 1106 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Daily), 365); | ||
1105 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_WEEKLY), 52); | 1107 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Weekly), 52); | ||
1106 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYOTHERWEEK), 26); | 1108 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryOtherWeek), 26); | ||
1107 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_FORTNIGHTLY), 26); | 1109 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Fortnightly), 26); | ||
1108 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYHALFMONTH), 24); | 1110 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryHalfMonth), 24); | ||
1109 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS), 17); | 1111 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryThreeWeeks), 17); | ||
1110 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYFOURWEEKS), 13); | 1112 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryFourWeeks), 13); | ||
1111 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS), 12); | 1113 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryThirtyDays), 12); | ||
1112 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_MONTHLY), 12); | 1114 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Monthly), 12); | ||
1113 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS), 6); | 1115 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryEightWeeks), 6); | ||
1114 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYOTHERMONTH), 6); | 1116 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryOtherMonth), 6); | ||
1115 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS), 4); | 1117 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryThreeMonths), 4); | ||
1116 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_QUARTERLY), 4); | 1118 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Quarterly), 4); | ||
1117 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYFOURMONTHS), 3); | 1119 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryFourMonths), 3); | ||
1118 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_TWICEYEARLY), 2); | 1120 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::TwiceYearly), 2); | ||
1119 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_YEARLY), 1); | 1121 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::Yearly), 1); | ||
1120 | QCOMPARE(MyMoneySchedule::eventsPerYear(MyMoneySchedule::OCCUR_EVERYOTHERYEAR), 0); | 1122 | QCOMPARE(MyMoneySchedule::eventsPerYear(Schedule::Occurrence::EveryOtherYear), 0); | ||
1121 | } | 1123 | } | ||
1122 | 1124 | | |||
1123 | void MyMoneyScheduleTest::testOccurrenceToString() | 1125 | void MyMoneyScheduleTest::testOccurrenceToString() | ||
1124 | { | 1126 | { | ||
1125 | // For each occurrenceE test MyMoneySchedule::occurrenceToString(occurrenceE) | 1127 | // For each occurrenceE test MyMoneySchedule::occurrenceToString(occurrenceE) | ||
1126 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_ONCE), QLatin1String("Once")); | 1128 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Once), QLatin1String("Once")); | ||
1127 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_DAILY), QLatin1String("Daily")); | 1129 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Daily), QLatin1String("Daily")); | ||
1128 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_WEEKLY), QLatin1String("Weekly")); | 1130 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Weekly), QLatin1String("Weekly")); | ||
1129 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERWEEK), QLatin1String("Every other week")); | 1131 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherWeek), QLatin1String("Every other week")); | ||
1130 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_FORTNIGHTLY), QLatin1String("Fortnightly")); | 1132 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Fortnightly), QLatin1String("Fortnightly")); | ||
1131 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYHALFMONTH), QLatin1String("Every half month")); | 1133 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryHalfMonth), QLatin1String("Every half month")); | ||
1132 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS), QLatin1String("Every three weeks")); | 1134 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThreeWeeks), QLatin1String("Every three weeks")); | ||
1133 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYFOURWEEKS), QLatin1String("Every four weeks")); | 1135 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryFourWeeks), QLatin1String("Every four weeks")); | ||
1134 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS), QLatin1String("Every thirty days")); | 1136 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThirtyDays), QLatin1String("Every thirty days")); | ||
1135 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_MONTHLY), QLatin1String("Monthly")); | 1137 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Monthly), QLatin1String("Monthly")); | ||
1136 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS), QLatin1String("Every eight weeks")); | 1138 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryEightWeeks), QLatin1String("Every eight weeks")); | ||
1137 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERMONTH), QLatin1String("Every two months")); | 1139 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherMonth), QLatin1String("Every two months")); | ||
1138 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS), QLatin1String("Every three months")); | 1140 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThreeMonths), QLatin1String("Every three months")); | ||
1139 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_QUARTERLY), QLatin1String("Quarterly")); | 1141 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Quarterly), QLatin1String("Quarterly")); | ||
1140 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYFOURMONTHS), QLatin1String("Every four months")); | 1142 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryFourMonths), QLatin1String("Every four months")); | ||
1141 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_TWICEYEARLY), QLatin1String("Twice yearly")); | 1143 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::TwiceYearly), QLatin1String("Twice yearly")); | ||
1142 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_YEARLY), QLatin1String("Yearly")); | 1144 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Yearly), QLatin1String("Yearly")); | ||
1143 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERYEAR), QLatin1String("Every other year")); | 1145 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherYear), QLatin1String("Every other year")); | ||
1144 | // For each occurrenceE set occurrence and compare occurrenceToString() with oTS(occurrence()) | 1146 | // For each occurrenceE set occurrence and compare occurrenceToString() with oTS(occurrence()) | ||
1145 | MyMoneySchedule s; | 1147 | MyMoneySchedule s; | ||
1146 | s.setStartDate(QDate(2007, 1, 1)); | 1148 | s.setStartDate(QDate(2007, 1, 1)); | ||
1147 | s.setNextDueDate(s.startDate()); | 1149 | s.setNextDueDate(s.startDate()); | ||
1148 | s.setLastPayment(s.startDate()); | 1150 | s.setLastPayment(s.startDate()); | ||
1149 | s.setOccurrence(MyMoneySchedule::OCCUR_ONCE); QCOMPARE(s.occurrenceToString(), QLatin1String("Once")); | 1151 | s.setOccurrence(Schedule::Occurrence::Once); QCOMPARE(s.occurrenceToString(), QLatin1String("Once")); | ||
1150 | s.setOccurrence(MyMoneySchedule::OCCUR_DAILY); QCOMPARE(s.occurrenceToString(), QLatin1String("Daily")); | 1152 | s.setOccurrence(Schedule::Occurrence::Daily); QCOMPARE(s.occurrenceToString(), QLatin1String("Daily")); | ||
1151 | s.setOccurrence(MyMoneySchedule::OCCUR_WEEKLY); QCOMPARE(s.occurrenceToString(), QLatin1String("Weekly")); | 1153 | s.setOccurrence(Schedule::Occurrence::Weekly); QCOMPARE(s.occurrenceToString(), QLatin1String("Weekly")); | ||
1152 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERWEEK); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other week")); | 1154 | s.setOccurrence(Schedule::Occurrence::EveryOtherWeek); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other week")); | ||
1153 | // Fortnightly no longer used: Every other week used instead | 1155 | // Fortnightly no longer used: Every other week used instead | ||
1154 | s.setOccurrence(MyMoneySchedule::OCCUR_FORTNIGHTLY); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other week")); | 1156 | s.setOccurrence(Schedule::Occurrence::Fortnightly); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other week")); | ||
1155 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYHALFMONTH); QCOMPARE(s.occurrenceToString(), QLatin1String("Every half month")); | 1157 | s.setOccurrence(Schedule::Occurrence::EveryHalfMonth); QCOMPARE(s.occurrenceToString(), QLatin1String("Every half month")); | ||
1156 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three weeks")); | 1158 | s.setOccurrence(Schedule::Occurrence::EveryThreeWeeks); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three weeks")); | ||
1157 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYFOURWEEKS); QCOMPARE(s.occurrenceToString(), QLatin1String("Every four weeks")); | 1159 | s.setOccurrence(Schedule::Occurrence::EveryFourWeeks); QCOMPARE(s.occurrenceToString(), QLatin1String("Every four weeks")); | ||
1158 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS); QCOMPARE(s.occurrenceToString(), QLatin1String("Every thirty days")); | 1160 | s.setOccurrence(Schedule::Occurrence::EveryThirtyDays); QCOMPARE(s.occurrenceToString(), QLatin1String("Every thirty days")); | ||
1159 | s.setOccurrence(MyMoneySchedule::OCCUR_MONTHLY); QCOMPARE(s.occurrenceToString(), QLatin1String("Monthly")); | 1161 | s.setOccurrence(Schedule::Occurrence::Monthly); QCOMPARE(s.occurrenceToString(), QLatin1String("Monthly")); | ||
1160 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS); QCOMPARE(s.occurrenceToString(), QLatin1String("Every eight weeks")); | 1162 | s.setOccurrence(Schedule::Occurrence::EveryEightWeeks); QCOMPARE(s.occurrenceToString(), QLatin1String("Every eight weeks")); | ||
1161 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERMONTH); QCOMPARE(s.occurrenceToString(), QLatin1String("Every two months")); | 1163 | s.setOccurrence(Schedule::Occurrence::EveryOtherMonth); QCOMPARE(s.occurrenceToString(), QLatin1String("Every two months")); | ||
1162 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three months")); | 1164 | s.setOccurrence(Schedule::Occurrence::EveryThreeMonths); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three months")); | ||
1163 | // Quarterly no longer used. Every three months used instead | 1165 | // Quarterly no longer used. Every three months used instead | ||
1164 | s.setOccurrence(MyMoneySchedule::OCCUR_QUARTERLY); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three months")); | 1166 | s.setOccurrence(Schedule::Occurrence::Quarterly); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three months")); | ||
1165 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYFOURMONTHS); QCOMPARE(s.occurrenceToString(), QLatin1String("Every four months")); | 1167 | s.setOccurrence(Schedule::Occurrence::EveryFourMonths); QCOMPARE(s.occurrenceToString(), QLatin1String("Every four months")); | ||
1166 | s.setOccurrence(MyMoneySchedule::OCCUR_TWICEYEARLY); QCOMPARE(s.occurrenceToString(), QLatin1String("Twice yearly")); | 1168 | s.setOccurrence(Schedule::Occurrence::TwiceYearly); QCOMPARE(s.occurrenceToString(), QLatin1String("Twice yearly")); | ||
1167 | s.setOccurrence(MyMoneySchedule::OCCUR_YEARLY); QCOMPARE(s.occurrenceToString(), QLatin1String("Yearly")); | 1169 | s.setOccurrence(Schedule::Occurrence::Yearly); QCOMPARE(s.occurrenceToString(), QLatin1String("Yearly")); | ||
1168 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERYEAR); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other year")); | 1170 | s.setOccurrence(Schedule::Occurrence::EveryOtherYear); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other year")); | ||
1169 | // Test occurrenceToString(mult,occ) | 1171 | // Test occurrenceToString(mult,occ) | ||
1170 | // Test all pairs equivalent to simple occurrences: should return the same as occurrenceToString(simpleOcc) | 1172 | // Test all pairs equivalent to simple occurrences: should return the same as occurrenceToString(simpleOcc) | ||
1171 | // TODO replace string with (mult,occ) call. | 1173 | // TODO replace string with (mult,occ) call. | ||
1172 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_ONCE), MyMoneySchedule::occurrenceToString(1, MyMoneySchedule::OCCUR_ONCE)); | 1174 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Once), MyMoneySchedule::occurrenceToString(1, Schedule::Occurrence::Once)); | ||
1173 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_DAILY), MyMoneySchedule::occurrenceToString(1, MyMoneySchedule::OCCUR_DAILY)); | 1175 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Daily), MyMoneySchedule::occurrenceToString(1, Schedule::Occurrence::Daily)); | ||
1174 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_WEEKLY), MyMoneySchedule::occurrenceToString(1, MyMoneySchedule::OCCUR_WEEKLY)); | 1176 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Weekly), MyMoneySchedule::occurrenceToString(1, Schedule::Occurrence::Weekly)); | ||
1175 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERWEEK), MyMoneySchedule::occurrenceToString(2, MyMoneySchedule::OCCUR_WEEKLY)); | 1177 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherWeek), MyMoneySchedule::occurrenceToString(2, Schedule::Occurrence::Weekly)); | ||
1176 | // OCCUR_FORTNIGHTLY will no longer be used: only Every Other Week | 1178 | // Fortnightly will no longer be used: only Every Other Week | ||
1177 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYHALFMONTH), MyMoneySchedule::occurrenceToString(1, MyMoneySchedule::OCCUR_EVERYHALFMONTH)); | 1179 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryHalfMonth), MyMoneySchedule::occurrenceToString(1, Schedule::Occurrence::EveryHalfMonth)); | ||
1178 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS), MyMoneySchedule::occurrenceToString(3, MyMoneySchedule::OCCUR_WEEKLY)); | 1180 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThreeWeeks), MyMoneySchedule::occurrenceToString(3, Schedule::Occurrence::Weekly)); | ||
1179 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYFOURWEEKS), MyMoneySchedule::occurrenceToString(4, MyMoneySchedule::OCCUR_WEEKLY)); | 1181 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryFourWeeks), MyMoneySchedule::occurrenceToString(4, Schedule::Occurrence::Weekly)); | ||
1180 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_MONTHLY), MyMoneySchedule::occurrenceToString(1, MyMoneySchedule::OCCUR_MONTHLY)); | 1182 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Monthly), MyMoneySchedule::occurrenceToString(1, Schedule::Occurrence::Monthly)); | ||
1181 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS), MyMoneySchedule::occurrenceToString(8, MyMoneySchedule::OCCUR_WEEKLY)); | 1183 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryEightWeeks), MyMoneySchedule::occurrenceToString(8, Schedule::Occurrence::Weekly)); | ||
1182 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERMONTH), MyMoneySchedule::occurrenceToString(2, MyMoneySchedule::OCCUR_MONTHLY)); | 1184 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherMonth), MyMoneySchedule::occurrenceToString(2, Schedule::Occurrence::Monthly)); | ||
1183 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS), MyMoneySchedule::occurrenceToString(3, MyMoneySchedule::OCCUR_MONTHLY)); | 1185 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryThreeMonths), MyMoneySchedule::occurrenceToString(3, Schedule::Occurrence::Monthly)); | ||
1184 | // OCCUR_QUARTERLY will no longer be used: only Every Three Months | 1186 | // Quarterly will no longer be used: only Every Three Months | ||
1185 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYFOURMONTHS), MyMoneySchedule::occurrenceToString(4, MyMoneySchedule::OCCUR_MONTHLY)); | 1187 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryFourMonths), MyMoneySchedule::occurrenceToString(4, Schedule::Occurrence::Monthly)); | ||
1186 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_TWICEYEARLY), MyMoneySchedule::occurrenceToString(6, MyMoneySchedule::OCCUR_MONTHLY)); | 1188 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::TwiceYearly), MyMoneySchedule::occurrenceToString(6, Schedule::Occurrence::Monthly)); | ||
1187 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_YEARLY), MyMoneySchedule::occurrenceToString(1, MyMoneySchedule::OCCUR_YEARLY)); | 1189 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::Yearly), MyMoneySchedule::occurrenceToString(1, Schedule::Occurrence::Yearly)); | ||
1188 | QCOMPARE(MyMoneySchedule::occurrenceToString(MyMoneySchedule::OCCUR_EVERYOTHERYEAR), MyMoneySchedule::occurrenceToString(2, MyMoneySchedule::OCCUR_YEARLY)); | 1190 | QCOMPARE(MyMoneySchedule::occurrenceToString(Schedule::Occurrence::EveryOtherYear), MyMoneySchedule::occurrenceToString(2, Schedule::Occurrence::Yearly)); | ||
1189 | // Test additional calls with other mult,occ | 1191 | // Test additional calls with other mult,occ | ||
1190 | QCOMPARE(MyMoneySchedule::occurrenceToString(2, MyMoneySchedule::OCCUR_ONCE), QLatin1String("2 times")); | 1192 | QCOMPARE(MyMoneySchedule::occurrenceToString(2, Schedule::Occurrence::Once), QLatin1String("2 times")); | ||
1191 | QCOMPARE(MyMoneySchedule::occurrenceToString(2, MyMoneySchedule::OCCUR_DAILY), QLatin1String("Every 2 days")); | 1193 | QCOMPARE(MyMoneySchedule::occurrenceToString(2, Schedule::Occurrence::Daily), QLatin1String("Every 2 days")); | ||
1192 | QCOMPARE(MyMoneySchedule::occurrenceToString(5, MyMoneySchedule::OCCUR_WEEKLY), QLatin1String("Every 5 weeks")); | 1194 | QCOMPARE(MyMoneySchedule::occurrenceToString(5, Schedule::Occurrence::Weekly), QLatin1String("Every 5 weeks")); | ||
1193 | QCOMPARE(MyMoneySchedule::occurrenceToString(2, MyMoneySchedule::OCCUR_EVERYHALFMONTH), QLatin1String("Every 2 half months")); | 1195 | QCOMPARE(MyMoneySchedule::occurrenceToString(2, Schedule::Occurrence::EveryHalfMonth), QLatin1String("Every 2 half months")); | ||
1194 | QCOMPARE(MyMoneySchedule::occurrenceToString(5, MyMoneySchedule::OCCUR_MONTHLY), QLatin1String("Every 5 months")); | 1196 | QCOMPARE(MyMoneySchedule::occurrenceToString(5, Schedule::Occurrence::Monthly), QLatin1String("Every 5 months")); | ||
1195 | QCOMPARE(MyMoneySchedule::occurrenceToString(3, MyMoneySchedule::OCCUR_YEARLY), QLatin1String("Every 3 years")); | 1197 | QCOMPARE(MyMoneySchedule::occurrenceToString(3, Schedule::Occurrence::Yearly), QLatin1String("Every 3 years")); | ||
1196 | QCOMPARE(MyMoneySchedule::occurrenceToString(37, MyMoneySchedule::OCCUR_ONCE), QLatin1String("37 times")); | 1198 | QCOMPARE(MyMoneySchedule::occurrenceToString(37, Schedule::Occurrence::Once), QLatin1String("37 times")); | ||
1197 | QCOMPARE(MyMoneySchedule::occurrenceToString(43, MyMoneySchedule::OCCUR_DAILY), QLatin1String("Every 43 days")); | 1199 | QCOMPARE(MyMoneySchedule::occurrenceToString(43, Schedule::Occurrence::Daily), QLatin1String("Every 43 days")); | ||
1198 | QCOMPARE(MyMoneySchedule::occurrenceToString(61, MyMoneySchedule::OCCUR_WEEKLY), QLatin1String("Every 61 weeks")); | 1200 | QCOMPARE(MyMoneySchedule::occurrenceToString(61, Schedule::Occurrence::Weekly), QLatin1String("Every 61 weeks")); | ||
1199 | QCOMPARE(MyMoneySchedule::occurrenceToString(73, MyMoneySchedule::OCCUR_EVERYHALFMONTH), QLatin1String("Every 73 half months")); | 1201 | QCOMPARE(MyMoneySchedule::occurrenceToString(73, Schedule::Occurrence::EveryHalfMonth), QLatin1String("Every 73 half months")); | ||
1200 | QCOMPARE(MyMoneySchedule::occurrenceToString(83, MyMoneySchedule::OCCUR_MONTHLY), QLatin1String("Every 83 months")); | 1202 | QCOMPARE(MyMoneySchedule::occurrenceToString(83, Schedule::Occurrence::Monthly), QLatin1String("Every 83 months")); | ||
1201 | QCOMPARE(MyMoneySchedule::occurrenceToString(89, MyMoneySchedule::OCCUR_YEARLY), QLatin1String("Every 89 years")); | 1203 | QCOMPARE(MyMoneySchedule::occurrenceToString(89, Schedule::Occurrence::Yearly), QLatin1String("Every 89 years")); | ||
1202 | // Test instance-level occurrenceToString method is using occurrencePeriod and multiplier | 1204 | // Test instance-level occurrenceToString method is using occurrencePeriod and multiplier | ||
1203 | // For each base occurrence set occurrencePeriod and multiplier | 1205 | // For each base occurrence set occurrencePeriod and multiplier | ||
1204 | s.setOccurrencePeriod(MyMoneySchedule::OCCUR_ONCE); s.setOccurrenceMultiplier(1); | 1206 | s.setOccurrencePeriod(Schedule::Occurrence::Once); s.setOccurrenceMultiplier(1); | ||
1205 | s.setOccurrence(MyMoneySchedule::OCCUR_ONCE); | 1207 | s.setOccurrence(Schedule::Occurrence::Once); | ||
1206 | s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Once")); | 1208 | s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Once")); | ||
1207 | s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("2 times")); | 1209 | s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("2 times")); | ||
1208 | s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("3 times")); | 1210 | s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("3 times")); | ||
1209 | s.setOccurrencePeriod(MyMoneySchedule::OCCUR_DAILY); | 1211 | s.setOccurrencePeriod(Schedule::Occurrence::Daily); | ||
1210 | s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Daily")); | 1212 | s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Daily")); | ||
1211 | s.setOccurrenceMultiplier(30); QCOMPARE(s.occurrenceToString(), QLatin1String("Every thirty days")); | 1213 | s.setOccurrenceMultiplier(30); QCOMPARE(s.occurrenceToString(), QLatin1String("Every thirty days")); | ||
1212 | s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 3 days")); | 1214 | s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 3 days")); | ||
1213 | s.setOccurrence(MyMoneySchedule::OCCUR_WEEKLY); | 1215 | s.setOccurrence(Schedule::Occurrence::Weekly); | ||
1214 | QCOMPARE(s.occurrenceToString(), QLatin1String("Weekly")); | 1216 | QCOMPARE(s.occurrenceToString(), QLatin1String("Weekly")); | ||
1215 | s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other week")); | 1217 | s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other week")); | ||
1216 | s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three weeks")); | 1218 | s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three weeks")); | ||
Context not available. | |||||
1219 | s.setOccurrenceMultiplier(7); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 7 weeks")); | 1221 | s.setOccurrenceMultiplier(7); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 7 weeks")); | ||
1220 | s.setOccurrenceMultiplier(8); QCOMPARE(s.occurrenceToString(), QLatin1String("Every eight weeks")); | 1222 | s.setOccurrenceMultiplier(8); QCOMPARE(s.occurrenceToString(), QLatin1String("Every eight weeks")); | ||
1221 | s.setOccurrenceMultiplier(9); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 9 weeks")); | 1223 | s.setOccurrenceMultiplier(9); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 9 weeks")); | ||
1222 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYHALFMONTH); | 1224 | s.setOccurrence(Schedule::Occurrence::EveryHalfMonth); | ||
1223 | s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Every half month")); | 1225 | s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Every half month")); | ||
1224 | s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 2 half months")); | 1226 | s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 2 half months")); | ||
1225 | s.setOccurrence(MyMoneySchedule::OCCUR_MONTHLY); | 1227 | s.setOccurrence(Schedule::Occurrence::Monthly); | ||
1226 | s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Monthly")); | 1228 | s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Monthly")); | ||
1227 | s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("Every two months")); | 1229 | s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("Every two months")); | ||
1228 | s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three months")); | 1230 | s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("Every three months")); | ||
Context not available. | |||||
1230 | s.setOccurrenceMultiplier(5); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 5 months")); | 1232 | s.setOccurrenceMultiplier(5); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 5 months")); | ||
1231 | s.setOccurrenceMultiplier(6); QCOMPARE(s.occurrenceToString(), QLatin1String("Twice yearly")); | 1233 | s.setOccurrenceMultiplier(6); QCOMPARE(s.occurrenceToString(), QLatin1String("Twice yearly")); | ||
1232 | s.setOccurrenceMultiplier(7); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 7 months")); | 1234 | s.setOccurrenceMultiplier(7); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 7 months")); | ||
1233 | s.setOccurrence(MyMoneySchedule::OCCUR_YEARLY); | 1235 | s.setOccurrence(Schedule::Occurrence::Yearly); | ||
1234 | s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Yearly")); | 1236 | s.setOccurrenceMultiplier(1); QCOMPARE(s.occurrenceToString(), QLatin1String("Yearly")); | ||
1235 | s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other year")); | 1237 | s.setOccurrenceMultiplier(2); QCOMPARE(s.occurrenceToString(), QLatin1String("Every other year")); | ||
1236 | s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 3 years")); | 1238 | s.setOccurrenceMultiplier(3); QCOMPARE(s.occurrenceToString(), QLatin1String("Every 3 years")); | ||
Context not available. | |||||
1240 | { | 1242 | { | ||
1241 | // For each occurrenceE test MyMoneySchedule::occurrencePeriodToString(occurrenceE) | 1243 | // For each occurrenceE test MyMoneySchedule::occurrencePeriodToString(occurrenceE) | ||
1242 | // Base occurrences are translated | 1244 | // Base occurrences are translated | ||
1243 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_ONCE), QLatin1String("Once")); | 1245 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Once), QLatin1String("Once")); | ||
1244 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_DAILY), QLatin1String("Day")); | 1246 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Daily), QLatin1String("Day")); | ||
1245 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_WEEKLY), QLatin1String("Week")); | 1247 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Weekly), QLatin1String("Week")); | ||
1246 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYHALFMONTH), QLatin1String("Half-month")); | 1248 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryHalfMonth), QLatin1String("Half-month")); | ||
1247 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_MONTHLY), QLatin1String("Month")); | 1249 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Monthly), QLatin1String("Month")); | ||
1248 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_YEARLY), QLatin1String("Year")); | 1250 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Yearly), QLatin1String("Year")); | ||
1249 | // All others are not translated so return Any | 1251 | // All others are not translated so return Any | ||
1250 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYOTHERWEEK), QLatin1String("Any")); | 1252 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryOtherWeek), QLatin1String("Any")); | ||
1251 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_FORTNIGHTLY), QLatin1String("Any")); | 1253 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Fortnightly), QLatin1String("Any")); | ||
1252 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS), QLatin1String("Any")); | 1254 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryThreeWeeks), QLatin1String("Any")); | ||
1253 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYFOURWEEKS), QLatin1String("Any")); | 1255 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryFourWeeks), QLatin1String("Any")); | ||
1254 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS), QLatin1String("Any")); | 1256 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryThirtyDays), QLatin1String("Any")); | ||
1255 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS), QLatin1String("Any")); | 1257 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryEightWeeks), QLatin1String("Any")); | ||
1256 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYOTHERMONTH), QLatin1String("Any")); | 1258 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryOtherMonth), QLatin1String("Any")); | ||
1257 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS), QLatin1String("Any")); | 1259 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryThreeMonths), QLatin1String("Any")); | ||
1258 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_QUARTERLY), QLatin1String("Any")); | 1260 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::Quarterly), QLatin1String("Any")); | ||
1259 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYFOURMONTHS), QLatin1String("Any")); | 1261 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryFourMonths), QLatin1String("Any")); | ||
1260 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_TWICEYEARLY), QLatin1String("Any")); | 1262 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::TwiceYearly), QLatin1String("Any")); | ||
1261 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(MyMoneySchedule::OCCUR_EVERYOTHERYEAR), QLatin1String("Any")); | 1263 | QCOMPARE(MyMoneySchedule::occurrencePeriodToString(Schedule::Occurrence::EveryOtherYear), QLatin1String("Any")); | ||
1262 | } | 1264 | } | ||
1263 | 1265 | | |||
1264 | void MyMoneyScheduleTest::testOccurrencePeriod() | 1266 | void MyMoneyScheduleTest::testOccurrencePeriod() | ||
Context not available. | |||||
1275 | s.setNextDueDate(s.startDate()); | 1277 | s.setNextDueDate(s.startDate()); | ||
1276 | s.setLastPayment(s.startDate()); | 1278 | s.setLastPayment(s.startDate()); | ||
1277 | // Set all base occurrences | 1279 | // Set all base occurrences | ||
1278 | s.setOccurrencePeriod(MyMoneySchedule::OCCUR_ONCE); | 1280 | s.setOccurrencePeriod(Schedule::Occurrence::Once); | ||
1279 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_ONCE); | 1281 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Once); | ||
1280 | s.setOccurrenceMultiplier(1); | 1282 | s.setOccurrenceMultiplier(1); | ||
1281 | QCOMPARE(s.occurrenceMultiplier(), 1); | 1283 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
1282 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_ONCE); | 1284 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Once); | ||
1283 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_ONCE); | 1285 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Once); | ||
1284 | s.setOccurrenceMultiplier(2); | 1286 | s.setOccurrenceMultiplier(2); | ||
1285 | QCOMPARE(s.occurrenceMultiplier(), 2); | 1287 | QCOMPARE(s.occurrenceMultiplier(), 2); | ||
1286 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_ONCE); | 1288 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Once); | ||
1287 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_ONCE); | 1289 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Once); | ||
1288 | 1290 | | |||
1289 | s.setOccurrencePeriod(MyMoneySchedule::OCCUR_DAILY); | 1291 | s.setOccurrencePeriod(Schedule::Occurrence::Daily); | ||
1290 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_DAILY); | 1292 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Daily); | ||
1291 | s.setOccurrenceMultiplier(1); | 1293 | s.setOccurrenceMultiplier(1); | ||
1292 | QCOMPARE(s.occurrenceMultiplier(), 1); | 1294 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
1293 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_DAILY); | 1295 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Daily); | ||
1294 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_DAILY); | 1296 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Daily); | ||
1295 | s.setOccurrenceMultiplier(30); | 1297 | s.setOccurrenceMultiplier(30); | ||
1296 | QCOMPARE(s.occurrenceMultiplier(), 30); | 1298 | QCOMPARE(s.occurrenceMultiplier(), 30); | ||
1297 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_DAILY); | 1299 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Daily); | ||
1298 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS); | 1300 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThirtyDays); | ||
1299 | s.setOccurrenceMultiplier(2); | 1301 | s.setOccurrenceMultiplier(2); | ||
1300 | QCOMPARE(s.occurrenceMultiplier(), 2); | 1302 | QCOMPARE(s.occurrenceMultiplier(), 2); | ||
1301 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_DAILY); | 1303 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Daily); | ||
1302 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_DAILY); | 1304 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Daily); | ||
1303 | 1305 | | |||
1304 | s.setOccurrencePeriod(MyMoneySchedule::OCCUR_WEEKLY); | 1306 | s.setOccurrencePeriod(Schedule::Occurrence::Weekly); | ||
1305 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1307 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1306 | s.setOccurrenceMultiplier(1); | 1308 | s.setOccurrenceMultiplier(1); | ||
1307 | QCOMPARE(s.occurrenceMultiplier(), 1); | 1309 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
1308 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1310 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1309 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_WEEKLY); | 1311 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Weekly); | ||
1310 | s.setOccurrenceMultiplier(2); | 1312 | s.setOccurrenceMultiplier(2); | ||
1311 | QCOMPARE(s.occurrenceMultiplier(), 2); | 1313 | QCOMPARE(s.occurrenceMultiplier(), 2); | ||
1312 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1314 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1313 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERWEEK); | 1315 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherWeek); | ||
1314 | s.setOccurrenceMultiplier(3); | 1316 | s.setOccurrenceMultiplier(3); | ||
1315 | QCOMPARE(s.occurrenceMultiplier(), 3); | 1317 | QCOMPARE(s.occurrenceMultiplier(), 3); | ||
1316 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1318 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1317 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHREEWEEKS); | 1319 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThreeWeeks); | ||
1318 | s.setOccurrenceMultiplier(4); | 1320 | s.setOccurrenceMultiplier(4); | ||
1319 | QCOMPARE(s.occurrenceMultiplier(), 4); | 1321 | QCOMPARE(s.occurrenceMultiplier(), 4); | ||
1320 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1322 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1321 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYFOURWEEKS); | 1323 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryFourWeeks); | ||
1322 | s.setOccurrenceMultiplier(5); | 1324 | s.setOccurrenceMultiplier(5); | ||
1323 | QCOMPARE(s.occurrenceMultiplier(), 5); | 1325 | QCOMPARE(s.occurrenceMultiplier(), 5); | ||
1324 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1326 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1325 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_WEEKLY); | 1327 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Weekly); | ||
1326 | s.setOccurrenceMultiplier(8); | 1328 | s.setOccurrenceMultiplier(8); | ||
1327 | QCOMPARE(s.occurrenceMultiplier(), 8); | 1329 | QCOMPARE(s.occurrenceMultiplier(), 8); | ||
1328 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1330 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1329 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS); | 1331 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryEightWeeks); | ||
1330 | 1332 | | |||
1331 | s.setOccurrencePeriod(MyMoneySchedule::OCCUR_EVERYHALFMONTH); | 1333 | s.setOccurrencePeriod(Schedule::Occurrence::EveryHalfMonth); | ||
1332 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); | 1334 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::EveryHalfMonth); | ||
1333 | s.setOccurrenceMultiplier(1); | 1335 | s.setOccurrenceMultiplier(1); | ||
1334 | QCOMPARE(s.occurrenceMultiplier(), 1); | 1336 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
1335 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); | 1337 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::EveryHalfMonth); | ||
1336 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); | 1338 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryHalfMonth); | ||
1337 | s.setOccurrenceMultiplier(2); | 1339 | s.setOccurrenceMultiplier(2); | ||
1338 | QCOMPARE(s.occurrenceMultiplier(), 2); | 1340 | QCOMPARE(s.occurrenceMultiplier(), 2); | ||
1339 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); | 1341 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::EveryHalfMonth); | ||
1340 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); | 1342 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryHalfMonth); | ||
1341 | 1343 | | |||
1342 | s.setOccurrencePeriod(MyMoneySchedule::OCCUR_MONTHLY); | 1344 | s.setOccurrencePeriod(Schedule::Occurrence::Monthly); | ||
1343 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1345 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1344 | s.setOccurrenceMultiplier(1); | 1346 | s.setOccurrenceMultiplier(1); | ||
1345 | QCOMPARE(s.occurrenceMultiplier(), 1); | 1347 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
1346 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1348 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1347 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_MONTHLY); | 1349 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Monthly); | ||
1348 | s.setOccurrenceMultiplier(2); | 1350 | s.setOccurrenceMultiplier(2); | ||
1349 | QCOMPARE(s.occurrenceMultiplier(), 2); | 1351 | QCOMPARE(s.occurrenceMultiplier(), 2); | ||
1350 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1352 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1351 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERMONTH); | 1353 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherMonth); | ||
1352 | s.setOccurrenceMultiplier(3); | 1354 | s.setOccurrenceMultiplier(3); | ||
1353 | QCOMPARE(s.occurrenceMultiplier(), 3); | 1355 | QCOMPARE(s.occurrenceMultiplier(), 3); | ||
1354 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1356 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1355 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); | 1357 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThreeMonths); | ||
1356 | s.setOccurrenceMultiplier(4); | 1358 | s.setOccurrenceMultiplier(4); | ||
1357 | QCOMPARE(s.occurrenceMultiplier(), 4); | 1359 | QCOMPARE(s.occurrenceMultiplier(), 4); | ||
1358 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1360 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1359 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYFOURMONTHS); | 1361 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryFourMonths); | ||
1360 | s.setOccurrenceMultiplier(5); | 1362 | s.setOccurrenceMultiplier(5); | ||
1361 | QCOMPARE(s.occurrenceMultiplier(), 5); | 1363 | QCOMPARE(s.occurrenceMultiplier(), 5); | ||
1362 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1364 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1363 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_MONTHLY); | 1365 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Monthly); | ||
1364 | s.setOccurrenceMultiplier(6); | 1366 | s.setOccurrenceMultiplier(6); | ||
1365 | QCOMPARE(s.occurrenceMultiplier(), 6); | 1367 | QCOMPARE(s.occurrenceMultiplier(), 6); | ||
1366 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1368 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1367 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_TWICEYEARLY); | 1369 | QCOMPARE(s.occurrence(), Schedule::Occurrence::TwiceYearly); | ||
1368 | 1370 | | |||
1369 | s.setOccurrencePeriod(MyMoneySchedule::OCCUR_YEARLY); | 1371 | s.setOccurrencePeriod(Schedule::Occurrence::Yearly); | ||
1370 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_YEARLY); | 1372 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Yearly); | ||
1371 | s.setOccurrenceMultiplier(1); | 1373 | s.setOccurrenceMultiplier(1); | ||
1372 | QCOMPARE(s.occurrenceMultiplier(), 1); | 1374 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
1373 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_YEARLY); | 1375 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Yearly); | ||
1374 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_YEARLY); | 1376 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Yearly); | ||
1375 | s.setOccurrenceMultiplier(2); | 1377 | s.setOccurrenceMultiplier(2); | ||
1376 | QCOMPARE(s.occurrenceMultiplier(), 2); | 1378 | QCOMPARE(s.occurrenceMultiplier(), 2); | ||
1377 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_YEARLY); | 1379 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Yearly); | ||
1378 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERYEAR); | 1380 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherYear); | ||
1379 | s.setOccurrenceMultiplier(3); | 1381 | s.setOccurrenceMultiplier(3); | ||
1380 | QCOMPARE(s.occurrenceMultiplier(), 3); | 1382 | QCOMPARE(s.occurrenceMultiplier(), 3); | ||
1381 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_YEARLY); | 1383 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Yearly); | ||
1382 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_YEARLY); | 1384 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Yearly); | ||
1383 | 1385 | | |||
1384 | // Set occurrence: check occurrence, Period and Multiplier | 1386 | // Set occurrence: check occurrence, Period and Multiplier | ||
1385 | s.setOccurrence(MyMoneySchedule::OCCUR_ONCE); | 1387 | s.setOccurrence(Schedule::Occurrence::Once); | ||
1386 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_ONCE); | 1388 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Once); | ||
1387 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_ONCE); | 1389 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Once); | ||
1388 | QCOMPARE(s.occurrenceMultiplier(), 1); | 1390 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
1389 | 1391 | | |||
1390 | s.setOccurrence(MyMoneySchedule::OCCUR_DAILY); | 1392 | s.setOccurrence(Schedule::Occurrence::Daily); | ||
1391 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_DAILY); | 1393 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Daily); | ||
1392 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_DAILY); | 1394 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Daily); | ||
1393 | QCOMPARE(s.occurrenceMultiplier(), 1); | 1395 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
1394 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS); | 1396 | s.setOccurrence(Schedule::Occurrence::EveryThirtyDays); | ||
1395 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS); | 1397 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThirtyDays); | ||
1396 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_DAILY); | 1398 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Daily); | ||
1397 | QCOMPARE(s.occurrenceMultiplier(), 30); | 1399 | QCOMPARE(s.occurrenceMultiplier(), 30); | ||
1398 | 1400 | | |||
1399 | s.setOccurrence(MyMoneySchedule::OCCUR_WEEKLY); | 1401 | s.setOccurrence(Schedule::Occurrence::Weekly); | ||
1400 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_WEEKLY); | 1402 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Weekly); | ||
1401 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1403 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1402 | QCOMPARE(s.occurrenceMultiplier(), 1); | 1404 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
1403 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERWEEK); | 1405 | s.setOccurrence(Schedule::Occurrence::EveryOtherWeek); | ||
1404 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERWEEK); | 1406 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherWeek); | ||
1405 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1407 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1406 | QCOMPARE(s.occurrenceMultiplier(), 2); | 1408 | QCOMPARE(s.occurrenceMultiplier(), 2); | ||
1407 | // Fortnightly no longer used: Every other week used instead | 1409 | // Fortnightly no longer used: Every other week used instead | ||
1408 | s.setOccurrence(MyMoneySchedule::OCCUR_FORTNIGHTLY); | 1410 | s.setOccurrence(Schedule::Occurrence::Fortnightly); | ||
1409 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERWEEK); | 1411 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherWeek); | ||
1410 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1412 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1411 | QCOMPARE(s.occurrenceMultiplier(), 2); | 1413 | QCOMPARE(s.occurrenceMultiplier(), 2); | ||
1412 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHREEWEEKS); | 1414 | s.setOccurrence(Schedule::Occurrence::EveryThreeWeeks); | ||
1413 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHREEWEEKS); | 1415 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThreeWeeks); | ||
1414 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1416 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1415 | QCOMPARE(s.occurrenceMultiplier(), 3); | 1417 | QCOMPARE(s.occurrenceMultiplier(), 3); | ||
1416 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYFOURWEEKS); | 1418 | s.setOccurrence(Schedule::Occurrence::EveryFourWeeks); | ||
1417 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYFOURWEEKS); | 1419 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryFourWeeks); | ||
1418 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1420 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1419 | QCOMPARE(s.occurrenceMultiplier(), 4); | 1421 | QCOMPARE(s.occurrenceMultiplier(), 4); | ||
1420 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS); | 1422 | s.setOccurrence(Schedule::Occurrence::EveryEightWeeks); | ||
1421 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS); | 1423 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryEightWeeks); | ||
1422 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_WEEKLY); | 1424 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Weekly); | ||
1423 | QCOMPARE(s.occurrenceMultiplier(), 8); | 1425 | QCOMPARE(s.occurrenceMultiplier(), 8); | ||
1424 | 1426 | | |||
1425 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYHALFMONTH); | 1427 | s.setOccurrence(Schedule::Occurrence::EveryHalfMonth); | ||
1426 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); | 1428 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryHalfMonth); | ||
1427 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_EVERYHALFMONTH); | 1429 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::EveryHalfMonth); | ||
1428 | QCOMPARE(s.occurrenceMultiplier(), 1); | 1430 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
1429 | 1431 | | |||
1430 | s.setOccurrence(MyMoneySchedule::OCCUR_MONTHLY); | 1432 | s.setOccurrence(Schedule::Occurrence::Monthly); | ||
1431 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_MONTHLY); | 1433 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Monthly); | ||
1432 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1434 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1433 | QCOMPARE(s.occurrenceMultiplier(), 1); | 1435 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
1434 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERMONTH); | 1436 | s.setOccurrence(Schedule::Occurrence::EveryOtherMonth); | ||
1435 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERMONTH); | 1437 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherMonth); | ||
1436 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1438 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1437 | QCOMPARE(s.occurrenceMultiplier(), 2); | 1439 | QCOMPARE(s.occurrenceMultiplier(), 2); | ||
1438 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); | 1440 | s.setOccurrence(Schedule::Occurrence::EveryThreeMonths); | ||
1439 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); | 1441 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThreeMonths); | ||
1440 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1442 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1441 | QCOMPARE(s.occurrenceMultiplier(), 3); | 1443 | QCOMPARE(s.occurrenceMultiplier(), 3); | ||
1442 | // Quarterly no longer used. Every three months used instead | 1444 | // Quarterly no longer used. Every three months used instead | ||
1443 | s.setOccurrence(MyMoneySchedule::OCCUR_QUARTERLY); | 1445 | s.setOccurrence(Schedule::Occurrence::Quarterly); | ||
1444 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYTHREEMONTHS); | 1446 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryThreeMonths); | ||
1445 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1447 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1446 | QCOMPARE(s.occurrenceMultiplier(), 3); | 1448 | QCOMPARE(s.occurrenceMultiplier(), 3); | ||
1447 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYFOURMONTHS); | 1449 | s.setOccurrence(Schedule::Occurrence::EveryFourMonths); | ||
1448 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYFOURMONTHS); | 1450 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryFourMonths); | ||
1449 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1451 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1450 | QCOMPARE(s.occurrenceMultiplier(), 4); | 1452 | QCOMPARE(s.occurrenceMultiplier(), 4); | ||
1451 | s.setOccurrence(MyMoneySchedule::OCCUR_TWICEYEARLY); | 1453 | s.setOccurrence(Schedule::Occurrence::TwiceYearly); | ||
1452 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_TWICEYEARLY); | 1454 | QCOMPARE(s.occurrence(), Schedule::Occurrence::TwiceYearly); | ||
1453 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_MONTHLY); | 1455 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Monthly); | ||
1454 | QCOMPARE(s.occurrenceMultiplier(), 6); | 1456 | QCOMPARE(s.occurrenceMultiplier(), 6); | ||
1455 | 1457 | | |||
1456 | s.setOccurrence(MyMoneySchedule::OCCUR_YEARLY); | 1458 | s.setOccurrence(Schedule::Occurrence::Yearly); | ||
1457 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_YEARLY); | 1459 | QCOMPARE(s.occurrence(), Schedule::Occurrence::Yearly); | ||
1458 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_YEARLY); | 1460 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Yearly); | ||
1459 | QCOMPARE(s.occurrenceMultiplier(), 1); | 1461 | QCOMPARE(s.occurrenceMultiplier(), 1); | ||
1460 | s.setOccurrence(MyMoneySchedule::OCCUR_EVERYOTHERYEAR); | 1462 | s.setOccurrence(Schedule::Occurrence::EveryOtherYear); | ||
1461 | QCOMPARE(s.occurrence(), MyMoneySchedule::OCCUR_EVERYOTHERYEAR); | 1463 | QCOMPARE(s.occurrence(), Schedule::Occurrence::EveryOtherYear); | ||
1462 | QCOMPARE(s.occurrencePeriod(), MyMoneySchedule::OCCUR_YEARLY); | 1464 | QCOMPARE(s.occurrencePeriod(), Schedule::Occurrence::Yearly); | ||
1463 | QCOMPARE(s.occurrenceMultiplier(), 2); | 1465 | QCOMPARE(s.occurrenceMultiplier(), 2); | ||
1464 | } | 1466 | } | ||
1465 | 1467 | | |||
Context not available. | |||||
1467 | { | 1469 | { | ||
1468 | // Conversion between Simple and Compound occurrences | 1470 | // Conversion between Simple and Compound occurrences | ||
1469 | // Each simple occurrence to compound occurrence | 1471 | // Each simple occurrence to compound occurrence | ||
1470 | MyMoneySchedule::occurrenceE occ; | 1472 | Schedule::Occurrence occ; | ||
1471 | int mult; | 1473 | int mult; | ||
1472 | occ = MyMoneySchedule::OCCUR_ONCE; mult = 1; | 1474 | occ = Schedule::Occurrence::Once; mult = 1; | ||
1473 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1475 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1474 | QVERIFY(occ == MyMoneySchedule::OCCUR_ONCE && mult == 1); | 1476 | QVERIFY(occ == Schedule::Occurrence::Once && mult == 1); | ||
1475 | occ = MyMoneySchedule::OCCUR_DAILY; mult = 1; | 1477 | occ = Schedule::Occurrence::Daily; mult = 1; | ||
1476 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1478 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1477 | QVERIFY(occ == MyMoneySchedule::OCCUR_DAILY && mult == 1); | 1479 | QVERIFY(occ == Schedule::Occurrence::Daily && mult == 1); | ||
1478 | occ = MyMoneySchedule::OCCUR_WEEKLY; mult = 1; | 1480 | occ = Schedule::Occurrence::Weekly; mult = 1; | ||
1479 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1481 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1480 | QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 1); | 1482 | QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 1); | ||
1481 | occ = MyMoneySchedule::OCCUR_EVERYOTHERWEEK; mult = 1; | 1483 | occ = Schedule::Occurrence::EveryOtherWeek; mult = 1; | ||
1482 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1484 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1483 | QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 2); | 1485 | QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 2); | ||
1484 | occ = MyMoneySchedule::OCCUR_FORTNIGHTLY; mult = 1; | 1486 | occ = Schedule::Occurrence::Fortnightly; mult = 1; | ||
1485 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1487 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1486 | QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 2); | 1488 | QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 2); | ||
1487 | occ = MyMoneySchedule::OCCUR_EVERYHALFMONTH; mult = 1; | 1489 | occ = Schedule::Occurrence::EveryHalfMonth; mult = 1; | ||
1488 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1490 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1489 | QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYHALFMONTH && mult == 1); | 1491 | QVERIFY(occ == Schedule::Occurrence::EveryHalfMonth && mult == 1); | ||
1490 | occ = MyMoneySchedule::OCCUR_EVERYTHREEWEEKS; mult = 1; | 1492 | occ = Schedule::Occurrence::EveryThreeWeeks; mult = 1; | ||
1491 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1493 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1492 | QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 3); | 1494 | QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 3); | ||
1493 | occ = MyMoneySchedule::OCCUR_EVERYFOURWEEKS; mult = 1; | 1495 | occ = Schedule::Occurrence::EveryFourWeeks; mult = 1; | ||
1494 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1496 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1495 | QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 4); | 1497 | QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 4); | ||
1496 | occ = MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS; mult = 1; | 1498 | occ = Schedule::Occurrence::EveryThirtyDays; mult = 1; | ||
1497 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1499 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1498 | QVERIFY(occ == MyMoneySchedule::OCCUR_DAILY && mult == 30); | 1500 | QVERIFY(occ == Schedule::Occurrence::Daily && mult == 30); | ||
1499 | occ = MyMoneySchedule::OCCUR_MONTHLY; mult = 1; | 1501 | occ = Schedule::Occurrence::Monthly; mult = 1; | ||
1500 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1502 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1501 | QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 1); | 1503 | QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 1); | ||
1502 | occ = MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS; mult = 1; | 1504 | occ = Schedule::Occurrence::EveryEightWeeks; mult = 1; | ||
1503 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1505 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1504 | QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 8); | 1506 | QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 8); | ||
1505 | occ = MyMoneySchedule::OCCUR_EVERYOTHERMONTH; mult = 1; | 1507 | occ = Schedule::Occurrence::EveryOtherMonth; mult = 1; | ||
1506 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1508 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1507 | QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 2); | 1509 | QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 2); | ||
1508 | occ = MyMoneySchedule::OCCUR_EVERYTHREEMONTHS; mult = 1; | 1510 | occ = Schedule::Occurrence::EveryThreeMonths; mult = 1; | ||
1509 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1511 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1510 | QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 3); | 1512 | QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 3); | ||
1511 | occ = MyMoneySchedule::OCCUR_QUARTERLY; mult = 1; | 1513 | occ = Schedule::Occurrence::Quarterly; mult = 1; | ||
1512 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1514 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1513 | QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 3); | 1515 | QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 3); | ||
1514 | occ = MyMoneySchedule::OCCUR_EVERYFOURMONTHS; mult = 1; | 1516 | occ = Schedule::Occurrence::EveryFourMonths; mult = 1; | ||
1515 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1517 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1516 | QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 4); | 1518 | QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 4); | ||
1517 | occ = MyMoneySchedule::OCCUR_TWICEYEARLY; mult = 1; | 1519 | occ = Schedule::Occurrence::TwiceYearly; mult = 1; | ||
1518 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1520 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1519 | QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 6); | 1521 | QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 6); | ||
1520 | occ = MyMoneySchedule::OCCUR_YEARLY; mult = 1; | 1522 | occ = Schedule::Occurrence::Yearly; mult = 1; | ||
1521 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1523 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1522 | QVERIFY(occ == MyMoneySchedule::OCCUR_YEARLY && mult == 1); | 1524 | QVERIFY(occ == Schedule::Occurrence::Yearly && mult == 1); | ||
1523 | occ = MyMoneySchedule::OCCUR_EVERYOTHERYEAR; mult = 1; | 1525 | occ = Schedule::Occurrence::EveryOtherYear; mult = 1; | ||
1524 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | 1526 | MyMoneySchedule::simpleToCompoundOccurrence(mult, occ); | ||
1525 | QVERIFY(occ == MyMoneySchedule::OCCUR_YEARLY && mult == 2); | 1527 | QVERIFY(occ == Schedule::Occurrence::Yearly && mult == 2); | ||
1526 | // Compound to Simple Occurrences | 1528 | // Compound to Simple Occurrences | ||
1527 | occ = MyMoneySchedule::OCCUR_ONCE; mult = 1; | 1529 | occ = Schedule::Occurrence::Once; mult = 1; | ||
1528 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1530 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1529 | QVERIFY(occ == MyMoneySchedule::OCCUR_ONCE && mult == 1); | 1531 | QVERIFY(occ == Schedule::Occurrence::Once && mult == 1); | ||
1530 | occ = MyMoneySchedule::OCCUR_DAILY; mult = 1; | 1532 | occ = Schedule::Occurrence::Daily; mult = 1; | ||
1531 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1533 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1532 | QVERIFY(occ == MyMoneySchedule::OCCUR_DAILY && mult == 1); | 1534 | QVERIFY(occ == Schedule::Occurrence::Daily && mult == 1); | ||
1533 | occ = MyMoneySchedule::OCCUR_WEEKLY; mult = 1; | 1535 | occ = Schedule::Occurrence::Weekly; mult = 1; | ||
1534 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1536 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1535 | QVERIFY(occ == MyMoneySchedule::OCCUR_WEEKLY && mult == 1); | 1537 | QVERIFY(occ == Schedule::Occurrence::Weekly && mult == 1); | ||
1536 | occ = MyMoneySchedule::OCCUR_WEEKLY; mult = 2; | 1538 | occ = Schedule::Occurrence::Weekly; mult = 2; | ||
1537 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1539 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1538 | QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYOTHERWEEK && mult == 1); | 1540 | QVERIFY(occ == Schedule::Occurrence::EveryOtherWeek && mult == 1); | ||
1539 | // MyMoneySchedule::OCCUR_FORTNIGHTLY not converted back | 1541 | // Schedule::Occurrence::Fortnightly not converted back | ||
1540 | occ = MyMoneySchedule::OCCUR_EVERYHALFMONTH; mult = 1; | 1542 | occ = Schedule::Occurrence::EveryHalfMonth; mult = 1; | ||
1541 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1543 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1542 | QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYHALFMONTH && mult == 1); | 1544 | QVERIFY(occ == Schedule::Occurrence::EveryHalfMonth && mult == 1); | ||
1543 | occ = MyMoneySchedule::OCCUR_WEEKLY; mult = 3; | 1545 | occ = Schedule::Occurrence::Weekly; mult = 3; | ||
1544 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1546 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1545 | QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYTHREEWEEKS && mult == 1); | 1547 | QVERIFY(occ == Schedule::Occurrence::EveryThreeWeeks && mult == 1); | ||
1546 | occ = MyMoneySchedule::OCCUR_WEEKLY ; mult = 4; | 1548 | occ = Schedule::Occurrence::Weekly ; mult = 4; | ||
1547 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1549 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1548 | QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYFOURWEEKS && mult == 1); | 1550 | QVERIFY(occ == Schedule::Occurrence::EveryFourWeeks && mult == 1); | ||
1549 | occ = MyMoneySchedule::OCCUR_DAILY; mult = 30; | 1551 | occ = Schedule::Occurrence::Daily; mult = 30; | ||
1550 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1552 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1551 | QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYTHIRTYDAYS && mult == 1); | 1553 | QVERIFY(occ == Schedule::Occurrence::EveryThirtyDays && mult == 1); | ||
1552 | occ = MyMoneySchedule::OCCUR_MONTHLY; mult = 1; | 1554 | occ = Schedule::Occurrence::Monthly; mult = 1; | ||
1553 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1555 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1554 | QVERIFY(occ == MyMoneySchedule::OCCUR_MONTHLY && mult == 1); | 1556 | QVERIFY(occ == Schedule::Occurrence::Monthly && mult == 1); | ||
1555 | occ = MyMoneySchedule::OCCUR_WEEKLY; mult = 8; | 1557 | occ = Schedule::Occurrence::Weekly; mult = 8; | ||
1556 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1558 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1557 | QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYEIGHTWEEKS && mult == 1); | 1559 | QVERIFY(occ == Schedule::Occurrence::EveryEightWeeks && mult == 1); | ||
1558 | occ = MyMoneySchedule::OCCUR_MONTHLY; mult = 2; | 1560 | occ = Schedule::Occurrence::Monthly; mult = 2; | ||
1559 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1561 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1560 | QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYOTHERMONTH && mult == 1); | 1562 | QVERIFY(occ == Schedule::Occurrence::EveryOtherMonth && mult == 1); | ||
1561 | occ = MyMoneySchedule::OCCUR_MONTHLY; mult = 3; | 1563 | occ = Schedule::Occurrence::Monthly; mult = 3; | ||
1562 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1564 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1563 | QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYTHREEMONTHS && mult == 1); | 1565 | QVERIFY(occ == Schedule::Occurrence::EveryThreeMonths && mult == 1); | ||
1564 | // MyMoneySchedule::OCCUR_QUARTERLY not converted back | 1566 | // Schedule::Occurrence::Quarterly not converted back | ||
1565 | occ = MyMoneySchedule::OCCUR_MONTHLY; mult = 4; | 1567 | occ = Schedule::Occurrence::Monthly; mult = 4; | ||
1566 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1568 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1567 | QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYFOURMONTHS && mult == 1); | 1569 | QVERIFY(occ == Schedule::Occurrence::EveryFourMonths && mult == 1); | ||
1568 | occ = MyMoneySchedule::OCCUR_MONTHLY; mult = 6; | 1570 | occ = Schedule::Occurrence::Monthly; mult = 6; | ||
1569 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1571 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1570 | QVERIFY(occ == MyMoneySchedule::OCCUR_TWICEYEARLY && mult == 1); | 1572 | QVERIFY(occ == Schedule::Occurrence::TwiceYearly && mult == 1); | ||
1571 | occ = MyMoneySchedule::OCCUR_YEARLY; mult = 1; | 1573 | occ = Schedule::Occurrence::Yearly; mult = 1; | ||
1572 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1574 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1573 | QVERIFY(occ == MyMoneySchedule::OCCUR_YEARLY && mult == 1); | 1575 | QVERIFY(occ == Schedule::Occurrence::Yearly && mult == 1); | ||
1574 | occ = MyMoneySchedule::OCCUR_YEARLY; mult = 2; | 1576 | occ = Schedule::Occurrence::Yearly; mult = 2; | ||
1575 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | 1577 | MyMoneySchedule::compoundToSimpleOccurrence(mult, occ); | ||
1576 | QVERIFY(occ == MyMoneySchedule::OCCUR_EVERYOTHERYEAR && mult == 1); | 1578 | QVERIFY(occ == Schedule::Occurrence::EveryOtherYear && mult == 1); | ||
1577 | } | 1579 | } | ||
1578 | 1580 | | |||
1579 | void MyMoneyScheduleTest::testProcessingDates() | 1581 | void MyMoneyScheduleTest::testProcessingDates() | ||
Context not available. | |||||
1625 | try { | 1627 | try { | ||
1626 | sch = MyMoneySchedule(node); | 1628 | sch = MyMoneySchedule(node); | ||
1627 | QVERIFY(sch.isFinished() == true); | 1629 | QVERIFY(sch.isFinished() == true); | ||
1628 | QVERIFY(sch.occurrencePeriod() == MyMoneySchedule::OCCUR_MONTHLY); | 1630 | QVERIFY(sch.occurrencePeriod() == Schedule::Occurrence::Monthly); | ||
1629 | QVERIFY(sch.paymentDates(QDate::currentDate(), QDate::currentDate().addDays(21)).count() == 0); | 1631 | QVERIFY(sch.paymentDates(QDate::currentDate(), QDate::currentDate().addDays(21)).count() == 0); | ||
1630 | } catch (const MyMoneyException &) { | 1632 | } catch (const MyMoneyException &) { | ||
1631 | QFAIL("Unexpected exception"); | 1633 | QFAIL("Unexpected exception"); | ||
Context not available. | |||||
1640 | QDate dueDate(2010, 5, 23); | 1642 | QDate dueDate(2010, 5, 23); | ||
1641 | QDate adjustedDueDate(2010, 5, 21); | 1643 | QDate adjustedDueDate(2010, 5, 21); | ||
1642 | s.setNextDueDate(dueDate); | 1644 | s.setNextDueDate(dueDate); | ||
1643 | s.setOccurrence(MyMoneySchedule::OCCUR_MONTHLY); | 1645 | s.setOccurrence(Schedule::Occurrence::Monthly); | ||
1644 | s.setWeekendOption(MyMoneySchedule::MoveBefore); | 1646 | s.setWeekendOption(Schedule::WeekendOption::MoveBefore); | ||
1645 | 1647 | | |||
1646 | //if adjustedNextPayment works ok with adjusted date prior to the current date, it should return 2010-06-23 | 1648 | //if adjustedNextPayment works ok with adjusted date prior to the current date, it should return 2010-06-23 | ||
1647 | QDate nextDueDate(2010, 6, 23); | 1649 | QDate nextDueDate(2010, 6, 23); | ||
Context not available. | |||||
1703 | QDate refDate(2011, 8, 10); // just some ref date before the last payment | 1705 | QDate refDate(2011, 8, 10); // just some ref date before the last payment | ||
1704 | 1706 | | |||
1705 | s.setStartDate(endDate.addMonths(-1)); | 1707 | s.setStartDate(endDate.addMonths(-1)); | ||
1706 | s.setOccurrence(MyMoneySchedule::OCCUR_MONTHLY); | 1708 | s.setOccurrence(Schedule::Occurrence::Monthly); | ||
1707 | s.setEndDate(endDate); | 1709 | s.setEndDate(endDate); | ||
1708 | // the next due date is on this day but the policy is to move the | 1710 | // the next due date is on this day but the policy is to move the | ||
1709 | // schedule to the next processing day (Monday) | 1711 | // schedule to the next processing day (Monday) | ||
1710 | s.setWeekendOption(MyMoneySchedule::MoveAfter); | 1712 | s.setWeekendOption(Schedule::WeekendOption::MoveAfter); | ||
1711 | s.setNextDueDate(endDate); | 1713 | s.setNextDueDate(endDate); | ||
1712 | 1714 | | |||
1713 | // the payment should be found between the respective date and one month after | 1715 | // the payment should be found between the respective date and one month after | ||
Context not available. |