Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2024-09-10 02:19:42 +02:00
commit 4eb2b28c72
20 changed files with 225 additions and 143 deletions

View file

@ -9,21 +9,21 @@
*/
return [
// # Issue statistics:
// PhanPluginUnknownPropertyType : 1790+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 1310+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 1090+ occurrences
// PhanUndeclaredProperty : 810+ occurrences
// PhanPluginUnknownObjectMethodCall : 750+ occurrences
// PhanUndeclaredGlobalVariable : 720+ occurrences
// PhanPluginUnknownArrayMethodParamType : 610+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 530+ occurrences
// PhanPossiblyUndeclaredVariable : 360+ occurrences
// PhanPluginUnknownPropertyType : 1620+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 1160+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 1050+ occurrences
// PhanUndeclaredProperty : 780+ occurrences
// PhanUndeclaredGlobalVariable : 700+ occurrences
// PhanPluginUnknownObjectMethodCall : 550+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 510+ occurrences
// PhanPluginUnknownArrayMethodParamType : 470+ occurrences
// PhanPossiblyUndeclaredVariable : 350+ occurrences
// PhanPluginUnknownArrayFunctionReturnType : 230+ occurrences
// PhanTypeMismatchProperty : 220+ occurrences
// PhanTypeMismatchProperty : 210+ occurrences
// PhanPluginUnknownArrayFunctionParamType : 170+ occurrences
// PhanTypeExpectedObjectPropAccess : 150+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 150+ occurrences
// PhanPluginUnknownArrayPropertyType : 110+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 120+ occurrences
// PhanPluginUnknownArrayPropertyType : 85+ occurrences
// PhanPluginUndeclaredVariableIsset : 70+ occurrences
// PhanPluginEmptyStatementIf : 65+ occurrences
// PhanRedefineFunction : 55+ occurrences
@ -39,32 +39,17 @@ return [
// PhanPluginDuplicateExpressionBinaryOp : 10+ occurrences
// PhanPluginSuspiciousParamPosition : 10+ occurrences
// PhanTypeMismatchDimFetchNullable : 10+ occurrences
// PhanPluginDuplicateArrayKey : 8 occurrences
// PhanUndeclaredMethod : 5 occurrences
// PhanInvalidFQSENInClasslike : 4 occurrences
// PhanPluginDuplicateArrayKey : 4 occurrences
// PhanEmptyFQSENInClasslike : 3 occurrences
// PhanUndeclaredMethod : 3 occurrences
// PhanParamTooMany : 2 occurrences
// PhanAccessMethodProtected : 1 occurrence
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'htdocs/accountancy/admin/productaccount.php' => ['PhanTypeMismatchArgumentNullableInternal'],
'htdocs/accountancy/bookkeeping/card.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/accountancy/bookkeeping/listbyaccount.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/accountancy/class/accountancycategory.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayPropertyType', 'PhanPossiblyUndeclaredVariable'],
'htdocs/accountancy/class/accountancyexport.class.php' => ['PhanTypeMismatchReturn', 'PhanUndeclaredProperty'],
'htdocs/accountancy/class/accountancyimport.class.php' => ['PhanPluginUnknownArrayMethodParamType'],
'htdocs/accountancy/class/accountingaccount.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayPropertyType', 'PhanPossiblyUndeclaredVariable'],
'htdocs/accountancy/class/api_accountancy.class.php' => ['PhanPluginUnknownArrayPropertyType'],
'htdocs/accountancy/class/bookkeeping.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/accountancy/class/lettering.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'],
'htdocs/accountancy/customer/list.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/accountancy/journal/bankjournal.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/accountancy/journal/expensereportsjournal.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/accountancy/journal/purchasesjournal.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/accountancy/journal/sellsjournal.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/accountancy/journal/variousjournal.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/accountancy/supplier/list.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/accountancy/class/accountancycategory.class.php' => ['PhanPluginUnknownArrayPropertyType'],
'htdocs/accountancy/class/accountancyexport.class.php' => ['PhanUndeclaredProperty'],
'htdocs/adherents/admin/member.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/adherents/canvas/actions_adherentcard_common.class.php' => [/* Traverses Adherent as array, ignore */ 'PhanTypeSuspiciousNonTraversableForeach'],
'htdocs/adherents/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
@ -772,7 +757,7 @@ return [
'htdocs/fichinter/card.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/fichinter/class/api_interventions.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanUndeclaredProperty'],
'htdocs/fichinter/class/fichinter.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanPluginUnknownObjectMethodCall'],
'htdocs/fichinter/class/fichinterrec.class.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/fichinter/class/fichinterrec.class.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/fichinter/class/fichinterstats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'],
'htdocs/fichinter/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/fichinter/tpl/linkedobjectblock.tpl.php' => ['PhanPluginUnknownObjectMethodCall'],
@ -996,7 +981,7 @@ return [
'htdocs/projet/index.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/projet/list.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/projet/stats/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/projet/tasks.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/projet/tasks.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/projet/tasks/comment.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/projet/tasks/contact.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/projet/tasks/document.php' => ['PhanTypeMismatchArgumentProbablyReal'],

View file

@ -274,6 +274,7 @@ if ($action == 'update' && $permissiontobind) {
*/
$form = new FormAccounting($db);
'@phan-var-force string[] $toselect'; // For some reason typing is lost at this point
// Default AccountingAccount RowId Product / Service
// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid
@ -517,7 +518,7 @@ if ($resql) {
$massactionbutton = '';
$nbselected = is_array($toselect) ? count($toselect) : 0;
$nbselected = count($toselect);
if ($massaction == 'set_default_account') {
if ($nbselected <= 0) {
$langs->load("errors");
@ -726,10 +727,8 @@ if ($resql) {
}
$selected = 0;
if (!empty($toselect)) {
if (in_array($product_static->id, $toselect)) {
$selected = 1;
}
if (in_array($product_static->id, $toselect)) {
$selected = 1;
}
print '<tr class="oddeven">';

View file

@ -517,7 +517,7 @@ if ($action == 'create') {
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setjournal">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1);
print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, 0, 1, 1);
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
@ -780,7 +780,7 @@ if ($action == 'create') {
} else {
print '<tr class="oddeven" data-lineid="'.((int) $line->id).'">';
print '<!-- td columns in display mode -->';
$resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true);
$resultfetch = $accountingaccount->fetch(0, $line->numero_compte, true);
print '<td>';
if ($resultfetch > 0) {
print $accountingaccount->getNomUrl(0, 1, 1, '', 0);

View file

@ -213,6 +213,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
}
$error = 0;
$result = -1; // For static analysis
$documentlink = ''; // For static analysis
$permissiontoadd = $user->hasRight('accounting', 'mouvements', 'creer');
@ -1023,6 +1025,10 @@ print "</tr>\n";
$displayed_account_number = null; // Start with undefined to be able to distinguish with empty
$objectstatic = null; // Init for static analysis
$objectlink = ''; // Init for static analysis
$result = -1; // Init for static analysis
// Loop on record
// --------------------------------------------------------------------
$i = 0;
@ -1036,6 +1042,11 @@ $totalarray['val']['totaldebit'] = 0;
$totalarray['val']['totalcredit'] = 0;
$totalarray['val']['totalbalance'] = 0;
// Init for static analysis
$colspan = 0; // colspan before field 'label of operation'
$colspanend = 0; // colspan after debit/credit
$accountg = '-';
while ($i < min($num, $limit)) {
$line = $object->lines[$i];

View file

@ -2,6 +2,7 @@
/* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro>
* Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -113,12 +114,12 @@ class AccountancyCategory // extends CommonObject
public $active;
/**
* @var array Lines cptbk
* @var Object[] Lines cptbk
*/
public $lines_cptbk;
/**
* @var array Lines display
* @var Object[] Lines display
*/
public $lines_display;
@ -133,7 +134,7 @@ class AccountancyCategory // extends CommonObject
public $sdcpermonth;
/**
* @var array Sum debit credit per account
* @var array<string,float> Sum debit credit per account
*/
public $sdcperaccount;
@ -508,8 +509,8 @@ class AccountancyCategory // extends CommonObject
/**
* Function to add an accounting account in an accounting category
*
* @param int $id_cat Id category
* @param array $cpts list of accounts array
* @param int $id_cat Id category
* @param array<string,?string> $cpts list of accounts array
*
* @return int Return integer <0 if KO, >0 if OK
*/
@ -619,11 +620,11 @@ class AccountancyCategory // extends CommonObject
/**
* Function to show result of an accounting account from the ledger with a direction and a period
*
* @param int|array $cpt Accounting account or array of accounting account
* @param int|array<?string> $cpt Accounting account or array of accounting account
* @param string $date_start Date start
* @param string $date_end Date end
* @param int $sens Sens of the account: 0: credit - debit (use this by default), 1: debit - credit
* @param string $thirdparty_code Thirdparty code
* @param int<0,1> $sens Sens of the account: 0: credit - debit (use this by default), 1: debit - credit
* @param string $thirdparty_code Third party code
* @param int $month Specific month - Can be empty
* @param int $year Specific year - Can be empty
* @return integer Return integer <0 if KO, >= 0 if OK
@ -635,8 +636,9 @@ class AccountancyCategory // extends CommonObject
$this->sdc = 0;
$this->sdcpermonth = array();
$listofaccount = '';
if (is_array($cpt)) {
$listofaccount = '';
foreach ($cpt as $cptcursor) {
if (! is_null($cptcursor)) {
if ($listofaccount) {
@ -710,7 +712,7 @@ class AccountancyCategory // extends CommonObject
* Function to get an array of all active custom groups (llx_c_accunting_categories) with their accounts from the chart of account (ll_accounting_acount)
*
* @param int $catid Custom group ID
* @return array|integer Result in table (array), -1 if KO
* @return array<string,array<int,array{id:int,code:string,label:string,position:string,category_type:string,formula:string,sens:string,account_number:string,account_label:string}>>|int<-1,-1> Result in table (array), -1 if KO
* @see getCats(), getCptsCat()
*/
public function getCatsCpts($catid = 0)
@ -837,7 +839,7 @@ class AccountancyCategory // extends CommonObject
* @param string $predefinedgroupwhere Sql criteria filter to select accounting accounts. This value must be sanitized and not come from an input of a user.
* Example: "pcg_type = 'EXPENSE' AND fk_pcg_version = 'xx'"
* Example: "fk_accounting_category = 99"
* @return array|int Array of accounting accounts or -1 if error
* @return array<array{id:int,account_number:string,account_label:string}>|int<-1,-1> Array of accounting accounts or -1 if error
* @see getCats(), getCatsCpts()
*/
public function getCptsCat($cat_id, $predefinedgroupwhere = '')

View file

@ -63,8 +63,8 @@ class AccountancyImport
/**
* Clean amount
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param array<array{val:null|int|float|string,type:int<-1,1>}> $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array<string,string> $listfields Fields list to add
* @param int $record_key Record key
* @return float Value
*/
@ -77,8 +77,8 @@ class AccountancyImport
/**
* Clean value with trim
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param array<array{val:null|int|float|string,type:int<-1,1>}> $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array<string,string> $listfields Fields list to add
* @param int $record_key Record key
* @return mixed Value
*/
@ -90,8 +90,8 @@ class AccountancyImport
/**
* Compute amount
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param array<array{val:null|int|float|string,type:int<-1,1>}> $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array<string,string> $listfields Fields list to add
* @param int $record_key Record key
* @return string Value
*/
@ -119,8 +119,8 @@ class AccountancyImport
/**
* Compute direction
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param array<array{val:null|int|float|string,type:int<-1,1>}> $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array<string,string> $listfields Fields list to add
* @param int $record_key Record key
* @return string Value
*/
@ -145,8 +145,8 @@ class AccountancyImport
/**
* Compute piece number
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param array<array{val:null|int|float|string,type:int<-1,1>}> $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array<string,string> $listfields Fields list to add
* @param int $record_key Record key
* @return string Value
*/

View file

@ -145,7 +145,7 @@ class AccountingAccount extends CommonObject
public $reconcilable;
/**
* @var array cache array
* @var array<string,int> cache array
*/
private $accountingaccount_codetotid_cache = array();
@ -729,9 +729,9 @@ class AccountingAccount extends CommonObject
* @param Product $product Product object sell or buy
* @param Facture|FactureFournisseur $facture Facture
* @param FactureLigne|SupplierInvoiceLine $factureDet Facture Det
* @param array $accountingAccount Array of Accounting account
* @param array<string,int> $accountingAccount Array of Accounting account
* @param string $type Customer / Supplier
* @return array|int Array of accounting accounts suggested or < 0 if technical error.
* @return array{suggestedaccountingaccountbydefaultfor:string,suggestedaccountingaccountfor:string,suggestedid:?int,code_l:string,code_p:string,code_t:string}|int<-1,-1> Array of accounting accounts suggested or < 0 if technical error.
* 'suggestedaccountingaccountbydefaultfor'=>Will be used for the label to show on tooltip for account by default on any product
* 'suggestedaccountingaccountfor'=>Is the account suggested for this product
*/
@ -745,6 +745,7 @@ class AccountingAccount extends CommonObject
$parameters = array('buyer' => $buyer, 'seller' => $seller, 'product' => $product, 'facture' => $facture, 'factureDet' => $factureDet ,'accountingAccount' => $accountingAccount, 0 => $type);
$reshook = $hookmanager->executeHooks('accountancyBindingCalculation', $parameters); // Note that $action and $object may have been modified by some hooks
$result = -1; // Init for static analysis
if (empty($reshook)) {
$const_name = '';
if ($type == 'customer') {

View file

@ -2,6 +2,7 @@
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2019 Cedric Ancelin <icedo.anc@gmail.com>
* Copyright (C) 2023 Lionel Vessiller <lvessiller@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -30,7 +31,7 @@ class Accountancy extends DolibarrApi
{
/**
*
* @var array $FIELDS Mandatory fields, checked when create and update object
* @var string[] $FIELDS Mandatory fields, checked when create and update object
*/
public static $FIELDS = array();
@ -40,7 +41,7 @@ class Accountancy extends DolibarrApi
public $bookkeeping;
/**
* @var AccountancyExport $accountancy_export {@type AccountancyExport}
* @var AccountancyExport $accountancyexport {@type AccountancyExport}
*/
public $accountancyexport;
@ -137,7 +138,7 @@ class Accountancy extends DolibarrApi
// set filter for each period available
$filter = array();
$doc_date_start = null;
$doc_date_end= null;
$doc_date_end = null;
$now = dol_now();
$now_arr = dol_getdate($now);
$now_month = $now_arr['mon'];
@ -173,9 +174,9 @@ class Accountancy extends DolibarrApi
$prev_month_date_list = array();
$prev_month_date_list[] = dol_get_prev_month($now_month, $now_year); // get previous month for index = 0
for ($i = 1; $i < $nb_prev_month; $i++) {
$prev_month_date_list[] = dol_get_prev_month($prev_month_date_list[$i-1]['month'], $prev_month_date_list[$i-1]['year']); // get i+1 previous month for index=i
$prev_month_date_list[] = dol_get_prev_month($prev_month_date_list[$i - 1]['month'], $prev_month_date_list[$i - 1]['year']); // get i+1 previous month for index=i
}
$doc_date_start = dol_mktime(0, 0, 0, $prev_month_date_list[$nb_prev_month-1]['month'], 1, $prev_month_date_list[$nb_prev_month-1]['year']); // first day of n previous month for index=n-1
$doc_date_start = dol_mktime(0, 0, 0, $prev_month_date_list[$nb_prev_month - 1]['month'], 1, $prev_month_date_list[$nb_prev_month - 1]['year']); // first day of n previous month for index=n-1
$doc_date_end = dol_get_last_day($prev_month_date_list[0]['year'], $prev_month_date_list[0]['month']); // last day of previous month for index = 0
} elseif ($period == 'currentyear' || $period == 'lastyear') {
$period_year = $now_year;

View file

@ -408,7 +408,7 @@ class BookKeeping extends CommonObject
$sql .= ', entity';
$sql .= ") VALUES (";
$sql .= "'".$this->db->idate($this->doc_date)."'";
$sql .= ", ".(isDolTms($this->date_lim_reglement) ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'NULL');
$sql .= ", ".(isDolTms($this->date_lim_reglement) ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'NULL');
$sql .= ", '".$this->db->escape($this->doc_type)."'";
$sql .= ", '".$this->db->escape($this->doc_ref)."'";
$sql .= ", ".((int) $this->fk_doc);
@ -839,7 +839,7 @@ class BookKeeping extends CommonObject
* @param string $sortfield Sort field
* @param int $limit limit
* @param int $offset offset limit
* @param array $filter filter array
* @param array<string,string> $filter filter array
* @param string $filtermode filter mode (AND or OR)
* @param int $option option (0: general account or 1: subaccount)
* @param int $countonly Do not fill the $object->lines, return only the count.
@ -1040,7 +1040,7 @@ class BookKeeping extends CommonObject
* @param string $sortfield Sort field
* @param int $limit Limit
* @param int $offset Offset limit
* @param string|array $filter Filter array
* @param string|array<string,string> $filter Filter array
* @param string $filtermode Filter mode (AND or OR)
* @param int $showAlreadyExportMovements Show movements when field 'date_export' is not empty (0:No / 1:Yes (Default))
* @return int Return integer <0 if KO, >0 if OK
@ -1228,7 +1228,7 @@ class BookKeeping extends CommonObject
* @param string $sortfield Sort field
* @param int $limit Limit
* @param int $offset Offset limit
* @param string|array $filter Filter
* @param string|array<string,string> $filter Filter
* @param string $filtermode Filter mode (AND or OR)
* @param int $option option (0: aggregate by general account or 1: aggreegate by subaccount)
* @return int Return integer <0 if KO, >0 if OK
@ -2180,11 +2180,11 @@ class BookKeeping extends CommonObject
*
* @param string $selectid Preselected chart of accounts
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
* @param int<0,1> $showempty Add an empty field
* @param array<array{method:string,url:string,htmlname:string,params:array<string,string>}> $event Event options
* @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
* @param string $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account starting from this number
* @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 = '')
@ -2251,7 +2251,7 @@ class BookKeeping extends CommonObject
* FIXME: This function takes the parent of parent to get the root account !
*
* @param string $account Accounting account
* @return array|int Array with root account information (max 2 upper level), <0 if KO
* @return array{id:int,account_number:string,label:string}|int<-1,-1> Array with root account information (max 2 upper level), <0 if KO
*/
public function getRootAccount($account = null)
{
@ -2565,7 +2565,7 @@ class BookKeeping extends CommonObject
*
* @param int $date_start Date start
* @param int $date_end Date end
* @return array|int Return integer <0 if KO, Fiscal periods : [[id, date_start, date_end, label], ...]
* @return array{total:int,list:array<array{year:int,count:array<int<1,12>,int>,total:int}>}|int<-1,-1> Return integer <0 if KO, Fiscal periods : [[id, date_start, date_end, label], ...]
*/
public function getCountByMonthForFiscalPeriod($date_start, $date_end)
{
@ -2790,9 +2790,11 @@ class BookKeeping extends CommonObject
$this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('Codejournal') . ' (' . $langs->trans('AccountingJournalType9') . ')';
$error++;
}
} else {
$journal = null;
}
if (!$error) {
if (!$error && is_object($journal)) {
$accounting_groups_used_for_balance_sheet_account = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT'))), 'strlen');
$accounting_groups_used_for_income_statement = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT'))), 'strlen');
@ -2886,7 +2888,7 @@ class BookKeeping extends CommonObject
if (!$error && $income_statement_amount != 0) {
$mt = $income_statement_amount;
$accountingaccount = new AccountingAccount($this->db);
$accountingaccount->fetch(null, getDolGlobalString($income_statement_amount < 0 ? 'ACCOUNTING_RESULT_LOSS' : 'ACCOUNTING_RESULT_PROFIT'), true);
$accountingaccount->fetch(0, getDolGlobalString($income_statement_amount < 0 ? 'ACCOUNTING_RESULT_LOSS' : 'ACCOUNTING_RESULT_PROFIT'), true);
$bookkeeping = new BookKeeping($this->db);
$bookkeeping->doc_date = $new_fiscal_period->date_start;

View file

@ -3,6 +3,7 @@
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -33,6 +34,9 @@ include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
*/
class Lettering extends BookKeeping
{
/**
* @var array<string,array{payment_table:string,payment_table_fk_bank:string,doc_payment_table:string,doc_payment_table_fk_payment:string,doc_payment_table_fk_doc:string,linked_info:array<array{table:string,fk_doc:string,fk_link:string,prefix:string,fk_line_link?:string,table_link_line?:string,fk_table_link_line?:string,fk_table_link_line_parent?:string,is_fk_link_is_also_fk_doc?:bool}>}>
*/
public static $doc_type_infos = array(
'customer_invoice' => array(
'payment_table' => 'paiement',
@ -289,7 +293,7 @@ class Lettering extends BookKeeping
/**
*
* @param array $ids ids array
* @param int[] $ids ids array
* @param int $notrigger no trigger
* @param bool $partial Partial lettering
* @return int
@ -316,11 +320,15 @@ class Lettering extends BookKeeping
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (empty($obj->lettering_code)) continue;
if (empty($obj->lettering_code)) {
continue;
}
// Remove normal lettering code if set partial lettering
if ($partial && preg_match('/^[A-Z]+$/', $obj->lettering_code)) {
if (!empty($obj->bookkeeping_ids)) $ids = array_diff($ids, explode(',', $obj->bookkeeping_ids));
if (!empty($obj->bookkeeping_ids)) {
$ids = array_diff($ids, explode(',', $obj->bookkeeping_ids));
}
} elseif (!$partial && preg_match('/^[a-z]+$/', $obj->lettering_code)) {
// Delete partial lettering code if set normal lettering
$sql2 = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET";
@ -427,7 +435,7 @@ class Lettering extends BookKeeping
/**
*
* @param array $ids ids array
* @param int[] $ids ids array
* @param int $notrigger no trigger
* @return int Nb of affectd rows or <0 if error
*/
@ -463,7 +471,7 @@ class Lettering extends BookKeeping
/**
* Lettering bookkeeping lines all types
*
* @param array $bookkeeping_ids Lettering specific list of bookkeeping id
* @param int[] $bookkeeping_ids Lettering specific list of bookkeeping id
* @param bool $unlettering Do unlettering
* @return int Return integer <0 if error (nb lettered = result -1), 0 if noting to lettering, >0 if OK (nb lettered)
*/
@ -495,7 +503,7 @@ class Lettering extends BookKeeping
/**
* Lettering bookkeeping lines
*
* @param array $bookkeeping_ids Lettering specific list of bookkeeping id
* @param int[] $bookkeeping_ids Lettering specific list of bookkeeping id
* @param bool $unlettering Do unlettering
* @return int Return integer <0 if error (nb lettered = result -1), 0 if noting to lettering, >0 if OK (nb lettered)
*/
@ -581,9 +589,9 @@ class Lettering extends BookKeeping
/**
* Lettering bookkeeping lines
*
* @param array $bookkeeping_ids Lettering specific list of bookkeeping id
* @param int[] $bookkeeping_ids Lettering specific list of bookkeeping id
* @param bool $only_has_subledger_account Get only lines who have subledger account
* @return array|int Return integer <0 if error otherwise all linked lines by block
* @return int<-1,-1>|array<array<int,array{id:int,piece_num:int,debit:int|float,credit:int|float,lettering_code:string}>> Return integer <0 if error otherwise all linked lines by block
*/
public function getLinkedLines($bookkeeping_ids, $only_has_subledger_account = true)
{
@ -719,8 +727,8 @@ class Lettering extends BookKeeping
/**
* Get all fk_doc by doc_type from list of bank ids
*
* @param array $bank_ids List of bank ids
* @return array|int Return integer <0 if error otherwise all fk_doc by doc_type
* @param int[] $bank_ids List of bank ids
* @return array<string,array<int,int>>|int Return integer <0 if error otherwise all fk_doc by doc_type
*/
public function getDocTypeAndFkDocFromBankLines($bank_ids)
{
@ -761,9 +769,9 @@ class Lettering extends BookKeeping
/**
* Get all bank ids from list of document ids of a type
*
* @param array $document_ids List of document id
* @param array<string,int[]> $document_ids List of document id
* @param string $doc_type Type of document ('customer_invoice' or 'supplier_invoice', ...)
* @return array|int Return integer <0 if error otherwise all all bank ids from list of document ids of a type
* @return array<int,int>|int<-1,-1> Return integer <0 if error otherwise all all bank ids from list of document ids of a type
*/
public function getBankLinesFromFkDocAndDocType($document_ids, $doc_type)
{
@ -794,6 +802,7 @@ class Lettering extends BookKeeping
$sql = "SELECT DISTINCT p." . $this->db->sanitize($doc_type_info['payment_table_fk_bank']) . " AS fk_doc";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->db->sanitize($doc_type_info['payment_table']) . " AS p";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $this->db->sanitize($doc_type_info['doc_payment_table']) . " AS dp ON dp." . $this->db->sanitize($doc_type_info['doc_payment_table_fk_payment']) . " = p.rowid";
// Implode used on array of int @phan-suppress-next-line PhanTypeMismatchArgumentInternal
$sql .= " WHERE dp." . $this->db->sanitize($doc_type_info['doc_payment_table_fk_doc']) . " IN (" . $this->db->sanitize(implode(',', $document_ids)) . ")";
$sql .= " AND p." . $this->db->sanitize($doc_type_info['payment_table_fk_bank']) . " > 0";
@ -815,9 +824,9 @@ class Lettering extends BookKeeping
/**
* Get all linked document ids by group and type
*
* @param array $document_ids List of document id
* @param int[] $document_ids List of document id
* @param string $doc_type Type of document ('customer_invoice' or 'supplier_invoice', ...)
* @return array|int Return integer <0 if error otherwise all linked document ids by group and type [ [ 'doc_type' => [ doc_id, ... ], ... ], ... ]
* @return array<int,array<int,int>>|int<-1,-1> Return integer <0 if error otherwise all linked document ids by group and type [ [ 'doc_type' => [ doc_id, ... ], ... ], ... ]
*/
public function getLinkedDocumentByGroup($document_ids, $doc_type)
{
@ -903,11 +912,11 @@ class Lettering extends BookKeeping
/**
* Get element ids grouped by link or element in common
*
* @param array $link_by_element List of payment ids by link key
* @param array $element_by_link List of element ids by link key
* @param string $link_key Link key (used for recursive function)
* @param array $current_group Current group (used for recursive function)
* @return array List of element ids grouped by link or element in common
* @param array<array<string,int>> $link_by_element List of payment ids by link key
* @param array<string,array<int,int>> $element_by_link List of element ids by link key
* @param string $link_key Link key (used for recursive function)
* @param array<int,int> $current_group Current group (used for recursive function)
* @return array<int,array<int,int>> List of element ids grouped by link or element in common
*/
public function getGroupElements(&$link_by_element, &$element_by_link, $link_key = '', &$current_group = array())
{
@ -917,8 +926,9 @@ class Lettering extends BookKeeping
return $grouped_elements;
}
if (empty($link_key)) {
// Save list when is the begin of recursive function
// Save list when is the first step of the recursive recursive function
$save_link_by_element = $link_by_element;
$save_element_by_link = $element_by_link;
}
@ -957,8 +967,8 @@ class Lettering extends BookKeeping
if (empty($link_key)) {
// Restore list when is the begin of recursive function
$link_by_element = $save_link_by_element;
$element_by_link = $save_element_by_link;
$link_by_element = $save_link_by_element; // @phan-suppress-current-line PhanPossiblyUndeclaredVariable
$element_by_link = $save_element_by_link; // @phan-suppress-current-line PhanPossiblyUndeclaredVariable
}
return $grouped_elements;

View file

@ -7,6 +7,7 @@
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -550,6 +551,8 @@ if ($result) {
$accountingaccount_codetotid_cache = array();
$suggestedaccountingaccountfor = ''; // Initialise (for static analysis)
$suggestedaccountingaccountbydefaultfor = '';
while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result);

View file

@ -113,6 +113,9 @@ $error = 0;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
$pastmonth = null; // Initialise for static analysis (could be really unseg)
$pastmonthyear = null;
if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
@ -199,6 +202,7 @@ $tmppayment = new Paiement($db);
$tmpinvoice = new Facture($db);
$accountingaccount = new AccountingAccount($db);
$account_transfer = 'NotDefined'; // For static analysis, NotDefined is a reserved word
// Get code of finance journal
$accountingjournalstatic = new AccountingJournal($db);
@ -631,19 +635,19 @@ if (!$error && $action == 'writebookkeeping' && $user->hasRight('accounting', 'b
$now = dol_now();
$accountingaccountcustomer = new AccountingAccount($db);
$accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true);
$accountingaccountcustomer->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true);
$accountingaccountsupplier = new AccountingAccount($db);
$accountingaccountsupplier->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true);
$accountingaccountsupplier->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true);
$accountingaccountpayment = new AccountingAccount($db);
$accountingaccountpayment->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true);
$accountingaccountpayment->fetch(0, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true);
$accountingaccountexpensereport = new AccountingAccount($db);
$accountingaccountexpensereport->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT, true);
$accountingaccountexpensereport->fetch(0, $conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT, true);
$accountingaccountsuspense = new AccountingAccount($db);
$accountingaccountsuspense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true);
$accountingaccountsuspense->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true);
$error = 0;
foreach ($tabpay as $key => $val) { // $key is rowid into llx_bank
@ -791,43 +795,43 @@ if (!$error && $action == 'writebookkeeping' && $user->hasRight('accounting', 'b
} elseif (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$accountingaccount->fetch(null, $k, true); // TODO Use a cache
$accountingaccount->fetch(0, $k, true); // TODO Use a cache
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'payment_vat') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$accountingaccount->fetch(null, $k, true); // TODO Use a cache
$accountingaccount->fetch(0, $k, true); // TODO Use a cache
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'payment_donation') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$accountingaccount->fetch(null, $k, true); // TODO Use a cache
$accountingaccount->fetch(0, $k, true); // TODO Use a cache
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'member') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$accountingaccount->fetch(null, $k, true); // TODO Use a cache
$accountingaccount->fetch(0, $k, true); // TODO Use a cache
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'payment_loan') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$accountingaccount->fetch(null, $k, true); // TODO Use a cache
$accountingaccount->fetch(0, $k, true); // TODO Use a cache
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'payment_various') {
$bookkeeping->subledger_account = $k;
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
$accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache
$accountingaccount->fetch(0, $tabpay[$key]["account_various"], true); // TODO Use a cache
$bookkeeping->numero_compte = $tabpay[$key]["account_various"];
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'banktransfert') {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$accountingaccount->fetch(null, $k, true); // TODO Use a cache
$accountingaccount->fetch(0, $k, true); // TODO Use a cache
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $accountingaccount->label;
} else {
@ -1097,7 +1101,7 @@ if (empty($action) || $action == 'view') {
$variousstatic = new PaymentVarious($db);
$title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1);
$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-bankjournal');
$nom = $title;
@ -1475,7 +1479,7 @@ $db->close();
/**
* Return source for doc_ref of a bank transaction
*
* @param array $val Array of val
* @param array<string,null|int|float|string> $val Array of val
* @param string $typerecord Type of record ('payment', 'payment_supplier', 'payment_expensereport', 'payment_vat', ...)
* @return string A string label to describe a record into llx_bank_url
*/

View file

@ -8,6 +8,7 @@
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018 Eric Seigne <eric.seigne@cap-rel.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -60,6 +61,13 @@ $now = dol_now();
$hookmanager->initHooks(array('expensereportsjournal'));
$parameters = array();
$taber = array(); // Initialise for static analysis
$tabht = array();
$tabtva = array();
$tabttc = array();
$tablocaltax1 = array();
$tablocaltax2 = array();
// Security check
if (!isModEnabled('accounting')) {
accessforbidden();
@ -90,6 +98,9 @@ $journal_label = $accountingjournalstatic->label;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
$pastmonth = null; // Initialise (could be unset)
$pastmonthyear = null; // Initialise (could be unset)
if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
@ -251,7 +262,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$error = 0;
$accountingaccountexpense = new AccountingAccount($db);
$accountingaccountexpense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'), true);
$accountingaccountexpense->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'), true);
foreach ($taber as $key => $val) { // Loop on each expense report
$errorforline = 0;
@ -322,7 +333,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
foreach ($tabht[$key] as $k => $mt) {
if ($mt) {
// get compte id and label
if ($accountingaccount->fetch(null, $k, true)) {
if ($accountingaccount->fetch(0, $k, true)) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
@ -523,7 +534,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
// Fees
foreach ($tabht[$key] as $k => $mt) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
$accountingaccount->fetch(0, $k, true);
if ($mt) {
print '"'.$date.'"'.$sep;
print '"'.$val["ref"].'"'.$sep;
@ -563,7 +574,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
if (empty($action) || $action == 'view') {
$title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1);
$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-expensereportsjournal');
$nom = $title;
@ -573,7 +584,7 @@ if (empty($action) || $action == 'view') {
$builddate = dol_now();
$description = $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$listofchoices = array('notyet' => $langs->trans("NotYetInGeneralLedger"), 'already' => $langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);

View file

@ -75,6 +75,17 @@ if (!$user->hasRight('accounting', 'bind', 'write')) {
$error = 0;
$tabfac = array();
$tabht = array();
$tabtva = array();
$tabttc = array();
$tablocaltax1 = array();
$tablocaltax2 = array();
$tabrctva = array();
$tabrclocaltax1 = array();
$tabrclocaltax2 = array();
$tabpay = array();
/*
* Actions
@ -93,6 +104,9 @@ $journal_label = $accountingjournalstatic->label;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
$pastmonth = null; // Initialise, could be unset
$pastmonthyear = null; // Initialise, could be unset
if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
@ -400,7 +414,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$invoicestatic = new FactureFournisseur($db);
$accountingaccountsupplier = new AccountingAccount($db);
$accountingaccountsupplier->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true);
$accountingaccountsupplier->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true);
foreach ($tabfac as $key => $val) { // Loop on each invoice
$errorforline = 0;
@ -614,7 +628,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) {
$accountingaccount->fetch(null, $k, true); // TODO Use a cache for label
$accountingaccount->fetch(0, $k, true); // TODO Use a cache for label
$label_account = $accountingaccount->label;
$bookkeeping = new BookKeeping($db);
@ -833,7 +847,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
// Product / Service
foreach ($tabht[$key] as $k => $mt) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
$accountingaccount->fetch(0, $k, true);
//if ($mt) {
print '"'.$key.'"'.$sep;
print '"'.$date.'"'.$sep;
@ -929,7 +943,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
if (empty($action) || $action == 'view') {
$title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1);
$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-purchasesjournal');
$nom = $title;

View file

@ -77,6 +77,14 @@ if (!$user->hasRight('accounting', 'bind', 'write')) {
$error = 0;
$tabfac = array();
$tabht = array();
$tabtva = array();
$tabwarranty = array();
$tabttc = array();
$tablocaltax1 = array();
$tablocaltax2 = array();
/*
* Actions
@ -95,6 +103,9 @@ $journal_label = $accountingjournalstatic->label;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
$pastmonth = null; // Initialise, could be unset
$pastmonthyear = null; // Initialise, could be unset
if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
@ -427,10 +438,10 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
$invoicestatic = new Facture($db);
$accountingaccountcustomer = new AccountingAccount($db);
$accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true);
$accountingaccountcustomer->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true);
$accountingaccountcustomerwarranty = new AccountingAccount($db);
$accountingaccountcustomerwarranty->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'), true);
$accountingaccountcustomerwarranty->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'), true);
foreach ($tabfac as $key => $val) { // Loop on each invoice
$errorforline = 0;
@ -670,7 +681,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) {
$accountingaccount->fetch(null, $k, true); // TODO Use a cache for label
$accountingaccount->fetch(0, $k, true); // TODO Use a cache for label
$label_account = $accountingaccount->label;
$bookkeeping = new BookKeeping($db);
@ -731,7 +742,7 @@ if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'b
if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
foreach ($tabrevenuestamp[$key] as $k => $mt) {
if ($mt) {
$accountingaccount->fetch(null, $k, true); // TODO Use a cache for label
$accountingaccount->fetch(0, $k, true); // TODO Use a cache for label
$label_account = $accountingaccount->label;
$bookkeeping = new BookKeeping($db);
@ -922,7 +933,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
// Product / Service
foreach ($tabht[$key] as $k => $mt) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
$accountingaccount->fetch(0, $k, true);
//if ($mt) {
print '"'.$key.'"'.$sep;
print '"'.$date.'"'.$sep;
@ -997,7 +1008,7 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 !
if (empty($action) || $action == 'view') {
$title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1);
$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-sellsjournal');
$nom = $title;

View file

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2021-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -61,6 +62,9 @@ $parameters = array();
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
$pastmonth = null; // Initialise, could be unset
$pastmonthyear = null; // Initialise, could be unset
if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
@ -196,7 +200,7 @@ if ($object->nature == 2) {
}
$title = $langs->trans("GenerationOfAccountingEntries") . ' - ' . $object->getNomUrl(0, 2, 1, '', 1);
$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-variousjournal');
$nom = $title;

View file

@ -7,6 +7,7 @@
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -561,6 +562,8 @@ if ($result) {
$accountingaccount_codetotid_cache = array();
$suggestedaccountingaccountfor = '';
$suggestedaccountingaccountbydefaultfor = '';
while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result);

View file

@ -73,15 +73,15 @@ class FormAccounting extends Form
/**
* Return list of journals with label by nature
*
* @param string $selectid Preselected journal code
* @param string $htmlname Name of field in html form
* @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
* @param int $showempty Add an empty field
* @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code
* @param int $select_out Set value returned by select. 0=rowid (default), 1=code
* @param string $morecss More css non HTML object
* @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
* @param int $disabledajaxcombo Disable ajax combo box.
* @param string $selectid Preselected journal code
* @param string $htmlname Name of field in html form
* @param int<0,9> $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
* @param int<0,1> $showempty Add an empty field
* @param int<0,1> $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code
* @param int<0,1> $select_out Set value returned by select. 0=rowid (default), 1=code
* @param string $morecss More css non HTML object
* @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
* @param int<0,1> $disabledajaxcombo Disable ajax combo box.
* @return string|int String with HTML select, or -1 if error
*/
public function select_journal($selectid, $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '', $disabledajaxcombo = 0)

View file

@ -445,7 +445,7 @@ function ajax_dialog($title, $message, $w = 350, $h = 150)
* TODO: It is used when COMPANY_USE_SEARCH_TO_SELECT and CONTACT_USE_SEARCH_TO_SELECT are set by html.formcompany.class.php. Should use ajax_autocompleter instead like done by html.form.class.php for select_produits.
*
* @param string $htmlname Name of html select field ('myid' or '.myclass')
* @param array $events More events option. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param array<array{method:string,url:string,htmlname:string,params:array<string,string>}> $events More events option. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param int $minLengthToAutocomplete Minimum length of input string to start autocomplete
* @param int $forcefocus Force focus on field
* @param string $widthTypeOfAutocomplete 'resolve' or 'off'

View file

@ -194,9 +194,10 @@ class Projects extends DolibarrApi
* @param int $category Use this param to filter list by category
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
* @return array Array of project objects
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '', $properties = '')
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '', $properties = '', $pagination_data = false)
{
if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
throw new RestException(403);
@ -244,6 +245,9 @@ class Projects extends DolibarrApi
}
}
//this query will return total orders with the filters given
$sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -273,6 +277,23 @@ class Projects extends DolibarrApi
throw new RestException(503, 'Error when retrieve project list : '.$this->db->lasterror());
}
//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
if ($pagination_data) {
$totalsResult = $this->db->query($sqlTotals);
$total = $this->db->fetch_object($totalsResult)->total;
$tmp = $obj_ret;
$obj_ret = [];
$obj_ret['data'] = $tmp;
$obj_ret['pagination'] = [
'total' => (int) $total,
'page' => $page, //count starts from 0
'page_count' => ceil((int) $total / $limit),
'limit' => $limit
];
}
return $obj_ret;
}