Assignment
NAME
App::Moneymoor::Model::Assignment - money given to a category in a budget period.
SYNOPSIS
use App::Moneymoor::Model::Assignment;
my $a = App::Moneymoor::Model::Assignment.new(
period => '2026-03-01',
category-id => $groceries,
amount => 40000, # £400.00
);
my $loaded = App::Moneymoor::Model::Assignment.new-from-row(%row);
DESCRIPTION
An assignment is the only budgeting fact the user authors directly:
"in March, Groceries gets Ā£400". It is a set, not an increment ā
there is exactly one row per (period, category), enforced by a
unique index, and Gateway::Assignment.set upserts it. Moving money
between two categories is two upserts inside one SQL transaction
(move-money), which is why the pair can never half-apply.
This model is deliberately scheme-ignorant: it carries the period key
it was given and has no opinion about whether that key is a start
under anybody's scheme. Gateway::Assignment holds the scheme and
refuses to store a key that is not one; Service::Budget holds it
again and skips such a row with a warning if one arrives from
somewhere else.
Amounts may be negative: pulling £50 back out of a category that was
never funded that period leaves -5000 assigned, and the engine
treats that exactly as it reads ā the category has Ā£50 less, Ready to
Assign has £50 more.
Assignments in future periods are legal and deliberate. They are
deducted from Ready to Assign immediately, in every period, not just
in the period they land in: budgeting December's council tax in August
means August's Ready to Assign no longer offers you that money. See
rule 4 in App::Moneymoor::Service::Budget.
Assigning to the rta category is rejected by the gateway. "Ready to
Assign" is the pool assignments come from; letting it be assigned
to would make the arithmetic circular.
ATTRIBUTES
idā primary key; absent on a not-yet-inserted row.periodā requiredYYYY-MM-DD: the start date of the budget period the money belongs to. Under the defaultmonthly/1scheme that is always the first of a month, and the pre-periodYYYY-MMkeys migrate by appending-01; seeApp::Moneymoor::Util::Period.category-idā required FK tocategories.id.amountā signed integer pence; default 0.
METHODS
new-from-row(%row)ā build from a DBIish row hash.