Skip to content

Commit

Permalink
Finishing auto TakePOS setup with default account (#26683)
Browse files Browse the repository at this point in the history
* Finishing auto TakePOS setup with default account

* Travis FIX

* Travis fix

* Update modTakePos.class.php

* Copy customer logic

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
  • Loading branch information
andreubisquerra and eldy committed Nov 19, 2023
1 parent cb26b28 commit 63643e5
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion htdocs/core/modules/modTakePos.class.php
Expand Up @@ -267,7 +267,7 @@ public function __construct($db)
*/
public function init($options = '')
{
global $conf, $db, $langs, $user;
global $conf, $db, $langs, $user, $mysoc;
$langs->load("cashdesk");

dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", "browser", 'chaine', 0, '', $conf->entity);
Expand Down Expand Up @@ -323,6 +323,26 @@ public function init($options = '')
}
}

//Create cash account if not exists
if (!getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH1')) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$cashaccount = new Account($db);
$searchaccountid = $cashaccount->fetch(0, "CASH-POS");
if ($searchaccountid == 0) {
$cashaccount->ref = "CASH-POS";
$cashaccount->label = $langs->trans("DefaultCashPOSLabel");
$cashaccount->courant = 2;
$cashaccount->country_id = $mysoc->country_id ? $mysoc->country_id : 1;
$cashaccount->date_solde = dol_now();
$searchaccountid = $cashaccount->create($user);
}
if ($searchaccountid > 0) {
dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH1", $result, 'chaine', 0, '', $conf->entity);
} else {
setEventMessages($societe->error, $category->errors, 'errors');
}
}

$result = $this->_load_tables('/install/mysql/', 'takepos');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
Expand Down

0 comments on commit 63643e5

Please sign in to comment.