Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Dec 13, 2024
1 parent 9d4a21d commit 7c1a6a3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 13 deletions.
22 changes: 11 additions & 11 deletions htdocs/payplugdolicloud/core/modules/modPayplugDolicloud.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,23 +470,23 @@ public function init($options = '')
// Create bank account Payplug if not exists
if (!getDolGlobalInt('PAYPLUG_DOLICLOUD_BANK_ACCOUNT_FOR_PAYMENTS')) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$cashaccount = new Account($this->db);
$searchaccountid = $cashaccount->fetch(0, "PAYPLUG");
$bankaccount = new Account($this->db);
$searchaccountid = $bankaccount->fetch(0, "PAYPLUG");
if ($searchaccountid == 0) {
$cashaccount->ref = "Payplug";
$cashaccount->label = 'Payplug';
$cashaccount->courant = Account::TYPE_CURRENT; // deprecated
$cashaccount->type = Account::TYPE_CURRENT;
$cashaccount->country_id = $mysoc->country_id ? $mysoc->country_id : 1;
$cashaccount->date_solde = dol_now();
$bankaccount->ref = "Payplug";
$bankaccount->label = 'Payplug';
$bankaccount->type = Account::TYPE_CURRENT;
$bankaccount->country_id = $mysoc->country_id ? $mysoc->country_id : 1;
$bankaccount->date_solde = dol_now();
$idjournal = dol_getIdFromCode($this->db, 'BQ', 'accounting_journal', 'code', 'rowid');
$cashaccount->fk_accountancy_journal = (int) $idjournal;
$searchaccountid = $cashaccount->create($user);
$bankaccount->fk_accountancy_journal = (int) $idjournal;

$searchaccountid = $bankaccount->create($user);
}
if ($searchaccountid > 0) {
dolibarr_set_const($this->db, "PAYPLUG_DOLICLOUD_BANK_ACCOUNT_FOR_PAYMENTS", $searchaccountid, 'chaine', 0, '', $conf->entity);
} else {
setEventMessages($cashaccount->error, $cashaccount->errors, 'errors');
setEventMessages($bankaccount->error, $bankaccount->errors, 'errors');
}
}

Expand Down
29 changes: 27 additions & 2 deletions htdocs/stancerdolicloud/core/modules/modStancerDolicloud.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,33 @@ public function __construct($db)
*/
public function init($options = '')
{
global $conf, $langs;

global $conf, $langs, $mysoc, $user;

// Create bank account Payplug if not exists
if (!getDolGlobalInt('STANCER_DOLICLOUD_BANK_ACCOUNT_FOR_PAYMENTS')) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$bankaccount = new Account($this->db);
$searchaccountid = $bankaccount->fetch(0, "STANCER");
if ($searchaccountid == 0) {
$bankaccount->ref = "Stancer";
$bankaccount->label = 'Stancer';
$bankaccount->type = Account::TYPE_CURRENT;
$bankaccount->country_id = $mysoc->country_id ? $mysoc->country_id : 1;
$bankaccount->date_solde = dol_now();
$idjournal = dol_getIdFromCode($this->db, 'BQ', 'accounting_journal', 'code', 'rowid');
$bankaccount->fk_accountancy_journal = (int) $idjournal;

$searchaccountid = $bankaccount->create($user);
}
if ($searchaccountid > 0) {
dolibarr_set_const($this->db, "STANCER_DOLICLOUD_BANK_ACCOUNT_FOR_PAYMENTS", $searchaccountid, 'chaine', 0, '', $conf->entity);
} else {
setEventMessages($bankaccount->error, $bankaccount->errors, 'errors');
}
}



//$result = $this->_load_tables('/install/mysql/', 'stancerdolicloud');
$result = $this->_load_tables('/stancerdolicloud/sql/');
if ($result < 0) {
Expand Down

0 comments on commit 7c1a6a3

Please sign in to comment.