Skip to main content

updateHarvest

@svenvw/fdm-source


@svenvw/fdm-source / fdm-core/src / updateHarvest

Function: updateHarvest()

updateHarvest(fdm, principal_id, b_id_harvesting, b_lu_harvest_date, b_lu_yield, b_lu_n_harvestable?, b_lu_n_residue?, b_lu_p_harvestable?, b_lu_p_residue?, b_lu_k_harvestable?, b_lu_k_residue?): Promise<void>

Defined in: fdm-core/src/harvest.ts:512

Updates an existing harvest record.

This function allows for the modification of harvest details. It first verifies that the principal has the necessary permissions to update the harvest. Within a database transaction, it updates the harvest date and the associated analysis data, such as yield and nutrient content. If the cultivation is designated as a single-harvest type, the function also adjusts the cultivation's termination date to match the new harvest date.

Parameters

fdm

any

The FDM instance providing the connection to the database.

principal_id

any

The ID of the principal performing the update, for permission checking.

b_id_harvesting

any

The unique identifier of the harvest to be updated.

b_lu_harvest_date

any

The new date of the harvest.

b_lu_yield

any

The new dry-matter yield for the harvest, in kg/ha.

b_lu_n_harvestable?

any

The new total nitrogen content in the harvestable yield (g N/kg).

b_lu_n_residue?

any

The new total nitrogen content in the crop residue (g N/kg).

b_lu_p_harvestable?

any

The new total phosphorus content in the harvestable yield (g P2O5/kg).

b_lu_p_residue?

any

The new total phosphorus content in the crop residue (g P2O5/kg).

b_lu_k_harvestable?

any

The new total potassium content in the harvestable yield (g K2O/kg).

b_lu_k_residue?

any

The new total potassium content in the crop residue (g K2O/kg).

Returns

Promise<void>

A Promise that resolves when the update is complete.

Throws

Error if the harvest does not exist, permission checks fail, or any database update fails.