DEV Community

Caper B
Caper B

Posted on

How I Automate My Freelance Workflow with Python

How I Automate My Freelance Workflow with Python

As a freelancer, I've learned that automation is key to increasing productivity and efficiency. In this article, I'll share how I use Python to automate my freelance workflow, from project management to invoicing and payment tracking.

Project Management Automation

I use a combination of Python scripts and tools like Trello and GitHub to manage my projects. Here's an example of how I automate project board updates using the Trello API and Python:

import requests

# Trello API credentials
api_key = "YOUR_API_KEY"
api_token = "YOUR_API_TOKEN"
board_id = "YOUR_BOARD_ID"

# Get all cards on the board
response = requests.get(f"https://api.trello.com/1/boards/{board_id}/cards", params={
    "key": api_key,
    "token": api_token
})

# Update card status based on due date
for card in response.json():
    due_date = card["due"]
    if due_date and due_date <= datetime.date.today():
        # Move card to "Overdue" list
        requests.put(f"https://api.trello.com/1/cards/{card['id']}", params={
            "key": api_key,
            "token": api_token,
            "idList": "OVERDUE_LIST_ID"
        })
Enter fullscreen mode Exit fullscreen mode

This script checks all cards on my project board and moves them to the "Overdue" list if their due date has passed.

Time Tracking Automation

Accurate time tracking is essential for freelancers, as it directly affects our earnings. I use a Python script to track my time spent on projects and generate reports:

import datetime
import json

# Load time tracking data from file
with open("time_tracking.json", "r") as f:
    time_tracking_data = json.load(f)

# Add new time entry
def add_time_entry(project_name, hours_worked):
    time_entry = {
        "project_name": project_name,
        "hours_worked": hours_worked,
        "date": datetime.date.today().isoformat()
    }
    time_tracking_data.append(time_entry)
    with open("time_tracking.json", "w") as f:
        json.dump(time_tracking_data, f)

# Generate time tracking report
def generate_report():
    report = {}
    for time_entry in time_tracking_data:
        project_name = time_entry["project_name"]
        if project_name not in report:
            report[project_name] = 0
        report[project_name] += time_entry["hours_worked"]
    return report

# Example usage
add_time_entry("Project A", 2)
print(generate_report())
Enter fullscreen mode Exit fullscreen mode

This script allows me to easily add new time entries and generate reports by project.

Invoicing and Payment Tracking Automation

I use a combination of Python scripts and tools like Stripe and Wave to automate my invoicing and payment tracking. Here's an example of how I generate invoices using the Wave API and Python:

import requests

# Wave API credentials
api_key = "YOUR_API_KEY"
api_token = "YOUR_API_TOKEN"

# Create new invoice
def create_invoice(customer_name, amount):
    response = requests.post("https://api.waveapps.com/v1/invoices", headers={
        "Authorization": f"Bearer {api_token}"
    }, json={
        "customer": {
            "name": customer_name
        },
        "amount": amount
    })
    return response.json()["id"]

# Example usage
invoice_id = create_invoice("John Doe", 1000)
print(invoice_id)
Enter fullscreen mode Exit fullscreen mode

This script generates a new invoice using the Wave API and returns the invoice ID.

Monetization Angle

By automating my freelance workflow, I'm able to increase my productivity and efficiency, which directly affects my earnings. I'm able to take on more projects and

Top comments (0)