calculateBalanceForProductBefore() cast the SUM of stock movement values
to (int), which truncated the fractional part. For products tracked in
fractional units (kg, liters, ...), the before/after period stock balance
displayed in the stock movement list (product/stock/movement_list.php) was
wrong (for example a real balance of 10.5 was shown as 10).
Cast the computed balance to (float) instead and update the method return
type accordingly.
Add a PHPUnit test (MouvementStockTest::testCalculateBalanceForProductBefore)
that records a fractional reception and checks the returned balance is not
truncated.
* opérations CRUD du modèle DiscountAbsolute
* taux de taxes locales et types ajoutés au modèle
* canvas et méthode paramétrées pour test unitaires
* test création et lecture OK
* #37423 - DiscountAbsolute model refactor to have localtaxes on a remise - unit tests completed
* phpcs
* remove comment
* phpcs local
* remove attributes in favor of parent
* phpstan - type de données et correction tests unitaires
* typage des retours
* .
* exceptions Phan sur test unitaire
* commentaire de fonction bien formatté
* directives phan depuis CommonClassTest
* avertissements phan
* removing localtaxes from multicurrency attributes as not supported by data model
* interface testing from ThirdParty comm/remx.php with added multicurrency ttc support
* phpcs OK
* phan typage
* merci phan
* buyer / seller roles of thirdparty integrity
* attribute typo in fetch
* setabsolutediscount and converttoreduc controller actions take into account localtaxes
* usage of localtaxes for discounts in objects
* phpcs
* stan typing
* integrity of multicurrency for generated credit note from supplier invoice
htdocs/core/actions_massactions.inc.php:1060-1140 wrapped all selected
records in a single begin/commit so a mid-loop failure rolled back
records that had already validated. For modules that side-effect on
validate (VeriFactu / AEAT push, e-invoice gateways), the side effect
cannot be reverted alongside the local rollback, leaving the local DB
and the external system out of sync.
Add a hidden constant MAIN_MASSVALIDATE_<OBJECTCLASS>_NO_GLOBAL_TRANSACTION
that, when set to 1, moves the begin/commit pair inside the loop so each
record is its own atomic unit. The constant is per-objectclass per eldy's
review on the issue, so it can be enabled by the module on the page that
needs it (e.g. MAIN_MASSVALIDATE_FACTURE_NO_GLOBAL_TRANSACTION on the
customer invoice list) without affecting other mass-validate pages.
Default behavior is unchanged: with no constant set, the original
all-or-nothing transaction stays in place.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
htdocs/datapolicy/class/datapolicycron.class.php:378 skipped the row as soon
as isObjectUsed() returned non-zero, regardless of whether the cron loop was
running the delete or anonymize action. isObjectUsed() on Societe is true as
soon as a quote, order, contract, intervention, shipment, etc. points at the
record - all things that are legitimately kept under accounting / commercial
retention while the personal data on the thirdparty itself must still be
erasable under GDPR.
Apply the guard only for action='delete' (where referential integrity is at
stake). Anonymization runs to completion regardless of attached commercial
documents.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
The SELECT of ExpenseReportLine::fetch() was missing a comma after the
"tcheck_file" column. The concatenated SQL became
"... tcheck_file pjt.rowid as projet_id ..." which is a syntax error, so
the query always failed and fetch() returned -1.
This broke loading a single expense report line, both in the UI (confirm
delete line in expensereport/card.php) and in the REST API
(PUT /expensereports/{id}/lines/{lineid}).
The column is now also qualified with its table alias (fde.) for
consistency with the other columns of the SELECT.
Add a PHPUnit test (ExpenseReportTest::testExpenseReportLineFetch) that
creates an expense report with a line and reloads it: it fails before
the fix and passes after.
PHPStan level 9 (apstats config) reports at htdocs/cron/list.php:363:
"Variable $filter might not be defined."
$filter was only initialized inside the "if (empty($reshook))" Actions
block, but it is used unconditionally later to build the SQL WHERE clause.
When a hook intercepts the Actions section ($reshook not empty), $filter
stayed undefined. Initialize it with the other search criteria so it is
always defined.
As $filter is now always an array, the "is_array($filter)" guard becomes
redundant (it would raise a level 10 'always evaluate to true' warning),
so the condition is simplified to "count($filter) > 0". No behaviour change.
Co-authored-by: Muvikx <kilyan.cotten@epitech.eu>
PHPStan level 9 (apstats config) reports at htdocs/core/lib/bank.lib.php:465:
"Variable $s might not be defined."
The variable $s was initialized inside the for() init expression
(for ($i = 0, $s = 0; ...)). As the apstats ruleset sets
polluteScopeWithLoopInitialAssignments: false, the assignment is not
seen as defined after the loop, where $s is used to compute the RIB key.
Moved the $s = 0 initialization just before the loop. No behaviour change.
Co-authored-by: Muvikx <kilyan.cotten@epitech.eu>
PHPStan level 9 (apstats config) reports at line 135:
"Variable $maxlength might not be defined."
$maxlength was never defined in this file and was passed as the 4th
argument (max label length) of FormProjets::select_projects(). An
undefined variable evaluates to null, and dol_trunc() returns the string
unchanged when its size argument is empty (null or 0). Passing 0
explicitly keeps the exact same behaviour (no truncation) and removes
the undefined-variable warning.
Co-authored-by: Muvikx <kilyan.cotten@epitech.eu>
PHPStan level 9 (apstats config) reports at line 444:
"Variable $maxlength might not be defined."
$maxlength was never defined in this file and was passed as the 4th
argument (max label length) of FormProjets::select_projects(). An
undefined variable evaluates to null, and dol_trunc() returns the string
unchanged when its size argument is empty (null or 0). Passing 0
explicitly keeps the exact same behaviour (no truncation) and removes
the undefined-variable warning.
Co-authored-by: Muvikx <kilyan.cotten@epitech.eu>
PHPStan level 9 (apstats config) reports at line 159:
"Variable $maxlength might not be defined."
$maxlength was never defined in this file and was passed as the 4th
argument (max label length) of FormProjets::select_projects(). An
undefined variable evaluates to null, and dol_trunc() returns the string
unchanged when its size argument is empty (null or 0). Passing 0
explicitly keeps the exact same behaviour (no truncation) and removes
the undefined-variable warning.
Co-authored-by: Muvikx <kilyan.cotten@epitech.eu>
PHPStan level 9 (apstats config) reports at line 233:
"Variable $maxlength might not be defined."
$maxlength was never defined in this file and was passed as the 4th
argument (max label length) of FormProjets::select_projects(). An
undefined variable evaluates to null, and dol_trunc() returns the string
unchanged when its size argument is empty (null or 0). Passing 0
explicitly keeps the exact same behaviour (no truncation) and removes
the undefined-variable warning.
Co-authored-by: Muvikx <kilyan.cotten@epitech.eu>
PHPStan level 9 (apstats config) reports at line 544:
"Variable $maxlength might not be defined."
$maxlength was never defined in this standalone page and was passed as
the 4th argument (max label length) of FormProjets::select_projects().
An undefined variable evaluates to null, and dol_trunc() returns the
string unchanged when its size argument is empty (null or 0). Passing 0
explicitly keeps the exact same behaviour (no truncation) and removes
the undefined-variable warning.
Co-authored-by: Muvikx <kilyan.cotten@epitech.eu>
PHPStan level 9 (apstats config) reports at line 1206:
"Variable $maxlength might not be defined."
$maxlength was never defined in this standalone page and was passed as
the 4th argument (max label length) of FormProjets::select_projects().
An undefined variable evaluates to null, and dol_trunc() returns the
string unchanged when its size argument is empty (null or 0). Passing 0
explicitly keeps the exact same behaviour (no truncation) and removes
the undefined-variable warning.
Co-authored-by: Muvikx <kilyan.cotten@epitech.eu>
PHPStan level 9 (apstats config) reports at line 244:
"Variable $backtopageforcancel might not be defined."
The page reads $backtopage from GETPOST and prints both a 'backtopage'
and a 'backtopageforcancel' hidden field, but $backtopageforcancel was
never read from the request, so it was always undefined.
Add the standard $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
line next to $backtopage, matching the canonical pattern used in
product/card.php and societe/card.php.
Co-authored-by: Muvikx <kilyan.cotten@epitech.eu>
PHPStan level 9 (apstats config) reports at line 836:
"Variable $selected might not be defined."
In the Kanban output, $selected was only defined inside the
"if ($massactionbutton || $massaction)" block, but it is always passed
to getKanbanView(). Initialize $selected = 0 before that block; 0 is the
exact value getKanbanView() falls back to when 'selected' is empty/absent
($selected = empty($arraydata['selected']) ? 0 : ...), so behaviour is
unchanged.
Phan reports at lines 808-809:
"Assigning $obj->status of type string to property but User->status/statut is int".
$obj->status comes from the SQL alias 'u.statut as status' (an int column
returned as a string by the DB layer) and is assigned to the int-typed
User::$status / User::$statut properties. Cast it to (int).
Co-authored-by: Muvikx <kilyan.cotten@epitech.eu>
* WIP AI design
- Chat Interface
- French Translation
* AI Home Screen
Added a home page for the AI assistant, with pre-recorded prompts
* Fix missing user
* Add copyright
* Fix working tools and alignment
Switch four list endpoints that still used the legacy DolibarrApi::_checkFilters
+ bare preg_replace_callback path to the hardened forgeSQLFromUniversalSearchCriteria()
already used by the rest of the same files. The legacy path only validated
parenthesis balance and concatenated non-matching text verbatim into the WHERE
clause, while the hardened path applies the dummy-criteria syntax check first.
Endpoints touched:
- htdocs/api/class/api_setup.class.php getListOfRegions
- htdocs/api/class/api_setup.class.php getListOfIncoterms
- htdocs/api/class/api_setup.class.php getListOfVAT
- htdocs/multicurrency/class/api_multicurrencies.class.php index
See #38768 for the report.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
CommandeFournisseur::addline rounds the line quantity to the next packaging
multiple but never enforces pfp.quantity (the supplier minimum purchase
quantity). A line with packaging=3 and qty_min=15 could therefore be saved
at qty=6 (only multiple of packaging) - the user-facing scenario from
#38783 with the table of expected vs actual values.
Two small changes:
1. htdocs/product/class/product.class.php get_buyprice() already maintains
$prod_supplier->fourn_qty for the dynamic-price code path at lines 2622
and 2691 but never propagates the same value to $this->fourn_qty (which
is the public property documented as MOQ at line 738). Assign $this->fourn_qty
in both branches of get_buyprice so callers can read it after the call.
2. htdocs/fourn/class/fournisseur.commande.class.php addline now applies a
second rounding pass against $prod->fourn_qty after the packaging multiple
step. If qty is still below qty_min, round qty_min up to the next packaging
multiple - the smallest qty that satisfies both constraints simultaneously.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
When PRODUCT_USE_CUSTOMER_PACKAGING / PRODUCT_USE_SUPPLIER_PACKAGING are
enabled, the four order line methods (Commande::addline, Commande::updateline,
CommandeFournisseur::addline, CommandeFournisseur::updateline) recompute the
quantity to the next packaging multiple. Reporter audited the four code paths
and listed six divergences between them; the customer addline at
htdocs/commande/class/commande.class.php:1720 is the reference and the rest
were re-aligned on it:
- Bug 1: supplier addline did not call setEventMessages() when qty < packaging,
so the user was silently corrected (htdocs/fourn/class/fournisseur.commande.class.php:2153).
- Bug 2: supplier addline used a raw float multiplication; switch to price2num('MS').
- Bug 3: supplier updateline used 'fmod() > 0' which is vulnerable to float
noise (fmod(3.0, 1.5) can yield 4.44e-16); switch to price2num((float) ..., 'MS').
- Bug 4: supplier updateline missed the qty < packaging notification.
- Bug 5: both updateline paths missed abs() in coeff = intval(qty / packaging) + 1,
which broke rounding for negative qty; the addline paths already do abs().
- Bug 6: supplier path used setEventMessages('mesgs') (green/info); the user
feedback is a corrected input, semantically a warning. Switch to 'warnings'
to match the customer path.
No behavior change for callers passing positive, valid quantities; the diff
only affects edge cases (negative qty, qty just under packaging, float-fmod
noise) and the message channel.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
htdocs/modulebuilder/index.php:1859 ran strtolower() on the raw form value
$proptype before storing it back into the object's field definition. That
lower-cased composite types like
'integer:Societe:societe/class/societe.class.php:1:(...__SHARED_ENTITIES__...)'
into 'integer:societe:...:(...__shared_entities__...)'. Two breakages from
that single transform:
1. PHP class names are case-sensitive on case-sensitive filesystems; 'societe'
then fails to instantiate where 'Societe' worked.
2. Substitution tokens such as __SHARED_ENTITIES__ are matched verbatim by
the entity filter; once lower-cased they no longer match.
Only lowercase truly atomic types ('Integer' -> 'integer', 'TEXT' -> 'text').
For anything containing ':' or '_' (composite spec, substitution token) keep
the user-typed casing.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
htdocs/product/inventory/inventory.php:264 wrote into llx_product_perentity
under MAIN_PRODUCT_PERENTITY_SHARED, but Product::fetch at line 2995-2997
of htdocs/product/class/product.class.php only reads pmp from that table when
both MULTICOMPANY_PRODUCT_SHARING_ENABLED and MULTICOMPANY_PMP_PER_ENTITY_ENABLED
are set. MAIN_PRODUCT_PERENTITY_SHARED is the accountancy-codes flag; using
it to gate the pmp write meant inventory wrote a value that fetch would
silently ignore (and overwriting whatever was there before).
Align the inventory write with the fetch read so the two stay in sync.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
htdocs/projet/element.php:1075 unconditionally negates total_ht / total_ttc for
commande_fournisseur and supplier_proposal rows. A few lines below at 1095 the
margin block also negates when $margin === 'minus'.
The default 'order_supplier' entry in $listofreferent ships without a margin
key, so users opt it into the profit calculation via
PROJECT_ELEMENTS_FOR_MINUS_MARGIN=order_supplier. The PROJECT_ELEMENTS_FOR_MINUS_MARGIN
loop at line 819 then sets $margin='minus' for that key, and both negations
fire on the same value - the supplier total flows into balance_ht as a positive
amount instead of being subtracted, which matches the symptom in the screenshot.
Skip the line-level negation when the margin block will take care of it.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>