diff --git a/modules/EcommerceFinance/Repositories/InstallationDetailMirrorRepository.php b/modules/EcommerceFinance/Repositories/InstallationDetailMirrorRepository.php index 1e5c470b..f7fdcf54 100644 --- a/modules/EcommerceFinance/Repositories/InstallationDetailMirrorRepository.php +++ b/modules/EcommerceFinance/Repositories/InstallationDetailMirrorRepository.php @@ -60,13 +60,16 @@ class InstallationDetailMirrorRepository return ['data' => [], 'ready' => true]; } + $transactionNo = $connection->table($dataset->targetTable()) + ->where('SourceGuid', $guid) + ->value('OrderNum'); $rows = $connection->table($items->targetTable()) ->where('guid', $guid) ->orderBy('Id') ->limit(100) ->get(); - return ['data' => $rows->map(fn (object $row): array => $this->mapItem((array) $row))->all(), 'ready' => true]; + return ['data' => $rows->map(fn (object $row): array => $this->mapItem((array) $row, $transactionNo))->all(), 'ready' => true]; } private function ready($dataset, $items, string $connection): bool @@ -140,7 +143,7 @@ class InstallationDetailMirrorRepository } /** @param array $row */ - private function mapItem(array $row): array + private function mapItem(array $row, mixed $transactionNo = null): array { $value = static function (array $row, string ...$names): mixed { foreach ($names as $name) { @@ -154,7 +157,7 @@ class InstallationDetailMirrorRepository }; return [ - 'transaction_no' => $value($row, 'Sourceno', 'source_no', 'orderNum', 'ordernum'), + 'transaction_no' => $value($row, 'Sourceno', 'source_no', 'orderNum', 'ordernum') ?? $transactionNo, 'product_id' => $value($row, 'shopproid'), 'id_owner' => $value($row, 'id_owner', 'idOwner'), 'department_owner' => $value($row, 'department_owner', 'departmentOwner'),