feat: profils par défaut par client + fix marge 0% + fix: suggest-slot ignore les créneaux déjà passés
Deploy via Portainer / deploy (push) Successful in 0s
Deploy via Portainer / deploy (push) Successful in 0s
This commit is contained in:
+24
-8
@@ -328,14 +328,30 @@ document.getElementById('pricingProfileSelect').addEventListener('change', funct
|
||||
}
|
||||
});
|
||||
|
||||
// ── Client : auto-remplir DM ──────────────────────────────────────────────────
|
||||
// ── Client : auto-remplir profils par défaut ─────────────────────────────────
|
||||
document.getElementById('clientSelect').addEventListener('change', function() {
|
||||
const dm = this.options[this.selectedIndex].dataset.dm;
|
||||
if (dm) {
|
||||
document.getElementById('design_multiplier').value = parseFloat(dm);
|
||||
updateDMLabel(parseFloat(dm));
|
||||
recalc();
|
||||
}
|
||||
const clientId = this.value;
|
||||
if (!clientId) return;
|
||||
fetch('/api/client/' + clientId + '/defaults')
|
||||
.then(r => r.json())
|
||||
.then(d => {
|
||||
if (d.machine_profile_id != null) document.getElementById('machineProfileSelect').value = d.machine_profile_id;
|
||||
if (d.handling_profile_id != null) document.getElementById('handlingProfileSelect').value = d.handling_profile_id;
|
||||
if (d.material_profile_id != null) document.getElementById('materialProfileSelect').value = d.material_profile_id;
|
||||
if (d.pricing_profile_id != null) {
|
||||
const sel = document.getElementById('pricingProfileSelect');
|
||||
sel.value = d.pricing_profile_id;
|
||||
// Appliquer DM + marge du profil tarif sélectionné
|
||||
const opt = sel.options[sel.selectedIndex];
|
||||
if (opt && opt.value) {
|
||||
const dm = parseFloat(opt.dataset.dm);
|
||||
const margin = parseFloat(opt.dataset.margin);
|
||||
if (!isNaN(dm)) { document.getElementById('design_multiplier').value = dm; updateDMLabel(dm); }
|
||||
if (!isNaN(margin)) { marginSlider.value = margin; updateMarginDisplay(margin); }
|
||||
}
|
||||
}
|
||||
recalc();
|
||||
});
|
||||
});
|
||||
|
||||
// ── Matiere : afficher stock ──────────────────────────────────────────────────
|
||||
@@ -374,7 +390,7 @@ function recalc() {
|
||||
hours: h,
|
||||
minutes: m,
|
||||
design_multiplier: parseFloat(document.getElementById('design_multiplier').value) || 1.80,
|
||||
gross_margin_pct: parseFloat(document.getElementById('gross_margin_pct').value) || 27.5,
|
||||
gross_margin_pct: parseFloat(document.getElementById('gross_margin_pct').value ?? 27.5),
|
||||
discount_pct: parseFloat(document.getElementById('discount_pct').value) || 0,
|
||||
material_id: document.getElementById('materialSelect').value || null,
|
||||
machine_profile_id: document.getElementById('machineProfileSelect').value || null,
|
||||
|
||||
Reference in New Issue
Block a user