diff --git a/app/Http/Controllers/AppController.php b/app/Http/Controllers/AppController.php
index ae5a7a1256a7..8c3b9b5fe59f 100644
--- a/app/Http/Controllers/AppController.php
+++ b/app/Http/Controllers/AppController.php
@@ -189,6 +189,7 @@ class AppController extends BaseController
Artisan::call('db:seed', array('--force' => true, '--class' => 'PaymentLibrariesSeeder'));
Artisan::call('optimize', array('--force' => true));
Cache::flush();
+ Session::flush();
Event::fire(new UserSettingsChanged());
Session::flash('message', trans('texts.processed_updates'));
} catch (Exception $e) {
diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php
index 557ddf95588f..4f6aefdd46ff 100644
--- a/app/Http/Controllers/InvoiceController.php
+++ b/app/Http/Controllers/InvoiceController.php
@@ -101,9 +101,6 @@ class InvoiceController extends BaseController
->addColumn('end_date', function ($model) { return Utils::fromSqlDate($model->end_date); })
->addColumn('amount', function ($model) { return Utils::formatMoney($model->amount, $model->currency_id); })
->addColumn('dropdown', function ($model) {
- if ($model->is_deleted) {
- return '
';
- }
$str = '
';
})
diff --git a/app/Http/routes.php b/app/Http/routes.php
index 40bf82fab066..0f2c08243159 100644
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -158,6 +158,7 @@ Route::group(['middleware' => 'auth'], function() {
Route::get('recurring_invoices', 'RecurringInvoiceController@index');
Route::get('invoices/{public_id}/clone', 'InvoiceController@cloneInvoice');
Route::post('invoices/bulk', 'InvoiceController@bulk');
+ Route::post('recurring_invoices/bulk', 'InvoiceController@bulk');
Route::get('quotes/create/{client_id?}', 'QuoteController@create');
Route::get('quotes/{public_id}/clone', 'InvoiceController@cloneInvoice');
diff --git a/app/Listeners/ActivityListener.php b/app/Listeners/ActivityListener.php
index 4eaef5b05355..6b7391b61868 100644
--- a/app/Listeners/ActivityListener.php
+++ b/app/Listeners/ActivityListener.php
@@ -295,11 +295,13 @@ class ActivityListener
public function deletedPayment(PaymentWasDeleted $event)
{
+ $payment = $event->payment;
+
$this->activityRepo->create(
- $event->payment,
+ $payment,
ACTIVITY_TYPE_DELETE_PAYMENT,
- $event->payment->amount,
- $event->payment->amount * -1
+ $payment->amount,
+ $payment->amount * -1
);
}
@@ -317,9 +319,13 @@ class ActivityListener
public function restoredPayment(PaymentWasRestored $event)
{
+ $payment = $event->payment;
+
$this->activityRepo->create(
- $event->payment,
- ACTIVITY_TYPE_RESTORE_PAYMENT
+ $payment,
+ ACTIVITY_TYPE_RESTORE_PAYMENT,
+ $event->fromDeleted ? $payment->amount * -1 : 0,
+ $event->fromDeleted ? $payment->amount : 0
);
}
}
diff --git a/app/Listeners/InvoiceListener.php b/app/Listeners/InvoiceListener.php
index 49fee6578d95..0a5a19c5bd0a 100644
--- a/app/Listeners/InvoiceListener.php
+++ b/app/Listeners/InvoiceListener.php
@@ -4,6 +4,7 @@ use App\Events\InvoiceWasEmailed;
use App\Events\InvoiceWasUpdated;
use App\Events\PaymentWasCreated;
use App\Events\PaymentWasDeleted;
+use App\Events\PaymentWasRestored;
use App\Events\InvoiceInvitationWasViewed;
class InvoiceListener
@@ -40,4 +41,18 @@ class InvoiceListener
$invoice->updateBalances($adjustment);
$invoice->updatePaidStatus();
}
+
+ public function restoredPayment(PaymentWasRestored $event)
+ {
+ if ( ! $event->fromDeleted) {
+ return;
+ }
+
+ $payment = $event->payment;
+ $invoice = $payment->invoice;
+ $adjustment = $payment->amount * -1;
+
+ $invoice->updateBalances($adjustment);
+ $invoice->updatePaidStatus();
+ }
}
diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php
index 2af8deb34785..14c5f08602b4 100644
--- a/app/Models/Invoice.php
+++ b/app/Models/Invoice.php
@@ -197,6 +197,10 @@ class Invoice extends EntityModel implements BalanceAffecting
public function updateBalances($balanceAdjustment, $partial = 0)
{
+ if ($this->is_deleted) {
+ return;
+ }
+
$this->balance = $this->balance + $balanceAdjustment;
if ($this->partial > 0) {
diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php
index 73439a8c54b7..b5daa89cdf8b 100644
--- a/app/Ninja/Repositories/InvoiceRepository.php
+++ b/app/Ninja/Repositories/InvoiceRepository.php
@@ -151,10 +151,6 @@ class InvoiceRepository extends BaseRepository
->addColumn('invoice_status_name', function ($model) { return $model->quote_invoice_id ? link_to("invoices/{$model->quote_invoice_id}/edit", trans('texts.converted')) : self::getStatusLabel($model->invoice_status_id, $model->invoice_status_name); })
->addColumn('dropdown', function ($model) use ($entityType) {
- if ($model->is_deleted) {
- return '';
- }
-
$str = '