mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Scan bills when editing and creating journals.
This commit is contained in:
@@ -1,18 +1,20 @@
|
|||||||
<?php namespace FireflyIII\Providers;
|
<?php namespace FireflyIII\Providers;
|
||||||
|
|
||||||
|
use App;
|
||||||
|
use Auth;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Models\BudgetLimit;
|
use FireflyIII\Models\BudgetLimit;
|
||||||
use FireflyIII\Models\LimitRepetition;
|
use FireflyIII\Models\LimitRepetition;
|
||||||
use FireflyIII\Models\Transaction;
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
use FireflyIII\Models\PiggyBankRepetition;
|
use FireflyIII\Models\PiggyBankRepetition;
|
||||||
|
use FireflyIII\Models\Transaction;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Support\Facades\Navigation;
|
use FireflyIII\Support\Facades\Navigation;
|
||||||
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
|
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
|
||||||
use Illuminate\Database\QueryException;
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class EventServiceProvider
|
* Class EventServiceProvider
|
||||||
*
|
*
|
||||||
@@ -57,6 +59,21 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
TransactionJournal::saved(
|
||||||
|
function (TransactionJournal $journal) {
|
||||||
|
|
||||||
|
/** @var \FireflyIII\Repositories\Bill\BillRepositoryInterface $repository */
|
||||||
|
$repository = App::make('FireflyIII\Repositories\Bill\BillRepositoryInterface');
|
||||||
|
|
||||||
|
$list = $journal->user->bills()->where('active', 1)->where('automatch', 1)->get();
|
||||||
|
/** @var Bill $bill */
|
||||||
|
foreach ($list as $bill) {
|
||||||
|
$repository->scan($bill, $journal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
Account::deleted(
|
Account::deleted(
|
||||||
function (Account $account) {
|
function (Account $account) {
|
||||||
|
|
||||||
@@ -68,14 +85,16 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
PiggyBank::created(function(PiggyBank $piggyBank) {
|
PiggyBank::created(
|
||||||
|
function (PiggyBank $piggyBank) {
|
||||||
$repetition = new PiggyBankRepetition;
|
$repetition = new PiggyBankRepetition;
|
||||||
$repetition->piggyBank()->associate($piggyBank);
|
$repetition->piggyBank()->associate($piggyBank);
|
||||||
$repetition->startdate = $piggyBank->startdate;
|
$repetition->startdate = $piggyBank->startdate;
|
||||||
$repetition->targetdate = $piggyBank->targetdate;
|
$repetition->targetdate = $piggyBank->targetdate;
|
||||||
$repetition->currentamount = 0;
|
$repetition->currentamount = 0;
|
||||||
$repetition->save();
|
$repetition->save();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
BudgetLimit::saved(
|
BudgetLimit::saved(
|
||||||
function (BudgetLimit $budgetLimit) {
|
function (BudgetLimit $budgetLimit) {
|
||||||
|
@@ -36,7 +36,7 @@ class CreateAccountsTable extends Migration
|
|||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
$table->integer('user_id')->unsigned();
|
$table->integer('user_id')->unsigned();
|
||||||
$table->integer('account_type_id')->unsigned();
|
$table->integer('account_type_id')->unsigned();
|
||||||
$table->string('name', 1024);
|
$table->string('name', 100);
|
||||||
$table->boolean('active');
|
$table->boolean('active');
|
||||||
|
|
||||||
// connect accounts to users
|
// connect accounts to users
|
||||||
|
@@ -15,12 +15,6 @@ class ChangesForV332 extends Migration {
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::table(
|
|
||||||
'transaction_journals', function (Blueprint $table) {
|
|
||||||
$table->boolean('encrypted');
|
|
||||||
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
Schema::table(
|
Schema::table(
|
||||||
'accounts', function (Blueprint $table) {
|
'accounts', function (Blueprint $table) {
|
||||||
|
@@ -279,7 +279,6 @@ class TestDataSeeder extends Seeder
|
|||||||
);
|
);
|
||||||
// and some events!
|
// and some events!
|
||||||
PiggyBankEvent::create(['piggy_bank_id' => $newCamera->id, 'date' => $this->som, 'amount' => 100]);
|
PiggyBankEvent::create(['piggy_bank_id' => $newCamera->id, 'date' => $this->som, 'amount' => 100]);
|
||||||
//PiggyBankRepetition::create(['piggy_bank_id' => $newCamera->id, 'startdate' => $this->som, 'targetdate' => null, 'currentamount' => 100]);
|
|
||||||
|
|
||||||
|
|
||||||
$newClothes = PiggyBank::create(
|
$newClothes = PiggyBank::create(
|
||||||
@@ -301,7 +300,6 @@ class TestDataSeeder extends Seeder
|
|||||||
);
|
);
|
||||||
|
|
||||||
PiggyBankEvent::create(['piggy_bank_id' => $newClothes->id, 'date' => $this->som, 'amount' => 100]);
|
PiggyBankEvent::create(['piggy_bank_id' => $newClothes->id, 'date' => $this->som, 'amount' => 100]);
|
||||||
//PiggyBankRepetition::create(['piggy_bank_id' => $newClothes->id, 'startdate' => $this->som, 'targetdate' => $end, 'currentamount' => 100]);
|
|
||||||
|
|
||||||
// weekly reminder piggy bank
|
// weekly reminder piggy bank
|
||||||
$weekly = PiggyBank::create(
|
$weekly = PiggyBank::create(
|
||||||
@@ -321,7 +319,6 @@ class TestDataSeeder extends Seeder
|
|||||||
'order' => 0,
|
'order' => 0,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//PiggyBankRepetition::create(['piggy_bank_id' => $weekly->id, 'startdate' => $this->som, 'targetdate' => $next, 'currentamount' => 0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -374,10 +371,10 @@ class TestDataSeeder extends Seeder
|
|||||||
'order' => 0,
|
'order' => 0,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
PiggyBankRepetition::create(['piggy_bank_id' => $recurring->id, 'startdate' => $this->som, 'targetdate' => $this->eom, 'currentamount' => 0]);
|
// PiggyBankRepetition::create(['piggy_bank_id' => $recurring->id, 'startdate' => $this->som, 'targetdate' => $this->eom, 'currentamount' => 0]);
|
||||||
PiggyBankRepetition::create(
|
// PiggyBankRepetition::create(
|
||||||
['piggy_bank_id' => $recurring->id, 'startdate' => $this->nsom, 'targetdate' => $this->neom, 'currentamount' => 0]
|
// ['piggy_bank_id' => $recurring->id, 'startdate' => $this->nsom, 'targetdate' => $this->neom, 'currentamount' => 0]
|
||||||
);
|
// );
|
||||||
Reminder::create(
|
Reminder::create(
|
||||||
['user_id' => $user->id, 'startdate' => $this->som, 'enddate' => $this->neom, 'active' => 1, 'notnow' => 0,
|
['user_id' => $user->id, 'startdate' => $this->som, 'enddate' => $this->neom, 'active' => 1, 'notnow' => 0,
|
||||||
'remindersable_id' => $recurring->id, 'remindersable_type' => 'PiggyBank']
|
'remindersable_id' => $recurring->id, 'remindersable_type' => 'PiggyBank']
|
||||||
|
Reference in New Issue
Block a user