Jump to content
Sign in to follow this  
jdw814

PeachTree CSV Export - Changes needed to contrib...

Recommended Posts

Hi all,

 

Okay, we recently got this contribution working for exports to PeachTree 2006 (Accountants Edition). In the process, there was a LOT of debugging and "tweaking" that had to be done. I don't really have the time to put everything we learned into a new version of the contribution (unless it would be for the State tax version only) -- so I thought I would just pass it along here.

 

Some of these fixes may not be "elegant", but they work...

 

-*-*-

 

1. Additional Fields:

(This applies to both osc_export.php and osc_export_batch.php, but I am using approx. line #s from the original osc_export_batch.php.)

 

~Line 91 (between "$ship_to_zip" and "$payment"), insert:

$ship_to_country = $tabel1['delivery_country'];

 

~Line 98 (after "$source_file"), insert:

$showfalse = "FALSE";

 

 

~Line 59, change the "headings" from:

$output = "Customer ID,Sales Order #,Date,Ship to Name,Ship to Address-Line One,Ship to City,Ship to State,Ship to Zipcode,Ship to Country,
Accounts Receivable Account,Sales Tax Code,Number of Distributions,So Distribution,Quantity,Item ID,Description,G/L Account,
Unit Price,Tax Type,Amount,Sales Tax Authority \n";

 

to:

$output = "Customer ID,Sales Order #,CRMemo,Date,Ship to Name,Ship to Address-Line One,Ship to City,Ship to State,Ship to Zipcode,Ship to Country,
Due Date,Terms,Accounts Receivable Account,Sales Tax Code,Number of Distributions,SO Distribution,Quantity,Item ID,Description,G/L Account,
Unit Price,Tax Type,Amount,Sales Tax Authority \n";

 

(The new fields are "CRMemo", "Due Date", and "Terms"... At least in PeachTree 2006, the import will NOT work properly without the "CRMemo" field. The addition of "Due Date" and "Terms" are optional.)

 

 

~Line 117, change the "common data" to look like the following:

(I've indicated the new lines, or changes, with comments.)

$common = $peachtreeaccount.$fieldseparator
.$ordernr.$fieldseparator
.$showfalse.$fieldseparator // CRMemo addition
.$date.$fieldseparator
.$ship_to_name.$fieldseparator
.$ship_to_address.$fieldseparator
.$ship_to_city.$fieldseparator
.$ship_to_state.$fieldseparator
.$ship_to_zip.$fieldseparator
.$ship_to_country.$fieldseparator // corrected from $telephone
.$date.$fieldseparator // Due Date addition, optional
.$payment.$fieldseparator // Terms addition, optional
.$peachtreeAR.$fieldseparator;

 

-*-*-

 

2. Addition of quote marks around values that might have commas in them -- to prevent "extra", unintended fields in some rows:

(This also applies to both osc_export.php and osc_export_batch.php -- and I am still using approx. line #s from the original osc_export_batch.php.)

 

~Line 12 (after "$fieldseparator"), insert:

$fieldquote = '"';

 

Then, add "$fieldquote" around any fields that might have commas in the value. Examples below:

 

~Line 164

.$object[$i]['products_quantity'] . $fieldseparator . $object[$i]['products_model']. $fieldseparator . $fieldquote . 
str_replace(""","",str_replace("\"","",$object[$i]['products_name'])). $fieldquote . $fieldseparator .$glsalesaccount . 
$fieldseparator . $fieldquote . number_format($object[$i]['final_price'], 2, '.', ',') . $fieldquote . $fieldseparator . 
"1" . $fieldseparator . $fieldquote . "-" . number_format($myamount, 2, '.', ',') . $fieldquote .$fieldseparator . "\n";

(Make the same changes at ~Line 200)

 

~Line 174

."0" . $fieldseparator . $fieldseparator . $fieldquote . $freightdescription . $fieldquote . $fieldseparator . 
$glfreightaccount . $fieldseparator . "0" . $fieldseparator . "26" . $fieldseparator . $fieldquote . "-" . $freight . 
$fieldquote .$fieldseparator . "\n";

(Make the same changes at ~Line 211)

 

~Line 185

."0" . $fieldseparator . $fieldseparator . $fieldquote . $salestaxdescription . $fieldquote . $fieldseparator .
$glsalestaxaccount . $fieldseparator . "0" . $fieldseparator . "0" . $fieldseparator . $fieldquote . "-" . $salestax . 
$fieldquote .$fieldseparator .$salestaxauthority ."\n";

 

 

-*-*-

 

3. Correcting data exported for items with Qty greater than 1:

(This also applies to both osc_export.php and osc_export_batch.php -- and I am still using approx. line #s from the original osc_export_batch.php.)

 

~Line 158 (after "$glsalesaccount"), insert:

$myamount = $object[$i]['final_price'] * $object[$i]['products_quantity'];

(Make the same change at ~Line 194)

 

~Line 164 change the second reference to

number_format($object[$i]['final_price'], 2, '.', ',')

to read as follows:

number_format($myamount, 2, '.', ',')

(Make the same change at ~Line 200)

 

-*-*-

 

4. Assigning values to "loop" variables, so that they are consistently accurate:

(This really only applies to osc_export_batch.php. We were seeing a situation where if one customer ordered 3 items -- and the next one only ordered 1, the second order would be "padded" with the last two items from the previous order. The problem was that variables used in the loop were not being properly reset at the beginning of each loop.)

 

~Line 142

Changed assignment of "$ii" to read as follows:

$ii=$x-1;
$i=1;
$h=1;

(Note that I am NOT assigning a value to "$no_of_rows" at this point.)

 

~Line 149 removed assignments for "$i", "$ii", and "$h".

Changed assignment of "$no_of_rows" to read as follows:

$no_of_rows=$ii+1;

 

~Line 169 changed while loop to read as follows:

while($h<=$ii) {

 

 

~Line 179, insert following assignment:

$no_of_rows=$ii+2;

 

~Line 189, remove comment codes in front of while loop and changed to read as follows:

while($h<=$ii) {

 

~Line 199, change:

.$i.$fieldseparator

to:

.$h.$fieldseparator

 

~Line 202, remove comment codes in front of "$h++;" - now need to increment the while loop

~Line 203, remove comment codes in front of "}" - now need to end the while loop

 

-*-*-

 

I hope that this information is helpful to someone!

 

Best Regards,

Julie

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×