Topic: How to Let FA Accept Classes/Types ID's Characters

Hello,

Find bellow a simple way to let the outstanding FA package support characters ID's in the Classes/Types Accounts.


1 - use en_US-Demo.sql  & en_US-New.sql Supporting Classes/Types Characters
     id's. This will be done easly by changing :

       - all varchar(11) should be changed to varchar(15) in the .sql file

       - CREATE TABLE `0_chart_class` (
         `cid` varchar(3) NOT NULL default '',
         `class_name` varchar(60) NOT NULL default '',
         `ctype` tinyint(1) NOT NULL default '0',
         `inactive` tinyint(1) NOT NULL default '0',
          PRIMARY KEY  (`cid`)
          ) TYPE=MyISAM  ;

       - CREATE TABLE `0_chart_master` (
         `account_code` varchar(15) NOT NULL default '',
         `account_code2` varchar(15) default '',
         `account_name` varchar(60) NOT NULL default '',
         `account_type` varchar(10) NOT NULL default '0',
         `inactive` tinyint(1) NOT NULL default '0',
          PRIMARY KEY  (`account_code`),
          KEY `account_code` (`account_code`),
          KEY `account_name` (`account_name`)
          ) TYPE=MyISAM  ;

        - CREATE TABLE `0_chart_types` (
         `id` varchar(10) NOT NULL default '',
         `name` varchar(60) NOT NULL default '',
         `class_id` varchar(3) NOT NULL default '0',
         `parent` varchar(10) NOT NULL default '-1',
         `inactive` tinyint(1) NOT NULL default '0',
           PRIMARY KEY  (`id`),
          KEY `name` (`name`)
          ) TYPE=MyISAM;

2 - do those simple modifications in the bellow files :

    * gl/includes/db/gl_db_account_types.inc

          - function add_account_type
            $sql = "INSERT INTO ".TB_PREF."chart_types (id, name, class_id, parent)
          VALUES (".db_escape($id).", ".db_escape($name).", ".db_escape
                                    ($class_id).", ".db_escape($parent).")";         
                     // FA original was  : VALUES ( $id,.......

          - function get_account_types
               $sql .= " ORDER BY class_id, id, parent ";
                    // FA Original : " ORDER BY class_id, id"

          - function get_account_classes
               $sql .= " ORDER BY ctype,cid";         
                   //  FA Original : " ORDER BY cid"

    * gl/manage/gl_account_classes.php
            1. comment the following lines:
      /* if (!is_numeric($_POST['id']))
        {
              display_error( _("The account class ID must be numeric."));
               set_focus('id');
                          return false;
         }
                */
            2. in the delete check :
         $sql= "SELECT COUNT(*) FROM ".TB_PREF."chart_types
                          WHERE class_id=".db_escape($selected_id)." ";
                             // FA Original:  class_id=$selected_id

     * gl/manage/gl_account_types.php
            1. comment the following lines:
    /*   if (!input_num('id'))
          {
            display_error( _("The account id must be an integer and cannot
                                                 be empty."));
            set_focus('id');
            return false;
           }
                */
            2. minor changes:
                 - $th = array(_("Group ID"), _("Group Name"), _("Subgroup Of"),
                                    _("Class Type"), "", "");    // khaled : ID ; Name

                 - if ($myrow["parent"] == "0")
                        //FA Original :   if ($myrow["parent"]== ANY_NUMERIC)
     
      * gl/manage/gl_accounts.php
    - text_row_ex(_("Account Code:"), 'account_code', 15);     
                       //FA Original was 11
                -  text_row_ex(_("Account Code 2:"), 'account_code2', 15);   
                      //FA Original was 11

       * includes/ui/ui_lists.inc
       'order' => array('account_code','type.id'),   
                      // FA Original :  array('type.id','account_code'),


Should also change in config.php : $accounts_alpha = 1;

I hope you will find those modifications usefull.

Finally, This is how I use FA & in every new version I do those modifications.

Regards,


Khaled

Re: How to Let FA Accept Classes/Types ID's Characters

Errata :

* includes/ui/ui_lists.inc
       'order' => array('account_code','type.id'),   
                      // FA Original :  array('type.id','account_code'),
       
       should keep it as FA Original : array('type.id','account_code'),


khaled

Re: How to Let FA Accept Classes/Types ID's Characters

We are having a discussiong regarding this in the developers mailing list. Please participate here. However, I see no reason to increase the account code field from 11 to 15 characters.
If the discussion find this ok, it will be implemented in 2.3

/Joe

Re: How to Let FA Accept Classes/Types ID's Characters

hi,

I am very glad that you are thinking to include this approach in 2.3.

RE : CHAR 15

0. The philosophy behind it is described as below :
   
    suppose you have an account number 11006050

    practically it is composed as :        1  100  1060

                   where :  1      ->  refer to the Class  account it belongs
                                100   ->  refer to the Group account it belongs
                                1060 ->  refer to the Account

             
1. Practically for a single company : CHAR 11      is sure enough.

2. Using CHAR 15 will be helfull in the case of having a company with multiple
    branshes. In this case,
        -  the first 11 char will be used to the company account
        -  and the last 4 char are to be used for the company branshes.
        -  in such a case , company with multiple branshes, you will have many
           accounts with the same numbers :
                                    11001060-010
                                    11001060-020
                                    11001060-030
        Later on, and when you decide print " Balance Sheet " of any Bransh, it
        can be isolated easely by queyring the database to the selected bransh
        (010  for example). A similar approach can also be developed to the
        global company Balance Sheet.


Thanks,


Khaled

Re: How to Let FA Accept Classes/Types ID's Characters

I see. Please Khaled, enter this topic in the developers mailing list. So we can have the material inside one thread here.

/Joe

Re: How to Let FA Accept Classes/Types ID's Characters

Hello, I have put your topic into the developers mailing list, Khaled.
We are having a good discussion here in the developers mailing list, and it seems to go your way, thanks to among others, Tom Hallman, US.

/Joe