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:CapitalOne"
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 payee => 'Malcolm Reynolds', # required
55 status => 'cleared', # optional; can be "cleared" or "pending"
56 memo => 'Medical supplies', # optional
57 postings => [ # required
59 account => 'Some Account', # required
60 amount => '16.25', # required for at least n-1 postings
63 format => '$1,000.00',
71 payee => 'Somebody', # optional
72 memo => 'Whatever', # optional
73 status => 'pending', # optional; can be "cleared" or "pending"
74 tags => [qw(niska train-job)],
85 our $VERSION = '9999.999'; # VERSION
89 $ledger = App
::HomeBank2Ledger
::Ledger-
>new(%ledger_data);
91 Construct a new ledger instance
.
98 return bless {%args}, $class;
103 Get an arrayref of accounts
.
107 Get an arrayref of commodities
.
111 Get an arrayref of payees
.
115 Get an arrayref of tags
.
119 Get an arrayref of transactions
.
123 sub accounts
{ shift-
>{accounts
} || [] }
124 sub commodities
{ shift-
>{commodities
} || [] }
125 sub payees
{ shift-
>{payees
} || [] }
126 sub tags
{ shift-
>{tags
} || [] }
127 sub transactions
{ shift-
>{transactions
} || [] }
133 =method add_commodities
145 =method add_transactions
151 # TODO - These should validate incoming data.
155 push @{$self->{accounts
}}, @_;
158 sub add_commodities
{
160 push @{$self->{commodities
}}, @_;
165 push @{$self->{payees
}}, @_;
170 push @{$self->{tags
}}, @_;
173 sub add_transactions
{
175 push @{$self->{transactions
}}, @_;