Templates, decomposition prix restructuree, TVA + VFL, fix DM buttons
This commit is contained in:
+9
-1
@@ -52,6 +52,8 @@
|
||||
.breakdown-row { display: flex; justify-content: space-between; padding: .2rem 0; font-size: .88rem; }
|
||||
.breakdown-row.total { font-weight: 700; font-size: 1rem; border-top: 2px solid #dee2e6; padding-top: .5rem; margin-top: .3rem; }
|
||||
.breakdown-row.subtotal { border-top: 1px solid #dee2e6; padding-top: .4rem; margin-top: .2rem; }
|
||||
.breakdown-row.section-header { font-weight: 600; font-size: .8rem; text-transform: uppercase;
|
||||
letter-spacing: .04em; color: #6b7280; padding-top: .6rem; margin-top: .2rem; border-top: 1px dashed #e5e7eb; }
|
||||
.breakdown-muted { color: #6b7280; }
|
||||
|
||||
.final-price { font-size: 2rem; font-weight: 700; color: #ff6b35; }
|
||||
@@ -82,6 +84,9 @@
|
||||
<a href="{{ url_for('materials') }}" class="{% if 'material' in request.endpoint %}active{% endif %}">
|
||||
<i class="bi bi-boxes"></i> Matières
|
||||
</a>
|
||||
<a href="{{ url_for('profiles') }}" class="{% if 'profile' in request.endpoint %}active{% endif %}">
|
||||
<i class="bi bi-bookmark-star"></i> Templates
|
||||
</a>
|
||||
<div class="nav-section">Analyse</div>
|
||||
<a href="{{ url_for('stats') }}" class="{% if request.endpoint=='stats' %}active{% endif %}">
|
||||
<i class="bi bi-bar-chart-line"></i> Statistiques
|
||||
@@ -107,4 +112,7 @@
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}{% if profile %}Modifier{% else %}Nouveau{% endif %} profil manutention{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<a href="{{ url_for('profiles') }}#handling" class="text-muted text-decoration-none small">
|
||||
<i class="bi bi-arrow-left"></i> Templates
|
||||
</a>
|
||||
<h1 class="mt-1">
|
||||
<i class="bi bi-hand-index me-2" style="color:#ff6b35"></i>
|
||||
{% if profile %}Modifier{% else %}Nouveau{% endif %} profil manutention
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-5">
|
||||
<form method="POST">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header py-3">Parametres</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Nom du profil</label>
|
||||
<input type="text" name="name" class="form-control" required
|
||||
value="{{ profile.name if profile else '' }}"
|
||||
placeholder="ex: Standard, Complexe, Rapide...">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Taux horaire (€/h)</label>
|
||||
<input type="number" name="handling_rate_per_hour" class="form-control" step="0.5" min="0" required
|
||||
value="{{ profile.handling_rate_per_hour if profile else settings.handling_rate_per_hour }}">
|
||||
<div class="form-text">Votre cout de main d'oeuvre par heure.</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Minutes de manutention par plateau</label>
|
||||
<input type="number" name="handling_minutes_per_plate" class="form-control" step="0.5" min="0" required
|
||||
value="{{ profile.handling_minutes_per_plate if profile else settings.handling_minutes_per_plate }}">
|
||||
<div class="form-text">Preparation + retrait pieces + nettoyage plateau, par impression.</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Notes</label>
|
||||
<textarea name="notes" class="form-control" rows="2">{{ profile.notes if profile else '' }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn px-4 fw-bold" style="background:#ff6b35;color:#fff">
|
||||
<i class="bi bi-save me-1"></i>Enregistrer
|
||||
</button>
|
||||
<a href="{{ url_for('profiles') }}#handling" class="btn btn-outline-secondary">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
+63
-25
@@ -22,7 +22,7 @@
|
||||
<div class="card-body">
|
||||
<table class="table table-sm mb-0">
|
||||
<tr><th class="text-muted fw-normal" style="width:45%">Client</th><td>{{ job.client_name or '—' }}</td></tr>
|
||||
<tr><th class="text-muted fw-normal">Matière</th>
|
||||
<tr><th class="text-muted fw-normal">Matiere</th>
|
||||
<td>
|
||||
{% if job.material_name %}
|
||||
<span class="badge bg-secondary">{{ job.material_type }}</span> {{ job.material_name }}
|
||||
@@ -30,13 +30,22 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr><th class="text-muted fw-normal">Fichier source</th>
|
||||
<td class="text-monospace small">{{ job.source_file or '—' }}</td></tr>
|
||||
<td class="small font-monospace">{{ job.source_file or '—' }}</td></tr>
|
||||
<tr><th class="text-muted fw-normal">Date</th><td>{{ job.created_at[:10] }}</td></tr>
|
||||
<tr><th class="text-muted fw-normal">Poids filament</th><td>{{ job.weight_g }} g</td></tr>
|
||||
<tr><th class="text-muted fw-normal">Durée impression</th><td>{{ job.print_time_s | fmt_time }}</td></tr>
|
||||
<tr><th class="text-muted fw-normal">Duree impression</th><td>{{ job.print_time_s | fmt_time }}</td></tr>
|
||||
<tr><th class="text-muted fw-normal">Coeff design</th><td>×{{ job.design_multiplier }}</td></tr>
|
||||
<tr><th class="text-muted fw-normal">Marge brute</th><td>{{ job.gross_margin_pct }} %</td></tr>
|
||||
<tr><th class="text-muted fw-normal">Remise</th><td>{{ job.discount_pct }} %</td></tr>
|
||||
{% if job.machine_profile_name %}
|
||||
<tr><th class="text-muted fw-normal">Profil machine</th><td>{{ job.machine_profile_name }}</td></tr>
|
||||
{% endif %}
|
||||
{% if job.handling_profile_name %}
|
||||
<tr><th class="text-muted fw-normal">Profil manutention</th><td>{{ job.handling_profile_name }}</td></tr>
|
||||
{% endif %}
|
||||
{% if job.pricing_profile_name %}
|
||||
<tr><th class="text-muted fw-normal">Profil tarif</th><td>{{ job.pricing_profile_name }}</td></tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
{% if job.notes %}
|
||||
<hr>
|
||||
@@ -48,30 +57,56 @@
|
||||
|
||||
<div class="col-md-7">
|
||||
<div class="card">
|
||||
<div class="card-header py-3"><i class="bi bi-receipt me-2"></i>Décomposition du prix</div>
|
||||
<div class="card-header py-3"><i class="bi bi-receipt me-2"></i>Decomposition du prix</div>
|
||||
<div class="card-body">
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Matière</span><span>{{ "%.4f"|format(job.material_cost) }} €</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Marge matière</span><span>{{ "%.4f"|format(job.material_margin) }} €</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Design (×{{ job.design_multiplier }})</span><span>{{ "%.4f"|format(job.design_cost) }} €</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Manutention</span><span>{{ "%.4f"|format(job.handling_cost) }} €</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Usure machine</span><span>{{ "%.4f"|format(job.wear_cost) }} €</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Électricité</span><span>{{ "%.4f"|format(job.electricity_cost) }} €</span></div>
|
||||
|
||||
<!-- Cout fixe -->
|
||||
<div class="breakdown-row section-header"><span>Cout fixe</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Matiere</span><span>{{ "%.4f"|format(job.material_cost) }} €</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Marge matiere</span><span>{{ "%.4f"|format(job.material_margin) }} €</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Usure machine</span><span>{{ "%.4f"|format(job.wear_cost) }} €</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Electricite</span><span>{{ "%.4f"|format(job.electricity_cost) }} €</span></div>
|
||||
<div class="breakdown-row subtotal">
|
||||
<span class="fw-semibold">Sous-total coûts</span>
|
||||
<span class="fw-semibold">{{ "%.2f"|format(job.subtotal) }} €</span>
|
||||
<span class="fw-semibold">Total cout fixe</span>
|
||||
<span class="fw-semibold">
|
||||
{% if job.cout_fixe %}{{ "%.2f"|format(job.cout_fixe) }}{% else %}{{ "%.2f"|format(job.material_cost + job.material_margin + job.wear_cost + job.electricity_cost) }}{% endif %} €
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Partie variable -->
|
||||
<div class="breakdown-row section-header"><span>Partie variable</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Manutention</span><span>{{ "%.4f"|format(job.handling_cost) }} €</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Design (×{{ job.design_multiplier }})</span><span>{{ "%.4f"|format(job.design_cost) }} €</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Marge brute ({{ job.gross_margin_pct }}%)</span><span>{{ "%.2f"|format(job.margin_amount) }} €</span></div>
|
||||
<div class="breakdown-row subtotal">
|
||||
<span class="fw-semibold">Total marge</span>
|
||||
<span class="fw-semibold">
|
||||
{% if job.total_marge %}{{ "%.2f"|format(job.total_marge) }}{% else %}{{ "%.2f"|format(job.handling_cost + job.design_cost + job.margin_amount) }}{% endif %} €
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Fiscal -->
|
||||
<div class="breakdown-row section-header"><span>Fiscal</span></div>
|
||||
<div class="breakdown-row">
|
||||
<span class="breakdown-muted">Marge brute ({{ job.gross_margin_pct }}%)</span>
|
||||
<span>{{ "%.2f"|format(job.margin_amount) }} €</span>
|
||||
<span class="breakdown-muted ps-2">Cotisations sociales</span>
|
||||
<span>{% if job.cotisations_amount %}{{ "%.2f"|format(job.cotisations_amount) }}{% else %}{{ "%.2f"|format(job.tax_amount) }}{% endif %} €</span>
|
||||
</div>
|
||||
{% if job.vfl_amount and job.vfl_amount > 0 %}
|
||||
<div class="breakdown-row">
|
||||
<span class="breakdown-muted">Cotisations micro-ent.</span>
|
||||
<span>{{ "%.2f"|format(job.tax_amount) }} €</span>
|
||||
<span class="breakdown-muted ps-2">VFL impot</span>
|
||||
<span>{{ "%.2f"|format(job.vfl_amount) }} €</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if job.tva_amount and job.tva_amount > 0 %}
|
||||
<div class="breakdown-row">
|
||||
<span class="breakdown-muted ps-2">TVA</span>
|
||||
<span>{{ "%.2f"|format(job.tva_amount) }} €</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if job.discount_pct > 0 %}
|
||||
<div class="breakdown-row text-danger">
|
||||
<span>Remise ({{ job.discount_pct }}%)</span>
|
||||
<span>−{{ "%.2f"|format((job.subtotal + job.margin_amount + job.tax_amount) * job.discount_pct / 100) }} €</span>
|
||||
<span class="ps-2">Remise ({{ job.discount_pct }}%)</span>
|
||||
<span>−{{ "%.2f"|format(job.final_price / (1 - job.discount_pct/100) * (job.discount_pct/100)) }} €</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="breakdown-row total">
|
||||
@@ -80,18 +115,21 @@
|
||||
</div>
|
||||
|
||||
<!-- Barre de composition -->
|
||||
{% set total = job.final_price %}
|
||||
{% set cout_f = job.cout_fixe or (job.material_cost + job.material_margin + job.wear_cost + job.electricity_cost) %}
|
||||
{% set tot_m = job.total_marge or (job.handling_cost + job.design_cost + job.margin_amount) %}
|
||||
{% set fiscal = (job.cotisations_amount or job.tax_amount or 0) + (job.vfl_amount or 0) + (job.tva_amount or 0) %}
|
||||
{% set total = job.final_price %}
|
||||
{% if total > 0 %}
|
||||
<div class="mt-4">
|
||||
<div class="d-flex justify-content-between small text-muted mb-1">
|
||||
<span>Coûts ({{ (job.subtotal/total*100)|round(1) }}%)</span>
|
||||
<span>Marge ({{ (job.margin_amount/total*100)|round(1) }}%)</span>
|
||||
<span>Taxes ({{ (job.tax_amount/total*100)|round(1) }}%)</span>
|
||||
<span>Cout fixe ({{ (cout_f/total*100)|round(1) }}%)</span>
|
||||
<span>Marge ({{ (tot_m/total*100)|round(1) }}%)</span>
|
||||
<span>Fiscal ({{ (fiscal/total*100)|round(1) }}%)</span>
|
||||
</div>
|
||||
<div class="progress" style="height:18px;border-radius:6px">
|
||||
<div class="progress-bar bg-secondary" style="width:{{ (job.subtotal/total*100)|round(1) }}%"></div>
|
||||
<div class="progress-bar" style="width:{{ (job.margin_amount/total*100)|round(1) }}%;background:#ff6b35"></div>
|
||||
<div class="progress-bar bg-warning text-dark" style="width:{{ (job.tax_amount/total*100)|round(1) }}%"></div>
|
||||
<div class="progress-bar bg-secondary" style="width:{{ (cout_f/total*100)|round(1) }}%"></div>
|
||||
<div class="progress-bar" style="width:{{ (tot_m/total*100)|round(1) }}%;background:#ff6b35"></div>
|
||||
<div class="progress-bar bg-warning text-dark" style="width:{{ (fiscal/total*100)|round(1) }}%"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}{% if profile %}Modifier{% else %}Nouveau{% endif %} profil machine{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<a href="{{ url_for('profiles') }}#machine" class="text-muted text-decoration-none small">
|
||||
<i class="bi bi-arrow-left"></i> Templates
|
||||
</a>
|
||||
<h1 class="mt-1">
|
||||
<i class="bi bi-cpu me-2" style="color:#ff6b35"></i>
|
||||
{% if profile %}Modifier{% else %}Nouveau{% endif %} profil machine
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-7">
|
||||
<form method="POST">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header py-3">Identite</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Nom du profil</label>
|
||||
<input type="text" name="name" class="form-control" required
|
||||
value="{{ profile.name if profile else '' }}"
|
||||
placeholder="ex: Bambu X1C standard, Imprimante A...">
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<label class="form-label fw-semibold">Notes</label>
|
||||
<textarea name="notes" class="form-control" rows="2">{{ profile.notes if profile else '' }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header py-3"><i class="bi bi-printer me-2"></i>Imprimante</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Prix d'achat (€)</label>
|
||||
<input type="number" name="printer_price" class="form-control" step="0.01" min="0" required
|
||||
value="{{ profile.printer_price if profile else settings.printer_price }}">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Duree de vie (heures)</label>
|
||||
<input type="number" name="printer_lifespan_hours" class="form-control" step="1" min="1" required
|
||||
value="{{ profile.printer_lifespan_hours|int if profile else settings.printer_lifespan_hours|int }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header py-3"><i class="bi bi-circle me-2"></i>Buse (nozzle)</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Prix de la buse (€)</label>
|
||||
<input type="number" name="nozzle_price" class="form-control" step="0.01" min="0" required
|
||||
value="{{ profile.nozzle_price if profile else settings.nozzle_price }}">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Duree de vie (heures)</label>
|
||||
<input type="number" name="nozzle_lifespan_hours" class="form-control" step="1" min="1" required
|
||||
value="{{ profile.nozzle_lifespan_hours|int if profile else settings.nozzle_lifespan_hours|int }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header py-3"><i class="bi bi-square me-2"></i>Plateau (plate)</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Prix du plateau (€)</label>
|
||||
<input type="number" name="plate_price" class="form-control" step="0.01" min="0" required
|
||||
value="{{ profile.plate_price if profile else settings.plate_price }}">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Duree de vie (heures)</label>
|
||||
<input type="number" name="plate_lifespan_hours" class="form-control" step="1" min="1" required
|
||||
value="{{ profile.plate_lifespan_hours|int if profile else settings.plate_lifespan_hours|int }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header py-3"><i class="bi bi-lightning me-2"></i>Electricite</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Puissance imprimante (kW)</label>
|
||||
<input type="number" name="printer_power_kw" class="form-control" step="0.01" min="0" required
|
||||
value="{{ profile.printer_power_kw if profile else settings.printer_power_kw }}">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Prix electricite (€/kWh)</label>
|
||||
<input type="number" name="electricity_price_kwh" class="form-control" step="0.001" min="0" required
|
||||
value="{{ profile.electricity_price_kwh if profile else settings.electricity_price_kwh }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn px-4 fw-bold" style="background:#ff6b35;color:#fff">
|
||||
<i class="bi bi-save me-1"></i>Enregistrer
|
||||
</button>
|
||||
<a href="{{ url_for('profiles') }}#machine" class="btn btn-outline-secondary">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,48 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}{% if profile %}Modifier{% else %}Nouveau{% endif %} profil matiere{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<a href="{{ url_for('profiles') }}#material" class="text-muted text-decoration-none small">
|
||||
<i class="bi bi-arrow-left"></i> Templates
|
||||
</a>
|
||||
<h1 class="mt-1">
|
||||
<i class="bi bi-box me-2" style="color:#ff6b35"></i>
|
||||
{% if profile %}Modifier{% else %}Nouveau{% endif %} profil matiere
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-5">
|
||||
<form method="POST">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header py-3">Parametres</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Nom du profil</label>
|
||||
<input type="text" name="name" class="form-control" required
|
||||
value="{{ profile.name if profile else '' }}"
|
||||
placeholder="ex: PLA standard, Filament technique, Flexible...">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Marge sur matiere (%)</label>
|
||||
<input type="number" name="material_margin_pct" class="form-control" step="0.5" min="0" max="200" required
|
||||
value="{{ profile.material_margin_pct if profile else settings.material_margin_pct }}">
|
||||
<div class="form-text">Applique sur le cout matiere brut (prix/kg x poids).</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Notes</label>
|
||||
<textarea name="notes" class="form-control" rows="2">{{ profile.notes if profile else '' }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn px-4 fw-bold" style="background:#ff6b35;color:#fff">
|
||||
<i class="bi bi-save me-1"></i>Enregistrer
|
||||
</button>
|
||||
<a href="{{ url_for('profiles') }}#material" class="btn btn-outline-secondary">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
+236
-66
@@ -8,6 +8,7 @@
|
||||
|
||||
<div class="row g-4">
|
||||
<div class="col-lg-7">
|
||||
|
||||
<!-- Import 3mf -->
|
||||
<div class="card mb-3 border border-warning border-opacity-50">
|
||||
<div class="card-header py-3">
|
||||
@@ -22,22 +23,26 @@
|
||||
</button>
|
||||
<span id="parseStatus" class="text-muted small"></span>
|
||||
</div>
|
||||
<div class="form-text mt-1">Glissez votre fichier .3mf depuis Bambu Studio pour remplir poids et duree automatiquement.</div>
|
||||
<div class="form-text mt-1">Votre fichier .3mf depuis Bambu Studio pour remplir poids et duree automatiquement.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="jobForm">
|
||||
|
||||
<!-- Donnees impression -->
|
||||
<div class="card mb-3">
|
||||
<div class="card-header py-3">Donnees impression</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-3 mb-3">
|
||||
<div class="col-md-8">
|
||||
<label class="form-label fw-semibold">Nom de la commande</label>
|
||||
<input type="text" name="name" id="jobName" class="form-control" required placeholder="ex: Marqueurs competition salle X">
|
||||
<input type="text" name="name" id="jobName" class="form-control" required
|
||||
placeholder="ex: Marqueurs competition salle X">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-semibold">Fichier source</label>
|
||||
<input type="text" name="source_file" id="sourceFile" class="form-control" placeholder="nom_fichier.3mf">
|
||||
<input type="text" name="source_file" id="sourceFile" class="form-control"
|
||||
placeholder="nom_fichier.3mf">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-3 mb-3">
|
||||
@@ -51,12 +56,13 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Matiere</label>
|
||||
<label class="form-label fw-semibold">Matiere (filament)</label>
|
||||
<select name="material_id" id="materialSelect" class="form-select">
|
||||
<option value="">Prix global (parametres)</option>
|
||||
{% for m in materials %}
|
||||
<option value="{{ m.id }}" data-price="{{ m.price_per_kg }}" data-stock="{{ m.stock_g }}" data-threshold="{{ m.low_stock_threshold_g }}">
|
||||
{{ m.name }} ({{ m.type }}) - {{ m.price_per_kg }}EUR/kg
|
||||
<option value="{{ m.id }}" data-price="{{ m.price_per_kg }}"
|
||||
data-stock="{{ m.stock_g }}" data-threshold="{{ m.low_stock_threshold_g }}">
|
||||
{{ m.name }} ({{ m.type }}) — {{ m.price_per_kg }} €/kg
|
||||
{% if m.stock_g <= 0 %}[RUPTURE]{% elif m.stock_g <= m.low_stock_threshold_g %}[stock bas]{% endif %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
@@ -67,7 +73,8 @@
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-semibold">Poids filament (g)</label>
|
||||
<input type="number" name="weight_g" id="weight_g" class="form-control" step="0.01" min="0.1" required placeholder="423.97">
|
||||
<input type="number" name="weight_g" id="weight_g" class="form-control"
|
||||
step="0.01" min="0.1" required placeholder="423.97">
|
||||
<div class="form-text">Champ Modele dans Bambu</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
@@ -83,6 +90,71 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Profils -->
|
||||
<div class="card mb-3">
|
||||
<div class="card-header py-3">
|
||||
<i class="bi bi-bookmark-star me-2"></i>Profils
|
||||
<a href="{{ url_for('profiles') }}" class="btn btn-sm btn-outline-secondary ms-2 py-0" target="_blank">
|
||||
<i class="bi bi-pencil-square"></i> Gerer
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold small">
|
||||
<i class="bi bi-cpu me-1 text-muted"></i>Profil machine
|
||||
</label>
|
||||
<select name="machine_profile_id" id="machineProfileSelect" class="form-select form-select-sm">
|
||||
<option value="">— Parametres globaux —</option>
|
||||
{% for p in machine_profiles %}
|
||||
<option value="{{ p.id }}">{{ p.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold small">
|
||||
<i class="bi bi-hand-index me-1 text-muted"></i>Profil manutention
|
||||
</label>
|
||||
<select name="handling_profile_id" id="handlingProfileSelect" class="form-select form-select-sm">
|
||||
<option value="">— Parametres globaux —</option>
|
||||
{% for p in handling_profiles %}
|
||||
<option value="{{ p.id }}">{{ p.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold small">
|
||||
<i class="bi bi-box me-1 text-muted"></i>Profil matiere
|
||||
</label>
|
||||
<select name="material_profile_id" id="materialProfileSelect" class="form-select form-select-sm">
|
||||
<option value="">— Parametres globaux —</option>
|
||||
{% for p in material_profiles %}
|
||||
<option value="{{ p.id }}" data-margin="{{ p.material_margin_pct }}">
|
||||
{{ p.name }} ({{ p.material_margin_pct }}%)
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold small">
|
||||
<i class="bi bi-tags me-1 text-muted"></i>Profil tarif client
|
||||
</label>
|
||||
<select name="pricing_profile_id" id="pricingProfileSelect" class="form-select form-select-sm">
|
||||
<option value="">— Manuel —</option>
|
||||
{% for p in pricing_profiles %}
|
||||
<option value="{{ p.id }}"
|
||||
data-dm="{{ p.design_multiplier }}"
|
||||
data-margin="{{ p.gross_margin_pct }}">
|
||||
{{ p.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Parametres tarifaires -->
|
||||
<div class="card mb-3">
|
||||
<div class="card-header py-3">Parametres tarifaires</div>
|
||||
<div class="card-body">
|
||||
@@ -90,22 +162,31 @@
|
||||
<label class="form-label fw-semibold">
|
||||
Coefficient design <span class="badge bg-secondary ms-1" id="dmLabel">x1.80</span>
|
||||
</label>
|
||||
<div class="d-flex gap-2 mb-2">
|
||||
<button type="button" class="btn btn-sm btn-outline-success" onclick="setDM(0.80)">STL fourni (x0.80)</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary" onclick="setDM(1.80)">Creation complete (x1.80)</button>
|
||||
<div class="d-flex gap-2 mb-2" id="dmButtons">
|
||||
<button type="button" id="btnDM080" class="btn btn-sm btn-outline-success" onclick="setDM(0.80)">
|
||||
<i class="bi bi-check2 me-1 d-none" id="checkDM080"></i>STL fourni (x0.80)
|
||||
</button>
|
||||
<button type="button" id="btnDM180" class="btn btn-sm btn-outline-primary" onclick="setDM(1.80)">
|
||||
<i class="bi bi-check2 me-1 d-none" id="checkDM180"></i>Creation complete (x1.80)
|
||||
</button>
|
||||
</div>
|
||||
<input type="number" name="design_multiplier" id="design_multiplier" class="form-control form-control-sm" step="0.05" min="0" value="1.80">
|
||||
<input type="number" name="design_multiplier" id="design_multiplier"
|
||||
class="form-control form-control-sm" step="0.05" min="0" value="1.80">
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-semibold d-flex justify-content-between">
|
||||
Marge brute <span id="marginDisplay" class="text-muted">27.5 %</span>
|
||||
Marge brute <span id="marginDisplay" class="fw-bold" style="color:#ff6b35">27.5 %</span>
|
||||
</label>
|
||||
<input type="range" name="gross_margin_pct" id="gross_margin_pct" class="form-range" min="20" max="35" step="0.5" value="27.5">
|
||||
<div class="d-flex justify-content-between" style="font-size:.75rem;color:#6b7280"><span>20%</span><span>35%</span></div>
|
||||
<input type="range" name="gross_margin_pct" id="gross_margin_pct" class="form-range"
|
||||
min="20" max="35" step="0.5" value="27.5">
|
||||
<div class="d-flex justify-content-between" style="font-size:.75rem;color:#6b7280">
|
||||
<span>20%</span><span>35%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Remise client (%)</label>
|
||||
<input type="number" name="discount_pct" id="discount_pct" class="form-control" min="0" max="100" step="0.5" value="0">
|
||||
<input type="number" name="discount_pct" id="discount_pct" class="form-control"
|
||||
min="0" max="100" step="0.5" value="0">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Notes internes</label>
|
||||
@@ -120,9 +201,12 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Recap temps reel -->
|
||||
<div class="col-lg-5">
|
||||
<div class="card sticky-top" style="top:1.5rem">
|
||||
<div class="card-header py-3"><i class="bi bi-receipt me-2"></i>Recapitulatif temps reel</div>
|
||||
<div class="card-header py-3">
|
||||
<i class="bi bi-receipt me-2"></i>Recapitulatif temps reel
|
||||
</div>
|
||||
<div class="card-body" id="breakdown">
|
||||
<div class="text-center text-muted py-4">
|
||||
<i class="bi bi-calculator fs-2"></i>
|
||||
@@ -136,6 +220,7 @@
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
// ── 3MF parser ────────────────────────────────────────────────────────────────
|
||||
function parse3mf() {
|
||||
const file = document.getElementById('file3mf').files[0];
|
||||
if (!file) { alert('Selectionnez un fichier .3mf'); return; }
|
||||
@@ -147,87 +232,172 @@ function parse3mf() {
|
||||
.then(r => r.json())
|
||||
.then(d => {
|
||||
let filled = [];
|
||||
if (d.weight_g) { document.getElementById('weight_g').value = d.weight_g; filled.push('poids'); }
|
||||
if (d.hours != null){ document.getElementById('hours').value = d.hours; filled.push('heures'); }
|
||||
if (d.weight_g) { document.getElementById('weight_g').value = d.weight_g; filled.push('poids'); }
|
||||
if (d.hours != null) { document.getElementById('hours').value = d.hours; filled.push('heures'); }
|
||||
if (d.minutes != null){ document.getElementById('minutes').value = d.minutes; }
|
||||
if (d.filename) {
|
||||
document.getElementById('sourceFile').value = d.filename;
|
||||
if (!document.querySelector('[name=name]').value)
|
||||
document.querySelector('[name=name]').value = d.filename;
|
||||
if (!document.getElementById('jobName').value)
|
||||
document.getElementById('jobName').value = d.filename;
|
||||
}
|
||||
status.textContent = filled.length ? 'Extrait: '+filled.join(', ') : 'Donnees non trouvees';
|
||||
status.style.color = filled.length ? '#22c55e' : '#f59e0b';
|
||||
status.textContent = filled.length ? 'Extrait: ' + filled.join(', ') : 'Donnees non trouvees';
|
||||
status.style.color = filled.length ? '#22c55e' : '#f59e0b';
|
||||
recalc();
|
||||
})
|
||||
.catch(() => { status.textContent = 'Erreur de lecture'; status.style.color='#ef4444'; });
|
||||
.catch(() => { status.textContent = 'Erreur de lecture'; status.style.color = '#ef4444'; });
|
||||
}
|
||||
|
||||
document.getElementById('materialSelect').addEventListener('change', function() {
|
||||
const opt = this.options[this.selectedIndex];
|
||||
const stock = parseFloat(opt.dataset.stock)||0;
|
||||
const threshold = parseFloat(opt.dataset.threshold)||200;
|
||||
const info = document.getElementById('stockInfo');
|
||||
if (!opt.value) { info.textContent=''; return; }
|
||||
if (stock<=0) info.innerHTML='<span class="text-danger">RUPTURE DE STOCK</span>';
|
||||
else if (stock<=threshold) info.innerHTML='<span class="text-warning">Stock bas: '+stock.toFixed(0)+' g</span>';
|
||||
else info.innerHTML='<span class="text-success">Stock: '+stock.toFixed(0)+' g</span>';
|
||||
recalc();
|
||||
});
|
||||
|
||||
// ── Coefficient design ────────────────────────────────────────────────────────
|
||||
function setDM(val) {
|
||||
document.getElementById('design_multiplier').value = val;
|
||||
document.getElementById('dmLabel').textContent = 'x'+val.toFixed(2);
|
||||
updateDMLabel(val);
|
||||
recalc();
|
||||
}
|
||||
document.getElementById('gross_margin_pct').addEventListener('input', function(){
|
||||
document.getElementById('marginDisplay').textContent = this.value+' %'; recalc();
|
||||
|
||||
function updateDMLabel(val) {
|
||||
val = parseFloat(val);
|
||||
document.getElementById('dmLabel').textContent = 'x' + val.toFixed(2);
|
||||
// Etat actif des boutons
|
||||
const is080 = Math.abs(val - 0.80) < 0.001;
|
||||
const is180 = Math.abs(val - 1.80) < 0.001;
|
||||
document.getElementById('btnDM080').className = 'btn btn-sm ' + (is080 ? 'btn-success' : 'btn-outline-success');
|
||||
document.getElementById('btnDM180').className = 'btn btn-sm ' + (is180 ? 'btn-primary' : 'btn-outline-primary');
|
||||
}
|
||||
|
||||
document.getElementById('design_multiplier').addEventListener('input', function() {
|
||||
updateDMLabel(this.value);
|
||||
recalc();
|
||||
});
|
||||
document.getElementById('design_multiplier').addEventListener('input', function(){
|
||||
document.getElementById('dmLabel').textContent = 'x'+parseFloat(this.value).toFixed(2); recalc();
|
||||
|
||||
// ── Marge ─────────────────────────────────────────────────────────────────────
|
||||
function updateMarginDisplay(val) {
|
||||
document.getElementById('marginDisplay').textContent = parseFloat(val).toFixed(1) + ' %';
|
||||
}
|
||||
|
||||
const marginSlider = document.getElementById('gross_margin_pct');
|
||||
marginSlider.addEventListener('input', function() { updateMarginDisplay(this.value); recalc(); });
|
||||
marginSlider.addEventListener('change', function() { updateMarginDisplay(this.value); recalc(); });
|
||||
|
||||
// ── Profil tarif client ───────────────────────────────────────────────────────
|
||||
document.getElementById('pricingProfileSelect').addEventListener('change', function() {
|
||||
const opt = this.options[this.selectedIndex];
|
||||
if (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();
|
||||
}
|
||||
});
|
||||
document.getElementById('clientSelect').addEventListener('change', function(){
|
||||
|
||||
// ── Client : auto-remplir DM ──────────────────────────────────────────────────
|
||||
document.getElementById('clientSelect').addEventListener('change', function() {
|
||||
const dm = this.options[this.selectedIndex].dataset.dm;
|
||||
if (dm) setDM(parseFloat(dm));
|
||||
if (dm) {
|
||||
document.getElementById('design_multiplier').value = parseFloat(dm);
|
||||
updateDMLabel(parseFloat(dm));
|
||||
recalc();
|
||||
}
|
||||
});
|
||||
|
||||
// ── Matiere : afficher stock ──────────────────────────────────────────────────
|
||||
document.getElementById('materialSelect').addEventListener('change', function() {
|
||||
const opt = this.options[this.selectedIndex];
|
||||
const stock = parseFloat(opt.dataset.stock) || 0;
|
||||
const threshold = parseFloat(opt.dataset.threshold) || 200;
|
||||
const info = document.getElementById('stockInfo');
|
||||
if (!opt.value) { info.textContent = ''; }
|
||||
else if (stock <= 0) info.innerHTML = '<span class="text-danger">RUPTURE DE STOCK</span>';
|
||||
else if (stock <= threshold) info.innerHTML = '<span class="text-warning">Stock bas : ' + stock.toFixed(0) + ' g</span>';
|
||||
else info.innerHTML = '<span class="text-success">Stock : ' + stock.toFixed(0) + ' g</span>';
|
||||
recalc();
|
||||
});
|
||||
|
||||
// ── Autres champs → recalc ────────────────────────────────────────────────────
|
||||
['weight_g','hours','minutes','discount_pct'].forEach(id => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.addEventListener('input', recalc);
|
||||
});
|
||||
['machineProfileSelect','handlingProfileSelect','materialProfileSelect'].forEach(id => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.addEventListener('change', recalc);
|
||||
});
|
||||
|
||||
// ── Calcul API ────────────────────────────────────────────────────────────────
|
||||
function recalc() {
|
||||
const w = parseFloat(document.getElementById('weight_g').value)||0;
|
||||
const h = parseInt(document.getElementById('hours').value)||0;
|
||||
const m = parseInt(document.getElementById('minutes').value)||0;
|
||||
if (w<=0 || (h===0 && m===0)) return;
|
||||
const w = parseFloat(document.getElementById('weight_g').value) || 0;
|
||||
const h = parseInt(document.getElementById('hours').value) || 0;
|
||||
const m = parseInt(document.getElementById('minutes').value) || 0;
|
||||
if (w <= 0 && h === 0 && m === 0) return;
|
||||
if (w <= 0) return;
|
||||
|
||||
const body = {
|
||||
weight_g: w, 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,
|
||||
discount_pct: parseFloat(document.getElementById('discount_pct').value)||0,
|
||||
material_id: document.getElementById('materialSelect').value||null,
|
||||
weight_g: w,
|
||||
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,
|
||||
discount_pct: parseFloat(document.getElementById('discount_pct').value) || 0,
|
||||
material_id: document.getElementById('materialSelect').value || null,
|
||||
machine_profile_id: document.getElementById('machineProfileSelect').value || null,
|
||||
handling_profile_id: document.getElementById('handlingProfileSelect').value || null,
|
||||
material_profile_id: document.getElementById('materialProfileSelect').value || null,
|
||||
};
|
||||
fetch('/api/calculate',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)})
|
||||
.then(r=>r.json()).then(d=>renderBreakdown(d,body));
|
||||
|
||||
fetch('/api/calculate', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(d => renderBreakdown(d, body))
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
function fmt(n) { return parseFloat(n).toFixed(4)+' EUR'; }
|
||||
function fmt2(n) { return parseFloat(n).toFixed(2)+' EUR'; }
|
||||
// ── Rendu du recap ────────────────────────────────────────────────────────────
|
||||
function fmt(n) { return parseFloat(n).toFixed(4) + ' €'; }
|
||||
function fmt2(n) { return parseFloat(n).toFixed(2) + ' €'; }
|
||||
|
||||
function renderBreakdown(d, body) {
|
||||
const dis = body.discount_pct>0
|
||||
? '<div class="breakdown-row text-danger"><span>Remise ('+body.discount_pct+'%)</span></div>' : '';
|
||||
const dm = parseFloat(body.design_multiplier).toFixed(2);
|
||||
const mgn = parseFloat(body.gross_margin_pct).toFixed(1);
|
||||
const dis = body.discount_pct > 0
|
||||
? `<div class="breakdown-row text-danger"><span>Remise (${body.discount_pct}%)</span><span>-${fmt2(d.final_price / (1 - body.discount_pct/100) * (body.discount_pct/100))}</span></div>` : '';
|
||||
const tvaRow = d._tva_pct > 0
|
||||
? `<div class="breakdown-row"><span class="breakdown-muted">TVA (${d._tva_pct}%)</span><span>${fmt2(d.tva_amount)}</span></div>` : '';
|
||||
const vflRow = d._vfl_pct > 0
|
||||
? `<div class="breakdown-row"><span class="breakdown-muted">VFL impot (${d._vfl_pct}%)</span><span>${fmt2(d.vfl_amount)}</span></div>` : '';
|
||||
|
||||
document.getElementById('breakdown').innerHTML = `
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Matiere</span><span>${fmt(d.material_cost)}</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Marge matiere (20%)</span><span>${fmt(d.material_margin)}</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Design (x${body.design_multiplier.toFixed(2)})</span><span>${fmt(d.design_cost)}</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Manutention</span><span>${fmt(d.handling_cost)}</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Usure machine</span><span>${fmt(d.wear_cost)}</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Electricite</span><span>${fmt(d.electricity_cost)}</span></div>
|
||||
<div class="breakdown-row subtotal"><span class="fw-semibold">Sous-total couts</span><span class="fw-semibold">${fmt2(d.subtotal)}</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Marge brute (${body.gross_margin_pct}%)</span><span>${fmt2(d.margin_amount)}</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted">Cotisations (12.3%)</span><span>${fmt2(d.tax_amount)}</span></div>
|
||||
<div class="breakdown-row section-header"><span>Cout fixe</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Matiere</span><span>${fmt(d.material_cost)}</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Marge matiere</span><span>${fmt(d.material_margin)}</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Usure machine</span><span>${fmt(d.wear_cost)}</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Electricite</span><span>${fmt(d.electricity_cost)}</span></div>
|
||||
<div class="breakdown-row subtotal"><span class="fw-semibold">Total cout fixe</span><span class="fw-semibold">${fmt2(d.cout_fixe)}</span></div>
|
||||
|
||||
<div class="breakdown-row section-header"><span>Partie variable</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Manutention</span><span>${fmt(d.handling_cost)}</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Design (x${dm})</span><span>${fmt(d.design_cost)}</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Marge brute (${mgn}%)</span><span>${fmt2(d.margin_amount)}</span></div>
|
||||
<div class="breakdown-row subtotal"><span class="fw-semibold">Total marge</span><span class="fw-semibold">${fmt2(d.total_marge)}</span></div>
|
||||
|
||||
<div class="breakdown-row section-header"><span>Fiscal</span></div>
|
||||
<div class="breakdown-row"><span class="breakdown-muted ps-2">Cotisations (${d._cot_pct}%)</span><span>${fmt2(d.cotisations_amount)}</span></div>
|
||||
${vflRow}
|
||||
${tvaRow}
|
||||
${dis}
|
||||
<div class="breakdown-row total"><span>PRIX FINAL</span><span class="final-price">${fmt2(d.final_price)}</span></div>`;
|
||||
}
|
||||
|
||||
// Init
|
||||
updateDMLabel(1.80);
|
||||
updateMarginDisplay(27.5);
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}{% if profile %}Modifier{% else %}Nouveau{% endif %} profil tarif{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<a href="{{ url_for('profiles') }}#pricing" class="text-muted text-decoration-none small">
|
||||
<i class="bi bi-arrow-left"></i> Templates
|
||||
</a>
|
||||
<h1 class="mt-1">
|
||||
<i class="bi bi-tags me-2" style="color:#ff6b35"></i>
|
||||
{% if profile %}Modifier{% else %}Nouveau{% endif %} profil tarif client
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-5">
|
||||
<form method="POST">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header py-3">Parametres</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Nom du profil</label>
|
||||
<input type="text" name="name" class="form-control" required
|
||||
value="{{ profile.name if profile else '' }}"
|
||||
placeholder="ex: Client STL, Client standard, Client VIP...">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Coefficient design</label>
|
||||
<div class="d-flex gap-2 mb-2">
|
||||
<button type="button" class="btn btn-sm btn-outline-success" onclick="setDM(0.80)">STL fourni (x0.80)</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary" onclick="setDM(1.80)">Creation complete (x1.80)</button>
|
||||
</div>
|
||||
<input type="number" name="design_multiplier" id="design_multiplier" class="form-control" step="0.05" min="0" required
|
||||
value="{{ profile.design_multiplier if profile else 1.80 }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold d-flex justify-content-between">
|
||||
Marge brute <span id="marginDisplay" class="text-muted">
|
||||
{{ profile.gross_margin_pct if profile else 27.5 }} %
|
||||
</span>
|
||||
</label>
|
||||
<input type="range" name="gross_margin_pct" id="gross_margin_pct" class="form-range"
|
||||
min="20" max="35" step="0.5"
|
||||
value="{{ profile.gross_margin_pct if profile else 27.5 }}">
|
||||
<div class="d-flex justify-content-between" style="font-size:.75rem;color:#6b7280"><span>20%</span><span>35%</span></div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Notes</label>
|
||||
<textarea name="notes" class="form-control" rows="2">{{ profile.notes if profile else '' }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn px-4 fw-bold" style="background:#ff6b35;color:#fff">
|
||||
<i class="bi bi-save me-1"></i>Enregistrer
|
||||
</button>
|
||||
<a href="{{ url_for('profiles') }}#pricing" class="btn btn-outline-secondary">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
function setDM(val) {
|
||||
document.getElementById('design_multiplier').value = val;
|
||||
}
|
||||
document.getElementById('gross_margin_pct').addEventListener('input', function() {
|
||||
document.getElementById('marginDisplay').textContent = this.value + ' %';
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,238 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}Templates / Profils{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header d-flex justify-content-between align-items-center">
|
||||
<h1><i class="bi bi-bookmark-star me-2" style="color:#ff6b35"></i>Templates & Profils</h1>
|
||||
</div>
|
||||
|
||||
<ul class="nav nav-tabs mb-4" id="profileTabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if not request.args.get('tab') or request.args.get('tab')=='machine' %}active{% endif %}"
|
||||
href="#machine" data-bs-toggle="tab" data-bs-target="#machine">
|
||||
<i class="bi bi-cpu me-1"></i>Machine
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if request.args.get('tab')=='handling' %}active{% endif %}"
|
||||
href="#handling" data-bs-toggle="tab" data-bs-target="#handling">
|
||||
<i class="bi bi-hand-index me-1"></i>Manutention
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if request.args.get('tab')=='material' %}active{% endif %}"
|
||||
href="#material" data-bs-toggle="tab" data-bs-target="#material">
|
||||
<i class="bi bi-box me-1"></i>Matiere
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if request.args.get('tab')=='pricing' %}active{% endif %}"
|
||||
href="#pricing" data-bs-toggle="tab" data-bs-target="#pricing">
|
||||
<i class="bi bi-tags me-1"></i>Tarif client
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
|
||||
<!-- Machine -->
|
||||
<div class="tab-pane fade {% if not request.args.get('tab') or request.args.get('tab')=='machine' %}show active{% endif %}" id="machine">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<p class="text-muted mb-0 small">Imprimante, buse, plateau et electricite. Remplace les parametres globaux lors du calcul.</p>
|
||||
<a href="{{ url_for('new_machine_profile') }}" class="btn btn-sm" style="background:#ff6b35;color:#fff">
|
||||
<i class="bi bi-plus-lg me-1"></i>Nouveau
|
||||
</a>
|
||||
</div>
|
||||
{% if machine_profiles %}
|
||||
<div class="card">
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Nom</th>
|
||||
<th>Imprimante</th>
|
||||
<th>Buse</th>
|
||||
<th>Plateau</th>
|
||||
<th>Puissance</th>
|
||||
<th>Electricite</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for p in machine_profiles %}
|
||||
<tr>
|
||||
<td class="fw-semibold">{{ p.name }}</td>
|
||||
<td class="small text-muted">{{ p.printer_price }}€ / {{ p.printer_lifespan_hours|int }}h</td>
|
||||
<td class="small text-muted">{{ p.nozzle_price }}€ / {{ p.nozzle_lifespan_hours|int }}h</td>
|
||||
<td class="small text-muted">{{ p.plate_price }}€ / {{ p.plate_lifespan_hours|int }}h</td>
|
||||
<td class="small text-muted">{{ p.printer_power_kw }} kW</td>
|
||||
<td class="small text-muted">{{ p.electricity_price_kwh }} €/kWh</td>
|
||||
<td class="text-end">
|
||||
<a href="{{ url_for('edit_machine_profile', id=p.id) }}" class="btn btn-sm btn-outline-secondary py-0 me-1">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<form method="POST" action="{{ url_for('delete_machine_profile', id=p.id) }}" class="d-inline"
|
||||
onsubmit="return confirm('Supprimer ce profil ?')">
|
||||
<button class="btn btn-sm btn-outline-danger py-0"><i class="bi bi-trash"></i></button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="card"><div class="card-body text-center text-muted py-4">
|
||||
<i class="bi bi-cpu fs-2"></i><p class="mt-2 small">Aucun profil machine.</p>
|
||||
</div></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Manutention -->
|
||||
<div class="tab-pane fade {% if request.args.get('tab')=='handling' %}show active{% endif %}" id="handling">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<p class="text-muted mb-0 small">Taux horaire et temps de preparation par plateau.</p>
|
||||
<a href="{{ url_for('new_handling_profile') }}" class="btn btn-sm" style="background:#ff6b35;color:#fff">
|
||||
<i class="bi bi-plus-lg me-1"></i>Nouveau
|
||||
</a>
|
||||
</div>
|
||||
{% if handling_profiles %}
|
||||
<div class="card">
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr><th>Nom</th><th>Taux horaire</th><th>Minutes / plateau</th><th>Cout fixe par job</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for p in handling_profiles %}
|
||||
{% set cost = (p.handling_rate_per_hour / 60) * p.handling_minutes_per_plate %}
|
||||
<tr>
|
||||
<td class="fw-semibold">{{ p.name }}</td>
|
||||
<td>{{ p.handling_rate_per_hour }} €/h</td>
|
||||
<td>{{ p.handling_minutes_per_plate }} min</td>
|
||||
<td class="fw-semibold" style="color:#ff6b35">{{ "%.2f"|format(cost) }} €</td>
|
||||
<td class="text-end">
|
||||
<a href="{{ url_for('edit_handling_profile', id=p.id) }}" class="btn btn-sm btn-outline-secondary py-0 me-1">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<form method="POST" action="{{ url_for('delete_handling_profile', id=p.id) }}" class="d-inline"
|
||||
onsubmit="return confirm('Supprimer ce profil ?')">
|
||||
<button class="btn btn-sm btn-outline-danger py-0"><i class="bi bi-trash"></i></button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="card"><div class="card-body text-center text-muted py-4">
|
||||
<i class="bi bi-hand-index fs-2"></i><p class="mt-2 small">Aucun profil manutention.</p>
|
||||
</div></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Matiere -->
|
||||
<div class="tab-pane fade {% if request.args.get('tab')=='material' %}show active{% endif %}" id="material">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<p class="text-muted mb-0 small">Marge appliquee sur le cout matiere. Utile pour differencier les types de filament (standard, technique, flexible...).</p>
|
||||
<a href="{{ url_for('new_material_profile') }}" class="btn btn-sm" style="background:#ff6b35;color:#fff">
|
||||
<i class="bi bi-plus-lg me-1"></i>Nouveau
|
||||
</a>
|
||||
</div>
|
||||
{% if material_profiles %}
|
||||
<div class="card">
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr><th>Nom</th><th>Marge matiere</th><th>Notes</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for p in material_profiles %}
|
||||
<tr>
|
||||
<td class="fw-semibold">{{ p.name }}</td>
|
||||
<td><span class="badge bg-secondary">{{ p.material_margin_pct }} %</span></td>
|
||||
<td class="small text-muted">{{ p.notes or '' }}</td>
|
||||
<td class="text-end">
|
||||
<a href="{{ url_for('edit_material_profile', id=p.id) }}" class="btn btn-sm btn-outline-secondary py-0 me-1">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<form method="POST" action="{{ url_for('delete_material_profile', id=p.id) }}" class="d-inline"
|
||||
onsubmit="return confirm('Supprimer ce profil ?')">
|
||||
<button class="btn btn-sm btn-outline-danger py-0"><i class="bi bi-trash"></i></button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="card"><div class="card-body text-center text-muted py-4">
|
||||
<i class="bi bi-box fs-2"></i><p class="mt-2 small">Aucun profil matiere.</p>
|
||||
</div></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Tarif client -->
|
||||
<div class="tab-pane fade {% if request.args.get('tab')=='pricing' %}show active{% endif %}" id="pricing">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<p class="text-muted mb-0 small">Coefficient design et marge brute. Creer un profil par type de relation client.</p>
|
||||
<a href="{{ url_for('new_pricing_profile') }}" class="btn btn-sm" style="background:#ff6b35;color:#fff">
|
||||
<i class="bi bi-plus-lg me-1"></i>Nouveau
|
||||
</a>
|
||||
</div>
|
||||
{% if pricing_profiles %}
|
||||
<div class="card">
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr><th>Nom</th><th>Coeff design</th><th>Marge brute</th><th>Notes</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for p in pricing_profiles %}
|
||||
<tr>
|
||||
<td class="fw-semibold">{{ p.name }}</td>
|
||||
<td><span class="badge bg-primary">x{{ p.design_multiplier }}</span></td>
|
||||
<td><span class="badge" style="background:#ff6b35">{{ p.gross_margin_pct }} %</span></td>
|
||||
<td class="small text-muted">{{ p.notes or '' }}</td>
|
||||
<td class="text-end">
|
||||
<a href="{{ url_for('edit_pricing_profile', id=p.id) }}" class="btn btn-sm btn-outline-secondary py-0 me-1">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<form method="POST" action="{{ url_for('delete_pricing_profile', id=p.id) }}" class="d-inline"
|
||||
onsubmit="return confirm('Supprimer ce profil ?')">
|
||||
<button class="btn btn-sm btn-outline-danger py-0"><i class="bi bi-trash"></i></button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="card"><div class="card-body text-center text-muted py-4">
|
||||
<i class="bi bi-tags fs-2"></i><p class="mt-2 small">Aucun profil tarif client.</p>
|
||||
</div></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
// Activer l'onglet correspondant au hash ou query param
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const hash = window.location.hash;
|
||||
if (hash) {
|
||||
const tab = document.querySelector('[data-bs-target="' + hash + '"]');
|
||||
if (tab) new bootstrap.Tab(tab).show();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
+45
-13
@@ -1,9 +1,10 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}Paramètres{% endblock %}
|
||||
{% block title %}Parametres{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h1><i class="bi bi-sliders me-2 text-secondary"></i>Paramètres</h1>
|
||||
<h1><i class="bi bi-sliders me-2 text-secondary"></i>Parametres globaux</h1>
|
||||
<p class="text-muted small mt-1">Valeurs par defaut — remplacees si un profil est selectionne lors du calcul.</p>
|
||||
</div>
|
||||
|
||||
<form method="POST">
|
||||
@@ -19,10 +20,10 @@
|
||||
step="0.01" value="{{ settings.filament_price_per_kg }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Marge matière (%)</label>
|
||||
<label class="form-label">Marge matiere (%)</label>
|
||||
<input type="number" name="material_margin_pct" class="form-control"
|
||||
step="0.5" value="{{ settings.material_margin_pct }}">
|
||||
<div class="form-text">Appliquée sur le coût matière brut.</div>
|
||||
<div class="form-text">Appliquee sur le cout matiere brut.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -30,7 +31,7 @@
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header py-3"><i class="bi bi-lightning-charge me-2"></i>Électricité</div>
|
||||
<div class="card-header py-3"><i class="bi bi-lightning-charge me-2"></i>Electricite</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Prix kWh (€)</label>
|
||||
@@ -58,7 +59,7 @@
|
||||
step="1" value="{{ settings.printer_price }}">
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<label class="form-label">Durée de vie (h)</label>
|
||||
<label class="form-label">Duree de vie (h)</label>
|
||||
<input type="number" name="printer_lifespan_hours" class="form-control"
|
||||
step="100" value="{{ settings.printer_lifespan_hours }}">
|
||||
</div>
|
||||
@@ -70,7 +71,7 @@
|
||||
step="0.5" value="{{ settings.nozzle_price }}">
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<label class="form-label">Durée de vie buse (h)</label>
|
||||
<label class="form-label">Duree de vie buse (h)</label>
|
||||
<input type="number" name="nozzle_lifespan_hours" class="form-control"
|
||||
step="10" value="{{ settings.nozzle_lifespan_hours }}">
|
||||
</div>
|
||||
@@ -82,7 +83,7 @@
|
||||
step="0.5" value="{{ settings.plate_price }}">
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<label class="form-label">Durée de vie plateau (h)</label>
|
||||
<label class="form-label">Duree de vie plateau (h)</label>
|
||||
<input type="number" name="plate_lifespan_hours" class="form-control"
|
||||
step="50" value="{{ settings.plate_lifespan_hours }}">
|
||||
</div>
|
||||
@@ -112,10 +113,41 @@
|
||||
<div class="card-header py-3"><i class="bi bi-percent me-2"></i>Fiscal</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Taux cotisations micro-entrepreneur (%)</label>
|
||||
<input type="number" name="tax_rate_pct" class="form-control"
|
||||
step="0.1" value="{{ settings.tax_rate_pct }}">
|
||||
<div class="form-text">12.3% pour vente de marchandises (2024).</div>
|
||||
<label class="form-label fw-semibold">Cotisations sociales (%)</label>
|
||||
<input type="number" name="cotisations_rate_pct" class="form-control"
|
||||
step="0.1" value="{{ settings.cotisations_rate_pct }}">
|
||||
<div class="form-text">12.3% pour prestation de services (2024). Calculees sur le CA HT.</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Versement Forfaitaire Liberatoire — impot (%)</label>
|
||||
<input type="number" name="vfl_rate_pct" class="form-control"
|
||||
step="0.1" value="{{ settings.vfl_rate_pct }}">
|
||||
<div class="form-text">
|
||||
1.7% pour prestation de services (option VFL). Mettre 0 si vous n'etes pas au VFL
|
||||
(impot calcule separement sur declaration classique).
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="mb-2">
|
||||
<label class="form-label fw-semibold">TVA (%)</label>
|
||||
<input type="number" name="tva_rate_pct" class="form-control"
|
||||
step="0.1" value="{{ settings.tva_rate_pct }}">
|
||||
<div class="form-text">
|
||||
<strong>0</strong> si vous etes en franchise en base de TVA (CA < seuil).
|
||||
<strong>20</strong> si vous avez depasse le seuil et devez facturer la TVA.
|
||||
La TVA est affichee separement et s'ajoute au prix HT.
|
||||
</div>
|
||||
</div>
|
||||
{% set total_charges = settings.cotisations_rate_pct + settings.vfl_rate_pct %}
|
||||
<div class="alert alert-info py-2 mt-3 mb-0 small">
|
||||
<i class="bi bi-info-circle me-1"></i>
|
||||
Charges totales sur CA : <strong>{{ total_charges }} %</strong>
|
||||
(cotisations {{ settings.cotisations_rate_pct }}% + VFL {{ settings.vfl_rate_pct }}%)
|
||||
{% if settings.tva_rate_pct > 0 %}
|
||||
+ TVA {{ settings.tva_rate_pct }}% ajoutee au prix HT
|
||||
{% else %}
|
||||
— franchise TVA active
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -125,7 +157,7 @@
|
||||
|
||||
<div class="mt-4">
|
||||
<button type="submit" class="btn px-4 py-2 fw-bold" style="background:#ff6b35;color:#fff">
|
||||
<i class="bi bi-save me-2"></i>Enregistrer les paramètres
|
||||
<i class="bi bi-save me-2"></i>Enregistrer les parametres
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user