Step 5 of 7

Step 5: Upload Shipping Documents & Automatic Payment

When delivery period arrives, supplier uploads shipping documents. Documents are stored in uploads/ directory on server filesystem. Upon upload, supplier automatically receives 100% payment (already received at deposit, but confirmed). Payment request with countdown automatically appears in buyer dashboard.

📍 Page Location

URL: /manage-contract/:contractId

📸 Visual Representation of the Page

Step 5: Upload Shipping Documents & Automatic Payment

Manage Contract

Contract Details:
Product: Wheat
Quantity: 5000 MT
Total Value: $2,627,500

🎨 Detailed Visual Description

Document upload page shows contract details and file upload interface. Supplier can upload multiple files (PDF, JPG, PNG). Files are stored in uploads/ directory on server. File path format: uploads/{timestamp}-{originalFilename}. After upload, supplier dashboard shows "Documents Uploaded" and "Payment Status: 100% Received". Buyer dashboard automatically shows payment request with countdown timer = (voyage time - 3 days).

Key Visual Elements:

  • Multiple file upload
  • File type validation
  • Upload progress
  • Document list
  • Document storage in uploads/ directory
  • Automatic payment confirmation
  • Payment request to buyer with countdown

⚙️ Backend Process

API Endpoint: POST /api/contracts/:contractId/documents

Process Flow:
1. Receives files via Multer middleware
2. Validates file types (PDF, JPG, PNG) and sizes (max 10MB)
3. Stores files in filesystem: uploads/{timestamp}_{safeFilename}
4. File naming format: {timestamp}_{originalName} (e.g., uploads/1734567890_Bill_of_Lading.pdf)
5. Creates document records in database.documents Map
6. Each document record stores: id, contractId, filename (stored name), originalName (user filename), path (e.g., uploads/1734567890_Bill_of_Lading.pdf), size, mimetype, uploadedBy, uploadedAt
7. Updates contract: documentsUploaded = true, documentsUploadedAt = timestamp
8. Calculates paymentDueDate = documentsUploadedAt + (voyageTime - 3 days)
9. Supplier has already received 100% at deposit stage (30% from pool + 70% financed)
10. Payment is confirmed and supplier sees "Payment Received: 100%"
11. Sends payment request notification to buyer with countdown timer
12. Buyer dashboard shows: "Payment Due: $X (70% + fees)" with countdown
13. Logs audit event: documents_uploaded
14. Returns success with document metadata and storage paths

Database Operations:

  • Table: database.documents (create), database.contracts (update)
  • Action: Store documents in uploads/ directory, create document records, update contract status, create payment request for buyer

➡️ Next Action

Supplier has received 100% payment. Buyer sees payment request with countdown. If buyer pays within countdown, contract completes. If countdown expires, contract goes to auction with minimum bid = 70% + fees.