getLedgerEntityId: Initial implementation.
All tests now pass: ok 15 - getLedgerEntityId: fails when rows are not returned but _verifyId() somehow passed ok 16 - getLedgerEntityId: fails when rows are not returned but _verifyId() somehow passed ok 17 - getLedgerEntityId: lives when valid id is given... ok 18 - getLedgerEntityId: ...and return value is correct.
This commit is contained in:
parent
0ca9d394e2
commit
2e14c340ec
1 changed files with 19 additions and 0 deletions
|
@ -381,6 +381,25 @@ for it.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
sub getLedgerEntityId($$) {
|
||||||
|
my($self, $donorId) = @_;
|
||||||
|
|
||||||
|
die "getLedgerEntityId: invalid supporter id, $donorId" unless $self->_verifyId($donorId);
|
||||||
|
|
||||||
|
my $lei = $self->dbh()->selectall_hashref("SELECT ledger_entity_id FROM donor WHERE id = " .
|
||||||
|
$self->dbh->quote($donorId, 'SQL_INTEGER'),
|
||||||
|
'ledger_entity_id');
|
||||||
|
my $rowCount = scalar keys %{$lei};
|
||||||
|
die "setPreferredEmailAddress: DATABASE INTEGRITY ERROR: more than one email address is preferred for supporter, \"$donorId\""
|
||||||
|
if $rowCount > 1;
|
||||||
|
|
||||||
|
if ($rowCount == 1) {
|
||||||
|
my ($ledgerEntityId) = keys %$lei;
|
||||||
|
return $ledgerEntityId;
|
||||||
|
} else {
|
||||||
|
die "getLedgerEntityId: DATABASE INTEGRITY ERROR: $donorId was valid but non-1 row count returned";
|
||||||
|
}
|
||||||
|
}
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
=begin addPostalAddress
|
=begin addPostalAddress
|
||||||
|
|
Loading…
Reference in a new issue