CA3 hierarchise (cadres A/B, refs de lignes, split immo) + periodicite mensuelle/trimestrielle URSSAF et TVA
Deploy via Portainer / deploy (push) Successful in 1s
Deploy via Portainer / deploy (push) Successful in 1s
This commit is contained in:
+24
-7
@@ -24,6 +24,23 @@ def _annee(request):
|
||||
return int(request.GET.get("annee", date.today().year))
|
||||
|
||||
|
||||
TRIMESTRES = [(1, "T1 (janv.–mars)", [1, 2, 3]), (2, "T2 (avr.–juin)", [4, 5, 6]),
|
||||
(3, "T3 (juil.–sept.)", [7, 8, 9]), (4, "T4 (oct.–déc.)", [10, 11, 12])]
|
||||
|
||||
|
||||
def _periode(request, entreprise, champ):
|
||||
"""Retourne (mois_filtre, periode_sel, label, options, type) selon la
|
||||
périodicité (mensuelle/trimestrielle) configurée sur l'entreprise."""
|
||||
if getattr(entreprise, champ, "mensuelle") == "trimestrielle":
|
||||
defaut = (date.today().month - 1) // 3 + 1
|
||||
sel = min(max(int(request.GET.get("periode", defaut)), 1), 4)
|
||||
_, label, mois = TRIMESTRES[sel - 1]
|
||||
return mois, sel, label, [(i, lab) for i, lab, _ in TRIMESTRES], "trimestre"
|
||||
defaut = date.today().month
|
||||
sel = min(max(int(request.GET.get("periode", request.GET.get("mois", defaut))), 1), 12)
|
||||
return sel, sel, MOIS[sel - 1], [(i, MOIS[i - 1]) for i in range(1, 13)], "mois"
|
||||
|
||||
|
||||
def _base_ctx(request, entreprise, annee, vue):
|
||||
return {
|
||||
"entreprise": entreprise,
|
||||
@@ -68,10 +85,10 @@ def declaration_urssaf(request):
|
||||
if entreprise is None:
|
||||
return render(request, "compta/decl_urssaf.html", {"entreprise": None})
|
||||
annee = _annee(request)
|
||||
mois = int(request.GET.get("mois", date.today().month))
|
||||
mois, periode_sel, label, options, ptype = _periode(request, entreprise, "periodicite_urssaf")
|
||||
ctx = _base_ctx(request, entreprise, annee, "urssaf")
|
||||
ctx["mois_sel"] = mois
|
||||
ctx["decl"] = services.declaration_urssaf(entreprise, annee, mois)
|
||||
ctx.update({"periode_sel": periode_sel, "periode_options": options, "periode_type": ptype})
|
||||
ctx["decl"] = services.declaration_urssaf(entreprise, annee, mois, label)
|
||||
return render(request, "compta/decl_urssaf.html", ctx)
|
||||
|
||||
|
||||
@@ -81,12 +98,12 @@ def declaration_tva(request):
|
||||
if entreprise is None:
|
||||
return render(request, "compta/decl_tva.html", {"entreprise": None})
|
||||
annee = _annee(request)
|
||||
mois = int(request.GET.get("mois", date.today().month))
|
||||
mois, periode_sel, label, options, ptype = _periode(request, entreprise, "periodicite_tva")
|
||||
mode = request.GET.get("mode") or entreprise.vue_tva
|
||||
ctx = _base_ctx(request, entreprise, annee, "tva")
|
||||
ctx["mois_sel"] = mois
|
||||
ctx["mode"] = mode
|
||||
ctx["decl"] = services.declaration_tva(entreprise, annee, mois)
|
||||
ctx.update({"periode_sel": periode_sel, "periode_options": options,
|
||||
"periode_type": ptype, "mode": mode})
|
||||
ctx["decl"] = services.declaration_tva(entreprise, annee, mois, label)
|
||||
return render(request, "compta/decl_tva.html", ctx)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user