|
|
@@ -2,10 +2,12 @@
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
+use App\Constraint\MoreThanOrEqualsConstraint;
|
|
|
use App\Constraint\NotInConstraint;
|
|
|
use App\Enums\SalesOrderStatuses;
|
|
|
use App\Traits\DateTimeTrait;
|
|
|
use App\Traits\SoftDeleteTrait;
|
|
|
+use Carbon\CarbonImmutable;
|
|
|
use RuntimeException;
|
|
|
|
|
|
/**
|
|
|
@@ -126,11 +128,13 @@ class Customer extends Model {
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
- public function getActiveSalesOrders(): array {
|
|
|
+ public function getRecentSalesOrders(): array {
|
|
|
$location_ids = array_column($this->getLocations(), "id");
|
|
|
+ $dt_threshold = CarbonImmutable::now($_ENV["TIMEZONE"])->subYear();
|
|
|
|
|
|
return Document::query([
|
|
|
"location_id" => $location_ids,
|
|
|
+ "date" => new MoreThanOrEqualsConstraint($dt_threshold->toDateString()),
|
|
|
"invoice_status" => new NotInConstraint(SalesOrderStatuses::VOID, SalesOrderStatuses::UNCOLLECTIBLE),
|
|
|
"dts_deleted" => null,
|
|
|
], [
|