dolibarr  9.0.0
multicurrency.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
4  * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
5  * Copyright (C) 2015 RaphaĆ«l Doursenaud <rdoursenaud@gpcsolutions.fr>
6  * Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
28 // Put here all includes required by your class file
29 require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
30 require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
31 
39 {
43  public $element = 'multicurrency';
44 
48  public $table_element = 'multicurrency';
49 
53  public $table_element_line="multicurrency_rate";
54 
58  public $rates = array();
59 
63  public $id;
64 
68  public $code;
69 
73  public $name;
74 
78  public $entity;
79 
83  public $date_create;
84 
88  public $fk_user;
89 
93  public $rate;
94 
100  public function __construct(DoliDB $db)
101  {
102  $this->db = &$db;
103 
104  return 1;
105  }
106 
115  public function create(User $user, $trigger = true)
116  {
117  global $conf,$langs;
118 
119  dol_syslog('Currency::create', LOG_DEBUG);
120 
121  $error = 0;
122 
123  if (self::checkCodeAlreadyExists($this->code))
124  {
125  $error++;
126  $this->errors[] = $langs->trans('multicurrency_code_already_added');
127  return -1;
128  }
129 
130  if (empty($this->entity) || $this->entity <= 0) $this->entity = $conf->entity;
131  $now=date('Y-m-d H:i:s');
132 
133  // Insert request
134  $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
135  $sql .= ' code,';
136  $sql .= ' name,';
137  $sql .= ' entity,';
138  $sql .= ' date_create,';
139  $sql .= ' fk_user';
140  $sql .= ') VALUES (';
141  $sql .= ' \'' . $this->db->escape($this->code) . '\',';
142  $sql .= ' \'' . $this->db->escape($this->name) . '\',';
143  $sql .= ' \'' . $this->entity . '\',';
144  $sql .= ' \'' . $now . '\',';
145  $sql .= ' \'' . $user->id . '\'';
146  $sql .= ')';
147 
148  $this->db->begin();
149 
150  dol_syslog(__METHOD__,LOG_DEBUG);
151  $resql = $this->db->query($sql);
152  if (!$resql) {
153  $error ++;
154  $this->errors[] = 'Error ' . $this->db->lasterror();
155  dol_syslog('Currency::create ' . join(',', $this->errors), LOG_ERR);
156  }
157 
158  if (!$error) {
159  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
160  $this->date_create = $now;
161  $this->fk_user = $user->id;
162 
163  if ($trigger) {
164  $result=$this->call_trigger('CURRENCY_CREATE', $user);
165  if ($result < 0) $error++;
166  }
167  }
168 
169  if ($error) {
170  $this->db->rollback();
171 
172  return - 1 * $error;
173  } else {
174  $this->db->commit();
175 
176  return $this->id;
177  }
178  }
179 
188  public function fetch($id, $code = null)
189  {
190  dol_syslog('Currency::fetch', LOG_DEBUG);
191 
192  global $conf;
193 
194  $sql = 'SELECT';
195  $sql .= ' c.rowid, c.name, c.code, c.entity, c.date_create, c.fk_user';
196  $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' AS c';
197  if (!empty($code)) $sql .= ' WHERE c.code = \''.$this->db->escape($code).'\' AND c.entity = '.$conf->entity;
198  else $sql .= ' WHERE c.rowid = ' . $id;
199 
200  dol_syslog(__METHOD__,LOG_DEBUG);
201  $resql = $this->db->query($sql);
202 
203  if ($resql) {
204  $numrows = $this->db->num_rows($resql);
205  if ($numrows) {
206  $obj = $this->db->fetch_object($resql);
207 
208  $this->id = $obj->rowid;
209  $this->name = $obj->name;
210  $this->code = $obj->code;
211  $this->entity = $obj->entity;
212  $this->date_create = $obj->date_create;
213  $this->fk_user = $obj->fk_user;
214 
215  $this->fetchAllCurrencyRate();
216  $this->getRate();
217  }
218  $this->db->free($resql);
219 
220  if ($numrows) {
221  return 1;
222  } else {
223  return 0;
224  }
225  } else {
226  $this->errors[] = 'Error ' . $this->db->lasterror();
227  dol_syslog('Currency::fetch ' . join(',', $this->errors), LOG_ERR);
228 
229  return -1;
230  }
231  }
232 
238  public function fetchAllCurrencyRate()
239  {
240  $sql = 'SELECT cr.rowid';
241  $sql.= ' FROM ' . MAIN_DB_PREFIX . $this->table_element_line. ' as cr';
242  $sql.= ' WHERE cr.fk_multicurrency = '.$this->id;
243  $sql.= ' ORDER BY cr.date_sync DESC';
244 
245  $this->rates = array();
246 
247  dol_syslog(__METHOD__,LOG_DEBUG);
248  $resql = $this->db->query($sql);
249  if ($resql) {
250  $num = $this->db->num_rows($resql);
251 
252  while ($obj = $this->db->fetch_object($resql)) {
253  $rate = new CurrencyRate($this->db);
254  $rate->fetch($obj->rowid);
255 
256  $this->rates[] = $rate;
257  }
258  $this->db->free($resql);
259 
260  return $num;
261  } else {
262  $this->errors[] = 'Error ' . $this->db->lasterror();
263  dol_syslog('Currency::fetchAllCurrencyRate ' . join(',', $this->errors), LOG_ERR);
264 
265  return - 1;
266  }
267  }
268 
277  public function update(User $user, $trigger = true)
278  {
279  $error = 0;
280 
281  dol_syslog('Currency::update', LOG_DEBUG);
282 
283  // Clean parameters
284  $this->name = trim($this->name);
285  $this->code = trim($this->code);
286 
287  // Check parameters
288  if (empty($this->code)) {
289  $error++;
290  dol_syslog('Currency::update $this->code can not be empty', LOG_ERR);
291 
292  return -1;
293  }
294 
295  // Update request
296  $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
297  $sql .= ' name=\''.$this->db->escape($this->name).'\'';
298  $sql .= ' code=\''.$this->db->escape($this->code).'\'';
299  $sql .= ' WHERE rowid=' . $this->id;
300 
301  dol_syslog(__METHOD__,LOG_DEBUG);
302  $this->db->begin();
303 
304  $resql = $this->db->query($sql);
305  if (!$resql) {
306  $error ++;
307  $this->errors[] = 'Error ' . $this->db->lasterror();
308  dol_syslog('Currency::update ' . join(',', $this->errors), LOG_ERR);
309  }
310 
311  if (!$error && $trigger) {
312  $result=$this->call_trigger('CURRENCY_MODIFY',$user);
313  if ($result < 0) $error++;
314  }
315 
316  // Commit or rollback
317  if ($error) {
318  $this->db->rollback();
319 
320  return - 1 * $error;
321  } else {
322  $this->db->commit();
323 
324  return 1;
325  }
326  }
327 
335  public function delete($trigger = true)
336  {
337  global $user;
338 
339  dol_syslog('Currency::delete', LOG_DEBUG);
340 
341  $error = 0;
342 
343  $this->db->begin();
344 
345  if ($trigger) {
346  $result=$this->call_trigger('CURRENCY_DELETE',$user);
347  if ($result < 0) $error++;
348  }
349 
350  if (!$error) {
351  // Delete all rates before
352  if (!$this->deleteRates()) {
353  $error ++;
354  $this->errors[] = 'Error ' . $this->db->lasterror();
355  dol_syslog('Currency::delete ' . join(',', $this->errors), LOG_ERR);
356  }
357 
358  $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
359  $sql .= ' WHERE rowid=' . $this->id;
360 
361  dol_syslog(__METHOD__,LOG_DEBUG);
362  $resql = $this->db->query($sql);
363  if (!$resql) {
364  $error ++;
365  $this->errors[] = 'Error ' . $this->db->lasterror();
366  dol_syslog('Currency::delete ' . join(',', $this->errors), LOG_ERR);
367  }
368  }
369 
370  // Commit or rollback
371  if ($error) {
372  $this->db->rollback();
373 
374  return - 1 * $error;
375  } else {
376  $this->db->commit();
377 
378  return 1;
379  }
380  }
381 
387  public function deleteRates()
388  {
389  foreach ($this->rates as &$rate)
390  {
391  if ($rate->delete() <= 0)
392  {
393  return false;
394  }
395  }
396 
397  return true;
398  }
399 
407  public function addRate($rate)
408  {
409  $currencyRate = new CurrencyRate($this->db);
410  $currencyRate->rate = $rate;
411 
412  if ($currencyRate->create($this->id) > 0)
413  {
414  $this->rate = $currencyRate;
415  return 1;
416  }
417  else
418  {
419  $this->rate = null;
420  return -1;
421  }
422  }
423 
432  function addRateFromDolibarr($code, $rate)
433  {
434  global $db, $user;
435 
436  $currency = new MultiCurrency($db);
437  $currency->code = $code;
438  $currency->name = $code;
439 
440  $sql = 'SELECT label FROM '.MAIN_DB_PREFIX.'c_currencies WHERE code_iso = \''.$db->escape($code).'\'';
441 
442  dol_syslog(__METHOD__,LOG_DEBUG);
443  $resql = $db->query($sql);
444  if ($resql && ($line = $db->fetch_object($resql)))
445  {
446  $currency->name = $line->label;
447  }
448 
449  if ($currency->create($user) > 0)
450  {
451  $currency->addRate($rate);
452 
453  if (!empty($line)) return 2;
454  else return 1;
455  }
456 
457  return -1;
458  }
459 
467  public function updateRate($rate)
468  {
469  return $this->addRate($rate);
470  }
471 
477  public function getRate()
478  {
479  $sql = 'SELECT cr.rowid';
480  $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as cr';
481  $sql.= ' WHERE cr.fk_multicurrency = '.$this->id;
482  $sql.= ' AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM '.MAIN_DB_PREFIX.$this->table_element_line.' AS cr2 WHERE cr2.fk_multicurrency = '.$this->id.')';
483 
484  dol_syslog(__METHOD__,LOG_DEBUG);
485  $resql = $this->db->query($sql);
486  if ($resql && ($obj = $this->db->fetch_object($resql))) {
487  $this->rate = new CurrencyRate($this->db);
488  return $this->rate->fetch($obj->rowid);
489  }
490  }
491 
500  public static function getIdFromCode(&$db, $code)
501  {
502  global $conf;
503 
504  $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE code = \''.$db->escape($code).'\' AND entity = '.$conf->entity;
505 
506  dol_syslog(__METHOD__,LOG_DEBUG);
507  $resql = $db->query($sql);
508  if ($resql && $obj = $db->fetch_object($resql)) return $obj->rowid;
509  else return 0;
510  }
511 
522  public static function getIdAndTxFromCode(&$db, $code, $date_document='')
523  {
524  global $conf;
525 
526  $sql1 = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m';
527  $sql1.= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)';
528  $sql1.= ' WHERE m.code = \''.$db->escape($code).'\'';
529  $sql1.= " AND m.entity IN (".getEntity('multicurrency').")";
530  $sql2= '';
531  if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE) && !empty($date_document)) $sql2.= ' AND DATE_FORMAT(mc.date_sync, "%Y-%m-%d") = "'.date('Y-m-d', $date_document).'"';
532  $sql3.= ' ORDER BY mc.date_sync DESC LIMIT 1';
533 
534  dol_syslog(__METHOD__,LOG_DEBUG);
535  $resql = $db->query($sql1.$sql2.$sql3);
536 
537  if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate);
538  else
539  {
540  if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE))
541  {
542  $resql = $db->query($sql1.$sql3);
543  if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate);
544  }
545 
546  return array(0, 1);
547  }
548  }
549 
559  public static function getAmountConversionFromInvoiceRate($fk_facture, $amount, $way='dolibarr', $table='facture')
560  {
561  global $db;
562 
563  $multicurrency_tx = self::getInvoiceRate($fk_facture, $table);
564 
565  if ($multicurrency_tx)
566  {
567  if ($way == 'dolibarr') return $amount * $multicurrency_tx;
568  else return $amount / $multicurrency_tx;
569  }
570  else return $amount;
571  }
572 
580  public static function getInvoiceRate($fk_facture, $table='facture')
581  {
582  global $db;
583 
584  $sql = 'SELECT multicurrency_tx FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.$fk_facture;
585 
586  dol_syslog(__METHOD__,LOG_DEBUG);
587  $resql = $db->query($sql);
588  if ($resql && ($line = $db->fetch_object($resql)))
589  {
590  return $line->multicurrency_tx;
591  }
592 
593  return false;
594  }
595 
602  public static function recalculRates(&$TRate)
603  {
604  global $conf;
605 
606  if (!empty($conf->global->MULTICURRENCY_ALTERNATE_SOURCE))
607  {
608  $alternate_source = 'USD'.$conf->global->MULTICURRENCY_ALTERNATE_SOURCE;
609  if (!empty($TRate->{$alternate_source}))
610  {
611  $coef = $TRate->USDUSD / $TRate->{$alternate_source};
612  foreach ($TRate as $attr => &$rate)
613  {
614  $rate *= $coef;
615  }
616 
617  return 1;
618  }
619 
620  return -1; // Alternate souce not found
621  }
622 
623  return 0; // Nothing to do
624  }
625 
632  public static function syncRates($response)
633  {
634  global $db,$conf;
635 
636  $ch = curl_init('http://apilayer.net/api/live?access_key='.$key.'');
637  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
638  $response = curl_exec($ch);
639  curl_close($ch);
640  $response = json_decode($response);
641 
642  if ($response->success)
643  {
644 
645  $TRate = $response->quotes;
646  $timestamp = $response->timestamp;
647 
648  if (self::recalculRates($TRate) >= 0)
649  {
650  foreach ($TRate as $currency_code => $rate)
651  {
652  $code = substr($currency_code, 3, 3);
653  $obj = new MultiCurrency($db);
654  if ($obj->fetch(null, $code) > 0)
655  {
656  $obj->updateRate($rate);
657  }
658  else
659  {
660  self::addRateFromDolibarr($code, $rate);
661  }
662  }
663  }
664  }
665  else
666  {
667  setEventMessages($langs->trans('multicurrency_syncronize_error', $response->error->info), null, 'errors');
668  }
669  }
670 
677  public static function checkCodeAlreadyExists($code)
678  {
679  global $db;
680 
681  $currency = new MultiCurrency($db);
682  if ($currency->fetch('', $code) > 0) return true;
683  else return false;
684  }
685 }
686 
691 {
695  public $element = 'multicurrency_rate';
696 
700  public $table_element = 'multicurrency_rate';
701 
705  public $id;
706 
710  public $rate;
711 
715  public $date_sync;
716 
720  public $fk_multicurrency;
721 
725  public $entity;
726 
732  public function __construct(DoliDB $db)
733  {
734  $this->db = &$db;
735 
736  return 1;
737  }
738 
747  public function create($fk_multicurrency, $trigger = true)
748  {
749  global $conf, $user;
750 
751  dol_syslog('CurrencyRate::create', LOG_DEBUG);
752 
753  $error = 0;
754  $this->rate = price2num($this->rate);
755  if (empty($this->entity) || $this->entity <= 0) $this->entity = $conf->entity;
756  $now=date('Y-m-d H:i:s');
757 
758  // Insert request
759  $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
760  $sql .= ' rate,';
761  $sql .= ' date_sync,';
762  $sql .= ' fk_multicurrency,';
763  $sql .= ' entity';
764  $sql .= ') VALUES (';
765  $sql .= ' '.$this->rate.',';
766  $sql .= ' \'' . $now . '\',';
767  $sql .= ' \'' . $fk_multicurrency . '\',';
768  $sql .= ' \'' . $this->entity . '\'';
769  $sql .= ')';
770 
771  $this->db->begin();
772 
773  dol_syslog(__METHOD__,LOG_DEBUG);
774  $resql = $this->db->query($sql);
775  if (!$resql) {
776  $error ++;
777  $this->errors[] = 'Error ' . $this->db->lasterror();
778  dol_syslog('CurrencyRate::create ' . join(',', $this->errors), LOG_ERR);
779  }
780 
781  if (!$error) {
782  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
783  $this->fk_multicurrency = $fk_multicurrency;
784  $this->date_sync = $now;
785 
786  if ($trigger) {
787  $result=$this->call_trigger('CURRENCYRATE_CREATE', $user);
788  if ($result < 0) $error++;
789  }
790  }
791 
792  if ($error) {
793  $this->db->rollback();
794 
795  return - 1 * $error;
796  } else {
797  $this->db->commit();
798 
799  return $this->id;
800  }
801  }
802 
810  public function fetch($id)
811  {
812  dol_syslog('CurrencyRate::fetch', LOG_DEBUG);
813 
814  $sql = 'SELECT cr.rowid, cr.rate, cr.date_sync, cr.fk_multicurrency, cr.entity';
815  $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' AS cr';
816  $sql .= ' WHERE cr.rowid = ' . $id;
817 
818  dol_syslog(__METHOD__,LOG_DEBUG);
819  $resql = $this->db->query($sql);
820  if ($resql) {
821  $numrows = $this->db->num_rows($resql);
822  if ($numrows) {
823  $obj = $this->db->fetch_object($resql);
824 
825  $this->id = $obj->rowid;
826  $this->rate = $obj->rate;
827  $this->date_sync = $obj->date_sync;
828  $this->fk_multicurrency = $obj->fk_multicurrency;
829  $this->entity = $obj->entity;
830  }
831  $this->db->free($resql);
832 
833  if ($numrows) {
834  return 1;
835  } else {
836  return 0;
837  }
838  } else {
839  $this->errors[] = 'Error ' . $this->db->lasterror();
840  dol_syslog('CurrencyRate::fetch ' . join(',', $this->errors), LOG_ERR);
841 
842  return - 1;
843  }
844  }
845 
853  public function update($trigger = true)
854  {
855  global $user;
856 
857  $error = 0;
858 
859  dol_syslog('CurrencyRate::update', LOG_DEBUG);
860 
861  $this->rate = price2num($this->rate);
862 
863  // Update request
864  $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
865  $sql .= ' rate='.$this->rate;
866  $sql .= ' WHERE rowid=' . $this->id;
867 
868  $this->db->begin();
869 
870  dol_syslog(__METHOD__,LOG_DEBUG);
871  $resql = $this->db->query($sql);
872  if (!$resql) {
873  $error ++;
874  $this->errors[] = 'Error ' . $this->db->lasterror();
875  dol_syslog('CurrencyRate::update ' . join(',', $this->errors), LOG_ERR);
876  }
877 
878  if (!$error && $trigger) {
879  $result=$this->call_trigger('CURRENCYRATE_MODIFY',$user);
880  if ($result < 0) $error++;
881  }
882 
883  // Commit or rollback
884  if ($error) {
885  $this->db->rollback();
886 
887  return -1 * $error;
888  } else {
889  $this->db->commit();
890 
891  return 1;
892  }
893  }
894 
902  public function delete($trigger = true)
903  {
904  global $user;
905 
906  dol_syslog('CurrencyRate::delete', LOG_DEBUG);
907 
908  $error = 0;
909 
910  $this->db->begin();
911 
912  if ($trigger) {
913  $result=$this->call_trigger('CURRENCYRATE_DELETE',$user);
914  if ($result < 0) $error++;
915  }
916 
917  if (!$error) {
918  $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
919  $sql .= ' WHERE rowid='.$this->id;
920 
921  dol_syslog(__METHOD__,LOG_DEBUG);
922  $resql = $this->db->query($sql);
923  if (!$resql) {
924  $error ++;
925  $this->errors[] = 'Error ' . $this->db->lasterror();
926  dol_syslog('CurrencyRate::delete ' . join(',', $this->errors), LOG_ERR);
927  }
928  }
929 
930  // Commit or rollback
931  if ($error) {
932  $this->db->rollback();
933 
934  return - 1 * $error;
935  } else {
936  $this->db->commit();
937 
938  return 1;
939  }
940  }
941 }
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
static getIdFromCode(&$db, $code)
Get id of currency from code.
getRate()
Fetch CurrencyRate object in $this->rate.
__construct(DoliDB $db)
Constructor.
static getInvoiceRate($fk_facture, $table='facture')
Get current invoite rate.
static syncRates($response)
Sync rates from api.
static recalculRates(&$TRate)
With free account we can&#39;t set source then recalcul all rates to force another source.
Class to manage Dolibarr users.
Definition: user.class.php:41
Class to manage Dolibarr database access.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
Class CurrencyRate.
static checkCodeAlreadyExists($code)
Check in database if the current code already exists.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
create(User $user, $trigger=true)
Create object into database.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
create($fk_multicurrency, $trigger=true)
Create object into database.
updateRate($rate)
Add new entry into llx_multicurrency_rate to historise.
update($trigger=true)
Update object into database.
static getAmountConversionFromInvoiceRate($fk_facture, $amount, $way='dolibarr', $table='facture')
Get the conversion of amount with invoice rate.
deleteRates()
Delete rates in database.
fetch($id, $code=null)
Load object in memory from the database.
addRateFromDolibarr($code, $rate)
Try get label of code in llx_currency then add rate.
addRate($rate)
Delete rate in database.
Class Currency.
call_trigger($trigger_name, $user)
Call trigger based on this instance.
fetch($id)
Load object in memory from the database.
__construct(DoliDB $db)
Constructor.
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)