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

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(filePath = "userbook.json"): Initializes a new Book object with a file path where a JSON file is to be saved. filePath is set to be "userbook.json" in default if not specified. Loads existing data from filePath if available, otherwise creates an empty book with the specified JSON name in the file path.

saveData(filePath = "userbook.json"): Saves the current state of the book to the JSON file in the filePath.

loadData(filePath = "userbook.json"): Loads data from the JSON file in the filePath 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, filePath = "userbook.json"): Adds a transaction to the book and saves the updated data into the JSON file in the filePath 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, filePath = "userbook.json"): Removes a transaction from the book based on its type and index, then saves the updated data into the JSON file in the filePath. Parameters: t_type: String, either 'income' or 'expense'. index: Index of the transaction to be removed.

clearAll(filePath = "userbook.json"): Clears all transactions in both 'income' and 'expense' categories and saves the updated data into the JSON file in the filePath.

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=2): Plots a line chart or bar chart to represent the monthly trend of income, expenses, and balance.

  • graph_type: (default 2)
    • 1: a line chart
    • 2: a bar chart

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

  • transaction_type: (default expense)

    • income
    • expense
  • graph_type: (default 1)

    • 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(amount=0, type=1,): Set a monthly budget based on either a specified amount or a percentage of average income.

  • amount: (default 0)

    • For type=1, it is the amount of the monthly budget
    • For type=2, it is the percentage of average income (0-100)
  • type: (default 1)

    • 1 : setting the budget with a specific amount
    • 2 : setting the budget with a percentage of average income

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.8.tar.gz (14.7 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.8-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bookkeeping-0.0.8.tar.gz
  • Upload date:
  • Size: 14.7 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.8.tar.gz
Algorithm Hash digest
SHA256 217eefc71e14dab3d708e94a76cc001f53319421f02f10ea7517b5b28d52d556
MD5 c7a86d7725f6d1738361c81f90b0882b
BLAKE2b-256 25e61b5a962520c2ccb8082650a483d6fd5cb4f9ec0ccc8372fa5b91a8810cb1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bookkeeping-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 12.1 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f48d32a3fc60f199df4c3b0583806b53279097211f3f27ddba3d3abe033a75ec
MD5 dea2d8003989c4a7fcac4f28081ee37b
BLAKE2b-256 c70beb09180ebb3b434dc1934442ff2e09eea0c5eaab93137ea1fc1b44455dc9

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