1

(5 replies, posted in Setup)

Oh... You were trying to get data out of FA?

In that case, you'd be better off with a simple php script reading from the database directly. No need for ODBC, either. Just make sure you filter/escape all strings before embedding them into your SQL query.

2

(5 replies, posted in Setup)

appelm wrote:

Just looking around and found a post about how curl can use the login fields to pass username and password:

curl -F 'user_name_entry_field=<username>' -F 'password=<password>' -F 'company_login_name=<company number>' url

I don't even really understand what curl is but wondering if there's a way to use those field names in the url in the same way.

Curl allows you to script a browser session from the command line. The snippet above logs in and creates a session. Once there is a session, the script could load a particular page and insert the data into the appropriate form fields before submitting the form.

It should be possible to call such a script from Excel with the appropriate parameters. As long as the form in question doesn't use AJAX, it should work.

3

(5 replies, posted in Translations)

The best (and, indeed, the only reasonable) way would be to treat it as another date format. There is absolutely no reason to change how it's stored internally.

4

(10 replies, posted in Reporting)

GJ,

For a simple change like this, the "quick 'n' dirty" way is just fine. You just need to remember what you did when you decide to upgrade to a new version.

Apmuthu,

I agree that a translation would be the "proper" way to do this, but how would that work if one was already using, say, Australian or Indian English? Should we (and could we?) have a "local.mo" which - if present - would override parts of the installed language pack?

Not from within FA itself, but you can have a cron job (or a "scheduled task" if you're on Windows) do it easily enough.

Below is what I run on a Linux server.

#!/bin/bash
url="http://hostname.domain.tld/"
cd "$(dirname "$0")"

curl -s -c my_session -F 'user_name_entry_field=backup' \
                      -F 'password=secretpassword' \
                      -F 'company_login_name=0' ${url} >/dev/null

curl -s -b my_session -F 'creat=Create Backup' ${url}admin/backups.php \
     | hxnormalize -l 240 -x | hxselect -s '\n' -c '#msgbox' | hxselect -c div 
echo
rm my_session

The script uses curl to log in as user "backup" with password "secretpassword" and "clicks" the "create backup" button for you. The "hx" stuff is there to select out the interesting parts (success/failure status messages) from the server response. Just remove that line if you don't want it.

6

(14 replies, posted in Setup)

I still don't understand what that function is supposed to be doing. Why would the increase in precision differ depending on whether a precision parameter has been passed to the function or taken from some configuration setting?

Not that it would matter, because as far as I could tell that function is never called.

dls wrote:

How would the files get the multi-byte UTF data in them (As a result of a setting incorrect?)

I was thinking there might be some customer names/addresses, item descriptions etc. which contained them. That would explain why it doesn't happen every time.

dls wrote:

and how can I detect whether this is happening?

Reliably determining a file's encoding is trickier than one would imagine. Besides, there could well be other reasons the file size gets mangled. (There might not even be a file at that point, but rather a string stored in memory.)

So what I would do is to look at the server response to the requests for a) a dynamically generated report, and b) the same report served from company/pdf_files/

If the content-length headers of the two responses differ, there's your problem.

I would use something like Wireshark, but there's probably a plugin for your browser which can be used to debug HTTP headers.

I doubt it has anything to do with size as such. If the file itself seems OK, then I'd suspect the problem to be related to how the server presents the file to the browser. It wouldn't open at all if the MIME type was wrong, but what if there was a mismatch between content-length and actual file size?

Do the offending files by any chance contain multi-byte UTF data? I can see how that could throw off a naive implementation expecting one character to equal one byte.

It's not as simple as just printing off a supplier invoice. These are customer invoices issued on behalf of the supplier. - FA would effectively have to create a customer invoice without affecting AR or stock levels and then processing it as a normal supplier invoice. And the created invoices would have to be numbered on a per-supplier basis, presumably with a different prefix for each supplier.

I'm not saying it can't done, but there would have to be changes to the database structure. And while most of the code required probably already exists, there's the matter of fitting this thing into the current workflow and menus. We can probably expect users to distinguish between customer and supplier invoices, but here's something which could be confused with both. Should it be enabled by default? If not, should the setting be per company, user or supplier? There's a lot that need to be thought through if we want such a feature.

Anyway, this kind of invoicing isn't an accounting issue at all, but rather an administrative shortcut. While you do need an invoice to match the payment, the accountant (or accounting system) doesn't really care who issued it.

For now, I suggest you create an invoice in your favourite word processor and let FA handle it as any supplier invoice.

Speaking of includes/ui/ui_input.inc, what's this supposed to do?

//JAM  Allow entered unit prices to be fractional
function unit_amount_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
{
    if (!isset($dec))
          $dec = user_price_dec()+2;
    amount_cells_ex($label, $name, 15, 15, $init, $params, $post_label, $dec+2);
}

If my guess is right, you should rather add it to the blacklist. That will screw up the AJAX stuff, but should confirm whether it is indeed Javascript which effectively disables the link.

Be careful, though. It seems bad things can happen if the AJAX calls fail.

Presumably it's a timeout issue. The full report simply takes too long to generate, and the script running it is killed off before it completes.

Look at this thread on Extending Time out and see if that helps.

I've seen something similar, where links (to other tabs, I believe) appeared dead. I found, however, that dragging them into the browser's address field triggered the page request.

My best guess is that the click gets intercepted by some Javascript event handler.

apmuthu wrote:

Ajax is necessary to fill in the UOM from the stock_master lookup table. If that does not work, then the insert would be as you get now.

Shouldn't errors like this be handled at the database level? I've always regarded MySQL as something of a Mickey Mouse database, but surely it supports foreign key constraints by now?

15

(3 replies, posted in Accounts Receivable)

Just issue a credit note for the missing 2000. The reported sales for this period will be reduced by that amount, which in turn will reduce the tax by 200.

I'm curious about what's actually stored in the database.

Try something like
SELECT description,units FROM 0_stock_master

If the two items have different values for "units", there is a bug where the items are added to the database. If not, there is a problem reading or parsing the data.

17

(6 replies, posted in Setup)

http://php.net/manual/en/info.configuration.php#ini.max-execution-time

18

(12 replies, posted in Setup)

Isn't this exactly what was described in post #3 of this thread?

Joe's reservations in #4 would certainly still apply.

Of course it's relative to the "includes" directory, because that's where session.inc resides. The function dirname(__FILE__) returns the path to the running script.

You can either use an absolute path:
ini_set('session.save_path', '/opt/FrontAccounting/tmp/');

or append the relative path to the current directory:
ini_set('session.save_path', dirname(__FILE__).'/../tmp/');

I recommend the latter, as it does not make any assumption about where FA is actually installed.

Go to Setup->System and General GL Setup and look for the "Bank Charges Account" setting. I would suspect it's set to your bank account, rather than the expense account you expect.

Line 401 seems to explicitly invert the values as they are being printed. Could that be the problem?

https://github.com/apmuthu/frontaccount … n.php#L401

$rep->AmountCol2($i, $i + 1, $sales[$i] * -1, $dec, 0, 4, 0, $fill, NULL, 1, true);

Blindly rewriting the input seems dangerous enough as it is. Your proposal means any sequence of digits followed by an underscore will be replaced, whereas it can currently only happen to the string "0_".

I suggest line 305 be removed. Or at the very least be changed to consider some context. To make it foolproof we would need a parser for SQL, but extending the matched strings to each of the "allowed commands" might be good enough. At least until someone starts storing SQL queries in the database...

I'm thinking something like
preg_replace("/CREATE TABLE \d+_/i", "CREATE TABLE ".$connection['tbpref'], $line);
preg_replace("/INSERT INTO \d+_/i", "INSERT INTO ".$connection['tbpref'], $line);
...

It might work, but it's not pretty.

Of course you could tweak the code to send the message with more attachments. The basic steps should be obvious to any programmer:

1. Find the code which attaches the invoice to the email message.
2. Look up the attachments in FA for the transaction in question.
3. Add these as email attachments in whatever way the invoice is added.


(Apmuthu's suggestion only works if your server is accessible from the internet, and I'm not sure it's any easier. It requires changes not only to FA itself, but also to the web server configuration. Errors in the latter could affect the entire server.)

24

(2 replies, posted in Accounts Receivable)

Short answer:
The attachments need to be opened separately and printed.

Longer answer:
Printing is typically done by preparing a document (HTML, PDF, Excel...) and sending it to the client, which in turn sends it to a local printer. If your server is on a local network (physically or logically, i.e. connected through some form of VPN tunnel) it would be trivial to add some code which could send the attachment from the server to a printer, but then... Attachments are not necessarily printable. They could be anything - binary files, sound recordings etc. Even something as seemingly "printable" as a word processor document is really only printable through the application which created it.

You could adapt the form, but then you would either have to change the database accordingly or have the backend concatenate the fields into the existing field (corresponding to the current textarea). Changing the database would require changes to the code wherever addresses are handled. (Perhaps one could do something with SQL views.)

I think apmuthu did some work where he used (abused?) a "notes" field to store what was essentially key-value data. Perhaps you could do something similar and tag the address data with things like postcode, city and country. But you'd still have to handle the tags whenever displaying (or printing) the address.

(This could possibly be developed into a general method of defining address formats, while keeping the complexity on the database side to a minimum.)

For now, I would do my best to avoid it. Is there another way you could deduce the country from existing data? VAT number? Phone number?