Split Attachment column into Invoice and Receipt fields

- Add separate Invoice and Receipt columns to Bills table for clearer
  document organization
- Update upload-attachment.sh to accept column parameter (defaults to
  Invoice, use Receipt for payment confirmations)
- Update all documentation examples and workflows
- Add receipt upload step to payment workflows
- Update validation checklist to verify both fields

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-04 21:11:04 -05:00
parent e468c5bc3b
commit a83f436a08
2 changed files with 43 additions and 24 deletions

View File

@@ -1,10 +1,11 @@
#!/bin/bash
# upload-attachment.sh - Upload file and link to Grist record
# Usage: ./upload-attachment.sh <file> <table> <record_id> [token]
# Usage: ./upload-attachment.sh <file> <table> <record_id> [token] [column]
#
# Examples:
# ./upload-attachment.sh invoice.pdf Bills 13
# ./upload-attachment.sh receipt.jpg Bills 13 sess_abc123...
# ./upload-attachment.sh invoice.pdf Bills 13 # defaults to Invoice column
# ./upload-attachment.sh invoice.pdf Bills 13 sess_abc123... # with token
# ./upload-attachment.sh receipt.pdf Bills 13 sess_abc123... Receipt # specify column
set -e
@@ -12,17 +13,21 @@ FILE="$1"
TABLE="$2"
RECORD_ID="$3"
TOKEN="$4"
COLUMN="${5:-Invoice}" # Default to Invoice column
if [[ -z "$FILE" || -z "$TABLE" || -z "$RECORD_ID" ]]; then
echo "Usage: $0 <file> <table> <record_id> [token]"
echo "Usage: $0 <file> <table> <record_id> [token] [column]"
echo ""
echo "Arguments:"
echo " file Path to file to upload"
echo " table Grist table name (e.g., Bills)"
echo " record_id Record ID to attach file to"
echo " token Session token (optional, will prompt if not provided)"
echo " column Attachment column name (default: Invoice, use Receipt for payment receipts)"
echo ""
echo "Example: $0 invoice.pdf Bills 13"
echo "Examples:"
echo " $0 invoice.pdf Bills 13 # Upload invoice"
echo " $0 receipt.pdf Bills 13 \$TOKEN Receipt # Upload receipt"
exit 1
fi
@@ -53,12 +58,12 @@ fi
echo "Uploaded: attachment_id=$ATTACHMENT_ID"
# Link to record via proxy
echo "Linking to $TABLE id=$RECORD_ID..."
echo "Linking to $TABLE id=$RECORD_ID column=$COLUMN..."
LINK_RESPONSE=$(curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"method\": \"update_records\", \"table\": \"$TABLE\", \"records\": [{\"id\": $RECORD_ID, \"fields\": {\"Attachment\": [\"L\", $ATTACHMENT_ID]}}]}" \
-d "{\"method\": \"update_records\", \"table\": \"$TABLE\", \"records\": [{\"id\": $RECORD_ID, \"fields\": {\"$COLUMN\": [\"L\", $ATTACHMENT_ID]}}]}" \
"$BASE_URL/api/v1/proxy")
echo "$LINK_RESPONSE" | jq .
echo "Done! Attachment $ATTACHMENT_ID linked to $TABLE record $RECORD_ID"
echo "Done! Attachment $ATTACHMENT_ID linked to $TABLE.$COLUMN record $RECORD_ID"