collectInputForOrganicMatterBalanceForFarms
@nmi-agro/fdm-source / fdm-calculator/src / collectInputForOrganicMatterBalanceForFarms
Function: collectInputForOrganicMatterBalanceForFarms()
collectInputForOrganicMatterBalanceForFarms(
fdm,principal_id,farmIds,timeframe):Promise<OrganicMatterBalanceInput&object[]>
Defined in: fdm-calculator/src/balance/organic-matter/input.ts:186
Alpha
Collects all necessary input data from an FDM instance to calculate the organic matter balance for multiple farms.
This function acts as a data-gathering layer, interacting with the FDM core to fetch all records required for the organic matter balance calculation. It retrieves data for the given farms and timeframe, including field details, cultivation history, soil analyses, and fertilizer applications. It fetches the complete fertilizer and cultivation catalogues for all farms in batch to minimise database queries.
Parameters
fdm
FdmType
The FDM instance, used for all database interactions.
principal_id
PrincipalId
The ID of the user or service principal requesting the data, for authorization purposes.
farmIds
farmsTypeSelect[]
The unique identifiers for the farms.
timeframe
Timeframe
The time period (start and end dates) for which to collect the data.
Returns
Promise<OrganicMatterBalanceInput & object[]>
A promise that resolves with an array of OrganicMatterBalanceInput objects with b_id_farm containing all the structured data.
Throws
Throws an error if any of the database queries fail or if a specified field is not found.