Skip to main content

Library to adjust transactions in YNAB based on custom patterns

Project description

ynab-transaction-adjuster

GitHub Release Github Release

"Buy Me A Coffee"

This library helps you to automatically adjust transactions in YNAB based on your logic. It allows you to implement your adjustments in a simple factory class which you can run against your existing transactions and update relevant fields like date, payee, category, memo and flags. It also allows you to split transactions.

Preparations

  1. Create a personal access token for YNAB as described here
  2. Get the IDs of your budget and account which records are faulty. You can find both IDs if you go to https://app.ynab.com/ and open the target account by clicking on the name on the left hand side menu. The URL does now contain both IDs https://app.ynab.com/<budget_id>/accounts/<account_id>

Installation

Install library from PyPI

pip install ynab-transaction-adjuster

Usage

A detailed documentation is available at https://ynab-transaction-adjuster.readthedocs.io

Basic Usage

Create an Adjuster

Create a child class of YnabTransactionAdjuster. This class needs to implement a filter() and an adjust() method which contain the intended logic. The filter() method receives a list of OriginalTransaction objects which can be filtered before adjustement. The adjust() method receives a singular OriginalTransaction and a TransactionModifier. The latter is prefilled with values from the original transaction. Its attributes can be modified, and it needs to be returned at the end of the function. Please check the detailed usage section for explanations how to change different attributes.

from ynabtransactionadjuster import YnabTransactionAdjuster
from ynabtransactionadjuster.models import OriginalTransaction, TransactionModifier


class MyAdjuster(YnabTransactionAdjuster):
    
    def filter(self, transactions: List[OriginalTransaction]) -> List[OriginalTransaction]:
        # your implementation
        
        # return the filtered list of transactions
        return transactions
        
    def adjust(self, original: OriginalTransaction, modifier: TransactionModifier) -> TransactionModifier:
        # your implementation

		# return the altered modifier
		return modifier

Initialize

Initalize the adjuster with token, budget and account from YNAB

my_adjuster = MyAdjuster(token='<token>', budget='<budget>', account='<account>')

Test

Test the adjuster on records fetched via the test()method. The method fetches and executes the adjustments but doesn't write the results back to YNAB. Instead it returns a list of the changed transactions which can be inspected for the changed properties.

mod_transactions = my_adjuster.test()

Run

If you are satisfied with the functionality you can execute the adjuster with the run() method. This will run the adjustments and will update the changed transactions in YNAB. The method returns an integer with the number of successfully updated records.

count_of_updated_transactions = my_adjuster.run()

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

ynab_transaction_adjuster-0.3.7.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

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

ynab_transaction_adjuster-0.3.7-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

Details for the file ynab_transaction_adjuster-0.3.7.tar.gz.

File metadata

  • Download URL: ynab_transaction_adjuster-0.3.7.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1017-azure

File hashes

Hashes for ynab_transaction_adjuster-0.3.7.tar.gz
Algorithm Hash digest
SHA256 3c7ca29c3bfcc02e306ddff94f1a3818077c56f42cb12e9414757bd4c1037627
MD5 39fb73a8e337c0aba8f39bcfd4cdd88c
BLAKE2b-256 e970095e1c889ec0235f2bcb26469c3b288705ea0952e6077f6468e804a9f487

See more details on using hashes here.

File details

Details for the file ynab_transaction_adjuster-0.3.7-py3-none-any.whl.

File metadata

File hashes

Hashes for ynab_transaction_adjuster-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b08be72792c23d14a35858c0052ecf0a4d1d89f222b01ba81ed4678987adc6a3
MD5 585ef9989f613ffd50a1ac8f6b468355
BLAKE2b-256 5468325c3cd6562c4a0e9e181eadfe4a56c144d6012ce374b251b580eb7af149

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