Reputation: 5
$invoiceTotal = $settings['Setting']['currency'] . $thisInvoice['Invoice']['invoice_total'];
$bedrag = $settings['Setting']['currency'] . number_format($thisInvoice['Payment']['0']['amount'], 2, '.', ',');
$openbedrag = $invoiceTotal - $bedrag;
//$invoiceTotal = 2
//$bedrag = 1
Why is $openbedrag = $invoiceTotal - $bedrag;
not working ?
It is a simple calculation, why it doesn't calculate this variables ?
It outputs 0 -_-'
UPDATE PROBLEM FIXED
$invoiceTotal = $settings['Setting']['currency'].$thisInvoice['Invoice']['invoice_total'];
$bedrag = $settings['Setting']['currency'].number_format($thisInvoice['Payment']['0']['amount'], 2, '.', ',');
$openbedrag2 = $thisInvoice['Invoice']['invoice_total'] - $thisInvoice['Payment']['0']['amount'];
$openbedrag = $settings['Setting']['currency'].$openbedrag2;
Currency sets €
Upvotes: 0
Views: 65
Reputation: 2540
if $settings['Setting']['currency'] this containing symbol , then avoid using $settings['Setting']['currency'] in Your calculation time. so Your calculation would be like below:-
$invoiceTotal = $thisInvoice['Invoice']['invoice_total'];
$bedrag = $thisInvoice['Payment']['0']['amount'];
$openbedrag = $invoiceTotal - $bedrag;
$openbedrag = $settings['Setting']['currency'].number_format($openbedrag, 2, '.', ',');
NOTE:- also don't use number_format in Your calculation time. use it ate display time means after the calculation in final output.
Upvotes: 0
Reputation: 780889
You need to do arithmetic with the original numbers, not the formatted ones.
$openbedrag = $thisInvoice['Invoice']['invoice_total'] - $thisInvoice['Payment']['0']['amount'];
Upvotes: 1
Reputation: 2103
convert into integers:-
$openbedrag = ($invoiceTotal * 1.0) - ($bedrag * 1.0);
Upvotes: 0