transaction.scm date subtotal options - calling wizards ...

Christopher Lam christopher.lck at gmail.com
Fri Sep 22 11:41:10 EDT 2017


Hi John,



The origin of this project comes from my wish to produce report... "how
much did I spend on various categories, in this quarter?"


Source account=Asset:Bank.

Prime-sortkey=date

Prime-subtotal=quarterly

Sec-sortkey=other-accname

Sec-subtotal=true



2016Q1

Expense:Groceries

01/01/16 – Allmart $200

01/02/16 – Qmart $300

01/03/16 – Nomart $300

*Subtotal Expense:Groceries $800*

Expense:Petrol

15/01/16 – Coral $300

15/02/16 – BQ $250

* Subtotal Expense:Petrol $550*

* Subtotal 2016Q1 = $1350*



However the current query mechanism means that the dates will be split up,
because, although they belong to the same quarter, they have different
dates.

qof-query mechanism cannot sort by quarter... can only sort by date.


I attach 2 screenshots to illustrate and the sample test file. This is my
amended transaction.scm and the original/custom sorter can be chosen in the
checkbox.


C

On 22 September 2017 at 23:33, Christopher Lam <christopher.lck at gmail.com>
wrote:

> Hi John,
>
>
>
> The origin of this project comes from my wish to produce report.
>
> Source account=Asset:Bank. Prime-sortkey=date (subtotal quarterly) and
> sec-sortkey=other-accname (subtotal=true).
>
>
>
> 2016Q1
>
> Expense:Groceries
>
> 01/01/16 – Allmart $200
>
> 01/02/16 – Qmart $300
>
> 01/03/16 – Nomart $300
>
> *Subtotal Expense:Groceries $800*
>
> Expense:Petrol
>
> 15/01/16 – Coral $300
>
> 15/02/16 – BQ $250
>
> * Subtotal Expense:Petrol $550*
>
> * Subtotal 2016Q1 = $1350*
>
>
>
> However the current query mechanism means that the dates will be split up,
> because they’
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> *From: *John Ralls <jralls at ceridwen.us>
> *Sent: *Friday, 22 September 2017 10:40 PM
> *To: *Christopher Lam <christopher.lck at gmail.com>
> *Cc: *gnucash-devel at lists.gnucash.org
> *Subject: *Re: transaction.scm date subtotal options - calling wizards ...
>
>
>
>
>
>
>
> On Sep 22, 2017, at 5:48 AM, Christopher Lam <christopher.lck at gmail.com>
> wrote:
>
>
>
> Hi devs,
>
> While working on transaction.scm (again) to fix a sorting/grouping bug[1],
> I came across some inconsistencies:
>
> 1. if I choose sortkey "date" "exact-time" -- they do the exact same thing,
> but otherwise work well
>
> 2. if I choose sortkey "reconciled date" -- it does what it says, however
> *the date-subtotal selector is not used at all.*
>
> 3. if I choose sortkey "register order"
> (a) first, I'm not entirely sure what exactly this mean - *does it mean,
> sort by EntryDate *(accessible by xaccTransGetDateEntered
> <https://wiki.gnucash.org/docs/MASTER/group__Transaction.html#
> gaa03b01c98f9ac644074a19a182cd5dd3>)
>
> (b) second, it allows date-subtotal selection, which to me is puzzling, but
> could be acceptable if we're sorting by EntryDate
>
> My conclusion from above would be that the original date-sorting-types has
> a typo, it was (define date-sorting-types (list 'date 'exact-time
> 'register-order)) but it should really be (define date-sorting-types (list
> 'date 'exact-time 'reconciled-date))
>
> *What would be the consensus from wizards if we had to do it right?*
>
> I suggest:
> 1. We change (define date-sorting-types (list 'date 'exact-time
> 'reconciled-date))
> 2. When sorting by register-order, it should disallow date-subtotals
>
> My solution to produce my report correctly requires a custom sorting
> algorithm which is nearly complete, and would override the
> qof-query-set-sort-order. Work-in-progress at
> https://github.com/christopherlam/gnucash/commits/master-fix-grouping-
> by-date
>
> [1] this bug relates to my preferred sorting/grouping: prime-sortkey=date,
> subtotal=quarterly, sec-sortkey=account-name, subtotal=true. This will
> produce an incorrect grouping whereby a quarter (eg 2016 Q1) will be split
> incorrectly, because the query will sort by dates rather than quarters.
> Documented in my comment on
> https://bugzilla.gnome.org/show_bug.cgi?id=626385
>
>
>
> Christopher,
>
>
>
> I would expect “Register Order” to mean the normal sorting order of
> transactions in the register:
>
> date-posted, num, date-entered, description, though it’s possible that it
> would look at the Sort By… settings on the source register.
>
>
>
> “Date” should be “date-posted” for clarity. While a sort of date-entered
> might be amusing it’s not particularly useful. Exact time on date-posted
> isn’t meaningful: All transactions are posted at 10:59Z so that the date
> remains the same in most time zones. Similarly I’d expect that most
> date-reconciled entries will be grouped on a single date and time since
> it’s unusual to reconcile an account more than once per day (or even once
> per month for most people).
>
>
>
> I don’t understand your analysis that "a quarter (eg 2016 Q1) will be
> split incorrectly, because the query will sort by dates rather than
> quarters”. Sorting by quarters is just a large-granularity sort by date; a
> sort by date at day granularity should be easily divided by quarters.
>
>
>
> Regards,
>
> John Ralls
>
>
>
>
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sort-test.gnucash
Type: application/x-gnucash
Size: 1702 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20170922/d43447df/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: original-sort.png
Type: image/png
Size: 280969 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20170922/d43447df/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: my-sort.png
Type: image/png
Size: 266679 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20170922/d43447df/attachment-0003.png>


More information about the gnucash-devel mailing list