49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
import json
|
|
import requests
|
|
import csv
|
|
from dateutil import parser
|
|
|
|
# Prepare transactions
|
|
transactions = []
|
|
with open("chequing statement.csv", newline="") as f:
|
|
reader = csv.DictReader(f)
|
|
idx = 1
|
|
for row in reader:
|
|
try:
|
|
txn_id = f"{row['Account Number']}_{idx}"
|
|
txn_date = parser.parse(row["Transaction Date"]).isoformat()
|
|
amount = float(row["Amount"].replace(",", "").strip())
|
|
vendor = row["Description 2"].strip()
|
|
notes = f"{row['Account Type']} {row['Cheque Number']} {row['Description 1']}".strip()
|
|
transactions.append({
|
|
"id": txn_id,
|
|
"transaction_date": txn_date,
|
|
"amount": amount,
|
|
"vendor": vendor,
|
|
"notes": notes
|
|
})
|
|
idx += 1
|
|
except Exception as e:
|
|
continue
|
|
|
|
# Receipt data for Ajai Invoice (3).jpg
|
|
receipt = {
|
|
"id": "33754868-bff5-4caf-9ece-cfd63f4e52d9",
|
|
"file_name": "Ajai Invoice (3).jpg",
|
|
"upload_date": "2025-07-02T15:31:23.641315",
|
|
"receipt_date": "2025-02-07T00:00:00",
|
|
"amount": 1412.5,
|
|
"tax": 162.5,
|
|
"vendor": "Ajai Srivastava CPA, Accounting Services & Taxes",
|
|
"category": "Office"
|
|
}
|
|
|
|
# Build request
|
|
data = {
|
|
"receipts": [receipt],
|
|
"transactions": transactions
|
|
}
|
|
|
|
# Post to /match
|
|
response = requests.post("http://localhost:8000/match", json=data)
|
|
print(json.dumps(response.json(), indent=2)) |