TVA en sélection des taux officiels français, TTC non éditable
Le champ TVA devient un select (0 %, 2,1 %, 5,5 %, 10 %, 20 %) plutôt qu'une saisie libre, avec une option "Autre (préciser)" qui révèle le champ décimal existant -- indispensable pour les lignes migrées, dont le taux rétro-calculé (figli_compta_ledger_update_8005()) est souvent un taux effectif non standard qu'il ne faut surtout pas forcer à s'aligner sur l'une des 5 valeurs officielles. Montant TTC passe de readonly à #disabled : non focusable, non éditable même via les flèches d'un input number, et Form API rejette toute valeur soumise malgré tout au profit de #default_value. Le select est un élément de formulaire à part (pas un widget de champ) pour éviter que WidgetBase::extractFormValues() ne s'étouffe sur une clé étrangère mêlée aux valeurs de field_tva -- un #validate callback recopie la valeur choisie dans field_tva au moment opportun (après tous les #validate, avant la reconstruction de l'entité au submit). L'affichage/masquage du champ "Autre" repose sur du JS simple plutôt que sur #states : #states pose bien l'attribut data-drupal-states mais ne bascule jamais la visibilité dans cette modale AJAX précise, pour une raison non identifiée (un #states pourtant fonctionnel existe juste au-dessus, sur field_entree_liee, qui surveille un vrai champ Field API plutôt qu'un select ajouté à la main).
This commit is contained in:
@@ -88,9 +88,18 @@ html.gin--dark-mode .figli-ledger-form {
|
||||
.figli-ledger-form > .field--name-field-montant-ht {
|
||||
grid-column: 1 / 2;
|
||||
}
|
||||
.figli-ledger-form > .field--name-field-tva {
|
||||
/* The field_tva_rate select (added in figli_compta_ledger_form_alter(),
|
||||
not a real field so it gets no field--name-* class) fills the middle
|
||||
slot of the HT/TVA/TTC row instead -- see that function's #weight
|
||||
comment for why this specific ordering (weight 6, between HT's 5 and
|
||||
TTC's 7) matters, not just matching column numbers. field_tva itself
|
||||
only appears -- full width, its own row -- when "Autre" is picked. */
|
||||
.figli-ledger-form > .js-form-item-field-tva-rate {
|
||||
grid-column: 2 / 3;
|
||||
}
|
||||
.figli-ledger-form > .field--name-field-tva {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
.figli-ledger-form > .field--name-field-montant-ttc {
|
||||
grid-column: 3 / 4;
|
||||
}
|
||||
@@ -135,12 +144,15 @@ html.gin--dark-mode .figli-ledger-form {
|
||||
outline: 2px solid var(--flform-accent);
|
||||
outline-offset: 1px;
|
||||
}
|
||||
/* Montant TTC: readonly, computed from HT + TVA (see
|
||||
figli_compta_ledger_node_presave()) -- a faint fill instead of the
|
||||
plain white/transparent of an editable field reads as "there but not
|
||||
for you to type in" without looking disabled/greyed-out. */
|
||||
.figli-ledger-form input[readonly].form-element {
|
||||
/* Montant TTC: #disabled, computed from HT + TVA (see
|
||||
figli_compta_ledger_node_presave()) -- a faint fill and full opacity
|
||||
(overriding the browser's default half-transparent disabled look,
|
||||
which would make the computed number harder to read) instead of the
|
||||
plain white/transparent of an editable field. */
|
||||
.figli-ledger-form input:disabled.form-element {
|
||||
background: var(--flform-bg-subtle);
|
||||
color: var(--flform-text);
|
||||
opacity: 1;
|
||||
cursor: default;
|
||||
}
|
||||
.figli-ledger-form input[type="date"].form-element {
|
||||
|
||||
Reference in New Issue
Block a user