mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-15 01:03:16 +01:00
Enforce billable rate restriction in controllers and importers instead of model hooks
This commit is contained in:
committed by
Gregor Vostrak
parent
3197c8c7a0
commit
1c41432389
@@ -8,7 +8,6 @@ use App\Enums\TimeEntryType;
|
||||
use App\Models\Concerns\CustomAuditable;
|
||||
use App\Models\Concerns\HasUuids;
|
||||
use App\Service\BillableRateService;
|
||||
use App\Service\BillingContract;
|
||||
use Carbon\CarbonInterval;
|
||||
use Database\Factories\TimeEntryFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -141,12 +140,6 @@ class TimeEntry extends Model implements AuditableContract
|
||||
$timeEntry->client_id = null;
|
||||
$timeEntry->tags = [];
|
||||
}
|
||||
// Organizations that can not use billable rates can keep or remove the billable flag, but not set it
|
||||
if ($timeEntry->billable && ! $timeEntry->getOriginal('billable') && ! app(BillingContract::class)->canUseBillableRates($timeEntry->loadMissing('organization')->organization)) {
|
||||
$timeEntry->billable = false;
|
||||
// Note: The billable rate is computed before saving, non-billable time entries have no billable rate
|
||||
$timeEntry->billable_rate = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user