From 25b6b3a9a4ec63b3478224699aac15d625a75c68 Mon Sep 17 00:00:00 2001 From: Thomas Bloor Date: Thu, 24 May 2018 15:16:28 +0100 Subject: [PATCH] Fix recurring transactions calculator for after-the-fact updates --- .../LocalLoop/Command/recur_transactions.pm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/Pear/LocalLoop/Command/recur_transactions.pm b/lib/Pear/LocalLoop/Command/recur_transactions.pm index e5bdeb3..7aab7ea 100644 --- a/lib/Pear/LocalLoop/Command/recur_transactions.pm +++ b/lib/Pear/LocalLoop/Command/recur_transactions.pm @@ -87,12 +87,11 @@ sub run { return; } - my $now = DateTime->now(); my $purchase_time = DateTime->new( - year => $now->year, - month => $now->month, - day => $now->day, - hour => $start_time_dt->hour, + year => $datetime->year, + month => $datetime->month, + day => $datetime->day, + hour => $start_time_dt->hour, minute => $start_time_dt->minute, second => $start_time_dt->second, time_zone => 'UTC', @@ -102,12 +101,12 @@ sub run { my $distance = $recur_result->distance; my $new_transaction = $schema->resultset('Transaction')->create({ - buyer_id => $recur_result->buyer_id, - seller_id => $recur_result->seller_id, - value => $recur_result->value, + buyer_id => $recur_result->buyer_id, + seller_id => $recur_result->seller_id, + value => $recur_result->value, purchase_time => $app->format_db_datetime($purchase_time), - distance => $distance, - essential => ( defined $essential ? $essential : 0 ), + distance => $distance, + essential => ( defined $essential ? $essential : 0 ), }); unless ( defined $new_transaction ) {