4,301

(10 replies, posted in Banking and General Ledger)

Post the "USA" standard check layout and the check printed on it (superimposed as well) both scaled to size as an image somewhere and state the link here in.

Locate the file modules/rep_check_print/reporting/rep_check_print.php and edit the function print_check().

4,302

(1 replies, posted in FA Modifications)

The SQL is:

SELECT tt.rate
FROM `0_stock_master` sm LEFT JOIN `0_tax_types` tt
        ON (`sm`.`tax_type_id` = `tt`.`id`)
WHERE stock_id="MY_ITEM";

Tax rates are not that straightforward. The items may be having different tax rates depending on the actual invoice where a Customer may have tax overrides.

Attached is the ERD for the SQL provided here.

Will the function get_item_tax_type_for_item($stock_id)

function get_item_tax_type_for_item($stock_id)
{
    $sql = "SELECT ".TB_PREF."item_tax_types.* FROM ".TB_PREF."item_tax_types,".TB_PREF."stock_master WHERE 
        ".TB_PREF."stock_master.stock_id=".db_escape($stock_id)."
        AND ".TB_PREF."item_tax_types.id=".TB_PREF."stock_master.tax_type_id";
    
    $result = db_query($sql, "could not get item tax type");
    
    return db_fetch($result);    
}

in lines 61 to 70 intaxes/db/item_tax_types_db.inc suffice or would you like to clone it by replacing the sql?

At the moment, just increase the number of decimal places in the Setup => Display Setup and round off the field in the report to 2 decimal places.

FA v2.4 has been in the making for quite a few years now....a few more months to wait is okay perhaps....

4,304

(44 replies, posted in Reporting)

I have attached the output of your SQL statement for the en_US-demo CoA - I do not see any duplications. Please show which ones you consider duplicate for what set of restricted unique keys.

4,305

(44 replies, posted in Reporting)

@dls: I think @elax did mention some limitations, possibly for Supplier Invoices.

@elax: please have a look.

4,306

(44 replies, posted in Reporting)

After comparing elax FA v2.3.19 Tax Support Patch, incorporated changes in FA 2.3.22+ as on date retaining all white space in the latter.

Please provide feedback.

4,307

(44 replies, posted in Reporting)

@dls: Please note that there are real changes only in these 3 FA 2.3.22+ changed files:
config.default.php
includes/ui/items_cart.inc
gl/includes/gl_bank.php
when compared to elax patch files for 2.3.19.

The devs are on holiday....... not yet fixed. Easter is drawing near....

4,309

(44 replies, posted in Reporting)

Your archive contains a file
   gl_db_bank_trans.inc
but not the file
   gl/includes/db/gl_db_trans.inc.

If you want to synch with the latest en_US-new CoA, then perform the following sql statements selectively based on contents in each table:

DB Schema Synch

/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;

ALTER TABLE `0_bank_accounts` CHANGE `bank_account_name` `bank_account_name` varchar(120)  COLLATE utf8_unicode_ci NOT NULL DEFAULT '' after `account_type`;
ALTER TABLE `0_chart_types` CHANGE `name` `name` varchar(120)  COLLATE utf8_unicode_ci NOT NULL DEFAULT '' after `id`;
ALTER TABLE `0_debtor_trans` ADD KEY `order_`(`order_`);
ALTER TABLE `0_purch_orders` 
    CHANGE `total` `total` double   NOT NULL DEFAULT 0 after `delivery_address`, 
    CHANGE `tax_included` `tax_included` tinyint(1)   NOT NULL DEFAULT 0 after `total`;
ALTER TABLE `0_suppliers` 
    CHANGE `tax_included` `tax_included` tinyint(1)   NOT NULL DEFAULT 0 after `payment_terms`, 
    CHANGE `dimension_id` `dimension_id` int(11)   NULL DEFAULT 0 after `tax_included`, 
    CHANGE `dimension2_id` `dimension2_id` int(11)   NULL DEFAULT 0 after `dimension_id`, 
    CHANGE `tax_group_id` `tax_group_id` int(11)   NULL after `dimension2_id`, 
    CHANGE `credit_limit` `credit_limit` double   NOT NULL DEFAULT 0 after `tax_group_id`, 
    CHANGE `purchase_account` `purchase_account` varchar(15)  COLLATE utf8_unicode_ci NOT NULL DEFAULT '' after `credit_limit`, 
    CHANGE `payable_account` `payable_account` varchar(15)  COLLATE utf8_unicode_ci NOT NULL DEFAULT '' after `purchase_account`, 
    CHANGE `payment_discount_account` `payment_discount_account` varchar(15)  COLLATE utf8_unicode_ci NOT NULL DEFAULT '' after `payable_account`, 
    CHANGE `notes` `notes` tinytext  COLLATE utf8_unicode_ci NOT NULL after `payment_discount_account`, 
    CHANGE `inactive` `inactive` tinyint(1)   NOT NULL DEFAULT 0 after `notes`;
ALTER TABLE `0_users` 
    CHANGE `query_size` `query_size` tinyint(1) unsigned   NOT NULL DEFAULT 10 after `last_visit_date`, 
    CHANGE `print_profile` `print_profile` varchar(30)  COLLATE utf8_unicode_ci NOT NULL DEFAULT '' after `pos`;

/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;

DB Data Synch

SET AUTOCOMMIT = 0;

/*
-- Remove Contacts - use for new install only
DELETE FROM `0_crm_contacts`  WHERE 1 ;
*/

/*
-- Remove Persons - use for new install only
DELETE FROM `0_crm_persons`  WHERE 1 ;
*/

INSERT IGNORE INTO `0_fiscal_year` VALUES ('7', '2014-01-01', '2014-12-31', '0');
INSERT IGNORE INTO `0_fiscal_year` VALUES ('8', '2015-01-01', '2015-12-31', '0');

/*
-- Execute for new install only (for others if executed, then all item related records will need to changed if used)
DELETE FROM `0_item_units`  WHERE (`abbr` = 'ea.') ;
INSERT INTO `0_item_units` VALUES ('each', 'Each', '0', '0');
*/
INSERT INTO `0_item_units` VALUES ('hr', 'Hours', '0', '0');

-- FA 2.3.22+ changes days_before_due from 1 to 0
UPDATE `0_payment_terms` SET `days_before_due`='0' WHERE (`terms_indicator` = 4 AND `terms`='Cash Only') ;

-- NULL to blank string
UPDATE `0_print_profiles` SET `report`='' WHERE (`id` BETWEEN 1 AND 3) ;

/*
-- Remove Quick Entries - for new install only
DELETE FROM `0_quick_entries`  WHERE 1 ;
*/

-- areas 526 added for FA 2.3.22+
UPDATE `0_security_roles` SET `areas`='257;258;259;260;513;514;515;516;517;518;519;520;521;522;523;524;525;526;769;770;771;772;773;774;2817;2818;2819;2820;2821;2822;2823;3073;3074;3082;3075;3076;3077;3078;3079;3080;3081;3329;3330;3331;3332;3333;3334;3335;5377;5633;5634;5635;5636;5637;5641;5638;5639;5640;5889;5890;5891;7937;7938;7939;7940;8193;8194;8195;8196;8197;8449;8450;8451;10497;10753;10754;10755;10756;10757;11009;11010;11011;11012;13057;13313;13314;13315;15617;15618;15619;15620;15621;15622;15623;15624;15628;15625;15626;15627;15873;15874;15875;15876;15877;15878;15879;15880;15883;15881;15882;16129;16130;16131;16132'  WHERE (`id` = 2) ;

UPDATE `0_stock_category` SET `dflt_tax_type`='1', `dflt_units`='hr'  WHERE (`category_id` = 4) ;

INSERT INTO `0_sys_prefs` VALUES ('bcc_email', 'setup.company', 'varchar', '100', '');

-- reset `type_no` to 1 as it is no longer used
UPDATE `0_sys_types` SET `type_no`='1' WHERE 1;

COMMIT;

The sqls are attached as well.

Customer Credit Limits are enforced when invoicing them and will decrement as amount of unpaid customer bills add up. Supplier Credit Limits are only indicators for us and are not enforced.

1. Take a backup.
2. Create a Credit Note
3. Take another backup
4. Compare the two backups and see what got inserted.

This will reveal what tables are affected and what needs to be undone especially if many transaction have occurred along with the Credit Note transaction and possibly some allocation transactions for it and others.

Further differences will be there on whether it is a Supplier or Customer Credit Note you intend to delete and what you want to do with the allocations to them that might have been done as well.

4,313

(44 replies, posted in Reporting)

Upload it anywhere and paste the url here.

4,314

(9 replies, posted in Setup)

@tm: You are right about restriction of backups to responsible and authorised users only. The solution I provided would be useful if some critical tables are just read only views made from tables outside of FA.

@khkoh: Anyone who takes a restricted backup using the script here can always inject the necessary sqls with different users, security_roles, etc., and upload and restore them. It can also be able to exclude certain prefixed tables that may not be part of native FA at all and managed elsewhere. If prefixes are used, non prefixed tables get excluded in the original code itself.

In preparing this code hack, understanding and documenting the backup process has been achieved.

Restoring from a completely new hacked backup file with only insert statements can be a nice way of importing records into FA and in some instances provide a base for a new CoA!

4,315

(9 replies, posted in Setup)

My previous solutions do not work because the $all_tables is an array of arrays.

Lines 505 to 513 in admin/db/maintenance_db.inc:

    // get auto_increment values and names of all tables
    $res = db_query("show table status");
    $all_tables = array();
    while($row = db_fetch($res))
    {
        if (($conn["tbpref"] == "" && !preg_match('/[0-9]+_/', $row['Name'])) ||
            ($conn["tbpref"] != "" && strpos($row['Name'], $conn["tbpref"]) === 0))
            $all_tables[] = $row;
    }

is now replaced with:

    // get auto_increment values and names of all tables
    $res = db_query("show table status");
    $all_tables = array();
    $skip_tables_list = Array('users', 'security_roles', 'sql_trail');
    for ($i = 0; $i < count($skip_tables_list); $i++) {
        $skip_tables_list[$i] = $conn["tbpref"].$skip_tables_list[$i];
    }
    while($row = db_fetch($res))
    {
        if (($conn["tbpref"] == "" && !preg_match('/[0-9]+_/', $row['Name'])) ||
            ($conn["tbpref"] != "" && strpos($row['Name'], $conn["tbpref"]) === 0))
            if (!(in_array($row['Name'], $skip_tables_list, true)))
                $all_tables[] = $row;
    }

The variable $skip_tables_list is populated with the names of tables to be skipped (without table prefixes).

The tables missing tables in the backup remain untouched in the database when restored.

The wiki has been updated and the code has been tested.

The Arabic Egypt 8 digits CoA - GAAP has some field order differences with standard en_US-new.sql CoA. Check out the corrected version from my GitHub Repo. Since the devs are not updating the official pkg repo as frequently as we would wish, these issues will crop up more often.

Use a program like WinMerge on Windows and compare the sql/en_US-new.sql and sql/ar_EG-8digits.sql for differences in schema first.

Also verify that you are using the latest snapshot of FA v2.3.22+.

The said sql/ar_EG-8digits.sql Chart of Accounts has now been updated to synch with the sql/en_US-new.sql in my GitHub Repo. It now has the CREATE TABLE IF NOT EXISTS and DROP TABLE constructs in them. Overwrite your sql/ar_EG-8digits.sql file with the one from my GitHub Repo.

@joe: all FA v2.3.x CoAs should have the same schema in the official pkg repo - otherwise, the "official" and "signed" will have lost "trust".

4,318

(44 replies, posted in Reporting)

@dls: Please post the changed files that worked for FA v2.3.22+

The Standard en_US-demo.sql running on FA 2.3.22+ on windows localhost provides the attached outputs. Whilst the Balance Sheet report (rep706.php) is displayed with no zeroes, the Trial Balance report (rep708.php) has a filter for with and without zeroes.

Check your Egypt CoA with the standard en_US-demo.sql file for any differences.

4,320

(9 replies, posted in Setup)

A more generic version of the insert code above is:

$skip_tables_list = Array('users', 'security_roles', 'sql_trail');

foreach ($skip_tables_list as $skip_table_name) {
    if (($key = array_search($conn["tbpref"].$skip_table_name, $all_tables)) !== false) {
        unset($all_tables[$key]);
    }
}

This information has now been wiki-ed.

4,321

(48 replies, posted in Setup)

A bunch of changes have been pushed from the dev's repos to the FA 2.4 Unstable Hg repo a few days ago.

The reports display error on Windows listed in the 22nd post (has fix there as well) in this thread still exists. The devs have been informed.

The current snapshot of FA v2.4 does not install out of the box for the demo CoA since in the sql/en_US-demo.sql there is an Error in field type change in it's line 836:

`type_no` `type_no` int(11) NOT NULL default '0',

which should be:

`type_no` int(11) NOT NULL default '0',

The Devs have been informed.

Here is a short list of changes in the Unstable FA 2.4 codebase since my last reporting post:

  • Changes in db schema gl_trans.type_no optimized to int, changed lock_stock.reorder_level type to double.

  • Added dimension edition on purchase invoice entry.

Files affected

purchasing/includes/ui/invoice_ui.inc
purchasing/includes/ui/po_ui.inc
purchasing/includes/db/invoice_db.inc
purchasing/includes/db/invoice_items_db.inc
purchasing/includes/supp_trans_class.inc
purchasing/includes/po_class.inc
purchasing/includes/purchasing_db.inc

sql/en_US-new.sql

Field Type changes:
0_gl_trans.type_no bigint(16) default 1 => int(11) default 0
0_loc_stock.reorder_level bigint(20) => int(11)

Appended 2 new fields to 0_supp_invoice_items:
  `dimension_id` int(11) NOT NULL DEFAULT '0',
  `dimension2_id` int(11) NOT NULL DEFAULT '0',

sql/en_US-demo.sql

Same as above.
Demo data INSERT statements extended with 0 values for the 2 new fields in 0_supp_invoice_items

sql/alter2.4.sql: UPDATE and ALTER statements for the above changes

reporting/includes/class.mail.inc: Cleanup and preparing for XLS extension
gl/manage/bank_accounts.php: Better Error Message when trying to use GL Accounts with transactions
reporting/includes/reporting.inc: Wrong no. of parameters for Invoice (rep107)
includes/ui/ui_controls.inc: $timeout parameter added to function meta_forward()
includes/db/inventory_db.inc
: Removed unused function update_stock_move_pid()
purchasing/includes/db/invoice_db.inc
: Removed commented out function update_stock_move_pid() usage

Fixed initialization of company specific settings in SysPrefs:

includes/prefs/sysprefs.inc: New function refresh_company_prefs() added
(Devs: spelling mistakes in a few places for the word 'preferences')
$_SESSION['SysPrefs']->db_ok becomes $SysPrefs->db_ok in

  • includes/session.inc

  • sales/sales_order_entry.php

  • admin/db/company_db.inc

Added mysql query retry after database deadlock detection.

includes/db/connect_db.inc: New constant MAX_DEADLOCK_RETRY defined
The 2 db driver files use it:
includes/db/connect_db_mysqli.inc
includes/db/connect_db_mysql.inc

Small cleanup to branch name length in input form and printouts.

Affected files - can be backported:

Attachments were not moved to new transaction after edition for some document types.

admin/db/attachments_db.inc: New function move_trans_attachments() added
Used in:

  • gl/includes/db/gl_db_banking.inc

  • sales/includes/db/sales_invoice_db.inc

  • sales/includes/db/sales_delivery_db.inc

  • purchasing/includes/db/invoice_db.inc

includes/access_levels.inc: Additional access control related ui helpers added - check_edit_access, access_post, access_num

4,322

(5 replies, posted in Reporting)

Now included in FA 2.4

Most modern browsers have their key bindings changeable. FireFox 31.4.0esr on WinXP SP3  did not need any changes for F4 to work as desired in FA.

Anyway, thanks. Your valuable inputs have been used to create a new Wiki page to address it.

Lines 555 to 582 in includes/ui/ui_controls.inc:

/*
    Redirector for selector F4 calls.
    $sel_editors is array of selname=>editor_page
*/
function editor_redirect($sel_editors, $save_fun='') {
    foreach ($sel_editors as $selname=>$editor)
        if (isset($_POST['_'.$selname.'_editor'])) {
            if (function_exists($save_fun))
                $save_fun();
            unset($_POST['_'.$selname.'_editor']);
            context_call($editor, array_keys($_POST));
        }
}
/*
    Return procedure for selector F4 calls
*/
function editor_return($vars, $restore_fun='') {
    if (function_exists($restore_fun))
        $restore_fun();

    if ($ret = context_restore()) {
        foreach ($vars as $postname=>$retname)
            if (isset($ret[$retname])) {
                $_POST[$postname] = $ret[$retname];
                set_focus($postname);
            }
    }
}

Lines 445 to 479 in the same file defines the hotkeys (key 115 => F4 for Items):

/* Table editor interfaces. Key is editor type
    0 => url of editor page
    1 => hotkey code
    2 => context help
*/
$popup_editors = array(
    'customer' => array('/sales/manage/customers.php?debtor_no=', 
        113,    _("Customers"), 900, 500),
    'branch' => array('/sales/manage/customer_branches.php?SelectedBranch=', 
        114, _("Branches"), 900, 700),
    'supplier' => array('/purchasing/manage/suppliers.php?supplier_id=', 
        113, _("Suppliers"), 900, 700),
    'item' => array('/inventory/manage/items.php?stock_id=', 
        115, _("Items"), 800, 600)
);
/*
    Bind editors for various selectors.
    $type - type of editor
    $input - name of related input field
    $caller - optional function key code (available values F1-F12: 112-123,
        true: default)
*/
function set_editor($type, $input, $caller=true)
{
    global $path_to_root, $Editors, $popup_editors, $Pagehelp;

    $key = $caller===true ? $popup_editors[$type][1] : $caller;

    $Editors[$key] = array( $path_to_root . $popup_editors[$type][0], $input, 
        $popup_editors[$type][3], $popup_editors[$type][4]);
    
    $help = 'F' . ($key - 111) . ' - ';
    $help .= $popup_editors[$type][2];
    $Pagehelp[] = $help;
}

The file includes/ui_ui_lists.inc has several references to set_editor() function that defines the popup.
Lines 740 to 749 in it are:

function stock_items_list($name, $selected_id=null, $all_option=false, 
    $submit_on_change=false, $opts=array(), $editkey = false)
{
    global $all_items;

    $sql = "SELECT stock_id, s.description, c.description, s.inactive, s.editable
            FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id";

    if ($editkey)
        set_editor('item', $name, $editkey);

...
...

4,324

(44 replies, posted in Reporting)

@elax: the patch and files I provided in the 19th post in this thread were culled from your repo and has your nine files and the patch for the changes as of FA v2.3.19. These may be used for comparing with their counterparts to suitably modify files in FA v2.3.22+.

@dls: No familiarity with Git is necessary to use the changed files in my earlier post's attachment and the patch file in it is self explanatory. Just compare their original files with their current counterparts and compare the patch files to see what modifications are needed in FA v2.3.22+. Mere overwriting into FA v2.3.22+ will not be advisable.

The only thing not explicitly stated was that there were no database schema changes envisaged.

4,325

(44 replies, posted in Reporting)

Is the FA v2.3.19 patch in the attached file sufficient to now port to FA v2.3.22+?