Skip to content

Add Renure Support for 2026 Norms and Fertilizer Planning - #712

Merged
SvenVw merged 19 commits into
developmentfrom
FDM675
Jul 24, 2026
Merged

Add Renure Support for 2026 Norms and Fertilizer Planning#712
SvenVw merged 19 commits into
developmentfrom
FDM675

Conversation

@SvenVw

@SvenVw SvenVw commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added Renure fertilizer/norm support for 2026+ (incl. 80 kg N/ha) across planning, compliance, and norms calculations.
    • Added an “include Renure products” planning option that only impacts 2026+.
    • Updated the UI to show Renure-specific norms/filling (including “Renure N”) and improved fertilizer visuals using Renure RVO codes across dashboards and timeline views.
  • Bug Fixes
    • Newly synced fertilizer catalogue items are now automatically provisioned for existing farms with the relevant catalogue enabled.
  • Tests
    • Expanded Renure coverage for norms, prompts, product filtering, compliance, and catalogue synchronization.

Closes #675

SvenVw added 11 commits July 22, 2026 10:02
…e as 4th norm and provide value and filling functions. For 2025 do not return Renure norm and count as manure for filling.
…BAAT fertilizer catalogue: Ammoniumsulfaat, Ammoniumnitraat, Mineralenconcentraat and Ammoniumstruviet. Also two non-Renure variants of Ammoniumstruviet and Kaliumstruviet are added. For mestcode 134 no default product has been added to the catalogue as it is a generic "other" category.
…run on app startup) now automatically acquires a newly introduced fertilizer catalogue product for every existing farm that already has that catalogue source enabled, mirroring the bulk-acquisition that happens when a new farm is created
@SvenVw SvenVw self-assigned this Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@SvenVw, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bbb15f01-70c4-469e-846a-4c5f510cd2d6

📥 Commits

Reviewing files that changed from the base of the PR and between 75e7bcf and 5a3a753.

📒 Files selected for processing (2)
  • fdm-app/app/components/blocks/fertilizer/form.tsx
  • fdm-core/src/db/schema.ts
📝 Walkthrough

Walkthrough

Renure support is added across fertilizer catalogues, 2025/2026 norm calculations, fertilizer planning, Gerrit agent contracts, synchronization, and application displays. RVO codes 130–134 are propagated through data flows, with 2026-specific norms and includeRenure handling.

Changes

Renure calculation and catalogue support

Layer / File(s) Summary
2025/2026 calculator and aggregation
fdm-calculator/src/norms/...
Renure is treated as manure in 2025 and as a separate 80 kg N/ha norm with application fillings from 2026; farm aggregation and tests include Renure values.
Catalogue and synchronization
fdm-core/src/..., fdm-data/src/..., fdm-core/src/db/...
RVO codes 130–134, BAAT products, database enum values, and acquisition backfilling for newly synced catalogue products are added.

Planning and application integration

Layer / File(s) Summary
Agent planning and compliance
fdm-agents/src/...
The includeRenure strategy, prompt guidance, fertilizer filtering, simulation compliance checks, and Gerrit norm contracts are extended for 2026+.
Norm display and metrics
fdm-app/app/integrations/..., fdm-app/app/lib/..., fdm-app/app/components/blocks/norms/..., fdm-app/app/routes/...norms...
Renure norms, fillings, progress bars, cards, and application breakdowns are calculated and conditionally displayed for 2026+.
Fertilizer metadata and visual classification
fdm-app/app/components/..., fdm-app/app/routes/...
p_type_rvo is propagated through fertilizer, rotation, farm, and timeline data; Renure receives dedicated icons, colors, badges, and strategy-form filtering.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • nmi-agro/fdm#156: Extends the same farm-level norm aggregation logic used here with a Renure norm field.
  • nmi-agro/fdm#285: Establishes shared p_type_rvo classification paths extended here for Renure.
  • nmi-agro/fdm#618: Refactors the fertilizer-planner paths used by the new Renure logic.

Suggested labels: enhancement, fdm-app, fdm-core, fdm-data, fdm-calculator

Suggested reviewers: gerardhros

Poem

A rabbit hops through fields of green,
Four norms now bloom where three had been.
RVO codes dance in a row,
Renure icons softly glow.
“JA or NEE?” the planner sings—
2026 sprouts new things! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR implements Renure support across core, app, calculator, catalogue, and Gerrit flows, matching the linked issue's 2026+ requirements and tests.
Out of Scope Changes check ✅ Passed The changed files are all tied to Renure norms, catalogue data, UI, or Gerrit behavior, with no unrelated scope expansion evident.
Title Check ✅ Passed Title check skipped as CodeRabbit has written the PR title.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch FDM675

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.55172% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
fdm-agents/src/tools/fertilizer-planner/index.ts 90.62% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot changed the title @coderabbitai Add Renure Support for 2026 Norms and Fertilizer Planning Jul 23, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (2)
fdm-app/app/components/blocks/timeline/timeline-colors.ts (1)

13-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Align the helper parameter with FertilizerKind.

FertilizerKind and the runtime fallback both support "other", but getFertilizerKindColor rejects it at compile time. Accept FertilizerKind | null | undefined (or remove "other" from the exported union) to avoid caller-side casts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@fdm-app/app/components/blocks/timeline/timeline-colors.ts` around lines 13 -
24, Update the getFertilizerKindColor parameter type to use FertilizerKind |
null | undefined, ensuring it accepts the existing "other" value while
preserving the current null/undefined fallback behavior and
FERTILIZER_KIND_COLOR mapping.
fdm-app/app/lib/gerrit.server.ts (1)

183-185: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the Renure filling call type-safe.

Line 184 uses as any, so TypeScript cannot verify that the 2026 factory exposes this method or that it returns NormFilling; a contract drift would become a runtime failure. Expose the 2026 method through a typed factory branch instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@fdm-app/app/lib/gerrit.server.ts` around lines 183 - 185, Replace the
`(fillingFuncs as any)` access in the 2026 branch with a typed factory branch
that explicitly exposes `calculateFertilizerApplicationFillingForRenure` and
returns `NormFilling`. Ensure the factory’s type contract verifies both method
availability and return type, while preserving `Promise.resolve(undefined)` for
non-2026 years.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@fdm-agents/src/tools/fertilizer-planner/index.ts`:
- Around line 750-763: The fertilizer planner must enforce the independent 2026
Renure ceiling regardless of includeRenure. In
fdm-agents/src/tools/fertilizer-planner/index.ts lines 750-763, calculate and
aggregate Renure norm/filling from 2026 onward, expose them through farmTotals,
and add compliance validation for exceeding 80 kg N/ha while retaining
includeRenure only for product eligibility. In
fdm-agents/src/tools/fertilizer-planner/index.test.ts lines 846-852, verify
enabling Renure suppresses only the strategy opt-out issue and add coverage for
a plan exceeding the Renure ceiling.

In `@fdm-app/app/components/blocks/gerrit/strategy-form.tsx`:
- Around line 99-120: Update the effect around includeRenure to return without
changing selections when showRenure is false. When showRenure is enabled, do not
automatically append Renure product IDs for includeRenure true or undefined;
preserve the user’s existing selectedFertilizerIds, while retaining filtering of
Renure products when includeRenure is explicitly false.

In `@fdm-app/app/components/blocks/timeline/mobile-view.tsx`:
- Line 79: Update eventColor, used by EventTypeIcon for the mobile event tile
styling, to detect Renure using event.p_type_rvo in addition to event.p_type.
Ensure Renure events use the same color classification as FertilizerIcon instead
of relying solely on the primary type.

In `@fdm-app/app/routes/farm`.$b_id_farm.$calendar.norms.$b_id.tsx:
- Around line 340-345: Update the showRenure rendering block to conditionally
render both ItemSeparator and renderApplicationContributionForNorm only when
applicationFilling.renure exists; keep the current behavior unchanged when a
Renure contribution is present.

In `@fdm-core/src/catalogues.ts`:
- Around line 646-670: Update the public catalogue-product creation flow around
the farm backfill loop to require authorization before creating farm-owned
fertilizer, acquiring, and picking records. Pass an acting principal_id and
validate that principal’s permission for each farm, or enforce an explicitly
privileged scheduler-only actor; do not perform the inserts for unauthorized
farms.

In `@fdm-data/src/fertilizers/catalogues/baat.json`:
- Around line 2941-3192: Add a new BAAT catalogue entry for Renure “ander
ammoniumzout” with p_type_rvo set to 134, matching the existing Renure catalogue
conventions and required nutrient/application fields. Keep the existing
Ammoniumstruviet and Kaliumstruviet entries BAAT076 and BAAT077 unchanged at
p_type_rvo 115.

---

Nitpick comments:
In `@fdm-app/app/components/blocks/timeline/timeline-colors.ts`:
- Around line 13-24: Update the getFertilizerKindColor parameter type to use
FertilizerKind | null | undefined, ensuring it accepts the existing "other"
value while preserving the current null/undefined fallback behavior and
FERTILIZER_KIND_COLOR mapping.

In `@fdm-app/app/lib/gerrit.server.ts`:
- Around line 183-185: Replace the `(fillingFuncs as any)` access in the 2026
branch with a typed factory branch that explicitly exposes
`calculateFertilizerApplicationFillingForRenure` and returns `NormFilling`.
Ensure the factory’s type contract verifies both method availability and return
type, while preserving `Promise.resolve(undefined)` for non-2026 years.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b9b3fd0c-f457-4959-8edf-24117f60c618

📥 Commits

Reviewing files that changed from the base of the PR and between 5c95c23 and 43ba345.

📒 Files selected for processing (65)
  • .changeset/gentle-donkeys-smile.md
  • .changeset/gentle-herons-relax.md
  • .changeset/khaki-corners-cheer.md
  • .changeset/quiet-jokes-relax.md
  • .changeset/six-games-sit.md
  • .changeset/yummy-wasps-happen.md
  • fdm-agents/src/agents/gerrit/agent.ts
  • fdm-agents/src/agents/gerrit/schema.ts
  • fdm-agents/src/index.test.ts
  • fdm-agents/src/index.ts
  • fdm-agents/src/tools/fertilizer-planner/index.test.ts
  • fdm-agents/src/tools/fertilizer-planner/index.ts
  • fdm-app/app/components/blocks/farms/columns.tsx
  • fdm-app/app/components/blocks/fertilizer-applications/list.tsx
  • fdm-app/app/components/blocks/fertilizer-applications/metrics.tsx
  • fdm-app/app/components/blocks/fertilizer/columns.tsx
  • fdm-app/app/components/blocks/fertilizer/form.tsx
  • fdm-app/app/components/blocks/fertilizer/utils.ts
  • fdm-app/app/components/blocks/fields/columns.tsx
  • fdm-app/app/components/blocks/gerrit/plan-table.tsx
  • fdm-app/app/components/blocks/gerrit/schema.ts
  • fdm-app/app/components/blocks/gerrit/strategy-form.tsx
  • fdm-app/app/components/blocks/gerrit/summary-cards.tsx
  • fdm-app/app/components/blocks/gerrit/types.ts
  • fdm-app/app/components/blocks/norms/farm-norms.tsx
  • fdm-app/app/components/blocks/norms/field-norms.tsx
  • fdm-app/app/components/blocks/rotation/columns.tsx
  • fdm-app/app/components/blocks/rotation/fertilizer-display.tsx
  • fdm-app/app/components/blocks/timeline/gantt-view.tsx
  • fdm-app/app/components/blocks/timeline/mobile-view.tsx
  • fdm-app/app/components/blocks/timeline/timeline-colors.ts
  • fdm-app/app/components/blocks/timeline/timeline-events.ts
  • fdm-app/app/components/custom/fertilizer-icon.tsx
  • fdm-app/app/integrations/calculator.ts
  • fdm-app/app/lib/gerrit.server.ts
  • fdm-app/app/routes/api.gerrit.stream.ts
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id._index.tsx
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.gerrit.tsx
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.norms.$b_id.tsx
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.norms._index.tsx
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.rotation.tsx
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.timeline.tsx
  • fdm-app/app/routes/organization.$slug.$calendar.farms._index.tsx
  • fdm-calculator/src/norms/farm.test.ts
  • fdm-calculator/src/norms/farm.ts
  • fdm-calculator/src/norms/index.ts
  • fdm-calculator/src/norms/nl/2025/filling/dierlijke-mest-gebruiksnorm.test.ts
  • fdm-calculator/src/norms/nl/2025/filling/table-11-mestcodes.ts
  • fdm-calculator/src/norms/nl/2025/filling/table-9.ts
  • fdm-calculator/src/norms/nl/2026/filling/dierlijke-mest-gebruiksnorm.test.ts
  • fdm-calculator/src/norms/nl/2026/filling/renure-gebruiksnorm.test.ts
  • fdm-calculator/src/norms/nl/2026/filling/renure-gebruiksnorm.ts
  • fdm-calculator/src/norms/nl/2026/filling/table-11-mestcodes.ts
  • fdm-calculator/src/norms/nl/2026/filling/table-9.ts
  • fdm-calculator/src/norms/nl/2026/filling/types.d.ts
  • fdm-calculator/src/norms/nl/2026/value/renure-gebruiksnorm.test.ts
  • fdm-calculator/src/norms/nl/2026/value/renure-gebruiksnorm.ts
  • fdm-core/src/catalogues.test.ts
  • fdm-core/src/catalogues.ts
  • fdm-core/src/db/migrations/0032_overjoyed_beast.sql
  • fdm-core/src/db/migrations/meta/0032_snapshot.json
  • fdm-core/src/db/migrations/meta/_journal.json
  • fdm-core/src/db/schema.ts
  • fdm-core/src/fertilizer.ts
  • fdm-data/src/fertilizers/catalogues/baat.json

Comment thread fdm-agents/src/tools/fertilizer-planner/index.ts
Comment thread fdm-app/app/components/blocks/gerrit/strategy-form.tsx Outdated
Comment thread fdm-app/app/components/blocks/timeline/mobile-view.tsx Outdated
Comment thread fdm-app/app/routes/farm.$b_id_farm.$calendar.norms.$b_id.tsx Outdated
Comment thread fdm-core/src/catalogues.ts
Comment thread fdm-data/src/fertilizers/catalogues/baat.json

@BoraIneviNMI BoraIneviNMI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the farm.$b_id_farm.fertilizers.new._index route you need to include the purple color for renures too.

? "bg-blue-600 text-white hover:bg-blue-700"
: "bg-gray-600 text-white hover:bg-gray-700"
isRenure
? "bg-purple-600 text-white hover:bg-purple-700"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its correct that this structure differs? so RENURE is not a p_type but a boolean p_type_rvo? is this because a RENURE is basically another type of mineral product?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in f34c731

.filter((name) => {
if (name === "isDerogation") return showDerogation
if (name === "includeRenure") return showRenure
return true

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both TRUE can never occur?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes Renure is available from 2026 and degoration up to 2025

phosphate: GebruiksnormResult
nitrogen: GebruiksnormResult
renure?: GebruiksnormResult
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question mark makes it optional?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

export function getFertilizerKindColor(
p_type: "manure" | "mineral" | "compost" | null | undefined,
p_type: FertilizerKind | null | undefined,
): string {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is not only adding renure but switching all p_types to the export const. is that preferred above just adding "renure"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the type for fertilizer is now defined at a single place

"p_ef_nh3": 0.113,
"p_name_nl": "Ammoniumsulfaat (Renure)",
"p_dm": 999,
"p_density": 1,

@gerardhros gerardhros Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this actually a granule or a liquid? might discuss Romke.
https://wiki.groenkennisnet.nl/space/mestverwaarding/330170384/RENURE

Most RENURE products are aqueous mineral concentrates, liquid digestate fractions, or purified ammonium salt solutions created via reverse osmosis, evaporation, or stripping-scrubbing technologies
https://nutriman.net/sites/default/files/2020-07/520-INFO_SHEET_PRODUCT-Mineral_concentrate.pdf

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in d014d19

"p_zn_rt": null,
"p_type_rvo": 130,
"p_app_method_options": "broadcasting||pocket placement||incorporation",
"p_app_amount_unit": "kg/ha",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

application depends on form, if liquid then injection?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in d014d19

@gerardhros gerardhros left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice update, looks great.
see few questions. Most import one is the composition of RENURE, being granular or liquid. To be discussed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
fdm-app/app/components/blocks/gerrit/strategy-form.tsx (1)

99-112: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the shared Renure classifier.

The local code list duplicates RENURE_RVO_CODES; use isRenureRvoCode(fert?.p_type_rvo) so filtering stays aligned with catalogue metadata.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@fdm-app/app/components/blocks/gerrit/strategy-form.tsx` around lines 99 -
112, Update the filtering logic in the useEffect around selectedFertilizerIds to
remove the local renureCodes list and use the shared isRenureRvoCode classifier
with fert?.p_type_rvo. Preserve the existing behavior for non-renure fertilizers
and the current form update flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@fdm-app/app/components/blocks/fertilizer/utils.ts`:
- Around line 11-22: Update getFertilizerCategoryFromRvoCode in
fdm-app/app/components/blocks/fertilizer/utils.ts to expose a shared resolver
accepting p_type and p_type_rvo, preferring every recognized RVO category
including Renure and falling back to p_type. In
fdm-app/app/components/blocks/fertilizer-applications/list.tsx:60-63, use this
resolver for FertilizerIcon; in
fdm-app/app/components/blocks/fields/columns.tsx:160-162 and
fdm-app/app/components/blocks/rotation/fertilizer-display.tsx:36-43, preserve
fertilizer.p_type as the fallback; and in
fdm-app/app/components/blocks/timeline/mobile-view.tsx:60-82, derive one
resolved kind and reuse it for both tile color and icon.

---

Nitpick comments:
In `@fdm-app/app/components/blocks/gerrit/strategy-form.tsx`:
- Around line 99-112: Update the filtering logic in the useEffect around
selectedFertilizerIds to remove the local renureCodes list and use the shared
isRenureRvoCode classifier with fert?.p_type_rvo. Preserve the existing behavior
for non-renure fertilizers and the current form update flow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 581a6785-9f30-4b17-9095-2e6dfde6414f

📥 Commits

Reviewing files that changed from the base of the PR and between 43ba345 and f34c731.

📒 Files selected for processing (22)
  • .changeset/gentle-herons-relax.md
  • fdm-agents/src/tools/fertilizer-planner/index.test.ts
  • fdm-agents/src/tools/fertilizer-planner/index.ts
  • fdm-app/app/components/blocks/fertilizer-applications/list.tsx
  • fdm-app/app/components/blocks/fertilizer/columns.tsx
  • fdm-app/app/components/blocks/fertilizer/utils.ts
  • fdm-app/app/components/blocks/fields/columns.tsx
  • fdm-app/app/components/blocks/gerrit/plan-table.tsx
  • fdm-app/app/components/blocks/gerrit/strategy-form.tsx
  • fdm-app/app/components/blocks/gerrit/types.ts
  • fdm-app/app/components/blocks/rotation/fertilizer-display.tsx
  • fdm-app/app/components/blocks/timeline/gantt-view.tsx
  • fdm-app/app/components/blocks/timeline/mobile-view.tsx
  • fdm-app/app/components/blocks/timeline/timeline-colors.ts
  • fdm-app/app/components/custom/fertilizer-badge.tsx
  • fdm-app/app/components/custom/fertilizer-icon.tsx
  • fdm-app/app/lib/gerrit.server.ts
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.norms.$b_id.tsx
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.rotation.tsx
  • fdm-calculator/src/norms/nl/2026/filling/renure-gebruiksnorm.test.ts
  • fdm-core/src/db/schema.ts
  • fdm-data/src/fertilizers/catalogues/baat.json
🚧 Files skipped from review as they are similar to previous changes (9)
  • .changeset/gentle-herons-relax.md
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.rotation.tsx
  • fdm-core/src/db/schema.ts
  • fdm-agents/src/tools/fertilizer-planner/index.test.ts
  • fdm-app/app/components/blocks/fertilizer/columns.tsx
  • fdm-app/app/components/custom/fertilizer-icon.tsx
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.norms.$b_id.tsx
  • fdm-app/app/lib/gerrit.server.ts
  • fdm-app/app/components/blocks/timeline/gantt-view.tsx

Comment on lines +11 to +22
export function getFertilizerCategoryFromRvoCode(
p_type_rvo?: string | null,
): FertilizerKind {
if (p_type_rvo) {
if (RENURE_RVO_CODES.includes(p_type_rvo)) return "renure"
if (MINERAL_RVO_CODES.includes(p_type_rvo)) return "mineral"
if (COMPOST_RVO_CODES.includes(p_type_rvo)) return "compost"
if (MANURE_RVO_CODES.includes(p_type_rvo)) return "manure"
if (OTHER_RVO_CODES.includes(p_type_rvo)) return "other"
}
return "other"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Resolve fertilizer kind from both metadata fields consistently.

RVO-only callers turn products without p_type_rvo into other, while the applications list prioritizes potentially stale p_type; mobile timeline color and icon can therefore disagree. Add one resolver that uses a recognized RVO category (including Renure) and otherwise falls back to p_type, then use it everywhere.

  • fdm-app/app/components/blocks/fertilizer/utils.ts#L11-L22: expose a resolver accepting both p_type and p_type_rvo.
  • fdm-app/app/components/blocks/fertilizer-applications/list.tsx#L60-L63: use the shared resolver instead of passing competing values to FertilizerIcon.
  • fdm-app/app/components/blocks/fields/columns.tsx#L160-L162: retain fertilizer.p_type as fallback when RVO metadata is missing.
  • fdm-app/app/components/blocks/rotation/fertilizer-display.tsx#L36-L43: retain fertilizer.p_type as fallback when RVO metadata is missing.
  • fdm-app/app/components/blocks/timeline/mobile-view.tsx#L60-L82: derive one kind and use it for both tile color and icon.
📍 Affects 5 files
  • fdm-app/app/components/blocks/fertilizer/utils.ts#L11-L22 (this comment)
  • fdm-app/app/components/blocks/fertilizer-applications/list.tsx#L60-L63
  • fdm-app/app/components/blocks/fields/columns.tsx#L160-L162
  • fdm-app/app/components/blocks/rotation/fertilizer-display.tsx#L36-L43
  • fdm-app/app/components/blocks/timeline/mobile-view.tsx#L60-L82
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@fdm-app/app/components/blocks/fertilizer/utils.ts` around lines 11 - 22,
Update getFertilizerCategoryFromRvoCode in
fdm-app/app/components/blocks/fertilizer/utils.ts to expose a shared resolver
accepting p_type and p_type_rvo, preferring every recognized RVO category
including Renure and falling back to p_type. In
fdm-app/app/components/blocks/fertilizer-applications/list.tsx:60-63, use this
resolver for FertilizerIcon; in
fdm-app/app/components/blocks/fields/columns.tsx:160-162 and
fdm-app/app/components/blocks/rotation/fertilizer-display.tsx:36-43, preserve
fertilizer.p_type as the fallback; and in
fdm-app/app/components/blocks/timeline/mobile-view.tsx:60-82, derive one
resolved kind and reuse it for both tile color and icon.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@fdm-app/app/routes/farm`.$b_id_farm.fertilizers.new._index.tsx:
- Around line 216-223: Update the fertilizer badge rendering around
FertilizerBadge so it is shown when either fertilizer.p_type_rvo or
fertilizer.p_type is available. Use the RVO value when present and
fertilizer.p_type as the category fallback for custom fertilizers, while
preserving the existing hidden behavior when neither value exists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b9db7c6c-a9e2-4547-b4ad-31e088a457b7

📥 Commits

Reviewing files that changed from the base of the PR and between f34c731 and 75e7bcf.

📒 Files selected for processing (2)
  • fdm-app/app/components/blocks/fertilizer/form.tsx
  • fdm-app/app/routes/farm.$b_id_farm.fertilizers.new._index.tsx

Comment thread fdm-app/app/routes/farm.$b_id_farm.fertilizers.new._index.tsx
@SvenVw
SvenVw merged commit 8e9e73d into development Jul 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Renure support (gebruiksruimte + norms + Gerrit) — from 2026

3 participants