Split
NAME
App::Moneymoor::Model::Split - the categorized part of a transaction.
SYNOPSIS
use App::Moneymoor::Model::Split;
# A £60 shop split between food and household:
my @splits = (
App::Moneymoor::Model::Split.new(category-id => $groceries, amount => -4500),
App::Moneymoor::Model::Split.new(category-id => $household, amount => -1500),
);
# ... created together with the transaction, in one SQL transaction:
$gw.create($txn, :@splits);
my $s = App::Moneymoor::Model::Split.new-from-row(%row);
DESCRIPTION
Splits are where transactions meet envelopes. Every categorized
transaction owns at least one, and their amounts must sum to the
transaction's amount ā Gateway::Transaction enforces that inside
the same SQL transaction that writes them, so a budget file can never
contain a half-categorized transaction.
Amounts follow the transaction's sign convention (outflow negative, inflow positive), so a refund split is positive and a spending split is negative. A split may be zero ā that is a legitimate placeholder while a UI is being edited ā and the engine treats zero splits as no-ops.
Inflows are categorized like anything else: a salary payment is a
split against the rta category, which is what makes it "Ready to
Assign" rather than money that appeared in an envelope by magic.
memo is per-split, so a three-way split can explain each part.
ATTRIBUTES
idā primary key; absent on a not-yet-inserted row.transaction-idā FK totransactions.id. Left unset when building splits to pass toGateway::Transaction.create: the gateway fills it in once the transaction has an id.category-idā required FK tocategories.id.amountā required signed integer pence.memoā free-form, default empty string.
METHODS
new-from-row(%row)ā build from a DBIish row hash.is-inflow/is-outflowā amount sign predicates.