Skip to main content

addOrganicCertification

@svenvw/fdm-source


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

Function: addOrganicCertification()

addOrganicCertification(fdm, principal_id, b_id_farm, b_organic_traces, b_organic_skal, b_organic_issued, b_organic_expires): Promise<any>

Defined in: fdm-core/src/organic.ts:57

Adds a new organic certification for a specific farm.

This function checks if the principal has 'write' permission on the farm, then creates a new organic certification and links it to the farm. It also validates the TRACES and SKAL numbers, and the issue/expiry dates.

Parameters

fdm

any

The FDM instance providing the connection to the database.

principal_id

any

The identifier of the principal creating the certification.

b_id_farm

any

The identifier of the farm receiving the certification.

b_organic_traces

any

The document number according to the EU Traces database.

b_organic_skal

any

The SKAL number.

b_organic_issued

any

The timestamp the certificate is valid from.

b_organic_expires

any

The timestamp the certificate expires.

Returns

Promise<any>

The unique identifier for the new organic certification.

Throws

If the principal does not have permission, validation fails, or the database transaction fails.