29 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
41 public $element =
'accounting_account';
46 public $table_element =
'accounting_account';
51 public $picto =
'billr';
57 public $ismultientitymanaged = 1;
63 public $restrictiononfksoc = 1;
90 public $fk_pcg_version;
100 public $account_number;
105 public $account_parent;
110 public $account_category;
115 public $account_category_label;
135 public $fk_user_author;
140 public $fk_user_modif;
150 public $reconcilable;
155 private $accountingaccount_codetotid_cache = array();
158 const STATUS_ENABLED = 1;
159 const STATUS_DISABLED = 0;
172 $this->next_prev_filter =
"fk_pcg_version IN (SELECT pcg_version FROM ".MAIN_DB_PREFIX.
"accounting_system WHERE rowid = ".((int) $conf->global->CHARTOFACCOUNTS).
")";
184 public function fetch($rowid =
null, $account_number =
null, $limittocurrentchart = 0, $limittoachartaccount =
'')
188 if ($rowid || $account_number) {
189 $sql =
"SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active, a.reconcilable";
190 $sql .=
", ca.label as category_label";
191 $sql .=
" FROM ".MAIN_DB_PREFIX.
"accounting_account as a";
192 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_accounting_category as ca ON a.fk_accounting_category = ca.rowid";
195 $sql .=
" a.rowid = ".(int) $rowid;
196 } elseif ($account_number) {
197 $sql .=
" a.account_number = '".$this->db->escape($account_number).
"'";
198 $sql .=
" AND a.entity = ".$conf->entity;
200 if (!empty($limittocurrentchart)) {
201 $sql .=
' AND a.fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.
'accounting_system WHERE rowid = '.((int) $conf->global->CHARTOFACCOUNTS).
')';
203 if (!empty($limittoachartaccount)) {
204 $sql .=
" AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount).
"'";
207 dol_syslog(get_class($this).
"::fetch rowid=".$rowid.
" account_number=".$account_number, LOG_DEBUG);
209 $result = $this->
db->query($sql);
211 $obj = $this->
db->fetch_object($result);
214 $this->
id = $obj->rowid;
215 $this->
rowid = $obj->rowid;
216 $this->
ref = $obj->account_number;
217 $this->datec = $obj->datec;
218 $this->tms = $obj->tms;
219 $this->fk_pcg_version = $obj->fk_pcg_version;
220 $this->pcg_type = $obj->pcg_type;
221 $this->account_number = $obj->account_number;
222 $this->account_parent = $obj->account_parent;
223 $this->label = $obj->label;
224 $this->labelshort = $obj->labelshort;
225 $this->account_category = $obj->fk_accounting_category;
226 $this->account_category_label = $obj->category_label;
227 $this->fk_user_author = $obj->fk_user_author;
228 $this->fk_user_modif = $obj->fk_user_modif;
229 $this->active = $obj->active;
230 $this->status = $obj->active;
231 $this->reconcilable = $obj->reconcilable;
238 $this->error =
"Error ".$this->db->lasterror();
239 $this->errors[] =
"Error ".$this->db->lasterror();
252 public function create($user, $notrigger = 0)
259 if (isset($this->fk_pcg_version)) {
260 $this->fk_pcg_version = trim($this->fk_pcg_version);
262 if (isset($this->pcg_type)) {
263 $this->pcg_type = trim($this->pcg_type);
265 if (isset($this->account_number)) {
266 $this->account_number = trim($this->account_number);
268 if (isset($this->label)) {
269 $this->label = trim($this->label);
271 if (isset($this->labelshort)) {
272 $this->labelshort = trim($this->labelshort);
275 if (empty($this->pcg_type) || $this->pcg_type ==
'-1') {
276 $this->pcg_type =
'XXXXXX';
282 $sql =
"INSERT INTO " . MAIN_DB_PREFIX .
"accounting_account(";
285 $sql .=
", fk_pcg_version";
286 $sql .=
", pcg_type";
287 $sql .=
", account_number";
288 $sql .=
", account_parent";
290 $sql .=
", labelshort";
291 $sql .=
", fk_accounting_category";
292 $sql .=
", fk_user_author";
294 $sql .=
", reconcilable";
295 $sql .=
") VALUES (";
296 $sql .=
" '".$this->db->idate($now).
"'";
297 $sql .=
", ".((int) $conf->entity);
298 $sql .=
", ".(empty($this->fk_pcg_version) ?
'NULL' :
"'".$this->db->escape($this->fk_pcg_version).
"'");
299 $sql .=
", ".(empty($this->pcg_type) ?
'NULL' :
"'".$this->db->escape($this->pcg_type).
"'");
300 $sql .=
", ".(empty($this->account_number) ?
'NULL' :
"'".$this->db->escape($this->account_number).
"'");
301 $sql .=
", ".(empty($this->account_parent) ? 0 : (int) $this->account_parent);
302 $sql .=
", ".(empty($this->label) ?
"''" :
"'".$this->db->escape($this->label).
"'");
303 $sql .=
", ".(empty($this->labelshort) ?
"''" :
"'".$this->db->escape($this->labelshort).
"'");
304 $sql .=
", ".(empty($this->account_category) ? 0 : (int) $this->account_category);
305 $sql .=
", ".((int) $user->id);
306 $sql .=
", ".(int) $this->active;
307 $sql .=
", ".(int) $this->reconcilable;
312 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
316 $this->errors[] =
"Error " . $this->
db->lasterror();
320 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX .
"accounting_account");
335 foreach ($this->errors as $errmsg) {
336 dol_syslog(get_class($this) .
"::create " . $errmsg, LOG_ERR);
337 $this->error .= ($this->error ?
', ' . $errmsg : $errmsg);
339 $this->
db->rollback();
356 if (empty($this->pcg_type) || $this->pcg_type ==
'-1') {
357 $this->pcg_type =
'XXXXXX';
362 $sql =
"UPDATE " . MAIN_DB_PREFIX .
"accounting_account ";
363 $sql .=
" SET fk_pcg_version = " . ($this->fk_pcg_version ?
"'" . $this->
db->escape($this->fk_pcg_version) .
"'" :
"null");
364 $sql .=
" , pcg_type = " . ($this->pcg_type ?
"'" . $this->
db->escape($this->pcg_type) .
"'" :
"null");
365 $sql .=
" , account_number = '" . $this->
db->escape($this->account_number) .
"'";
366 $sql .=
" , account_parent = " . (int) $this->account_parent;
367 $sql .=
" , label = " . ($this->label ?
"'" . $this->
db->escape($this->label) .
"'" :
"''");
368 $sql .=
" , labelshort = " . ($this->labelshort ?
"'" . $this->
db->escape($this->labelshort) .
"'" :
"''");
369 $sql .=
" , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category);
370 $sql .=
" , fk_user_modif = " . ((int) $user->id);
371 $sql .=
" , active = " . (int) $this->active;
372 $sql .=
" , reconcilable = " . (int) $this->reconcilable;
373 $sql .=
" WHERE rowid = " . ((int) $this->
id);
375 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
376 $result = $this->
db->query($sql);
381 if ($this->
db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
382 $this->error = $this->
db->lasterror();
383 $this->
db->rollback();
387 $this->error = $this->
db->lasterror();
388 $this->
db->rollback();
402 $sql =
"(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX.
"facturedet";
403 $sql .=
" WHERE fk_code_ventilation=".((int) $this->
id).
")";
405 $sql .=
" (SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX.
"facture_fourn_det";
406 $sql .=
" WHERE fk_code_ventilation=".((int) $this->
id).
")";
408 dol_syslog(get_class($this).
"::checkUsage", LOG_DEBUG);
414 $this->error = $langs->trans(
'ErrorAccountancyCodeIsAlreadyUse');
420 $this->error = $this->
db->lasterror();
432 public function delete($user, $notrigger = 0)
442 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"accounting_account";
443 $sql .=
" WHERE rowid=" . ((int) $this->
id);
445 dol_syslog(get_class($this) .
"::delete sql=" . $sql);
449 $this->errors[] =
"Error " . $this->
db->lasterror();
455 foreach ($this->errors as $errmsg) {
456 dol_syslog(get_class($this) .
"::delete " . $errmsg, LOG_ERR);
457 $this->error .= ($this->error ?
', ' . $errmsg : $errmsg);
459 $this->
db->rollback();
483 public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle =
'', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option =
'')
485 global $langs, $conf, $hookmanager;
486 require_once DOL_DOCUMENT_ROOT .
'/core/lib/accounting.lib.php';
488 if (!empty($conf->dol_no_mouse_hover)) {
496 if (empty($option) || $option ==
'ledger') {
497 $url = DOL_URL_ROOT .
'/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . urlencode($this->account_number) .
'&search_accountancy_code_end=' . urlencode($this->account_number);
498 $labelurl = $langs->trans(
"ShowAccountingAccountInLedger");
499 } elseif ($option ==
'journals') {
500 $url = DOL_URL_ROOT .
'/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . urlencode($this->account_number) .
'&search_accountancy_code_end=' . urlencode($this->account_number);
501 $labelurl = $langs->trans(
"ShowAccountingAccountInJournals");
502 } elseif ($option ==
'accountcard') {
503 $url = DOL_URL_ROOT .
'/accountancy/admin/card.php?id=' . urlencode($this->
id);
504 $labelurl = $langs->trans(
"ShowAccountingAccount");
508 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
509 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
510 $add_save_lastsearch_values = 1;
512 if ($add_save_lastsearch_values) {
513 $url .=
'&save_lastsearch_values=1';
516 $picto =
'accounting_account';
519 if (empty($this->labelshort) || $withcompletelabel == 1) {
520 $labeltoshow = $this->label;
522 $labeltoshow = $this->labelshort;
525 $label =
'<u>' . $labelurl .
'</u>';
526 if (!empty($this->account_number)) {
527 $label .=
'<br><b>' . $langs->trans(
'AccountAccounting') .
':</b> ' .
length_accountg($this->account_number);
529 if (!empty($labeltoshow)) {
530 $label .=
'<br><b>' . $langs->trans(
'Label') .
':</b> ' . $labeltoshow;
533 $label .=
' - ' . $moretitle;
537 if (empty($notooltip)) {
538 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
543 $linkclose .=
' class="classfortooltip"';
546 $linkstart =
'<a href="' . $url .
'"';
547 $linkstart .= $linkclose .
'>';
558 $label_link .=
' - ' . ($nourl ?
'<span class="opacitymedium">' :
'') . $labeltoshow . ($nourl ?
'</span>' :
'');
562 $result .= ($linkstart .
img_object(($notooltip ?
'' : $label), $picto, ($notooltip ?
'' :
'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1) . $linkend);
564 if ($withpicto && $withpicto != 2) {
567 if ($withpicto != 2) {
568 $result .= $linkstart . $label_link . $linkend;
571 $hookmanager->initHooks(array($this->element .
'dao'));
572 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
573 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
575 $result = $hookmanager->resPrint;
577 $result .= $hookmanager->resPrint;
590 $sql =
'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms';
591 $sql .=
' FROM ' . MAIN_DB_PREFIX .
'accounting_account as a';
592 $sql .=
' WHERE a.rowid = ' . ((int) $id);
594 dol_syslog(get_class($this) .
'::info sql=' . $sql);
599 $obj = $this->
db->fetch_object(
$resql);
600 $this->
id = $obj->rowid;
602 $this->user_creation_id = $obj->fk_user_author;
603 $this->user_modification_id = $obj->fk_user_modif;
604 $this->date_creation = $this->
db->jdate($obj->datec);
605 $this->date_modification = $this->
db->jdate($obj->tms);
624 $fieldtouse =
'active';
626 $fieldtouse =
'reconcilable';
632 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"accounting_account ";
633 $sql .=
"SET ".$fieldtouse.
" = '0'";
634 $sql .=
" WHERE rowid = ".((int) $id);
636 dol_syslog(get_class($this).
"::accountDeactivate ".$fieldtouse, LOG_DEBUG);
637 $result = $this->
db->query($sql);
643 $this->error = $this->
db->lasterror();
644 $this->
db->rollback();
665 $fieldtouse =
'active';
667 $fieldtouse =
'reconcilable';
670 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"accounting_account";
671 $sql .=
" SET ".$fieldtouse.
" = '1'";
672 $sql .=
" WHERE rowid = ".((int) $id);
674 dol_syslog(get_class($this).
"::account_activate ".$fieldtouse, LOG_DEBUG);
675 $result = $this->
db->query($sql);
680 $this->error = $this->
db->lasterror();
681 $this->
db->rollback();
694 return $this->
LibStatut($this->status, $mode);
708 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
710 $langs->load(
"users");
711 $this->labelStatus[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
712 $this->labelStatus[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
713 $this->labelStatusShort[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
714 $this->labelStatusShort[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
717 $statusType =
'status4';
718 if ($status == self::STATUS_DISABLED) {
719 $statusType =
'status5';
722 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
743 $hookmanager->initHooks(array(
'accountancyBindingCalculation'));
746 $parameters = array(
'buyer' => $buyer,
'seller' => $seller,
'product' => $product,
'facture' => $facture,
'factureDet' => $factureDet ,
'accountingAccount'=>$accountingAccount, $type);
747 $reshook = $hookmanager->executeHooks(
'accountancyBindingCalculation', $parameters);
749 if (empty($reshook)) {
751 if ($type ==
'customer') {
752 $const_name =
"SOLD";
753 } elseif ($type ==
'supplier') {
757 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
758 $isBuyerInEEC =
isInEEC($buyer);
759 $isSellerInEEC =
isInEEC($seller);
766 $suggestedaccountingaccountbydefaultfor =
'';
767 if ($factureDet->product_type == 1) {
768 if ($buyer->country_code == $seller->country_code || empty($buyer->country_code)) {
769 $code_l = (!empty($conf->global->{
'ACCOUNTING_SERVICE_' . $const_name .
'_ACCOUNT'}) ? $conf->global->{
'ACCOUNTING_SERVICE_' . $const_name .
'_ACCOUNT'} :
'');
770 $suggestedaccountingaccountbydefaultfor =
'';
772 if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) {
773 $code_l = (!empty($conf->global->{
'ACCOUNTING_SERVICE_' . $const_name .
'_ACCOUNT'}) ? $conf->global->{
'ACCOUNTING_SERVICE_' . $const_name .
'_ACCOUNT'} :
'');
774 $suggestedaccountingaccountbydefaultfor =
'eecwithvat';
775 } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) {
776 $code_l = (!empty($conf->global->{
'ACCOUNTING_SERVICE_' . $const_name .
'_ACCOUNT'}) ? $conf->global->{
'ACCOUNTING_SERVICE_' . $const_name .
'_ACCOUNT'} :
'');
777 $suggestedaccountingaccountbydefaultfor =
'eecwithoutvatnumber';
778 } elseif ($isSellerInEEC && $isBuyerInEEC) {
779 $code_l = (!empty($conf->global->{
'ACCOUNTING_SERVICE_' . $const_name .
'_INTRA_ACCOUNT'}) ? $conf->global->{
'ACCOUNTING_SERVICE_' . $const_name .
'_INTRA_ACCOUNT'} :
'');
780 $suggestedaccountingaccountbydefaultfor =
'eec';
782 $code_l = (!empty($conf->global->{
'ACCOUNTING_SERVICE_' . $const_name .
'_EXPORT_ACCOUNT'}) ? $conf->global->{
'ACCOUNTING_SERVICE_' . $const_name .
'_EXPORT_ACCOUNT'} :
'');
783 $suggestedaccountingaccountbydefaultfor =
'export';
786 } elseif ($factureDet->product_type == 0) {
787 if ($buyer->country_code == $seller->country_code || empty($buyer->country_code)) {
788 $code_l = (!empty($conf->global->{
'ACCOUNTING_PRODUCT_' . $const_name .
'_ACCOUNT'}) ? $conf->global->{
'ACCOUNTING_PRODUCT_' . $const_name .
'_ACCOUNT'} :
'');
789 $suggestedaccountingaccountbydefaultfor =
'';
791 if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) {
792 $code_l = (!empty($conf->global->{
'ACCOUNTING_PRODUCT_' . $const_name .
'_ACCOUNT'}) ? $conf->global->{
'ACCOUNTING_PRODUCT_' . $const_name .
'_ACCOUNT'} :
'');
793 $suggestedaccountingaccountbydefaultfor =
'eecwithvat';
794 } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) {
795 $code_l = (!empty($conf->global->{
'ACCOUNTING_PRODUCT_' . $const_name .
'_ACCOUNT'}) ? $conf->global->{
'ACCOUNTING_PRODUCT_' . $const_name .
'_ACCOUNT'} :
'');
796 $suggestedaccountingaccountbydefaultfor =
'eecwithoutvatnumber';
797 } elseif ($isSellerInEEC && $isBuyerInEEC) {
798 $code_l = (!empty($conf->global->{
'ACCOUNTING_PRODUCT_' . $const_name .
'_INTRA_ACCOUNT'}) ? $conf->global->{
'ACCOUNTING_PRODUCT_' . $const_name .
'_INTRA_ACCOUNT'} :
'');
799 $suggestedaccountingaccountbydefaultfor =
'eec';
801 $code_l = (!empty($conf->global->{
'ACCOUNTING_PRODUCT_' . $const_name .
'_EXPORT_ACCOUNT'}) ? $conf->global->{
'ACCOUNTING_PRODUCT_' . $const_name .
'_EXPORT_ACCOUNT'} :
'');
802 $suggestedaccountingaccountbydefaultfor =
'export';
811 $suggestedaccountingaccountfor =
'';
812 if ((($buyer->country_code == $seller->country_code) || empty($buyer->country_code))) {
814 if ($type ==
'customer' && !empty($product->accountancy_code_sell)) {
815 $code_p = $product->accountancy_code_sell;
816 } elseif ($type ==
'supplier' && !empty($product->accountancy_code_buy)) {
817 $code_p = $product->accountancy_code_buy;
819 $suggestedid = $accountingAccount[
'dom'];
820 $suggestedaccountingaccountfor =
'prodserv';
822 if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) {
824 if ($type ==
'customer' && !empty($product->accountancy_code_sell)) {
825 $code_p = $product->accountancy_code_sell;
826 } elseif ($type ==
'supplier' && !empty($product->accountancy_code_buy)) {
827 $code_p = $product->accountancy_code_buy;
829 $suggestedid = $accountingAccount[
'dom'];
830 $suggestedaccountingaccountfor =
'eecwithvat';
831 } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) {
833 if ($type ==
'customer' && !empty($product->accountancy_code_sell)) {
834 $code_p = $product->accountancy_code_sell;
835 } elseif ($type ==
'supplier' && !empty($product->accountancy_code_buy)) {
836 $code_p = $product->accountancy_code_buy;
838 $suggestedid = $accountingAccount[
'dom'];
839 $suggestedaccountingaccountfor =
'eecwithoutvatnumber';
840 } elseif ($isSellerInEEC && $isBuyerInEEC && !empty($product->accountancy_code_sell_intra)) {
842 if ($type ==
'customer' && !empty($product->accountancy_code_sell_intra)) {
843 $code_p = $product->accountancy_code_sell_intra;
844 } elseif ($type ==
'supplier' && !empty($product->accountancy_code_buy_intra)) {
845 $code_p = $product->accountancy_code_buy_intra;
847 $suggestedid = $accountingAccount[
'intra'];
848 $suggestedaccountingaccountfor =
'eec';
851 if ($type ==
'customer' && !empty($product->accountancy_code_sell_export)) {
852 $code_p = $product->accountancy_code_sell_export;
853 } elseif ($type ==
'supplier' && !empty($product->accountancy_code_buy_export)) {
854 $code_p = $product->accountancy_code_buy_export;
856 $suggestedid = $accountingAccount[
'export'];
857 $suggestedaccountingaccountfor =
'export';
862 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
863 if (!empty($buyer->code_compta_product)) {
864 $code_t = $buyer->code_compta_product;
865 $suggestedid = $accountingAccount[
'thirdparty'];
866 $suggestedaccountingaccountfor =
'thirdparty';
872 if ($factureDet->desc ==
"(DEPOSIT)" || $facture->type == $facture::TYPE_DEPOSIT) {
873 $accountdeposittoventilated =
new self($this->db);
874 if ($type ==
'customer') {
875 $result = $accountdeposittoventilated->fetch(
'', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1);
876 } elseif ($type ==
'supplier') {
877 $result = $accountdeposittoventilated->fetch(
'', $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT, 1);
879 if (isset($result) && $result < 0) {
883 $code_l = $accountdeposittoventilated->ref;
886 $suggestedid = $accountdeposittoventilated->rowid;
887 $suggestedaccountingaccountfor =
'deposit';
891 if (!empty($facture->fk_facture_source)) {
892 $invoiceSource =
new $facture($this->
db);
893 $invoiceSource->fetch($facture->fk_facture_source);
895 if ($facture->type == $facture::TYPE_CREDIT_NOTE && $invoiceSource->type == $facture::TYPE_DEPOSIT) {
896 $accountdeposittoventilated =
new self($this->db);
897 if ($type ==
'customer') {
898 $accountdeposittoventilated->fetch(
'', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1);
899 } elseif ($type ==
'supplier') {
900 $accountdeposittoventilated->fetch(
'', $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT, 1);
902 $code_l = $accountdeposittoventilated->ref;
905 $suggestedid = $accountdeposittoventilated->rowid;
906 $suggestedaccountingaccountfor =
'deposit';
912 if (empty($suggestedid) && empty($code_p) && !empty($code_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) {
913 if (empty($this->accountingaccount_codetotid_cache[$code_l])) {
914 $tmpaccount =
new self($this->db);
915 $result = $tmpaccount->fetch(0, $code_l, 1);
919 if ($tmpaccount->id > 0) {
920 $suggestedid = $tmpaccount->id;
922 $this->accountingaccount_codetotid_cache[$code_l] = $tmpaccount->id;
924 $suggestedid = $this->accountingaccount_codetotid_cache[$code_l];
928 'suggestedaccountingaccountbydefaultfor' => $suggestedaccountingaccountbydefaultfor,
929 'suggestedaccountingaccountfor' => $suggestedaccountingaccountfor,
930 'suggestedid' => $suggestedid,
936 if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) {
937 return $hookmanager->resArray;
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
Class to manage accounting accounts.
LibStatut($status, $mode=0)
Renvoi le libelle d'un statut donne.
accountDeactivate($id, $mode=0)
Deactivate an account (for status active or status reconcilable)
__construct($db)
Constructor.
checkUsage()
Check usage of accounting code.
update($user)
Update record.
getNomUrl($withpicto=0, $withlabel=0, $nourl=0, $moretitle='', $notooltip=0, $save_lastsearch_value=-1, $withcompletelabel=0, $option='')
Return clicable name (with picto eventually)
create($user, $notrigger=0)
Insert new accounting account in chart of accounts.
accountActivate($id, $mode=0)
Account activated.
info($id)
Information on record.
fetch($rowid=null, $account_number=null, $limittocurrentchart=0, $limittoachartaccount='')
Load record in memory.
getAccountingCodeToBind(Societe $buyer, Societe $seller, Product $product, $facture, $factureDet, $accountingAccount=array(), $type='')
Return Suggest accounting accounts to bind.
getLibStatut($mode=0)
Retourne le libelle du statut d'un user (actif, inactif)
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_now($mode='auto')
Return date for now.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.