feat: Show product margin in history price changes table

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Eduard Wisch 2026-03-17 14:48:38 +01:00
parent 91c1ddd919
commit aa363920f9

View file

@ -169,12 +169,13 @@ if ($filter > 0) {
}
$sql = "SELECT pp.rowid, pp.fk_product, pp.date_price, pp.price, pp.price_ttc, pp.tva_tx, pp.price_base_type,";
$sql .= " p.ref, p.label as product_label,";
$sql .= " p.ref, p.label as product_label, pe.preisbot_margin,";
$sql .= " (SELECT pp2.price FROM ".MAIN_DB_PREFIX."product_price pp2";
$sql .= " WHERE pp2.fk_product = pp.fk_product AND pp2.date_price < pp.date_price";
$sql .= " ORDER BY pp2.date_price DESC LIMIT 1) as old_price";
$sql .= " FROM ".MAIN_DB_PREFIX."product_price pp";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = pp.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields pe ON pe.fk_object = pp.fk_product";
$sql .= " WHERE pp.price_label = 'Preisbot'";
$sql .= $sqlFilter;
$sql .= " ORDER BY pp.date_price DESC";
@ -190,6 +191,7 @@ if ($resql && $db->num_rows($resql) > 0) {
print '<th class="right">'.$langs->trans("PreviousPrice").'</th>';
print '<th class="right">'.$langs->trans("NewPrice").'</th>';
print '<th class="right">'.$langs->trans("Diff").'</th>';
print '<th class="right">'.$langs->trans("PreisBotMinMargin").'</th>';
print '<th class="right">'.$langs->trans("VAT").'</th>';
print '</tr>';
@ -215,6 +217,7 @@ if ($resql && $db->num_rows($resql) > 0) {
print '<td class="right opacitymedium">'.(!is_null($oldPrice) ? number_format($oldPrice, 2, ',', '.').' €' : '-').'</td>';
print '<td class="right"><strong>'.number_format($newPrice, 2, ',', '.').' €</strong></td>';
print '<td class="right"'.$diffClass.'>'.$diffStr.'</td>';
print '<td class="right">'.(!is_null($obj->preisbot_margin) ? number_format((float)$obj->preisbot_margin, 0).' %' : '-').'</td>';
print '<td class="right">'.number_format((float)$obj->tva_tx, 0).' %</td>';
print '</tr>';
}