Merge branch 'release/3.1.4'

This commit is contained in:
Sander Dorigo
2014-10-14 07:32:00 +02:00
7 changed files with 104 additions and 121 deletions

View File

@@ -175,12 +175,6 @@ class EloquentRecurringTransactionRepository implements RecurringTransactionRepo
return $messageBag;
}
if ($recurringTransaction->date < Carbon::now()) {
$messageBag->add('date', 'Must be in the future.');
return $messageBag;
}
if ($recurringTransaction->validate()) {
$recurringTransaction->save();
} else {

View File

@@ -33,46 +33,9 @@ class EloquentJournalTrigger
/** @var \RecurringTransaction $recurring */
foreach ($set as $recurring) {
$matches = explode(' ', $recurring->match);
/*
* 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;
\Event::fire('recurring.rescan', [$recurring, $journal]);
}
}
/*
* 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;
}

View File

@@ -41,20 +41,36 @@ class EloquentRecurringTrigger
$wordMatch = false;
$matches = explode(' ', $recurring->match);
$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;
foreach ($matches as $word) {
if (!(strpos($description, strtolower($word)) === false)) {
$count++;
}
}
if ($count > 0) {
if ($count >= count($matches)) {
$wordMatch = true;
}
/*
* Match amount.
*/
$transactions = $journal->transactions()->get();
$amountMatch = false;
if (count($transactions) > 1) {
@@ -73,6 +89,7 @@ class EloquentRecurringTrigger
$journal->recurringTransaction()->associate($recurring);
$journal->save();
}
}
/**

View File

@@ -1,15 +1,12 @@
@extends('layouts.default')
@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="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'])}}
<div class="form-group">
<label for="inputOldPassword" class="col-sm-4 control-label">Old password</label>
@@ -37,7 +34,8 @@
</div>
</div>
{{Form::close()}}
</div>
</div>
</div>
</div>
@stop

View File

@@ -1,8 +1,15 @@
@extends('layouts.default')
@section('content')
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<p class="lead"><a href="{{route('change-password')}}">Change your password</a></p>
<div class="col-lg-6 col-md-12 col-sm-12">
<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>
@stop

View File

@@ -212,6 +212,9 @@ $(function () {
});
$.getJSON('chart/home/recurring').success(function (data) {
if (data[0].data.length == 0) {
$('#recurring').parent().parent().remove();
} else {
$('#recurring').highcharts({
title: {
text: null
@@ -247,6 +250,7 @@ $(function () {
},
series: data
});
}
});
});