# Vendor Registration Legal Acceptance and Agreement Design

## Goal

Require vendors to accept the platform Terms and Conditions and Privacy Policy during account registration, then download, sign, and upload a vendor agreement for admin review during business verification.

## User Flow

### Registration

The vendor registration form includes two unchecked, required checkboxes:

- I accept the Vendor Terms and Conditions.
- I accept the Privacy Policy.

Each legal-document label links to a public inner page in the vendor application. These pages use the existing authentication layout and contain clearly labelled placeholder legal content that can later be replaced without changing the registration flow.

The Register Account button remains disabled until both checkboxes are selected. The API also rejects registration unless both acceptance flags are true, so the requirement cannot be bypassed through a direct request.

On successful registration, the company record stores:

- `terms_accepted_at`
- `privacy_policy_accepted_at`
- `legal_acceptance_version`

Version `1.0` is used for the initial dummy content.

### Agreement signing and upload

The vendor verification step includes a required Signed Vendor Agreement card alongside the existing required verification documents.

The card provides:

- A Download Agreement button linked to a dummy vendor agreement PDF.
- Instructions to download, sign externally, and upload the completed document.
- A required PDF, JPG, or PNG upload field.

The agreement must be uploaded before verification can be submitted. It uses the existing 5 MB verification-document limit and MIME-type validation.

### Verification status and re-upload

The signed agreement is stored as a standard verification document with type `signed_vendor_agreement`. It participates in the existing pending, approved, and rejected document workflow.

If an admin rejects the agreement, it appears in the vendor re-upload screen with the rejection reason and can be replaced in the same way as other rejected documents.

## Admin Review

`signed_vendor_agreement` is added to the backend verification document definitions as a required document.

Because admin vendor details already render `verification_documents`, the agreement appears in the existing document-review interface with:

- Document title
- Uploaded filename and link
- Upload date and version
- Pending, approved, or rejected state
- Rejection reason

Admin cannot approve the vendor until all required documents, including the signed agreement, are present.

## Application Structure

### Vendor web application

- Extend `Register.jsx` with legal acceptance state, linked checkbox labels, disabled-submit behavior, and acceptance values in the registration request.
- Add public Terms and Conditions and Privacy Policy pages with dummy content.
- Add routes for both legal pages.
- Extend `RegisterVerify.jsx` with the agreement download and required upload.
- Ensure `RegisterReupload.jsx` accepts the new agreement type through the existing rejected-document mapping.
- Add the dummy agreement PDF under the vendor application's public assets.

### Backend

- Extend the company model with legal acceptance timestamps and content version.
- Require and validate both acceptance flags in company registration.
- Store acceptance metadata only after validation succeeds.
- Add `signed_vendor_agreement` to `DOCUMENT_DEFINITIONS` as required.
- Accept the agreement multipart field in verification and re-upload routes/controllers.
- Return it through existing vendor and admin verification responses.

## Validation and Error Handling

- Frontend submission is disabled until both legal checkboxes are selected.
- Backend accepts only explicit boolean-like true values (`true`, `1`, `"1"`, or `"true"`).
- Missing legal acceptance returns a clear validation response.
- Missing signed agreement blocks verification submission and names the missing document.
- Invalid agreement type or files larger than 5 MB use the existing verification upload errors.
- Existing vendors remain valid; legal acceptance fields are nullable to avoid breaking stored records.
- Existing pending vendors will be required to provide the newly required signed agreement before admin approval.

## Testing

- Register button is disabled when either legal checkbox is unchecked.
- Legal links open the correct public inner pages.
- Direct registration requests without either acceptance flag are rejected.
- Successful registration records both timestamps and version.
- Verification submission is blocked without the signed agreement.
- Valid agreement PDF/image uploads and appears in vendor status and admin review.
- Admin approval is blocked when the agreement is absent.
- Rejected agreements can be re-uploaded.
- Existing login and verification-document flows continue to work.
