Topic: Error editing (updating) Account Groups in 2.3 CVS

I have tried to set the following account groups:

0 - Level 1 TEST 1
00 - Level 2 TEST 1
000 - Level 3 - TEST 1-1
001 - Level 3 - TEST 1-2
01 - Level 2 - TEST 2
010 - Level 3 - TEST 2-1
011 - Level 3 - TEST 2-2
...

When I've tried to edit account group 00 ("Level 2 TEST 1"), I've got an error:
"You cannot set an account group to be a subgroup of itself."

At that moment, I've also noticed that 00 ("Level 2 TEST 1") is actually not listed as a subgroup of 0 ("Level 1 TEST 1"), altough I've entered it that way. The same is with 000 ("Level 3 - TEST 1-1") and 001 ("Level 3 - TEST 1-2"), which should be subgroups of 00. When I click to edit them, 000 and 001 are reported to be subgroups of 0 instead of 00.

Account groups 01 and 010 are OK.

I guess the problem is that somewhere 0 and 00 are still treated as the same (integers instead of strings...).

Re: Error editing (updating) Account Groups in 2.3 CVS

Yes, will be fixed asap.

/Joe

Re: Error editing (updating) Account Groups in 2.3 CVS

CVS unstable (2.3 CVS) is updated. Affected files:

/gl/includes/db/gl_db_account_types.inc
/gl/manage/gl_account_classes.php
/gl/manage/gl_account_types.php
/includes/ui/ui_lists.inc

Thanks for reporting this.

/Joe

Re: Error editing (updating) Account Groups in 2.3 CVS

joe,

thank you for a quick fix.

Unfortunately, it doesn't seem to (completely) resolve the issue.

"Subgroup of" in Account Groups table now contains entries, but I am still getting the error "You cannot set an account group to be a subgroup of itself." when I try to edit level 2 or level 3 subaccounts (level 1 subaccount can be edited and saved).

I've checked - all files you are listing are updated (new).

BTW, I've noticed all default level 1 subgroups have parent -1 (in the database), while my level 1 test entry got 0 after editing (was set to be a subgroup of itself immediately after CVS update).

Rgds,

LUTi

Re: Error editing (updating) Account Groups in 2.3 CVS

It is the zeros that are causing the problems. You can either change your groups one by one by editing them and select None for parent and save again. Or you can use phpMyAdmin and change all the 0 in parents to an empty string.
Or you can use this SQL for fixing this.

UPDATE `0_chart_types` SET parent='' WHERE parent='0' OR parent='-1';

After that, you can again use 0 as a parent if there is such a group.

This SQL is going to be part of alter2.3.sql when upgrading in a while.

/Joe

Re: Error editing (updating) Account Groups in 2.3 CVS

Hi,

I've set all subgroups (00 / 000) to None (empty) through web interface (went well).

After, when I've tried to set group 0 as a parent of 00, I've got (well known): "You cannot set an account group to be a subgroup of itself.".

So, there seems to be some "numeric" check remaining, which is causing this (annoying) error report...

Editing database manually (not with phpMyAdmin, which is quite slow sometimes...; I prefer HeidiSQL, and suggest it to the others as well) seems to do the trick (table is now displayed well), but this bug can probably not be considered as 100% resolved yet (since we can not edit account types through the web interface...).

In next days, I'll try to see how it behaves (in other activities than just enter / edit it...).

Thanks & regards,

LUTi

Re: Error editing (updating) Account Groups in 2.3 CVS

This was related to the following expressing in php:
if ("00" == "0")

This will return true in php. I have now used strcmp instead for comparing the strings in the file /gl/manage/gl_account_types.php, but there is still a problem when setting the correct type in the listbox (for parent). I will have to discuss this with Janusz.
In the meantime you can pick up the latest revision in the CVS unstable.

/Joe

8 (edited by LUTi 03/24/2010 08:39:26 am)

Re: Error editing (updating) Account Groups in 2.3 CVS

joe,

thank you, editing of all levels ("0", "00", "000" tested) seems to work fine now.

What exactly do you mean by a problem setting type of parent? The only situation when I've got the error was setting "00" (intermediate level) to some other type (went OK) and than back to the type "00" had before (and, is same as "0" and "00"). In this case (or, when tried to change type to something else...) I got the error "id = 00, parent = 00".

I was able to come around setting type of "0" to type of "00" first, than set "00" type (to the desired type, can be whatever...) and at the end set type of "0" back (can be whatever). For sure it is not nice to have a situation that end with error, but as it is now fulfills my needs quite well (I don't expect to change types very often...).

Probably the cause is in some numeric/string conversions? I believe in those IDs you have to get rid of any numeric treatment, and compare (sub)strings - if some sting matches left part of another string, it can be a parent (example: 0 at level 1 and 00 at level 2), but doesn't have to be (example: 1 and 11, when both level 1). If it doesn't, it can't be (example: 0 at level 1 and 11 at level 2).

But, why are parents tested at all, when setting (changing) a group type? If we can change a subgroup to something different as a parent, but we can not change back to the same type? I could understand the opposite (restricting the type of subgroup to the type of a parent), but I need them to be different in some cases. At the end, it should be a responsability of admin to take care about that (maybe we could display a warning that something unusual is happening, but in some groups I need them to be different!).

Regarding types, I would have just a remark (became even more obvious when I was doing the moves as above, and account groups were jumping here and there...) - everything (assounts and account groups) should be ordered by account ID by my opinion, not by account types. If the list is longer, it becomes even more annoying searching some account around.  Or, to have a preference about how those lists are ordered - this would be even better, as anyone could adjust how he/she wants to see something (I would defenitely choose by IDs, as we have for example 2 different types of subgroups - incomes and costs - within one main group in official COA).

Re: Error editing (updating) Account Groups in 2.3 CVS

Janusz has how fixed the combox group order. I have tested further on the subject and fixed a couple of other minor errors. Now the types is working as intended.

Please update your CVS unstable. The files affected are:
/includes/ui/ui_lists.inc
/gl/includes/db/gl_db_account_types.inc
/gl/manage/gl_account_types.php

/Joe

10 (edited by LUTi 03/25/2010 07:50:29 am)

Re: Error editing (updating) Account Groups in 2.3 CVS

Changing class types seems to work well now, thank you.

Subgroup parent list seems to be a bit unodrered though. Could be unpleaseant if there are many groups (a long list), with similar names (titles). Probably the order shall be by Group ID, considering level order as well (as it would be in a table above if it wouldn't be odrered by class types first). I am attaching a screenshot.

What about (an option to have) account groups ordered by "Group ID" (instead of "Class Type") in a table displayed? Shall I put this in feature requests?

11 (edited by LUTi 03/25/2010 08:00:48 am)

Re: Error editing (updating) Account Groups in 2.3 CVS

It seems I have a problem with a screenshot attachment. Another try...

Doesn't work... Is it not possible to attach a JPG screenshot?

A try with zipped one...  Doesn't work. :-(

OK, no screenshot...

I have to type it:

my groups are:
0     - level 1 - TEST
00   - level 2 - TEST1
000 - level 3 - TEST1-1
001 - level 3 - TEST1-2
01   - level 2 - TEST2
010 - level 3 - TEST2-1
011 - level 2 - TEST2-2
1     - Current Assets
2     - Inventory Assets
...


which are listed as:
None
Current Assests
level 3 - TEST1-2
level 3 - TEST2-1
level 2 - TEST2
level 3 - TEST1-1
level 2 - TEST1
level 1 - TEST
level 3 - TEST2-2
Inventory Assets
...

Re: Error editing (updating) Account Groups in 2.3 CVS

Hello, I think your list should be sorted just as you typed it (with None in front). All these types are belonging to the same class type, right?
The sort order is class type, type id.

I will have a look at it.

/Joe

Re: Error editing (updating) Account Groups in 2.3 CVS

None is OK, but 0 should be in front of 1 (both are Assets...), or?

And, 0 should be followed by 00, 000, 001, 01, 010, 111 by my opinion. Imagine you have about 25 groups or more of the same type, all mixed (not sorted...) and with quite similar names... If they are ordered as in COA, it would be much easier to find the right one.

And, what is the reason that groups are ordered by class type? I mean, if the national chart of account is not sorted this way, why not to allow it to be matched? Isn't it why IDs are there for - to manage the sort order with them? It can be by class types or not, as one desires. Wouldn't it be better this way (it can suit anyone...)?

Re: Error editing (updating) Account Groups in 2.3 CVS

There must be something wrong with your setup. It is sorted correctly in my environment.
Did you remember to download the latest /includes/ui/ui_lists.inc from the CVS unstable?
You can download it here:



This types_list has been updated.


/Joe

15 (edited by LUTi 03/26/2010 10:24:49 am)

Re: Error editing (updating) Account Groups in 2.3 CVS

Yes, I've checked - it is the same (and, I've just updated the whole CVS tree again, no changes...).

Maybe the reason could be that you've entered the data in the order (as it should be)? I can not imagine what would be different, but for sure on my system it is as described above (a pitty that I can not attach a screenshot...).

I am getting the unstable branch - this should be OK, or? I see some updates every day, and "FrontAccounting 2.3 CVS (m7) - Theme: default - " is reported (at the moment: "Version 2.3 CVS (m7) Build 25.03.2010").

Re: Error editing (updating) Account Groups in 2.3 CVS

You could send me a backup (sql script) from your test client. You can use the email address on the 'Contact Us' page for sending attachments to us.

/Joe

Re: Error editing (updating) Account Groups in 2.3 CVS

Hi Joe,

it is default empty installation. I've set CVS version just to test this feature, as it is very important to me (otherwise, I am evaluating 2.2.7 version).

So, the only difference is (copied from backup):

### Data of table `0_chart_types` ###
INSERT INTO `0_chart_types` VALUES ('1', 'Current Assets', '1', '-1', '0');
INSERT INTO `0_chart_types` VALUES ('2', 'Inventory Assets', '1', '-1', '0');
INSERT INTO `0_chart_types` VALUES ('3', 'Capital Assets', '1', '-1', '0');
INSERT INTO `0_chart_types` VALUES ('4', 'Current Liabilities', '2', '-1', '0');
INSERT INTO `0_chart_types` VALUES ('5', 'Long Term Liabilities', '2', '-1', '0');
INSERT INTO `0_chart_types` VALUES ('6', 'Share Capital', '2', '-1', '0');
INSERT INTO `0_chart_types` VALUES ('7', 'Retained Earnings', '2', '-1', '0');
INSERT INTO `0_chart_types` VALUES ('8', 'Sales Revenue', '3', '-1', '0');
INSERT INTO `0_chart_types` VALUES ('9', 'Other Revenue', '3', '-1', '0');
INSERT INTO `0_chart_types` VALUES ('10', 'Cost of Goods Sold', '4', '-1', '0');
INSERT INTO `0_chart_types` VALUES ('11', 'Payroll Expenses', '4', '-1', '0');
INSERT INTO `0_chart_types` VALUES ('12', 'General & Administrative expenses', '4', '-1', '0');
INSERT INTO `0_chart_types` VALUES ('0', 'level 1 - TEST', '1', '', '0');
INSERT INTO `0_chart_types` VALUES ('00', 'level 2 - TEST1', '1', '0', '0');
INSERT INTO `0_chart_types` VALUES ('000', 'level 3 - TEST1-1', '1', '00', '0');
INSERT INTO `0_chart_types` VALUES ('01', 'level 2 - TEST2', '1', '0', '0');
INSERT INTO `0_chart_types` VALUES ('010', 'level 3 - TEST2-1', '1', '01', '0');
INSERT INTO `0_chart_types` VALUES ('001', 'level 3 - TEST1-2', '1', '00', '0');
INSERT INTO `0_chart_types` VALUES ('011', 'level 3 - TEST2-2', '1', '01', '0');

Up to Administrative expenses (12) it is a default, the rest is everything I've added. If there is a need, I can send you a complete backup and screenshot, but it was easier to simply copy/paste an extract from a backup (just made for this purpose) here...

Re: Error editing (updating) Account Groups in 2.3 CVS

Yes, I understand.
The Account Group table above is ordered correctly, but the combobox list is sorted in a strange way. It should have been sorted just as the Account Group table.
Janusz will have a second look at the function gl_account_types_list.

/Joe

Re: Error editing (updating) Account Groups in 2.3 CVS

This has now been fixed in CVS unstable. Affected file /includes/ui/ui_lists.inc.

You can download it here:



/Joe

Re: Error editing (updating) Account Groups in 2.3 CVS

You should also download the following file from CVS unstable



Otherwhise some of the reports will not print.

/Joe

21 (edited by LUTi 03/29/2010 08:35:34 am)

Re: Error editing (updating) Account Groups in 2.3 CVS

joe,

thank you. This is resolved now, dropdown list is properly ordered.

I've found another weirdness. After adding a group:
ID: 13
Name: TEST 3
Subgroup Of: None
Class Type: Assets

I've found it listed between groups 1 ("Current Assets") and 2 ("Inventory Assets"). Shouldn't it be listed after 3 ("Capital Assets"), since it is not a subgroup of 1?

Otherwise, we could simply say sublevels are automatic (10 is a subgroup of 1, 100 is a subgroup if 10 etc.). But, if we accept more than 10 (ID 0 - 9) level 1 groups (as now 10, 11 and 12 are...), they should be ordered as if they are integers, or? Otherwise, the ordering is quite confusing (like in good old DOS and older Win$ versions, with dir command).

Also my another question seems to be overlooked, altough not so unimportant as it may look. Imagine I change (from the situation as in my previous post) the group 001 to class type "Liabilities" now. It will fall down to the position after group 3 ("Capital Assets"), being the first one among "Liabilities" groups (altough being a subgroup of 01, listed in another / totally different position). If there are many account groups (doesn't fit in just one screen), this can be not only quite annoying, but also confusing (one may think some groups or subgroups doesn't exist, would try to create them, get an error...). I think all groups should be listed by the ID order, no matter what class type they are. If I want all assets to be listed first, liabilities after etc., I can change IDs and I have such an order. Why to insist on so strange ordering (without at least giving us an option to disable it / to order by ID only)?

Re: Error editing (updating) Account Groups in 2.3 CVS

The groups are sorted by class_id, group id. And inside the group_id it is sorted per subgroup. When running the reports it is doing the right way.

This is the way it works. You can rearrange the group_id. The update routine will adjust the subgroups and accounts groups in the accounts table accordingly.

/Joe

23 (edited by LUTi 03/30/2010 06:30:36 am)

Re: Error editing (updating) Account Groups in 2.3 CVS

joe,

I understand this is the way it works...

I just don't uderstand how should 13 be between 1 and 2, if it is on the same level. 13 is higher than 2, or? ;-)

I think that within the same level IDs should be compared as numbers, not strings (where 13 comes before 2, as 1 is lower than 2...). Sublevels are something else, as it is common practice in accounting to add digits on the right side...

And, I don't understand your suggestion to rearrange group_id - to achieve what? I can do whatever I want with IDs, they will still be ordered by class ID first (what I don't like). If you think this is how it should be (without changing it, or give us an option to disable / change that), I will have to patch my code (probably just one SQL to be edited or so - haven't take a look yet). Altough I hate to do that (unless really necessary), it should make us all happy...

Re: Error editing (updating) Account Groups in 2.3 CVS

All the group ids and subgroup ids are strings, so 13 is between 1 and 2. So you will have to rearrange your ids to fit into your hierarchy.
It is quite obvious why we sort by class_id first. The balance sheets and PL statements are created by using this class_id.

/Joe

Re: Error editing (updating) Account Groups in 2.3 CVS

Yes, reports are "theoretically" arranged by class_id. Theoretically because today reports are much different, at least in Slovenia (a sort of GIFI system, where many accounts are merged together in certain category, not as in COA or in classic BS or PL reports...). So, I consider class_id only as a tool to decide how to record a transaction (debit / credit). In any case, in account management screens I like things to be listed as prescribed by the COA. In any case, I've found the file and changed 1 line, and I hope we are both (all) happy... ;-)

About my issue (so that 13 is not less than 2), it can be solved.

Try the following query:

SELECT c5.id, c5.name, c5.class_id, c5.parent, c5.inactive FROM (
  SELECT IF(c4.parent3 = '' OR c4.parent3 = '-1', c4.id3, c4.parent3) AS id4,
            IF(c4.parent3 = '' OR c4.parent3 = '-1', '-1', (SELECT parent FROM 0_chart_types cx4 WHERE cx4.id = c4.parent3)) AS parent4,
            c4.* FROM (
    SELECT IF(c3.parent2 = '' OR c3.parent2 = '-1', c3.id2, c3.parent2) AS id3,
            IF(c3.parent2 = '' OR c3.parent2 = '-1', '-1', (SELECT parent FROM 0_chart_types cx3 WHERE cx3.id = c3.parent2)) AS parent3,
            c3.* FROM (
      SELECT IF(c2.parent1 = '' OR c2.parent1 = '-1', c2.id1, c2.parent1) AS id2,
            IF(c2.parent1 = '' OR c2.parent1 = '-1', '-1', (SELECT parent FROM 0_chart_types cx2 WHERE cx2.id = c2.parent1)) AS parent2,
            c2.* FROM (
        SELECT IF(c1.parent = '' OR c1.parent = '-1', c1.id, c1.parent) AS id1,
            IF(c1.parent = '' OR c1.parent = '-1', '-1', (SELECT parent FROM 0_chart_types cx1 WHERE cx1.id = c1.parent)) AS parent1,
            c1.* FROM (
          SELECT * FROM 0_chart_types c) AS c1) AS c2) AS c3) AS c4
) AS c5 ORDER BY
          CAST(id4 AS UNSIGNED), CAST(id3 AS UNSIGNED), CAST(id2 AS UNSIGNED), CAST(id1 AS UNSIGNED), id, parent;

I think so many recursive levels should be enough to sort 5 levels of account groups properly.

I've tested that query with account group table, it seems to be OK (a table in account group add/edit form is created well; haven't tested the situation where $all, $class_id or $parent would be false though...). Where is the query which creates the dropdown list for the "Subgroup Of:" field (I'd like to fix that one too...)?

You have to add your class_id to the sort, of course... ;-)