From d3933f53afabdcf65a31ef4f83c0cc3e2cb63367 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Mon, 15 Jul 2019 04:50:46 +0100 Subject: [PATCH] Fix some annoyances with joins --- lib/Pear/LocalLoop/Controller/Api/External.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Pear/LocalLoop/Controller/Api/External.pm b/lib/Pear/LocalLoop/Controller/Api/External.pm index dd41dd0..4a2ee0e 100644 --- a/lib/Pear/LocalLoop/Controller/Api/External.pm +++ b/lib/Pear/LocalLoop/Controller/Api/External.pm @@ -303,27 +303,27 @@ sub post_supplier_history { order_by => { '-asc' => 'organisation.name' }, } ); - my $quarter_year_rs = $c->schema->resultset('Transaction')->search( + my $quarter_year_rs = $c->schema->resultset('Entity')->search( { - 'me.purchase_time' => { + 'sales.purchase_time' => { -between => [ $dtf->format_datetime($third), $dtf->format_datetime($last), ], }, - 'me.buyer_id' => $user->entity->id, + 'sales.buyer_id' => $user->entity->id, }, { - join => { seller => 'organisation' }, + join => [ 'sales', 'organisation' ], columns => [ { - id => 'me.seller_id', + id => 'me.id', name => 'organisation.name', count => \"COUNT(*)", - total_spend => { sum => 'me.value' }, + total_spend => { sum => 'sales.value' }, } ], - group_by => 'me.seller_id', + group_by => [ 'me.id', 'organisation.name' ], order_by => { '-asc' => 'organisation.name' }, } );