Skip to main content

Library to adjust transactions in YNAB based on custom patterns

Project description

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 an integer with the number of successfully updated records.

count_of_updated_transactions = my_adjuster.update(modified_transactions)

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-1.3.0.tar.gz (24.0 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-1.3.0-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ynab_transaction_adjuster-1.3.0.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.5.0-1018-azure

File hashes

Hashes for ynab_transaction_adjuster-1.3.0.tar.gz
Algorithm Hash digest
SHA256 931cef8d2e86dc2c4c2abbf47bb6cfbbb57c60f076abd6f61b07c88c920a9825
MD5 c89262261ff9d1777cb0141dd66973f7
BLAKE2b-256 35bfe543a275e4fbe980781dfbf2b6e88793a10aa5b695cce34c857e5b6a86c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ynab_transaction_adjuster-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 adf763d5c782fa070e17a466e9df529c9be774505f5a0a7d9c751a62067c8af6
MD5 62d1d87a542273e9b87b0ef195e5e72c
BLAKE2b-256 9e17bce62b813a2fc2ea4e1539b59e70cd827a99f8e14131661454b2391d0da1

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