@@ -80,15 +80,17 @@ final class PrivateAuditSourceReader
|
||||
if ($table === 'tenants') {
|
||||
return $query->where('id', $actor->tenant_id);
|
||||
}
|
||||
if ($table === 'pa_outbox') {
|
||||
return $query->join('pa_events', 'pa_events.id', '=', 'pa_outbox.event_id')
|
||||
->where('pa_events.tenant_id', $actor->tenant_id)->where('pa_events.company_id', 0)->where('pa_events.unit_id', 0);
|
||||
if (in_array($table, ['pa_outbox', 'ps_outbox'], true)) {
|
||||
$events = $table === 'pa_outbox' ? 'pa_events' : 'ps_events';
|
||||
|
||||
return $query->join($events, $events.'.id', '=', $table.'.event_id')
|
||||
->where($events.'.tenant_id', $actor->tenant_id)->where($events.'.company_id', 0)->where($events.'.unit_id', 0);
|
||||
}
|
||||
if (! in_array('tenant_id', $available, true)) {
|
||||
throw new LogicException('Fonte sem âmbito de empresa explícito.');
|
||||
}
|
||||
$query->where($table.'.tenant_id', $actor->tenant_id);
|
||||
if (str_starts_with($table, 'pa_') || str_starts_with($table, 'gl_')) {
|
||||
if (str_starts_with($table, 'pa_') || str_starts_with($table, 'ps_') || str_starts_with($table, 'gl_')) {
|
||||
// The standalone Compras adapters explicitly use company/unit zero inside the current tenant.
|
||||
if (! in_array('company_id', $available, true) || ! in_array('unit_id', $available, true)) {
|
||||
throw new LogicException('Preserve o âmbito do núcleo financeiro comum.');
|
||||
@@ -108,7 +110,7 @@ final class PrivateAuditSourceReader
|
||||
if ($columns === []) {
|
||||
throw new LogicException('Fonte instalada sem campos conhecidos.');
|
||||
}
|
||||
$key = in_array('id', $columns, true) ? 'id' : ($table === 'pa_outbox' ? 'event_id' : 'tenant_id');
|
||||
$key = in_array('id', $columns, true) ? 'id' : (in_array($table, ['pa_outbox', 'ps_outbox'], true) ? 'event_id' : 'tenant_id');
|
||||
if ($table === 'external_payments') {
|
||||
foreach (ExternalPayment::query()->select($columns)->orderBy('id')->lazy(100) as $payment) {
|
||||
$row = [];
|
||||
|
||||
Reference in New Issue
Block a user