]>
Dogcows Code - chaz/homebank2ledger/blob - lib/App/HomeBank2Ledger/Ledger.pm
1 package App
::HomeBank2Ledger
::Ledger
;
2 # ABSTRACT: Ledger data representation
8 our $VERSION = '0.010'; # VERSION
14 return bless {%args}, $class;
18 sub accounts
{ shift-
>{accounts
} || [] }
19 sub commodities
{ shift-
>{commodities
} || [] }
20 sub payees
{ shift-
>{payees
} || [] }
21 sub tags
{ shift-
>{tags
} || [] }
22 sub transactions
{ shift-
>{transactions
} || [] }
25 # TODO - These should validate incoming data.
29 push @{$self->{accounts
}}, @_;
34 push @{$self->{commodities
}}, @_;
39 push @{$self->{payees
}}, @_;
44 push @{$self->{tags
}}, @_;
47 sub add_transactions
{
49 push @{$self->{transactions
}}, @_;
62 App::HomeBank2Ledger::Ledger - Ledger data representation
70 my $ledger = App::HomeBank2Ledger::Ledger->new;
72 $ledger->add_payees("Ann's Antiques", "Missy Automative");
74 for my $payee (@{$ledger->payees}) {
75 print "Payee: $payee\n";
80 This class provides a unified in-memory representation of a ledger, including associated metadata.
82 Here is a specification for the substructures:
86 This is a fully-qualified account name. Names may contain colons for representing a hierarchy of
93 "Assets:Bank:Chase1234"
97 "Liabilities:Credit Card:Capital One"
103 This is a hashref like this:
106 symbol => '$', # required
107 iso => 'USD', # optional
108 name => 'US Dollar', # optional
109 format => '$1000.00', # optional
114 This is just a string with the name of a "payee" or memo/description/narration.
118 This is just a string with the text of a tag.
122 This is a hashref like this:
125 date => '2019-06-12', # required
126 aux_date => '2019-06-13', # optional
127 status => 'cleared', # optional; can be "cleared" or "pending"
128 code => '1234', # optional
129 payee => 'Malcolm Reynolds', # required
130 note => 'Medical supplies', # optional
131 postings => [ # required
133 account => 'Some Account', # required
134 amount => '16.25', # required for at least n-1 postings
137 format => '$1,000.00',
145 payee => 'Somebody', # optional
146 note => 'Whatever', # optional
147 status => 'pending', # optional; can be "cleared" or "pending"
148 tags => [qw(niska train-job)],
150 date => '2019-01-28',
153 commodity => { ... },
158 commodity => { ... },
169 Get an arrayref of accounts.
173 Get an arrayref of commodities.
177 Get an arrayref of payees.
181 Get an arrayref of tags.
185 Get an arrayref of transactions.
191 $ledger = App::HomeBank2Ledger::Ledger->new(%ledger_data);
193 Construct a new ledger instance.
199 =head2 add_commodities
211 =head2 add_transactions
217 Please report any bugs or feature requests on the bugtracker website
218 L<https://github.com/chazmcgarvey/homebank2ledger/issues>
220 When submitting a bug or request, please include a test-file or a
221 patch to an existing test-file that illustrates the bug or desired
226 Charles McGarvey <chazmcgarvey@brokenzipper.com>
228 =head1 COPYRIGHT AND LICENSE
230 This software is Copyright (c) 2019 by Charles McGarvey.
232 This is free software, licensed under:
234 The MIT (X11) License
This page took 0.043051 seconds and 4 git commands to generate.