|
@@ -362,6 +362,7 @@ class EstimateResource extends Resource
|
362
|
362
|
'expiration_date',
|
363
|
363
|
'approved_at',
|
364
|
364
|
'accepted_at',
|
|
365
|
+ 'converted_at',
|
365
|
366
|
'declined_at',
|
366
|
367
|
'last_sent_at',
|
367
|
368
|
'last_viewed_at',
|
|
@@ -393,9 +394,9 @@ class EstimateResource extends Resource
|
393
|
394
|
->successNotificationTitle('Estimates Approved')
|
394
|
395
|
->failureNotificationTitle('Failed to Approve Estimates')
|
395
|
396
|
->before(function (Collection $records, Tables\Actions\BulkAction $action) {
|
396
|
|
- $containsNonDrafts = $records->contains(fn (Estimate $record) => ! $record->isDraft());
|
|
397
|
+ $isInvalid = $records->contains(fn (Estimate $record) => ! $record->canBeApproved());
|
397
|
398
|
|
398
|
|
- if ($containsNonDrafts) {
|
|
399
|
+ if ($isInvalid) {
|
399
|
400
|
Notification::make()
|
400
|
401
|
->title('Approval Failed')
|
401
|
402
|
->body('Only draft estimates can be approved. Please adjust your selection and try again.')
|
|
@@ -420,9 +421,9 @@ class EstimateResource extends Resource
|
420
|
421
|
->successNotificationTitle('Estimates Sent')
|
421
|
422
|
->failureNotificationTitle('Failed to Mark Estimates as Sent')
|
422
|
423
|
->before(function (Collection $records, Tables\Actions\BulkAction $action) {
|
423
|
|
- $doesntContainUnsent = $records->contains(fn (Estimate $record) => $record->status !== EstimateStatus::Unsent);
|
|
424
|
+ $isInvalid = $records->contains(fn (Estimate $record) => ! $record->canBeMarkedAsSent());
|
424
|
425
|
|
425
|
|
- if ($doesntContainUnsent) {
|
|
426
|
+ if ($isInvalid) {
|
426
|
427
|
Notification::make()
|
427
|
428
|
->title('Sending Failed')
|
428
|
429
|
->body('Only unsent estimates can be marked as sent. Please adjust your selection and try again.')
|
|
@@ -435,9 +436,7 @@ class EstimateResource extends Resource
|
435
|
436
|
})
|
436
|
437
|
->action(function (Collection $records, Tables\Actions\BulkAction $action) {
|
437
|
438
|
$records->each(function (Estimate $record) {
|
438
|
|
- $record->updateQuietly([
|
439
|
|
- 'status' => EstimateStatus::Sent,
|
440
|
|
- ]);
|
|
439
|
+ $record->markAsSent();
|
441
|
440
|
});
|
442
|
441
|
|
443
|
442
|
$action->success();
|
|
@@ -449,9 +448,9 @@ class EstimateResource extends Resource
|
449
|
448
|
->successNotificationTitle('Estimates Accepted')
|
450
|
449
|
->failureNotificationTitle('Failed to Mark Estimates as Accepted')
|
451
|
450
|
->before(function (Collection $records, Tables\Actions\BulkAction $action) {
|
452
|
|
- $doesntContainSent = $records->contains(fn (Estimate $record) => $record->status !== EstimateStatus::Sent || $record->wasAccepted());
|
|
451
|
+ $isInvalid = $records->contains(fn (Estimate $record) => ! $record->canBeMarkedAsAccepted());
|
453
|
452
|
|
454
|
|
- if ($doesntContainSent) {
|
|
453
|
+ if ($isInvalid) {
|
455
|
454
|
Notification::make()
|
456
|
455
|
->title('Acceptance Failed')
|
457
|
456
|
->body('Only sent estimates that haven\'t been accepted can be marked as accepted. Please adjust your selection and try again.')
|
|
@@ -480,9 +479,9 @@ class EstimateResource extends Resource
|
480
|
479
|
->successNotificationTitle('Estimates Declined')
|
481
|
480
|
->failureNotificationTitle('Failed to Mark Estimates as Declined')
|
482
|
481
|
->before(function (Collection $records, Tables\Actions\BulkAction $action) {
|
483
|
|
- $doesntContainSent = $records->contains(fn (Estimate $record) => $record->status !== EstimateStatus::Sent || $record->wasDeclined());
|
|
482
|
+ $isInvalid = $records->contains(fn (Estimate $record) => ! $record->canBeMarkedAsDeclined());
|
484
|
483
|
|
485
|
|
- if ($doesntContainSent) {
|
|
484
|
+ if ($isInvalid) {
|
486
|
485
|
Notification::make()
|
487
|
486
|
->title('Declination Failed')
|
488
|
487
|
->body('Only sent estimates that haven\'t been declined can be marked as declined. Please adjust your selection and try again.')
|