diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php
index 4eda43dcca5..e439cfadc31 100644
--- a/htdocs/adherents/list.php
+++ b/htdocs/adherents/list.php
@@ -96,6 +96,7 @@ $fieldstosearchall = array(
'd.note_public'=>'NotePublic',
'd.note_private'=>'NotePrivate',
);
+if($db->type == 'pgsql') unset($fieldstosearchall['d.rowid']);
$arrayfields=array(
'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),
diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php
index b03872a8fbd..9ae20ac06d7 100644
--- a/htdocs/admin/multicurrency.php
+++ b/htdocs/admin/multicurrency.php
@@ -61,7 +61,7 @@ if (preg_match('/set_(.*)/',$action,$reg))
dol_print_error($db);
}
}
-
+
if (preg_match('/del_(.*)/',$action,$reg))
{
$code=$reg[1];
@@ -79,7 +79,7 @@ if (preg_match('/del_(.*)/',$action,$reg))
if ($action == 'add_currency')
{
$langs->loadCacheCurrencies('');
-
+
$code = GETPOST('code', 'alpha');
$rate = GETPOST('rate', 'alpha');
$currency = new MultiCurrency($db);
@@ -96,23 +96,23 @@ if ($action == 'add_currency')
elseif ($action == 'update_currency')
{
$submit = GETPOST('submit', 'alpha');
-
+
if ($submit == $langs->trans('Modify'))
{
$fk_multicurrency = GETPOST('fk_multicurrency', 'int');
- $rate = GETPOST('rate', 'float');
+ $rate = price2num(GETPOST('rate', 'alpha'));
$currency = new MultiCurrency($db);
-
+
if ($currency->fetch($fk_multicurrency) > 0)
{
$currency->updateRate($rate);
- }
+ }
}
elseif ($submit == $langs->trans('Delete'))
{
$fk_multicurrency = GETPOST('fk_multicurrency', 'int');
$currency = new MultiCurrency($db);
-
+
if ($currency->fetch($fk_multicurrency) > 0)
{
if ($currency->delete() > 0) setEventMessages($langs->trans('RecordDeleted'), array());
@@ -120,14 +120,14 @@ elseif ($action == 'update_currency')
}
}
}
-elseif ($action == 'synchronize')
+elseif ($action == 'synchronize')
{
$response = GETPOST('response');
$response = json_decode($response);
-
+
if ($response->success)
{
- MultiCurrency::syncRates($response);
+ MultiCurrency::syncRates($response);
}
else
{
@@ -226,7 +226,7 @@ print '';
print '';
*/
-/* TODO uncomment when the functionality will integrated
+/* TODO uncomment when the functionality will integrated
$var=!$var;
print '
';
print '| '.$langs->transnoentitiesnoconv("multicurrency_modifyRateApplication").' | ';
@@ -259,8 +259,8 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
print $langs->trans("Value").' ';
print '';
print '
';
-
-
+
+
$var=!$var;
print '';
print '| '.$langs->transnoentitiesnoconv("multicurrency_appId").' | ';
@@ -273,7 +273,7 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
print '';
print '';
print '
';
-
+
$var=!$var;
print '';
print '| '.$langs->transnoentitiesnoconv("multicurrency_appCurrencySource").' | ';
@@ -286,7 +286,7 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
print '';
print '';
print '
';
-
+
$var=!$var;
print '';
print '| '.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").' | ';
@@ -299,7 +299,7 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
print '';
print '';
print '
';
-
+
print '';
print '
';
}
@@ -334,7 +334,7 @@ print '';
foreach ($TCurrency as &$currency)
{
if($currency->code == $conf->currency) continue;
-
+
$var=!$var;
print '';
print '| '.$currency->code.' - '.$currency->name.' | ';
@@ -363,7 +363,7 @@ print '
{
$("#bt_sync").attr("disabled", true);
var url_sync = "http://apilayer.net/api/live?access_key='.$conf->global->MULTICURRENCY_APP_ID.'&format=1'.(!empty($conf->global->MULTICURRENCY_APP_SOURCE) ? '&source='.$conf->global->MULTICURRENCY_APP_SOURCE : '').'";
-
+
$.ajax({
url: url_sync,
dataType: "jsonp"
diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php
index 453d1f75319..5307237919b 100644
--- a/htdocs/comm/mailing/class/advtargetemailing.class.php
+++ b/htdocs/comm/mailing/class/advtargetemailing.class.php
@@ -474,7 +474,7 @@ class AdvanceTargetingMailing extends CommonObject
$sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as saleman ON saleman.fk_soc=t.rowid ";
}
if (array_key_exists('cust_categ', $arrayquery)) {
- $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "categorie_societe as custcateg ON custcateg.fk_societe=t.rowid ";
+ $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "categorie_societe as custcateg ON custcateg.fk_soc=t.rowid ";
}
if (!empty($arrayquery['cust_name'])) {
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index c4bb0ace2f2..9de9ffed222 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -1513,7 +1513,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '';
} else {
print '';
- print $form->select_company('', 'socid', 's.client = 1 OR s.client = 3', 'SelectThirdParty');
+ print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 3)', 'SelectThirdParty');
// reload page to retrieve customer informations
if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE))
{
@@ -2541,7 +2541,7 @@ if ($action == 'create' && $user->rights->commande->creer)
if (! empty($conf->expedition->enabled)) {
$numshipping = $object->nb_expedition();
- if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfProductsLines() > 0) {
+ if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) {
if ($user->rights->expedition->creer) {
print '';
diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php
index cec3d648450..8491ca45b09 100644
--- a/htdocs/compta/bank/bankentries.php
+++ b/htdocs/compta/bank/bankentries.php
@@ -372,6 +372,8 @@ if (dol_strlen($search_dv_end) > 0) $param .= '&search_end_dvmonth=' . GETPOST
if ($search_req_nb) $param.='&req_nb='.urlencode($search_req_nb);
if (GETPOST("thirdparty")) $param.='&thirdparty='.urlencode(GETPOST("thirdparty"));
if ($optioncss != '') $param.='&optioncss='.$optioncss;
+if(!empty($search_conciliated) || $search_conciliated === 0) $param.='&search_conciliated='.$search_conciliated;
+
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 0047aa67b90..b6d610c65b6 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1149,7 +1149,9 @@ if (empty($reshook))
// Extrafields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) {
- $lines[$i]->fetch_optionals($lines[$i]->rowid);
+ $targetExtraFields = new ExtraFields($db);
+ $targetExtraFieldLabels = $targetExtraFields->fetch_name_optionals_label($object->table_element_line);
+ $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraFieldLabels);
$array_options = $lines[$i]->array_options;
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 6c73746d9af..60970b5b1e2 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -486,7 +486,8 @@ class Facture extends CommonInvoice
foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
{
$originforcontact = 'commande';
- $originidforcontact = $value->id;
+ if (is_object($value)) $originidforcontact = $value->id;
+ else $originidforcontact = $value;
break; // We take first one
}
}
diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php
index 130e378b33e..2f84f02111f 100644
--- a/htdocs/compta/facture/fiche-rec.php
+++ b/htdocs/compta/facture/fiche-rec.php
@@ -513,7 +513,7 @@ if (empty($reshook))
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
-
+
// if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ?
if (! empty($price_ht))
{
@@ -1055,7 +1055,7 @@ if ($action == 'create')
$disableedit=1;
$disablemove=1;
$disableremove=1;
- $ret = $object->printObjectLines('', $mysoc, $soc, $lineid, 0); // No date selector for template invoice
+ $ret = $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice
}
print "\n";
@@ -1470,7 +1470,7 @@ else
{
//$disableedit=1;
//$disablemove=1;
- $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 0); // No date selector for template invoice
+ $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice
}
// Form to add new line
@@ -1481,7 +1481,7 @@ else
$var = true;
// Add free products/services
- $object->formAddObjectLine(0, $mysoc, $soc); // No date selector for template invoice
+ $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice
$parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php
index 5c5aa8489be..4d9fdebeb64 100644
--- a/htdocs/compta/facture/stats/index.php
+++ b/htdocs/compta/facture/stats/index.php
@@ -232,7 +232,7 @@ $tmp_companies = $form->select_thirdparty_list($socid,'socid',$filter,1, 0, 0, a
$companies = array();
foreach ($tmp_companies as $value) {
- $companies[$value['value']] = $value['label'];
+ $companies[$value['key']] = $value['label'];
}
print '';
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 16450fd9feb..ab7afea77a4 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -2239,6 +2239,8 @@ abstract class CommonObject
$error=0;
+ $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1;
+
// Define constants to find lines to sum
$fieldtva='total_tva';
$fieldlocaltax1='total_localtax1';
@@ -2291,7 +2293,6 @@ abstract class CommonObject
$obj = $this->db->fetch_object($resql);
// Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none'
- $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1;
if ($forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto'
{
$localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx);
@@ -2309,11 +2310,14 @@ abstract class CommonObject
}
}
- $this->total_ht += $obj->total_ht; // The only field visible at end of line detail
+ $this->total_ht += $obj->total_ht; // The field visible at end of line detail
$this->total_tva += $obj->total_tva;
$this->total_localtax1 += $obj->total_localtax1;
$this->total_localtax2 += $obj->total_localtax2;
$this->total_ttc += $obj->total_ttc;
+ $this->multicurrency_total_ht += $obj->multicurrency_total_ht; // The field visible at end of line detail
+ $this->multicurrency_total_tva += $obj->multicurrency_total_tva;
+ $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc;
if (! isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate]=0;
if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0;
@@ -2322,7 +2326,7 @@ abstract class CommonObject
$total_tva_by_vats[$obj->vatrate] += $obj->total_tva;
$total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc;
- if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat
+ if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency
{
$tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1);
$diff=price2num($total_tva_by_vats[$obj->vatrate]-$tmpvat, 'MT', 1);
@@ -2346,26 +2350,25 @@ abstract class CommonObject
}
// Add revenue stamp to total
- $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0;
+ $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0;
+ $this->multicurrency_total_ttc += isset($this->revenuestamp)?($this->revenuestamp * $multicurrency_tx):0;
// Situations totals
- if ($this->situation_cycle_ref && $this->situation_counter > 1) {
+ if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits')) {
$prev_sits = $this->get_prev_sits();
- foreach ($prev_sits as $sit) {
+ foreach ($prev_sits as $sit) { // $sit is an object Facture loaded with a fetch.
$this->total_ht -= $sit->total_ht;
$this->total_tva -= $sit->total_tva;
$this->total_localtax1 -= $sit->total_localtax1;
$this->total_localtax2 -= $sit->total_localtax2;
$this->total_ttc -= $sit->total_ttc;
+ $this->multicurrency_total_ht -= $sit->multicurrency_total_ht;
+ $this->multicurrency_total_tva -= $sit->multicurrency_total_tva;
+ $this->multicurrency_total_ttc -= $sit->multicurrency_total_ttc;
}
}
- // Multicurrency
- $this->multicurrency_total_ht += $this->total_ht * $multicurrency_tx;
- $this->multicurrency_total_tva += $this->total_tva * $multicurrency_tx;
- $this->multicurrency_total_ttc += $this->total_ttc * $multicurrency_tx;
-
$this->db->free($resql);
// Now update global field total_ht, total_ttc and tva
@@ -2379,7 +2382,7 @@ abstract class CommonObject
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva';
if ($this->element == 'propal') $fieldttc='total';
if ($this->element == 'expensereport') $fieldtva='total_tva';
- if ($this->element == 'supplier_proposal') $fieldttc='total';
+ if ($this->element == 'supplier_proposal') $fieldttc='total';
if (empty($nodatabaseupdate))
{
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 57e4f612840..2c89bb6598b 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5809,29 +5809,39 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
$i3 = 0;
foreach($tmpcrits as $tmpcrit)
{
- $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '') . $field . " LIKE '";
+ $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
+
+ if (preg_match('/\.(id|rowid)$/', $field)) // Special cas for rowid that is sometimes a ref so used as a search field
+ {
+ $newres .= $field . " = " . (is_numeric(trim($tmpcrit))?trim($tmpcrit):'0');
+ }
+ else
+ {
+ $newres .= $field . " LIKE '";
+
+ $tmpcrit=trim($tmpcrit);
+ $tmpcrit2=$tmpcrit;
+ $tmpbefore='%'; $tmpafter='%';
+ if (preg_match('/^[\^\$]/', $tmpcrit))
+ {
+ $tmpbefore='';
+ $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
+ }
+ if (preg_match('/[\^\$]$/', $tmpcrit))
+ {
+ $tmpafter='';
+ $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
+ }
+ $newres .= $tmpbefore;
+ $newres .= $db->escape($tmpcrit2);
+ $newres .= $tmpafter;
+ $newres .= "'";
+ if (empty($tmpcrit2))
+ {
+ $newres .= ' OR ' . $field . " IS NULL";
+ }
+ }
- $tmpcrit=trim($tmpcrit);
- $tmpcrit2=$tmpcrit;
- $tmpbefore='%'; $tmpafter='%';
- if (preg_match('/^[\^\$]/', $tmpcrit))
- {
- $tmpbefore='';
- $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
- }
- if (preg_match('/[\^\$]$/', $tmpcrit))
- {
- $tmpafter='';
- $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
- }
- $newres .= $tmpbefore;
- $newres .= $db->escape($tmpcrit2);
- $newres .= $tmpafter;
- $newres .= "'";
- if (empty($tmpcrit2))
- {
- $newres .= ' OR ' . $field . " IS NULL";
- }
$i3++;
}
$i2++; // a criteria was added to string
diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php
index 6b868663aa7..ac2372c5825 100644
--- a/htdocs/core/lib/json.lib.php
+++ b/htdocs/core/lib/json.lib.php
@@ -42,19 +42,21 @@ if (! function_exists('json_encode'))
*
* @param mixed $elements PHP Object to json encode
* @return string Json encoded string
- * @deprecated PHP >= 5.3 supports native json_encode
* @see json_encode()
*/
function dol_json_encode($elements)
{
- dol_syslog('dol_json_encode() is deprecated. Please update your code to use native json_encode().', LOG_WARNING);
+ dol_syslog("For better permorfance, enable the native json in your PHP", LOG_WARNING);
- $num=count($elements);
+ $num=0;
if (is_object($elements)) // Count number of properties for an object
{
- $num=0;
foreach($elements as $key => $value) $num++;
}
+ else
+ {
+ $num=count($elements);
+ }
//var_dump($num);
// determine type
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 1b79cc9163d..89c4ceaa137 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -1753,6 +1753,8 @@ function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0)
*/
function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = null)
{
+ if (empty($hookmanager)) global $hookmanager;
+
$reshook=0;
$result='';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php
index 2fe652f6ac9..0cb1f755450 100644
--- a/htdocs/core/lib/price.lib.php
+++ b/htdocs/core/lib/price.lib.php
@@ -50,8 +50,8 @@
* @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).
* @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default)
* @param double $multicurrency_tx Currency rate (1 by default)
- * @param double $pu_ht_devise Amount in currency
- * @return array [
+ * @param double $pu_devise Amount in currency
+ * @return array [
* 0=total_ht,
* 1=total_vat, (main vat only)
* 2=total_ttc, (total_ht + main vat + local taxes)
@@ -65,15 +65,16 @@
* 10=total_tax2 for total_ht,
* 11=pu_tax1 for pu_ht, !! should not be used
* 12=pu_tax2 for pu_ht, !! should not be used
- * 13=!! should not be used
+ * 13=?? !! should not be used
* 14=total_tax1 for total_ht_without_discount,
- * 15=total_tax2 for total_ht_without_discount]
+ * 15=total_tax2 for total_ht_without_discount,
+ *
* 16=multicurrency_total_ht
* 17=multicurrency_total_tva
* 18=multicurrency_total_ttc
* 19=multicurrency_pu_ht
*/
-function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_ht_devise=0)
+function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_devise=0)
{
global $conf,$mysoc,$db;
@@ -101,10 +102,10 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
//dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress);
$countryid=$seller->country_id;
-
+
if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate=(float) $uselocaltax1_rate;
if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate=(float) $uselocaltax2_rate;
-
+
if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj;
if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj;
@@ -143,14 +144,15 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
}
else dol_print_error($db);
}
-
+
// pu calculation from pu_devise if pu empty
- if(empty($pu) && !empty($pu_ht_devise)) {
- $pu = $pu_ht_devise / $multicurrency_tx;
- } else {
- $pu_ht_devise = $pu * $multicurrency_tx;
+ if(empty($pu) && !empty($pu_devise)) {
+ $pu = $pu_devise / $multicurrency_tx;
}
-
+ if(empty($pu_devise) && !empty($multicurrency_tx)) {
+ $pu_devise = $pu * $multicurrency_tx;
+ }
+
// initialize total (may be HT or TTC depending on price_base_type)
$tot_sans_remise = $pu * $qty * $progress / 100;
$tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100));
@@ -338,13 +340,47 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
}
}
-
+
// Multicurrency
- $result[16] = price2num($result[0] * $multicurrency_tx, 'MT');
- $result[17] = price2num($result[1] * $multicurrency_tx, 'MT');
- $result[18] = price2num($result[2] * $multicurrency_tx, 'MT');
- $result[19] = price2num($pu_ht_devise, 'MU');
-
+ if ($multicurrency_tx != 1)
+ {
+ // Recal function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop.
+ $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0);
+
+ $result[16] = $newresult[0];
+ $result[17] = $newresult[1];
+ $result[18] = $newresult[2];
+ $result[19] = $newresult[3];
+ $result[20] = $newresult[4];
+ $result[21] = $newresult[5];
+ $result[22] = $newresult[6];
+ $result[23] = $newresult[7];
+ $result[24] = $newresult[8];
+ $result[25] = $newresult[9];
+ $result[26] = $newresult[10];
+ /*
+ $result[16] = price2num($result[0] * $multicurrency_tx, 'MT');
+ $result[17] = price2num($result[1] * $multicurrency_tx, 'MT');
+ $result[18] = price2num($result[2] * $multicurrency_tx, 'MT');
+ $result[19] = price2num($pu_devise, 'MU');
+ */
+ }
+ else
+ {
+ $result[16] = $result[0];
+ $result[17] = $result[1];
+ $result[18] = $result[2];
+ $result[19] = $result[3];
+ $result[20] = $result[4];
+ $result[21] = $result[5];
+ $result[22] = $result[6];
+ $result[23] = $result[7];
+ $result[24] = $result[8];
+ $result[25] = $result[9];
+ $result[26] = $result[10];
+ }
+
+ //var_dump($result);
// initialize result array
//for ($i=0; $i <= 18; $i++) $result[$i] = (float) $result[$i];
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index 54c1f546903..e8dee5b8068 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -216,11 +216,11 @@ class pdf_einstein extends ModelePDFCommandes
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$pdf->SetAutoPageBreak(1,0);
-
+
$heightforinfotot = 40; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-
+
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
@@ -293,16 +293,16 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
-
+
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
-
+
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
-
+
// Affiche notes
$notetoshow=empty($object->note_public)?'':$object->note_public;
if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
@@ -454,7 +454,7 @@ class pdf_einstein extends ModelePDFCommandes
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
else $tvaligne=$object->lines[$i]->total_tva;
-
+
$localtax1ligne=$object->lines[$i]->total_localtax1;
$localtax2ligne=$object->lines[$i]->total_localtax2;
$localtax1_rate=$object->lines[$i]->localtax1_tx;
@@ -561,7 +561,7 @@ class pdf_einstein extends ModelePDFCommandes
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
}
*/
-
+
// Pied de page
$this->_pagefoot($pdf,$object,$outputlangs);
if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
@@ -838,6 +838,8 @@ class pdf_einstein extends ModelePDFCommandes
// Show VAT by rates and total
$pdf->SetFillColor(248,248,248);
+ $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
+
$this->atleastoneratenotnull=0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
@@ -1011,7 +1013,6 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetFillColor(224,224,224);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
- $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
}
@@ -1024,7 +1025,7 @@ class pdf_einstein extends ModelePDFCommandes
//$creditnoteamount=$object->getSumCreditNotesUsed();
//$depositsamount=$object->getSumDepositsUsed();
//print "x".$creditnoteamount."-".$depositsamount;exit;
- $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
+ $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if (! empty($object->paye)) $resteapayer=0;
if ($deja_regle > 0)
@@ -1270,7 +1271,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
}
}
-
+
$posy+=2;
// Show list of linked objects
diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
index d1697b767bd..62862e06e11 100644
--- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
@@ -84,7 +84,7 @@ class pdf_rouget extends ModelePdfExpedition
}
$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
-
+
if ($this->page_largeur < 210) // To work with US executive format
{
$this->posxweightvol-=20;
@@ -92,7 +92,7 @@ class pdf_rouget extends ModelePdfExpedition
$this->posxqtyordered-=20;
$this->posxqtytoship-=20;
}
-
+
if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{
$this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
@@ -139,17 +139,17 @@ class pdf_rouget extends ModelePdfExpedition
if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
{
$objphoto = new Product($this->db);
-
+
for ($i = 0 ; $i < $nblignes ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
-
+
$objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product);
-
+
$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
$dir = $conf->product->dir_output.'/'.$pdir;
-
+
$realpath='';
foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
@@ -169,17 +169,17 @@ class pdf_rouget extends ModelePdfExpedition
{
$filename=$obj['photo'];
}
-
+
$realpath = $dir.$filename;
break;
}
-
+
if ($realpath) $realpatharray[$i]=$realpath;
}
}
-
- if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
-
+
+ if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
+
if ($conf->expedition->dir_output)
{
// Definition de $dir et $file
@@ -219,7 +219,7 @@ class pdf_rouget extends ModelePdfExpedition
// Set nblignes with the new facture lines content after hook
$nblignes = count($object->lines);
-
+
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
$heightforinfotot = 8; // Height reserved to output the info and total part
@@ -282,11 +282,11 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
-
+
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
-
+
$tab_top = $nexY+6;
$height_incoterms += 4;
}
@@ -343,7 +343,7 @@ class pdf_rouget extends ModelePdfExpedition
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
-
+
$tab_height = $tab_height - $height_note;
$tab_top = $nexY+6;
}
@@ -400,7 +400,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->startTransaction();
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
-
+
$pageposafter=$pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
@@ -434,10 +434,10 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->commitTransaction();
}
$posYAfterDescription=$pdf->GetY();
-
+
$nexY = $pdf->GetY();
$pageposafter=$pdf->getPage();
-
+
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
@@ -456,29 +456,29 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetXY($this->posxweightvol, $curY);
$weighttxt='';
- if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
+ if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
{
$weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight");
}
$voltxt='';
- if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
+ if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
{
$voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume");
}
-
+
$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?' ':'').$voltxt, 0, 0, false, true, 'C');
//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?' ':'').$voltxt,'','C');
-
+
if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{
$pdf->SetXY($this->posxqtyordered, $curY);
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C');
}
-
+
$pdf->SetXY($this->posxqtytoship, $curY);
$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C');
- if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT))
+ if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT))
{
$pdf->SetXY($this->posxpuht, $curY);
$pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R');
@@ -489,7 +489,7 @@ class pdf_rouget extends ModelePdfExpedition
$nexY+=3;
if ($weighttxt && $voltxt) $nexY+=2;
-
+
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
{
@@ -548,7 +548,7 @@ class pdf_rouget extends ModelePdfExpedition
}
// Affiche zone totaux
- $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+ $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
// Pied de page
$this->_pagefoot($pdf,$object,$outputlangs);
@@ -612,7 +612,7 @@ class pdf_rouget extends ModelePdfExpedition
}*/
if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
-
+
$useborder=0;
$index = 0;
@@ -626,12 +626,12 @@ class pdf_rouget extends ModelePdfExpedition
$totalOrdered=$tmparray['ordered'];
$totalToShip=$tmparray['toship'];
// Set trueVolume and volume_units not currently stored into database
- if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
+ if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
{
$object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
$object->volume_units=$object->size_units * 3;
}
-
+
if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
@@ -640,48 +640,48 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
-
+
if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{
$pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
}
-
+
$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
-
+
if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
-
+
$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
}
-
+
// Total Weight
if ($totalWeighttoshow)
{
$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
-
+
$index++;
}
if ($totalVolumetoshow)
{
$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
-
+
$index++;
}
if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
-
+
$pdf->SetTextColor(0,0,0);
return ($tab2_top + ($tab2_hl * $index));
}
-
+
/**
* Show table for lines
*
@@ -728,7 +728,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetXY($this->posxweightvol-1, $tab_top+1);
$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C');
}
-
+
if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{
$pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
@@ -738,14 +738,14 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
}
}
-
+
$pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxqtytoship, $tab_top+1);
$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C');
}
-
+
if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
$pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height);
@@ -754,7 +754,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetXY($this->posxpuht-1, $tab_top+1);
$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C');
}
-
+
$pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height);
if (empty($hidetop))
{
@@ -763,7 +763,7 @@ class pdf_rouget extends ModelePdfExpedition
}
}
-
+
}
/**
@@ -780,7 +780,7 @@ class pdf_rouget extends ModelePdfExpedition
global $conf,$langs,$mysoc;
$langs->load("orders");
-
+
$default_font_size = pdf_getPDFFontSize($outputlangs);
pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
@@ -796,7 +796,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetFont('','B', $default_font_size + 3);
$w = 110;
-
+
$posy=$this->marge_haute;
$posx=$this->page_largeur-$this->marge_droite-$w;
@@ -863,7 +863,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetFont('','', $default_font_size + 1);
$posy+=5;
-
+
$pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R');
@@ -876,7 +876,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R');
}
-
+
if (! empty($object->thirdparty->code_client))
{
$posy+=4;
@@ -904,7 +904,7 @@ class pdf_rouget extends ModelePdfExpedition
if ($result >= 0)
{
//$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
-
+
$pdf->SetFont('','', $default_font_size - 2);
$text=$linkedobject->ref;
if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
@@ -939,7 +939,7 @@ class pdf_rouget extends ModelePdfExpedition
$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
-
+
// Show sender frame
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 2);
@@ -950,7 +950,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
$pdf->SetTextColor(0,0,60);
$pdf->SetFillColor(255,255,255);
-
+
// Show sender name
$pdf->SetXY($posx+2,$posy+3);
$pdf->SetFont('','B',$default_font_size);
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 02d239105b0..be88b7d4114 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -214,9 +214,9 @@ class pdf_crabe extends ModelePDFFactures
{
$object->fetch_thirdparty();
- $deja_regle = $object->getSommePaiement();
- $amount_credit_notes_included = $object->getSumCreditNotesUsed();
- $amount_deposits_included = $object->getSumDepositsUsed();
+ $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
// Definition of $dir and $file
if ($object->specimen)
@@ -255,16 +255,16 @@ class pdf_crabe extends ModelePDFFactures
// Set nblignes with the new facture lines content after hook
$nblignes = count($object->lines);
$nbpayments = count($object->getListOfPayments());
-
+
// Create pdf instance
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$pdf->SetAutoPageBreak(1,0);
-
+
$heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-
+
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
@@ -509,7 +509,7 @@ class pdf_crabe extends ModelePDFFactures
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxqty, $curY);
// Enough for 6 chars
-
+
if ($this->situationinvoice)
{
$pdf->MultiCell($this->posxprogress-$this->posxqty-0.8, 4, $qty, 0, 'R');
@@ -769,9 +769,9 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFont('','', $default_font_size - 4);
-
+
// Loop on each deposits and credit notes included
- $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
+ $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,";
$sql.= " re.description, re.fk_facture_source,";
$sql.= " f.type, f.datef";
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f";
@@ -796,7 +796,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($tab3_posx, $tab3_top+$y);
$pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0);
$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
- $pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
$pdf->MultiCell(20, 3, $text, 0, 'L', 0);
$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
@@ -815,14 +815,14 @@ class pdf_crabe extends ModelePDFFactures
// Loop on each payment
// TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql
- $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount,";
+ $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
$sql.= " cp.code";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
//$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1";
$sql.= " ORDER BY p.datep";
-
+
$resql=$this->db->query($sql);
if ($resql)
{
@@ -835,7 +835,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($tab3_posx, $tab3_top+$y);
$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
- $pdf->MultiCell(20, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
@@ -1052,7 +1052,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + 0);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
-
+
$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + 0);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);
@@ -1060,6 +1060,8 @@ class pdf_crabe extends ModelePDFFactures
// Show VAT by rates and total
$pdf->SetFillColor(248,248,248);
+ $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
+
$this->atleastoneratenotnull=0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
@@ -1071,7 +1073,7 @@ class pdf_crabe extends ModelePDFFactures
else
{
// FIXME amount of vat not supported with multicurrency
-
+
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
@@ -1141,26 +1143,26 @@ class pdf_crabe extends ModelePDFFactures
}
//}
-
+
// VAT
// Situations totals migth be wrong on huge amounts
if ($object->situation_cycle_ref && $object->situation_counter > 1) {
-
+
$sum_pdf_tva = 0;
foreach($this->tva as $tvakey => $tvaval){
$sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object
}
-
+
if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one)
$coef_fix_tva = $object->total_tva / $sum_pdf_tva;
-
+
foreach($this->tva as $tvakey => $tvaval) {
$this->tva[$tvakey]=$tvaval * $coef_fix_tva;
}
}
-
+
}
-
+
foreach($this->tva as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
@@ -1270,7 +1272,6 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFillColor(224,224,224);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
- $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
}
@@ -1278,10 +1279,10 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,0);
- $creditnoteamount=$object->getSumCreditNotesUsed();
- $depositsamount=$object->getSumDepositsUsed();
+ $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
//print "x".$creditnoteamount."-".$depositsamount;exit;
- $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
+ $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if ($object->paye) $resteapayer=0;
if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0)
@@ -1416,7 +1417,7 @@ class pdf_crabe extends ModelePDFFactures
if (empty($hidetop))
{
$pdf->SetXY($this->posxqty-1, $tab_top+1);
-
+
if($this->situationinvoice)
{
$pdf->MultiCell($this->posxprogress-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
@@ -1430,14 +1431,14 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
}
-
+
if ($this->situationinvoice) {
$pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
-
+
if (empty($hidetop)) {
-
+
$pdf->SetXY($this->posxprogress, $tab_top+1);
-
+
if($conf->global->PRODUCT_USE_UNITS)
{
$pdf->MultiCell($this->posxunit-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C');
@@ -1450,9 +1451,9 @@ class pdf_crabe extends ModelePDFFactures
{
$pdf->MultiCell($this->postotalht-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C');
}
-
+
}
-
+
}
if($conf->global->PRODUCT_USE_UNITS) {
@@ -1617,7 +1618,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : " . dol_print_date($object->date_pointoftax,"day",false,$outputlangs), '', 'R');
}
-
+
if ($object->type != 2)
{
$posy+=3;
@@ -1648,7 +1649,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell($w, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
}
}
-
+
$posy+=1;
// Show list of linked objects
diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
index 83306b95adb..0ee7c37e622 100644
--- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
+++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
@@ -294,7 +294,7 @@ class pdf_soleil extends ModelePDFFicheinter
$pageposafter=$pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
- $pdf->writeHTMLCell(0, 0, $curX, $curY, $txt.' '.$desc, LR, 1, 0);
+ $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,$desc), 0, 1, 0);
$pageposafter=$pdf->getPage();
$posyafter=$pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php
index 017ffd1d121..39ebd275c67 100644
--- a/htdocs/core/modules/modFournisseur.class.php
+++ b/htdocs/core/modules/modFournisseur.class.php
@@ -272,12 +272,12 @@ class modFournisseur extends DolibarrModules
$this->rights[$r][5] = 'approve2';
}
-
+
// Menus
//-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager.
-
-
+
+
// Exports
//--------
$r=0;
@@ -435,7 +435,7 @@ class modFournisseur extends DolibarrModules
// End add extra fields object
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
- if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
+ if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
@@ -444,7 +444,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')';
- if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
+ if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
// Order
$r++;
diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php
index 504d48efea3..872c13f4090 100644
--- a/htdocs/core/modules/modProduct.class.php
+++ b/htdocs/core/modules/modProduct.class.php
@@ -155,14 +155,14 @@ class modProduct extends DolibarrModules
if ($mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR';
if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue'));
if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode'));
- if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.unitprice'=>'SuppliersPrices'));
+ if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.unitprice'=>'BuyingPrice','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin'));
if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.cost_price'=>'CostPrice'));
if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('group_concat(cat.label)'=>'Categories'));
if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote'));
$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date');
if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric'));
if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text'));
- if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric'));
+ if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric'));
if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text'));
if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array("group_concat(cat.label)"=>'Text'));
$this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",'p.label'=>"product",'p.description'=>"product",'p.url'=>"product",'p.accountancy_code_sell'=>'product','p.accountancy_code_buy'=>'product','p.note'=>"product",'p.length'=>"product",'p.surface'=>"product",'p.volume'=>"product",'p.weight'=>"product",'p.customcode'=>'product','p.price_base_type'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>"product",'p.tosell'=>"product",'p.tobuy'=>"product",'p.datec'=>"product",'p.tms'=>"product");
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index d2ecfb60d81..54f3a4e351e 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -273,7 +273,7 @@ class pdf_azur extends ModelePDFPropales
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$pdf->SetAutoPageBreak(1,0);
-
+
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
@@ -322,19 +322,19 @@ class pdf_azur extends ModelePDFPropales
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
-
+
$heightforinfotot = 40; // Height reserved to output the info and total part
$heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0;
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
-
+ //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
+
$this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
-
+
$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = 130;
@@ -383,7 +383,7 @@ class pdf_azur extends ModelePDFPropales
$notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs);
if ($tmpuser->email) $notetoshow.=', Mail: '.$tmpuser->email;
if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
- }
+ }
if ($notetoshow)
{
$tab_top = 88 + $height_incoterms;
@@ -552,14 +552,14 @@ class pdf_azur extends ModelePDFPropales
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
else $tvaligne=$object->lines[$i]->total_tva;
-
+
$localtax1ligne=$object->lines[$i]->total_localtax1;
$localtax2ligne=$object->lines[$i]->total_localtax2;
$localtax1_rate=$object->lines[$i]->localtax1_tx;
$localtax2_rate=$object->lines[$i]->localtax2_tx;
$localtax1_type=$object->lines[$i]->localtax1_type;
- $localtax2_type=$object->lines[$i]->localtax2_type;
-
+ $localtax2_type=$object->lines[$i]->localtax2_type;
+
if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
@@ -667,7 +667,7 @@ class pdf_azur extends ModelePDFPropales
{
$posy=$this->_signature_area($pdf, $object, $posy, $outputlangs);
}
-
+
// Pied de page
$this->_pagefoot($pdf,$object,$outputlangs);
if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
@@ -1010,6 +1010,8 @@ class pdf_azur extends ModelePDFPropales
// Show VAT by rates and total
$pdf->SetFillColor(248,248,248);
+ $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
+
$this->atleastoneratenotnull=0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
@@ -1186,7 +1188,6 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetFillColor(224,224,224);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
- $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
}
@@ -1479,7 +1480,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
}
}
-
+
$posy+=2;
// Show list of linked objects
diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
index 1e7e6f4bcad..2578509cf71 100644
--- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
+++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
@@ -717,6 +717,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$useborder=0;
+ // Total TTC
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0,0,60);
@@ -727,6 +728,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1);
+ $creditnoteamount=0;
+ $depositsamount=0;
+ //$creditnoteamount=$object->getSumCreditNotesUsed();
+ //$depositsamount=$object->getSumDepositsUsed();
+ //print "x".$creditnoteamount."-".$depositsamount;exit;
+ $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
+ if (! empty($object->paye)) $resteapayer=0;
+
if ($deja_regle > 0)
{
$index++;
@@ -743,7 +752,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetTextColor(0,0,0);
}
@@ -877,6 +886,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
*/
function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
{
+ global $conf;
+
+ $sign=1;
+ if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
+
$tab3_posx = 120;
$tab3_top = $posy + 8;
$tab3_width = 80;
@@ -910,8 +924,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetFont('','', $default_font_size - 4);
+ // Loop on each deposits and credit notes included
+ //
+
// Loop on each payment
- $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,";
+ $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
$sql.= " cp.code";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
@@ -929,7 +946,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetXY($tab3_posx, $tab3_top+$y);
$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
- $pdf->MultiCell(20, 3, price($row->amount), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0);
$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
index c882ed89800..2be42687f80 100644
--- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
+++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
@@ -840,7 +840,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
//$creditnoteamount=$object->getSumCreditNotesUsed();
//$depositsamount=$object->getSumDepositsUsed();
//print "x".$creditnoteamount."-".$depositsamount;exit;
- $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
+ $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if (! empty($object->paye)) $resteapayer=0;
if ($deja_regle > 0)
diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php
index 4ed3ecb7cef..213e4cc4d2b 100644
--- a/htdocs/fichinter/card.php
+++ b/htdocs/fichinter/card.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2002-2007 Rodolphe Quiedeville
* Copyright (C) 2004-2016 Laurent Destailleur
* Copyright (C) 2005-2015 Regis Houssin
- * Copyright (C) 2011-2013 Juanjo Menent
+ * Copyright (C) 2011-2017 Juanjo Menent
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014-2015 Ferran Marcet
* Copyright (C) 2014-2015 Charlie Benke
@@ -785,7 +785,8 @@ if (empty($reshook))
$parameters=array('id'=>$object->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
- { $result=$object->updateExtraField($_POST["attribute"]);
+ {
+ $result=$object->insertExtraFields();
if ($result < 0)
{
$error++;
diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php
index b1a17f0a1e8..c8e31e78b4f 100644
--- a/htdocs/fourn/card.php
+++ b/htdocs/fourn/card.php
@@ -629,19 +629,40 @@ if ($object->id > 0)
if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer)
{
$langs->load("supplier_proposal");
- print ''.$langs->trans("AddSupplierProposal").'';
+ if ($object->status == 1)
+ {
+ print ''.$langs->trans("AddSupplierProposal").'';
+ }
+ else
+ {
+ print ''.$langs->trans("AddSupplierProposal").'';
+ }
}
- if ($user->rights->fournisseur->commande->creer)
+ if ($user->rights->fournisseur->commande->creer)
{
$langs->load("orders");
- print ''.$langs->trans("AddOrder").'';
+ if ($object->status == 1)
+ {
+ print ''.$langs->trans("AddOrder").'';
+ }
+ else
+ {
+ print ''.$langs->trans("AddOrder").'';
+ }
}
if ($user->rights->fournisseur->facture->creer)
{
$langs->load("bills");
- print ''.$langs->trans("AddBill").'';
+ if ($object->status == 1)
+ {
+ print ''.$langs->trans("AddBill").'';
+ }
+ else
+ {
+ print ''.$langs->trans("AddBill").'';
+ }
}
if ($user->rights->fournisseur->facture->creer)
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index d7d1e542b3a..822ff7a7b5c 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -1408,7 +1408,7 @@ class CommandeFournisseur extends CommonOrder
$result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', $this->fk_soc); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref/$this->fk_soc
if ($result > 0)
{
- $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice
+ $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice
$ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice
}
if ($result == 0) // If result == 0, we failed to found the supplier reference price
diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php
index 118ef3df3b1..0925eb0eb9f 100644
--- a/htdocs/fourn/facture/list.php
+++ b/htdocs/fourn/facture/list.php
@@ -84,9 +84,12 @@ $day_lim = GETPOST('day_lim','int');
$month_lim = GETPOST('month_lim','int');
$year_lim = GETPOST('year_lim','int');
$toselect = GETPOST('toselect', 'array');
+$filter = GETPOST('filtre','alpha');
$option = GETPOST('option');
-if ($option == 'late') $filter = 'paye:0';
+if ($option == 'late') {
+ $filter = 'paye:0';
+}
$search_all = GETPOST('sall', 'alphanohtml');
$search_label = GETPOST("search_label","alpha");
diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php
index dd64b53ae66..8e8ab6f287c 100644
--- a/htdocs/holiday/card.php
+++ b/htdocs/holiday/card.php
@@ -41,6 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
$myparam = GETPOST("myparam");
$action=GETPOST('action', 'alpha');
$id=GETPOST('id', 'int');
+$fuserid = (GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id);
// Protection if external user
if ($user->societe_id > 0) accessforbidden();
diff --git a/htdocs/includes/tcpdi/tcpdi.php b/htdocs/includes/tcpdi/tcpdi.php
index 48fdd8198f5..999ff99ea5b 100644
--- a/htdocs/includes/tcpdi/tcpdi.php
+++ b/htdocs/includes/tcpdi/tcpdi.php
@@ -580,7 +580,7 @@ class TCPDI extends FPDF_TPL {
* close all files opened by parsers
*/
function _closeParsers() {
- if ($this->state > 2 && count($this->parsers) > 0) {
+ if ($this->state > 2 && is_array($this->parsers) && count($this->parsers) > 0) {
$this->cleanUp();
return true;
}
diff --git a/htdocs/install/check.php b/htdocs/install/check.php
index adbe7759f4e..c96e83ea1d4 100644
--- a/htdocs/install/check.php
+++ b/htdocs/install/check.php
@@ -306,7 +306,19 @@ else
}
else
{
- require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
+ require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
+
+ // If password is encoded, we decode it
+ if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
+ {
+ require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
+ if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
+ {
+ $dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted
+ $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
+ }
+ else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
+ }
// $conf is already instancied inside inc.php
$conf->db->type = $dolibarr_main_db_type;
@@ -315,12 +327,12 @@ else
$conf->db->name = $dolibarr_main_db_name;
$conf->db->user = $dolibarr_main_db_user;
$conf->db->pass = $dolibarr_main_db_pass;
- $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
+ $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
if ($db->connected && $db->database_selected)
{
$ok=true;
}
- }
+ }
}
}
diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql
index 76c8f6df672..42389a5c2dd 100644
--- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql
+++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql
@@ -4,6 +4,7 @@
-- when current version is 4.0.0 or higher.
--
-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
+-- -- VPGSQL8.2 ALTER SEQUENCE IF EXISTS llx_table_rowid_seq RENAME TO llx_table_new_rowid_seq;
-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname;
@@ -60,6 +61,8 @@ ALTER TABLE llx_user DROP COLUMN phenix_login;
ALTER TABLE llx_user DROP COLUMN phenix_pass;
ALTER TABLE llx_user ADD COLUMN dateemployment datetime;
+ALTER TABLE llx_user MODIFY login varchar(50) NOT NULL;
+
ALTER TABLE llx_societe ADD COLUMN fk_account integer;
ALTER TABLE llx_commandedet ADD COLUMN fk_commandefourndet integer DEFAULT NULL after import_key; -- link to detail line of commande fourn (resplenish)
@@ -118,6 +121,8 @@ create table llx_expensereport_extrafields
ALTER TABLE llx_expensereport_extrafields ADD INDEX idx_expensereport_extrafields (fk_object);
ALTER TABLE llx_cotisation RENAME TO llx_subscription;
+-- VPGSQL8.2 ALTER SEQUENCE IF EXISTS llx_cotisation_rowid_seq RENAME TO llx_subscription_rowid_seq;
+
ALTER TABLE llx_subscription ADD UNIQUE INDEX uk_subscription (fk_adherent,dateadh);
ALTER TABLE llx_subscription CHANGE COLUMN cotisation subscription real;
ALTER TABLE llx_adherent_type CHANGE COLUMN cotisation subscription varchar(3) NOT NULL DEFAULT '1';
diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql
index 467455e57de..66224c17ea5 100755
--- a/htdocs/install/mysql/migration/repair.sql
+++ b/htdocs/install/mysql/migration/repair.sql
@@ -33,7 +33,7 @@
-- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci;
-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8;
-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci;
--- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_batchlot MODIFY batch VARCHAR(30) CHARACTER SET utf8;
+-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_batch MODIFY batch VARCHAR(30) CHARACTER SET utf8;
-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_batch MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci;
diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php
index 03f24c3ec80..160d66491a1 100644
--- a/htdocs/public/members/new.php
+++ b/htdocs/public/members/new.php
@@ -500,13 +500,13 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE))
print ' |
';
}
// EMail
-print '| '.$langs->trans("Email").' * | |
'."\n";
+print '| '.$langs->trans("Email").' * | |
'."\n";
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
- print '| '.$langs->trans("Login").' * | |
'."\n";
- print '| '.$langs->trans("Password").' * | |
'."\n";
- print '| '.$langs->trans("PasswordAgain").' * | |
'."\n";
+ print '| '.$langs->trans("Login").' * | |
'."\n";
+ print '| '.$langs->trans("Password").' * | |
'."\n";
+ print '| '.$langs->trans("PasswordAgain").' * | |
'."\n";
}
// Birthday
print '| '.$langs->trans("DateToBirth").' | ';
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 90bcb8522de..6c07c9fa734 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -586,6 +586,12 @@ div.myavailability {
text-overflow: ellipsis;
white-space: nowrap;
}
+.tdoverflowmax200 { /* For tdoverflow, the max-midth become a minimum ! */
+ max-width: 200px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
.tdoverflowmax300 { /* For tdoverflow, the max-midth become a minimum ! */
max-width: 300px;
overflow: hidden;
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 60c52e8683f..ff217042b23 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -564,6 +564,12 @@ div.myavailability {
text-overflow: ellipsis;
white-space: nowrap;
}
+.tdoverflowmax200 { /* For tdoverflow, the max-midth become a minimum ! */
+ max-width: 200px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
.tdoverflowmax300 {
max-width: 300px;
overflow: hidden;
diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php
index 3e09450b9cb..d3b1efaf072 100755
--- a/test/phpunit/PricesTest.php
+++ b/test/phpunit/PricesTest.php
@@ -141,6 +141,11 @@ class PricesTest extends PHPUnit_Framework_TestCase
global $mysoc;
$mysoc=new Societe($db);
+ // To force status that say module multicompany is on
+ //$conf->multicurrency=new stdClass();
+ //$conf->multicurrency->enabled = 0;
+
+
/*
* Country France
*/
@@ -151,7 +156,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0);
print __METHOD__." result1=".join(', ',$result1)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36, 1.24),$result1,'Test1 FR');
+ $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0),$result1,'Test1 FR');
// qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value)
$mysoc->country_code='FR';
@@ -159,16 +164,16 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205);
print __METHOD__." result1=".join(', ',$result1)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.56, 9.34795),$result1,'Test1 FR');
-
+ $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.57, 9.34795, 0.93479, 10.28274, 18.7, 1.87, 20.57, 0, 0),$result1,'Test1b FR');
+
// qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100
$mysoc->country_code='FR';
$mysoc->country_id=1;
$result1=calcul_price_total(2, 0, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205, 20);
print __METHOD__." result1=".join(', ',$result1)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20),$result1,'Test1 FR');
-
+ $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20, 2, 22, 40, 4, 44, 0, 0),$result1,'Test1c FR');
+
/*
* Country Spain
*/
@@ -181,7 +186,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10),$result2,'Test1 ES');
+ $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0),$result2,'Test1 ES');
// 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (other method autodetect)
$mysoc->country_code='ES';
@@ -191,7 +196,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10),$result2,'Test2 ES');
+ $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0),$result2,'Test2 ES');
// --------------------------------------------------------
@@ -203,7 +208,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10),$result2,'Test3 ES');
+ $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0),$result2,'Test3 ES');
// 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect)
$mysoc->country_code='ES';
@@ -213,7 +218,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10),$result2,'Test4 ES');
+ $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0),$result2,'Test4 ES');
// --------------------------------------------------------
@@ -224,7 +229,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$mysoc->localtax2_assuj=1;
$result2=calcul_price_total(10, 10, 0, 10, 0, -19, 0, 'HT', 0, 1);
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10),$result2,'Test5 ES for service');
+ $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19),$result2,'Test5 ES for service');
// 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a service and not a product
$mysoc->country_code='ES';
@@ -234,7 +239,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10),$result2,'Test6 ES for product');
+ $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0),$result2,'Test6 ES for product');
// 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a product and not a service
$mysoc->country_code='ES';
@@ -244,7 +249,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 1);
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10),$result2,'Test6 ES for service');
+ $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19),$result2,'Test6 ES for service');
// --------------------------------------------------------
@@ -256,7 +261,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, -10, 0, 10, 0, 19, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10),$result2,'Test7 ES for product');
+ $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0),$result2,'Test7 ES for product');
// Credit Note: 10 * -10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect), we provide a service and not a product
$mysoc->country_code='ES';
@@ -265,7 +270,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$mysoc->localtax2_assuj=1;
$result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 1);
print __METHOD__." result2=".join(', ',$result2)."\n";
- $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10),$result2,'Test8 ES for service');
+ $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19),$result2,'Test8 ES for service');
/*
@@ -282,7 +287,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result3=calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2
print __METHOD__." result3=".join(', ',$result3)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10),$result3,'Test9 CI');
+ $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0),$result3,'Test9 CI');
// 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (other method autodetect)
$mysoc->country_code='CI';
@@ -292,7 +297,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result3=calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2
print __METHOD__." result3=".join(', ',$result3)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
- $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10),$result3,'Test10 CI');
+ $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0),$result3,'Test10 CI');
return true;
}
|