Skip to content

Calculate potential kits stock from components#38012

Open
edupulpillo wants to merge 18 commits intoDolibarr:developfrom
edupulpillo:develop
Open

Calculate potential kits stock from components#38012
edupulpillo wants to merge 18 commits intoDolibarr:developfrom
edupulpillo:develop

Conversation

@edupulpillo
Copy link
Copy Markdown
Contributor

@edupulpillo edupulpillo commented Apr 27, 2026

Added calculation for potential kits stock based on component quantities and available stock displayed at the bottom of the components list

Fix #38010

[The stock qty of product-kits are not displayed neither in the product sheet or the kit Tab with the list of components]

Added calculation for potential kits stock based on component quantities and available stock displayed at the bottom of the components list
Copy link
Copy Markdown
Contributor Author

@edupulpillo edupulpillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation fix

Copy link
Copy Markdown
Contributor Author

@edupulpillo edupulpillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation fix

Copy link
Copy Markdown
Contributor Author

@edupulpillo edupulpillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Calculate potential kits stock from components

type mitsmatch fix
Comment thread htdocs/product/composition/card.php Outdated
$colspan_counter = null;
print '<tr class="total-row right">';
print '<td></td><td></td><td></td>';
print '<td colspan="' . ($colspan_counter + 4) . '" class="titlefield">' . $langs->trans("PotentialKitsFromStock") . '</td>';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: there are several methods to potentially fix the phan error

card.php: PhanTypeInvalidLeftOperandOfAdd: Invalid operator: left operand of + is null (expected array or number)

You could use The PHP ternary operator to make a 1 liner, and I would make that line just before using the variable `colspan_counter``

Something like

$colspan_counter = (is_null($colspan_counter) ? (0) : ($colspan_counter);
print '<td colspan="' . ($colspan_counter + 4) . '" class="titlefield">' . $langs->trans("PotentialKitsFromStock") . '</td>';

But it may just be much more interesting to figure out why $colspan_counter was null to begin with.

Copy link
Copy Markdown
Contributor Author

@edupulpillo edupulpillo Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$colspan_counter in null only about my ignorance. Should i assign a value = 0 (integer) am i right ?
So now your review is not needed anymore. Kindly accept the latest version, it pased already allt he tests of code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edupulpillo I am not sure what the colspan_counter is for, but if you want to do addition, then starting with 0 is a good bet, but if you only do the addition once - why even have a variable?

Copy link
Copy Markdown
Contributor Author

@edupulpillo edupulpillo Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, better to use a constant

So now your review is not needed anymore. Kindly accept the latest version, it pased already allt he tests of code. Please complete your review is not possible to cancel a request review accidentally requested

Comment thread htdocs/product/composition/card.php
Copy link
Copy Markdown
Contributor Author

@edupulpillo edupulpillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

potential_kit_stock = 0 instead null

@edupulpillo edupulpillo marked this pull request as draft April 28, 2026 16:57
@edupulpillo edupulpillo marked this pull request as ready for review April 28, 2026 20:29
@edupulpillo edupulpillo marked this pull request as draft April 30, 2026 17:11
@edupulpillo edupulpillo marked this pull request as ready for review April 30, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The stock qty of product-kits are not displayed neither in the product sheet or the kit Tab with the list of components

3 participants