From 0e3afa437be922a1fc9f3a7c02f3fb0fff536ff1 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 29 Jan 2023 12:06:32 +0100 Subject: [PATCH] Bugfix shopimport, bugfixes presta, support for project specific number ranges --- www/lib/class.erpapi.php | 14 +++++++++++++- www/pages/shopimport.php | 8 ++++---- www/pages/shopimporter_presta.php | 14 +++++--------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index 8f04e543..c12a4d90 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -29440,10 +29440,22 @@ function Firmendaten($field,$projekt="") $process_lock = $this->app->erp->ProzessLock("erpapi_getnextnummer"); $eigenernummernkreis = 0; + $newbelegnr = ''; if($eigenernummernkreis=='1') { + $allowedtypes = ['angebot', 'auftrag', 'rechnung', 'lieferschein', 'arbeitsnachweis', 'reisekosten', + 'bestellung', 'gutschrift', 'kundennummer', 'lieferantennummer', 'mitarbeiternummer', 'waren', + 'produktion', 'sonstiges', 'anfrage', 'artikelnummer', 'kalkulation', 'preisanfrage', 'proformarechnung', + 'retoure', 'verbindlichkeit', 'goodspostingdocument', 'receiptdocument']; - } else { + $dbfield = "next_$type"; + $dbvalue = $this->app->DB->Select("SELECT $dbfield FROM projekt WHERE id='$projekt' LIMIT 1"); + if (!empty($dbvalue)) { + $newbelegnr = $this->CalcNextNummer($dbvalue); + $this->app->DB->Update("UPDATE projekt SET $dbfield='$newbelegnr' WHERE id='$projekt' LIMIT 1"); + } + } + if (empty($newbelegnr)) { // naechste switch($type) { diff --git a/www/pages/shopimport.php b/www/pages/shopimport.php index 397b7a89..291e3d90 100644 --- a/www/pages/shopimport.php +++ b/www/pages/shopimport.php @@ -1,4 +1,4 @@ - +*/ +?> app->erp->KundeAnlegen($typ,$name,$abteilung, // $unterabteilung,$ansprechpartner,$adresszusatz,$strasse,$land,$plz,$ort,$email,$telefon,$telefax,$ustid,$partner,$projekt); - if(strlen($warenkorb['kundennummer'])!=''){ + if(!empty($warenkorb['kundennummer'])){ $adresse = $this->app->DB->Select("SELECT id FROM adresse WHERE kundennummer='{$warenkorb['kundennummer']}' $adresseprojekt AND geloescht!=1 LIMIT 1"); } diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index 69149240..0a329611 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -253,15 +253,11 @@ class Shopimporter_Presta extends ShopimporterBase if (!empty($cart['lieferadresse_land']) && $this->taxationByDestinationCountry) { $taxedCountry = $cart['lieferadresse_land']; } - if (strval($order->total_paid_tax_incl) === strval($order->total_paid_tax_excl)) { - if ($this->app->erp->IstEU($taxedCountry)) { - $cart['ust_befreit'] = 1; - } elseif ($this->app->erp->Export($taxedCountry)) { - $cart['ust_befreit'] = 2; - } else { - $cart['ust_befreit'] = 3; - } - } + $lieferschwelle = $this->app->DB->Select("SELECT * FROM lieferschwelle WHERE empfaengerland='$taxedCountry' LIMIT 1"); + if ($this->app->erp->IstEU($taxedCountry) || !empty($lieferschwelle['ueberschreitungsdatum'])) { + $cart['ust_befreit'] = 1; + } elseif ($this->app->erp->Export($taxedCountry)) { + $cart['ust_befreit'] = 2; $taxes = []; $this->app->erp->RunHook('getTaxRatesFromShopOrder', 2, $taxedCountry, $taxes);