-
Notifications
You must be signed in to change notification settings - Fork 4
Support common units for fertilizer application amounts (l/ha, m3/ha, ton/ha) #565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
f9a6e48
Add option to select fertilizer catalogue application amount unit
BoraIneviNMI a30916f
Adapt fdm-app to use the new fertilizer application amount display va…
BoraIneviNMI 3ce3f81
Add changeset
BoraIneviNMI a49a207
Merge branch 'development' into FDM520
BoraIneviNMI c3e20c9
Address nitpicks
BoraIneviNMI ae03041
Add fertilizer application units to the bemestingsplan PDF
BoraIneviNMI 9990a93
Use hardcoded table for RVO code unit suggestions
BoraIneviNMI b6724d3
Add extendCatalogueFertilizer and improve coverage
BoraIneviNMI e012719
Merge branch 'development' into FDM520
BoraIneviNMI bdb0b20
Address nitpicks
BoraIneviNMI 57f9802
Remove unused import
BoraIneviNMI 81c97fc
Move unit conversions in Gerrit
BoraIneviNMI 2cd07c9
Fix type errors in fdm-calculator
BoraIneviNMI 708bfe9
Do not use path alias in fdm-calculator
BoraIneviNMI 4097f6b
Improve things
BoraIneviNMI 53d774a
Add fertilizer RVO code 120
BoraIneviNMI e367153
Reject non-positive density values in fromKgPerHa
BoraIneviNMI 945e92c
Add a way to specify fertilizer amounts directly in kg/ha
BoraIneviNMI 2f53d99
Fix type errors
BoraIneviNMI 0b4107b
Combine CalculatorFertilizerApplication and IncompleteFertilizerAppli…
BoraIneviNMI 68f884f
Make stuff consistent
BoraIneviNMI 6b0251d
Address nitpicks
BoraIneviNMI 62d302a
Remove the way to specify fertilizer application amount unit
BoraIneviNMI 2d1e863
Rename unit-conversion module and add more tests
BoraIneviNMI 67c5d6e
Merge branch 'development' into FDM520
SvenVw 91ffed3
fix: use lowercase for liters
SvenVw 1ded75c
refactor: at the unit conversion return number instead of decimal
SvenVw 8ae1387
docs: improve typedocs for fertilizer application unit conversion fun…
SvenVw 45ba4c6
refactor: remove functio to guess unit of fertilizer
SvenVw a922790
feat: Add default values for p_app_amount_unit to baat catalogue
SvenVw 30dfb1b
refactor: remove some left over code
SvenVw 3cbec2c
refactor: use lowecase for liter
SvenVw e9c797d
refactor: some type improvements
SvenVw f8502b1
refactor: improve text
SvenVw deb98d2
refactor: make sure gerrit uses display units
SvenVw f70fff3
fix: enable to update the unit of fertilzier
SvenVw 5fae90e
fix: zod for p_amount_app_display
SvenVw fe7a0ec
tests: remove not used tests
SvenVw 2ba6be3
tests: fix
SvenVw 60eac40
fix: type issue
SvenVw 16e9f40
tests: fixes
SvenVw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@nmi-agro/fdm-data": minor | ||
| --- | ||
|
|
||
| Add default values for p_app_amount_unit to baat catalogue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@nmi-agro/fdm-app": minor | ||
| --- | ||
|
|
||
| Fertilizer application amounts are now shown in units relevant to the fertilizer type used, possibly saving the user from converting application amounts to kg/ha all the time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@nmi-agro/fdm-core": minor | ||
| --- | ||
|
|
||
| addFertilizerApplication and updateFertilizerApplication functions now expect an application value in the unit defined for the fertilizer, instead of kg/ha for every fertilizer. The unit is included in the return values of `getFertilizer`, `getFertilizers` etc. as `p_app_amount_unit`. `getFertilizerApplication`, `getFertilizerApplications` etc. now include `p_app_amount_display` and `p_app_amount_unit` which are to be shown to the user instead of p_app_amount and `kg/ha`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
fdm-app/app/components/blocks/fertilizer-applications/formschema.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
fdm-app/app/components/blocks/fertilizer-applications/utils.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import type { AppAmountUnit } from "@nmi-agro/fdm-core" | ||
|
|
||
| export const applicationUnitOptions = { | ||
| "kg/ha": { label: "kg/ha", totalLabel: "kg" }, | ||
| "ton/ha": { label: "ton/ha", totalLabel: "ton" }, | ||
| "l/ha": { label: "l/ha", totalLabel: "L" }, | ||
| "m3/ha": { label: "m³/ha", totalLabel: "m³" }, | ||
| } as const | ||
|
|
||
| /** | ||
| * Get the pretty-printed mass or volume per area unit for fertilizer applications | ||
| * @param unit unit to get the label for | ||
| * @returns the pretty-printed unit | ||
| */ | ||
| export function getApplicationAmountUnitLabel(unit: AppAmountUnit) { | ||
| return applicationUnitOptions[unit].label | ||
| } | ||
|
|
||
| /** | ||
| * Gets the pretty-printed mass or volume unit for fertilizer applications (for when taking sum of areas times application amounts) | ||
| * @param unit unit to get the corresponding unit for | ||
| * @returns the pretty-printed corresponding mass or volume unit | ||
| */ | ||
| export function getApplicationAmountTotalUnitLabel(unit: AppAmountUnit) { | ||
| return applicationUnitOptions[unit].totalLabel | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.