|
|
@@ -2,6 +2,8 @@
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
+use App\Constraint\NotInConstraint;
|
|
|
+use App\Enums\SalesOrderStatuses;
|
|
|
use App\Traits\DateTimeTrait;
|
|
|
use App\Traits\SoftDeleteTrait;
|
|
|
use RuntimeException;
|
|
|
@@ -112,4 +114,17 @@ class Customer extends Model {
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
+ public function getActiveSalesOrders(): array {
|
|
|
+ $location_ids = array_column($this->getLocations(), "id");
|
|
|
+
|
|
|
+ return Document::query([
|
|
|
+ "location_id" => $location_ids,
|
|
|
+ "invoice_status" => new NotInConstraint(SalesOrderStatuses::VOID, SalesOrderStatuses::UNCOLLECTIBLE),
|
|
|
+ "dts_deleted" => null,
|
|
|
+ ], [
|
|
|
+ "sort" => "date",
|
|
|
+ "order" => "desc",
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
}
|