-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplugin.py
More file actions
28 lines (22 loc) · 790 Bytes
/
plugin.py
File metadata and controls
28 lines (22 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import copy, datetime
from dateutil import rrule
from recurrent.event_parser import RecurringEvent
from beancount.core import data
__plugins__ = [ 'repete', ]
REPETE = 'repete'
def repete(entries, options):
new_entries = []
rubbish_bin = []
for txn in data.filter_txns(entries):
if REPETE in txn.meta:
rubbish_bin.append(txn)
re = RecurringEvent(now_date=txn.date)
re.parse(txn.meta[REPETE])
for i in rrule.rrulestr(re.get_RFC_rrule(), dtstart=txn.date):
new = copy.deepcopy(txn)
new = new._replace(date=i.date())
del new.meta[REPETE]
new_entries.append(new)
for txn in rubbish_bin:
entries.remove(txn)
return entries + new_entries, []