Skip to main content

Function: addFertilizer()

addFertilizer(fdm, principal_id, p_id_catalogue, b_id_farm, p_acquiring_amount, p_acquiring_date): Promise<any>

Defined in: fdm-core/src/fertilizer.ts:187

Alpha

Adds a fertilizer aqcuiring record to a farm.

This function creates a new fertilizer acquiring record by performing a transactional insertion into the fertilizers, fertilizerAcquiring, and fertilizerPicking tables. It verifies that the user has write permission on the specified farm before proceeding.

Parameters

fdm

any

The FDM instance providing the connection to the database. The instance can be created with createFdmServer.

principal_id

any

The identifier of the user making the request.

p_id_catalogue

any

The catalogue ID of the fertilizer.

b_id_farm

any

The ID of the farm where the fertilizer is applied.

p_acquiring_amount

any

The amount of fertilizer acquired.

p_acquiring_date

any

The date when the fertilizer was acquired.

Returns

Promise<any>

A Promise resolving to the ID of the newly created fertilizer acquiring record.

Throws

If adding the fertilizer acquiring record fails.