Projet

Général

Profil

Bug #53772

Données calculées : erreur 500 sur un formulaire (type décimal)

Ajouté par Marie Kuntz il y a presque 3 ans. Mis à jour il y a presque 3 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Version cible:
-
Début:
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Oui
Planning:
Non

Description

J'ai ajouté des données calculées sur un formulaire existant (https://demarches-gers.test.entrouvert.org/backoffice/forms/103/) et en arrivant sur la page qui contient ces champs, j'ai une erreur 500. L'erreur se poursuit sur tout le formulaire, si je reviens sur une page précédente et que je la rafraichis, j'ai aussi une erreur 500.

Les données calculées sont là : https://demarches-gers.test.entrouvert.org/backoffice/forms/103/fields/pages/429/

Pour reproduire, il faut aller jusqu'à la page "Récapitulatif calculs" : https://demarches-gers.test.entrouvert.org/sante-social/fond-de-solidarite-logement-travailleur-social-donnees-calculees/, j'ai isolé les DC sur la page suivante "page tmp" (l'affichage de cette page se fait correctement), en passant à la page d'après, l'erreur 500 se produit.


Fichiers

Révisions associées

Révision c05ae587 (diff)
Ajouté par Frédéric Péters il y a presque 3 ans

sql: use custom json encoder for computed data storage (#53772)

Historique

#1

Mis à jour par Frédéric Péters il y a presque 3 ans

Tu aurais un code suivi d'une demande permettant de voir cette erreur 500 sans saisir toutes les pages ?

#2

Mis à jour par Frédéric Péters il y a presque 3 ans

  • Sujet changé de Données calculées : erreur 500 sur un formulaire à Données calculées : erreur 500 sur un formulaire (type décimal)
Exception:
  type = '<class 'TypeError'>', value = 'Object of type Decimal is not JSON serializable'

C'est donc qu'il y a stockage d'un nombre décimal, ce qui n'est pas un type json. (je n'imaginais pas qu'un problème de ce type arriverait si vite et j'aurais parié sur les dates).

Pour référence :

  • uc_total_dc :
{% if form_var_foyer_plus_un == "Oui" or form_var_enfant_demandeur == "Oui" or form_var_couple_demandeur == "Oui" %}{% with var1=form_var_uc|getlist:"uc_foyer"|sum|add:form_var_uc_demandeur %}{% if var1|decimal > 4.5 %}4.5{% else %}{{ var1 }}{% endif %}{% endwith %}{% else %}{{form_var_uc_demandeur}}{% endif %}
  • reste_a_vivre_dc :
{% if form_var_foyer_plus_un == "Oui" %}{% with ressources=form_var_revenu_salaire_demandeur|add:form_var_revenu_non_salaire_demandeur|add:form_var_revenu_pension_alimentaire_demandeur|add:form_var_revenu_patrimoniaux_demandeur|add:form_var_revenu_autre_demandeur|add:form_var_revenu_salaire_foyer|add:form_var_revenu_non_salaire_foyer|add:form_var_revenu_pension_alimentaire_foyer|add:form_var_revenu_patrimoniaux_foyer|add:form_var_revenu_autre_foyer|add:form_var_allocation_demandeur|add:form_var_complement_demandeur|add:form_var_allocation_handicap_demandeur|add:form_var_rsa_demandeur|add:form_var_ppa_demandeur|add:form_var_chomage_demandeur|add:form_var_indemnite_demandeur|add:form_var_rente_demandeur|add:form_var_aide_sociale_demandeur|add:form_var_retraite_demandeur|add:form_var_autre_ressource_demandeur|add:form_var_allocation_foyer|add:form_var_complement_foyer|add:form_var_allocation_handicap_foyer|add:form_var_rsa_foyer|add:form_var_ppa_foyer|add:form_var_chomage_foyer|add:form_var_indemnite_foyer|add:form_var_rente_foyer|add:form_var_aide_sociale_foyer|add:form_var_retraite_foyer|add:form_var_autre_ressource_demandeur charges=form_var_charge_loyer|add:form_var_charge_locative|add:form_var_charge_accession|add:form_var_charge_pension_alimentaire|add:form_var_charge_electricite|add:form_var_charge_gaz|add:form_var_charge_eau|add:form_var_charge_chauffage|add:form_var_charge_assurance|add:form_var_charge_telephone|add:form_var_charge_mutuelle|add:form_var_charge_garde|add:form_var_charge_cantine|add:form_var_charge_impots|add:form_var_charge_transport|add:form_var_charge_autre dettes=form_var_dette_logement|add:form_var_dette_electricite|add:form_var_dette_gaz|add:form_var_dette_eau|add:form_var_dette_telephone|add:form_var_dette_alimentaire|add:form_var_dette_credit|add:form_var_dette_sante|add:form_var_dette_decouvert|add:form_var_dette_banque|add:form_var_dette_impot|add:form_var_dette_autre credits=form_var_credit_conso_montant|add:form_var_credit_auto_montant|add:form_var_credit_autre_montant %}{{ ressources|subtract:charges|subtract:dettes|subtract:credits}}{% endwith %}{% else %}{% with ressources=form_var_revenu_salaire_demandeur|add:form_var_revenu_non_salaire_demandeur|add:form_var_revenu_pension_alimentaire_demandeur|add:form_var_revenu_patrimoniaux_demandeur|add:form_var_revenu_autre_demandeur|add:form_var_allocation_demandeur|add:form_var_complement_demandeur|add:form_var_allocation_handicap_demandeur|add:form_var_rsa_demandeur|add:form_var_ppa_demandeur|add:form_var_chomage_demandeur|add:form_var_indemnite_demandeur|add:form_var_rente_demandeur|add:form_var_aide_sociale_demandeur|add:form_var_retraite_demandeur|add:form_var_autre_ressource_demandeur|add:form_var_autre_ressource_demandeur charges=form_var_charge_loyer|add:form_var_charge_locative|add:form_var_charge_accession|add:form_var_charge_pension_alimentaire|add:form_var_charge_electricite|add:form_var_charge_gaz|add:form_var_charge_eau|add:form_var_charge_chauffage|add:form_var_charge_assurance|add:form_var_charge_telephone|add:form_var_charge_mutuelle|add:form_var_charge_garde|add:form_var_charge_cantine|add:form_var_charge_impots|add:form_var_charge_transport|add:form_var_charge_autre dettes=form_var_dette_logement|add:form_var_dette_electricite|add:form_var_dette_gaz|add:form_var_dette_eau|add:form_var_dette_telephone|add:form_var_dette_alimentaire|add:form_var_dette_credit|add:form_var_dette_sante|add:form_var_dette_decouvert|add:form_var_dette_banque|add:form_var_dette_impot|add:form_var_dette_autre credits=form_var_plan_apurement|getlist:"credit_montant"|sum %}{{ ressources|subtract:charges|subtract:dettes|subtract:credits}}{% endwith %}{% endif %}
  • taux_effort_dc :
{% if form_var_foyer_plus_un == "Oui" or form_var_enfant_demandeur == "Oui" or form_var_couple_demandeur == "Oui" %}{% with ressources=form_var_revenu_salaire_demandeur|add:form_var_revenu_non_salaire_demandeur|add:form_var_revenu_pension_alimentaire_demandeur|add:form_var_revenu_patrimoniaux_demandeur|add:form_var_revenu_autre_demandeur|add:form_var_allocation_demandeur|add:form_var_complement_demandeur|add:form_var_allocation_handicap_demandeur|add:form_var_rsa_demandeur|add:form_var_ppa_demandeur|add:form_var_chomage_demandeur|add:form_var_indemnite_demandeur|add:form_var_rente_demandeur|add:form_var_aide_sociale_demandeur|add:form_var_retraite_demandeur|add:form_var_autre_ressource_demandeur|add:form_var_revenu_salaire_foyer|add:form_var_revenu_non_salaire_foyer|add:form_var_revenu_pension_alimentaire_foyer|add:form_var_revenu_patrimoniaux_foyer|add:form_var_revenu_autre_foyer|add:form_var_allocation_foyer|add:form_var_complement_foyer|add:form_var_allocation_handicap_foyer|add:form_var_rsa_foyer|add:form_var_ppa_foyer|add:form_var_chomage_foyer|add:form_var_indemnite_foyer|add:form_var_rente_foyer|add:form_var_aide_sociale_foyer|add:form_var_retraite_foyer|add:form_var_autre_ressource_foyer %}{% with loyer_residuel=form_var_charge_loyer|subtract:form_var_apl_demandeur|subtract:form_var_apl_foyer var1=ressources|multiply:100 %}{{loyer_residuel|divide:var1}}{% endwith %}{% endwith %}{% else %}{% with ressources=form_var_revenu_salaire_demandeur|add:form_var_revenu_non_salaire_demandeur|add:form_var_revenu_pension_alimentaire_demandeur|add:form_var_revenu_patrimoniaux_demandeur|add:form_var_revenu_autre_demandeur|add:form_var_allocation_demandeur|add:form_var_complement_demandeur|add:form_var_allocation_handicap_demandeur|add:form_var_rsa_demandeur|add:form_var_ppa_demandeur|add:form_var_chomage_demandeur|add:form_var_indemnite_demandeur|add:form_var_rente_demandeur|add:form_var_aide_sociale_demandeur|add:form_var_retraite_demandeur|add:form_var_autre_ressource_demandeur %}{% with loyer_residuel=form_var_charge_loyer|subtract:form_var_apl_demandeur var1=ressources|multiply:100 %}{{loyer_residuel|divide:var1}}{% endwith %}{% endwith %}{% endif %}
  • qf_dc :
{% if form_var_foyer_plus_un == "Oui" or form_var_enfant_demandeur == "Oui" or form_var_couple_demandeur == "Oui" %}{% with ressources=form_var_revenu_salaire_demandeur|add:form_var_revenu_non_salaire_demandeur|add:form_var_revenu_pension_alimentaire_demandeur|add:form_var_revenu_patrimoniaux_demandeur|add:form_var_revenu_autre_demandeur|add:form_var_revenu_salaire_foyer|add:form_var_revenu_non_salaire_foyer|add:form_var_revenu_pension_alimentaire_foyer|add:form_var_revenu_patrimoniaux_foyer|add:form_var_revenu_autre_foyer|add:form_var_allocation_demandeur|add:form_var_complement_demandeur|add:form_var_allocation_handicap_demandeur|add:form_var_rsa_demandeur|add:form_var_ppa_demandeur|add:form_var_chomage_demandeur|add:form_var_indemnite_demandeur|add:form_var_rente_demandeur|add:form_var_aide_sociale_demandeur|add:form_var_retraite_demandeur|add:form_var_autre_ressource_demandeur|add:form_var_allocation_foyer|add:form_var_complement_foyer|add:form_var_allocation_handicap_foyer|add:form_var_rsa_foyer|add:form_var_ppa_foyer|add:form_var_chomage_foyer|add:form_var_indemnite_foyer|add:form_var_rente_foyer|add:form_var_aide_sociale_foyer|add:form_var_retraite_foyer|add:form_var_autre_ressource_demandeur uc30=form_var_uc_total|multiply:30 %}{{ressources|divide:uc30}}{% endwith %}{% else %}{% with ressources=form_var_revenu_salaire_demandeur|add:form_var_revenu_non_salaire_demandeur|add:form_var_revenu_pension_alimentaire_demandeur|add:form_var_revenu_patrimoniaux_demandeur|add:form_var_revenu_autre_demandeur|add:form_var_allocation_demandeur|add:form_var_complement_demandeur|add:form_var_allocation_handicap_demandeur|add:form_var_rsa_demandeur|add:form_var_ppa_demandeur|add:form_var_chomage_demandeur|add:form_var_indemnite_demandeur|add:form_var_rente_demandeur|add:form_var_aide_sociale_demandeur|add:form_var_retraite_demandeur|add:form_var_autre_ressource_demandeur|add:form_var_autre_ressource_demandeur uc30=form_var_uc_total|multiply:30 %}{{ressources|divide:uc30}}{% endwith %}{% endif %}
#3

Mis à jour par Frédéric Péters il y a presque 3 ans

  • Assigné à mis à Frédéric Péters

La seule exploitation que je vois plus loin, c'est :

form_var_taux_effort_dc|decimal > 3

Étant donné le |decimal déjà présent, on pourrait avoir simplement comme règle de conversion de passer le type décimal sous forme de chaine de caractères.

#4

Mis à jour par Frédéric Péters il y a presque 3 ans

Encodage/décodage avant stockage.

#5

Mis à jour par Thomas Noël il y a presque 3 ans

  • Statut changé de Solution proposée à Solution validée

Sounds good, on gagne aussi la jsonification des dates ou des fichiers, c'est bien.

#6

Mis à jour par Frédéric Péters il y a presque 3 ans

  • Statut changé de Solution validée à Résolu (à déployer)
commit c05ae5877dd583844797528d530c238d12405019
Author: Frédéric Péters <fpeters@entrouvert.com>
Date:   Wed May 5 15:08:43 2021 +0200

    sql: use custom json encoder for computed data storage (#53772)
#7

Mis à jour par Frédéric Péters il y a presque 3 ans

  • Statut changé de Résolu (à déployer) à Solution déployée

Formats disponibles : Atom PDF