Functional Documentation
This module contains functions for manipulating document data and performing various operations related to document fields.
Description: Sets the value of a field in the document data.
Parameters:
document_data
(dict): The document data containing field information.
field_name
(str): The name of the field to set.
value
: The value to set for the field.
Example:
set_field_value(document_data, "name", "John Doe")
Description: Sets the value of a date field in the document data.
Parameters:
document_data
(dict): The document data containing field information.
field_name
(str): The name of the date field to set.
value
: The date value to set in ISO format (e.g., "2020-12-31").
Example:
set_date_value(document_data, "date_of_birth", "1990-05-15")
Description: Sets a custom attribute of a field in the document data.
Parameters:
attribute_name
(str): The name of the attribute to set.
value
: The value to set for the attribute.
Example:
set_field_attribute(document_data, "address", "is_verified", True)
Description: Updates the status of a document with the specified ID.
Parameters:
doc_id
(str): The ID of the document to update.
user
: The user performing the update (either user ID or UserAuthentication object).
org_id
: The ID of the organization to which the document belongs.
status
(str): The new status of the document.
message
: Optional message associated with the status update.
doc_classification_class
: Optional document classification class.
Example:
update_document_status_with_doc_id("123456", user, org_id, "approved", "Document approved")
Description: Checks if a supplier is valid based on the provided criteria.
Parameters:
user
(UserAuthentication): The authenticated user.
filter_data_json
: Filter criteria for validating the supplier.
sub_org_id
: Optional sub-organization ID for filtering.
Example:
is_supplier_valid(user, {"name": "Supplier Inc."})
Description: Marks a field as invalid in the document data.
Parameters:
document_data
(dict): The document data containing field information.
field_name
(str): The name of the field to mark as invalid.
message
(str): The validation message for the field.
code
(optional): Error code for the validation (default is None).
Example:
set_field_as_invalid(document_data, "email", "Invalid email format", "EMAIL_FORMAT_INVALID")
\