Skip to content

Commit

Permalink
refactor: add extension point for MB impl
Browse files Browse the repository at this point in the history
  • Loading branch information
ericaltendorf committed Aug 23, 2024
1 parent a222563 commit 26817eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions beancount/core/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class Booking(enum.Enum):
# HIFO with transfer awareness
HIFO_XFER_AWARE = 'HIFO_XFER_AWARE'

# Extension point for Magicbeans.
MAGICBEANS = 'MAGICBEANS'

# All possible types of entries. These are the main data structures in use
# within the program. They are all treated as immutable.
#
Expand Down
5 changes: 5 additions & 0 deletions beancount/parser/booking_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ def booking_method_HIFO_XFER_AWARE(entry, posting, matches):
else:
return booking_method_LowIFO(entry, posting, matches)

def booking_method_magicbeans_stub(entry, posting, matches):
"""Magicbeans booking method stub."""
raise NotImplementedError("Magicbeans booking method should be redefined by Magicbeans package")


_BOOKING_METHODS = {
Booking.STRICT: booking_method_STRICT,
Expand All @@ -405,4 +409,5 @@ def booking_method_HIFO_XFER_AWARE(entry, posting, matches):
Booking.HIFO_XFER_AWARE: booking_method_HIFO_XFER_AWARE,
Booking.NONE: booking_method_NONE,
Booking.AVERAGE: booking_method_AVERAGE,
Booking.MAGICBEANS: booking_method_magicbeans_stub, # Should be redefined by Magicbeans package
}

0 comments on commit 26817eb

Please sign in to comment.