mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-25 14:58:40 +00:00
Merge branch 'release/3.1.4'
This commit is contained in:
@@ -175,12 +175,6 @@ class EloquentRecurringTransactionRepository implements RecurringTransactionRepo
|
|||||||
return $messageBag;
|
return $messageBag;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($recurringTransaction->date < Carbon::now()) {
|
|
||||||
$messageBag->add('date', 'Must be in the future.');
|
|
||||||
return $messageBag;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($recurringTransaction->validate()) {
|
if ($recurringTransaction->validate()) {
|
||||||
$recurringTransaction->save();
|
$recurringTransaction->save();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -33,46 +33,9 @@ class EloquentJournalTrigger
|
|||||||
|
|
||||||
/** @var \RecurringTransaction $recurring */
|
/** @var \RecurringTransaction $recurring */
|
||||||
foreach ($set as $recurring) {
|
foreach ($set as $recurring) {
|
||||||
$matches = explode(' ', $recurring->match);
|
\Event::fire('recurring.rescan', [$recurring, $journal]);
|
||||||
|
|
||||||
/*
|
|
||||||
* Count the number of matches.
|
|
||||||
*/
|
|
||||||
$count = 0;
|
|
||||||
foreach ($matches as $word) {
|
|
||||||
if (!(strpos($description, strtolower($word)) === false)) {
|
|
||||||
$count++;
|
|
||||||
\Log::debug('Recurring transaction #' . $recurring->id . ': word "' . $word . '" found in "' . $description . '".');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Check the amount if match on words:
|
|
||||||
*/
|
|
||||||
$amount = max(floatval($journal->transactions[0]->amount), floatval($journal->transactions[1]->amount));
|
|
||||||
$min = floatval($recurring->amount_min);
|
|
||||||
$max = floatval($recurring->amount_max);
|
|
||||||
if ($amount >= $min && $amount <= $max) {
|
|
||||||
$result[$recurring->id] = $count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* The one with the highest value is the winrar!
|
|
||||||
*/
|
|
||||||
$index = array_search(max($result), $result);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Find the recurring transaction:
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($result[$index] > 0 && $index > 0) {
|
|
||||||
|
|
||||||
$winner = $journal->user()->first()->recurringtransactions()->find($index);
|
|
||||||
if ($winner) {
|
|
||||||
$journal->recurringTransaction()->associate($winner);
|
|
||||||
$journal->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -41,20 +41,36 @@ class EloquentRecurringTrigger
|
|||||||
$wordMatch = false;
|
$wordMatch = false;
|
||||||
$matches = explode(' ', $recurring->match);
|
$matches = explode(' ', $recurring->match);
|
||||||
$description = strtolower($journal->description);
|
$description = strtolower($journal->description);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Attach expense account to description for more narrow matching.
|
||||||
|
*/
|
||||||
|
$transactions = $journal->transactions()->get();
|
||||||
|
/** @var \Transaction $transaction */
|
||||||
|
foreach ($transactions as $transaction) {
|
||||||
|
/** @var \Account $account */
|
||||||
|
$account = $transaction->account()->first();
|
||||||
|
/** @var \AccountType $type */
|
||||||
|
$type = $account->accountType()->first();
|
||||||
|
if ($type->type == 'Expense account' || $type->type == 'Beneficiary account') {
|
||||||
|
$description .= ' ' . strtolower($account->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($matches as $word) {
|
foreach ($matches as $word) {
|
||||||
if (!(strpos($description, strtolower($word)) === false)) {
|
if (!(strpos($description, strtolower($word)) === false)) {
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($count > 0) {
|
if ($count >= count($matches)) {
|
||||||
$wordMatch = true;
|
$wordMatch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Match amount.
|
* Match amount.
|
||||||
*/
|
*/
|
||||||
$transactions = $journal->transactions()->get();
|
|
||||||
$amountMatch = false;
|
$amountMatch = false;
|
||||||
if (count($transactions) > 1) {
|
if (count($transactions) > 1) {
|
||||||
|
|
||||||
@@ -73,6 +89,7 @@ class EloquentRecurringTrigger
|
|||||||
$journal->recurringTransaction()->associate($recurring);
|
$journal->recurringTransaction()->associate($recurring);
|
||||||
$journal->save();
|
$journal->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,15 +1,12 @@
|
|||||||
@extends('layouts.default')
|
@extends('layouts.default')
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
|
||||||
<p class="text-info">
|
|
||||||
Use this extremely obvious form to change your password.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-6 col-md-12 col-sm-12">
|
<div class="col-lg-6 col-md-12 col-sm-12">
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
<div class="panel-heading">
|
||||||
|
Change your password
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
{{Form::open(['class' => 'form-horizontal'])}}
|
{{Form::open(['class' => 'form-horizontal'])}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="inputOldPassword" class="col-sm-4 control-label">Old password</label>
|
<label for="inputOldPassword" class="col-sm-4 control-label">Old password</label>
|
||||||
@@ -37,7 +34,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{Form::close()}}
|
{{Form::close()}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@stop
|
@stop
|
||||||
|
@@ -1,8 +1,15 @@
|
|||||||
@extends('layouts.default')
|
@extends('layouts.default')
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-6 col-md-12 col-sm-12">
|
||||||
<p class="lead"><a href="{{route('change-password')}}">Change your password</a></p>
|
<div class="panel panel-primary">
|
||||||
|
<div class="panel-heading">
|
||||||
|
Options
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<a href="{{route('change-password')}}">Change your password</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@stop
|
@stop
|
||||||
|
@@ -212,6 +212,9 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.getJSON('chart/home/recurring').success(function (data) {
|
$.getJSON('chart/home/recurring').success(function (data) {
|
||||||
|
if (data[0].data.length == 0) {
|
||||||
|
$('#recurring').parent().parent().remove();
|
||||||
|
} else {
|
||||||
$('#recurring').highcharts({
|
$('#recurring').highcharts({
|
||||||
title: {
|
title: {
|
||||||
text: null
|
text: null
|
||||||
@@ -247,6 +250,7 @@ $(function () {
|
|||||||
},
|
},
|
||||||
series: data
|
series: data
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
Reference in New Issue
Block a user