Re: Importing customer csv data in FA v2.3.6

I have wiki-ed the discussions here starting from your first post here to help others taking their first steps in FA(iry) Land.

Re: Importing customer csv data in FA v2.3.6

ok, I tried the mods but it just splorked so for now I'm going to use the default install from snapshot. At least I got the Canadian CoA to work, and I also deleted company#2 and ran it from default 0_ company because some features weren't available to the admin user and I didn't want to jump back and forth. I'll send what I found re CoA once I'm sure it's working.

Tks, A

Re: Importing customer csv data in FA v2.3.6

Install from the snapshot and then apply the mods and see what breaks - tmp/errors.log and apache error logs.

Re: Importing customer csv data in FA v2.3.6

Good Morning @apmuthu, yesterday I was able to get our Prestashop connector working well with the new CoA, transferring inventory items and clients. So we'll get our year end inventory figures inputted so now I can start using the inventory control system and issue FA purchase orders. This should be a big help because we have warehouse stock in several different countries, with sales in several different currencies (being in the electronics import/export business).

I think my approach with the mods was too hasty, trying to update everything at once, so now I'm going to see if I can develop a procedure to do them one by one, as it should be much easier to debug. I'm glad that the FA file and db structure is so well organized; this will make the process a lot easier to understand.

I have created a folder structure on my local machine that replicates the FA folder structure. This new replicated structure contains only the modified files from your repository site, and it will make it easier to upload only one change at a time and study the result.

Regards, Adrian

30 (edited by apmuthu 01/06/2015 04:43:29 pm)

Re: Importing customer csv data in FA v2.3.6

Please be aware that some files should be uploaded together.

The ones in the company folder are not required if you do not want to use the extra info option (CID, BinLoc) which enables the printing of the Branch ID (either external lookup Branch ID in the notes field or in it's absence, the branch_code field)  and the Bin Location in the long_description field in the Packing List report. It is explained in the Wiki Page for Bin Location in FA.

The admin backups file is used to provide extended functionality for backup file renaming and for execution of various linux commands and outputting the results in the browser. It is discussed in this post.

There is also some code (header2.inc) to display a pretty PayPal link in the Invoice - discussed in this post and later updated in my repo.

Congrats. You are making exemplary progress indeed inspite of our "half way across the world timezone human latency".

Re: Importing customer csv data in FA v2.3.6

Hi @apmuthu, thanks for the tips and the kind words. Frankly, I would have been completely lost if it was not for your very thorough and prompt assistance. This project is one of the most complex I have ever tackled, and definitely not for the faint hearted.

Speaking about the time zone latency, you seem to be another one that never sleeps, like some others I know! smile

Regards, Adrian

32 (edited by apmuthu 01/06/2015 07:05:59 pm)

Re: Importing customer csv data in FA v2.3.6

When you do some testing see if you want to try this patch which is a backport from FA v2.4 where some legacy bugs are aslo fixed.

--- old/sales/customer_payments.php    Mon Sep 29 21:21:28 2014
+++ new/sales/customer_payments.php    Wed Jan 07 00:24:14 2015
@@ -54,6 +54,7 @@
         if($inv) {
             $_SESSION['alloc']->person_id = $_POST['customer_id'] = $inv['debtor_no'];
             $_SESSION['alloc']->read();
+            $_POST['BranchID'] = $inv['branch_code'];
             $_POST['DateBanked'] = sql2date($inv['tran_date']);
             foreach($_SESSION['alloc']->allocs as $line => $trans) {
                 if ($trans->type == ST_SALESINVOICE && $trans->type_no == $_GET['SInvoice']) {
@@ -247,9 +248,6 @@
 //    unset($_POST['branch_id']);
     $Ajax->activate('BranchID');
 }
-//if (isset($_POST['_DateBanked_changed'])) {
-//  $Ajax->activate('_ex_rate');
-//}
 
 //----------------------------------------------------------------------------------------------
 

The progress of this thread exposes how much I took for granted that anyone would be able to adopt the full disclosures on my GitHub Repo inspite of the regular cross referencing of the wiki to the forum posts.

Re: Importing customer csv data in FA v2.3.6

Hi @apmuthu, I think the wiki IS very good, and I probably would have just continued with that, if I hadn't discovered this problem of field reversal in the inventory items page. It was at that point I felt I needed to talk to somebody in the know, and luckily I got you.

But that all came about because of my assumption that Softaculous would automatically install the latest and greatest version, so my bad on that. This thread would probably not exist if I had just followed the regular install instructions.

Regards, Adrian

Re: Importing customer csv data in FA v2.3.6

Hi @apmuthu, one question I had about the US CoA is that I am getting a sql error with regards to the indexes on the 0_bom table, could you tell me if this is correct:

  PRIMARY KEY  (`parent`,`component`,`workcentre_added`,`loc_code`),
  KEY `component` (`component`),
  KEY `id` (`id`),
  KEY `loc_code` (`loc_code`),
  KEY `parent` (`parent`,`loc_code`),
  KEY `workcentre_added` (`workcentre_added`)

Tks, Adrian

35 (edited by apmuthu 01/07/2015 06:53:15 pm)

Re: Importing customer csv data in FA v2.3.6

Try making it:

  PRIMARY KEY  (`parent`,`loc_code`,`component`,`workcentre_added`),
  KEY `component` (`component`),
  KEY `id` (`id`),
  KEY `loc_code` (`loc_code`),
  KEY `workcentre_added` (`workcentre_added`)

to remove redundant indices but that is not the fix.


The fields parent and component refer to stock_id which is varchar(20) in the other tables and hence these two should be varchar(20) too but that should not generally be the cause of any problems except for type matching and index based joins.

The following sql will achieve the above changes:

ALTER TABLE `0_bom` 
    CHANGE `parent` `parent` VARCHAR(20) DEFAULT '' NOT NULL, 
    CHANGE `component` `component` VARCHAR(20) DEFAULT '' NOT NULL, 
    DROP INDEX `parent`, 
    DROP PRIMARY KEY, ADD PRIMARY KEY (`parent`, `loc_code`, `component`, `workcentre_added`); 

The file / function that is in error is:

includes/db/manufacturing_db.inc => update_bom()

function update_bom($selected_parent, $selected_component, $workcentre_added, $loc_code, $quantity)
{
    $sql = "UPDATE ".TB_PREF."bom SET workcentre_added=".db_escape($workcentre_added)
     . ",loc_code=".db_escape($loc_code) . ",
        quantity= " . $quantity . "
        WHERE parent=".db_escape($selected_parent) . "
        AND id=".db_escape($selected_component);
    check_db_error("Could not update this bom component", $sql);

    db_query($sql,"could not update bom");
}

should be

function update_bom($selected_parent, $selected_component, $workcentre_added, $loc_code, $quantity)
{
    $sql = "UPDATE ".TB_PREF."bom SET workcentre_added=".db_escape($workcentre_added)
     . ",loc_code=".db_escape($loc_code) . ",
        quantity= " . $quantity . "
        WHERE parent=".db_escape($selected_parent) . "
        AND component=".db_escape($selected_component);
    check_db_error("Could not update this bom component", $sql);

    db_query($sql,"could not update bom");
}

The only two functions there that use the id field in the 0_bom table are:

  • delete_bom()

  • get_component_from_bom()

*** The fix listed above for the file manufacturing_db.inc is not correct ***
It has been superceeded by a later commit in my GitHub Repo. - Thanks @itronics for pointing me in the right direction.

Re: Importing customer csv data in FA v2.3.6

Hi, actually the problem seemed to be around this line:

PRIMARY KEY  (`parent`,`loc_code`,`component`,`workcentre_added`),

It didn't throw a sql error when installing, it only showed up later when I did a backup copy with Navicat, and it complained that there can only be one primary index. Is the this perhaps sql syntax that navicat doesn't understand, or were they correct?

Regards, Adrian

37 (edited by apmuthu 01/07/2015 05:17:37 am)

Re: Importing customer csv data in FA v2.3.6

You will nevertheless need the fixes in my previous post as the error in update_bom() will show up when used.

Study the backup file sql and compare it with the original and see where Navicat (that specific version/build) falters. It is possible that your Navicat install expects the keyword "FOREIGN KEY" instead of the plain and possibly ambiguous "KEY" or it is expecting the equivalent "INDEX", in which case it is likely to affect quite a few tables!

The entire fix is now in the FAMods in my GltHub repo.

Re: Importing customer csv data in FA v2.3.6

Hi apmuthu, ok, I see the changes I need to implement. Just to be really clear, when I see - and + symbols in front of a line in the FAmods at github, it means add(+) and remove(-), is that correct? like here:

- PRIMARY KEY (`parent`,`component`,`workcentre_added`,`loc_code`),
+ PRIMARY KEY (`parent`,`loc_code`,`component`,`workcentre_added`),

I'm also finding there is very little difference between the US and Canadian CoA's, and the Canadian one is actually missing quite a few accounts that we would use (that are in the US one), so I think I'll make a whole new CCoA anyway.

Regards, Adrian

39 (edited by apmuthu 01/07/2015 07:46:07 am)

Re: Importing customer csv data in FA v2.3.6

Spot on! That's the right way for human readability. But... linux has a patch command to auto-magically traverse thru the folder tree and apply such "diffs" (can be generated from WinMerge - Unified Diff and adjusting for CRLF=>LF UnixDos differences in line endings).

Since there was one other key in the table that mimicked the first part of the proposed new re-arranged  Primary Key, we call it a redundant index and have it removed.

Making a new CoA from the en_US-new.sql will be the right way to proceed. The one in my updated FAMods folder has all the changes necessary. You need to change the order of currencies and their default id and rate value to 1 for the home currency making it the first one and the default currency in the users table and in the sys_prefs tables' data. If you add new account heads then space them numerically in steps of 10 or 5 and huddle them together logically for ease of sifting thru later. You may also want to adjust the fiscal_years table to suit your current and future installs.

Re: Importing customer csv data in FA v2.3.6

Ah, hello guys. Interesting discussion, but,

Maybe you should start Another topic for tis discussion, right?
We are not on the subject any more.

/Joe

41 (edited by apmuthu 01/07/2015 06:56:14 pm)

Re: Importing customer csv data in FA v2.3.6

@joe: In fact a few posts earlier, we found that the thread evolved into a FA Setup Tips topic and I wikied it as such for want of some forum feature to fork a part of it as a separate topic... This new topic can begin with the 13th post in this thread onwards.

For those who partook of my fix in the 35th post in this thread can now update it with the superceeded commit.

Re: Importing customer csv data in FA v2.3.6

One quick question, please, I can find the procedures for importing items and clients in the wiki, and it's very clear. But I can't seem to find anything about importing orders, is there something somewhere?

Tks, A

Re: Importing customer csv data in FA v2.3.6

Does the official extension "import_transactions" serve the purpose?

Re: Importing customer csv data in FA v2.3.6

ah, thanks, using the wrong word to search ...  transactions <-> orders

45 (edited by apmuthu 01/08/2015 08:32:31 am)

Re: Importing customer csv data in FA v2.3.6

You may even update the files in the package after installation but before activation / usage with the ones in my github repo.

Re: Importing customer csv data in FA v2.3.6

Hi apmuthu, as mentioned previously, because the CoA is such a core part of FA, I have decided to re-create the Canadian version of the CoA based on the US version. This will put it in sync with the US CoA and make things a lot easier to follow as I write the code for the Prestashop transaction connector.

I am doing it veeery carefully so there are no mistakes, and I will document the few accounts that are different from the US version. I'm very glad to have Winmerge as it makes it much easier to do, thanks for that.

I'm a week or two away from actually firing this thing up, so I'm wondering if there might be a new 'snapshot' coming up that will save me from tackling the mods?

Regards, Adrian

47 (edited by apmuthu 01/08/2015 05:13:37 pm)

Re: Importing customer csv data in FA v2.3.6

In fact I have just completed a few backports and non field db data into reports (Min Order, Prepaid Freight, etc) in my FAMods besides the en_GB-general.sql complete fix in the extensions.

The devs have categorically said they will only provide critical updates to the v2.3.x branch henceforth and I expect a final v2.3 release is hence due.

On the 7th the extensions were queried and an update was expected but all were frozen as of 28th last. I have also done a thorough clean up of all 38 official languages including the yet unaccepted Tamil (ta_IN) even though it has more phrases translated than some of those already there.

The easiest way to do a fresh CoA is to
1. Import the en_US-new.sql into a fresh database
2. Export it from your mysql client schema + data - to say one.sql
3. Make changes as you see fit in the tables that contain data - Currencies, date/time formats, company defaults, sys_prefs, chart_masters, fiscal years, etc.
4. Export it to say two.sql.
5. Use Winmerge to sift the differences and see how they compare with the existing Canadian one.
6. Make changes to two.sql but retain a blank audit_trail table and the standard users table from the US CoA except for some specifics for Canada. That way you'll preserve the default admin access / password and not bother with session based timestamp changes.
7. Remove the CREATE DB and USE DB commands in two.sql.
8. Now you have your CoA - two.sql - rename it to en_CA-general.sql and upload it in the place of your officially installed one so that the config entries remain.

The ones I maintain have the schema without the collations bunched together and the insert statements entered later all in one bunch with those that vary between CoA's alone towards the end. That way when making a new CoA, we just need to copy this and make changes to the data towards the end alone!

In fact my suggestion was to keep the schema and standard data in one sql file and the rest that changes between CoAs alone be used from separate sql files. It remains unaccepted due possibly to accommodate some queer collations and out of turn insertion of data where strict InnoDB and other RDMS constructs will make import fail on cascade dependencies.

Re: Importing customer csv data in FA v2.3.6

Hi apmuthu, I agree, I had actually been thinking about how I could keep the CoA differences separated, there really isn't much difference. This would allow the generic US CoA accounts to be somewhat standard, which will probably make things easier in the long run. After all, double entry accounting is double entry accounting, no matter where you are.

Thanks for the CoA tips, I'll keep muttering along ...

Regards, Adrian

49 (edited by apmuthu 01/08/2015 06:28:40 pm)

Re: Importing customer csv data in FA v2.3.6

Committed the mod for printing the name of the person who generated the sales quotation. Needs to be activated in line 19 of doctext.inc - depending on whether the one in the overriding company/#/reporting/includes folder is used or the native one in reporting/includes folder is used.

Re: Importing customer csv data in FA v2.3.6

Hi, just ftr, here are the changes I'm making to the en_US-new.sql to create the new Canadian CoA for us, not a lot of difference. I'm not quite sure why the Canadian one had the extra group re payroll deductions, but here it is:

Group 4: Current Liabilities
modifications:
'2120', '', 'Accrued Income Tax - State' -> 'Accrued Income Tax - Provincial'
'2150', '', 'Sales Tax' -> 'PST' [Provincial Sales tax]
additions:
'2155', '', 'GST' [Federal Goods & Services tax]
deletions:
'2310', '', 'Accr. Benefits - 401K'

Group 11: Payroll Expenses

additions:
'5480', '', 'EI Expense'
'5485', '', 'CPP Expense'
'5490', '', 'WCB Expense'
deletions:
'5520', '', 'Inc Tax Exp - State'

[added]Group 13: Payroll Deductions

'6100', '', 'EI Payable'
'6105', '', 'CPP Payable'
'6110', '', 'WCB Payable'
'6115', '', 'Income Tax Payable (Combined)'

Regards, Adrian