14 KiB
Workflow Design
Application Status Lifecycle
Final initial statuses:
draft
submitted
under_ppm_review
approved
rejected
assigned
cancelled
deleted_by_ktm
Application Status Meaning
| Status | Meaning |
|---|---|
draft |
Created but not fully submitted. Used only if partial saves are implemented. |
submitted |
Applicant or actor submitted the application for review. |
under_ppm_review |
PPM has opened or started reviewing the application. |
approved |
Application approved for a position but not necessarily assigned to final Saluran/team. |
rejected |
Application rejected with reason. |
assigned |
Approved applicant has active staff assignment. |
cancelled |
Application cancelled by Admin or workflow rule. |
deleted_by_ktm |
KTM-created placeholder/application removed so applicant can self-register. |
Public QR Application Flow
Phase 4 implementation behavior:
/pohon/{pusat_mengundi_uuid}resolves by public UUID and shows the public application form when registration is open.- If registration is closed, the same QR route shows a closed-registration page.
- Successful submissions redirect to
/permohonan/{application_uuid}/berjaya. - Uploaded IC documents and bank statements are stored on the private local disk under the application UUID path.
- Submitted applications immediately create
application_documents,application_status_histories, and pendingbank_verificationsrecords.
- Applicant scans QR code for a Pusat Mengundi.
- System resolves
/pohon/{pusat_mengundi_uuid}. - System checks election and registration period.
- If registration is closed, show clear closed-registration message.
- Applicant selects role: KTM, KP, KPDP, or PAPM.
- If selected role is KP or KPDP, system shows approved KTM list for that Pusat Mengundi with available vacancy.
- Applicant fills personal, contact, bank, and address details.
- Applicant uploads IC document and bank statement.
- System validates IC uniqueness for current election.
- If an active KTM-created applicant exists for the same IC, system blocks self-registration and explains that KTM must delete the pre-created record first.
- System stores documents privately.
- Application status becomes
submitted. - Bank verification starts as
pending. - PPM reviews the application in Phase 5.
Registration Period Rules
During registration period:
- Public Pemohon can register through QR.
- KTM can register KP.
- PPM can review and assign.
After registration period:
- Public self-registration is closed.
- KTM cannot register new KP.
- PPM cannot register new applicants.
- Only Admin can register, edit, or assign staff.
- Admin changes after closing require catatan.
- System must show clear closed-registration messages.
Registration open calculation:
registration_start_date <= today <= registration_end_date- plus
is_registration_open = true. - if
is_registration_open_overrideis not null, it explicitly opens or closes registration regardless of the normal date window.
Applicant Status Portal
Pemohon awam boleh semak status permohonan melalui /permohonan/{uuid}/status tanpa perlu log masuk.
- UUID awam permohonan digunakan sebagai pengecam — tiada login diperlukan.
- Pautan status dipaparkan pada halaman kejayaan permohonan dan boleh disalin.
- Maklumat yang dipaparkan: nama (disamarkan 3 aksara pertama), jawatan dipohon, pusat mengundi, status, sebab penolakan (jika ditolak), nombor rujukan UUID.
- Maklumat yang TIDAK dipaparkan: IC, akaun bank, nombor telefon, ID dalaman, saluran, nama KTM.
- UUID tidak dikenali → 200 dengan mesej generik ("status tidak dapat dipaparkan") — tidak mendedahkan sama ada UUID pernah wujud.
- Rekod
deleted_by_ktmdan rekod soft-deleted juga mengembalikan mesej generik.
Status display mapping:
| Status DB | Paparan |
|---|---|
submitted |
Menunggu Semakan |
under_ppm_review |
Sedang Disemak |
approved |
Diluluskan |
assigned |
Diluluskan & Ditempatkan |
rejected |
Ditolak (+ sebab penolakan) |
cancelled |
Dibatalkan |
Admin Election Settings
Admin can manage the following settings per election via /admin/setup/settings/{election}:
is_attendance_active— Toggle attendance recording on/off. Should only be activated on polling day. PPM cannot record attendance when this is false. Toggling is recorded in activity log with before/after values.is_registration_open_override— Three states: null (Auto — follows date window), true (Force Open — opens even outside date window), false (Force Closed — closes even inside date window). Use override only in exceptional circumstances. When override is active, a warning badge is shown on the settings page.
Changes to election settings require Admin role and are written to activity_log with log_name = 'admin_settings', recording who changed what and when.
Note: is_registration_open (the base toggle) is still set in the database during initial setup. The is_registration_open_override is the runtime control available via the Admin Settings UI.
KTM Vacancy Rule for Public KP/KPDP Selection
For public KP or KPDP applications:
- Candidate KTM options come from active
staff_assignmentswith positionKTM, same election, same Pusat Mengundi, and assigned Saluran Mengundi. - Remaining vacancy is calculated from
position_quotasfor the KTM's Saluran Mengundi and requested role. - Used vacancy counts active team assignments under that KTM plus reserved public applications in
submitted,under_ppm_review, orapprovedstatus. - If no vacancy remains, the KTM cannot be selected.
PPM Review Flow
Phase 5 implementation behavior:
- PPM application URLs use application public UUID.
- PPM list and detail views are scoped by active PPM
staff_assignments. ApplicationPolicyblocks PPM access to applications outside assigned Pusat Mengundi.- Approved applications are moved directly to
assignedbecause Phase 5 approval also creates the active staff assignment. - Private document download is available only through the authorized PPM review route.
- PPM opens own dashboard.
- System lists applications only for PPM's assigned Pusat Mengundi.
- PPM reviews applicant detail and documents.
- PPM may change applicant role before approval.
- System records any role change in audit trail.
- PPM approves only if IC document and bank statement exist.
- If approved as KTM, PPM assigns KTM to a Saluran Mengundi.
- If approved as KP or KPDP, PPM assigns applicant to an approved KTM under the same Pusat Mengundi.
- If approved as PAPM, system assigns at Pusat Mengundi level.
- System creates or updates
staff_assignments. - System records assignment history and activity log.
KTM Flow
Phase 6 implementation behavior:
- KTM routes are under
/ktm/applications. - KTM scope is based on active
staff_assignmentswith positionKTM, statusactive, and a Saluran Mengundi. - KTM can create only KP applicant records.
- KTM-created records are stored as
source = created_by_ktmandstatus = submitted. - Creating a KP applicant queues a Markdown email to the applicant.
- KTM approval creates an active KP
staff_assignmentsrow under the KTM assignment and changes application status toassigned. - KTM can delete only unassigned records they created through the KTM flow, changing status to
deleted_by_ktmbefore soft delete.
- KTM logs in and opens own dashboard.
- System identifies active KTM assignment and Saluran.
- KTM views own KP list and remaining KP vacancy.
- During registration period, KTM can register KP only.
- KTM-created KP has
source = created_by_ktm. - System sends email notification to applicant.
- KTM can approve KP application only under own team while registration is open.
- If applicant wants to self-register with the same IC, system blocks until KTM deletes the KTM-created record.
- Deleting a KTM-created applicant changes status to
deleted_by_ktm, records status history, and soft deletes the record.
Admin Manual Entry and Management Flow
Phase 7 implementation behavior:
- Admin management routes are under
/admin/management. - Admin can list all applications with filters for status, Pusat Mengundi, jawatan, and keyword.
- Admin can create manual application records with
source = admin_manual. - Manual Admin-created records create pending bank verification state but do not send KTM-created applicant email.
- Admin can edit application personal, role, bank, status, and placement-related fields.
- Admin can direct-assign an application to Pusat/Saluran/KTM team; this creates or updates
staff_assignments, sets application status toassigned, and writes status/assignment history. - Admin can edit existing
staff_assignments; changes are mirrored back to the related application where applicable. - Admin can key in and delete Police, KKM, and JKM representative records.
- If registration is closed, Admin changes require
catatan; the system stores it insystem_notes.
- Admin opens global application/staff list.
- Admin can create or edit application/staff records.
- Admin can directly assign staff to Pusat Mengundi and Saluran Mengundi.
- Admin can key in Police, KKM, and JKM records.
- If registration period has ended, Admin must provide
catatanfor any register/edit/assign action. - System saves note in
system_notes. - System records activity log and assignment/application history.
Admin Kewangan Flow
Phase 8 implementation behavior:
- Finance routes are under
/kewangan/bank. - Finance list shows applications in
approvedorassignedstatus. - Filters support Pusat Mengundi, role, bank verification status, missing bank statement, missing bank account number, and keyword search.
- Admin Kewangan can update only
bank_verifications.statusandfinance_note. - Updating verification records sets
verified_by_user_idandverified_atand writes activity log. - Admin Kewangan cannot access Admin assignment management routes.
- Finance export creates an XLSX file in private storage using OpenSpout and inserts an
export_logsrow.
- Admin Kewangan opens finance dashboard.
- System lists approved staff and bank verification status.
- Admin Kewangan filters by Pusat Mengundi, role, status, missing bank statement, or missing account number.
- Admin Kewangan marks bank verification as pending, verified, rejected, or requires correction.
- Admin Kewangan adds finance note.
- System records bank verification activity log.
- Admin Kewangan can export finance verification list.
Wheelchair Flow
Phase 9 implementation behavior:
- Wheelchair management routes are under
/admin/management/wheelchairs. - Admin can upsert one allocation record per election and Pusat Mengundi.
- Admin can record
takentransactions with quantity, date/time, person taking, and notes. - Admin can record
returnedtransactions with quantity, date/time, return condition, and notes. - System calculates total taken, total returned, outstanding quantity, and available quantity.
- Taken quantity is blocked when it exceeds available allocation.
- Returned quantity is blocked when it exceeds outstanding quantity.
- Allocation quantity is blocked when it is lower than outstanding quantity.
- Allocation changes and transactions are recorded in activity log.
- Admin enters allocated wheelchair quantity per Pusat Mengundi.
- Admin records taken quantity, date/time, and person taking.
- Admin records returned quantity, date/time, condition, and notes.
- System stores each movement in
wheelchair_transactions. - System records activity log.
Attendance Flow
Phase 10 implementation behavior:
- PPM attendance routes are under
/ppm/attendance. - PPM can only access Pusat Mengundi assigned through active PPM
staff_assignments. - PPM can record attendance only when
election_settings.is_attendance_active = true. - Attendance is recorded per active
staff_assignmentsrow and uses statusespresent,absent, ornot_recorded. - Present records store check-in time; absent and not-recorded records clear check-in time.
- Attendance updates write activity log with actor, staff assignment, status, and check-in time.
- Admin attendance routes are under
/admin/attendance. - Admin first view lists Pusat Mengundi with total staff, present, absent, and not recorded.
- Admin detail view shows staff name, role, Saluran, status, check-in time, notes, and recorded by.
- Admin detail export generates XLSX with OpenSpout and writes
export_logs.
- Attendance module becomes active based on election setting.
- PPM opens attendance screen for own Pusat Mengundi.
- System lists all assigned staff under that Pusat Mengundi.
- PPM marks each staff as present or absent.
- If present, check-in time is stored.
- System stores recorded by and note.
- Admin dashboard shows first-level list of Pusat Mengundi.
- Admin clicks Pusat Mengundi to see staff-level attendance details.
- Admin exports summary or detail attendance reports.
Attendance statuses:
present
absent
not_recorded
Bank Verification Status
pending
verified
rejected
requires_correction
Status meaning:
pending: Not yet checked by finance.verified: Bank details accepted.rejected: Bank details are invalid or unusable.requires_correction: Applicant/staff record needs correction or additional document.
Audit Events
Must be audited:
- Application submission.
- Application approval/rejection.
- Role change.
- Assignment creation/change/cancellation.
- Document upload/change.
- Bank verification update.
- Admin edit after registration closes.
- Attendance update.
- Wheelchair transaction.
- Excel export.
Audit record should include:
- actor
- action
- subject
- previous value
- new value
- timestamp
- note/catatan if available