public
Description: A personal finance manager written in RubyCocoa & DataMapper
Homepage: http://airgead.octopod.info
Clone URL: git://github.com/octopod/airgead.git
Change the debit_cents and credit_cents column title depending on the 
selected account type

  * Add vertical lines to the transaction view
  * clean up some code
octopod (author)
Fri Jul 04 16:37:55 -0700 2008
commit  8a5feb97d18479457aaf21dc0eacabb6a2617c91
tree    647cf79093102c229a8b16fb6d74807cf0877dda
parent  ce7b73f78565c87499d7b97dc0774e84aed84751
...
7
8
9
10
11
 
 
 
 
 
 
 
 
 
 
 
 
12
13
14
...
7
8
9
 
 
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
0
@@ -7,7 +7,17 @@ class AccountOutlineViewDelegate < NSObject
0
   end
0
   
0
   def outlineViewSelectionDidChange(notification)
0
- outline_view = notification.object
0
- @transaction_view.dataSource = TransactionOutlineViewDataSource.alloc.initWithAccount(outline_view.itemAtRow(outline_view.selectedRow))
0
+ account = notification.object.selectedItem
0
+ set_transaction_view_data_source(account)
0
+ set_transaction_view_column_titles(account)
0
+ end
0
+
0
+ def set_transaction_view_data_source(account)
0
+ @transaction_view.dataSource = TransactionOutlineViewDataSource.alloc.initWithAccount(account)
0
+ end
0
+
0
+ def set_transaction_view_column_titles(account)
0
+ @transaction_view.setTableColumnWithIdentifier_headerStringValue('credit_cents', account.credit_title)
0
+ @transaction_view.setTableColumnWithIdentifier_headerStringValue('debit_cents', account.debit_title)
0
   end
0
 end
0
\ No newline at end of file
...
3
4
5
6
 
7
8
9
10
 
11
12
13
14
...
3
4
5
 
6
7
8
9
 
10
11
12
13
14
0
@@ -3,11 +3,11 @@ require File.expand_path(File.dirname(__FILE__) + '/mixins/increased_by_debit')
0
 class AssetAccount < Account
0
   include IncreasedByDebit
0
   
0
- def self.debit_title
0
+ def debit_title
0
     "Deposit"
0
   end
0
   
0
- def self.credit_title
0
+ def credit_title
0
     "Withdrawal"
0
   end
0
 end
0
\ No newline at end of file
...
3
4
5
6
 
7
8
9
10
 
11
12
13
14
...
3
4
5
 
6
7
8
9
 
10
11
12
13
14
0
@@ -3,11 +3,11 @@ require File.expand_path(File.dirname(__FILE__) + '/mixins/increased_by_credit')
0
 class EquityAccount < Account
0
   include IncreasedByCredit
0
   
0
- def self.debit_title
0
+ def debit_title
0
     "Decrease"
0
   end
0
 
0
- def self.credit_title
0
+ def credit_title
0
     "Increase"
0
   end
0
 end
0
\ No newline at end of file
...
3
4
5
6
 
7
8
9
10
 
11
12
13
14
...
3
4
5
 
6
7
8
9
 
10
11
12
13
14
0
@@ -3,11 +3,11 @@ require File.expand_path(File.dirname(__FILE__) + '/mixins/increased_by_debit')
0
 class ExpenseAccount < Account
0
   include IncreasedByDebit
0
 
0
- def self.debit_title
0
+ def debit_title
0
     "Expense"
0
   end
0
 
0
- def self.credit_title
0
+ def credit_title
0
     "Rebate"
0
   end
0
 end
0
\ No newline at end of file
...
3
4
5
6
 
7
8
9
10
 
11
12
13
14
...
3
4
5
 
6
7
8
9
 
10
11
12
13
14
0
@@ -3,11 +3,11 @@ require File.expand_path(File.dirname(__FILE__) + '/mixins/increased_by_credit')
0
 class IncomeAccount < Account
0
   include IncreasedByCredit
0
   
0
- def self.debit_title
0
+ def debit_title
0
     "Charge"
0
   end
0
 
0
- def self.credit_title
0
+ def credit_title
0
     "Income"
0
   end
0
 end
0
\ No newline at end of file
...
3
4
5
6
 
7
8
9
10
 
11
12
13
14
...
3
4
5
 
6
7
8
9
 
10
11
12
13
14
0
@@ -3,11 +3,11 @@ require File.expand_path(File.dirname(__FILE__) + '/mixins/increased_by_credit')
0
 class LiabilityAccount < Account
0
   include IncreasedByCredit
0
   
0
- def self.debit_title
0
+ def debit_title
0
     "Payment"
0
   end
0
 
0
- def self.credit_title
0
+ def credit_title
0
     "Charge"
0
   end
0
 end
0
\ No newline at end of file
...
2
3
4
5
 
6
7
8
9
10
11
 
12
13
14
...
298
299
300
301
 
302
303
304
...
342
343
344
345
 
346
347
348
...
376
377
378
379
 
380
381
382
...
433
434
435
436
 
437
438
439
...
462
463
464
465
 
466
467
468
...
510
511
512
 
513
514
515
...
530
531
532
533
 
534
535
536
...
2324
2325
2326
2327
 
2328
2329
 
2330
2331
2332
...
2
3
4
 
5
6
7
8
9
10
 
11
12
13
14
...
298
299
300
 
301
302
303
304
...
342
343
344
 
345
346
347
348
...
376
377
378
 
379
380
381
382
...
433
434
435
 
436
437
438
439
...
462
463
464
 
465
466
467
468
...
510
511
512
513
514
515
516
...
531
532
533
 
534
535
536
537
...
2325
2326
2327
 
2328
2329
 
2330
2331
2332
2333
0
@@ -2,13 +2,13 @@
0
 <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
0
   <data>
0
     <int key="IBDocument.SystemTarget">1050</int>
0
- <string key="IBDocument.SystemVersion">9D34</string>
0
+ <string key="IBDocument.SystemVersion">9E17</string>
0
     <string key="IBDocument.InterfaceBuilderVersion">670</string>
0
     <string key="IBDocument.AppKitVersion">949.33</string>
0
     <string key="IBDocument.HIToolboxVersion">352.00</string>
0
     <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
0
       <bool key="EncodedWithXMLCoder">YES</bool>
0
- <integer value="241"/>
0
+ <integer value="244"/>
0
     </object>
0
     <object class="NSArray" key="IBDocument.PluginDependencies">
0
       <bool key="EncodedWithXMLCoder">YES</bool>
0
@@ -298,7 +298,7 @@
0
                                           <bool key="EncodedWithXMLCoder">YES</bool>
0
                                           <string>%m/%d/%y</string>
0
                                           <integer value="3"/>
0
- <integer value="1040"/>
0
+ <integer value="1040" id="262544395"/>
0
                                           <integer value="0"/>
0
                                         </object>
0
                                       </object>
0
@@ -342,7 +342,7 @@
0
                                   <reference key="NSTableView" ref="333376350"/>
0
                                 </object>
0
                                 <object class="NSTableColumn" id="996828807">
0
- <string key="NSIdentifier">credit_cents</string>
0
+ <string key="NSIdentifier">debit_cents</string>
0
                                   <double key="NSWidth">6.400000e+01</double>
0
                                   <double key="NSMinWidth">1.000000e+01</double>
0
                                   <double key="NSMaxWidth">3.402823e+38</double>
0
@@ -376,7 +376,7 @@
0
                                         <object class="NSMutableArray" key="dict.values">
0
                                           <bool key="EncodedWithXMLCoder">YES</bool>
0
                                           <integer value="1" id="9"/>
0
- <integer value="1040"/>
0
+ <reference ref="262544395"/>
0
                                           <integer value="2" id="10"/>
0
                                         </object>
0
                                       </object>
0
@@ -433,7 +433,7 @@
0
                                   <reference key="NSTableView" ref="333376350"/>
0
                                 </object>
0
                                 <object class="NSTableColumn" id="183854112">
0
- <string key="NSIdentifier">debit_cents</string>
0
+ <string key="NSIdentifier">credit_cents</string>
0
                                   <double key="NSWidth">8.400000e+01</double>
0
                                   <double key="NSMinWidth">1.000000e+01</double>
0
                                   <double key="NSMaxWidth">3.402823e+38</double>
0
@@ -462,7 +462,7 @@
0
                                         <object class="NSMutableArray" key="dict.values">
0
                                           <bool key="EncodedWithXMLCoder">YES</bool>
0
                                           <reference ref="9"/>
0
- <integer value="1040"/>
0
+ <reference ref="262544395"/>
0
                                           <reference ref="10"/>
0
                                         </object>
0
                                       </object>
0
@@ -510,6 +510,7 @@
0
                               <reference key="NSGridColor" ref="402922379"/>
0
                               <double key="NSRowHeight">1.700000e+01</double>
0
                               <int key="NSTvFlags">-767557632</int>
0
+ <int key="NSGridStyleMask">1</int>
0
                               <int key="NSColumnAutoresizingStyle">4</int>
0
                               <int key="NSDraggingSourceMaskForLocal">15</int>
0
                               <int key="NSDraggingSourceMaskForNonLocal">0</int>
0
@@ -530,7 +531,7 @@
0
                           <reference key="NSSuperview" ref="995707690"/>
0
                           <reference key="NSTarget" ref="995707690"/>
0
                           <string key="NSAction">_doScroller:</string>
0
- <double key="NSCurValue">3.700000e+01</double>
0
+ <double key="NSCurValue">9.182005e-01</double>
0
                           <double key="NSPercent">1.390978e-01</double>
0
                         </object>
0
                         <object class="NSScroller" id="349309482">
0
@@ -2324,9 +2325,9 @@
0
           <reference ref="9"/>
0
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
0
           <reference ref="9"/>
0
- <string>{{0, 322}, {974, 522}}</string>
0
+ <string>{{77, 68}, {974, 522}}</string>
0
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
0
- <string>{{0, 322}, {974, 522}}</string>
0
+ <string>{{77, 68}, {974, 522}}</string>
0
           <reference ref="9"/>
0
           <reference ref="9"/>
0
           <reference ref="9"/>
...
1
2
3
 
4
5
6
...
8
9
10
11
12
 
 
13
14
15
16
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
19
20
21
22
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
25
26
...
1
2
 
3
4
5
6
...
8
9
10
 
 
11
12
13
 
 
 
 
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
 
 
 
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
0
@@ -1,6 +1,6 @@
0
 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
0
 
0
-describe AccountOutlineViewDelegate, 'initWithTransactionView(transaction_view)' do
0
+describe AccountOutlineViewDelegate, '.initWithTransactionView(transaction_view)' do
0
   it "store the transaction_view reference in the class" do
0
     transaction_view = mock('transaction_view')
0
     delegate = AccountOutlineViewDelegate.alloc.initWithTransactionView(transaction_view)
0
@@ -8,18 +8,53 @@ describe AccountOutlineViewDelegate, 'initWithTransactionView(transaction_view)'
0
   end
0
 end
0
 
0
-describe AccountOutlineViewDelegate, 'outlineViewSelectionDidChange(notification)' do
0
- it "create a new TransactionOutlineViewDataSource with the selected account and set it as the transaction view data source (TODO: Make this less messy)" do
0
+describe AccountOutlineViewDelegate, '#outlineViewSelectionDidChange(notification)' do
0
+ it "sets up the transaction view with the selected account" do
0
     account = stub('account')
0
- outline_view = stub('outline_view')
0
- outline_view.stub!(:selectedRow).and_return(1)
0
- outline_view.stub!(:itemAtRow).and_return(account)
0
- notification = stub('notification', :object => outline_view)
0
+ notification = stub('notification', :object => stub('outline_view', :selectedItem => account))
0
+ account_delegate = AccountOutlineViewDelegate.alloc
0
+ account_delegate.should_receive(:set_transaction_view_data_source).with(account)
0
+ account_delegate.should_receive(:set_transaction_view_column_titles).with(account)
0
+ account_delegate.initWithTransactionView(stub('transaction_view')).outlineViewSelectionDidChange(notification)
0
+ end
0
+end
0
+
0
+describe AccountOutlineViewDelegate, '#set_transaction_view_data_source(account)' do
0
+ before(:each) do
0
+ @account = stub('account')
0
+ @transaction_view = stub_everything('transaction view')
0
+ @delegate = AccountOutlineViewDelegate.alloc.initWithTransactionView(@transaction_view)
0
+ end
0
+
0
+ it "creates a new TransactionOutlineViewDataSource with the account" do
0
     transaction_view_data_source = mock('transaction_view_data_source')
0
     TransactionOutlineViewDataSource.should_receive(:alloc).and_return(transaction_view_data_source)
0
- transaction_view_data_source.should_receive(:initWithAccount).with(account).and_return(transaction_view_data_source)
0
- transaction_view = mock('transaction_view')
0
- transaction_view.should_receive(:dataSource=).with(transaction_view_data_source)
0
- AccountOutlineViewDelegate.alloc.initWithTransactionView(transaction_view).outlineViewSelectionDidChange(notification)
0
+ transaction_view_data_source.should_receive(:initWithAccount).with(@account)
0
+ @delegate.set_transaction_view_data_source(@account)
0
+ end
0
+
0
+ it "sets the transaction view data source to the new object" do
0
+ data_source = stub_everything('data source')
0
+ TransactionOutlineViewDataSource.should_receive(:alloc).and_return(data_source)
0
+ @transaction_view.should_receive(:dataSource=).with(data_source)
0
+ @delegate.set_transaction_view_data_source(@account)
0
+ end
0
+end
0
+
0
+describe AccountOutlineViewDelegate, '#set_transaction_view_column_titles(account)' do
0
+ before(:each) do
0
+ @account = stub('account', :debit_title => 'debit', :credit_title => 'credit')
0
+ @transaction_view = stub_everything('transaction view')
0
+ @delegate = AccountOutlineViewDelegate.alloc.initWithTransactionView(@transaction_view)
0
+ end
0
+
0
+ it "sets the debit_cents column title with debit_title for the account" do
0
+ @transaction_view.should_receive(:setTableColumnWithIdentifier_headerStringValue).with('debit_cents', 'debit')
0
+ @delegate.set_transaction_view_column_titles(@account)
0
+ end
0
+
0
+ it "sets the credit_cents column title with credit_title for the account" do
0
+ @transaction_view.should_receive(:setTableColumnWithIdentifier_headerStringValue).with('credit_cents', 'credit')
0
+ @delegate.set_transaction_view_column_titles(@account)
0
   end
0
 end
0
\ No newline at end of file
...
10
11
12
13
 
14
15
 
16
17
18
19
 
20
21
 
22
23
24
...
10
11
12
 
13
14
 
15
16
17
18
 
19
20
 
21
22
23
24
0
@@ -10,14 +10,14 @@ describe AssetAccount do
0
   end
0
 end
0
 
0
-describe AssetAccount, ".debit_title" do
0
+describe AssetAccount, "#debit_title" do
0
   it "is Deposit" do
0
- AssetAccount.debit_title.should == 'Deposit'
0
+ AssetAccount.alloc.init.debit_title.should == 'Deposit'
0
   end
0
 end
0
 
0
-describe AssetAccount, ".credit_title" do
0
+describe AssetAccount, "#credit_title" do
0
   it "is Withdrawal" do
0
- AssetAccount.credit_title.should == 'Withdrawal'
0
+ AssetAccount.alloc.init.credit_title.should == 'Withdrawal'
0
   end
0
 end
0
\ No newline at end of file
...
10
11
12
13
 
14
15
 
16
17
18
19
 
20
21
 
22
23
24
...
10
11
12
 
13
14
 
15
16
17
18
 
19
20
 
21
22
23
24
0
@@ -10,14 +10,14 @@ describe EquityAccount do
0
   end
0
 end
0
 
0
-describe EquityAccount, ".debit_title" do
0
+describe EquityAccount, "#debit_title" do
0
   it "is Decrease" do
0
- EquityAccount.debit_title.should == 'Decrease'
0
+ EquityAccount.alloc.init.debit_title.should == 'Decrease'
0
   end
0
 end
0
 
0
-describe EquityAccount, ".credit_title" do
0
+describe EquityAccount, "#credit_title" do
0
   it "is Increase" do
0
- EquityAccount.credit_title.should == 'Increase'
0
+ EquityAccount.alloc.init.credit_title.should == 'Increase'
0
   end
0
 end
0
\ No newline at end of file
...
10
11
12
13
 
14
15
 
16
17
18
19
 
20
21
 
22
23
24
...
10
11
12
 
13
14
 
15
16
17
18
 
19
20
 
21
22
23
24
0
@@ -10,14 +10,14 @@ describe ExpenseAccount do
0
   end
0
 end
0
 
0
-describe ExpenseAccount, ".debit_title" do
0
+describe ExpenseAccount, "#debit_title" do
0
   it "is Expense" do
0
- ExpenseAccount.debit_title.should == 'Expense'
0
+ ExpenseAccount.alloc.init.debit_title.should == 'Expense'
0
   end
0
 end
0
 
0
-describe ExpenseAccount, ".credit_title" do
0
+describe ExpenseAccount, "#credit_title" do
0
   it "is Rebate" do
0
- ExpenseAccount.credit_title.should == 'Rebate'
0
+ ExpenseAccount.alloc.init.credit_title.should == 'Rebate'
0
   end
0
 end
0
\ No newline at end of file
...
10
11
12
13
 
14
15
 
16
17
18
19
 
20
21
 
22
23
24
...
10
11
12
 
13
14
 
15
16
17
18
 
19
20
 
21
22
23
24
0
@@ -10,14 +10,14 @@ describe IncomeAccount do
0
   end
0
 end
0
 
0
-describe IncomeAccount, ".debit_title" do
0
+describe IncomeAccount, "#debit_title" do
0
   it "is Charge" do
0
- IncomeAccount.debit_title.should == 'Charge'
0
+ IncomeAccount.alloc.init.debit_title.should == 'Charge'
0
   end
0
 end
0
 
0
-describe IncomeAccount, ".credit_title" do
0
+describe IncomeAccount, "#credit_title" do
0
   it "is Income" do
0
- IncomeAccount.credit_title.should == 'Income'
0
+ IncomeAccount.alloc.init.credit_title.should == 'Income'
0
   end
0
 end
0
\ No newline at end of file
...
10
11
12
13
 
14
15
 
16
17
18
19
 
20
21
 
22
23
24
...
10
11
12
 
13
14
 
15
16
17
18
 
19
20
 
21
22
23
24
0
@@ -10,14 +10,14 @@ describe LiabilityAccount do
0
   end
0
 end
0
 
0
-describe LiabilityAccount, ".debit_title" do
0
+describe LiabilityAccount, "#debit_title" do
0
   it "is Payment" do
0
- LiabilityAccount.debit_title.should == 'Payment'
0
+ LiabilityAccount.alloc.init.debit_title.should == 'Payment'
0
   end
0
 end
0
 
0
-describe LiabilityAccount, ".credit_title" do
0
+describe LiabilityAccount, "#credit_title" do
0
   it "is Charge" do
0
- LiabilityAccount.credit_title.should == 'Charge'
0
+ LiabilityAccount.alloc.init.credit_title.should == 'Charge'
0
   end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.