Skip to main content

ynab-transaction-adjuster

GitHub Release Maintained Monthly downloads

"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 Adjuster. This class needs to implement a filter() and an adjust() method which contain the intended logic. The filter() method receives a list of Transaction objects which can be filtered before adjustement. The adjust() method receives a single Transaction and a Modifier.The latter is prefilled with values from the original transaction and can be altered. The modifier 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 Adjuster, Transaction, Modifier


class MyAdjuster(Adjuster):

	def filter(self, transactions: List[Transaction]) -> List[Transaction]:
		# your implementation

		# return the filtered list of transactions
		return transactions

	def adjust(self, transaction: Transaction, modifier: Modifier) -> Modifier:
		# your implementation

		# return the altered modifier
		return modifier

Initialize

Create a Credentials object and initialize Adjuster class with it. Providing account for the credentials is optional. If not set the Adjuster will work on all transactions in the budget.

from ynabtransactionadjuster import Credentials

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

Apply

Apply the filter and adjust function on the fetched transactions from YNAB via the apply() method. It returns a filtered list of ModifiedTransaction which can be inspected for the changed properties via the changed_attributes attribute. Only actually changed transactions are returned.

modified_transactions = my_adjuster.apply()

Update

The modified transactions can be upated in YNAB passing them to the update() function. The method returns a list with the updated Transaction objects.

updated_transactions = my_adjuster.update(modified_transactions)

Metadata

Release files for ynab-transaction-adjuster 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ynab-transaction-adjuster 2.0.2
File Size Uploaded
ynab_transaction_adjuster-2.0.2.tar.gz 23.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ynab-transaction-adjuster 2.0.2
File Interpreter ABI Platform
ynab_transaction_adjuster-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 53.0 kB

Release files / ynab_transaction_adjuster-2.0.2.tar.gz

Download URL ynab_transaction_adjuster-2.0.2.tar.gz
Size 23.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5b7cc92d92f35986fd02f63053c3a133366d7579bfca111e1099d1a521dcd592
BLAKE2b-256 checksum
How to use checksums
1c77c89226aaff40c7dadd990596132c667a748effc8b77240e5d939d2f8ae48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Linux/6.8.0-1021-azure

Release files / ynab_transaction_adjuster-2.0.2-py3-none-any.whl

Download URL ynab_transaction_adjuster-2.0.2-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e87ce849c40d35d7e894ab170d3742faa4663779823b45eabee762a3c45fa7ee
BLAKE2b-256 checksum
How to use checksums
944284d0c8752e40b1e3cffe2f003f16b2c6297910ba311ba0ef889e586c8ae9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Linux/6.8.0-1021-azure

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page