2,276

(3 replies, posted in Reporting)

Sales => Sales Types => Tax Incl. => Yes / No.

There are only 2 Dimensions possible in FA as of now. However, each Dimension can have multiple sibling heads. If Dimension 1 is Department, then there can be several Departments in it.

What versions of PHP did you check earlier?

Shall we code so that:

Test expected    -1    1    31-12-2016        1    31-01-2017    31-12-2016 - 30-01-2017.

The last sent will then become 31-01-2017 ?

@stefan: would you like to submit the function changes?

Do a Winmerge diff check on your FA install root and the Github master codebase and see if there are any other file differences.

You can also use online diff tools like:

https://www.diffnow.com/
https://www.diffchecker.com/
http://www.comparemyfiles.com/

The existing code does not use floatval.

Line 318 of includes/current_user.inc should be:

    $num = number_format($number, $dec, $dsep, $tsep);

Like I said, the locale specific (like comma) separators do not have any say in the current exchange rate extraction.

The report can be rep310.php with appropriate inclusions in the report request forms. Whitespace synch has been done with respect to rep306.php (since it is based upon it) in FA 2.4.3+ as on date.

Screenshots and files for inclusion into the core attached.

@stefan: please verify if it works well at your end and whether it needs some fixes / enhancements.
@joe: see if can be included if it serves some useful purpose.

2,284

(9 replies, posted in Setup)

This must a a user preference and not a site-wide or company-wide setting.
This will entail a flag in the user table but settable by the sysadmin and not the user themselves as that could be leveraged for security violations like brute forcing.

I can confirm that the new way to compute the Google rate does not need to depend on any locale specific inputs and hence the latest commit in the gl_db_rates.inc will take care of it.

Clear your browser cache and company js_cache and login afresh in a sole instance of a new browser and see what gives. I have tested it extensively in PHP 5.3.1 on Windows and PHP 5.3.3 on Debian Squeeze. I will be building a fresh OpenVZ template for it on Debian Squeeze and will test on that as well.

YAHOO Exchange rate is broken due to upstreamn blockage. They rely on OFX, a Yahoo Widget.

Those who wish to see a backport if they are still using FA 2.3.x, let me know. There may be some die hard fans of FA 2.3.x - if it ain't broke why fix it - who may need extended support - they can contact the FA support facilitators.

@joe: Thanks for the Bloomberg commit.

The incremental patch file for the Google fix is attached herewith.

Both Google and Bloomberg Exchange rates work with the new fix attached herewith.

No need to bother with the number_format statement. The Bloomberg fix uses another part of the page which does not have any locale formatting. I have changed it a bit and re-uploaded it. If you were the first to download it then download it again.

PHP Simple XML Parsing

It appears that both php-curl and the FA function url_get_contents() fail for BLOOMBERG exchange rate provider now that they insist on https:// and also have a second colon in the url, the parsing of the url causes some problems.

The attached fix also overcomes the locale based thousands separator in the rate, mitigated by acquiring another string from the file that has no separators.

YAHOO has blocked all access to FA's means of exchange rate acquisition.
Checkout:
http://download.finance.yahoo.com/d/quotes.csv?s=USDIDR=X&f=sl1d1t1ba&e=.csv
The widget js that does the job is at:
https://widget-yahoo.ofx.com/resources/1500309750700/js/app.js
The new page to look at is:
https://widget-yahoo.ofx.com/
and this sports the separator with locale as well.

ECB is still available with no separators:
http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml

Google is also still available with no separators:
http://finance.google.com/finance/converter?a=1&from=OMR&to=IDR

Bloomberg is available for select currency sets with a separator:
https://www.bloomberg.com/quote/USDIDR:CUR

Try this now:

function calculate_next($myrow)
{
    if ($myrow["last_sent"] == '0000-00-00')
        $next = sql2date($myrow["begin"]);
    else
        $next = sql2date($myrow["last_sent"]);
    if ($myrow['days'] == -1 && $myrow['monthly'] > 0) {
        // ignore months when days = -1
            $next = begin_month($next); // to later become last day of previous month
            $myrow['days']=0;
    }
    $next = add_months($next, $myrow['monthly']);
    $next = add_days($next, $myrow['days']);
    return add_days($next,-1);
}

Also we need to check if locale specific separators will have their say as well.

2,293

(1 replies, posted in Accounts Receivable)

Whilst a Supplier's Reference is mandatory for all Purchase Forms (Payment Terms absent), the Customer Reference is available as an option for input in all Sales Forms (Sales Quotation, Order, Delivery and Invoice) where the Payment Terms (mandatory) is "Non Cash".

See attached screenshot.

More info in the Wiki.

From the wiki:

A days value of -1 together with a month value would be the last day in the previous month.

Hence we need a month value as well to get the period.

The function that can now be tried is:

function calculate_next($myrow)
{
    if ($myrow["last_sent"] == '0000-00-00')
        $next = sql2date($myrow["begin"]);
    else
        $next = sql2date($myrow["last_sent"]);
    if ($myrow['days'] == -1 && $myrow['monthly'] > 0) {
        // ignore months when days = -1
        $next = add_days(begin_month($next), -1); // last day of previous month
        $myrow['days']=0;
    }
    $next = add_months($next, $myrow['monthly']);
    $next = add_days($next, $myrow['days']);
    return add_days($next,-1);
}

Try to replace line 318 of /includes/current_user.inc:

    $num = number_format($number, $dec, $dsep, $tsep);

with

    $num = number_format(floatval(trim($number)), $dec, $dsep, $tsep);

PHP's loose typing has been trampled upon in later versions like 7.0+ and hence type casting may be needed.
This may happen when some whitespace creeps into $number.

For 30 days it appears okay so we do not need to change that portion.

For -1, the invoice needs to be raised on the last day of the month for the period from the last day of the previous month to the day before the last day of the current month.

The new function replacement should be:

function calculate_next($myrow)
{
    if ($myrow["last_sent"] == '0000-00-00')
        $next = sql2date($myrow["begin"]);
    else
        $next = sql2date($myrow["last_sent"]);
    if ($myrow['days'] == -1) {
        // ignore months when days = -1
            $next = add_days($next, 2); // <-- changed line
            $next = end_month($next);
            return $next;
    } else {
        $next = add_months($next, $myrow['monthly']);
        $next = add_days($next, $myrow['days']);
        return add_days($next,-1);
    }
}

These incremental changes are to assist those who installed from a release. Just overwrite the corresponding files harmlessly with these files and you have "upgraded".

The CHANGELOG.txt file in it will provide all the necessary info on what has changed.

If you download from my repo, you will get the list of changes separately that have not been accepted yet by the devs. The files in the FA24Mods folder can be used to overwrite their counterparts in the core before install.

@poncho1234: hope you are using the FA 2.4.3+ bleeding edge code and not just the release.

If we put in 1 month, then it will be a calendar month. If we put in 30 days, it will be just so using the add_month() function.

The -1 functionality works okay for the first invoice and is 1 day earlier for the rest.

Try to change the 3rd line above:

$next = add_days($next, 1);

to:

$next = add_days($next, 2);

and provide feedback for the "-1" cases.

Month is a calendar month and not 30 days.

Months and days can be used together like 1 month and 7 days.

The functions "add_months" and "add_days" are defined in includes/date_functions.inc.
The functions "days_in_month" and "end_month" are also defined therein.

We can use the native PHP function cal_days_in_month(CAL_GREGORIAN,10,2005); to get the days in a month / end of month. This function has been available since PHP 4.1+. The "-1" can be implemented using these functions.

Lines 79-81 of the function calculate_next():

    $next = add_months($next, $myrow['monthly']);
    $next = add_days($next, $myrow['days']);
    return add_days($next,-1);

can be altered to make for the "-1" functionality of last day of the month as:

if ($myrow['days'] == -1) {
// ignore months when days = -1
    $next = add_days($next, 1);
    $next = end_month($next);
    return $next;
} else {
    $next = add_months($next, $myrow['monthly']);
    $next = add_days($next, $myrow['days']);
    return add_days($next,-1);
}

Please test and provide feedback for inclusion into the core.