Skip to content

Commit

Permalink
debug fetch stock movements
Browse files Browse the repository at this point in the history
  • Loading branch information
inikoo committed Sep 24, 2024
1 parent 4136902 commit c9818cc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
1 change: 1 addition & 0 deletions app/Actions/Transfers/Aurora/FetchAuroraAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected function preProcessCommand(Command $command): void
'fetch:outers',
'fetch:portfolios',
'fetch:stock_movements',
'fetch:deleted-locations',
])) {
$this->onlyNew = (bool)$command->option('only_new');
}
Expand Down
32 changes: 23 additions & 9 deletions app/Actions/Transfers/Aurora/FetchAuroraDeletedLocations.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public function handle(SourceOrganisationService $organisationSource, int $organ
);

$this->recordNew($organisationSource);
$sourceData = explode(':', $location->source_id);
DB::connection('aurora')->table('Location Deleted Dimension')
->where('Location Deleted Key', $sourceData[1])
->update(['aiku_id' => $location->id]);

}

$sourceData = explode(':', $location->source_id);
DB::connection('aurora')->table('Location Deleted Dimension')
->where('Location Deleted Key', $sourceData[1])
->update(['aiku_id' => $location->id]);

return $location;
}

Expand All @@ -55,18 +55,32 @@ public function handle(SourceOrganisationService $organisationSource, int $organ

public function getModelsQuery(): Builder
{
return DB::connection('aurora')
$query = DB::connection('aurora')
->table('Location Deleted Dimension')
->select('Location Deleted Key as source_id')
->orderBy('source_id')
->select('Location Deleted Key as source_id');

if ($this->onlyNew) {
$query->whereNull('aiku_id');
}

$query->orderBy('source_id')
->when(app()->environment('testing'), function ($query) {
return $query->limit(20);
});

return $query;
}


public function count(): ?int
{
return DB::connection('aurora')->table('Location Deleted Dimension')->count();
$query = DB::connection('aurora')
->table('Location Deleted Dimension');
if ($this->onlyNew) {
$query->whereNull('aiku_id');
}

return $query->count();

}
}
4 changes: 4 additions & 0 deletions app/Transfers/Aurora/FetchAuroraOrgStockMovement.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ protected function parseModel(): void

$location = $this->parseLocation($this->organisation->id.':'.$this->auroraModelData->{'Location Key'}, $this->organisationSource);

if (!$location) {
dd($this->auroraModelData->{'Location Key'});
}

$date = $this->parseDatetime($this->auroraModelData->{'Date'});

$type = null;
Expand Down

0 comments on commit c9818cc

Please sign in to comment.