[Kmymoney-devel] Patch for HolidayRegion and Working Week

Colin cdwright at gwi.net
Sat Jan 9 06:03:07 CET 2010


On Thursday January 7 2010 05:02 pm Ian Neal wrote:
>   Colin wrote:
> > On Wednesday January 6 2010 08:32 pm Ian Neal wrote:
> >> Hi all,
> >>
> >> Find attached a patch (gzipped due to size) for the current kmymoney svn
> >> which 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.
> >>
> >> Any constructive comments/feedback/review are welcome,
> >>
> >> TIA,
> >>
> >> Ian
> >
> > My comments:
> > * Not tested it, but it looks great, Ian.  I've been wanting to see
> > calendar support for some time.
> 
> Thanks
> 
> > * I'd default Schedule working works and holidays using the settings
> > instead of hard-coding to British.  If you must hard-code I'd default to
> > USA for consistency: I know it can be wearing but defaulting to US make
> > particular sense given the tighter integration with KDE.
> 
> Which settings are you referring to that I should be using? The reason I
> used British for the default (which is used for testing) is that I know
> exactly which days holidays are on and can adapt the tests round those,
> I'd not have the same certainty with the USA ones. Is holiday_us
> currently correct, are there 10 days when banks don't open? (Actually I
> am waiting for a correction to holiday_gb as it is). If someone can
> confirm some federal days when banks do not open (that match the
> holiday_us) then I am happy to change the testing default to USA.
I've looked at holiday_us.

The federal holiday list is correct so you can use it.
Banks will, in particular be closed on New Year's Day, Independence Day, 
Thanksgiving and Christmas so sticking to those days should be fine.

You might want a comment noting that you know that the importance of holidays 
varies by state and banks may observe holidays differently.

Most banks (and other employers) "observe" date-specific holidays that fall on 
weekends on the Friday if Saturday or Monday if Sunday.  (Yes, they'll observe 
New Year's Day 2011 in 2010!)  Plus, some will close on the Thanksgiving 
Friday as well as Thursday.  I don't know whether that would stop the 
processing of electronic payments though.

Also, our credit union processes payments on Saturdays but not Sundays or 
holidays.  I don't know if that's typical.

USA really is a Union of States.  Not all banks in all states close on all 
federal holidays.  Some States also have additional state holidays (see 
http://en.wikipedia.org/wiki/Public_holidays_of_the_United_States#Legal_Holidays_by_States) 
but banks may not close on those.  Maine, where I live, has Patriot's Day as a 
state holiday but banks are open on that day.

> 
> > * I'd prefer to have a separate Calendar class with work weeks and
> > holidays. * You'd be able to assign the same Calendar to multiple
> > Schedules. * You could have Working Day date math in the class: then we
> > add "Every n Working Days" Occurrence
> >    * It would be easier to expand the Calendar functionality later to
> > support user-defined Calendars to allow Schedules to deal with the
> > variability of US public holidays and school holidays.
> 
> As far as I am concerned we have to rely on the facilities provided by
> KHolidays as/when that gets rewritten / enhanced we can take advantage
> of those new features.
As you said below KDE allows user-defined calendars so forget the 2nd bit.  (We 
could do with a nice KDE Holiday Calendar editor though.  Is there one?

However, we have two different settings that go together "working days" and 
"holidays".  By putting this in a different class we can have a single dialog 
where you set the working days and holidays. store the pair of settings 
together in a record in a "Calendar" table and point to it by Id from 
Schedules and Institutions.  That way we normalize the data and the user will 
only have to set up each combination once.

> To answer your suggestions:

> 
>     * At the moment you do use the same calendar for all
>       schedules/accounts/institutions - perhaps it could be enhanced so
>       that you can override that calendar for some accounts/institutions
>       though not sure the reasons for doing it for schedules. A usage
>       case for schedules might help explain. Either way that is a future
>       enhancement not in the scope of this work (at the moment).
Calendars by schedule would be useful for work-related expenses.  For example, 
my wife and I commute 40+ miles each working day.  Work miles are the major 
reason for a regular fill-up, especially for the 2nd car.  She's a teacher, so 
has lots of vacation days in addition to the holidays.  I work for a state 
agency in Maine so not only do I not work on federal and state holidays I also 
have 10 shutdown days each year from July 2009 to end June 2011.

Similarly at the local high school the children have a lunch account which 
parents or the child can deposit money into.  That would be refilled every n 
school days.  Children don't have school on holidays, in-service days or 
during school vacation.  Being able to use a calendar would make it easier to 
schedule.

If we ever implement formulas in transaction values having a calendar would 
allow scheduling of income or expenses with values dependent on the number of 
working days.

>     * Again a usage case for "Every n Working Days" would be useful (I
>       can think of one for n=1, bus/tram fair, but that could possibly
>       be covered by a 4th option for the weekendOption of "Skip Payment"
>       or something like that). A future enhancement anyway.
See above.  n=1 would be skippable but n > 1 not.

I can't think of a case for a "Skip Payment" weekend option, although I can 
for a general "Automatically Skip Payment" option: I have dummy schedules 
entered to help with forecasting and automatically skipping would save me a 
couple of clicks.

>     * As far as I am aware you can already create user defined calendars
>       (~/.holiday) but I've not tested that, but I would again say that
OK, I didn't know that.  I guess KDE needs a calendar editor.
>       was part of KHolidays.


> 
> Regards,
> 
> Ian
> 

Colin


More information about the KMyMoney-devel mailing list