-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix PhanTypeInvalidUnaryOperandNumeric & remove from exceptions
# Fix PhanTypeInvalidUnaryOperandNumeric & remove from exceptions Fix by casting result of date() or by adding typing hints. (This notification indicates a unary '-' or similar is performed on a value that may not be a number).
- Loading branch information
Showing
8 changed files
with
99 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
* Copyright (C) 2020 Maxime DEMAREST <[email protected]> | ||
* Copyright (C) 2021 Gauthier VERDOL <[email protected]> | ||
* Copyright (C) 2022-2024 Alexandre Spangaro <[email protected]> | ||
* Copyright (C) 2024 MDW <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -96,15 +97,15 @@ | |
|
||
|
||
$arrayfields = array( | ||
'type'=>array('label'=>"Type", 'checked'=>1), | ||
'date'=>array('label'=>"Date", 'checked'=>1), | ||
'date_due'=>array('label'=>"DateDue", 'checked'=>1), | ||
'ref'=>array('label'=>"Ref", 'checked'=>1), | ||
'documents'=>array('label'=>"Documents", 'checked'=>1), | ||
'paid'=>array('label'=>"Paid", 'checked'=>1), | ||
'total_ht'=>array('label'=>"TotalHT", 'checked'=>1), | ||
'total_ttc'=>array('label'=>"TotalTTC", 'checked'=>1), | ||
'total_vat'=>array('label'=>"TotalVAT", 'checked'=>1), | ||
'type' => array('label' => "Type", 'checked' => 1), | ||
'date' => array('label' => "Date", 'checked' => 1), | ||
'date_due' => array('label' => "DateDue", 'checked' => 1), | ||
'ref' => array('label' => "Ref", 'checked' => 1), | ||
'documents' => array('label' => "Documents", 'checked' => 1), | ||
'paid' => array('label' => "Paid", 'checked' => 1), | ||
'total_ht' => array('label' => "TotalHT", 'checked' => 1), | ||
'total_ttc' => array('label' => "TotalTTC", 'checked' => 1), | ||
'total_vat' => array('label' => "TotalVAT", 'checked' => 1), | ||
//... | ||
); | ||
|
||
|
@@ -135,14 +136,14 @@ | |
$error = 0; | ||
|
||
$listofchoices = array( | ||
'selectinvoices'=>array('label'=>'Invoices', 'picto'=>'bill', 'lang'=>'bills', 'enabled' => isModEnabled('invoice'), 'perms' => $user->hasRight('facture', 'lire')), | ||
'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'picto'=>'supplier_invoice', 'lang'=>'bills', 'enabled' => isModEnabled('supplier_invoice'), 'perms' => $user->hasRight('fournisseur', 'facture', 'lire')), | ||
'selectexpensereports'=>array('label'=>'ExpenseReports', 'picto'=>'expensereport', 'lang'=>'trips', 'enabled' => isModEnabled('expensereport'), 'perms' => $user->hasRight('expensereport', 'lire')), | ||
'selectdonations'=>array('label'=>'Donations', 'picto'=>'donation', 'lang'=>'donation', 'enabled' => isModEnabled('don'), 'perms' => $user->hasRight('don', 'lire')), | ||
'selectsocialcontributions'=>array('label'=>'SocialContributions', 'picto'=>'bill', 'enabled' => isModEnabled('tax'), 'perms' => $user->hasRight('tax', 'charges', 'lire')), | ||
'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'picto'=>'salary', 'lang'=>'salaries', 'enabled' => isModEnabled('salaries'), 'perms' => $user->hasRight('salaries', 'read')), | ||
'selectvariouspayment'=>array('label'=>'VariousPayment', 'picto'=>'payment', 'enabled' => isModEnabled('bank'), 'perms' => $user->hasRight('banque', 'lire')), | ||
'selectloanspayment'=>array('label'=>'PaymentLoan','picto'=>'loan', 'enabled' => isModEnabled('don'), 'perms' => $user->hasRight('loan', 'read')), | ||
'selectinvoices' => array('label' => 'Invoices', 'picto' => 'bill', 'lang' => 'bills', 'enabled' => isModEnabled('invoice'), 'perms' => $user->hasRight('facture', 'lire')), | ||
'selectsupplierinvoices' => array('label' => 'BillsSuppliers', 'picto' => 'supplier_invoice', 'lang' => 'bills', 'enabled' => isModEnabled('supplier_invoice'), 'perms' => $user->hasRight('fournisseur', 'facture', 'lire')), | ||
'selectexpensereports' => array('label' => 'ExpenseReports', 'picto' => 'expensereport', 'lang' => 'trips', 'enabled' => isModEnabled('expensereport'), 'perms' => $user->hasRight('expensereport', 'lire')), | ||
'selectdonations' => array('label' => 'Donations', 'picto' => 'donation', 'lang' => 'donation', 'enabled' => isModEnabled('don'), 'perms' => $user->hasRight('don', 'lire')), | ||
'selectsocialcontributions' => array('label' => 'SocialContributions', 'picto' => 'bill', 'enabled' => isModEnabled('tax'), 'perms' => $user->hasRight('tax', 'charges', 'lire')), | ||
'selectpaymentsofsalaries' => array('label' => 'SalariesPayments', 'picto' => 'salary', 'lang' => 'salaries', 'enabled' => isModEnabled('salaries'), 'perms' => $user->hasRight('salaries', 'read')), | ||
'selectvariouspayment' => array('label' => 'VariousPayment', 'picto' => 'payment', 'enabled' => isModEnabled('bank'), 'perms' => $user->hasRight('banque', 'lire')), | ||
'selectloanspayment' => array('label' => 'PaymentLoan','picto' => 'loan', 'enabled' => isModEnabled('don'), 'perms' => $user->hasRight('loan', 'read')), | ||
); | ||
|
||
|
||
|
@@ -157,6 +158,9 @@ | |
//if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); | ||
|
||
$filesarray = array(); | ||
|
||
'@phan-var-force array<string,array{id:string,entity:string,date:string,date_due:string,paid:float|int,amount_ht:float|int,amount_ttc:float|int,amount_vat:float|int,amount_localtax1:float|int,amount_localtax2:float|int,amount_revenuestamp:float|int,ref:string,fk:string,item:string,thirdparty_name:string,thirdparty_code:string,country_code:string,vatnum:string,sens:string,currency:string,line?:string,name?:string,files?:mixed}> $filesarray'; | ||
|
||
$result = false; | ||
if (($action == 'searchfiles' || $action == 'dl')) { | ||
if (empty($date_start)) { | ||
|
@@ -411,6 +415,7 @@ | |
$nofile['link'] = ''; | ||
$nofile['name'] = ''; | ||
|
||
|
||
$filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; | ||
} else { | ||
foreach ($files as $key => $file) { | ||
|
@@ -446,8 +451,8 @@ | |
} | ||
$filesarray[$file['item'].'_'.$file['id']]['files'][] = array( | ||
'link' => $link.urlencode($file['name']), | ||
'name'=>$file['name'], | ||
'ref'=>$file['ref'], | ||
'name' => $file['name'], | ||
'ref' => $file['ref'], | ||
'fullname' => $file['fullname'], | ||
'relpath' => '/'.$file['name'], | ||
'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'], | ||
|
@@ -522,7 +527,7 @@ | |
$zipname .= '_'.$project->ref; | ||
} | ||
} | ||
$zipname .='_export.zip'; | ||
$zipname .= '_export.zip'; | ||
|
||
dol_delete_file($zipname); | ||
|
||
|
@@ -689,6 +694,7 @@ | |
} | ||
|
||
$TData = dol_sort_array($filesarray, $sortfield, $sortorder); | ||
'@phan-var-force array<string,array{id:string,entity:string,date:string,date_due:string,paid:float|int,amount_ht:float|int,amount_ttc:float|int,amount_vat:float|int,amount_localtax1:float|int,amount_localtax2:float|int,amount_revenuestamp:float|int,ref:string,fk:string,item:string,thirdparty_name:string,thirdparty_code:string,country_code:string,vatnum:string,sens:string,currency:string,line?:string,name?:string,files?:mixed}> $TData'; | ||
|
||
|
||
$filename = dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
* Copyright (C) 2004-2007 Laurent Destailleur <[email protected]> | ||
* Copyright (C) 2022 Alexandre Spangaro <[email protected]> | ||
* Copyright (C) 2024 Frédéric France <[email protected]> | ||
* Copyright (C) 2024 MDW <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -82,12 +83,19 @@ class PaymentSocialContribution extends CommonObject | |
public $bank_line; | ||
|
||
/** | ||
* @deprecated | ||
* @deprecated Use $amount instead. | ||
* @see $amount | ||
* @var float|int | ||
*/ | ||
public $total; | ||
|
||
/** | ||
* @var float|int | ||
*/ | ||
public $amount; // Total amount of payment | ||
/** | ||
* @var array<float|int> | ||
*/ | ||
public $amounts = array(); // Array of amounts | ||
|
||
/** | ||
|
@@ -97,7 +105,7 @@ class PaymentSocialContribution extends CommonObject | |
|
||
/** | ||
* @var string | ||
* @deprecated | ||
* @deprecated Use $num_payment instead | ||
* @see $num_payment | ||
*/ | ||
public $num_paiement; | ||
|
@@ -318,8 +326,10 @@ public function fetch($id) | |
$this->tms = $this->db->jdate($obj->tms); | ||
$this->datep = $this->db->jdate($obj->datep); | ||
$this->amount = $obj->amount; | ||
$this->total = $obj->amount; | ||
$this->fk_typepaiement = $obj->fk_typepaiement; | ||
$this->num_payment = $obj->num_payment; | ||
$this->num_paiement = $obj->num_payment; | ||
$this->note_private = $obj->note; | ||
$this->fk_bank = $obj->fk_bank; | ||
$this->fk_user_creat = $obj->fk_user_creat; | ||
|
@@ -577,7 +587,7 @@ public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom | |
$acc = new Account($this->db); | ||
$acc->fetch($accountid); | ||
|
||
$total = $this->total; | ||
$total = $this->amount; | ||
if ($mode == 'payment_sc') { | ||
$total = -$total; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
* Copyright (C) 2004-2007 Laurent Destailleur <[email protected]> | ||
* Copyright (C) 2021 Gauthier VERDOL <[email protected]> | ||
* Copyright (C) 2024 Frédéric France <[email protected]> | ||
* Copyright (C) 2024 MDW <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -58,12 +59,20 @@ class PaymentVAT extends CommonObject | |
public $datep = ''; | ||
|
||
/** | ||
* @deprecated | ||
* @deprecated Use $amount instead | ||
* @see $amount | ||
* @var float|int | ||
*/ | ||
public $total; | ||
|
||
/** | ||
* @var float|int | ||
*/ | ||
public $amount; // Total amount of payment | ||
|
||
/** | ||
* @var array<float|int> | ||
*/ | ||
public $amounts = array(); // Array of amounts | ||
|
||
/** | ||
|
@@ -73,7 +82,7 @@ class PaymentVAT extends CommonObject | |
|
||
/** | ||
* @var string | ||
* @deprecated | ||
* @deprecated Use $num_payment instead | ||
* @see $num_payment | ||
*/ | ||
public $num_paiement; | ||
|
@@ -578,7 +587,7 @@ public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom | |
$acc = new Account($this->db); | ||
$acc->fetch($accountid); | ||
|
||
$total = $this->total; | ||
$total = $this->amount; | ||
if ($mode == 'payment_vat') { | ||
$total = -$total; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
/* Copyright (C) 2015-2017 Alexandre Spangaro <[email protected]> | ||
* Copyright (C) 2018 Nicolas ZABOURI <[email protected]> | ||
* Copyright (C) 2024 Frédéric France <[email protected]> | ||
* Copyright (C) 2024 MDW <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -65,7 +66,13 @@ class PaymentExpenseReport extends CommonObject | |
* @var int|string | ||
*/ | ||
public $datep = ''; | ||
/** | ||
* @var float|int | ||
*/ | ||
public $amount; // Total amount of payment | ||
/** | ||
* @var array<float|int> | ||
*/ | ||
public $amounts = array(); // Array of amounts | ||
|
||
/** | ||
|
@@ -94,7 +101,14 @@ class PaymentExpenseReport extends CommonObject | |
*/ | ||
public $fk_user_modif; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $type_code; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $type_label; | ||
|
||
/** | ||
|
@@ -693,7 +707,7 @@ public function getNomUrl($withpicto = 0, $maxlen = 0) | |
} | ||
global $action; | ||
$hookmanager->initHooks(array($this->element . 'dao')); | ||
$parameters = array('id'=>$this->id, 'getnomurl' => &$result); | ||
$parameters = array('id' => $this->id, 'getnomurl' => &$result); | ||
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks | ||
if ($reshook > 0) { | ||
$result = $hookmanager->resPrint; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
/* Copyright (C) 2014-2018 Alexandre Spangaro <[email protected]> | ||
* Copyright (C) 2015-2024 Frédéric France <[email protected]> | ||
* Copyright (C) 2020 Maxime DEMAREST <[email protected]> | ||
* Copyright (C) 2024 MDW <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -62,14 +63,23 @@ class PaymentLoan extends CommonObject | |
public $datep = ''; | ||
|
||
/** | ||
* @var array Array of amounts | ||
* @var array<float|int> Array of amounts | ||
*/ | ||
public $amounts = array(); | ||
|
||
public $amount_capital; // Total amount of payment | ||
/** | ||
* @var float|int Total amount of payment | ||
*/ | ||
public $amount_capital; | ||
|
||
/** | ||
* @var float|int | ||
*/ | ||
public $amount_insurance; | ||
|
||
/** | ||
* @var float|int | ||
*/ | ||
public $amount_interest; | ||
|
||
/** | ||
|
@@ -98,10 +108,22 @@ class PaymentLoan extends CommonObject | |
*/ | ||
public $fk_user_modif; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $type_code; | ||
/** | ||
* @var string | ||
*/ | ||
public $type_label; | ||
public $chid; | ||
/** | ||
* @var string | ||
*/ | ||
public $label; | ||
/** | ||
* @var string | ||
*/ | ||
public $paymenttype; | ||
public $bank_account; | ||
public $bank_line; | ||
|
@@ -666,7 +688,7 @@ public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $moretitl | |
|
||
global $action; | ||
$hookmanager->initHooks(array($this->element . 'dao')); | ||
$parameters = array('id'=>$this->id, 'getnomurl' => &$result); | ||
$parameters = array('id' => $this->id, 'getnomurl' => &$result); | ||
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks | ||
if ($reshook > 0) { | ||
$result = $hookmanager->resPrint; | ||
|
Oops, something went wrong.