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,255

(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.

Logo can now be disabled in the company setup page.

2,264

(24 replies, posted in Modules Add-on's)

Windows / DOS line endings are chr(13).chr(10) or "\r\n" whilst Unix line endings are just chr(10) or "\n". In frontaccounting, we can run the following on Unix to convert them wholesale (assuming the webroot to be /var/www/frontac):

cd /var/www/frontac
find ./ -type f \
        -name "*.php" \
     -o -name "*.css" \
     -o -name "*.js" \
     -o -name "*.txt" \
     -o -name "*.inc" \
     -o -name "*.sql" \
    | xargs dos2unix

The default value of the precision parameter in php.ini on a 32 bit system is 14 even when absent. In some installs it comes preset at 17. All float values that are a result of a fraction that has recurring decimals ad infinitum will generally truncate off at ini_get('precision')-3 decimals, to make up for a:
1. sign,
2. single integer to the left of the decimal point and
3. the decimal point itself.

Hence the line 356 of includes/current_user.inc:

        if ($len > $dec)

should be:

        if ($len > $dec && $len < ini_get('precision')-3)

@joe: can commit both fixes (decimals and report sql)

The sql in the function getAverageCost() defined in the file reporting/rep301.php (Inventory Valuation Report) is like:

SELECT move.*, IF(ISNULL(supplier.supplier_id), debtor.debtor_no, supplier.supplier_id) person_id
FROM 1_stock_moves move
     LEFT JOIN 1_supp_trans credit ON credit.trans_no=move.trans_no AND credit.type=move.type
     LEFT JOIN 1_grn_batch grn ON grn.id=move.trans_no AND 25=move.type
     LEFT JOIN 1_suppliers supplier ON IFNULL(grn.supplier_id, credit.supplier_id)=supplier.supplier_id
     LEFT JOIN 1_debtor_trans cust_trans ON cust_trans.trans_no=move.trans_no AND cust_trans.type=move.type
     LEFT JOIN 1_debtors_master debtor ON cust_trans.debtor_no=debtor.debtor_no
WHERE stock_id=102
  AND move.tran_date < '2017-11-27' 
  AND standard_cost > 0.001 
  AND qty <> 0 
  AND move.type <> 16 -- ST_LOCTRANSFER
ORDER BY tran_date;

This means that when the purchase invoice is made on 2017-11-27, the sql above computes the average cost to just before the said date and not including it. If a subsequent date is used for the query, then all is well (save for the irrational value at times not obeying the decimal limit).

@joe: must we correct line 65 in it:

            AND move.tran_date < '$to_date' AND standard_cost > 0.001 AND qty <> 0 AND move.type <> ".ST_LOCTRANSFER;

to be

            AND move.tran_date <= '$to_date' AND standard_cost > 0.001 AND qty <> 0 AND move.type <> ".ST_LOCTRANSFER;

so that it takes into consideration all transaction up until the end of the day and not to just before the date?

The decimals issue can be corrected by appropriately formatting the return value at the end of the said function or where it it used in line 211 in the report although line 229 uses it without assignment when $details is present. The culprit is line 357 in includes/current_user.inc for irrational numbers with large number of decimal places when the value of $dec becomes 14. It is best hard coded to 2.

2,267

(1 replies, posted in Wish List)

@joe: An inactive flag?

2,268

(24 replies, posted in Modules Add-on's)

Added Kanban to the list of extensions in my FA24extensions repo.

@notrinos: replace CRLF with LF (Unix line endings) in the 2 jquery files in your js folder and you may want to update your README.md to this one.

@itronics: can add it to the official pkg repo.

2,269

(4 replies, posted in FA Modifications)

Listed in the Pending Issues post.

In the meanwhile, export a quote and import it as a new one after modifying it or after importing it.

Stands corrected:
Line 146 in reporting/rep107.php:

               $result = get_customer_trans_details(ST_SALESINVOICE, $row['trans_no']);

gets the line items from the function (defined in sales/includes/db/cust_trans_details_db.inc) used above like:

SELECT line.*,
       line.unit_price+line.unit_tax AS FullUnitPrice,
       line.description AS StockDescription,
       item.units, item.mb_flag
FROM 1_debtor_trans_details line,1_stock_master item
WHERE (
       (debtor_trans_no=1) -- 1st Transaction in Demo Co
       AND debtor_trans_type=10 -- ST_SALESINVOICE
       AND item.stock_id=line.stock_id
)
ORDER BY id

This result having the invoice's line items are cycled through from lines 148 to 181 in reporting/rep107.php.

Lines 344 onwards in reporting/rep107.php cycle through the line items which is what you need to put into some javascripted set of tabs.

The image links can have a title attribute for their "a" tag.

It works okay in 2.4.3+.
The last significant changes to the file sales/create_recurrent_invoices.php that introduced the functions "calculate_from" and "calculate_next" were done between Apr and July 2015 and they compute correctly as per the wiki.

Attached are the screenshots of the Recurrent Sales Invoice Request Form, it's execution and the resultant Invoice generated.

Where in it do you face a problem?

2,274

(19 replies, posted in Accounts Payable)

@joe, @itronics: any updates?

2,275

(2 replies, posted in Installation)

@joe: Thanks. Commit Link.