From c34f720f94ee3118d3b0cfe3fc8984a733645866 Mon Sep 17 00:00:00 2001 From: juminet Date: Tue, 27 Jan 2026 10:26:57 +0000 Subject: [PATCH] Adding the option to deal with duplicate addresses in the BAN importer --- .changes/unreleased/Fixed-20260127-110742.yaml | 7 +++++++ .../Command/LoadAddressesFRFromBANCommand.php | 5 +++-- .../Service/Import/AddressReferenceFromBAN.php | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 .changes/unreleased/Fixed-20260127-110742.yaml diff --git a/.changes/unreleased/Fixed-20260127-110742.yaml b/.changes/unreleased/Fixed-20260127-110742.yaml new file mode 100644 index 000000000..b49f9aaf6 --- /dev/null +++ b/.changes/unreleased/Fixed-20260127-110742.yaml @@ -0,0 +1,7 @@ +kind: Fixed +body: | + Add the option to deal with duplicate address in BAN adress importer +time: 2026-01-27T11:07:42.709140905+01:00 +custom: + Issue: "496" + SchemaChange: No schema change diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANCommand.php index 8483c0be1..a747b4c2c 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANCommand.php @@ -31,7 +31,8 @@ class LoadAddressesFRFromBANCommand extends Command { $this->setName('chill:main:address-ref-from-ban') ->addArgument('departementNo', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'a list of departement numbers') - ->addOption('send-report-email', 's', InputOption::VALUE_REQUIRED, 'Email address where a list of unimported addresses can be send'); + ->addOption('send-report-email', 's', InputOption::VALUE_REQUIRED, 'Email address where a list of unimported addresses can be send') + ->addOption('allow-remove-double-refid', 'd', InputOption::VALUE_NONE, 'Should the address importer be allowed to remove same refid in the source data, if any'); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -40,7 +41,7 @@ class LoadAddressesFRFromBANCommand extends Command foreach ($input->getArgument('departementNo') as $departementNo) { $output->writeln('Import addresses for '.$departementNo); - $this->addressReferenceFromBAN->import($departementNo, $input->hasOption('send-report-email') ? $input->getOption('send-report-email') : null); + $this->addressReferenceFromBAN->import($departementNo, $input->hasOption('send-report-email') ? $input->getOption('send-report-email') : null, allowRemoveDoubleRefId: $input->hasOption('allow-remove-double-refid') ? $input->getOption('allow-remove-double-refid') : false); } return Command::SUCCESS; diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBAN.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBAN.php index 0aa4cd6ce..83def3d5c 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBAN.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBAN.php @@ -23,7 +23,7 @@ class AddressReferenceFromBAN private readonly AddressToReferenceMatcher $addressToReferenceMatcher, ) {} - public function import(string $departementNo, ?string $sendAddressReportToEmail = null): void + public function import(string $departementNo, ?string $sendAddressReportToEmail = null, ?bool $allowRemoveDoubleRefId = false): void { if (!is_numeric($departementNo)) { throw new \UnexpectedValueException('Could not parse this department number'); @@ -96,7 +96,7 @@ class AddressReferenceFromBAN ); } - $this->baseImporter->finalize(sendAddressReportToEmail: $sendAddressReportToEmail); + $this->baseImporter->finalize(allowRemoveDoubleRefId: $allowRemoveDoubleRefId, sendAddressReportToEmail: $sendAddressReportToEmail); $this->addressToReferenceMatcher->checkAddressesMatchingReferences();