mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-11-03 20:55:05 +00:00 
			
		
		
		
	This commit is contained in:
		@@ -37,6 +37,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
 | 
			
		||||
use Illuminate\Database\Eloquent\Relations\HasMany;
 | 
			
		||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
 | 
			
		||||
use Illuminate\Database\Eloquent\SoftDeletes;
 | 
			
		||||
use Illuminate\Support\Facades\Log;
 | 
			
		||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -167,12 +168,14 @@ class TransactionJournal extends Model
 | 
			
		||||
 | 
			
		||||
    public function scopeAfter(EloquentBuilder $query, Carbon $date): EloquentBuilder
 | 
			
		||||
    {
 | 
			
		||||
        return $query->where('transaction_journals.date', '>=', $date->format('Y-m-d 00:00:00'));
 | 
			
		||||
        Log::debug(sprintf('scopeAfter("%s")', $date->format('Y-m-d H:i:s')));
 | 
			
		||||
        return $query->where('transaction_journals.date', '>=', $date->format('Y-m-d H:i:s'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function scopeBefore(EloquentBuilder $query, Carbon $date): EloquentBuilder
 | 
			
		||||
    {
 | 
			
		||||
        return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
 | 
			
		||||
        Log::debug(sprintf('scopeBefore("%s")', $date->format('Y-m-d H:i:s')));
 | 
			
		||||
        return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function scopeTransactionTypes(EloquentBuilder $query, array $types): void
 | 
			
		||||
 
 | 
			
		||||
@@ -306,6 +306,8 @@ class BillRepository implements BillRepositoryInterface
 | 
			
		||||
    {
 | 
			
		||||
        // app('log')->debug('Now in getPaidDatesInRange()');
 | 
			
		||||
 | 
			
		||||
        Log::debug(sprintf('Search for linked journals between %s and %s', $start->toW3cString(), $end->toW3cString()));
 | 
			
		||||
 | 
			
		||||
        return $bill->transactionJournals()
 | 
			
		||||
            ->before($end)->after($start)->get(
 | 
			
		||||
                [
 | 
			
		||||
 
 | 
			
		||||
@@ -194,11 +194,19 @@ class BillTransformer extends AbstractTransformer
 | 
			
		||||
        $searchStart  = clone $start;
 | 
			
		||||
        $start->subDay();
 | 
			
		||||
 | 
			
		||||
        app('log')->debug(sprintf('Parameters are start: %s end: %s', $start->format('Y-m-d'), $this->parameters->get('end')->format('Y-m-d')));
 | 
			
		||||
        /** @var Carbon $end */
 | 
			
		||||
        $end = clone $this->parameters->get('end');
 | 
			
		||||
        $searchEnd = clone $end;
 | 
			
		||||
 | 
			
		||||
        // move the search dates to the start of the day.
 | 
			
		||||
        $searchStart->startOfDay();
 | 
			
		||||
        $searchEnd->endOfDay();
 | 
			
		||||
 | 
			
		||||
        app('log')->debug(sprintf('Parameters are start: %s end: %s', $start->format('Y-m-d'), $end->format('Y-m-d')));
 | 
			
		||||
        app('log')->debug(sprintf('Search parameters are: start: %s', $searchStart->format('Y-m-d')));
 | 
			
		||||
 | 
			
		||||
        // Get from database when bill was paid.
 | 
			
		||||
        $set          = $this->repository->getPaidDatesInRange($bill, $searchStart, $this->parameters->get('end'));
 | 
			
		||||
        $set          = $this->repository->getPaidDatesInRange($bill, $searchStart, $searchEnd);
 | 
			
		||||
        app('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.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user