mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Remove duplicate activity records for expenses and tasks
This commit is contained in:
parent
8fb8b63a13
commit
fc683784fc
@ -122,9 +122,9 @@ class StartupCheck
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if the user is claiming a license (ie, additional invoices, white label, etc.)
|
// Check if the user is claiming a license (ie, additional invoices, white label, etc.)
|
||||||
if (isset($_SERVER['REQUEST_URI'])) {
|
if ( ! Utils::isNinjaProd() && isset($_SERVER['REQUEST_URI'])) {
|
||||||
$claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license');
|
$claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license');
|
||||||
if (!$claimingLicense && Input::has('license_key') && Input::has('product_id')) {
|
if ( ! $claimingLicense && Input::has('license_key') && Input::has('product_id')) {
|
||||||
$licenseKey = Input::get('license_key');
|
$licenseKey = Input::get('license_key');
|
||||||
$productId = Input::get('product_id');
|
$productId = Input::get('product_id');
|
||||||
|
|
||||||
|
@ -499,6 +499,10 @@ class ActivityListener
|
|||||||
*/
|
*/
|
||||||
public function updatedTask(TaskWasUpdated $event)
|
public function updatedTask(TaskWasUpdated $event)
|
||||||
{
|
{
|
||||||
|
if ( ! $event->task->isChanged()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->activityRepo->create(
|
$this->activityRepo->create(
|
||||||
$event->task,
|
$event->task,
|
||||||
ACTIVITY_TYPE_UPDATE_TASK
|
ACTIVITY_TYPE_UPDATE_TASK
|
||||||
@ -507,6 +511,10 @@ class ActivityListener
|
|||||||
|
|
||||||
public function archivedTask(TaskWasArchived $event)
|
public function archivedTask(TaskWasArchived $event)
|
||||||
{
|
{
|
||||||
|
if ($event->task->is_deleted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->activityRepo->create(
|
$this->activityRepo->create(
|
||||||
$event->task,
|
$event->task,
|
||||||
ACTIVITY_TYPE_ARCHIVE_TASK
|
ACTIVITY_TYPE_ARCHIVE_TASK
|
||||||
@ -540,6 +548,10 @@ class ActivityListener
|
|||||||
|
|
||||||
public function updatedExpense(ExpenseWasUpdated $event)
|
public function updatedExpense(ExpenseWasUpdated $event)
|
||||||
{
|
{
|
||||||
|
if ( ! $event->expense->isChanged()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->activityRepo->create(
|
$this->activityRepo->create(
|
||||||
$event->expense,
|
$event->expense,
|
||||||
ACTIVITY_TYPE_UPDATE_EXPENSE
|
ACTIVITY_TYPE_UPDATE_EXPENSE
|
||||||
@ -548,6 +560,10 @@ class ActivityListener
|
|||||||
|
|
||||||
public function archivedExpense(ExpenseWasArchived $event)
|
public function archivedExpense(ExpenseWasArchived $event)
|
||||||
{
|
{
|
||||||
|
if ($event->expense->is_deleted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->activityRepo->create(
|
$this->activityRepo->create(
|
||||||
$event->expense,
|
$event->expense,
|
||||||
ACTIVITY_TYPE_ARCHIVE_EXPENSE
|
ACTIVITY_TYPE_ARCHIVE_EXPENSE
|
||||||
|
@ -270,4 +270,15 @@ class EntityModel extends Eloquent
|
|||||||
return array_get($icons, $entityType);
|
return array_get($icons, $entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isDirty return true if the field's new value is the same as the old one
|
||||||
|
public function isChanged()
|
||||||
|
{
|
||||||
|
foreach ($this->fillable as $field) {
|
||||||
|
if ($this->$field != $this->getOriginal($field)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,3 @@ Expense::updated(function ($expense) {
|
|||||||
Expense::deleting(function ($expense) {
|
Expense::deleting(function ($expense) {
|
||||||
$expense->setNullValues();
|
$expense->setNullValues();
|
||||||
});
|
});
|
||||||
|
|
||||||
Expense::deleted(function ($expense) {
|
|
||||||
event(new ExpenseWasDeleted($expense));
|
|
||||||
});
|
|
||||||
|
@ -14,6 +14,16 @@ class Task extends EntityModel
|
|||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
use PresentableTrait;
|
use PresentableTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'client_id',
|
||||||
|
'description',
|
||||||
|
'time_log',
|
||||||
|
'is_running',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@ -179,27 +179,4 @@ class ExpenseRepository extends BaseRepository
|
|||||||
|
|
||||||
return $expense;
|
return $expense;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function bulk($ids, $action)
|
|
||||||
{
|
|
||||||
$expenses = Expense::withTrashed()->scope($ids)->get();
|
|
||||||
|
|
||||||
foreach ($expenses as $expense) {
|
|
||||||
if ($action == 'restore') {
|
|
||||||
$expense->restore();
|
|
||||||
|
|
||||||
$expense->is_deleted = false;
|
|
||||||
$expense->save();
|
|
||||||
} else {
|
|
||||||
if ($action == 'delete') {
|
|
||||||
$expense->is_deleted = true;
|
|
||||||
$expense->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
$expense->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return count($tasks);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user