Skip to main content

A bookkeeping package

Project description

Bookkeeping Package

Overview

This package provide two main functionalities: transaction management and analysis, which are separatly designed in two sub-packages: management and analysis

Table of Contents

  • Sub-package: management
    • Module 1: transaction
    • Module 2: book
  • Sub-package: analysis
    • Module 1: analytics
    • Module 2: summary
    • Module 3: budget
  • Test file: How to use

Sub-package: management

Module 1: transaction

Transaction Class

Initiates an object that represents a single transaction record that contains information of a single user, date, and amount in this specific transaction

init(amount, desc, label=None): Initializes a new Transaction object.Parameters:amount: numeric value representing the transaction amount. desc: string describing the transaction. label: string representing the category or label of the transaction. Defaults to "other" if not provided.

Setters: setLabel(newLabel); setAmount(newAmount); setDate(newDate)

toDict(): converts the transaction to a dictionary. Returns: a dictionary representation of the transaction.

str(): returns a string representation of the transaction.

Income Class

A subclass of Transaction class that represents Income object

Class Attribute: incomeLabels that contains the pre-set income labels

init(): Initializes a new Income object by inheriting the __init()__ of Transaction class

Expense Class

A subclass of Transaction class that represents Expense object

Class Attribute: expenseLabels that contains pre-set expense labels

init(): Initializes a new Expense object by inheriting the __init()__ of Transaction class.

Module 2: book

Book Class

This class represents the Book object that keeps records of all transactions of a single user.

init(): Initializes a new Book object. Loads existing data from userBook.json if available, otherwise creates an empty book.

saveData(): Saves the current state of the book to userBook.json.

loadData(): Loads data from userBook.json into the book. If the file is not found or is not valid JSON, initializes the book with empty lists for 'income' and 'expense'.

addTran(transanction): Adds a transaction to the book and saves the updated data by taking an instance of the Income or Expense class.

searchTran(t_type, keyword): Searches for transactions of a given type of transaction containing a keyword in their description and prints the results. Parameters: t_type: string, either 'income' or 'expense'. keyword: string to search for in transaction descriptions.

removeTran(t_type, index): Removes a transaction from the book based on its type and index, then saves the updated data. Parameters: t_type: String, either 'income' or 'expense'. index: Index of the transaction to be removed.

clearAll(): Clears all transactions in both 'income' and 'expense' categories and saves the updated data.

displayBook(): Displays all transactions in the book.

Sub-package: analysis

Module 1: analytics

Analysis Class

The Analysis class is designed to load transaction data from a JSON file and store it in an attribute. This class serves as a base class for SummaryAnalysis class and BudgetAnalysis class.

init(): Initializes an instance of the Analysis class. This will automatically load transaction data from the default JSON file.

loadBookData(): Loads transaction data from the JSON file and returns a list of transactions. This method is automatically called during the initialization of the Analysis class.

Module 2: summary

SummaryAnalysis CLass

The SummaryAnalysis class is designed to perform basic analysis on monthly transactions.
It inherits from a base class Analysis. This class provides methods to check the overall balance for the current month, display trends in income, expenses, and balance over months using line or bar charts, and visualize the composition of income or expenses using pie charts.

init(): Creates an instance of the SummaryAnalysis class.

checkBalance(): Calculates the overall balance for the current month and prints the result.

displayTrend(graph_type): Plots a line chart or bar chart to represent the monthly trend of income, expenses, and balance.

  • graph_type:
    • 1: a line chart
    • 2: a bar chart

displayByLabel(transaction_type, graph_type): Plots a pie chart, donut chart, ring chart, or half-pie chart to represent the constitution of income or expenses by label.

  • transaction_type:

    • income
    • expense
  • graph_type:

    • 1: a pie chart
    • 2: a donut chart
    • 3: a ring chart
    • 4: a half-pie chart

Module 3: budget

BudgetAnalysis Class

The BudgetAnalysis class is designed to provide additional methods for basic budget-related analysis. It inherits from a base class Analysis. This class provides methods to set a monthly budget, check for expenses exceeding the budget, display transactions after the budget is exceeded, and visualize the trend of expenses exceeding the budget over months.

init(): Create an instance of the BudgetAnalysis class. This automatically initializes the budget as 0.

setBudget(type, amount): Set a monthly budget based on either a specified amount or a percentage of average income.

  • type:
    • 1 : setting the budget with a specific amount
    • 2 : setting the budget with a percentage of average income
  • amount:
    • For type=1, it is the amount of the monthly budget (>0)
    • For type=2, it is the percentage of average income (0-100)

overBudgetExpenses(): Print the amount of expenses exceeding the set budget for the current month and display expenses that occur after the budget is exceeded.

transactionsAfterBudgetExceeded(): Get all expenses of this month that occur after the point where the sum of expenses exceeds set budget.

displayTransactions(transactions): Display passed-in transactions as a formatted pandas dataframe.

displayOverBudgetTrend(): Plot a bar chart to show the monthly trend of expenses exceeding the budget.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bookkeeping-0.0.3.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bookkeeping-0.0.3-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file bookkeeping-0.0.3.tar.gz.

File metadata

  • Download URL: bookkeeping-0.0.3.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for bookkeeping-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e2e06b7819b91417e215167801c7740b36c267ebc5590873906e1b3f5fa5a7ba
MD5 f19db7064e4fe26a4330bc4f1d1e47e6
BLAKE2b-256 3b15f3d5e161d21a747669bba9d39c67e07cdc7dbb946eaa5f319a4e192f8010

See more details on using hashes here.

File details

Details for the file bookkeeping-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: bookkeeping-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for bookkeeping-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6a299011794ac9a401b6b5df26b19770c0b8f35bb8e4349d1a1f74da6eb52ab8
MD5 8e9163c5ae1418f5b81cd92d7b41910b
BLAKE2b-256 66373aa315e597dfab31bf2298c967a52cf27c861c6090145d14ebb433109ca7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page