Bug 221800

Summary: Make use of KGlobal::locale to calculate the working week and KHolidays for other non-working days
Product: [Applications] kmymoney Reporter: Ian Neal <iann_bugzilla>
Component: generalAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: HolidayRegion patch v0.1
Holiday Patch v0.2a
Holiday Patch v0.2b

Description Ian Neal 2010-01-08 14:57:26 UTC
Version:            (using KDE 4.3.4)
OS:                Linux
Installed from:    Fedora RPMs

At the moment the working week is fixed for scheduled transactions as being Monday to Friday. There is also no concept of other non-working days (for example in the UK, Bank Holidays).
The working week can be calculated from KGlobal::locale and there is existing functionality in KHolidays class to set a region and use its holiday calendar to find out holidays (those set to red or weekend).
Comment 1 Ian Neal 2010-01-08 15:01:24 UTC
Created attachment 39687 [details]
HolidayRegion patch v0.1

This patch makes the following changes:
* Switch from MoveFriday/MoveMonday to MoveBefore/MoveAfter for use with scheduled transactions;
* Strings with Friday / Monday now use previous / next working day;
* Strings with Weekend now use non-working days;
* Removed duplicate code from kenterscheduledlg.cpp and got it to use the code from mymoneyscheduled.cpp;
* Added UI to scheduled transactions settings page to be able to select relevant holiday calendar that the OS knows about as well as a (None) option;
* Added routine to calculate working week from KGlobal::locale() to kmymoney.cpp;
* Added methods to mymoneyscheduled.cpp to read/write holiday region and working week for scheduled transactions;
* Added defaults for holiday region (gb) and working week (Monday-Friday) to mymoneyscheduled.cpp;
* In mymoneyscheduled.cpp split some of the code out of adjustedNextDueDate to create adjustedDate so that kenterscheduledlg.cpp could use it instead of duplicating code;
* Rewrote the code in adjustedDate to it reflects the locale's working week and the selected holiday region;
* Added a new test that makes sure the working week is set correctly and working/non-working days are identified correctly;
* Added further tests to testAdjustedNextDueDate to make sure that the adjusted date is correct for non-working days not just weekends;
* Corrected it's vs its in various comments throughout code.

KHoliday assumes that any day marked as red or weekend is a holiday and at the moment it has no concept of financial holidays so I've worked with what it has provided.
Comment 2 Ian Neal 2010-01-11 23:57:21 UTC
Created attachment 39794 [details]
Holiday Patch v0.2a

Changes since v0.1:
* Switched from using the term working day to the term processing day to help avoid confusion with days that users work and days that institutions process transactions;
* Removed dependency on KHolidays from mymoneyscheduled.h/cpp as requested by Thomas (and with some help from him) by introducing an interface class IMyMoneyProcessingCalendar;
* Used m_regionMap instead of mRegionMap as requested;
* Removed use of depreciated QComboBox text method and used itemText instead;
* Added to mymoneyscheduletest test for checking new interface class and the fall back is working.
Comment 3 Ian Neal 2010-01-14 22:16:56 UTC
Created attachment 39905 [details]
Holiday Patch v0.2b

Unbitrotted against current svn.
Are there any other changes or is this ready to go into svn?
Comment 4 Thomas Baumgart 2010-01-17 20:26:13 UTC
SVN commit 1076212 by tbaumgart:

Added patch provided by Ian Neal

FEATURE: 221800
GUI:

 M  +4 -2      CMakeLists.txt  
 M  +1 -1      kmymoney/CMakeLists.txt  
 M  +1 -1      kmymoney/converter/mymoneygncreader.cpp  
 M  +4 -4      kmymoney/dialogs/keditscheduledlg.cpp  
 M  +3 -3      kmymoney/dialogs/keditscheduledlgdecl.ui  
 M  +1 -17     kmymoney/dialogs/kenterscheduledlg.cpp  
 M  +71 -0     kmymoney/dialogs/settings/ksettingsschedules.cpp  
 M  +14 -1     kmymoney/dialogs/settings/ksettingsschedules.h  
 M  +58 -6     kmymoney/dialogs/settings/ksettingsschedulesdecl.ui  
 M  +48 -2     kmymoney/kmymoney.cpp  
 M  +14 -4     kmymoney/kmymoney.h  
 M  +4 -0      kmymoney/kmymoney.kcfg  
 M  +8 -8      kmymoney/kmymoneyutils.h  
 M  +1 -0      kmymoney/mymoney/CMakeLists.txt  
 M  +44 -25    kmymoney/mymoney/mymoneyscheduled.cpp  
 M  +58 -23    kmymoney/mymoney/mymoneyscheduled.h  
 M  +45 -28    kmymoney/mymoney/mymoneyscheduletest.cpp  
 M  +2 -0      kmymoney/mymoney/mymoneyscheduletest.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1076212
Comment 5 Alvaro Soliverez 2010-01-18 02:57:36 UTC
SVN commit 1076352 by asoliverez:

Added missing file to the patch. Please check it's the right version, but it compiles fine here.

FEATURE: 221800

 A             imymoneyprocessingcalendar.h   [License: GPL (v2+)]


WebSVN link: http://websvn.kde.org/?view=rev&revision=1076352