Skip to main content

collectInputForNitrogenBalanceForFarms

@nmi-agro/fdm-source


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

Function: collectInputForNitrogenBalanceForFarms()

collectInputForNitrogenBalanceForFarms(fdm, principal_id, farmIds, timeframe): Promise<NitrogenBalanceInput & object[]>

Defined in: fdm-calculator/src/balance/nitrogen/input.ts:217

Alpha

Collects necessary input data from a FDM instance for calculating the nitrogen balance while minimizing the data lookups.

This function orchestrates the retrieval of data related to fields, cultivations, harvests, soil analyses, fertilizer applications, fertilizer details, and cultivation details across multiple farms and a timeframe. It fetches data from the FDM database and structures it into an array of NitrogenBalanceInput objects.

Parameters

fdm

FdmType

The FDM instance for database interaction.

principal_id

PrincipalId

The ID of the principal (user or service) initiating the data collection.

farmIds

farmsTypeSelect[]

The IDs of the farms for which to collect the nitrogen balance input.

timeframe

Timeframe

The timeframe for which to collect the data.

Returns

Promise<NitrogenBalanceInput & object[]>

A promise that resolves with an array of NitrogenBalanceInput objects with b_id_farm containing all the necessary data.

Throws

  • Throws an error if data collection or processing fails.