r32 - 04 May 2008 - 15:38:43 - StephanMagetYou are here: TWiki >  Codev Web > PluginsWebOrTWikiWebForPluginPackages > TWikiApplication > TableWidgkit > AccountLedgerApp
Tags:
twiki_application 1 Add my vote for this tag, , create new tag

Account Ledger Application

A TWikiApplication providing a useful MashUp of the CommentPlugin, SpreadSheetPlugin and the EditTablePlugin. Useful for keeping a checkbook style account balance. Thanks to everyone for their assistance both here and in the support web!

Example

IDEA! here on twiki.org I have set nonotify="on" in the %COMMENT% declaration. This prevents notification when folks experiment by posting a new ledger entry. In your own implementation, you may wish to have the notifications turned on.

    Date Item Debit Credit Balance
02/10/2007 pay check   1000 1000
02/10/2007 rent 550   450
02/10/2007 movie tickets 12.50   437.5
02/10/2007 stick of gum .99   436.51
02/10/2007 pay check   100.14 536.65
02/10/2007 another stick of gum .99   535.66
02/14/2007 web camera 13.25   522.41
06/19/2007 pair of shoes 100   422.41
        422.41
09/10/2007 Gas for scooter 7.86   414.55
01/10/2008       414.55
03/10/2008 vanalles   1000 1414.55
03/15/2008 Wiki book   59.95 1474.5
04/19/2008 Paycheck   100.78 1575.28
05/02/2008 Humptata 20.56   1554.72
05/04/2008 and again 20   1534.72

Add new ledger entry:
Description:
Made By: TWikiGuest   Date:   Debit:   Credit:

How To

1. Add the following to your Topic, WebPreferences, or TWikiPreferences

      * Set BALANCE = $EVAL( $VALUE($T(R$ROW(-1):C$COLUMN())) - $VALUE($T(R$ROW():C$COLUMN(-2))) + $VALUE($T(R$ROW():C$COLUMN(-1))) )

2. Add the following to UserTemplates

Add Ledger Entry

%TMPL:DEF{PROMPT:accountledger_table}%
%TABLE{ valign="top" }%
| <b>Add new ledger entry:</b> |||||
|  Description: | <input %DISABLED% type="text" size="90" name="descr" value="" /> ||||
|  Made By: | %MAINWEB%.%USERNAME%    | &nbsp; Date: <input %DISABLED% type="text" size="12" name="date" value="%SERVERTIME{$mo/$day/$year}%" /> | &nbsp; Debit: <input type="text" size="6" name="debit" value="" /> | &nbsp; Credit: <input type="text" size="6" name="credit" value="" /> <input %DISABLED% type="submit" value="%button|Add Entry%" /> |
%TMPL:END%

%TMPL:DEF{OUTPUT:accountledger_table}%%POS:BEFORE%| <!--LEDGERITEM--> | <!-- %MAINWEB%.%USERNAME% --> | %URLPARAM{"date"}% | %URLPARAM{"descr"}% | %URLPARAM{"debit"}% | %URLPARAM{"credit"}% |  %CALC{ %BALANCE% }% |
%TMPL:END%

3. Use the following to create an account legder

%EDITTABLE{changerows="off" quietsave="off" format="| label, 1, | label, 1, | text, 10, | text, 20 | text, 10 | text, 10 | label, 0, $percntCALC{ $percntBALANCE$percnt }$percnt |"}%
|  |  | *Date* | *Item*            | *Debit* | *Credit* | *Balance* |
%COMMENT{ type="accountledger_table" }%

-- Contributors: KeithHelfrich, ThomasFreudenberg, PeterThoeny - 12 Dec 2006

Comments and Discussion

Going one step further, here is a handy preference variable that you could set in TWikiPreferences :

   * Set ACCOUNTLEDGER = %EDITTABLE{changerows="off" quietsave="off" format="| label, 1, | label, 1, | text, 10, | text, 20 | text, 10 | text, 10 | label, 0, $percntCALC{ $percntBALANCE$percnt }$percnt |"}% %BR%
   |  |  | *Date* | *Item*            | *Debit* | *Credit* | *Balance* | %BR%
   %COMMENT{ type="accountledger_table" }%

This will allow for any user to place only the %ACCOUNTLEDGER% variable into their topic and receive a ready-to-use table like the one above.

Word of caution: this variable works on DakarRelease but not on CairoRelease

-- KeithHelfrich - 18 Dec 2006

The is an example TableWidgkit.

-- KeithHelfrich - 21 Dec 2006

Almost forgot the date smile I wonder what kind of date functions there are lying around that would insert the journal entry's date automatically, but leave it constant without updating with every change of the system clock ?

-- KeithHelfrich - 21 Dec 2006

Why not use the CommentPlugin to insert entries? That is able to insert a create-time date.

-- CrawfordCurrie - 21 Dec 2006

Keith, reading this, makes me think that you're doing a similar, but less power full thing to what we do using named sections and parameterised INCLUDEs. There are topics describing this technique - when i find them, i'll add links.

-- SvenDowideit - 21 Dec 2006

Thanks guys. Crawford, the simple answer is because I don't know how. Despite that limitation, this is the sort of thing that, to me, is what will make twiki AccessablyUseful? - giving users a pop-up menu of portable TableWidgkits that they can place into a topic whenever it serves their needs.

-- KeithHelfrich - 22 Dec 2006

On adding table rows with CommentPlugin, see EditActionItems sample application.

-- PeterThoeny - 24 Dec 2006

Thanks for the example, Peter. Going by that, I've revamped the example and instructions above for using the CommentPlugin. This is all working correctly for me at home. But for some reason, even though I've added the necessary UserTemplate, we get the error message above: No such template def TMPL:DEF{PROMPT:accountledger_table}, (which also prevents this comment box from working correctly)

-- KeithHelfrich - 25 Dec 2006

I have a question though - does the account ledger variable work under the EdinburghRelease ? I would seem not to generate the table correctly.

And the COMMENT variable on this page adds into the example table - not into this list...

-- ChrisHogan - 08 Feb 2007

Hi Chris, to be honest, the variable has never worked for me (I'm on Cairo) and I've not tested on Edinburgh, though I think that it should work. The most important parts to take from this app are the %BALANCE% variable, and the magic that happens there to do the math for you.

I've started the example ledger again with new entries because the comment had somehow been disjointed from the table, probably when folks deleted their old entries. ( Note: the best way to reverse a ledger entry is with another entry wink )

I also updated the example #UserTemplate that is used by the CommentPlugin. The individual now does not have the option to change his or her name in the "made by" field (display only). The template in use on twiki.org was not yet updated b/c I don't have permission to edit UserCommentsTemplate (maybe someone could do that for me?).

I'm certain that this app could be improved further, and would look forward to any contributions! One thing I've been wondering about is the ability to restrict edit of the raw text and instead allow changes only through the CommentPlugin or EditTablePlugin. I'm not sure how that would be done.

-- KeithHelfrich - 10 Feb 2007

This misbehaving comment box (bottom of the page) has been fixed...

-- KeithHelfrich - 10 Feb 2007

I changed the permission in TWiki04x01.UserCommentsTemplate, members of the TWikiCommunityGroup should be able to change the topic.

I also had to fix the output format of your template. You also fell into the trap of a spec change in TWiki 4.1: Leading and trailing empty lines are no longer removed. This breaks TWiki apps, skins and CommentPlugin templates. See Bugs:Item3510. Going forward we should have less issues like this because of our TWikiRelease04x01Process.

Suggestion: The read only WikiName of the person does not work in all cases. For example, a non-authenticated user is listed as TWikiGuest. Possibly restore an editable field, or add a conditional note to login if guest.

-- PeterThoeny - 10 Feb 2007

Thanks, Peter. From reading the Bugs:Item3510 page I can neither tell what was broken nor what you've done to fix it. But I am never-the-less appreciative. Is there a HOW-TO somewhere that tells us what to do after this spec change ?

Re: your suggestion on WikiName, my answer to that would be to Set DENYTOPICCHANGE = %MAINWEB%.TWikiGuest to prevent non-authenticated users from changing the account balance. Many sites will have even more restrictive requirements for who can add entries to the account ledger. But at the very least, this will prevent an anonymous entry.

-- KeithHelfrich - 10 Feb 2007

See TWikiReleaseNotes04x01#Template_spec_changed on how to work around the issue of this spec change.

On login question: The user will be authenticated if needed by the CommentPlugin, so instead of passing along the potentially unauth'ed guest user, simply use %WIKIUSERNAME% in the output template.

-- PeterThoeny - 10 Feb 2007

I've changed the template at UserCommentsTemplate#Add_Ledger_Entry to use %WIKIUSERNAME% instead of %MAINWEB%.%USERNAME%

Also, the #Example above was changed to set nonotify="on". This will prevent notifications to the WebNotify list for every time someone experiments by adding a new ledger entry.

-- KeithHelfrich - 15 Feb 2007

Hi Sorry, a bit of a newbie question. Where exactly do you add the template definition? Do I add as a topic? and if so where? Or manually in a file in the twiki installation?

-- AaronCoday - 10 Jan 2008

See http://twiki.org/cgi-bin/view/TWiki/TWikiTemplates and follow documentation for Template Topics

-- MartinCleaver - 03 May 2008

 
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r32 < r31 < r30 < r29 < r28 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback SourceForge.net Logo