ajout immo : Choisir exercice avant date d'achat
This commit is contained in:
parent
673003ea77
commit
9f8660a51f
2 changed files with 33 additions and 76 deletions
43
scripts.js
43
scripts.js
|
|
@ -48,47 +48,6 @@ function disableOptions(idSelect, init, values) {
|
|||
}
|
||||
}
|
||||
|
||||
// choisir les exercices affichés selon la date paramètre
|
||||
function chooseYears(id_date, id_exercices, id_years)
|
||||
{
|
||||
// masquer le message d'erreur
|
||||
document.getElementById('erreur').setAttribute('class', 'hidden');
|
||||
// activer toutes les options
|
||||
const select_field = document.getElementById(id_exercices);
|
||||
for (const choix of select_field.options) {
|
||||
choix.removeAttribute('disabled');
|
||||
choix.removeAttribute('selected');
|
||||
}
|
||||
|
||||
// voir dans quels exercices ouverts se situe la date d'acquisition
|
||||
const date_achat = getDate(id_date);
|
||||
const years_data = document.getElementById(id_years);
|
||||
let array_years = [];
|
||||
for (const choix of years_data.options) {
|
||||
if (choix.value != '') {
|
||||
const epox = choix.text.split(' ');
|
||||
if (epox[0] <= date_achat && date_achat <= epox[1]) {
|
||||
array_years.push(choix.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (array_years.length == 0) {
|
||||
document.getElementById('erreur').setAttribute('class', '');
|
||||
disableOptions(select_field, 1, array_years);
|
||||
select_field.value = '';
|
||||
setAccountYear(['credit_account', 'debit_account'], 0);
|
||||
} else if (array_years.length == 1) {
|
||||
disableOptions(select_field, 0, array_years);
|
||||
select_field.value = array_years[0];
|
||||
setAccountYear(['credit_account', 'debit_account'], array_years[0]);
|
||||
} else {
|
||||
disableOptions(select_field, 1, array_years);
|
||||
select_field.value = '';
|
||||
setAccountYear(['credit_account', 'debit_account'], 0);
|
||||
}
|
||||
}
|
||||
|
||||
// afficher la date de fin de l'exercice choisi
|
||||
function setDateEnd(id_exercices, id_date, id_years) {
|
||||
const selected_year = document.getElementById(id_exercices).value;
|
||||
|
|
@ -107,7 +66,7 @@ function setDateEnd(id_exercices, id_date, id_years) {
|
|||
}
|
||||
}
|
||||
|
||||
// renvoyer la valeur numérique d'un montant formatté en €
|
||||
// renvoyer la valeur numérique d'un montant formaté en €
|
||||
function getNumber(text) {
|
||||
return Number(text.replace(/ /g, '').replace(/,/, '.').replace(/€/, ''));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue