From ded20280694217a40cd6d69ae256ea1e0965521d Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Mon, 18 Jan 2016 21:10:47 -0800 Subject: [PATCH] Allow missing entityId in Ledger output. The ledger data can, in fact, sometimes have a missing entityId for various reasons. For now, these donations should just be ignored. Perhaps in future a warning of some sort should be generated. --- Supporters/lib/Supporters.pm | 3 ++- Supporters/t/Supporters.t | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Supporters/lib/Supporters.pm b/Supporters/lib/Supporters.pm index 79c7e62..f35a720 100644 --- a/Supporters/lib/Supporters.pm +++ b/Supporters/lib/Supporters.pm @@ -1447,8 +1447,9 @@ sub _readLedgerData($) { while (my $line = ) { next if $line =~ /^\s*$/; die "Invalid line in @cmd output:\n $line" - unless $line =~ /^\s*([^\d]+)\s+([\d\-]+)\s+(\S+)\s+\$\s*(\-?\s*[\d,\.]+)\s*$/; + unless $line =~ /^\s*([^\d]+)\s+([\d\-]+)\s+(\S*)\s+\$\s*(\-?\s*[\d,\.]+)\s*$/; my($type, $date, $entityId, $amount) = ($1, $2, $3, $4); + next unless defined $entityId and $entityId !~ /^\s*$/; if (defined $self->{programTypeSearch}) { if ($type =~ /$self->{programTypeSearch}{annual}/) { $type = 'Annual'; diff --git a/Supporters/t/Supporters.t b/Supporters/t/Supporters.t index 10e6478..6cca9fe 100644 --- a/Supporters/t/Supporters.t +++ b/Supporters/t/Supporters.t @@ -52,6 +52,7 @@ Supporters:Match Pledge 2015-02-26 Whitman-Dick \$-300.00 Supporters:Monthly 2015-02-16 Olson-Margaret \$-10.00 Supporters:Monthly 2015-06-30 Olson-Margaret \$-10.00 Supporters:Annual 2015-03-04 Harris-Joan \$-120.00 +Supporters:Annual 2016-01-10 \$-120.00 FAKE_LEDGER_TEST_DATA_END =item Public-facing methods of the module, as follows: