getElementProperties() is the central registry used across the
codebase (fetchObjectByElement(), generic links/extrafields, document
generation...) to resolve an element type string into its module,
classpath, classfile, classname, table and parent element, but it had
no test coverage despite being a ~480 line function with about 60
special-case branches plus several generic fallback paths.
Covers the representative paths rather than every branch:
- the generic completion of classfile/classname from subelement
(project)
- the 'myobject@mymodule' external-module syntax, including the
surprising fact that table_element keeps the raw '@'-string
- the 'myobject_mysubobject' syntax combined with a dedicated case
branch overriding module (project_task)
- the generic '...det' object-line fallback for an unknown module,
including the non-capitalized classname it produces (myobjectdet)
- a real '...det' case where the generic fallback runs first and a
dedicated branch only adds parent_element on top (contratdet)
- a real '...det' case where the dedicated branch instead overrides
classpath and classname set by the generic fallback (facturedet)
- the action/actioncomm special case, where table_element differs
from the raw input element
These are two of the most heavily used display functions in the whole
codebase (every page showing an amount or a date calls one of them),
yet neither had any test coverage.
testPrice covers: default rounding (min of MAIN_MAX_DECIMALS_UNIT/TOT),
keeping extra decimals present in the input, en_US vs fr_FR separators,
HTML mode ( ), international separators via $outlangs='none',
forcerounding (explicit decimal count and 'MU'), and currency symbol
placement (before for USD, after for EUR).
testDolPrintDate covers: empty input returning '', timestamp 0 being a
valid date, the language-independent format shortcuts (dayrfc,
standard, dayhourrfc, dayhourlog), a literal strftime-style format
string, and tzoutput=true (GMT) vs tzoutput=false (server TZ, forced
to UTC for the comparison) producing the same result.
testIsValidMXRecord() does a real live DNS lookup via
isValidMXRecord(), which is inherently CI-environment dependent. In a
recent Travis run, the assertion for usace.army.mil (result expected
1) failed while the other three domains in the same test resolved
correctly, indicating the .mil zone specifically was filtered/
unreachable from that CI network rather than any bug in
isValidMXRecord() itself - .mil DNS is a known target for network
filtering on shared CI infrastructure.
Replace it with microsoft.com, which has the same "domain with a
valid MX record" semantics but a far more globally reachable, stable
DNS setup less likely to be blocked by CI network policies.
The substr offsets in dol_print_phone did not line up with the segment
lengths, so formatted numbers repeated one digit and lost another.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
get_default_tva() VATRULE 2 selects the VAT rate attached to the buyer
department (c_tva.fk_department_buyer) but filters only on the department id.
Unlike get_product_vat_for_country(), it omits t.active and t.entity, so a
disabled rate (or a rate from another entity) can be returned as the default,
and because of the taux DESC ordering an inactive higher rate wins over the
active one.
Add "AND t.active > 0" and "AND t.entity IN (getEntity('c_tva'))" to the query.
The ordering is unchanged, so the documented behaviour is preserved: the rate
flagged Default (use_default) wins, otherwise the highest active rate.
Add testGetDefaultTvaForBuyerState() covering VATRULE 2, which was previously
untested: it asserts the active department rate is selected and the inactive
one is ignored.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* Qual: Add testcase for price2num to convert '21.500,00' in FR
* NEW: Accept numbers like 1.213,00 in locales with whitespace/empty thousands separator
# NEW: Accept numbers like 1.213,00 in locales with whitespace/empty thousands separator
- Graceful handling of comma and dot as decimal points and thousands separators in the `price2num` function.
- Improved the `getNonEmptyString` function to include proper indentation and spacing (automatic).
* Add testcases for price2num
* en_US tests for invalid prices, add doc for price2num regex
* Restore lost test to validate compatibility
* Update FunctionsLibTest.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>