Skip to content

Commit

Permalink
missing values error messages and input type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arnold-pichler committed Sep 24, 2024
1 parent c8f595b commit 7d6225d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/components/TheEntryForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
label="Fläche (ha)"
variant="outlined"
density="compact"
type="number"
hide-details
/>
</v-col>
Expand Down Expand Up @@ -213,6 +214,7 @@
label="NMin"
variant="outlined"
density="compact"
type="number"
hide-details
/>
</v-col>
Expand Down Expand Up @@ -314,6 +316,7 @@
label="NMin"
variant="outlined"
density="compact"
type="number"
hide-details
/>
</v-col>
Expand Down Expand Up @@ -406,6 +409,7 @@
:label="`Menge (in ${entry.cultures[i - 1].duengung[f - 1].typ == 'handelsdünger' ? tableAttribut('handelsdünger', entry.cultures[i - 1].duengung[f - 1].id, 'Einheit') : 'm³'})`"
variant="outlined"
density="compact"
type="number"
hide-details
/>
</v-col>
Expand Down Expand Up @@ -438,6 +442,7 @@
label="N(%)"
variant="outlined"
density="compact"
type="number"
hide-details
/>
</v-col>
Expand All @@ -458,6 +463,7 @@
label="P₂O₅(%)"
variant="outlined"
density="compact"
type="number"
hide-details
/>
</v-col>
Expand All @@ -478,6 +484,7 @@
label="K₂O(%)"
variant="outlined"
density="compact"
type="number"
hide-details
/>
</v-col>
Expand Down Expand Up @@ -542,6 +549,7 @@
:label="`Ernte (in ${ertragsTyp(entry.cultures[i - 1].kultur, 'einheit')})`"
variant="outlined"
density="compact"
type="number"
hide-details
/>
</v-col>
Expand Down
40 changes: 33 additions & 7 deletions src/components/TheFertilizerBalance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ function calculateBilanz() {
}
// Kulturen
for (let c = 1; c < entry.value.cultures.length; c++) {
let kulturErrors = false;
for (let c = 0; c < entry.value.cultures.length; c++) {
let anyErrors = false;
if (entry.value.cultures[c].kultur != '') {
if (
tableAttribut('kulturen', entry.value.cultures[c].kultur, 'Ertragserfassungsart') !==
Expand All @@ -68,18 +68,44 @@ function calculateBilanz() {
) {
if (entry.value.cultures[c].ertragslage === '') {
errors.value.push(`${c}. Hauptfrucht: Erwartete Ertragslage nicht angegeben`);
kulturErrors = true;
anyErrors = true;
}
if (entry.value.cultures[c].ertragslageernte === '') {
if (
entry.value.cultures[c].ertragslageernte === '' &&
parseFloat(entry.value.cultures[c].ernte) === 0
) {
errors.value.push(`${c}. Hauptfrucht: Keine Angaben zur Ernte`);
kulturErrors = true;
anyErrors = true;
}
}
if (!kulturErrors) {
// Düngung
if (entry.value.cultures[c].duengung.length > 0) {
for (let d = 0; d < entry.value.cultures[c].duengung.length; d++) {
if (entry.value.cultures[c].duengung[d].typ === '') {
if (c > 0) {
errors.value.push(`${c}. Hauptfrucht, ${d + 1}. Düngung: Keine Angaben zum Typ`);
} else {
errors.value.push(`Zwischenfrucht, ${d + 1}. Düngung: Keine Angaben zum Typ`);
}
anyErrors = true;
} else if (entry.value.cultures[c].duengung[d].menge <= 0) {
if (c > 0) {
errors.value.push(`${c}. Hauptfrucht, ${d + 1}. Düngung: Fehlende Mengenangabe`);
} else {
errors.value.push(`Zwischenfrucht, ${d + 1}. Düngung: Fehlende Mengenangabe`);
}
anyErrors = true;
}
}
}
if (!anyErrors) {
// Balance goes here / WIP
}
} else {
errors.value.push(`${c}. Hauptfrucht: Keine Kultur definiert`);
if (c > 0) {
errors.value.push(`${c}. Hauptfrucht: Keine Kultur definiert`);
}
}
}
bilanz.value = [];
Expand Down

0 comments on commit 7d6225d

Please sign in to comment.