Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to only generate transactions before today. #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,13 @@ $ bean-report example.beancount print
```

Note that the original template, on 2022-01-01, is not present in this output. This is always true: if a template's schedule would not generate its original date when evaluated, the template Transaction will not be produced.

### Options

Additionally, the following options are available which modify the entries of the plugin:
1. `only_past_transactions`

Default: Not set

Only generates transactions before today's date.

8 changes: 6 additions & 2 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

REPETE = 'repete'

def repete(entries, options):
def repete(entries, options, settings=None):
new_entries = []
rubbish_bin = []
for txn in data.filter_txns(entries):
Expand All @@ -20,7 +20,11 @@ def repete(entries, options):
new = copy.deepcopy(txn)
new = new._replace(date=i.date())
del new.meta[REPETE]
new_entries.append(new)
if settings == "only_past_transactions":
if new.date <= datetime.date.today():
new_entries.append(new)
else:
new_entries.append(new)

for txn in rubbish_bin:
entries.remove(txn)
Expand Down