Autres taxes CFE param, % marge sur HT, Prix HT/TVA/TTC séparés, clients sans coeff
This commit is contained in:
@@ -100,6 +100,7 @@ def init_db():
|
||||
('cotisations_rate_pct','12.3'),
|
||||
('vfl_rate_pct','1.0'),
|
||||
('tva_rate_pct','20.0'),
|
||||
('other_taxes_rate_pct','1.0'),
|
||||
('printer_power_kw','0.35'),
|
||||
]
|
||||
conn.executemany('INSERT OR IGNORE INTO settings VALUES (?,?)', defaults)
|
||||
@@ -115,6 +116,7 @@ def init_db():
|
||||
'ALTER TABLE jobs ADD COLUMN cotisations_amount REAL',
|
||||
'ALTER TABLE jobs ADD COLUMN vfl_amount REAL',
|
||||
'ALTER TABLE jobs ADD COLUMN tva_amount REAL',
|
||||
'ALTER TABLE jobs ADD COLUMN other_taxes_amount REAL',
|
||||
]
|
||||
for sql in migrations:
|
||||
try:
|
||||
@@ -214,10 +216,11 @@ def calc(weight_g, print_time_s, design_mult, gross_margin_pct, discount_pct,
|
||||
total_marge= handling + design + margin
|
||||
prix_ht = cout_fixe + total_marge # = sous_total + margin
|
||||
|
||||
cot_rate = s.get('cotisations_rate_pct', 12.3) / 100
|
||||
vfl_rate = s.get('vfl_rate_pct', 0.0) / 100
|
||||
tva_rate = s.get('tva_rate_pct', 0.0) / 100
|
||||
total_charges = cot_rate + vfl_rate
|
||||
cot_rate = s.get('cotisations_rate_pct', 12.3) / 100
|
||||
vfl_rate = s.get('vfl_rate_pct', 0.0) / 100
|
||||
tva_rate = s.get('tva_rate_pct', 0.0) / 100
|
||||
other_taxes_rate = s.get('other_taxes_rate_pct', 1.0) / 100
|
||||
total_charges = cot_rate + vfl_rate + other_taxes_rate
|
||||
|
||||
# Charges calculées sur le CA (prix de vente HT net)
|
||||
# prix_ht_net = prix_ht / (1 - total_charges) so that charges = prix_ht_net * total_charges
|
||||
@@ -226,11 +229,15 @@ def calc(weight_g, print_time_s, design_mult, gross_margin_pct, discount_pct,
|
||||
else:
|
||||
prix_ht_net = prix_ht
|
||||
|
||||
cot_amount = prix_ht_net * cot_rate
|
||||
vfl_amount = prix_ht_net * vfl_rate
|
||||
tva_amount = prix_ht_net * tva_rate
|
||||
prix_ttc = prix_ht_net + tva_amount
|
||||
final = prix_ttc * (1 - discount_pct / 100)
|
||||
cot_amount = prix_ht_net * cot_rate
|
||||
vfl_amount = prix_ht_net * vfl_rate
|
||||
other_taxes_amount = prix_ht_net * other_taxes_rate
|
||||
tva_amount = prix_ht_net * tva_rate
|
||||
prix_ttc = prix_ht_net + tva_amount
|
||||
final = prix_ttc * (1 - discount_pct / 100)
|
||||
|
||||
# % de marge effective sur le prix HT final
|
||||
marge_pct_on_ht = (total_marge / prix_ht_net * 100) if prix_ht_net > 0 else 0
|
||||
|
||||
return {
|
||||
# Lignes détaillées
|
||||
@@ -248,20 +255,23 @@ def calc(weight_g, print_time_s, design_mult, gross_margin_pct, discount_pct,
|
||||
'subtotal': round(sous_total, 4),
|
||||
'margin_amount': round(margin, 4),
|
||||
'total_marge': round(total_marge, 4),
|
||||
'marge_pct_on_ht': round(marge_pct_on_ht, 1),
|
||||
'prix_ht': round(prix_ht, 4),
|
||||
# Fiscal
|
||||
'cotisations_amount': round(cot_amount, 4),
|
||||
'vfl_amount': round(vfl_amount, 4),
|
||||
'tva_amount': round(tva_amount, 4),
|
||||
'prix_ht_net': round(prix_ht_net, 4),
|
||||
'prix_ttc': round(prix_ttc, 4),
|
||||
'cotisations_amount': round(cot_amount, 4),
|
||||
'vfl_amount': round(vfl_amount, 4),
|
||||
'other_taxes_amount': round(other_taxes_amount, 4),
|
||||
'tva_amount': round(tva_amount, 4),
|
||||
'prix_ht_net': round(prix_ht_net, 4),
|
||||
'prix_ttc': round(prix_ttc, 4),
|
||||
# Compat
|
||||
'tax_amount': round(cot_amount + vfl_amount, 4),
|
||||
'tax_amount': round(cot_amount + vfl_amount + other_taxes_amount, 4),
|
||||
'final_price': round(final, 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),
|
||||
'_other_taxes_pct': round(other_taxes_rate * 100, 2),
|
||||
'_material_margin_pct': s['material_margin_pct'],
|
||||
'_handling_rate': s['handling_rate_per_hour'],
|
||||
'_handling_minutes': s['handling_minutes_per_plate'],
|
||||
|
||||
Reference in New Issue
Block a user