Fix migration DB, detail recap, TVA BIC vente, docker-compose sans traefik
This commit is contained in:
@@ -98,11 +98,30 @@ def init_db():
|
||||
('handling_rate_per_hour','40.0'),('handling_minutes_per_plate','5'),
|
||||
('material_margin_pct','20.0'),
|
||||
('cotisations_rate_pct','12.3'),
|
||||
('vfl_rate_pct','1.7'),
|
||||
('tva_rate_pct','0.0'),
|
||||
('vfl_rate_pct','1.0'),
|
||||
('tva_rate_pct','20.0'),
|
||||
('printer_power_kw','0.35'),
|
||||
]
|
||||
conn.executemany('INSERT OR IGNORE INTO settings VALUES (?,?)', defaults)
|
||||
|
||||
# Migrations : ajout de colonnes si elles n'existent pas (upgrade DB existante)
|
||||
migrations = [
|
||||
'ALTER TABLE jobs ADD COLUMN machine_profile_id INTEGER',
|
||||
'ALTER TABLE jobs ADD COLUMN handling_profile_id INTEGER',
|
||||
'ALTER TABLE jobs ADD COLUMN material_profile_id INTEGER',
|
||||
'ALTER TABLE jobs ADD COLUMN pricing_profile_id INTEGER',
|
||||
'ALTER TABLE jobs ADD COLUMN cout_fixe REAL',
|
||||
'ALTER TABLE jobs ADD COLUMN total_marge REAL',
|
||||
'ALTER TABLE jobs ADD COLUMN cotisations_amount REAL',
|
||||
'ALTER TABLE jobs ADD COLUMN vfl_amount REAL',
|
||||
'ALTER TABLE jobs ADD COLUMN tva_amount REAL',
|
||||
]
|
||||
for sql in migrations:
|
||||
try:
|
||||
conn.execute(sql)
|
||||
except Exception:
|
||||
pass # colonne deja existante
|
||||
|
||||
conn.commit(); conn.close()
|
||||
|
||||
def get_settings():
|
||||
@@ -218,7 +237,11 @@ def calc(weight_g, print_time_s, design_mult, gross_margin_pct, discount_pct,
|
||||
'material_cost': round(mat, 4),
|
||||
'material_margin': round(mat_margin, 4),
|
||||
'wear_cost': round(wear, 4),
|
||||
'printer_wear': round(printer_w, 4),
|
||||
'nozzle_wear': round(nozzle_w, 4),
|
||||
'plate_wear': round(plate_w, 4),
|
||||
'electricity_cost': round(elec, 4),
|
||||
'kwh_used': round(s['printer_power_kw'] * (print_time_s / 3600), 4),
|
||||
'cout_fixe': round(cout_fixe, 4),
|
||||
'handling_cost': round(handling, 4),
|
||||
'design_cost': round(design, 4),
|
||||
@@ -235,10 +258,14 @@ def calc(weight_g, print_time_s, design_mult, gross_margin_pct, discount_pct,
|
||||
# Compat
|
||||
'tax_amount': round(cot_amount + vfl_amount, 4),
|
||||
'final_price': round(final, 2),
|
||||
# Taux appliqués (pour affichage)
|
||||
'_cot_pct': round(cot_rate * 100, 2),
|
||||
'_vfl_pct': round(vfl_rate * 100, 2),
|
||||
'_tva_pct': round(tva_rate * 100, 2),
|
||||
# Taux et paramètres appliqués (pour affichage)
|
||||
'_cot_pct': round(cot_rate * 100, 2),
|
||||
'_vfl_pct': round(vfl_rate * 100, 2),
|
||||
'_tva_pct': round(tva_rate * 100, 2),
|
||||
'_material_margin_pct': s['material_margin_pct'],
|
||||
'_handling_rate': s['handling_rate_per_hour'],
|
||||
'_handling_minutes': s['handling_minutes_per_plate'],
|
||||
'_elec_price': s['electricity_price_kwh'],
|
||||
}
|
||||
|
||||
def fmt_time(s):
|
||||
@@ -284,7 +311,7 @@ def new_client():
|
||||
conn = get_db()
|
||||
conn.execute('INSERT INTO clients(name,email,design_multiplier,notes) VALUES(?,?,?,?)',
|
||||
(request.form['name'], request.form.get('email',''),
|
||||
float(request.form['design_multiplier']), request.form.get('notes','')))
|
||||
float(request.form.get('design_multiplier', 1.80)), request.form.get('notes','')))
|
||||
conn.commit(); conn.close()
|
||||
return redirect(url_for('clients'))
|
||||
return render_template('client_form.html', client=None)
|
||||
@@ -296,7 +323,7 @@ def edit_client(id):
|
||||
if request.method == 'POST':
|
||||
conn.execute('UPDATE clients SET name=?,email=?,design_multiplier=?,notes=? WHERE id=?',
|
||||
(request.form['name'], request.form.get('email',''),
|
||||
float(request.form['design_multiplier']), request.form.get('notes',''), id))
|
||||
float(request.form.get('design_multiplier', client['design_multiplier'])), request.form.get('notes',''), id))
|
||||
conn.commit(); conn.close()
|
||||
return redirect(url_for('clients'))
|
||||
conn.close()
|
||||
|
||||
Reference in New Issue
Block a user