createFunctionsForNorms
@svenvw/fdm-source / fdm-calculator/src / createFunctionsForNorms
Function: createFunctionsForNorms()
createFunctionsForNorms(
b_region,year):object
Defined in: fdm-calculator/src/norms/index.ts:15
Parameters
b_region
"NL"
year
"2025"
Returns
aggregateNormsToFarmLevel()
aggregateNormsToFarmLevel: (
input) =>AggregatedNormsToFarmLevel
Aggregates the norm values from individual fields to the farm level. This function takes the output per field of the norm calculation, multiplies each norm by the field's area, and sums these values across all fields to provide total norms for the farm.
The result are three numbers (manure, nitrogen, phosphate) expressed as totals, not per hectare.
Parameters
input
InputAggregateNormsToFarmLevel
An array of field data, each containing field ID, area, and calculated norms.
Returns
An object containing the total aggregated norms for manure, nitrogen, and phosphate for the farm.
Example
const fieldData = [
{
b_id: "field1",
b_area: 10, // hectares
norms: {
manure: { normValue: 100, normSource: "Source A" }, // kg N/ha
nitrogen: { normValue: 150, normSource: "Source B" }, // kg N/ha
phosphate: { normValue: 50, normSource: "Source C" }, // kg P2O5/ha
},
},
{
b_id: "field2",
b_area: 5, // hectares
norms: {
manure: { normValue: 90, normSource: "Source A" }, // kg N/ha
nitrogen: { normValue: 140, normSource: "Source B" }, // kg N/ha
phosphate: { normValue: 45, normSource: "Source C" }, // kg P2O5/ha
},
},
];
const aggregatedNorms = aggregateNormsToFarmLevel(fieldData);
// aggregatedNorms will be:
// {
// manure: (100 * 10) + (90 * 5) = 1000 + 450 = 1450,
// nitrogen: (150 * 10) + (140 * 5) = 1500 + 700 = 2200,
// phosphate: (50 * 10) + (45 * 5) = 500 + 225 = 725,
// }
calculateNormForManure
calculateNormForManure:
any=getNL2025DierlijkeMestGebruiksNorm
calculateNormForNitrogen
calculateNormForNitrogen:
any=getNL2025StikstofGebruiksNorm
calculateNormForPhosphate
calculateNormForPhosphate:
any=getNL2025FosfaatGebruiksNorm
collectInputForNorms()
collectInputForNorms: (
fdm,principal_id,b_id) =>Promise<NL2025NormsInput> =collectNL2025InputForNorms
Collects all necessary input data from the FDM to calculate the Dutch (NL) norms for the year 2025.
This function orchestrates fetching data for a given farm, its fields, cultivations, and soil analyses, and structures it into a format suitable for the various NL 2025 norm calculation functions.
Parameters
fdm
FdmType
An initialized FdmType instance for data access.
principal_id
PrincipalId
The ID of the principal initiating the data collection.
b_id
string
The unique identifier of the field for which to collect data.
Returns
Promise<NL2025NormsInput>
A promise that resolves to an NL2025NormsInput object, containing all the
structured data required for the norm calculations.