|
@@ -132,7 +132,7 @@ class Estimate extends Document
|
132
|
132
|
|
133
|
133
|
public function shouldBeExpired(): bool
|
134
|
134
|
{
|
135
|
|
- return $this->expiration_date?->isBefore(today()) && $this->canBeExpired();
|
|
135
|
+ return $this->expiration_date?->isBefore(company_today()) && $this->canBeExpired();
|
136
|
136
|
}
|
137
|
137
|
|
138
|
138
|
public function isDraft(): bool
|
|
@@ -257,7 +257,7 @@ class Estimate extends Document
|
257
|
257
|
throw new \RuntimeException('Estimate is not in draft status.');
|
258
|
258
|
}
|
259
|
259
|
|
260
|
|
- $approvedAt ??= now();
|
|
260
|
+ $approvedAt ??= company_now();
|
261
|
261
|
|
262
|
262
|
$this->update([
|
263
|
263
|
'approved_at' => $approvedAt,
|
|
@@ -316,7 +316,7 @@ class Estimate extends Document
|
316
|
316
|
|
317
|
317
|
public function markAsSent(?Carbon $sentAt = null): void
|
318
|
318
|
{
|
319
|
|
- $sentAt ??= now();
|
|
319
|
+ $sentAt ??= company_now();
|
320
|
320
|
|
321
|
321
|
$this->update([
|
322
|
322
|
'status' => EstimateStatus::Sent,
|
|
@@ -326,7 +326,7 @@ class Estimate extends Document
|
326
|
326
|
|
327
|
327
|
public function markAsViewed(?Carbon $viewedAt = null): void
|
328
|
328
|
{
|
329
|
|
- $viewedAt ??= now();
|
|
329
|
+ $viewedAt ??= company_now();
|
330
|
330
|
|
331
|
331
|
$this->update([
|
332
|
332
|
'status' => EstimateStatus::Viewed,
|
|
@@ -357,8 +357,8 @@ class Estimate extends Document
|
357
|
357
|
->beforeReplicaSaved(function (self $original, self $replica) {
|
358
|
358
|
$replica->status = EstimateStatus::Draft;
|
359
|
359
|
$replica->estimate_number = self::getNextDocumentNumber();
|
360
|
|
- $replica->date = now();
|
361
|
|
- $replica->expiration_date = now()->addDays($original->company->defaultInvoice->payment_terms->getDays());
|
|
360
|
+ $replica->date = company_today();
|
|
361
|
+ $replica->expiration_date = company_today()->addDays($original->company->defaultInvoice->payment_terms->getDays());
|
362
|
362
|
})
|
363
|
363
|
->databaseTransaction()
|
364
|
364
|
->after(function (self $original, self $replica) {
|
|
@@ -388,7 +388,7 @@ class Estimate extends Document
|
388
|
388
|
|
389
|
389
|
public function markAsAccepted(?Carbon $acceptedAt = null): void
|
390
|
390
|
{
|
391
|
|
- $acceptedAt ??= now();
|
|
391
|
+ $acceptedAt ??= company_now();
|
392
|
392
|
|
393
|
393
|
$this->update([
|
394
|
394
|
'status' => EstimateStatus::Accepted,
|
|
@@ -417,7 +417,7 @@ class Estimate extends Document
|
417
|
417
|
|
418
|
418
|
public function markAsDeclined(?Carbon $declinedAt = null): void
|
419
|
419
|
{
|
420
|
|
- $declinedAt ??= now();
|
|
420
|
+ $declinedAt ??= company_now();
|
421
|
421
|
|
422
|
422
|
$this->update([
|
423
|
423
|
'status' => EstimateStatus::Declined,
|
|
@@ -458,8 +458,8 @@ class Estimate extends Document
|
458
|
458
|
'header' => $this->company->defaultInvoice->header,
|
459
|
459
|
'subheader' => $this->company->defaultInvoice->subheader,
|
460
|
460
|
'invoice_number' => Invoice::getNextDocumentNumber($this->company),
|
461
|
|
- 'date' => now(),
|
462
|
|
- 'due_date' => now()->addDays($this->company->defaultInvoice->payment_terms->getDays()),
|
|
461
|
+ 'date' => company_today(),
|
|
462
|
+ 'due_date' => company_today()->addDays($this->company->defaultInvoice->payment_terms->getDays()),
|
463
|
463
|
'status' => InvoiceStatus::Draft,
|
464
|
464
|
'currency_code' => $this->currency_code,
|
465
|
465
|
'discount_method' => $this->discount_method,
|
|
@@ -477,7 +477,7 @@ class Estimate extends Document
|
477
|
477
|
|
478
|
478
|
$this->replicateLineItems($invoice);
|
479
|
479
|
|
480
|
|
- $convertedAt ??= now();
|
|
480
|
+ $convertedAt ??= company_now();
|
481
|
481
|
|
482
|
482
|
$this->update([
|
483
|
483
|
'status' => EstimateStatus::Converted,
|