- """Use the given transaction to fulfill an obligation, if possible."""
+ """Use the given transaction to fulfill an obligation, if possible.
+ Any existing fulfillments for the given transaction will be deleted.
+ Then obligations which the transactions might fulfill are fulfilled
+ in order until the full amount of the transaction has been applied,
+ or no more matching obligations remain.
+ Obligations are ordered first by debit account, descending, so that
+ more specific expense obligations (like "Restaurants") get filled
+ first, but more generic obligations (like "Food") can still be
+ fulfilled. It's assumed that this feature is more useful for expenses
+ than for income. They are then ordered by date, ascending, within each
"DELETE FROM fulfillments WHERE transactionid = %s", (txrow.id,))
"AND isSubAccount(%s, o.debit_account) "
"AND (to_char(%s, o.dategroupformat) = "
"to_char(o.postdate, o.dategroupformat)) "
- "ORDER BY o.postdate ASC",
+ "ORDER BY o.postdate ASC",