Re: Import Transactions

@BraathWaate: Good to rely on core functions like the native get_next_trans_no() in the final fix now committed in my repo.

It is attached herewith.

Post's attachments

import_transactions.zip 49.7 kb, 12 downloads since 2017-10-19 

You don't have the permssions to download the attachments of this post.

Re: Import Transactions

This extension has been updated in the official pkg repo as v2.4.0-4.

Post's attachments

Official_Extensions_2017-11-02.png 42.4 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: Import Transactions

I have dowloaded the zip in msg 101 above...

I just tried to run the extension to import a direct sales invoice, I received the following errors, when I did a trial run:

Undefined variable: memo in file: /home/diazhair/public_html/accounts/modules/import_transactions/import_transactions.php at line 194

Undefined variable: person_id in file: /home/diazhair/public_html/accounts/modules/import_transactions/import_transactions.php at line 195

Unhandled exception [0]: Call to undefined function get_standard_cost(). in file: /home/diazhair/public_html/accounts/modules/import_transactions/includes/import_sales_order_entry.inc at line 127

Investigation reveals that the files have a lot of missing braces around the if statements
there are far too many to mention....

Fixing these and re-run, yields many more errors.... seems this has just not been tested...

Re: Import Transactions

Seems my attempts to fix have created more issues than solved....  due to guesses and mis-understanding on my part.... spent several hours, without success....so giving up... hopefully someone with more knowledge can solve...

Re: Import Transactions

Your import file does not have the data in the correct format - the third ($memo) and last but one ($person_id) fields are missing in your data file's records.

The function get_standard_cost() was available in FA 2.3, being defined in it's includes/db/inventory_db.inc and can be inserted somewhere in the module's file: modules/import_transactions/includes/import_sales_order_entry.inc as:

function get_standard_cost($stock_id)
{
    $sql = "SELECT (material_cost + labour_cost + overhead_cost) AS std_cost
        FROM ".TB_PREF."stock_master s WHERE stock_id=".db_escape($stock_id);
    $result = db_query($sql, "The standard cost cannot be retrieved");

    $myrow = db_fetch_row($result);

    return $myrow[0];
}

where you can replace the function name with it in the module's file.

If you wish to use the current code base, the above function has now been superseeded (on 2016-02-23 in FA 2.4 RC1) in the same file by:

function get_unit_cost($stock_id)
{
    $sql = "SELECT material_cost
        FROM ".TB_PREF."stock_master
        WHERE stock_id=".db_escape($stock_id);
    $result = db_query($sql, "The standard cost cannot be retrieved");

    $myrow = db_fetch_row($result);

    return $myrow[0];
}

The unit labour cost and unit overhead cost are also used now and hence the unit cost is sought to denote the unit material cost only.

Try the attached one that follows the latter code that leverages the currently available function.

@joe: which method is recommended?

Post's attachments

import_transactions.zip 49.7 kb, 5 downloads since 2017-12-22 

You don't have the permssions to download the attachments of this post.

Re: Import Transactions

Dear apmuthu, thanks for getting back so quickly.

I used the template salesinvoices...
and there are no columns for either memo or person_id
I am trying to import direct sales invoices...

so does this mean that the templates are not correct and I need to add extra fields....

I will download/try your attached file...

Re: Import Transactions

What is the correct way to apply these modified files ?

Re: Import Transactions

Overwrite the corresponding files in <FA webRoot>/modules/import_transactions folder with the ones updated and attached here.

Export a set of transactions and use that format for importing transactions.

Post's attachments

import_transactions.zip 49.8 kb, 6 downloads since 2017-12-22 

You don't have the permssions to download the attachments of this post.

Re: Import Transactions

Thanks that is clear. I was deleting and re-installing after copying.... which I think was overwriting.... ???

Maybe stupid question but how do I export a set of transactions ?

Re: Import Transactions

Updated extension in last post with heading line fixed in template. I thought there was an export feature in it. The import_items extension has it though.

111 (edited by drgrumpy 12/22/2017 07:53:51 pm)

Re: Import Transactions

I was already using that heading line as in your updated template, that is not the issue.

I now get 11 lines of errors reported...

Looking again at import_transaction.php in the latest code you have provided it looks inconsistent around lines 191 to 196 with lines above....

it looks to me that lines 194 and 195 should be within the
else if ((($type == ST_BANKDEPOSIT)... {  }

we should not be doing a str_replace on non existent variables

but there are no brackets used....

and surely line 196 should be another 'else if' not an 'if'
i.e. if importing a salesorder the template correctly matches line 197

Re: Import Transactions

Actually, the Sales Invoices import was coded later and old PHP's graceful degradation based on loose type acceptance is no longer available.

Try this version now.

Post's attachments

import_transactions.zip 49.9 kb, 5 downloads since 2017-12-22 

You don't have the permssions to download the attachments of this post.

Re: Import Transactions

It reads the line in now but I still get many errors, it seems very broken:

Missing argument 2 for references::is_valid(), called in /home/diazhair/public_html/accounts/modules/import_transactions/includes/import_sales_order_entry.inc on line 33 and defined in file: /home/diazhair/public_html/accounts/includes/references.inc at line 265
Undefined variable: type in file: /home/diazhair/public_html/accounts/includes/references.inc at line 268
Undefined offset: 10 in file: /home/diazhair/public_html/accounts/modules/import_transactions/import_transactions.php at line 278
Undefined offset: 10 in file: /home/diazhair/public_html/accounts/modules/import_transactions/import_transactions.php at line 323
Undefined property: import_sales_cart::$prep_amount in file: /home/diazhair/public_html/accounts/sales/includes/db/sales_order_db.inc at line 42
Undefined property: import_sales_cart::$fixed_asset in file: /home/diazhair/public_html/accounts/sales/includes/db/sales_order_db.inc at line 75
Missing argument 1 for get_shipping_tax_as_array(), called in /home/diazhair/public_html/accounts/modules/import_transactions/includes/import_sales_cart_class.inc on line 509 and defined in file: /home/diazhair/public_html/accounts/taxes/db/tax_groups_db.inc at line 128
Undefined variable: id in file: /home/diazhair/public_html/accounts/taxes/db/tax_groups_db.inc at line 132
Unhandled exception [0]: Call to undefined method import_sales_cart::is_prepaid(). in file: /home/diazhair/public_html/accounts/sales/includes/db/sales_delivery_db.inc at line 66

Re: Import Transactions

The missing 2nd argument for the $Refs->is_valid() method has been fixed using a session value - if this does not work, then the transaction type ($type) must be passed on as an argument to the can_process() function.

There is also a fix needed to the core for tax groups function. Line 128 of taxes/db/tax_groups_db.inc:

function get_shipping_tax_as_array($id)

should be:

function get_shipping_tax_as_array($id=null)

@joe: can fix the core.

Post's attachments

import_transactions.zip 49.9 kb, 4 downloads since 2017-12-23 

You don't have the permssions to download the attachments of this post.

Re: Import Transactions

@joe: Thanks for the commit.

Re: Import Transactions

Improvement but still fails:

Undefined offset: 10 in file: /home/diazhair/public_html/accounts/modules/import_transactions/import_transactions.php at line 278
Undefined offset: 10 in file: /home/diazhair/public_html/accounts/modules/import_transactions/import_transactions.php at line 323
Undefined property: import_sales_cart::$prep_amount in file: /home/diazhair/public_html/accounts/sales/includes/db/sales_order_db.inc at line 42
Undefined property: import_sales_cart::$fixed_asset in file: /home/diazhair/public_html/accounts/sales/includes/db/sales_order_db.inc at line 75
Unhandled exception [0]: Call to undefined method import_sales_cart::is_prepaid(). in file: /home/diazhair/public_html/accounts/sales/includes/db/sales_delivery_db.inc at line 66

117 (edited by apmuthu 12/25/2017 11:21:16 am)

Re: Import Transactions

The sales document types were missing for processing them. They have now been added.
Possible errors that may still remain are the fixed asset parameter in FA 2.4 for adding an invoice though a synch with the core cart class has been done.
The core may not yet have to be modified to degrade gracefully if the results of these changes demonstrate.

Post's attachments

import_transactions.zip 50.2 kb, 31 downloads since 2017-12-25 

You don't have the permssions to download the attachments of this post.

Re: Import Transactions

The direct Sales Invoice Imports works as per attachment.

@joe: can now commit it to official pkg repo.

Post's attachments

SampleImportingTxns.zip 208.5 kb, 31 downloads since 2017-12-25 

You don't have the permssions to download the attachments of this post.

Re: Import Transactions

Fantastic, it works as I expect.
Very many thanks apmuthu

Re: Import Transactions

The pkg repo is dedicated to Janusz. We will have to ask him.

Joe

Re: Import Transactions

This is a very important extension for FA and should have been built into the core as export/import are the important integration hooks for other applications to exchange data.

@itronics: please update the pkg repo accordingly.

122 (edited by dopee15 06/05/2018 04:04:24 am)

Re: Import Transactions

I apologize I'm very new to this... I'm trying to upload a sample invoice processing using sample from templates folder.. I'm getting errors... Im using 2.4.3

========================================================================
Undefined variable: memo in file: /home/mypinlight/public_html/facct/modules/import_transactions/import_transactions.php at line 194
Undefined variable: person_id in file: /home/mypinlight/public_html/facct/modules/import_transactions/import_transactions.php at line 195
Missing argument 2 for references::is_valid(), called in /home/mypinlight/public_html/facct/modules/import_transactions/includes/import_sales_order_entry.inc on line 33 and defined in file: /home/mypinlight/public_html/facct/includes/references.inc at line 265
Undefined variable: type in file: /home/mypinlight/public_html/facct/includes/references.inc at line 268
On line 2 you must enter a reference.
Undefined offset: 10 in file: /home/mypinlight/public_html/facct/modules/import_transactions/import_transactions.php at line 277
Error: date '01/12/2014' not properly formatted (line 2 in import file 'single_line_salesinvoices.csv')
Undefined offset: 10 in file: /home/mypinlight/public_html/facct/modules/import_transactions/import_transactions.php at line 322
Undefined offset: 2 in file: /home/mypinlight/public_html/facct/includes/date_functions.inc at line 395
Undefined offset: 1 in file: /home/mypinlight/public_html/facct/includes/date_functions.inc at line 395
Undefined property: import_sales_cart::$prep_amount in file: /home/mypinlight/public_html/facct/sales/includes/db/sales_order_db.inc at line 42
Undefined property: import_sales_cart::$fixed_asset in file: /home/mypinlight/public_html/facct/sales/includes/db/sales_order_db.inc at line 75
Missing argument 1 for get_shipping_tax_as_array(), called in /home/mypinlight/public_html/facct/modules/import_transactions/includes/import_sales_cart_class.inc on line 509 and defined in file: /home/mypinlight/public_html/facct/taxes/db/tax_groups_db.inc at line 128
Undefined variable: id in file: /home/mypinlight/public_html/facct/taxes/db/tax_groups_db.inc at line 132
Call to undefined method import_sales_cart::is_prepaid() in /home/mypinlight/public_html/facct/sales/includes/db/sales_delivery_db.inc on line 66
========================================================================

I wonder if someone could help me... I can give the username and password in my FA accounting link... also if you can help me regarding the template for sales order processing I'll be more than happy

Re: Import Transactions

I tried to follow every instruction here but I cant get rid of the errors.. hope anyone can help me...

Re: Import Transactions

Hello... I think I was to make it work.. Thanks to the file from sir Apmuthu.. I overwrite the files change the date settings on my FAaccounting then it works...

Re: Import Transactions

Hello... Import_transaction is working and I even created an ETL to get data from wordpress woocommerce and create CSV to upload new orders to FA..

However my problem is the freight cost... it is not capturing the freight cost in CSV.. I need help for this.. Thanks in advance