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 — required YYYY-MM-DD: the start date of the budget period the money belongs to. Under the default monthly/1 scheme that is always the first of a month, and the pre-period YYYY-MM keys migrate by appending -01; see App::Moneymoor::Util::Period.

  • category-id — required FK to categories.id.

  • amount — signed integer pence; default 0.

METHODS

  • new-from-row(%row) — build from a DBIish row hash.

App::Moneymoor v0.4.2

YNAB-style envelope budgeting: a derivation engine

Authors

  • Matt Doughty

License

Artistic-2.0

Dependencies

DBIish:ver<0.6.7>:auth<zef:raku-community-modules>Notcurses::Native:ver<0.6.5+>:auth<zef:apogee>Selkie:ver<0.16.0+>:auth<zef:apogee>JSON::Fast:ver<0.19>:auth<cpan:TIMOTIMO>MacOS::NativeLib:ver<0.0.6>:auth<zef:lizmat>

Test Dependencies

Provides

  • App::Moneymoor
  • App::Moneymoor::Config
  • App::Moneymoor::DB
  • App::Moneymoor::Gateway::Account
  • App::Moneymoor::Gateway::Assignment
  • App::Moneymoor::Gateway::Category
  • App::Moneymoor::Gateway::Payee
  • App::Moneymoor::Gateway::Transaction
  • App::Moneymoor::Handlers::Boot
  • App::Moneymoor::Model::Account
  • App::Moneymoor::Model::Assignment
  • App::Moneymoor::Model::Category
  • App::Moneymoor::Model::CategoryGroup
  • App::Moneymoor::Model::Payee
  • App::Moneymoor::Model::Split
  • App::Moneymoor::Model::Transaction
  • App::Moneymoor::Screen::Accounts
  • App::Moneymoor::Screen::Budget
  • App::Moneymoor::Screen::Login
  • App::Moneymoor::Screen::Main
  • App::Moneymoor::Screen::Main::Keybinds
  • App::Moneymoor::Screen::Main::Modals
  • App::Moneymoor::Screen::Main::Subscriptions
  • App::Moneymoor::Screen::Reports
  • App::Moneymoor::Service::Budget
  • App::Moneymoor::Service::Icons
  • App::Moneymoor::Service::Target
  • App::Moneymoor::Service::Workspace
  • App::Moneymoor::StoreHandlers
  • App::Moneymoor::Theme
  • App::Moneymoor::Theme::Catppuccin
  • App::Moneymoor::Theme::Dracula
  • App::Moneymoor::Theme::Everforest
  • App::Moneymoor::Theme::Gruvbox
  • App::Moneymoor::Theme::Kanagawa
  • App::Moneymoor::Theme::Monokai
  • App::Moneymoor::Theme::Nord
  • App::Moneymoor::Theme::OneDark
  • App::Moneymoor::Theme::RosePine
  • App::Moneymoor::Theme::Solarized
  • App::Moneymoor::Theme::TokyoNight
  • App::Moneymoor::Themes
  • App::Moneymoor::UI
  • App::Moneymoor::Util::Money
  • App::Moneymoor::Util::Period
  • App::Moneymoor::View::BudgetRow
  • App::Moneymoor::View::EmptyState
  • App::Moneymoor::View::HintBar
  • App::Moneymoor::View::InspectorPane
  • App::Moneymoor::View::ModalChrome
  • App::Moneymoor::View::RegisterRow
  • App::Moneymoor::View::ReportRow
  • App::Moneymoor::Widget::BannerBar
  • App::Moneymoor::Widget::BootProgressModal

The Camelia image is copyright 2009 by Larry Wall. "Raku" is a trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.