@@ -15,11 +15,14 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from . import core
from .._typing import (
MetaValueEnum,
Posting,
Transaction,
)
class MetaExpenseAllocation(core.PostingChecker):
ACCOUNTS = ('Expenses:',)
METADATA_KEY = 'expense-allocation'
VALUES_ENUM = core.MetadataEnum(METADATA_KEY, {
class MetaExpenseAllocation(core._NormalizePostingMetadataHook):
VALUES_ENUM = core.MetadataEnum('expense-allocation', {
'administration',
'fundraising',
'program',
@@ -32,5 +35,8 @@ class MetaExpenseAllocation(core.PostingChecker):
'Expenses:Services:Fundraising': VALUES_ENUM['fundraising'],
}
def _default_value(self, txn, post):
def _run_on_post(self, txn: Transaction, post: Posting) -> bool:
return post.account.startswith('Expenses:')
def _default_value(self, txn: Transaction, post: Posting) -> MetaValueEnum:
return self.DEFAULT_VALUES.get(post.account, 'program')