Bug ID: 393168
           Summary: [Patch] Fix working week in 5.x/master
           Product: kmymoney
           Version: git (master)
          Platform: Other
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
  Target Milestone: ---

Created attachment 112047
Working week patch

Hello developers,

First of all, thank you all for this great piece of software!

(I've been mostly a user of KMyMoney, and just started to learn about coding
recently.  It's my first time submitting a bug report (and a proposed patch),
so kindly please bear with me if there's any infelicities in my expression)

There's a feature in scheduled transactions which allow them to move
backwards/forwards in case a scheduled entry falls on a non-processing day,
e.g. a weekend.  However, I've noticed that that seems to have stopped working
in 5.x/master.

That's working in 4.8.  Out of curiosity I tried to find out what's changed.

It turns out there seems to be an 'overlooked' word in the porting of 'working
week' to kf5, namely that:

-  // TODO: port kf5
-  int weekStart = 1;//KLocale::global()->workingWeekStartDay();
-  int weekEnd = 7;//KLocale::global()->workingWeekEndDay();
+  QLocale locale;
+  int weekStart = locale.firstDayOfWeek();
+  int weekEnd = weekStart-1;
+  if (weekEnd < Qt::Monday) {
+    weekEnd = Qt::Sunday;
+  }

well in fact, weekStart and weekEnd would be referring to the workingWeek, so
in most cultures that'll actually be 1 and 5 (i.e. Monday to Friday).

In searching for alternatives (in porting away from KLocale in its wake), I
found from my Google searches QLocale::weekdays() (as opposed to weekends)
which seems to be a good replacement -- from the QT docs:

Returns a list of days that are considered weekdays according to the current

So in the proposed patch attached I've set m_processingDays accordingly from
QLocale::weekdays().  I've also moved down the #ifdef in
KMyMoneyApp::isProcessingDate so that it could always check against
weekdays/ends even without KF5Holidays.

Sorry for the lengthy description  (And don't be mistaken, there's not a scant
of criticism at all.  To the contrary I appreciate all the developers' efforts
all along, and the KF5 port must have been a little bit tedious)

And actually I'm very green at coding.   Very much appreciated if interested
developer(s) could help review the proposed patch --- and feel free to amend /
enhance it in any way you like.    

* * *

Some related past commits below for your reference:

2017-09-13  Ported start of week handing to KF5

2016-06-16  Remove kdelibs4support, disbaled some code which will need to be

The feature (and the m_processingDays bitArray) was first introduced some 8
years ago:
2010-01-17  Added patch provided by Ian Neal
For reference, the related discussion about the implementation could be found
in FEATURE: 221800

You are receiving this mail because:
You are watching all bug changes.

Reply via email to