Context for managing clearance letters (Surat Keterangan Bebas Perpustakaan).
Handles eligibility checks, letter generation, verification, and revocation.
Summary
Functions
Builds a member snapshot map from a user struct.
Checks whether a user is eligible to receive a clearance letter.
Deletes the old signature image from storage. Safe to call with nil.
Returns the eligible member type slugs from settings (comma-separated string).
Returns true when the clearance feature is enabled in system settings.
Formats a letter number by replacing {N} (zero-padded) and {YEAR} in the format template.
Generates a clearance letter for a user inside a DB transaction.
Generates a clearance letter for a user with a custom identifier.
Gets a clearance letter by UUID, preloading member and revoked_by.
Gets the latest non-revoked clearance letter for a member.
Gets a non-revoked clearance letter for a member by identifier.
Gets all non-revoked clearance letters for a member.
Returns all clearance settings as a map with string keys.
Returns a paginated list of clearance letters with preloaded member and member's node.
Revokes a clearance letter.
Saves clearance settings. Accepts a map with string keys matching the fields
returned by get_settings/0.
Functions
Builds a member snapshot map from a user struct.
The user may be loaded without :node preloaded.
Optionally accepts a custom identifier (for next-degree letters).
When VOILE_UNPAD_VISITOR_SOURCE is configured, fetches student data
from the external API using the effective identifier.
Checks whether a user is eligible to receive a clearance letter.
Returns a map with :eligible (bool) and :checks (list of check results).
Each check is a map with :key, :label, :passed, and :detail.
The user must be preloaded with :user_type for the member type check.
The locker check is only included when VoileLockerLuggage.Lockers is loaded.
Deletes the old signature image from storage. Safe to call with nil.
Returns the eligible member type slugs from settings (comma-separated string).
Returns true when the clearance feature is enabled in system settings.
Formats a letter number by replacing {N} (zero-padded) and {YEAR} in the format template.
Generates a clearance letter for a user inside a DB transaction.
The user may be loaded without :node preloaded.
Returns {:ok, letter} or {:error, reason}.
Generates a clearance letter for a user with a custom identifier.
This is intended for super-admin dashboard usage, where the member may have already requested clearance under a previous identifier.
Gets a clearance letter by UUID, preloading member and revoked_by.
Gets the latest non-revoked clearance letter for a member.
Gets a non-revoked clearance letter for a member by identifier.
Gets all non-revoked clearance letters for a member.
Returns all clearance settings as a map with string keys.
Returns a paginated list of clearance letters with preloaded member and member's node.
Options:
:node_id— integer; when provided, only letters whose member belongs to this node are returned.:search— string; fuzzy search on letter_number, member fullname, or member identifier.
Returns {letters, total_count, total_pages}.
Revokes a clearance letter.
Saves clearance settings. Accepts a map with string keys matching the fields
returned by get_settings/0.