Skip to content

Commit

Permalink
34. fixes & add context
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrakovich committed Jun 1, 2024
1 parent c2c3684 commit ad64d88
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/app/Jobs/OneC/UpdateOfflineOrdersJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
use App\Models\Orders\OfflineOrder;
use App\Models\User\User;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Context;
use Sentry\Severity;

use function Sentry\captureMessage;

class UpdateOfflineOrdersJob extends AbstractJob
{
Expand All @@ -33,6 +37,8 @@ public function handle(): void
$returnOrders = $this->getOrdersForReturn($orders);

foreach ($orders as $order) {
Context::add('1C order', $order->attributesToArray());

$orderItemKey = $this->generateKeyForCompare($order);
if (isset($returnOrders[$orderItemKey])) {
$returnOrder = $returnOrders[$orderItemKey];
Expand All @@ -43,15 +49,13 @@ public function handle(): void
}

if ($order->isReturn()) {
\Sentry\captureMessage(
"Return 1C order without sold order in DB, key: {$orderItemKey}",
\Sentry\Severity::warning()
);
captureMessage('Return 1C order without sold order in DB', Severity::warning());

continue;
}

$offlineOrder = new OfflineOrder([
'one_c_id' => $order->CODE,
'receipt_number' => $order->SP6098,
'stock_id' => $order->stock->id,
'product_id' => $order->product?->id,
Expand All @@ -74,7 +78,7 @@ public function handle(): void
*/
private function getLatestCode(): int
{
return OfflineOrder::query()->latest('id')->value('one_c_id');
return (int)OfflineOrder::query()->latest('id')->value('one_c_id');
}

/**
Expand Down

0 comments on commit ad64d88

Please sign in to comment.