This commit is contained in:
James Cole 2023-07-01 12:18:07 +02:00
parent ad0a1b9a24
commit b055a5d6af
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
4 changed files with 28 additions and 21 deletions

View File

@ -379,16 +379,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.19.2",
"version": "v3.20.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "210dd89560edb27a8e0d5086b734ac5b5fd4e0e4"
"reference": "0e8249e0b15e2bc022fbbd1090ce29d071481e69"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/210dd89560edb27a8e0d5086b734ac5b5fd4e0e4",
"reference": "210dd89560edb27a8e0d5086b734ac5b5fd4e0e4",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/0e8249e0b15e2bc022fbbd1090ce29d071481e69",
"reference": "0e8249e0b15e2bc022fbbd1090ce29d071481e69",
"shasum": ""
},
"require": {
@ -463,7 +463,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.19.2"
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.20.0"
},
"funding": [
{
@ -471,7 +471,7 @@
"type": "github"
}
],
"time": "2023-06-25T16:42:58+00:00"
"time": "2023-06-27T20:22:39+00:00"
},
{
"name": "psr/cache",

View File

@ -127,7 +127,7 @@ class ShowController extends Controller
*/
public function triggerTransaction(Webhook $webhook, TransactionGroup $group): JsonResponse
{
app('log')->debug(sprintf('Now in triggerTransaction(%d, %d)',$webhook->id, $group->id));
app('log')->debug(sprintf('Now in triggerTransaction(%d, %d)', $webhook->id, $group->id));
/** @var MessageGeneratorInterface $engine */
$engine = app(MessageGeneratorInterface::class);
$engine->setUser(auth()->user());

View File

@ -35,6 +35,7 @@ class PiggyBankEventHandler
{
/**
* @param ChangedPiggyBankAmount $event
*
* @return void
*/
public function changePiggyAmount(ChangedPiggyBankAmount $event): void
@ -45,7 +46,6 @@ class PiggyBankEventHandler
$journal = $event->transactionGroup->transactionJournals()->first();
}
$date = $journal?->date ?? today(config('app.timezone'));
// sanity check: event must not already exist for this journal and piggy bank.
if (null !== $journal) {
$exists = PiggyBankEvent::where('piggy_bank_id', $event->piggyBank->id)

View File

@ -30,14 +30,14 @@ use FireflyIII\Models\ObjectGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
/**
* Class BillTransformer
*/
class BillTransformer extends AbstractTransformer
{
/** @var BillRepositoryInterface */
private $repository;
private BillRepositoryInterface $repository;
/**
* BillTransformer constructor.
@ -60,7 +60,6 @@ class BillTransformer extends AbstractTransformer
{
$paidData = $this->paidData($bill);
$payDates = $this->payDates($bill);
$currency = $bill->transactionCurrency;
$notes = $this->repository->getNoteText($bill);
$notes = '' === $notes ? null : $notes;
@ -87,11 +86,15 @@ class BillTransformer extends AbstractTransformer
foreach ($payDates as $string) {
$payDatesFormatted[] = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone'))->toAtomString();
}
if (1 === $bill->id) {
var_dump($payDates);
var_dump($payDatesFormatted);
var_dump($paidData['next_expected_match']);
}
$nextExpectedMatch = null;
if (null !== $paidData['next_expected_match']) {
$nextExpectedMatch = Carbon::createFromFormat('!Y-m-d', $paidData['next_expected_match'], config('app.timezone'))->toAtomString();
}
$nextExpectedMatchDiff = trans('firefly.not_expected_period');
// converting back and forth is bad code but OK.
$temp = new Carbon($nextExpectedMatch);
@ -102,7 +105,7 @@ class BillTransformer extends AbstractTransformer
$current = $payDatesFormatted[0] ?? null;
if (null !== $current && !$temp->isToday()) {
$temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);
$nextExpectedMatchDiff = $temp2->diffForHumans(today(), CarbonInterface::DIFF_RELATIVE_TO_NOW);
$nextExpectedMatchDiff = $temp2->diffForHumans(today(config('app.timezone')), CarbonInterface::DIFF_RELATIVE_TO_NOW);
}
unset($temp, $temp2);
@ -152,28 +155,32 @@ class BillTransformer extends AbstractTransformer
*/
protected function paidData(Bill $bill): array
{
//Log::debug(sprintf('Now in paidData for bill #%d', $bill->id));
Log::debug(sprintf('Now in paidData for bill #%d', $bill->id));
if (null === $this->parameters->get('start') || null === $this->parameters->get('end')) {
// Log::debug('parameters are NULL, return empty array');
//Log::debug('parameters are NULL, return empty array');
return [
'paid_dates' => [],
'next_expected_match' => null,
];
}
//Log::debug(sprintf('Parameters are start:%s end:%s', $this->parameters->get('start')->format('Y-m-d'), $this->parameters->get('end')->format('Y-m-d')));
// 2023-07-1 sub one day from the start date to fix a possible bug (see #7704)
/** @var Carbon $start */
$start = clone $this->parameters->get('start');
$start->subDay();
//Log::debug(sprintf('Parameters are start:%s end:%s', $start->format('Y-m-d'), $this->parameters->get('end')->format('Y-m-d')));
/*
* Get from database when bill was paid.
*/
$set = $this->repository->getPaidDatesInRange($bill, $this->parameters->get('start'), $this->parameters->get('end'));
$set = $this->repository->getPaidDatesInRange($bill, $start, $this->parameters->get('end'));
//Log::debug(sprintf('Count %d entries in getPaidDatesInRange()', $set->count()));
/*
* Grab from array the most recent payment. If none exist, fall back to the start date and pretend *that* was the last paid date.
*/
//Log::debug(sprintf('Grab last paid date from function, return %s if it comes up with nothing.', $this->parameters->get('start')->format('Y-m-d')));
$lastPaidDate = $this->lastPaidDate($set, $this->parameters->get('start'));
//Log::debug(sprintf('Grab last paid date from function, return %s if it comes up with nothing.', $start->format('Y-m-d')));
$lastPaidDate = $this->lastPaidDate($set, $start);
//Log::debug(sprintf('Result of lastPaidDate is %s', $lastPaidDate->format('Y-m-d')));
/*
@ -192,7 +199,7 @@ class BillTransformer extends AbstractTransformer
}
if ($nextMatch->isSameDay($lastPaidDate)) {
/*
* Add another period because its the same day as the last paid date.
* Add another period because it's the same day as the last paid date.
*/
//Log::debug('Because the last paid date was on the same day as our next expected match, add another day.');
$nextMatch = app('navigation')->addPeriod($nextMatch, $bill->repeat_freq, $bill->skip);
@ -258,7 +265,7 @@ class BillTransformer extends AbstractTransformer
$currentStart = clone $this->parameters->get('start');
// 2023-06-23 subDay to fix 7655
$currentStart->subDay();
$loop = 0;
$loop = 0;
while ($currentStart <= $this->parameters->get('end')) {
$nextExpectedMatch = $this->nextDateMatch($bill, $currentStart);
// If nextExpectedMatch is after end, we continue: