forked from ScoDoc/ScoDoc
ajout taxe apprentissage
This commit is contained in:
parent
54a71b513a
commit
0485c8769d
@ -1,6 +1,7 @@
|
||||
"""entreprises.__init__
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from flask import Blueprint
|
||||
from app.scodoc import sco_etud
|
||||
from app.auth.models import User
|
||||
@ -47,4 +48,12 @@ def get_civilité(civ):
|
||||
return "Madame"
|
||||
|
||||
|
||||
@bp.app_template_filter()
|
||||
def check_taxe_now(taxes):
|
||||
for taxe in taxes:
|
||||
if taxe.annee == int(datetime.now().strftime("%Y")):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
from app.entreprises import routes
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
import re
|
||||
import requests
|
||||
from datetime import datetime
|
||||
|
||||
from flask_wtf import FlaskForm
|
||||
from flask_wtf.file import FileField, FileAllowed, FileRequired
|
||||
@ -33,6 +34,7 @@ from markupsafe import Markup
|
||||
from sqlalchemy import text
|
||||
from wtforms import (
|
||||
StringField,
|
||||
IntegerField,
|
||||
SubmitField,
|
||||
TextAreaField,
|
||||
SelectField,
|
||||
@ -44,7 +46,13 @@ from wtforms import (
|
||||
FormField,
|
||||
BooleanField,
|
||||
)
|
||||
from wtforms.validators import ValidationError, DataRequired, Email, Optional
|
||||
from wtforms.validators import (
|
||||
ValidationError,
|
||||
DataRequired,
|
||||
Email,
|
||||
Optional,
|
||||
NumberRange,
|
||||
)
|
||||
from wtforms.widgets import ListWidget, CheckboxInput
|
||||
|
||||
from app.entreprises.models import (
|
||||
@ -52,6 +60,7 @@ from app.entreprises.models import (
|
||||
EntrepriseCorrespondant,
|
||||
EntreprisePreferences,
|
||||
EntrepriseSite,
|
||||
EntrepriseTaxeApprentissage,
|
||||
)
|
||||
from app.models import Identite, Departement
|
||||
from app.auth.models import User
|
||||
@ -608,6 +617,50 @@ class StageApprentissageModificationForm(FlaskForm):
|
||||
raise ValidationError("Champ incorrect (selectionnez dans la liste)")
|
||||
|
||||
|
||||
class TaxeApprentissageForm(FlaskForm):
|
||||
hidden_entreprise_id = HiddenField()
|
||||
annee = IntegerField(
|
||||
"Année (*)",
|
||||
validators=[
|
||||
DataRequired(message=CHAMP_REQUIS),
|
||||
NumberRange(
|
||||
max=int(datetime.now().strftime("%Y")),
|
||||
message=f"L'année doit être inférieure ou égale à {int(datetime.now().strftime('%Y'))}",
|
||||
),
|
||||
],
|
||||
default=int(datetime.now().strftime("%Y")),
|
||||
)
|
||||
montant = IntegerField(
|
||||
"Montant (*)",
|
||||
validators=[
|
||||
DataRequired(message=CHAMP_REQUIS),
|
||||
NumberRange(
|
||||
min=1,
|
||||
message="Le montant doit être supérieur à 0",
|
||||
),
|
||||
],
|
||||
default=1,
|
||||
)
|
||||
notes = TextAreaField("Notes")
|
||||
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
||||
|
||||
def validate(self):
|
||||
validate = True
|
||||
if not FlaskForm.validate(self):
|
||||
validate = False
|
||||
|
||||
taxe = EntrepriseTaxeApprentissage.query.filter_by(
|
||||
entreprise_id=self.hidden_entreprise_id.data, annee=self.annee.data
|
||||
).first()
|
||||
if taxe is not None:
|
||||
self.annee.errors.append(
|
||||
"Une taxe d'apprentissage a déjà été versé pour cette année"
|
||||
)
|
||||
validate = False
|
||||
|
||||
return validate
|
||||
|
||||
|
||||
class EnvoiOffreForm(FlaskForm):
|
||||
responsables = FieldList(
|
||||
_build_string_field(
|
||||
@ -663,9 +716,11 @@ class DesactivationConfirmationForm(FlaskForm):
|
||||
notes_active = TextAreaField("Notes sur la désactivation", validators=[Optional()])
|
||||
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
|
||||
|
||||
|
||||
class ActivationConfirmationForm(FlaskForm):
|
||||
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
|
||||
|
||||
|
||||
class ValidationConfirmationForm(FlaskForm):
|
||||
submit = SubmitField("Valider", render_kw=SUBMIT_MARGE)
|
||||
|
||||
@ -685,6 +740,7 @@ class PreferencesForm(FlaskForm):
|
||||
mail_entreprise = StringField(
|
||||
"Mail notifications",
|
||||
validators=[Optional(), Email(message="Adresse e-mail invalide")],
|
||||
description="utilisé pour envoi mail notification application relations entreprises",
|
||||
)
|
||||
check_siret = BooleanField("Vérification SIRET")
|
||||
submit = SubmitField("Valider", render_kw=SUBMIT_MARGE)
|
||||
|
@ -155,6 +155,17 @@ class EntrepriseStageApprentissage(db.Model):
|
||||
notes = db.Column(db.Text)
|
||||
|
||||
|
||||
class EntrepriseTaxeApprentissage(db.Model):
|
||||
__tablename__ = "are_taxe_apprentissage"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
entreprise_id = db.Column(
|
||||
db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade")
|
||||
)
|
||||
annee = db.Column(db.Integer)
|
||||
montant = db.Column(db.Integer)
|
||||
notes = db.Column(db.Text)
|
||||
|
||||
|
||||
class EntrepriseEnvoiOffre(db.Model):
|
||||
__tablename__ = "are_envoi_offre"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
@ -30,6 +30,7 @@ from app.entreprises.forms import (
|
||||
StageApprentissageModificationForm,
|
||||
EnvoiOffreForm,
|
||||
AjoutFichierForm,
|
||||
TaxeApprentissageForm,
|
||||
ValidationConfirmationForm,
|
||||
ImportForm,
|
||||
PreferencesForm,
|
||||
@ -46,6 +47,7 @@ from app.entreprises.models import (
|
||||
EntrepriseEnvoiOffre,
|
||||
EntrepriseOffreDepartement,
|
||||
EntreprisePreferences,
|
||||
EntrepriseTaxeApprentissage,
|
||||
)
|
||||
from app.entreprises import app_relations_entreprises as are
|
||||
from app.models import Identite
|
||||
@ -181,6 +183,11 @@ def fiche_entreprise(id):
|
||||
.join(Identite, Identite.id == EntrepriseStageApprentissage.etudid)
|
||||
.all()
|
||||
)
|
||||
taxes = (
|
||||
EntrepriseTaxeApprentissage.query.filter_by(entreprise_id=id)
|
||||
.order_by(EntrepriseTaxeApprentissage.annee.desc())
|
||||
.all()
|
||||
)
|
||||
return render_template(
|
||||
"entreprises/fiche_entreprise.html",
|
||||
title="Fiche entreprise",
|
||||
@ -189,6 +196,7 @@ def fiche_entreprise(id):
|
||||
offres=offres_with_files,
|
||||
logs=logs,
|
||||
stages_apprentissages=stages_apprentissages,
|
||||
taxes=taxes,
|
||||
)
|
||||
|
||||
|
||||
@ -488,6 +496,32 @@ def fiche_entreprise_activer(id):
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/fiche_entreprise/<int:id>/add_taxe_apprentissage", methods=["GET", "POST"])
|
||||
def add_taxe_apprentissage(id):
|
||||
"""
|
||||
Permet d'ajouter une taxe d'apprentissage sur un fiche entreprise
|
||||
"""
|
||||
entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404(
|
||||
description=f"entreprise {id} inconnue"
|
||||
)
|
||||
form = TaxeApprentissageForm(hidden_entreprise_id=id)
|
||||
if form.validate_on_submit():
|
||||
taxe = EntrepriseTaxeApprentissage(
|
||||
entreprise_id=entreprise.id,
|
||||
annee=form.annee.data,
|
||||
montant=form.montant.data,
|
||||
notes=form.notes.data.strip(),
|
||||
)
|
||||
db.session.add(taxe)
|
||||
db.session.commit()
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id))
|
||||
return render_template(
|
||||
"entreprises/form.html",
|
||||
title="Ajout taxe apprentissage",
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@bp.route(
|
||||
"/fiche_entreprise_validation/<int:id>/validate_entreprise", methods=["GET", "POST"]
|
||||
)
|
||||
@ -1199,7 +1233,7 @@ def json_etudiants():
|
||||
if request.args.get("term") is None:
|
||||
abort(400)
|
||||
term = request.args.get("term").strip()
|
||||
etudiants = Identite.query.filter(Identite.nom.ilike(f"%{term}%")).all()
|
||||
etudiants = Identite.query.filter(Identite.nom.ilike(f"%{term}%")).limit(30).all()
|
||||
list = []
|
||||
for etudiant in etudiants:
|
||||
content = {}
|
||||
@ -1225,9 +1259,13 @@ def json_responsables():
|
||||
if request.args.get("term") is None:
|
||||
abort(400)
|
||||
term = request.args.get("term").strip()
|
||||
responsables = User.query.filter(
|
||||
responsables = (
|
||||
User.query.filter(
|
||||
User.nom.ilike(f"%{term}%"), User.nom.is_not(None), User.prenom.is_not(None)
|
||||
).all()
|
||||
)
|
||||
.limit(30)
|
||||
.all()
|
||||
)
|
||||
list = []
|
||||
|
||||
for responsable in responsables:
|
||||
|
@ -67,6 +67,20 @@
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.entreprise {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.entreprise > div {
|
||||
flex: 1 0 0;
|
||||
}
|
||||
|
||||
.taxe-apprentissage{
|
||||
overflow-y: scroll;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.sites-et-offres {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
@ -76,7 +76,7 @@
|
||||
{% if entreprise.active %}
|
||||
<li><a href="{{ url_for('entreprises.fiche_entreprise_desactiver', id=entreprise.id)}}" style="color:red">Désactiver</a></li>
|
||||
{% else %}
|
||||
<li><a href="{{ url_for('entreprises.fiche_entreprise_activer', id=entreprise.id)}}" style="color:blue">Activer</a></li>
|
||||
<li><a href="{{ url_for('entreprises.fiche_entreprise_activer', id=entreprise.id)}}" style="color:lightgreen">Activer</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -35,6 +35,23 @@
|
||||
Ville : {{ entreprise.ville }}<br>
|
||||
Pays : {{ entreprise.pays }}
|
||||
</div>
|
||||
|
||||
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
|
||||
<div>
|
||||
Taxe d'apprentissage<br>
|
||||
<a class="btn btn-primary" href="{{ url_for('entreprises.add_taxe_apprentissage', id=entreprise.id) }}">Ajouter taxe apprentissage</a>
|
||||
<div class="taxe-apprentissage">
|
||||
<ul>
|
||||
{% if not taxes|check_taxe_now %}
|
||||
<li>année actuelle : non versé</li>
|
||||
{% endif %}
|
||||
{% for taxe in taxes %}
|
||||
<li>{{ taxe.annee }} : {{ taxe.montant }} euros</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
Loading…
Reference in New Issue
Block a user