From 150381a20f4be5eb7c829f69ec06bb4f72e868a6 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Tue, 19 Sep 2023 13:59:38 +0200 Subject: [PATCH 1/5] Enable "Zahlzyklus" in "Abolauf" --- classes/Modules/SubscriptionCycle/SubscriptionModule.php | 4 ++-- www/pages/rechnungslauf.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/Modules/SubscriptionCycle/SubscriptionModule.php b/classes/Modules/SubscriptionCycle/SubscriptionModule.php index ef31098a..d672c6a3 100644 --- a/classes/Modules/SubscriptionCycle/SubscriptionModule.php +++ b/classes/Modules/SubscriptionCycle/SubscriptionModule.php @@ -31,14 +31,14 @@ class SubscriptionModule implements SubscriptionModuleInterface aa.id, @start := GREATEST(aa.startdatum, aa.abgerechnetbis) as start, @end := IF(aa.enddatum = '0000-00-00' OR aa.enddatum > :calcdate, :calcdate, aa.enddatum) as end, - @cycles := CASE + @cycles := GREATEST(aa.zahlzyklus, CASE WHEN aa.preisart = 'monat' THEN TIMESTAMPDIFF(MONTH, @start, @end) WHEN aa.preisart = 'jahr' THEN TIMESTAMPDIFF(YEAR, @start, @end) WHEN aa.preisart = '30tage' THEN FLOOR(TIMESTAMPDIFF(DAY, @start, @end) / 30) - END+1 as cycles, + END+1) as cycles, CASE WHEN aa.preisart = 'monat' THEN DATE_ADD(@start, INTERVAL @cycles MONTH) diff --git a/www/pages/rechnungslauf.php b/www/pages/rechnungslauf.php index dcb0313a..e09e1f89 100644 --- a/www/pages/rechnungslauf.php +++ b/www/pages/rechnungslauf.php @@ -94,7 +94,7 @@ class Rechnungslauf { DATE_ADD(@start, INTERVAL (FLOOR(TIMESTAMPDIFF(DAY, @start, IF(aa.enddatum = '0000-00-00' OR aa.enddatum > '$scalcdate', '$scalcdate', aa.enddatum)) / 30)+1)*30 DAY ) END, '%d.%m.%Y') SEPARATOR '
') as end, SUM((100-aa.rabatt)/100 * aa.preis * aa.menge * - (CASE + (GREATEST(aa.zahlzyklus, CASE WHEN aa.preisart = 'monat' THEN TIMESTAMPDIFF(MONTH, @start, @end) WHEN aa.preisart = 'jahr' THEN @@ -102,7 +102,7 @@ class Rechnungslauf { WHEN aa.preisart = '30tage' THEN FLOOR(TIMESTAMPDIFF(DAY, @start, @end) / 30) END - ) + )) ) as amount, adr.id FROM abrechnungsartikel aa From 4dd8b01ea90a658b47fba32e15f27984145c01d9 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Tue, 31 Jan 2023 12:14:56 +0100 Subject: [PATCH 2/5] Shopware6: remove "v2" part from URL in Client-lib as well, set pseudolager default to 0 instead of empty string --- classes/Modules/Shopware6/Client/Shopware6Client.php | 2 +- www/lib/class.erpapi.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Modules/Shopware6/Client/Shopware6Client.php b/classes/Modules/Shopware6/Client/Shopware6Client.php index 8ea75f4a..a7b3eed3 100644 --- a/classes/Modules/Shopware6/Client/Shopware6Client.php +++ b/classes/Modules/Shopware6/Client/Shopware6Client.php @@ -73,7 +73,7 @@ final class Shopware6Client $request = new ClientRequest( $method, - $this->url . 'v2/' . $endpoint, + $this->url . $endpoint, $headerInformation, empty($body) ? null : json_encode($body) ); diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index a34c54a0..298658a3 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -22527,7 +22527,7 @@ function ChargenMHDAuslagern($artikel, $menge, $lagerplatztyp, $lpid,$typ,$wert, $pseudolager = !empty($shopAricleArr['pseudolager'])?(float)$shopAricleArr['pseudolager']:0; } else { - $pseudolager = ''; + $pseudolager = 0; } $this->app->erp->RunHook('remote_send_article_list_pseudostorage', 3, $shop, $artikelid, $pseudolager); if(is_numeric($pseudolager) && $pseudolager < 0) { From c6dd3fdeff5a5deee6dc317f5c609ec787c92f8d Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Wed, 1 Mar 2023 12:39:42 +0100 Subject: [PATCH 3/5] bugfix: check for divisionByZero --- www/pages/shopimporter_presta.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index cce154a8..1ff7f207 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -284,17 +284,20 @@ class Shopimporter_Presta extends ShopimporterBase $cart['articlelist'] = []; foreach ($order->associations->order_rows->order_row as $order_row) { - - $steuersatz = (strval($order_row->unit_price_tax_incl) / strval($order_row->unit_price_tax_excl)) - 1; - $steuersatz = round($steuersatz, 1); - - $cart['articlelist'][] = [ + $article = [ 'articleid' => strval($order_row->product_reference), 'name' => strval($order_row->product_name), 'quantity' => strval($order_row->product_quantity), 'price_netto' => strval($order_row->unit_price_tax_excl), - 'steuersatz' => $steuersatz ]; + + if ($order_row->unit_price_tax_excl > 0) { + $steuersatz = (strval($order_row->unit_price_tax_incl) / strval($order_row->unit_price_tax_excl)) - 1; + $steuersatz = round($steuersatz, 1); + $article['steuersatz'] = $steuersatz; + } + + $cart['articlelist'][] = $article; } $fetchedOrders[] = [ From 5d1201637facad46d2463b37e0848d47c1a0a4a6 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 30 Jul 2023 22:08:32 +0200 Subject: [PATCH 4/5] Prestashop: Import metakeywords --- www/pages/shopimporter_presta.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index 1ff7f207..793deab0 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -384,13 +384,26 @@ class Shopimporter_Presta extends ShopimporterBase $res['kurztext_de'] = strip_tags($shortdescriptions['de']); $res['kurztext_en'] = strip_tags($shortdescriptions['en']); $res['hersteller'] = strval($product->product->manufacturer_name); - $res['metakeywords_de'] = $metakeywords['de']; - $res['metakeywords_en'] = $metakeywords['en']; $res['metatitle_de'] = $metatitles['de']; $res['metatitle_en'] = $metatitles['en']; $res['metadescription_de'] = $metadescriptions['de']; $res['metadescription_en'] = $metadescriptions['en']; + $tags = $product->product->associations->tags->tag; + $keywords = []; + foreach ($tags as $tag) { + $tagid = intval($tag->id); + $endpoint = "tags/{$tagid}"; + $tagdata = $this->prestaRequest('GET', $endpoint); + $tagiso = $this->langidToIso[intval($tagdata->tag->id_lang)]; + $tagvalue = strval($tagdata->tag->name); + if (!array_key_exists($tagiso, $keywords)) + $keywords[$tagiso] = []; + $keywords[$tagiso][] = $tagvalue; + } + $res['metakeywords_de'] = join(',', $keywords['de'] ?? []); + $res['metakeywords_en'] = join(',', $keywords['en'] ?? []); + $images = []; foreach ($product->product->associations->images->image as $img) { $endpoint = "images/products/$productId/$img->id"; From b759e2accdb1e3debd99577e70e7638c55d9558b Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Tue, 19 Sep 2023 14:37:54 +0200 Subject: [PATCH 5/5] Prestashop: small fix to reduce errors in log --- www/pages/shopimporter_presta.php | 1 + 1 file changed, 1 insertion(+) diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index 793deab0..c669f07c 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -23,6 +23,7 @@ class Shopimporter_Presta extends ShopimporterBase // TODO private $langidToIso = [3 => 'de', 1 => 'en']; private $taxationByDestinationCountry; + private $orderSearchLimit; public function __construct($app, $intern = false)