Payee
NAME
App::Moneymoor::Gateway::Payee - SQL gateway for payees.
SYNOPSIS
use App::Moneymoor::Gateway::Payee;
my $gw = App::Moneymoor::Gateway::Payee.new(:$db);
my $tesco = $gw.find-or-create('Tesco'); # insert or fetch
my $again = $gw.find-or-create(' Tesco ');
say $again.id == $tesco.id; # True ā names are trimmed
my @all = $gw.find-all; # ordered by name
$gw.rename($tesco.id, 'Tesco Express');
$gw.delete($tesco.id); # transactions keep their
# amounts, lose the name
DESCRIPTION
Payees are names. They carry no budgeting semantics and the engine never reads them; they exist so a transaction list can be grouped and searched by counterparty.
find-or-create is the method to reach for when attaching a payee to
a transaction: names are unique, and doing "look it up, insert if
missing" in the caller invites two code paths that disagree about
trimming. Names are trimmed before comparison and storage, so
'Tesco' and ' Tesco ' are the same payee.
Deleting a payee nulls the reference on its transactions
(ON DELETE SET NULL). Losing a name is an annoyance; losing a
transaction would be a corrupted budget.
ATTRIBUTES
dbā requiredApp::Moneymoor::DB.
METHODS
find-all(--Array)> ā ordered by name.find-by-id(Int:D --Model::Payee)> ā type object when absent.find-by-name(Str:D --Model::Payee)>create(Str:D $name --Model::Payee)> āFailureon a duplicate or empty name.find-or-create(Str:D $name --Model::Payee)>rename(Int:D $id, Str:D $name)delete(Int:D $id)usage-count(Int:D $id --Int)> ā how many transactions point at it.