Another possible fix for transactions under postgres
This commit is contained in:
parent
ed0a14c468
commit
f61c90a3c0
1 changed files with 19 additions and 32 deletions
|
@ -80,38 +80,25 @@ sub post_lcc_suppliers {
|
||||||
|
|
||||||
return $c->api_validation_error if $v->has_error;
|
return $c->api_validation_error if $v->has_error;
|
||||||
|
|
||||||
my $lcc_import_ext_ref = $c->schema->resultset('ExternalReference')->find_or_create({ name => 'LCC CSV' });
|
my $lcc_suppliers = $c->schema->resultset('Entity')->search(
|
||||||
|
|
||||||
return 0 unless $lcc_import_ext_ref;
|
|
||||||
|
|
||||||
my $columns = [qw/
|
|
||||||
sales.id
|
|
||||||
seller.id
|
|
||||||
organisation.id
|
|
||||||
organisation.name
|
|
||||||
organisation.street_name
|
|
||||||
organisation.town
|
|
||||||
organisation.postcode
|
|
||||||
organisation.country
|
|
||||||
/];
|
|
||||||
|
|
||||||
my $lcc_suppliers = $user->entity->purchases->search_related('seller',undef)->search(
|
|
||||||
undef,
|
|
||||||
{
|
{
|
||||||
prefetch => ['sales', 'organisation'],
|
'sales.buyer_id' => $user->entity->id,
|
||||||
columns => $columns,
|
},
|
||||||
group_by => $columns,
|
{
|
||||||
|
join => ['sales', 'organisation'],
|
||||||
|
group_by => ['me.id', 'organisation.id'],
|
||||||
'+select' => [
|
'+select' => [
|
||||||
{
|
{
|
||||||
'sum' => 'sales.value',
|
'sum' => 'sales.value',
|
||||||
'-as' => 'total_spend',
|
'-as' => 'total_spend',
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
'+as' => ['total_spend'],
|
'+as' => ['total_spend'],
|
||||||
page => $v->param('page') || 1,
|
page => $v->param('page') || 1,
|
||||||
rows => 10,
|
rows => 10,
|
||||||
order_by => $order_by,
|
order_by => $order_by,
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
my @supplier_list = (
|
my @supplier_list = (
|
||||||
map {{
|
map {{
|
||||||
|
|
Reference in a new issue