From 5da1e7756d2a4eb04753b8a97bc00063b4d3f687 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 18 Jun 2010 02:26:50 -0400 Subject: Added new option --inject=KEY[,KEY...] If you have a typed metadata key which contains an amount, you can use --inject=KEY to inject a posting with that amount wherever a match occurs. There are two main forms of usage: 2010-06-18 Sample ; Key:: $100 Expenses:Food $100.00 Assets:Checking The command would be: ledger reg --inject=Key In the above, transactional form, a posting under the account "Key" will be injected before the first posting reported for this transaction. It's amount will be $100. This only happens once for the whole transaction. It is also possible to associate the key with a posting: 2010-06-18 Sample Expenses:Food $100.00 ; Key:: $100 Assets:Checking Now the injected posting is generated whenever that particular post is reported. --- src/chain.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/chain.cc') diff --git a/src/chain.cc b/src/chain.cc index 64550663..8010ba74 100644 --- a/src/chain.cc +++ b/src/chain.cc @@ -258,6 +258,10 @@ post_handler_ptr chain_post_handlers(post_handler_ptr base_handler, if (report.HANDLED(related)) handler.reset(new related_posts(handler, report.HANDLED(related_all))); + if (report.HANDLED(inject_)) + handler.reset(new inject_posts(handler, report.HANDLED(inject_).str(), + report.session.journal->master)); + return handler; } -- cgit v1.2.3