ledger-cli-toolkit


Nameledger-cli-toolkit JSON
Version 0.8.2 PyPI version JSON
download
home_pagehttps://github.com/EddyBel/Ledgerpy
SummaryLibrería para manipular archivos de contabilidad en formato .ledger.
upload_time2025-01-19 00:39:47
maintainerNone
docs_urlNone
authorEduardo Rangel
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements chardet contourpy cycler fonttools kiwisolver matplotlib numpy packaging pillow pyparsing python-dateutil reportlab six tabulate
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center" >ledger-cli-toolkit</h1>

<p align="center">Ledger file manipulation library</p>

<p align="center">
 <img alt="banner_01" src="https://img.shields.io/github/last-commit/EddyBel/Ledgerpy?color=%23AED6F1&style=for-the-badge" />
 <img alt="banner_02" src="https://img.shields.io/github/license/EddyBel/Ledgerpy?color=%23EAECEE&style=for-the-badge" />
 <img alt="banner_03" src="https://img.shields.io/github/languages/top/EddyBel/Ledgerpy?color=%23F9E79F&style=for-the-badge" />
 <img alt="banner_04" src="https://img.shields.io/github/languages/count/EddyBel/Ledgerpy?color=%23ABEBC6&style=for-the-badge" />
 <img alt="banner_05" src="https://img.shields.io/github/languages/code-size/EddyBel/Ledgerpy?color=%23F1948A&style=for-the-badge" />
</p>


`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](./doc/preview/768_1x_shots_so.png)
![Preview](./doc/preview/413_1x_shots_so.png)

## 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:

```bash
pip install ledger-cli-toolkit
```

## Usage Examples

### Read and Convert a `.ledger` File to JSON

```python
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

```python
# 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

```python
# Parse transactions
transactions = parser. parse()

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

### Add a new transaction

```python
# 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](https://github.com/your-user/ledgerpy/issues) 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.

---

<p align="center">
  <a href="https://github.com/EddyBel" target="_blank">
    <img alt="Github" src="https://img.shields.io/badge/GitHub-%2312100E.svg?&style=for-the-badge&logo=Github&logoColor=white" />
  </a>
  <a href="https://www.linkedin.com/in/eduardo-rangel-eddybel/" target="_blank">
    <img alt="LinkedIn" src="https://img.shields.io/badge/linkedin-%230077B5.svg?&style=for-the-badge&logo=linkedin&logoColor=white" />
  </a>
</p>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/EddyBel/Ledgerpy",
    "name": "ledger-cli-toolkit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Eduardo Rangel",
    "author_email": "dante61918@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ee/ff/58a408cc53691ae7a6c0b521a022dee631aeef08584193f10248e94cc41c/ledger-cli-toolkit-0.8.2.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\" >ledger-cli-toolkit</h1>\r\n\r\n<p align=\"center\">Ledger file manipulation library</p>\r\n\r\n<p align=\"center\">\r\n <img alt=\"banner_01\" src=\"https://img.shields.io/github/last-commit/EddyBel/Ledgerpy?color=%23AED6F1&style=for-the-badge\" />\r\n <img alt=\"banner_02\" src=\"https://img.shields.io/github/license/EddyBel/Ledgerpy?color=%23EAECEE&style=for-the-badge\" />\r\n <img alt=\"banner_03\" src=\"https://img.shields.io/github/languages/top/EddyBel/Ledgerpy?color=%23F9E79F&style=for-the-badge\" />\r\n <img alt=\"banner_04\" src=\"https://img.shields.io/github/languages/count/EddyBel/Ledgerpy?color=%23ABEBC6&style=for-the-badge\" />\r\n <img alt=\"banner_05\" src=\"https://img.shields.io/github/languages/code-size/EddyBel/Ledgerpy?color=%23F1948A&style=for-the-badge\" />\r\n</p>\r\n\r\n\r\n`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.\r\n\r\n![Preview](./doc/preview/768_1x_shots_so.png)\r\n![Preview](./doc/preview/413_1x_shots_so.png)\r\n\r\n## Why `ledgerpy`?\r\n\r\nThe 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.\r\n\r\n## Features\r\n\r\n### Current Features\r\n\r\n- JSON Conversion: Converts .ledger files into JSON structures for easy analysis and manipulation.\r\n- Transaction Filtering: Filters records between specific dates.\r\n- Balance Calculation: Calculates account balances from processed transactions.\r\n- Add transactions: Add new transactions to .ledger files.\r\n\r\n### In development\r\nPlugin: LedgerVisual: An additional module that allows the visualization of accounting data in tables in a simple way.\r\n\r\n- Display of transactions in journal format: Presents transactions in a table style accounting journal, with columns for:\r\n  - Transaction number.\r\n  - Date and time.\r\n  - Concept.\r\n  - Debit.\r\n  - Credit.\r\n  - Includes a final row with \"EQUAL SUM\" to total debits and credits.\r\n\r\n- Display of general balances: Shows the balances by account in a table organized with:\r\n  - Account number.\r\n  - Account name.\r\n  - Unit (example: USD, MXN).\r\n  - Balance.\r\n\r\n## Long-term goals\r\n- Export to popular formats:\r\n- Export transactions and balances to CSV files.\r\n- Generate reports in PDF format with tables and graphs.\r\n- Connection with SQL databases:\r\n- Integration with databases such as MySQL, PostgreSQL and SQLite for storage and advanced querying of accounting data.\r\n\r\n## Installation\r\n\r\nYou can easily install `ledgerpy` from PyPI with the following command:\r\n\r\n```bash\r\npip install ledger-cli-toolkit\r\n```\r\n\r\n## Usage Examples\r\n\r\n### Read and Convert a `.ledger` File to JSON\r\n\r\n```python\r\nfrom ledger_cli import LedgerParser\r\n\r\n# Create a Parser Instance\r\nparser = LedgerParser(\"my_file.ledger\")\r\n\r\n# Convert the file to JSON\r\njson_transactions = parser.to_json()\r\nprint(json_transactions)\r\n```\r\n\r\n### Filter Transactions by Dates\r\n\r\n```python\r\n# Get Transactions Between Two Dates\r\nfiltered_transactions = parser.get_registers_between_dates(\"2023/01/01\", \"2023/12/31\")\r\nprint (filtered_transactions)\r\n```\r\n\r\n### Calculate balances by account\r\n\r\n```python\r\n# Parse transactions\r\ntransactions = parser. parse()\r\n\r\n# Calculate balances\r\nbalances = parser. calculate_balances(transactions)\r\nprint(balances)\r\n```\r\n\r\n### Add a new transaction\r\n\r\n```python\r\n# Add a transaction to the .ledger file\r\nparser. add_transaction(\r\n    date=\"2024/01/01\",\r\n    description=\"Payment of services\",\r\n    accounts=[\r\n        {\"account\": \"Expenses:Services\", \"unit\": \"USD\", \"amount\": 50.00},\r\n        {\"account\": \"Assets:Bank\", \"unit\": \"USD\", \"amount\": -50.00},\r\n    ])\r\n```\r\n\r\n## Contribute\r\n\r\nContributions are welcome! If you have ideas, find bugs, or want to improve the functionality of `ledgerpy`, feel free to open an [issue](https://github.com/your-user/ledgerpy/issues) or send a pull request.\r\n\r\n## License\r\n\r\nThis 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.\r\n\r\n---\r\n\r\n<p align=\"center\">\r\n  <a href=\"https://github.com/EddyBel\" target=\"_blank\">\r\n    <img alt=\"Github\" src=\"https://img.shields.io/badge/GitHub-%2312100E.svg?&style=for-the-badge&logo=Github&logoColor=white\" />\r\n  </a>\r\n  <a href=\"https://www.linkedin.com/in/eduardo-rangel-eddybel/\" target=\"_blank\">\r\n    <img alt=\"LinkedIn\" src=\"https://img.shields.io/badge/linkedin-%230077B5.svg?&style=for-the-badge&logo=linkedin&logoColor=white\" />\r\n  </a>\r\n</p>\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Librer\u00eda para manipular archivos de contabilidad en formato .ledger.",
    "version": "0.8.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/EddyBel/Ledgerpy/issues",
        "Homepage": "https://github.com/EddyBel/Ledgerpy"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eeff58a408cc53691ae7a6c0b521a022dee631aeef08584193f10248e94cc41c",
                "md5": "ca6005ea80642f7fbbc6d6c2309436f3",
                "sha256": "adef0045f2aa58270205b4c47177ff8ade949d2e1b0ff6678605f833c66ca66a"
            },
            "downloads": -1,
            "filename": "ledger-cli-toolkit-0.8.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ca6005ea80642f7fbbc6d6c2309436f3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 16187,
            "upload_time": "2025-01-19T00:39:47",
            "upload_time_iso_8601": "2025-01-19T00:39:47.042669Z",
            "url": "https://files.pythonhosted.org/packages/ee/ff/58a408cc53691ae7a6c0b521a022dee631aeef08584193f10248e94cc41c/ledger-cli-toolkit-0.8.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-19 00:39:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "EddyBel",
    "github_project": "Ledgerpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "chardet",
            "specs": [
                [
                    "==",
                    "5.2.0"
                ]
            ]
        },
        {
            "name": "contourpy",
            "specs": [
                [
                    "==",
                    "1.3.1"
                ]
            ]
        },
        {
            "name": "cycler",
            "specs": [
                [
                    "==",
                    "0.12.1"
                ]
            ]
        },
        {
            "name": "fonttools",
            "specs": [
                [
                    "==",
                    "4.55.3"
                ]
            ]
        },
        {
            "name": "kiwisolver",
            "specs": [
                [
                    "==",
                    "1.4.8"
                ]
            ]
        },
        {
            "name": "matplotlib",
            "specs": [
                [
                    "==",
                    "3.10.0"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "2.2.1"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": [
                [
                    "==",
                    "24.2"
                ]
            ]
        },
        {
            "name": "pillow",
            "specs": [
                [
                    "==",
                    "11.1.0"
                ]
            ]
        },
        {
            "name": "pyparsing",
            "specs": [
                [
                    "==",
                    "3.2.1"
                ]
            ]
        },
        {
            "name": "python-dateutil",
            "specs": [
                [
                    "==",
                    "2.9.0.post0"
                ]
            ]
        },
        {
            "name": "reportlab",
            "specs": [
                [
                    "==",
                    "4.2.5"
                ]
            ]
        },
        {
            "name": "six",
            "specs": [
                [
                    "==",
                    "1.17.0"
                ]
            ]
        },
        {
            "name": "tabulate",
            "specs": [
                [
                    "==",
                    "0.9.0"
                ]
            ]
        }
    ],
    "lcname": "ledger-cli-toolkit"
}
        
Elapsed time: 0.38894s