]>
Dogcows Code - chaz/homebank2ledger/blob - lib/App/HomeBank2Ledger/Ledger.pm
245e9b5ea697bf245c8b76c41004e68e89621446
1 package App
::HomeBank2Ledger
::Ledger
;
2 # ABSTRACT: Ledger data representation
8 our $VERSION = '0.006'; # 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:CapitalOne"
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 payee => 'Malcolm Reynolds', # required
127 status => 'cleared', # optional; can be "cleared" or "pending"
128 memo => 'Medical supplies', # optional
129 postings => [ # required
131 account => 'Some Account', # required
132 amount => '16.25', # required for at least n-1 postings
135 format => '$1,000.00',
143 payee => 'Somebody', # optional
144 memo => 'Whatever', # optional
145 status => 'pending', # optional; can be "cleared" or "pending"
146 tags => [qw(niska train-job)],
156 Get an arrayref of accounts.
160 Get an arrayref of commodities.
164 Get an arrayref of payees.
168 Get an arrayref of tags.
172 Get an arrayref of transactions.
178 $ledger = App::HomeBank2Ledger::Ledger->new(%ledger_data);
180 Construct a new ledger instance.
186 =head2 add_commodities
198 =head2 add_transactions
204 Please report any bugs or feature requests on the bugtracker website
205 L<https://github.com/chazmcgarvey/homebank2ledger/issues>
207 When submitting a bug or request, please include a test-file or a
208 patch to an existing test-file that illustrates the bug or desired
213 Charles McGarvey <chazmcgarvey@brokenzipper.com>
215 =head1 COPYRIGHT AND LICENSE
217 This software is Copyright (c) 2019 by Charles McGarvey.
219 This is free software, licensed under:
221 The MIT (X11) License
This page took 0.043018 seconds and 3 git commands to generate.