Add percentage diff column and price floor based on current price

Changes:
- Added "% Diff" column showing percentage difference between your price and suggested
- Changed minimum price logic: uses "Current Price - Margin%" instead of cost-based
- Updated settings description to explain the new logic
- Example: With 10% margin, €100 product won't be suggested below €90

This works better for stores without cost data - protects against excessive price drops.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-23 18:42:00 +01:00
parent b07810a88e
commit 12d96caf0c
2 changed files with 42 additions and 17 deletions

View File

@@ -307,19 +307,19 @@
var suggestedPrice = product.suggested_price ? data.currency + parseFloat(product.suggested_price).toFixed(2) : '-';
var priceLabel = product.price_type === 'sale' ? ' <small>(sale)</small>' : '';
// Gain/loss styling
var gainHtml = '-';
var gainStyle = '';
if (product.potential_gain !== null) {
var gain = parseFloat(product.potential_gain);
if (gain > 0) {
gainHtml = '+' + data.currency + gain.toFixed(2);
gainStyle = 'color: #00a32a; font-weight: bold;';
} else if (gain < 0) {
gainHtml = '-' + data.currency + Math.abs(gain).toFixed(2);
gainStyle = 'color: #d63638;';
// Percentage difference styling
var percentDiffHtml = '-';
var percentDiffStyle = '';
if (product.percent_diff !== null) {
var pct = parseFloat(product.percent_diff);
if (pct > 0) {
percentDiffHtml = '+' + pct.toFixed(1) + '%';
percentDiffStyle = 'color: #00a32a; font-weight: bold;';
} else if (pct < 0) {
percentDiffHtml = pct.toFixed(1) + '%';
percentDiffStyle = 'color: #d63638;';
} else {
gainHtml = data.currency + '0.00';
percentDiffHtml = '0%';
}
}
@@ -351,7 +351,7 @@
html += '<td><a href="post.php?post=' + product.id + '&action=edit" title="SKU: ' + product.sku + '">' + self.truncate(product.name, 40) + '</a></td>';
html += '<td>' + localPrice + priceLabel + '</td>';
html += '<td>' + suggestedPrice + '</td>';
html += '<td style="' + gainStyle + '">' + gainHtml + '</td>';
html += '<td style="' + percentDiffStyle + '">' + percentDiffHtml + '</td>';
html += '<td style="' + imprStyle + '">' + imprChange + '</td>';
html += '<td style="' + clickStyle + '">' + clickChange + '</td>';
html += '<td style="' + convStyle + '">' + convChange + '</td>';