]>
Dogcows Code - chaz/homebank2ledger/blob - Ledger.pm
18522cb55861a86f1557e4df76fb0ad181130626
1 package App
::HomeBank2Ledger
::Ledger
;
2 # ABSTRACT: Ledger data representation
8 our $VERSION = '0.001'; # 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 Get an arrayref of accounts.
97 Get an arrayref of commodities.
101 Get an arrayref of payees.
105 Get an arrayref of tags.
109 Get an arrayref of transactions.
115 $ledger = App::HomeBank2Ledger::Ledger->new(%ledger_data);
117 Construct a new ledger instance.
123 =head2 add_commodities
135 =head2 add_transactions
140 * "Assets:Bank:Chase1234"
141 * "Liabilities:Credit Card:CapitalOne"
145 This is a hashref like this:
148 symbol => '$', # required
149 iso => 'USD', # optional
150 name => 'US Dollar', # optional
151 format => '$1000.00', # optional
156 This is just a string with the name of a "payee" or memo/description/narration.
160 This is just a string with the text of a tag.
164 This is a hashref like this:
167 date => '2019-06-12', # required
168 payee => 'Malcolm Reynolds', # required
169 status => 'cleared', # optional; can be "cleared" or "pending"
170 memo => 'Medical supplies', # optional
171 postings => [ # required
173 account => 'Some Account', # required
174 amount => '16.25', # required for at least n-1 postings
177 format => '$1,000.00',
185 payee => 'Somebody', # optional
186 memo => 'Whatever', # optional
187 status => 'pending', # optional; can be "cleared" or "pending"
188 tags => [qw(niska train-job)],
196 Please report any bugs or feature requests on the bugtracker website
197 L<https://github.com/chazmcgarvey/homebank2ledger/issues>
199 When submitting a bug or request, please include a test-file or a
200 patch to an existing test-file that illustrates the bug or desired
205 Charles McGarvey <chazmcgarvey@brokenzipper.com>
207 =head1 COPYRIGHT AND LICENSE
209 This software is Copyright (c) 2019 by Charles McGarvey.
211 This is free software, licensed under:
213 The MIT (X11) License
This page took 0.042162 seconds and 3 git commands to generate.