@@ -102,6 +102,42 @@ class ProcurementReviewCsv
|
||||
}
|
||||
}
|
||||
$fulfilment = $report['fulfilment'];
|
||||
$limits = $report['agreement_limits'] ?? [];
|
||||
if (! is_array($limits)) {
|
||||
throw new \UnexpectedValueException('A projecção de acordos deve ser uma lista ou mapa de bases preservadas.');
|
||||
}
|
||||
$seen = [];
|
||||
$seenContracts = [];
|
||||
foreach ($limits as $binding) {
|
||||
if (! is_array($binding) || ! isset($binding['agreement_id']) || ! is_int($binding['agreement_id']) || $binding['agreement_id'] < 1) {
|
||||
throw new \UnexpectedValueException('Base contratual sem identidade válida.');
|
||||
}
|
||||
if (isset($seen[$binding['agreement_id']])) {
|
||||
continue;
|
||||
}
|
||||
$seen[$binding['agreement_id']] = true;
|
||||
if (isset($binding['contract']) && is_array($binding['contract'])) {
|
||||
$contract = $binding['contract'];
|
||||
if (! isset($contract['id']) || ! is_int($contract['id']) || $contract['id'] < 1) {
|
||||
throw new \UnexpectedValueException('Contrato global sem identidade válida.');
|
||||
}
|
||||
if (! isset($seenContracts[$contract['id']])) {
|
||||
$seenContracts[$contract['id']] = true;
|
||||
$fields('Contrato global por ordem', (string) $contract['id'], [...$contract, 'max_order_value_minor' => $contract['max_order_value_minor'] ?? 'Não definido'], [
|
||||
'record_key' => 'Identidade do contrato', 'reference' => 'Referência', 'version' => 'Versão preservada', 'currency' => 'Moeda',
|
||||
'max_order_value_minor' => 'Limite global por ordem (centavos)', 'checked_order_value_minor' => 'Total conferido nesta ordem (centavos)',
|
||||
]);
|
||||
}
|
||||
}
|
||||
$fields('Acordo por ordem', (string) $binding['agreement_id'], [...$binding,
|
||||
'basis' => 'Por ordem', 'max_order_value_minor' => $binding['max_order_value_minor'] ?? 'Não definido',
|
||||
'max_order_quantity_milli' => $binding['max_order_quantity_milli'] ?? 'Não definido'], [
|
||||
'record_key' => 'Identidade do acordo', 'version' => 'Versão preservada', 'reference' => 'Referência', 'basis' => 'Aplicação do limite',
|
||||
'currency' => 'Moeda', 'unit' => 'Unidade contratual', 'includes_tax' => 'Inclui impostos',
|
||||
'max_order_value_minor' => 'Limite por ordem (centavos)', 'max_order_quantity_milli' => 'Limite por ordem (milésimos)',
|
||||
'checked_order_value_minor' => 'Total conferido nesta ordem (centavos)', 'checked_order_quantity_milli' => 'Quantidade conferida nesta ordem (milésimos)',
|
||||
]);
|
||||
}
|
||||
$write(['Recepções', '', 'Registos disponíveis', count($fulfilment['receipts'])]);
|
||||
foreach ($fulfilment['receipts'] as $receipt) {
|
||||
$fields('Recepção', (string) $receipt['id'], $receipt, ['received_on' => 'Recebida em', 'delivery_note' => 'Guia']);
|
||||
|
||||
Reference in New Issue
Block a user