From 478b407646ee8b093df5eac4bc39be7557296c4b Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Mon, 26 Aug 2024 15:25:45 -0400 Subject: [PATCH] Sub Banco for the Cartola Services --- .../Contabilidad/Cartola/withSubBancos.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 app/src/Service/Contabilidad/Cartola/withSubBancos.php diff --git a/app/src/Service/Contabilidad/Cartola/withSubBancos.php b/app/src/Service/Contabilidad/Cartola/withSubBancos.php new file mode 100644 index 0000000..c49c3f9 --- /dev/null +++ b/app/src/Service/Contabilidad/Cartola/withSubBancos.php @@ -0,0 +1,36 @@ +subBancos []= $sub; + return $this; + } + public function getSubBanco(string $filename): Banco + { + foreach ($this->subBancos as $subBanco) { + if ($subBanco->is($filename)) { + return $subBanco; + } + } + return $this; + } + public function process(UploadedFileInterface $file): array + { + $filename = $this->processUploadedFile($file); + try { + $subBanco = $this->getSubBanco($filename); + $data = $subBanco->processFile($filename); + return $subBanco->mapColumns($data); + } catch (InvalidArgumentException) { + $data = parent::processFile($filename); + return $this->mapColumns($data); + } + } +}