1 package App
::HomeBank2Ledger
::Ledger
;
2 # ABSTRACT: Ledger data representation
6 my $ledger = App::HomeBank2Ledger::Ledger->new;
8 $ledger->add_payees("Ann's Antiques", "Missy Automative");
10 for my $payee (@{$ledger->payees}) {
11 print "Payee: $payee\n";
16 This class provides a unified in-memory representation of a ledger, including associated metadata.
18 Here is a specification for the substructures:
22 This is a fully-qualified account name. Names may contain colons for representing a hierarchy of
26 * "Assets:Bank:Chase1234"
27 * "Liabilities:Credit Card:Capital One"
31 This is a hashref like this:
34 symbol => '$', # required
35 iso => 'USD', # optional
36 name => 'US Dollar', # optional
37 format => '$1000.00', # optional
42 This is just a string with the name of a "payee" or memo/description/narration.
46 This is just a string with the text of a tag.
50 This is a hashref like this:
53 date => '2019-06-12', # required
54 aux_date => '2019-06-13', # optional
55 status => 'cleared', # optional; can be "cleared" or "pending"
56 code => '1234', # optional
57 payee => 'Malcolm Reynolds', # required
58 note => 'Medical supplies', # optional
59 postings => [ # required
61 account => 'Some Account', # required
62 amount => '16.25', # required for at least n-1 postings
65 format => '$1,000.00',
73 payee => 'Somebody', # optional
74 note => 'Whatever', # optional
75 status => 'pending', # optional; can be "cleared" or "pending"
76 tags => [qw(niska train-job)],
98 our $VERSION = '9999.999'; # VERSION
102 $ledger = App
::HomeBank2Ledger
::Ledger-
>new(%ledger_data);
104 Construct a new ledger instance
.
111 return bless {%args}, $class;
116 Get an arrayref of accounts
.
120 Get an arrayref of commodities
.
124 Get an arrayref of payees
.
128 Get an arrayref of tags
.
132 Get an arrayref of transactions
.
136 sub accounts
{ shift-
>{accounts
} || [] }
137 sub commodities
{ shift-
>{commodities
} || [] }
138 sub payees
{ shift-
>{payees
} || [] }
139 sub tags
{ shift-
>{tags
} || [] }
140 sub transactions
{ shift-
>{transactions
} || [] }
146 =method add_commodities
158 =method add_transactions
164 # TODO - These should validate incoming data.
168 push @{$self->{accounts
}}, @_;
171 sub add_commodities
{
173 push @{$self->{commodities
}}, @_;
178 push @{$self->{payees
}}, @_;
183 push @{$self->{tags
}}, @_;
186 sub add_transactions
{
188 push @{$self->{transactions
}}, @_;