Skip to main content

createUncachedFunctionsForFertilizerApplicationFilling

@nmi-agro/fdm-source


@nmi-agro/fdm-source / fdm-calculator/src / createUncachedFunctionsForFertilizerApplicationFilling

Function: createUncachedFunctionsForFertilizerApplicationFilling()

createUncachedFunctionsForFertilizerApplicationFilling(b_region, year): object

Defined in: fdm-calculator/src/norms/index.ts:132

Creates uncached calculation functions for fertilizer application norm fillings. Use this factory when evaluating proposed (not yet persisted) fertilizer plans, where caching provides no benefit and direct calculation is preferred. The returned functions take a single input argument (no fdm database instance).

Parameters

b_region

"NL"

year

Years

Returns

aggregateNormFillingsToFarmLevel

aggregateNormFillingsToFarmLevel: (input) => AggregatedNormFillingsToFarmLevel

Aggregates the norm filling values from individual fields to the farm level. This function takes the output per field of the norm filling calculation, multiplies each norm filling by the field's area, and sums these values across all fields to provide total norm fillings for the farm.

The result are three objects (manure, nitrogen, phosphate) each containing the total normFilling and combined applicationFillings, expressed as totals, not per hectare.

Parameters

input

InputAggregateNormFillingsToFarmLevel

An array of field data, each containing field ID, area, and calculated norm fillings.

Returns

AggregatedNormFillingsToFarmLevel

An object containing the total aggregated norm fillings for manure, nitrogen, and phosphate for the farm.

calculateFertilizerApplicationFillingForManure

calculateFertilizerApplicationFillingForManure: (input) => NormFilling = calculateNL2025FertilizerApplicationFillingForDierlijkeMestGebruiksNorm

Calculates the nitrogen usage from animal manure for a list of fertilizer applications.

This function determines the contribution of each fertilizer application to the nitrogen norm based on the type of manure used. It uses predefined values from table11Mestcodes to identify which fertilizers are considered animal manure and to find their nitrogen content.

Parameters

input

NL2025NormsFillingInput

The standardized input object containing all necessary data.

Returns

NormFilling

An object containing the total nitrogen usage (normFilling) and a detailed breakdown per application (applicationFilling).

Throws

Throws an error if a fertilizer or its RVO type is not found, ensuring data integrity.

calculateFertilizerApplicationFillingForNitrogen

calculateFertilizerApplicationFillingForNitrogen: (input) => Promise<NormFilling> = calculateNL2025FertilizerApplicationFillingForStikstofGebruiksNorm

Calculates the nitrogen utilization norm filling for a set of fertilizer applications. This function determines the amount of effective nitrogen applied, taking into account fertilizer type, nitrogen content, working coefficients, soil type, grazing intention, and land use (bouwland/arable land).

Parameters

input

NL2025NormsFillingInput

The standardized input object containing all necessary data.

Returns

Promise<NormFilling>

An object containing the total norm filling and details for each application.

calculateFertilizerApplicationFillingForPhosphate

calculateFertilizerApplicationFillingForPhosphate: (input) => NormFilling = calculateNL2025FertilizerApplicationFillingForFosfaatGebruiksNorm

Calculates the norm filling for phosphate application, taking into account the "Stimuleren organische stofrijke meststoffen" (Stimulating organic-rich fertilizers) regulation.

This regulation, detailed in Staatscourant 2023, nr. 5152, aims to encourage the use of organic-rich fertilizers by applying a differentiated percentage to their phosphate content when calculating against the phosphate usage norm.

Key aspects of the regulation implemented:

  1. Minimum Threshold (Condition 1): A discount is only applied if at least 20 kg/ha of phosphate from organic-rich fertilizers is applied.
  2. Iterative Discounting: The differentiated percentage (25% or 75% mee) is applied iteratively. The discount is only valid for the portion of organic-rich phosphate that, when summed with other discounted organic-rich phosphate, does not exceed the fosfaatgebruiksnorm. Any organic-rich phosphate applied beyond this limit is counted at 100% towards the norm.
  3. Prioritization: To maximize the benefit for the farmer, fertilizers with a 25% contribution factor (e.g., compost) are prioritized for the discount over those with a 75% contribution factor (e.g., strorijke vaste mest). This has been acknowledged by RVO to be possible in personal communication with Sven.

Parameters

input

NL2025NormsFillingInput

The standardized input object containing all necessary data.

Returns

NormFilling

An object containing the total norm filling and a breakdown per application.

collectInputForFertilizerApplicationFilling

collectInputForFertilizerApplicationFilling: (fdm, principal_id, b_id, fosfaatgebruiksnorm) => Promise<NL2025NormsFillingInput> = collectNL2025InputForFertilizerApplicationFilling

Collects all necessary input data from fdm-core functions for the NL 2025 norms filling calculations. This function standardizes the data collection process, ensuring all calculation functions receive a unified input object (NL2025NormsFillingInput).

Parameters

fdm

FdmType

The FdmType instance for interacting with the Farm Data Model.

principal_id

PrincipalId

The ID of the principal (user or organization) performing the calculation.

b_id

string

The ID of the field for which the norms are being calculated.

fosfaatgebruiksnorm

number

The phosphate usage norm in kg/ha for the current calculation.

Returns

Promise<NL2025NormsFillingInput>

A promise that resolves to a standardized input object containing cultivations, fertilizer applications, fertilizers, organic certification status, grazing intention status, the phosphate usage norm, and the field's centroid.

Throws

Throws an error if the specified field cannot be found.