tag:infinitekind.tenderapp.com,2009-01-14:/discussions/moneydance-development/2542-budget-itemsInfinite Kind: Discussion 2019-10-19T15:00:22Ztag:infinitekind.tenderapp.com,2009-01-14:Comment/473954242019-06-29T05:54:42Z2019-06-29T05:54:42ZBudget items<div><p>I'm not into java, only python (jython).<br>
I'm OK with txns - creating, editing etc but am now trying to access Budget items (querying, creating, sorting etc) but cannot seem to find how to start. Any guidance or pointers (python) would be much appreciated.</p></div>davidcullentag:infinitekind.tenderapp.com,2009-01-14:Comment/473954242019-07-07T03:00:35Z2019-07-07T03:00:36ZBudget items<div><p>I too am interested in this capability. Any preliminary guidance would be most appreciated.</p></div>Tobias Goldstonetag:infinitekind.tenderapp.com,2009-01-14:Comment/473954242019-07-08T03:34:55Z2019-07-08T03:34:56ZBudget items<div><p>caveat: I'm just learning python so things won't be elegant for a while (if ever).</p>
<p>Here's something I mashed together to pull current budget list items and print them.<br>
It looks like it defaults the display amount to the current interval/period.</p>
<p>from com.infinitekind.moneydance.model import *</p>
<p>budgetsList = moneydance_data.getBudgets()<br>
currentBudget = budgetsList.findCurrentBudget()<br>
items = currentBudget.getItemList()<br>
for item in items:<br>
amount = item.getAmount()/ 100 interval = item.getInterval() dateRange = item.getDateRange() print 'Amount: $' + str(amount) print 'Interval: ' + str(interval) print 'Date Range: ' + str(dateRange) print</p>
<p>I'm interested in figuring out how close to any of my budgeted categories amount I am at any one time.</p>
<p>Thanks,</p>
<p>Tobias</p></div>Tobias Goldstonetag:infinitekind.tenderapp.com,2009-01-14:Comment/473954242019-07-16T04:12:37Z2019-07-16T04:12:37ZBudget items<div><p>Thanks, Tobias. This is helpful. However, little else to go on (api has no examples or tutorial).</p></div>davidcullentag:infinitekind.tenderapp.com,2009-01-14:Comment/473954242019-07-16T06:02:05Z2019-07-16T06:02:05ZBudget items<div><p>I don't know if this will help. I have written a budget generator extension in Java. In that extension I get the current actuals by reading through the transactions for the period and category and totalling them.</p>
<p>In java terms this is getBook().getTransactionSet().getTransactions(filter) where the filter determines whether or not a transaction is to be included in the total.</p>
<p>The filter basically is true when the account of the transaction equals the budget category and the transaction date is within the budget period. Remember MD contains 2 transactions per real transaction, one against the actual account (the parent) and one against the category(the split).</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/473954242019-07-16T17:31:11Z2019-07-16T17:31:11ZBudget items<div><p>It looks like within a budget there's a calculated actual that can be<br>
referenced along with the budgeting by category. Unfortunately I can't<br>
find a way to pull the data via Python.</p>
<p>If there's anyone who could help provide a code snippet I'd love to see it.</p>
<p>It would be nice to build extensions but it's proving super difficult<br>
without some additional guidance.</p>
<p>Thanks,</p></div>Toby Goldstonetag:infinitekind.tenderapp.com,2009-01-14:Comment/473954242019-07-18T13:02:36Z2019-07-18T13:02:36ZBudget items<div><p>I don't know python but the enclosed seems to work. I believe that you can use any of the defined classes/methods in the documentation within your python script</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/473954242019-07-18T13:09:26Z2019-07-18T13:09:26ZBudget items<div><p>Another approach is to look at the Calculate method and then interrogate the CalculationResult subclass (see: <a href="https://infinitekind.com/dev/apidoc/com/infinitekind/moneydance/model/Budget.html">https://infinitekind.com/dev/apidoc/com/infinitekind/moneydance/mod...</a>)</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/473954242019-07-20T02:54:18Z2019-07-20T02:54:19ZBudget items<div><p>Two questions… If I try to run that in version 2019.3 then there’s an undefined variable ‘book’. Would that be a reference to the AccountBook object?</p>
<p>I don’t see where in your script book gets defined/referenced anywhere. I think it might be missing book = moneydance.getCurrentAccountBook()</p>
<p>Also you’re using TxnSet in your function but I’m not sure where that’s getting defined and it does error out.</p>
<p>allTrans = book.getTransactionSet().getAllTxns()<br>
def getAmount(TxnSet, item) :</p>
<p>All this being said this particular class (if I can figure out how to reference it) perhaps holds the answer to an easy actual vs budget by category query: Class BudgetItemDetail</p></div>Toby Goldstonetag:infinitekind.tenderapp.com,2009-01-14:Comment/473954242019-07-20T07:05:31Z2019-07-20T07:05:31ZBudget items<div><p>sorry about that, there is a missing line</p>
<p>book=moneydance_data which should be after line 1</p>
<p>Obviously the indentation needs to be sorted out but I copied the file, added the above line and it ran.</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/473954242019-07-20T08:20:08Z2019-07-20T08:20:08ZBudget items<div><p>I have had a look at python within MD.</p>
<p>The variable moneydance_data is the AccountBook object for the current file. From this you can get to any of the data within the file.</p>
<p>Have a look at <a href="https://bitbucket.org/mikerb/moneydance-2019/wiki/Moneydance%20Object%20Model">https://bitbucket.org/mikerb/moneydance-2019/wiki/Moneydance%20Obje...</a></p>
<p>It will show you the structure of the data.</p>
<p>From that variable you can use any of the API calls as defined in the core API (see <a href="https://infinitekind.com/dev/apidoc/index.html">https://infinitekind.com/dev/apidoc/index.html</a>)</p>
<p>I have created a quick test of the Budget.calcuate(from, to, showall,showzero) call. See enclosed.</p>
<p>Hope this helps. You may want to look at the whole of my wiki, it has a number of extensions and information for MD (see <a href="https://bitbucket.org/mikerb/moneydance-2019/wiki/Home">https://bitbucket.org/mikerb/moneydance-2019/wiki/Home</a>)</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/473954242019-07-20T14:59:47Z2019-07-20T14:59:47ZBudget items<div><p>Thanks! Your wiki information is great.</p></div>Toby Goldstone