Skip to main content

Librería para manipular archivos de contabilidad en formato .ledger.

Project description

ledger-cli-toolkit

Ledger file manipulation library

banner_01 banner_02 banner_03 banner_04 banner_05

ledgerpy is a Python library designed to read, manipulate, and generate accounting files in .ledger format. It offers a simple way to work with these files within the Python ecosystem, transforming them into JSON-like structures that are easy to process and analyze.

Preview Preview

Why ledgerpy?

The project was born from the need to have a tool to manipulate and read .ledger files directly from Python. While there are powerful tools such as ledger-cli to interact with these types of files from the command line, ledgerpy seeks to offer the same capability, but within the language, allowing developers to integrate this data into their applications in a simple way.

Features

Current Features

  • JSON Conversion: Converts .ledger files into JSON structures for easy analysis and manipulation.
  • Transaction Filtering: Filters records between specific dates.
  • Balance Calculation: Calculates account balances from processed transactions.
  • Add transactions: Add new transactions to .ledger files.

In development

Plugin: LedgerVisual: An additional module that allows the visualization of accounting data in tables in a simple way.

  • Display of transactions in journal format: Presents transactions in a table style accounting journal, with columns for:

    • Transaction number.
    • Date and time.
    • Concept.
    • Debit.
    • Credit.
    • Includes a final row with "EQUAL SUM" to total debits and credits.
  • Display of general balances: Shows the balances by account in a table organized with:

    • Account number.
    • Account name.
    • Unit (example: USD, MXN).
    • Balance.

Long-term goals

  • Export to popular formats:
  • Export transactions and balances to CSV files.
  • Generate reports in PDF format with tables and graphs.
  • Connection with SQL databases:
  • Integration with databases such as MySQL, PostgreSQL and SQLite for storage and advanced querying of accounting data.

Installation

You can easily install ledgerpy from PyPI with the following command:

pip install ledger-cli-toolkit

Usage Examples

Read and Convert a .ledger File to JSON

from ledger_cli import LedgerParser

# Create a Parser Instance
parser = LedgerParser("my_file.ledger")

# Convert the file to JSON
json_transactions = parser.to_json()
print(json_transactions)

Filter Transactions by Dates

# Get Transactions Between Two Dates
filtered_transactions = parser.get_registers_between_dates("2023/01/01", "2023/12/31")
print (filtered_transactions)

Calculate balances by account

# Parse transactions
transactions = parser. parse()

# Calculate balances
balances = parser. calculate_balances(transactions)
print(balances)

Add a new transaction

# Add a transaction to the .ledger file
parser. add_transaction(
    date="2024/01/01",
    description="Payment of services",
    accounts=[
        {"account": "Expenses:Services", "unit": "USD", "amount": 50.00},
        {"account": "Assets:Bank", "unit": "USD", "amount": -50.00},
    ])

Contribute

Contributions are welcome! If you have ideas, find bugs, or want to improve the functionality of ledgerpy, feel free to open an issue or send a pull request.

License

This project is licensed under the MIT License. This means that you can use, modify, and distribute the code freely, as long as you include the original license notice.


Github LinkedIn

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

ledger_cli_toolkit-1.6.0.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

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

ledger_cli_toolkit-1.6.0-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file ledger_cli_toolkit-1.6.0.tar.gz.

File metadata

  • Download URL: ledger_cli_toolkit-1.6.0.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for ledger_cli_toolkit-1.6.0.tar.gz
Algorithm Hash digest
SHA256 8bcbeb9436f8d690a3d78983bb59062a3b36e25f583992e5b68c44c2b805f8ec
MD5 b062aa1916e78ee790b8115a011264f4
BLAKE2b-256 08f64f400f064cf7a23ca4ca17b6c90cf17d4a4fbb37c922127837047c5b3fd3

See more details on using hashes here.

File details

Details for the file ledger_cli_toolkit-1.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ledger_cli_toolkit-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc55f964c580363b91ba34ee8ea20ba4adf4b0c3acd16a64e5b8ac1de7754258
MD5 63d2ad1f564c2dfbb41e1ea2eb905714
BLAKE2b-256 3188a46139e4b1b4de754e9dd2879183c2a0372d68134147b81c5013d4cfc304

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