Automating Invoice Data Entry
Example Prompt:
Example Response:
import PyPDF2
import re
# Function to extract text from PDF
def extract_text_from_pdf(pdf_path):
with open(pdf_path, 'rb') as file:
reader = PyPDF2.PdfReader(file)
text = ''
for page in reader.pages:
text += page.extract_text() + '\n'
return text
# Function to extract invoice details
def extract_invoice_details(text):
invoice_number = re.search(r'Invoice Number: (\d+)', text)
invoice_date = re.search(r'Date: (\d{2}/\d{2}/\d{4})', text)
total_amount = re.search(r'Total Amount: \$([\d,]+\.\d{2})', text)
return {
'invoice_number': invoice_number.group(1) if invoice_number else 'Not found',
'invoice_date': invoice_date.group(1) if invoice_date else 'Not found',
'total_amount': total_amount.group(1) if total_amount else 'Not found'
}
# Main execution
pdf_path = 'path_to_your_invoice.pdf'
text = extract_text_from_pdf(pdf_path)
invoice_details = extract_invoice_details(text)
print(invoice_details)
Related Tasks:
Creating Vendor Profiles
Example Prompt:
Example Response:
Related Tasks:
Generating Payment Schedules
Example Prompt:
Example Response:
import pandas as pd
# Load the invoice data
invoice_data = pd.read_csv('path_to_your_invoices.csv')
# Assuming the CSV has columns: 'Invoice Number', 'Due Date', 'Total Amount'
# Convert 'Due Date' to datetime format
invoice_data['Due Date'] = pd.to_datetime(invoice_data['Due Date'])
# Sort invoices by due date
payment_schedule = invoice_data.sort_values(by='Due Date')
# Display the payment schedule
print('Payment Schedule:')
print(payment_schedule[['Invoice Number', 'Due Date', 'Total Amount']])
Related Tasks:
Creating Financial Reports
Example Prompt:
Example Response:
import pandas as pd
# Load the financial data
financial_data = pd.read_excel('path_to_your_financial_data.xlsx')
# Calculate key metrics
# Assuming the data has columns: 'Revenue', 'Expenses'
total_revenue = financial_data['Revenue'].sum()
total_expenses = financial_data['Expenses'].sum()
net_profit = total_revenue - total_expenses
# Create a summary report
summary_report = {
'Total Revenue': total_revenue,
'Total Expenses': total_expenses,
'Net Profit': net_profit
}
# Display the summary report
print('Summary Report:')
for key, value in summary_report.items():
print(f'{key}: ${value:,.2f}')
Related Tasks:
Preparing for Audits
Example Prompt:
Example Response:
Related Tasks: