From 461dd8869168a3441aacea572ae8ea65cbdb37d7 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Mon, 15 Jul 2019 12:36:28 +0100 Subject: [PATCH] Fix import ref --- lib/Pear/LocalLoop/Controller/Api/External.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/Pear/LocalLoop/Controller/Api/External.pm b/lib/Pear/LocalLoop/Controller/Api/External.pm index 1b94d5b..6482af8 100644 --- a/lib/Pear/LocalLoop/Controller/Api/External.pm +++ b/lib/Pear/LocalLoop/Controller/Api/External.pm @@ -17,14 +17,12 @@ sub post_lcc_transactions { return $c->api_validation_error if $validation->has_error; - my $search_ref = undef; - if ( $validation->param('search') ) { - $search_ref = { - "organisation.name" => { '-like' => join( '', '%', $validation->param('search'), '%' ) }, - }; + my $search_ref = { 'me.buyer_id' => $user->entity->id }; + if ($validation->param('search')) { + $search_ref->{"organisation.name"} = { '-like' => join('', '%', $validation->param('search'), '%') }; } - my $lcc_transactions = $lcc_import_ext_ref->transactions->search( + my $lcc_transactions = $c->schema->resultset('Transaction')->search( $search_ref, { page => $validation->param('page') || 1,