diff --git a/lib/Pear/LocalLoop/Controller/Api/Categories.pm b/lib/Pear/LocalLoop/Controller/Api/Categories.pm index 9913f42..95f9db5 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Categories.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Categories.pm @@ -43,7 +43,7 @@ sub post_category_list { for my $cat_trans ( $month_transaction_category_rs->all ) { my $quantised = $c->db_datetime_parser->parse_datetime($cat_trans->get_column('quantised')); my $days = $c->format_iso_date( $quantised ) || 0; - my $category = $cat_trans->get_column('category_id') || 0; + my $category = $cat_trans->get_column('category_id') || undef; my $value = ($cat_trans->get_column('value') || 0) / 100000; $data->{categories}->{$days} = [] unless exists $data->{categories}->{$days}; push @{ $data->{categories}->{$days} }, { diff --git a/lib/Pear/LocalLoop/Controller/Api/Transactions.pm b/lib/Pear/LocalLoop/Controller/Api/Transactions.pm index a2458d6..e5bbc94 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Transactions.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Transactions.pm @@ -42,7 +42,7 @@ sub post_transaction_list_purchases { purchase_time => $c->format_iso_datetime($_->purchase_time), }} $transactions->all ); - + my @recurring_transaction_list = ( map {{ id => $_->id, @@ -51,7 +51,7 @@ sub post_transaction_list_purchases { start_time => $c->format_iso_datetime($_->start_time), last_updated => $c->format_iso_datetime($_->last_updated) || undef, essential => $_->essential, - category => $_->category_id, + category => $_->category_id || 0, recurring_period => $_->recurring_period, }} $recurring_transactions->all ); diff --git a/lib/Pear/LocalLoop/Controller/Api/Upload.pm b/lib/Pear/LocalLoop/Controller/Api/Upload.pm index dea1f10..31fa234 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Upload.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Upload.pm @@ -249,16 +249,15 @@ sub post_category { # push @{ $categories->{ ids } }, $_->get_column('id'); # push @{ $categories->{ names } }, $_->get_column('name'); # } - my @category_list = ( - map {{ - id => $_->id, - name => $_->name, - }} $category_rs->all + my %category_list = ( + map { + $_->id => $_->name, + } $category_rs->all ); return $self->render( json => { success => Mojo::JSON->true, - categories => \@category_list, + categories => \%category_list, }); }