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

@@ -22,9 +22,9 @@ class ProfileController extends BaseController
*/ */
public function index() public function index()
{ {
View::share('title','Profile'); View::share('title', 'Profile');
View::share('subTitle',Auth::user()->email); View::share('subTitle', Auth::user()->email);
View::share('mainTitleIcon','fa-user'); View::share('mainTitleIcon', 'fa-user');
return View::make('profile.index'); return View::make('profile.index');
} }
@@ -33,9 +33,9 @@ class ProfileController extends BaseController
*/ */
public function changePassword() public function changePassword()
{ {
View::share('title',Auth::user()->email); View::share('title', Auth::user()->email);
View::share('subTitle','Change your password'); View::share('subTitle', 'Change your password');
View::share('mainTitleIcon','fa-user'); View::share('mainTitleIcon', 'fa-user');
return View::make('profile.change-password'); return View::make('profile.change-password');
} }

View File

@@ -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 {

View File

@@ -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;
} }

View File

@@ -41,21 +41,37 @@ class EloquentRecurringTrigger
$wordMatch = false; $wordMatch = false;
$matches = explode(' ', $recurring->match); $matches = explode(' ', $recurring->match);
$description = strtolower($journal->description); $description = strtolower($journal->description);
$count = 0;
/*
* 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) { 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) {
$amount = max(floatval($transactions[0]->amount), floatval($transactions[1]->amount)); $amount = max(floatval($transactions[0]->amount), floatval($transactions[1]->amount));
@@ -73,6 +89,7 @@ class EloquentRecurringTrigger
$journal->recurringTransaction()->associate($recurring); $journal->recurringTransaction()->associate($recurring);
$journal->save(); $journal->save();
} }
} }
/** /**

View File

@@ -1,43 +1,41 @@
@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">
{{Form::open(['class' => 'form-horizontal'])}} <div class="panel-heading">
<div class="form-group"> Change your password
<label for="inputOldPassword" class="col-sm-4 control-label">Old password</label>
<div class="col-sm-8">
<input type="password" class="form-control" id="inputOldPassword" placeholder="Old password" name="old">
</div>
</div> </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>
<div class="col-sm-8">
<input type="password" class="form-control" id="inputOldPassword" placeholder="Old password" name="old">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="inputNewPassword1" class="col-sm-4 control-label">New password</label> <label for="inputNewPassword1" class="col-sm-4 control-label">New password</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="password" class="form-control" id="inputNewPassword1" placeholder="New password" name="new1"> <input type="password" class="form-control" id="inputNewPassword1" placeholder="New password" name="new1">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="inputNewPassword2" class="col-sm-4 control-label">New password (again)</label> <label for="inputNewPassword2" class="col-sm-4 control-label">New password (again)</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="password" class="form-control" id="inputNewPassword2" placeholder="New password (again)" name="new2"> <input type="password" class="form-control" id="inputNewPassword2" placeholder="New password (again)" name="new2">
</div> </div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-10">
<button type="submit" class="btn btn-success">Change your password</button>
</div>
</div>
{{Form::close()}}
</div> </div>
<div class="form-group"> </div>
<div class="col-sm-offset-4 col-sm-10">
<button type="submit" class="btn btn-success">Change your password</button>
</div>
</div>
{{Form::close()}}
</div> </div>
</div> </div>
@stop @stop

View File

@@ -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

View File

@@ -212,41 +212,45 @@ $(function () {
}); });
$.getJSON('chart/home/recurring').success(function (data) { $.getJSON('chart/home/recurring').success(function (data) {
$('#recurring').highcharts({ if (data[0].data.length == 0) {
title: { $('#recurring').parent().parent().remove();
text: null } else {
}, $('#recurring').highcharts({
credits: { title: {
enabled: false text: null
}, },
tooltip: { credits: {
formatter: function () { enabled: false
if (this.point.objType == 'paid') { },
return this.key + ': \u20AC ' + Highcharts.numberFormat(this.y, 2); tooltip: {
} else { formatter: function () {
return this.key + ': ~\u20AC ' + Highcharts.numberFormat(this.y, 2); if (this.point.objType == 'paid') {
} return this.key + ': \u20AC ' + Highcharts.numberFormat(this.y, 2);
} else {
} return this.key + ': ~\u20AC ' + Highcharts.numberFormat(this.y, 2);
},
plotOptions: {
pie: {
events: {
click: function (e) {
if (e.point.url != null) {
window.location = e.point.url;
}
} }
},
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
} }
} },
}, plotOptions: {
series: data pie: {
}); events: {
click: function (e) {
if (e.point.url != null) {
window.location = e.point.url;
}
}
},
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
}
}
},
series: data
});
}
}); });
}); });