1

(13 replies, posted in FA Modifications)

Wouldn't it be possible to encrypt the data transmitted? There could (should) be only one user (security role) per session, of course.

Or, to somehow attach some form ID to variable names, when a new form is opened for the first time, and pass only this information to the server and back later (when data is changed / edited)?

In any case, to distinguish one form window from the other (speaking about the same form). I'd say this could be really useful in many situations...

2

(13 replies, posted in FA Modifications)

Maybe it would be good to consider to redesign it to enable more opened forms (the same ones) within one browser? It is a bit unsafe, as it is now, or? In particular if different forms do share some session variables. I may open a new window unintentionally (right click instead of left - I have this habit as I generally like to simply close some windows later instead of scrolling back and look for some previous page...), or sometimes even need to do (check / enter / edit) something in some other form.

It should not be too hard, or? To pass all form variables as arguments, instead of keeping them as session variables...

Thank you for a suggestion about more browsers anyway. ;-)

3

(13 replies, posted in FA Modifications)

I doubt that sys_prefs table could be of any use for my problem.

If you look at my code above, you can see I am using _SESSION variables, as you did (in original file). These are exactly the same in the first instance, in the second instance and so on (if I click edit the invoice more than just once - to have one instance to work on it, and post it at the end, but have another / unmodified version till the end to copy something out of it, or to post it as another new invoice, or whatever...).

I've thought to concatenate a random string to their names, but can not do that as I should do it only the first time (when already posted invoice is read), but not later anymore (next time something is changed and the screen is refreshed, but invoice not saved / posted yet). On the other hand, I would need to know their names (containing random string) next time, to be able to read them.

So, I see no way to have them different for one and another window within the same session.

Is there an easy way to have some variables kept between form submits for each window instance separately, and not for the session. I mean, without passing all of them all the time with GET / POST, when the form is submitted (as it is now)?

The way I've intended to resolve it above, my changes were relatively simple and safe, as I haven't directly save no information (I was just preprocessed the form for the new invoice) in the database. All critical code is still yours. If I should change it more in depth, I'm afraid I would do something incomplete / wrong, without being even aware of that (you know all the logic about what goes where, but I have absolutely not a clear picture about that!).

Is it a bit more clear to you what is my problem now? I'm sorry, but have no idea how to explain it in a better way...

4

(14 replies, posted in Setup)

We have probably quite weird system of transferring profit/loss in Slovenia. There is a different account for profit and a different account for loss (for both a closing year and a new fiscal year). Can this anyhow be handled in an automatic way? As it is now, I guess not.

So, where should I start to work on the code (to check if we have a profit or a loss, and based on that use one or another pair of accounts - which obviously have to be specified both in an admin screen...).

What I would like to do is:
- add 2 fields in the setup screen ("loss account" and "transferred loss account", for example)
- if both accounts above are defined, and we calculate a current fiscal year loss, we use those 2 fields instead (otherwise, we do the default)

Or, would it be too much to ask developers to add this (with a setting in config file, where I have to explicitely enable those 2 fields being displayed - not to bother the whole world with this by default...)?  ;-)

5

(3 replies, posted in Setup)

rmartino0913,

I guess voiding a transaction means more or less to just delete it.

What you need is a transaction reversal, what would be "the right way" (in particular for a traditional / old-fashioned accountant) to handle mistakes. And, sometimes the only possible / allowed option (in case of stock / inventory and changing purchase prices).

It would be generally great to have an option to use any already posted transaction as a template for a new transaction. This way it would be relatively quick and easy to:
1. Enter a reversed transaction (just editing quantities or amounts to negative before posting)
2. Add a new (correct) transaction (just editing the wrong item before posting)

I am missing a comfortable way to handle vendor invoice mistakes in the first place (where can be quite a nubmer of lines / data, which have to be typed in again and again, with a possibility of new mistakes, now...).

Thank you, joe.

I can confirm that the code provided resolved this issue (just a note for the others: users_db.inc is in /admin/db/, not in /admin/).

Just a minor (cosmetic) thing. If this option is switched off, there should be no dash after Theme, I believe (a dash which separates theme info and online users info when this option is on).

I can confirm it works fine in 2.3.3 (function seems to be quite different now).

Yeah, but:
- don't see transactions of other accounts anymore (to compare or understand something...)
- may get a totally wrong impression about some account transactions, if the balance within a period is 0 or something small, but there are a lot of transactions (or, the total of debit and credit transactions both is quite big)

I believe the overview (complete picture) should be as informative as possible...

But, it seems to me that in 2.3.3 this is done as I've suggested. So - a big Thanks, guys!  :-)

Maybe just some separators or something to see better which checkbox belongs to some text, and it will be perfect. ;-)

9

(3 replies, posted in Wish List)

What about some other - a bit more capable - platform?  By the way - where have you found this punBB at all?!  ;-)

10

(13 replies, posted in FA Modifications)

The latest made is above (post #4). I haven't done it for the latest release, because it may be too dangerous for me to use it, as it is now (I like to have multiple windows opened at the same time, to copy/paste data...).

I have to figure out how to do it more safe before I could use it, or simply wait that the developers provide some solution. By the way, Joe, what are the plans about this subject (I see in demo 2.4 CVS there is still no option to edit supplier invoice...)? I am waiting this to be resolved, and then I am almost ready (another feature is GIFI field implementation, but I believe I can do GIFI based balences / reports in MySQL / manually somehow, if everything else will be OK...) to consider switching to FrontAccounting for my production environment (I am still at SQL Ledger for that at the moment, and try to do tests in parallel as much as my time permits...).

For sure I will publish here if I manage to achieve some progress, but am quite short on time recently (not to mention that I don't know exactly how to proceed to make variables being kept per instance, not per session, what I believe is a problem with my "solution" now...).

The following errors:

mysql_query(): supplied argument is not a valid MySQL-Link resource in file: <frontaccounting_path>/includes/db/connect_db.inc at line 51
mysql_errno(): supplied argument is not a valid MySQL-Link resource in file: <frontaccounting_path>/includes/db/connect_db.inc at line 143
mysql_num_rows(): supplied argument is not a valid MySQL result resource in file: <frontaccounting_path>/includes/db/connect_db.inc at line 103

are displayed after logout (Thank you for using FrontAccounting 2.3.3 / Click here to Login Again... screen), when $show_users_online is set ($show_users_online = 1; in config.php).

$db variable does not seem to be set there...

But in my case nothing was displayed even after setting the dates within a current fiscal year (please see above, my fiscal year is 1.1.2009 - 31.12.2009, and dates for a trial balance are set to the same period). So, my from date is within a fiscal year.

As said, I suspect after opening a form, starting date for a trial balance period is somehow not checked anymore (not actualized, as I change it). What is weird is that the error message is not displayed anymore, just initially (but, the code execution always ends at that point - I've tried to put some debugging output to some different positions within this function, and simply couldn't get any further than that; I've also noticed the starting date didn't change as I've changed it...)

I've noticed double quotes in text are simply not accepted by this forum.

I guess it is too simple (basic) PHP processing of entered text, but in any case - forgetting this for a moment made me loose quite some minutes of typing in last couple of days (when you hit 'Submit topic', everything after the first double quote is simply cut away). Of course I haven't typed everything again after, as I was sooo angry about...

I believe today it is a lot of decent SW available, which could handle not only double quotes, but also some formatting (as a 'code' tag, for example) - to make things better visible.

Is it too much to ask to make a small improvement about that? ;-)

I see Trial Balance has quite uncommon way of displaying starting and ending balance (both Credit and Debit field). Checking 'Only balances' I get more or less what I would like to see for Starting and ending balance, but definitely not for transactions within a period (a sum of 1.000 of Debit transactions and 1.000 of Credit transactions is displayed as 0 - as nothing happened with this account...).

So, I would suggest to have radio buttons for each of:
- starting balance
- transactions within a period
- ending balance

where each could be one of:
- all Credit and Debit values
- just a total (Credit or Debit amount)
- just a single column 8positive or negative amount)

BTW - checkboxes - as are displayed now - are a bit confusing. A checkbox is often (usually) left to the corresponding text, so it is easy to check a wrong option by mistake. So, probably there should be more space between each option (or, some borders around). Or, to put options in more lines (dimensions in one column and other options in another column, for example).

15

(13 replies, posted in FA Modifications)

By the way, my temporary solution above can be tricky. After you edit one invoice, some sessin variables remain set, so some extra lines have to be added to prevent any new invoice added after (within the same session) to be voided imediately.

My latest patch (for 2.3.0) is:

=============================================================================================================
--- purchasing/supplier_invoice.php.ORIGINAL    2010-12-10 14:12:44.000000000 +0100
+++ purchasing/supplier_invoice.php        2010-12-27 22:28:52.000000000 +0100
@@ -25,7 +25,73 @@ if ($use_popup_windows)
    $js .= get_js_open_window(900, 500);
if ($use_date_picker)
    $js .= get_js_date_picker();
-page(_($help_context = "Enter Supplier Invoice"), false, false, "", $js);
+
+if (isset($_GET['ModifySI'])) {
+//display_notification_centered(_("Modify SI TRUE<br>"));
+    $help_context = "Modifying Supplier Invoice";
+    $error_msg = '';
+
+    if (isset($_GET["trans_no"])) {
+        $trans_no = $_GET["trans_no"];
+    }
+    elseif (isset($_POST["trans_no"])) {
+        $trans_no = $_POST["trans_no"];
+    }
+    else    $trans_no = null;
+
+    if ($trans_no != null) {
+        $_SESSION['page_title'] = sprintf(_("Modifying Supplier Invoice # %d."), $trans_no);
+        if (is_closed_trans(ST_SUPPINVOICE, $trans_no)) {
+            $error_msg = _("The selected transaction was closed for edition.");
+        }
+        else {
+            $void_entry = get_voided_entry(ST_SUPPINVOICE, $trans_no);
+            if ($void_entry != null) {
+                $error_msg = _("The selected transaction has already been voided.");
+            }
+            else {
+                $result = get_gl_trans(ST_SUPPINVOICE, $trans_no);
+                if (db_num_rows($result) == 0) {
+                    $error_msg = _("Cannot find Supplier Invoice # ") . $trans_no;
+                }
+            }
+        }
+    }
+    else {
+        $_SESSION['page_title'] = _("Modifying Supplier Invoice (with missing #).");
+        $error_msg = _("Supplier Invoice # is missing!");
+    }
+
+    if ($error_msg == '') {
+        $supp_trans = new supp_trans(ST_SUPPINVOICE);
+        read_supp_invoice($trans_no, ST_SUPPINVOICE, $supp_trans);
+        page($_SESSION['page_title'], false, false,'', $js);
+        $_SESSION['supp_trans'] = $supp_trans;
+        $_SESSION['inv_modify'] = true;
+        $_SESSION['old_trans'] = $trans_no;
+        $_SESSION['old_date'] = $supp_trans->tran_date;
+    }
+    else {
+        $_SESSION['inv_modify'] = false;
+        $_SESSION['old_trans'] = null;
+        $_SESSION['old_date'] = null;
+        page($_SESSION['page_title'], false, false,'', $js);
+        display_error($error_msg);
+        end_page(true);
+        exit;
+    }
+}
+elseif (isset($_GET['New'])) {
+//display_notification_centered(_("New TRUE, Modify SI FALSE<br>"));
+    $_SESSION['inv_modify'] = false;
+    $_SESSION['old_trans'] = null;
+    $_SESSION['old_date'] = null;
+    page(_($help_context = "Enter Supplier Invoice"), false, false, "", $js);
+}
+else {
+//display_notification_centered(_("Modify SI unchanged...<br>"));
+    page(_($help_context = "Enter Supplier Invoice"), false, false, "", $js);
+}

//----------------------------------------------------------------------------------------

@@ -193,6 +259,27 @@ function check_data()

//--------------------------------------------------------------------------------------------------

+function handle_void_invoice()
+{
+
+    if (!exists_supp_trans(ST_SUPPINVOICE, $_SESSION['old_trans']))
+        return false;
+    if (!post_void_supp_trans(ST_SUPPINVOICE, $_SESSION['old_trans']))
+        return false;
+
+    $ret = void_transaction(ST_SUPPINVOICE, $_SESSION['old_trans'], $_SESSION['old_date'], 'Invoice Modification - Old Version');
+
+    if ($ret)
+    {
+        display_notification_centered(_("Old invoice has been voided."));
+    }
+    else {
+        display_error(_("Old invoice cannot be voided."));
+        set_focus('trans_no');
+    }
+    return $ret;
+}
+
function handle_commit_invoice()
{
    copy_to_trans($_SESSION['supp_trans']);
@@ -212,7 +299,14 @@ function handle_commit_invoice()

if (isset($_POST['PostInvoice']))
{
-    handle_commit_invoice();
+    if ($_SESSION['inv_modify']) {
+        if (handle_void_invoice($_SESSION['old_trans'], $_SESSION['old_date'])) {
+            handle_commit_invoice();
+        }
+    }
+    else {
+        handle_commit_invoice();
+    }
}

function check_item_data($n)
=============================================================================================================

Patch for gl/inquiry/journal_inquiry.php above is OK (and also needed).


Also be careful If you open another tab in your browser with another invoice in between (while you "edit" one invoice). I think session variables mix up and results are unpredictable (in any case things are not as they should be). This should somehow be resolved before I could consider my patch really usable. So, take care before using this solution (altough it seems to work otherwise...).

In any case, I hope as well there will be a safe solution in the near future available.

To try out the new version (2.3.1), I've set a starting balance in 2008 (according to the instructions), and entered some transaction in the mid of January 2009. When I go to the Trial Balance, the dates are:
From: 17.12.2010 (??? - shouldn't it be 17.1.2010, or 1.1.2011?!)
To: 16.1.2011 (today)

Even if I change these dates to 1.1.2009 - 31.12.2009, nothing is displayed...

I've found out the reason seems to be that $_POST['TransFromDate'] isn't changed as I change it in form, so the check at the beginning of display_trial_balance() always fails. What is interesting is that the error (just 2 lines above 'return' clause) isn't displayed anymore (just initially, but not after I change the date and click 'Show' button).

Commenting out the whole:

if (isset($_POST['TransFromDate]))
{
   ...
}

at the beginning of display_trial_balance() function seems to resolve the problem (the trial balance is displayed after).

17

(13 replies, posted in FA Modifications)

I know supplier invoices shouldn't be edited, as this can easily make a mess in inventory (and COGS calculations). But, what about the case when it is the last transaction, so nothing would actually change if we make some correction (for example, we've found a typo when we've printed the invoice after it has been posted; or, we want just to edit a memo, or a product description, which wouldn't actually change anything...)?

The option to void such a transaction and type all over again I don't find very convenient. So, I've adapted the "supplier invioce form" so I can "open" some previously entered invoice, make corrections and repost it. At this stage, I actually void the previous invoice (with the date of that transaction), and post a new version of the invoice.

I know it is not the exact solution for the case above, but it is something I was able to do (seems to work for me, as much as I was able to test up to now...). To be able to achieve to actually edit the existing invoice and repost it (with the old ID), if it can be done safely (no transactions after it yet, or some insignificant changes that don't affect stock), I should have a more in-depth knowledge about FA (and, MySQL and PHP) - which unfortunately I don't. So, any help in this direction is more than welcome (what to check to be sure that it is the last transaction, and what would be the most convenient way to make modifications).

In any case, below is my code (modifications). Any feedback is more than welcome, in particular if I've done something I shouldn't (so I can introduce some inconsistency in the database using this).

=============================================================================================

--- gl/inquiry/journal_inquiry.php.ORIGINAL    2010-12-10 14:12:42.000000000 +0100
+++ gl/inquiry/journal_inquiry.php        2010-12-27 13:50:52.000000000 +0100
@@ -94,7 +94,7 @@ $editors = array(
    ST_CUSTDELIVERY => "/sales/customer_delivery.php?ModifyDelivery=%d",
//   16=> Location Transfer,
//   17=> Inventory Adjustment,
-//   20=> Supplier Invoice,
+   ST_SUPPINVOICE => "/purchasing/supplier_invoice.php?ModifySI=Yes&trans_no=%d",
//   21=> Supplier Credit Note,
//   22=> Supplier Payment,
//   25=> Purchase Order Delivery,
--- purchasing/supplier_invoice.php.ORIGINAL    2010-12-10 14:12:44.000000000 +0100
+++ purchasing/supplier_invoice.php        2010-12-27 13:43:49.000000000 +0100
@@ -25,7 +25,64 @@ if ($use_popup_windows)
    $js .= get_js_open_window(900, 500);
if ($use_date_picker)
    $js .= get_js_date_picker();
-page(_($help_context = "Enter Supplier Invoice"), false, false, "", $js);
+
+if (isset($_GET['ModifySI'])) {
+    $help_context = "Modifying Supplier Invoice";
+    $error_msg = '';
+
+    if (isset($_GET["trans_no"])) {
+        $trans_no = $_GET["trans_no"];
+    }
+    elseif (isset($_POST["trans_no"])) {
+        $trans_no = $_POST["trans_no"];
+    }
+    else    $trans_no = null;
+
+    if ($trans_no != null) {
+        $_SESSION['page_title'] = sprintf(_("Modifying Supplier Invoice # %d."), $trans_no);
+        if (is_closed_trans(ST_SUPPINVOICE, $trans_no)) {
+            $error_msg = _("The selected transaction was closed for edition.");
+        }
+        else {
+            $void_entry = get_voided_entry(ST_SUPPINVOICE, $trans_no);
+            if ($void_entry != null) {
+                $error_msg = _("The selected transaction has already been voided.");
+            }
+            else {
+                $result = get_gl_trans(ST_SUPPINVOICE, $trans_no);
+                if (db_num_rows($result) == 0) {
+                    $error_msg = _("Cannot find Supplier Invoice # ") . $trans_no;
+                }
+            }
+        }
+    }
+    else {
+        $_SESSION['page_title'] = _("Modifying Supplier Invoice (with missing #).");
+        $error_msg = _("Supplier Invoice # is missing!");
+    }
+
+    if ($error_msg == '') {
+        $supp_trans = new supp_trans(ST_SUPPINVOICE);
+        read_supp_invoice($trans_no, ST_SUPPINVOICE, $supp_trans);
+        page($_SESSION['page_title'], false, false,'', $js);
+        $_SESSION['supp_trans'] = $supp_trans;
+        $_SESSION['inv_modify'] = true;
+        $_SESSION['old_trans'] = $trans_no;
+        $_SESSION['old_date'] = $supp_trans->tran_date;
+    }
+    else {
+        $_SESSION['inv_modify'] = false;
+        $_SESSION['old_trans'] = null;
+        $_SESSION['old_date'] = null;
+        page($_SESSION['page_title'], false, false,'', $js);
+        display_error($error_msg);
+        end_page(true);
+        exit;
+    }
+}
+else {
+    page(_($help_context = "Enter Supplier Invoice"), false, false, "", $js);
+}

//----------------------------------------------------------------------------------------

@@ -193,6 +250,27 @@ function check_data()

//--------------------------------------------------------------------------------------------------

+function handle_void_invoice()
+{
+
+    if (!exists_supp_trans(ST_SUPPINVOICE, $_SESSION['old_trans']))
+        return false;
+    if (!post_void_supp_trans(ST_SUPPINVOICE, $_SESSION['old_trans']))
+        return false;
+
+    $ret = void_transaction(ST_SUPPINVOICE, $_SESSION['old_trans'], $_SESSION['old_date'], 'Invoice Modification - Old (Voided) Version');
+
+    if ($ret)
+    {
+        display_notification_centered(_("Old invoice has been voided."));
+    }
+    else {
+        display_error(_("Old invoice cannot be voided."));
+        set_focus('trans_no');
+    }
+    return $ret;
+}
+
function handle_commit_invoice()
{
    copy_to_trans($_SESSION['supp_trans']);
@@ -212,7 +290,15 @@ function handle_commit_invoice()

if (isset($_POST['PostInvoice']))
{
-    handle_commit_invoice();
+    if ($_SESSION['inv_modify']) {
+        if (handle_void_invoice($_SESSION['old_trans'], $_SESSION['old_date'])) {
+            display_notification_centered(_("New invoice data:<br>") . print_r($_SESSION['supp_trans'], TRUE) . "<br>");
+            handle_commit_invoice();
+        }
+    }
+    else {
+        handle_commit_invoice();
+    }
}

function check_item_data($n)

=============================================================================================

18

(0 replies, posted in FA Modifications)

In Slovenia, we have separate VAT accounts for VAT-registered clents, and separate ones for the others (non-registered).

So, I have to set the following taxes:
20% VAT - for VAT-registered clients (account 26000)
20% VAT - for the others (account 26001)
8,5% VAT - for VAT-registered clients (account 26010)
8,5% VAT - for the others (account 26011)

On the other hand, for us (as a VAT-registered company), the account is generally (to make it simple; can be different, but depending on the origin...) always the same (16000 for 20% VAT / 16010 for 8,5% VAT).

As I was not able to enter the combinations:
20% VAT | 26000 | 16000
and
20% VAT | 26001 | 16000

I had to modify the checking function (so only the sales account has to be unique):

=======================================================

--- taxes/db/tax_types_db.inc.ORIGINAL    2010-12-10 14:12:45.000000000 +0100
+++ taxes/db/tax_types_db.inc        2010-12-22 09:47:30.000000000 +0100
@@ -102,8 +102,7 @@ function is_tax_gl_unique($gl_code, $gl_

    $sql = "SELECT count(*) FROM "
        .TB_PREF."tax_types   
-        WHERE (sales_gl_code=" .db_escape($gl_code)
-        ." OR purchasing_gl_code=" .db_escape($purch_code). ")";
+        WHERE sales_gl_code=" .db_escape($gl_code);

    if ($selected_id != -1)
        $sql .= " AND id!=".db_escape($selected_id);

=======================================================

For the moment, my simplification suits for my needs.

Generally, I believe, we have to take care that the combination of both (sales tax and purchase tax) is unique. There could also be the case, that the sales taxes has to be booked at the same account, but the purchase taxes have to be booked to the different accounts (for example in slovenia, when the same product is purchased in diffrent countries, but sold in a home country, even to the same client). What do you think about that?

I prefer to see accounts and account types ordered by ID, and not by type.

I've made the following modifications:

--- gl/includes/db/gl_db_account_types.inc.ORIGINAL    2010-12-10 14:12:42.000000000 +0100
+++ gl/includes/db/gl_db_account_types.inc        2010-12-14 12:04:16.000000000 +0100
@@ -71,7 +71,7 @@ function get_account_types($all=false, $
 
     if (count($where))
         $sql .= ' WHERE '.implode(' AND ', $where);
-    $sql .= " ORDER BY class_id, id, parent";
+    $sql .= " ORDER BY id, parent";
 
     return db_query($sql, "could not get account types");
 }
@@ -128,7 +128,7 @@ function get_account_classes($all=false,
         $sql .= " AND ctype>".CL_EQUITY." OR ctype=0";
     elseif ($balance == 1) 
         $sql .= " AND ctype>0 AND ctype<".CL_INCOME; 
-    $sql .= " ORDER BY ctype, cid";
+    $sql .= " ORDER BY cid";
 
     return db_query($sql, "could not get account classes");
 }
--- includes/ui/ui_lists.inc.ORIGINAL            2010-12-10 14:12:42.000000000 +0100
+++ includes/ui/ui_lists.inc                2010-12-17 15:45:28.000000000 +0100
@@ -1547,7 +1547,7 @@ function gl_account_types_list($name, $s
     return combo_input($name, $selected_id, $sql, 'id', 'name',
     array(
         'format' => '_format_account',
-        'order' => array('class_id', 'id', 'parent'),
+        'order' => array('id', 'parent'),
         'spec_option' =>$all_option,
         'spec_id' => $all_items
     ) );
@@ -1592,7 +1592,7 @@ function gl_all_accounts_list($name, $se
         'spec_option' => $all_option===true ?  _("Use Item Sales Accounts") : $all_option,
         'spec_id' => '',
         'type' => 2,
-        'order' => array('type.class_id','type.id','account_code'),
+        'order' => array('type.id','account_code'),
         'search_box' => $cells,
             'search_submit' => false,
             'size' => 12,
@@ -1608,7 +1608,13 @@ function gl_all_accounts_list($name, $se
 
 function _format_account($row)
 {
-        return $row[0] .  "&nbsp;&nbsp;&nbsp;&nbsp;" . $row[1];
+        $return = $row[0];
+        $rlen = strlen($return);
+        if ($rlen > 6) $rlen = 6;
+        for ($i = $rlen; $i < 9; $i++) {
+            $return .= "&nbsp;&nbsp;";
+        }
+        return $return . $row[1];
 }
 
 function gl_all_accounts_list_cells($label, $name, $selected_id=null,

Maybe it would be good to have a setting (option) about that - to display them ordered by type, or by ID (maybe even by name as well)?

I would find it much more useful to have this option here (patches / modification or modified files attached).

21

(2 replies, posted in FA Modifications)

What about all defaults all around, which are linked to certain accounts?

It would however be good to have an option to start from scratch (as empty databese as possible), and to have some script to check what it yet to be entered (all defaults we have to select, after the COA is established, but before we can actually start using FA).

22

(2 replies, posted in FA Modifications)

I have just the following:

MySQL my.cnf file [only a line relevant to UTF-8]:
[mysqld]
default-character-set = utf8


Slovene language [lang/installed_languages.inc] with:
'code' => 'sl_SI',
'name' => 'Slovenš&#269;ina',
'encoding' => 'utf-8',
...


And, I needed just to slightly modify (only 2 lines are added) one FA file (connect_db.inc):

==================================================================

--- includes/db/connect_db.inc.ORIGINAL        2010-12-10 14:12:42.000000000 +0100
+++ includes/db/connect_db.inc            2010-12-14 13:40:11.000000000 +0100
@@ -25,6 +25,7 @@ function set_global_connection($company=
    $connection = $db_connections[$company];

    $db = mysql_connect($connection["host"], $connection["dbuser"], $connection["dbpassword"]);
+        mysql_set_charset('utf8', $db);
        mysql_select_db($connection["dbname"], $db);
    return $db;
}
@@ -169,6 +170,7 @@ function db_create_db($connection)
{
    $db = mysql_connect($connection["host"] ,
        $connection["dbuser"], $connection["dbpassword"]);
+    mysql_set_charset('utf8', $db);
    if (!mysql_select_db($connection["dbname"], $db))
    {
        $sql = "CREATE DATABASE " . $connection["dbname"] . "";

==================================================================

Up to now, everything seems to work OK.

It seems it isn't too complicated to make account / account types names longer. I've changed in MySQL:
`0_chart_master`.`account_name` to VARCHAR 255
`0_chart_types`.`name` to VARCHAR 255

and modifications to 2 files, as in attachment.

Up to now, everything seems to work quite OK. I'd appreciate any feedbacks.

Here is a query which seems to handle up to 6 levels, as long as COA doesn't become really silly:

SELECT c8.id, c8.name, c8.class_id, c8.parent, c8.inactive FROM (
  SELECT
    IF(c7.parent1 = '-1', c7.id, IF(c7.parent2 = '-1', c7.level5, IF(c7.parent3 = '-1', c7.level4, IF(c7.parent4 = '-1', c7.level3, IF(c7.parent5 = '-1', c7.level2, c7.level1))))) AS group1,
    IF(c7.parent2 = '-1', c7.id, IF(c7.parent3 = '-1', c7.level5, IF(c7.parent4 = '-1', c7.level4, IF(c7.parent5 = '-1', c7.level3, c7.level2)))) AS group2,
    IF(c7.parent3 = '-1', c7.id, IF(c7.parent4 = '-1', c7.level5, IF(c7.parent5 = '-1', c7.level4, c7.level3))) AS group3,
    IF(c7.parent4 = '-1', c7.id, IF(c7.parent5 = '-1', c7.level5, c7.level4)) AS group4,
    IF(c7.parent5 = '-1', c7.id, c7.level5) AS group5,
    c7.* FROM (
      SELECT
        IF(parent1 = '-1', 1, IF(parent2 = '-1', 2, IF(parent3 = '-1', 3, IF(parent4 = '-1', 4, IF(parent5 = '-1', 5, 6))))) AS grp_level,
        IF(c6.parent5 = '-1', c6.level2, c6.parent5) AS level1,
        c6.* FROM (
          SELECT
            IF(c5.parent4 = '-1', '-1', (SELECT IF(parent = '', '-1', parent) FROM 0_chart_types cx4 WHERE cx4.id = c5.parent4)) AS parent5,
            IF(c5.parent4 = '-1', c5.level3, c5.parent4) AS level2,
            c5.* FROM (
              SELECT
                IF(c4.parent3 = '-1', '-1', (SELECT IF(parent = '', '-1', parent) FROM 0_chart_types cx3 WHERE cx3.id = c4.parent3)) AS parent4,
                IF(c4.parent3 = '-1', c4.level4, c4.parent3) AS level3,
                c4.* FROM (
                  SELECT
                    IF(c3.parent2 = '-1', '-1', (SELECT IF(parent = '', '-1', parent) FROM 0_chart_types cx2 WHERE cx2.id = c3.parent2)) AS parent3,
                    IF(c3.parent2 = '-1', c3.level5, c3.parent2) AS level4,
                    c3.* FROM (
                      SELECT
                        IF(c2.parent1 = '-1', '-1', (SELECT IF(parent = '', '-1', parent) FROM 0_chart_types cx1 WHERE cx1.id = c2.parent1)) AS parent2,
                        IF(c2.parent1 = '-1', c2.id, c2.parent1) AS level5,
                        c2.* FROM (
                          SELECT
                            IF(c1.parent = '' OR c1.parent = '-1', '-1', c1.parent) AS parent1,
                            c1.* FROM (
                              SELECT * FROM 0_chart_types c) AS c1) AS c2) AS c3) AS c4) AS c5) AS c6) AS c7) AS c8
ORDER BY CAST(group1 AS UNSIGNED), CAST(group2 AS UNSIGNED), CAST(group3 AS UNSIGNED), CAST(group4 AS UNSIGNED), CAST(group5 AS UNSIGNED), CAST(id AS UNSIGNED), grp_level

About 2 - I believe the current solution (situation) is not consistent.

If levels are not automatic and defined by number of digits (so 0-9 is 1st level, 00-99 is 2nd level and so on), we cannot accept to order as we do now. 13 cannot be between 1 and 2, I hope this is clear. Why ordering as I've suggested is not good? Why groups or subgroups within one level (and under the same parent...) couldn't (or, shouldn't) be grouped according to normal (human understandable) counting (numbering)?

By the way, I've noticed my query is not 100% OK, I have to work on it a bit more. But generally, I think within a (sub)group of "equally weighted" (the same level and parent) entries, sorting has to be done as we count. Or, limit the number of entries within such group to 10 entries (1 digit), to avoid confusion.