From 6e98fca7ad38b6dbf9c42cc73dd4ce1e87d7bf97 Mon Sep 17 00:00:00 2001 From: Marko <52066939+HeX87@users.noreply.github.com> Date: Thu, 23 Nov 2023 16:54:04 +0100 Subject: [PATCH] add fixed export --- .github/workflows/qodana_code_quality.yml | 19 ++++++++ .idea/dataSources.xml | 4 +- docker-compose.yml | 8 ++-- qodana.yaml | 34 ++++++++++++++ src/Command/HiltesExportCommand.php | 7 +-- src/Command/HiltesImportCommand.php | 6 ++- src/Command/JtlExportCommand.php | 12 ----- src/Command/JtlImportCommand.php | 57 ----------------------- src/Helper/Hiltes.php | 40 +++++++++------- src/Helper/HiltesImport.php | 6 +-- src/Helper/Jtl.php | 16 ++++--- src/Helper/Slack.php | 30 ------------ templates/slack/index.html.twig | 20 -------- 13 files changed, 101 insertions(+), 158 deletions(-) create mode 100644 .github/workflows/qodana_code_quality.yml create mode 100644 qodana.yaml delete mode 100644 src/Command/JtlImportCommand.php delete mode 100644 src/Helper/Slack.php delete mode 100644 templates/slack/index.html.twig diff --git a/.github/workflows/qodana_code_quality.yml b/.github/workflows/qodana_code_quality.yml new file mode 100644 index 0000000..5d0c836 --- /dev/null +++ b/.github/workflows/qodana_code_quality.yml @@ -0,0 +1,19 @@ +name: Qodana +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + +jobs: + qodana: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: 'Qodana Scan' + uses: JetBrains/qodana-action@v2023.2 + env: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index 1297f1c..5179711 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -8,13 +8,13 @@ jdbc:mysql://127.0.0.1:3306 $ProjectFileDir$ - + mariadb true true DDEV generated data source org.mariadb.jdbc.Driver - jdbc:mariadb://127.0.0.1:55034/db?user=db&password=db + jdbc:mariadb://127.0.0.1:55000/db?user=db&password=db $ProjectFileDir$ diff --git a/docker-compose.yml b/docker-compose.yml index 73d5780..357b607 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,9 +17,9 @@ services: image: adminer restart: always ports: - - 8080:8080 + - "8080:8080" -###> doctrine/doctrine-bundle ### + ###> doctrine/doctrine-bundle ### database: image: postgres:${POSTGRES_VERSION:-15}-alpine environment: @@ -34,6 +34,6 @@ services: ###< doctrine/doctrine-bundle ### volumes: -###> doctrine/doctrine-bundle ### + ###> doctrine/doctrine-bundle ### database_data: -###< doctrine/doctrine-bundle ### +###< doctrine/doctrine-bundle ### \ No newline at end of file diff --git a/qodana.yaml b/qodana.yaml new file mode 100644 index 0000000..524f146 --- /dev/null +++ b/qodana.yaml @@ -0,0 +1,34 @@ +#-------------------------------------------------------------------------------# +# Qodana analysis is configured by qodana.yaml file # +# https://www.jetbrains.com/help/qodana/qodana-yaml.html # +#-------------------------------------------------------------------------------# +version: "1.0" +#Specify inspection profile for code analysis +profile: + name: qodana.starter +#Enable inspections +#include: +# - name: +#Disable inspections +#exclude: +# - name: +# paths: +# - +php: + version: 8.1 #(Applied in CI/CD pipeline) +#Execute shell command before Qodana execution (Applied in CI/CD pipeline) +#bootstrap: sh ./prepare-qodana.sh +#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline) +#plugins: +# - id: #(plugin id can be found at https://plugins.jetbrains.com) +#Specify Qodana linter for analysis (Applied in CI/CD pipeline) +linter: jetbrains/qodana-php:latest +include: + - name: PhpRedundantOptionalArgumentInspection + - name: PhpUnhandledExceptionInspection + - name: PhpReturnDocTypeMismatchInspection + - name: PhpUnusedLocalVariableInspection +exclude: + - name: All + paths: + - public \ No newline at end of file diff --git a/src/Command/HiltesExportCommand.php b/src/Command/HiltesExportCommand.php index 0275d80..dea2c58 100644 --- a/src/Command/HiltesExportCommand.php +++ b/src/Command/HiltesExportCommand.php @@ -53,12 +53,13 @@ class HiltesExportCommand extends Command if (!$l) { dd('Login faild' . 'STOP ' . __METHOD__ . ' / ' . __LINE__); } - $orders = $this->orderRepository->findAll(); - #dump($orders); /** * @var Order */ - $order = false; + $orders = $this->orderRepository->findAll(); + #dump($orders); + + foreach ($orders as $order) { if ($order->getStatus() > 0) continue; $tA = $order->getData();#json_decode($order->getData()); diff --git a/src/Command/HiltesImportCommand.php b/src/Command/HiltesImportCommand.php index 6471951..a53edda 100644 --- a/src/Command/HiltesImportCommand.php +++ b/src/Command/HiltesImportCommand.php @@ -57,7 +57,7 @@ class HiltesImportCommand extends Command $hiltesImport = new HiltesImport($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger); - $r = $hiltesImport->startImport($input->getOption('delta')); + $hiltesImport->startImport($input->getOption('delta')); if (isset($r['error'])) { $io->error($r['text']); @@ -67,7 +67,9 @@ class HiltesImportCommand extends Command $io->info('Start Hiltes Push JTL'); $jtl = new Jtl($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger); - $jtl->createExportFile($jtl->getProducts()); + + $jtl->createExportFile($jtl->getProducts(0), 'standard'); + $jtl->createExportFile($jtl->getProducts(8), 'wms'); $io->success('Done.'); return Command::SUCCESS; diff --git a/src/Command/JtlExportCommand.php b/src/Command/JtlExportCommand.php index 857067a..33c2d9e 100644 --- a/src/Command/JtlExportCommand.php +++ b/src/Command/JtlExportCommand.php @@ -51,18 +51,6 @@ class JtlExportCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); -// $arg1 = $input->getArgument('arg1'); -// -// if ($arg1) { -// $io->note(sprintf('You passed an argument: %s', $arg1)); -// } -// -// if ($input->getOption('option1')) { -// // ... -// } - - $io = new SymfonyStyle($input, $output); - $io->success('Start JTL Export'); /** diff --git a/src/Command/JtlImportCommand.php b/src/Command/JtlImportCommand.php deleted file mode 100644 index f188e8a..0000000 --- a/src/Command/JtlImportCommand.php +++ /dev/null @@ -1,57 +0,0 @@ -addArgument('arg1', InputArgument::OPTIONAL, 'Argument description') - ->addOption('option1', null, InputOption::VALUE_NONE, 'Option description'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $io = new SymfonyStyle($input, $output); - $arg1 = $input->getArgument('arg1'); - - if ($arg1) { - $io->note(sprintf('You passed an argument: %s', $arg1)); - } - - if ($input->getOption('option1')) { - // ... - } - - $chatter = new Chatter(new Transport('xoxb-1234-56789abcdefghijklmnopqrstuv')); - - - $message = (new ChatMessage('You got a new invoice for 15 EUR.')) - // if not set explicitly, the message is sent to the - // default transport (the first one configured) - ->transport('slack'); - - - $sentMessage = $chatter->send($message); - - $io->success('You have a new command! Now make it your own! Pass --help to see your options.'); - - return Command::SUCCESS; - } -} \ No newline at end of file diff --git a/src/Helper/Hiltes.php b/src/Helper/Hiltes.php index 4c704ad..ad0f83c 100644 --- a/src/Helper/Hiltes.php +++ b/src/Helper/Hiltes.php @@ -31,19 +31,19 @@ class Hiltes $this->hiltesPass = $_ENV['HILTES_API_PASS']; } - public function import() - { - - $finder = new Finder(); - $finder->files()->in($this->current_dir_path . "/hiltes/h2c/"); - - foreach ($finder as $file) { - $contents = $file->getContents(); - - //var_dump($contents); - } - - } +// public function import() +// { +// +// $finder = new Finder(); +// $finder->files()->in($this->current_dir_path . "/hiltes/h2c/"); +// +// foreach ($finder as $file) { +// $contents = $file->getContents(); +// +// //var_dump($contents); +// } +// +// } /** * @param string $data @@ -84,13 +84,14 @@ class Hiltes public function createRequest($orderData) { - $data = array(); $this->loginToHiltes('', ''); - $order = $this->orderRepository->findOneBy(array('orderId' => $orderData->getOrderId())); /** * @var Order */ + $order = $this->orderRepository->findOneBy(array('orderId' => $orderData->getOrderId())); + + if ($order) { //foreach ($orders as $order) { if ($order->getStatus() != 2) return false; @@ -116,9 +117,12 @@ class Hiltes # "AchievedSalesPrice" => 0, #X Erzielter Verkaufspreis $tSalNr = array(); foreach ($tA['positions'] as $v) { - if ($v['type'] == 'versandposition') { - $SalesNumber = '000001'; - $SalesGoodsGroupNumber = 9350; + if ($v['type'] == 'versandposition' || $v['sku'] == '') { +// $SalesNumber = '000001'; +// $SalesGoodsGroupNumber = 9350; + + // Versandkosten werden nicht übermittelt + continue; } else { $SalesNumber = (!empty($v['gtin']) ? $v['gtin'] : $v['sku']); if (preg_match('/^([0-9]+)_/', $SalesNumber, $tP)) { diff --git a/src/Helper/HiltesImport.php b/src/Helper/HiltesImport.php index 8b54e8a..ab191c1 100644 --- a/src/Helper/HiltesImport.php +++ b/src/Helper/HiltesImport.php @@ -40,7 +40,7 @@ class HiltesImport /** - * @return array|void + * @return void */ public function startImport($delta = false) { @@ -182,10 +182,8 @@ class HiltesImport $warehouse->setId((int)$warehouseName); $warehouse->setName($warehouseName); $this->warehouseRepository->save($warehouse, true); - $this->cachedWarehouseIds[$warehouseName] = $warehouse; - } else { - $this->cachedWarehouseIds[$warehouseName] = $warehouse; } + $this->cachedWarehouseIds[$warehouseName] = $warehouse; } if (!empty($this->cachedWarehouseIds[$warehouseName])) { diff --git a/src/Helper/Jtl.php b/src/Helper/Jtl.php index e30717b..b8eb331 100644 --- a/src/Helper/Jtl.php +++ b/src/Helper/Jtl.php @@ -42,15 +42,19 @@ class Jtl * Holt alle Produkte und deren Lagerbestände * @return array */ - public function getProducts(): array + public function getProducts(int $warehouseId): array { $r = $this->productRepository->findAll(); - $data = array(); foreach ($r as $product) { - $stock = $this->stockRepository->findBy(['product_id' => $product->getId()]); + + if ($warehouseId != 0) { + $stock = $this->stockRepository->findBy(['product_id' => $product->getId(), 'warehouse_id' => $warehouseId]); + } else { + $stock = $this->stockRepository->findBy(['product_id' => $product->getId()]); + } if ($stock) { foreach ($stock as $s) { @@ -83,17 +87,17 @@ class Jtl * @param $data * @return void */ - public function createExportFile($data): void + public function createExportFile($data, $warehouse): void { try { - $writer = Writer::createFromPath(getcwd() . '/www/jtl/cds-export.csv', 'w+'); + $writer = Writer::createFromPath(getcwd() . '/www/jtl/' . $warehouse . '.csv', 'w+'); $bytes = $writer->insertAll(new ArrayIterator($data)); if ($bytes) { $this->logger->info('Exported ' . $bytes . ' bytes'); $FTP = new Ftp(); - $FTP->uploadFile(getcwd() . '/www/jtl/cds-export.csv'); + $FTP->uploadFile(getcwd() . '/www/jtl/' . $warehouse . '.csv'); } } catch (Exception $e) { diff --git a/src/Helper/Slack.php b/src/Helper/Slack.php deleted file mode 100644 index 4b5b9e7..0000000 --- a/src/Helper/Slack.php +++ /dev/null @@ -1,30 +0,0 @@ -chatter = $chatter; - } - - public function sendMessage(string $message): void - { - $message = (new ChatMessage($message)) - ->transport('slack'); - - try { - $sentMessage = $this->chatter->send($message); - } catch (TransportExceptionInterface $e) { - - } - } - -} \ No newline at end of file diff --git a/templates/slack/index.html.twig b/templates/slack/index.html.twig deleted file mode 100644 index 8340ad0..0000000 --- a/templates/slack/index.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Hello SlackController!{% endblock %} - -{% block body %} - - -
-

Hello {{ controller_name }}! ✅

- - This friendly message is coming from: - -
-{% endblock %}