Skip to content

Conversation

@SylvainLegrand
Copy link
Contributor

use of "MAIN_CHECKBOX_LEFT_COLUMN"
fix calculation of best supplier price

use of "MAIN_CHECKBOX_LEFT_COLUMN"
fix calculation of best supplier price
Copilot AI review requested due to automatic review settings November 13, 2025 14:38
@the-dolibear-bot-for-v18 the-dolibear-bot-for-v18 bot added the Issue for v18 maintenance Team PR is in a maintenance branch with several approvers. Waiting approval of all of them. label Nov 13, 2025
SylvainLegrand added a commit to InfraS-SARL/Easya-dolibarr that referenced this pull request Nov 13, 2025
Dolibarr#36245
use of "MAIN_CHECKBOX_LEFT_COLUMN"
fix calculation of best supplier price
Copilot finished reviewing on behalf of SylvainLegrand November 13, 2025 14:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR backports two fixes from v22: (1) support for the MAIN_CHECKBOX_LEFT_COLUMN configuration to move action/checkbox columns to the left side of tables, and (2) correction of the best supplier price calculation to properly account for discounts when finding the minimum price.

  • Added support for MAIN_CHECKBOX_LEFT_COLUMN configuration option to position action columns on the left side of supplier price tables
  • Fixed best supplier price calculation to compare discounted unit prices instead of base unit prices
  • Added explicit float casts to price calculations for better type safety

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
htdocs/product/fournisseurs.php Implements conditional rendering of action/checkbox columns based on MAIN_CHECKBOX_LEFT_COLUMN configuration, allowing columns to appear on either left or right side of the supplier prices table
htdocs/fourn/class/fournisseur.product.class.php Fixes supplier price comparison logic to use $fourn_unitprice_with_discount instead of $fourn_unitprice, ensuring discounts are properly considered when finding the minimum price

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="center nowraponall">';
if ($usercancreate) {
print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?id='.((int) $object->id).'&socid='.((int) $productfourn->fourn_id).'&action=edit_price&token='.newToken().'&rowid='.((int) $productfourn->product_fourn_price_id).'">'.img_edit()."</a>";
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

The action parameter should be update_price instead of edit_price. The correct action is update_price as shown in the right column implementation (line 1314) and as handled by the form processing logic (line 474 where $action == 'update_price' is checked).

Suggested change
print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?id='.((int) $object->id).'&socid='.((int) $productfourn->fourn_id).'&action=edit_price&token='.newToken().'&rowid='.((int) $productfourn->product_fourn_price_id).'">'.img_edit()."</a>";
print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?id='.((int) $object->id).'&socid='.((int) $productfourn->fourn_id).'&action=update_price&token='.newToken().'&rowid='.((int) $productfourn->product_fourn_price_id).'">'.img_edit()."</a>";

Copilot uses AI. Check for mistakes.
@rycks
Copy link
Contributor

rycks commented Nov 20, 2025

i'm sorry @SylvainLegrand but we can't accept that PR : please split your contribution in two parts: one for MAIN_CHECKBOX_LEFT_COLUMN and an other one for calculation of best supplier price

thanks,
Éric

@rycks rycks added the PR to split into several PRs PR is too large or not "atomic" on feature. Please try to push it in several independent PR. label Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue for v18 maintenance Team PR is in a maintenance branch with several approvers. Waiting approval of all of them. PR to split into several PRs PR is too large or not "atomic" on feature. Please try to push it in several independent PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants