From 26817eb1d8183d2cac56cc5429d90b062bdeeffc Mon Sep 17 00:00:00 2001 From: Eric Altendorf Date: Fri, 23 Aug 2024 11:30:35 -0700 Subject: [PATCH] refactor: add extension point for MB impl --- beancount/core/data.py | 3 +++ beancount/parser/booking_method.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/beancount/core/data.py b/beancount/core/data.py index b2cc2838d..c6532ce81 100644 --- a/beancount/core/data.py +++ b/beancount/core/data.py @@ -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. # diff --git a/beancount/parser/booking_method.py b/beancount/parser/booking_method.py index 4255a4831..a5d93f4d7 100644 --- a/beancount/parser/booking_method.py +++ b/beancount/parser/booking_method.py @@ -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, @@ -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 }