Skip to content

Commit

Permalink
fix: phpstan for accountancy/class/bookkeeping.class.php
Browse files Browse the repository at this point in the history
  • Loading branch information
FHenry committed Jan 23, 2024
1 parent 4e8d0cc commit f00f99a
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions htdocs/accountancy/class/bookkeeping.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function create(User $user, $notrigger = 0)
$this->journal_label = trim($this->journal_label);
}
if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num);
$this->piece_num = (int) $this->piece_num;
}
if (empty($this->debit)) {
$this->debit = 0.0;
Expand Down Expand Up @@ -385,6 +385,10 @@ public function create(User $user, $notrigger = 0)
$this->piece_num = 1;
}

$this->debit = (float) price2num($this->debit, 'MT');
$this->credit = (float) price2num($this->credit, 'MT');
$this->montant = (float) price2num($this->montant, 'MT');

$now = dol_now();

$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
Expand Down Expand Up @@ -615,16 +619,16 @@ public function createStd(User $user, $notrigger = 0, $mode = '')
$this->label_operation = trim($this->label_operation);
}
if (isset($this->debit)) {
$this->debit = trim($this->debit);
$this->debit = (float) $this->debit;
}
if (isset($this->credit)) {
$this->credit = trim($this->credit);
$this->credit = (float) $this->credit;
}
if (isset($this->montant)) {
$this->montant = trim($this->montant);
$this->montant = (float) $this->montant;
}
if (isset($this->amount)) {
$this->amount = trim($this->amount);
$this->amount = (float) $this->amount;
}
if (isset($this->sens)) {
$this->sens = trim($this->sens);
Expand All @@ -639,7 +643,7 @@ public function createStd(User $user, $notrigger = 0, $mode = '')
$this->journal_label = trim($this->journal_label);
}
if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num);
$this->piece_num = (int) $this->piece_num;
}
if (empty($this->debit)) {
$this->debit = 0;
Expand All @@ -663,9 +667,9 @@ public function createStd(User $user, $notrigger = 0, $mode = '')
return -1;
}

$this->debit = price2num($this->debit, 'MT');
$this->credit = price2num($this->credit, 'MT');
$this->montant = price2num($this->montant, 'MT');
$this->debit = (float) price2num($this->debit, 'MT');
$this->credit = (float) price2num($this->credit, 'MT');
$this->montant = (float) price2num($this->montant, 'MT');

$now = dol_now();

Expand Down Expand Up @@ -1349,13 +1353,16 @@ public function update(User $user, $notrigger = 0, $mode = '')
$this->label_operation = trim($this->label_operation);
}
if (isset($this->debit)) {
$this->debit = trim($this->debit);
$this->debit = (float) $this->debit;
}
if (isset($this->credit)) {
$this->credit = trim($this->credit);
$this->credit = (float) $this->credit;
}
if (isset($this->montant)) {
$this->montant = (float) $this->montant;
}
if (isset($this->amount)) {
$this->amount = trim($this->amount);
$this->amount = (float) $this->amount;
}
if (isset($this->sens)) {
$this->sens = trim($this->sens);
Expand All @@ -1370,7 +1377,7 @@ public function update(User $user, $notrigger = 0, $mode = '')
$this->journal_label = trim($this->journal_label);
}
if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num);
$this->piece_num = (int) $this->piece_num;
}

$result = $this->canModifyBookkeeping($this->id);
Expand All @@ -1387,6 +1394,7 @@ public function update(User $user, $notrigger = 0, $mode = '')

$this->debit = price2num($this->debit, 'MT');
$this->credit = price2num($this->credit, 'MT');
$this->montant = price2num($this->montant, 'MT');

// Check parameters
// Put here code to add a control on parameters values
Expand Down Expand Up @@ -1751,7 +1759,7 @@ public function initAsSpecimen()
$now = dol_now();

$this->id = 0;
$this->doc_date = $now;
$this->doc_date = (string) $now;
$this->doc_type = '';
$this->doc_ref = '';
$this->fk_doc = 0;
Expand Down Expand Up @@ -1825,7 +1833,7 @@ public function fetchPerMvt($piecenum, $mode = '')
* Return next number movement
*
* @param string $mode Mode
* @return string Next numero to use
* @return int Return integer <0 if KO, >0 if OK (Next numero to use)
*/
public function getNextNumMvt($mode = '')
{
Expand Down Expand Up @@ -2126,7 +2134,7 @@ public function transformTransaction($direction = 0, $piece_num = '')
* @param int $select_in Value is a aa.rowid (0 default) or aa.account_number (1)
* @param int $select_out Set value returned by select 0=rowid (default), 1=account_number
* @param string $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
* @return string String with HTML select
* @return string|int String with HTML select or -1 if KO
*/
public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '')
{
Expand Down Expand Up @@ -2232,7 +2240,7 @@ public function getRootAccount($account = null)
* Description of accounting account
*
* @param string $account Accounting account
* @return string Account desc
* @return string|int Account desc or -1 if KO
*/
public function get_compte_desc($account = null)
{
Expand Down

0 comments on commit f00f99a

Please sign in to comment.