arad85 wrote:

Anyone like to comment on the ones supplied by tclim?

Anyone?

Ahh yes. Got it - thanks Scott. No worries about firewalls then smile

Anyone like to comment on the ones supplied by tclim?

Hi Scott

Thanks for the quick reply. I've not come across WinForms apps before and IU still don't understand how this works. How does the data get to and from the FA and eCommerce sites when one is behind a firewall? Is it run on a 3rd machine which manages the pulling and pushing?

swheeler wrote:

Hi arad85,

For CartSpan, you should only need to 'whitelist' the IP address of the local machine that is making a call to the FA server.

Thanks,
Scott

Hi Scott,

Thanks for the response, but I do not want to port forward or whitelist if at all possible - I see it as a security hole (the e-commerce site will be run on a shared server). I'd like to keep it so the e-commerce site cannot see the FA server - I'd be prepared to run cron jobs and sync via data exports though. Is this possible?

Hi all,

I'm aware of the modules supplied by tclim and the one supplied by swheeler (CartSpan) but I am not clear how these work when your e-commerce solution is visible on the net whilst your FrontAccounting system is hidden behind a firewall. In this case, the e-commerce system can't access the F/A database so can't easily sync with it - at least, not from the commerce site. Is this usecase supported with these extensions?

TIA

You're right! I could. I thought someone would have don this somewhere, but just couldn't find it. Never mind, it was a good learning exercise - and useful should anyone else want it...

Edit to correct the line in import_csv_ui.inc:

if ($data[0] == "#") continue;

to

if ($data[0][0] == "#") continue;

It didn't work if there wasn't a space after the #

NOTE: this method requires you to edit a FA delivered file. If you don't feel comfortable with this, then this method isn't for you

We use frontaccounting to run a small retail outlet which has a fairly large number of different items for sale. The till has a barcode scanner and reports sales against barcodes and we can get that data back onto the computer. I wanted to automate the import of this data into the daily sales records to speed things up as well as avoiding any manual entry issues.

The first thing to do is get the data from the till into a format suitable for use in FA. I have a method of automating barcode->Frontaccounting stock item code (via a couple of shell scripts which is beyond the scope of this post) so I can get the data to a format that has the information ready for input into FA. I also couldn't find anyone who had done this before (I may well be looking in the wrong place but...) so I thought I'd share my method in case anyone else wanted it.

The format of the file to read in is:

# Any line where the first character is a hash is a comment
# FA-ITEM-CODE,QUANTITY,TOTAL PRICE
ITEM0001,2,7.00
ITEM0002,1,2.45

which shows 3 sales, 2 of ITEM0001 at a TOTAL price of £7 (so average £3.50 each) and 1 of ITEM0002 at £2.45 (I'm UK based). The code then imports the file into the sales order form. In doing this it

  • Checks to see if the item is defined in the database and prints an error if not

  • Looks up the sales price in the database and works out any discount that has been given

  • Adds the item to the sales order with the correct quantities and discount

Note: you can have multiple lines with the same item in, so if the normal selling price of ITEM0001 is £4, and one of the sales you gave a 25% discount, you could equally well have written the above csv file as:

# Any line where the first character is a hash is a comment
# FA-ITEM-CODE,QUANTITY,TOTAL PRICE
ITEM0001,1,3.00
ITEM0001,1,4.00
ITEM0002,1,2.45

and it will still work.

Log into your FA machine and change directory to the WWW root (for my system which is Debian based, this is /var/www) and then change directory to the FA directory (if there is one). Then change directory into the sales directory (/var/www/fa/sales in my casee). In there, you will find a file called sales_order_entry.php This file is the main sales order entry code. Change the following section of code (around line 700) from:

        $cancelorder = _("Cancel Order");
        $porder = _("Place Order");
        $corder = _("Commit Order Changes");
}
start_form();

hidden('cart_id');
$customer_error = display_order_header($_SESSION['Items'],
        ($_SESSION['Items']->any_already_delivered() == 0), $idate);

to look like:

        $cancelorder = _("Cancel Order");
        $porder = _("Place Order");
        $corder = _("Commit Order Changes");
}

// Add the import CSV file
include_once($path_to_root . "/sales/includes/ui/import_csv_ui.inc");

start_form();

hidden('cart_id');
$customer_error = display_order_header($_SESSION['Items'],
        ($_SESSION['Items']->any_already_delivered() == 0), $idate);

Note: there is only a single line edit in this file which includes the next file before the start_form().  This adds the import file dialogue onto the page with the form.

Now change directory to includes/ui (which is beneath the sales directory)  and create the file import_csv_ui.inc with the contents (with thanks to Tom Hallman for his import_multiplejournalentries to let me see how to read files in PHP):

<?php
/**********************************************************************
    Author: arad85
        Released under the terms of the GNU General Public License, GPL,
        as published by the Free Software Foundation, either version 3
        of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
if (isset($_POST['ImportFile'])) {
  if (isset($_FILES['imp']) && ($_FILES['imp']['name'] != ''))
    {
      $filename = $_FILES['imp']['tmp_name'];
      $fp = @fopen($filename, "r");
      if (!$fp)
        {
          display_error("Error opening file $filename");
        } else
        {
          while ($data = fgetcsv($fp))
            {
              // Skip blank lines
              if (count($data) == 1) continue;

              // Skip lines beginning with a # - comment lines
              if ($data[0][0] == "#") continue;

              // Parse the row of data; Format: stock_id, quantity, price
              list($stock_id, $quantity, $price) = $data;

              // Is this actually an item or not?
              $item = db_fetch(get_item_kit($stock_id));

              // if not, report an error and move to the next line
              if (empty($item))
                {
                  display_error(_("ERROR: item ").$stock_id. " "
                                  . _("does not exist in the inventory database. Please check your import file"));
                  continue;
                }

              // Convert price to a units price rather than total value
              $price = round(($price/$quantity), 2);

              // Find out what we should be selling this for
              $std_price = get_kit_price($stock_id, $_SESSION['Items']->customer_currency,
                $_SESSION['Items']->sales_type, $_SESSION['Items']->price_factor, get_post('OrderDate'), true);

              // If we don't have a price set, just assume sales price = actual price
              if ($std_price == 0)
                $std_price = $price;

              // Calculate the discount
              $discount = round(($std_price - $price) / $std_price, 3);

              // And add the item to the order
              add_to_order($_SESSION['Items'], $stock_id, $quantity, $std_price, $discount);
            }
        }

      @fclose($fp);

      page_modified();
      line_start_focus();
    }

    else
      display_error("No file selected for import");
}

//- Add the import box here
start_form(true);
start_table(TABLESTYLE2, "width=80%");
echo "<tr><td colspan=3 align='center' class='label'><b>Import CSV file</b></td></tr>";
label_cells("File to import:", "<input type='file' id='imp' name='imp'>", "class='label'");
submit_cells('ImportFile', _("Perform Import"), "align='center' valign='bottom'", _('Import CSV file of sales'));
end_table(1);
end_form();

?>

Don't forget to change the permissions to the correct values to allow your www process to read them (and noone else to edit them).

Hopefully, you can now import a CSV file into the sales form.

arad85 wrote:

Actually, looking at this further, the goods supplied are out of the scope for VAT, so should not appear on the return at all...

Or even easier... Set up a second tax group which has no taxes included and set the supplier as belonging to this tax group (also create them with Tax Included Prices marked although this is only a cosmetic change). Once done, the purchase of any item from the supplier doesn't have any tax added/deducted and once in stock, the item is subject to the usual tax rules on sale. All the figures seem to work nicely so...

Actually, looking at this further, the goods supplied are out of the scope for VAT, so should not appear on the return at all and I think I have fixed my own problem. Doing some testing, it appears I have to do 2 things:

  • Setup 4 tax types (20%, 5%, 0% and exempt) The key item I had missed was the difference between 0% tax (which is included in tax returns) and tax-exempt (not included in tax returns) - obvious when you think of it

  • Buy items from tax-exempt companies as exempt items and then "manufacture" them into items for sale at the appropriate tax rate. That way, the purchase item is treated correctly, the output tax is also treated correctly and as far as I can see, the audit trail is correct too.

I'm not sure how to handle this....

We are using FA to manage the accounting of a small crafts business. The business is VAT registered and so has to pay VAT on all items sold that are VATable. One or two of our suppliers are not VAT registered - we understand what we have to charge VAT on and pay VAT on, but I can't seem to setup the system to give me the information I want. Let us say I have sold an item at £120 inc VAT that I bought for £60 from a non-vat reg'd company. I know I have to pay the taxman £20 (20% of £100) and show Output and Output Tax as £100 and £20 respectively but I also need to show that Input and Input Tax as £60 and £0.

Does anyone know how to do this?

itronics wrote:

Generally it is not advisable to work under any application without saving your work by hours, but surelly I understand your iritation.
Yes, please make the report for this issue on Mantis.
Janusz

It was more getting used to the system (it was only 20 or so lines, but had taken her a while to put in). 2104 entered: http://mantis.frontaccounting.com/view.php?id=2104

itronics wrote:

Yes, you are right. This make sense in forms which can contain many entered data lines

There were some very rude words being spoken by Ms arad85 last night when she lost about an hours work (we are just getting used to the system) by navigating away from a purchase order page!

Do you need me to enter a bug report for this?

Hello all,

When you are in any of the purchase screens and you have entered in any data on the page, the system should give you a warning before you move away that the entry will be cancelled. The sales tab does this.

To reproduce, enter a purchase order, add some items and navigate away. The system does this immediately and loses the order. Do the same on a sales order and a popup appears with the text:

Entered data has not been saved yet.
Do you want to abandon changes?

This really should be on any page that has the chance of significant data entry. Reproduced on 2.3.15 and multiple themes.

Hi Janusz,

itronics wrote:

Unfortunatelly there was a bug introduced recently in php mailing code. This is fixed now, and will be available with next release. You can also fix it yourself as explained in this thread.
Janusz

No problems - at least it has been fixed and the fix is easy to apply! I couldn't find that issue by searching - my search terms must have been a little off - apologies.

Thanks - and keep up the good work on a great product (just started to use FA).

Andy

A new install of FA 2.3.15 (created tonight). A working implementation of ssmtp so I can send both via the command line AND via the php mail() function (see below).

When I try and send an invoice by mail, the system responds with:

PURCHASE ORDER 1. Sending document by email failed. Email: s

Where the email is always the first letter of the company contact mail (i.e. the email is s if the mail address is ssss@example.com, and y if the email is ysss@example.com). Looking at the debug log from ssmtp, it is refusing the mail as it can't find a mailbox s@mydomain.com.

If I remove the mail contact, it says:

You have no email contact defined for this type of document for 'Supplier'.

If I have this as a .php file:

<?php
$to = "me@mydomain.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

I get a mail from someonelse@example.com with headers/text as you'd expect - so the mail() function is working fine.

It looks like the mail is only taking the first letter of the name. Anyone any ideas?