8
0
Fork 0

Compare commits

...
This repository has been archived on 2021-01-04. You can view files and clone it, but cannot push or open issues or pull requests.

11 Commits

Author SHA1 Message Date
Daniel Seifert cd273486ad
Merge branch 'rel_1.x' into rel_1.x_articlePrices 2021-01-04 11:34:20 +01:00
Daniel Seifert b3c85652da
add abandoned support note 2021-01-04 11:31:04 +01:00
Daniel Seifert f990a05031
can't use named parameters for prepared statements, prevent parameterlist with surplus entries for prepared statements 2020-06-25 15:45:12 +02:00
Daniel Seifert db2d8cb09a
make article price adjustment scripts compatible to OXID 4.10 / 5.3 2020-06-25 12:02:21 +02:00
Daniel Seifert f4d7c8ef5f
add article price adjustment scripts
# Conflicts:
#	composer.json
#	copy_this/_taxRates/Models/articlePricesAbstract.php
#	copy_this/_taxRates/Models/genericAbstract.php
#	copy_this/_taxRates/Models/raiseArticlePrices.php
#	copy_this/_taxRates/Models/raiseTrait.php
#	copy_this/_taxRates/Models/reduceArticlePrices.php
#	copy_this/_taxRates/Models/reduceTrait.php
#	copy_this/_taxRates/Models/taxRateAbstract.php
#	copy_this/_taxRates/bin/raiseArticlePrices
#	copy_this/_taxRates/bin/reduceArticlePrices
2020-06-25 11:41:21 +02:00
Daniel Seifert e6a542c13e
change different PHP versions note
Merge branch 'master' into rel_1.x

# Conflicts:
#	README.md
2020-06-18 13:43:39 +02:00
Daniel Seifert cecc4fd47a
Merge branch 'rel_2.x' into rel_1.x
# Conflicts:
#	README.md
2020-06-16 15:02:27 +02:00
Daniel Seifert 222927a218
add documention notes for special VAT handlings 2020-06-15 08:38:32 +02:00
Daniel Seifert 521128a511
changelog completed 2020-06-11 15:17:21 +02:00
Daniel Seifert 27a95f0d14
remove convert shop id to int because of "oxbaseshop" value, add note for different PHP version 2020-06-11 15:09:34 +02:00
Daniel Seifert 44f093b950
add release for OXID 4.10 / 5.3 2020-06-08 22:16:22 +02:00
17 changed files with 427 additions and 135 deletions

View File

@ -1,14 +1,19 @@
# TaxRatesAdjustment / Anpassung der MwSt.-Sätze
## eingestellte Modulpflege
Dieses Modul wurde für die Steueranpassung in Deutschland im Jahr 2020 erstellt. Da diese Ereignisse vergangen sind, wird dieses Modul nicht mehr weiterentwickelt und auch nicht mehr unterstützt.
## Funktionsumfang
### Was kann das Modul?
Dieses Modul stellt 2 Aufrufe bereit, die in Standardkonstellationen die MwSt.-Sätze anpasst, die in Deutschland zum 01.07.20 und zum 01.01.2021 geändert werden (Bestandteil des beschlossenen Corona-Konjunkturpaketes).
Weiterhin können über 2 weitere Aufrufe die Artikelpreise passend reduziert bzw. erhöht werden.
Die Anpassung kann über entsprechende Cronjobs zeitgesteuert zum Stichtermin ausgeführt werden, ohne dass hierfür Ihre Anwesenheit erforderlich ist.
Die Scripte ändern:
Die Steuerscripte ändern:
- den im Shop eingestellten allgemeinen Steuersatz
- an den Artikeln hinterlegte spezielle Steuersätze
@ -16,6 +21,19 @@ Die Scripte ändern:
- von 7% zu 5%
- sowie später auch zurück
Die Steuerscripte ändern:
- den Standardpreis der Artikel
- den UVP-Preis der Artikel
- den Varminpreis an Elternartikeln (der Variantenpreis selbst wird schon mit dem Standardpreis geändert)
- den Varmaxpreis an Elternartikeln (der Variantenpreis selbst wird schon mit dem Standardpreis geändert)
- von 19% zu 16% und
- von 7% zu 5%
- sowie später auch zurück
Berücksichtigt werden artikelabhängige Steuersätze sowie auch der generelle Steuersatz des Shops. Bei den Varianten-MinPreisen und Max-Preisen wird der Steuersatz des Elternartikels zugrunde gelegt.
Weicht der Steuersatz der Varianten vom Elternartikel ab, muss dies manuell nachgearbeitet werden.
Bei Multishopinstallationen (Enterprise Edition) können die zu aktualisierenden Subshops definiert werden.
Die Scripte prüfen anhand der Systemzeit mit kleinen Toleranzen (+/-3 Tage um das jeweilige Umstellungsdatum), ob die Veränderung ausgeführt werden darf. Damit wird verhindert, dass ein versehentliches Auslösen zur falschen Shopkonfiguration führt.
@ -28,41 +46,61 @@ Weiterhin werden auch die absoluten Artikelpreise und Berechnungswege nicht ange
- Werden Artikelpreise brutto gepflegt und angezeigt, werden danach weiterhin die bisherigen Preise verwendet, jedoch mit geändertem Steuersatz.
- Werden Artikelpreise netto gepflegt und brutto angezeigt, ändern sich die daraus errechneten Bruttopreise.
Passen Sie die Artikelpreise danach ggf. an. Beachten Sie hierbei speziell die Artikel, die einer Preisbindung unterliegen.
Für die Preisanpassungen stehen Ihnen die entsprechenden Scripte im Modul zur Verfügung.
Beachten Sie bei der Preisanpassung speziell die Artikel, die einer Preisbindung unterliegen.
Artikel, die von der Steuersenkung ausgenommen sind (z.B. Tabakwaren) können hierbei nicht berücksichtigt werden und erfordern eine manuelle Nachbearbeitung.
Die Preise werden immer auf dem im Shop vorliegenden Preis angewandt. Hierbei kann es durchaus zu Rundungsungenauigkeiten kommen.
Gibt es in Ihrem Shop reguläre Steuersätze mit 16% oder 5%, werden diese beim Zurücksetzen ebenfalls auf 19% bzw. 7% angehoben. Eine Unterscheidung, welcher Steuersatz vorab reduziert wurde, gibt es nicht. Diese Anpassung muss dann manuell durchgeführt werden.
## Systemanforderung
- installierter OXID eShop in Version 6 und dessen Anforderungen
- installierter OXID eShop in Version 4.10 (CE, PE) oder 5.3 (EE) und dessen Anforderungen
Ein Einsatz in älteren Shopversionen ist vor dem Livebetrieb zwingend auf Verwendbarkeit zu testen.
## Installation / Update
Während der Installation werden noch keine Shopeinstellungen geändert. Führen Sie diesen Befehl im Shophauptverzeichnis aus:
Kopieren Sie den Inhalt des `copy_this`-Ordners in Ihren Shopordner. Achten Sie darauf, auch die verborgene .htaccess mitzukopieren, dass die Scripte nicht über den Browser von außen erreichbar sind.
```
composer require d3/taxratesadjustment:"^2.0" --update-no-dev
```
Vergeben Sie den Scripten im Ordner `_taxRates/bin` Ausführungsrechte.
## Ausführung
- Bitte führen Sie die Umstellung rechtzeitig vorab in einer Testinstallation durch und prüfen Ihren Shop, um Fehler im Livebetrieb zu vermeiden. Zum Übergehen der Datumsprüfung können Sie den folgenden Befehlen einfach den Parameter `-d` anhängen: z.B. `[ Shoppfad ]/vendor/bin/reduceTaxRate -d`. Für den Livebetrieb soll der Parameter nicht verwendet werden.
- Bitte führen Sie die Umstellung rechtzeitig vorab in einer Testinstallation durch und prüfen Ihren Shop, um Fehler im Livebetrieb zu vermeiden. Zum Übergehen der Datumsprüfung können Sie den folgenden Befehlen einfach den Parameter `-d` anhängen: z.B. `[ Shoppfad ]/_taxRates/bin/reduceTaxRate -d`. Für den Livebetrieb soll der Parameter nicht verwendet werden.
- Legen Sie sich unbedingt vor jeder Ausführung eine Datensicherung an. Die Software wird nach bestem Wissen erstellt. Durch die Vielzahl an möglichen Shopkonstellationen können wir jedoch keine Gewährleistung für die richtige Ausführung und eventuelle Folgen übernehmen.
Richten Sie einen ersten Cronjob ein, der idealerweise am 01.07.2020 um 00:00 folgendes Script startet, um die Steuersätze zu senken. Alternativ führen Sie dieses Script zum passenden Zeitpunkt auf der Serverkonsole manuell aus:
Richten Sie einen ersten Cronjob ein, der idealerweise am 01.07.2020 um 00:00 folgendes Script startet, um die Steuersätze zu senken. Alternativ führen Sie dieses Script zum passenden Zeitpunkt manuell auf der Serverkonsole aus:
```
[ Shoppfad ]/vendor/bin/reduceTaxRate
[ Shoppfad ]/_taxRates/bin/reduceTaxRate
```
Richten Sie einen zweiten Cronjob ein, der idealerweise am 01.01.2021 um 00:00 folgendes Script startet, um die Steuersätze zurückzusetzen. Alternativ führen Sie dieses Script zum passenden Zeitpunkt auf der Serverkonsole manuell aus:
Richten Sie einen zweiten Cronjob ein, der idealerweise am 01.01.2021 um 00:00 folgendes Script startet, um die Steuersätze zurückzusetzen. Alternativ führen Sie dieses Script zum passenden Zeitpunkt manuell auf der Serverkonsole aus:
```
[ Shoppfad ]/vendor/bin/raiseTaxRate
[ Shoppfad ]/_taxRates/bin/raiseTaxRate
```
Nutzen Sie für die Preisanpassungen die folgenden Scripte als Cronjob zum passenden Moment:
um die Artikelpreise zu senken::
```
[ Shoppfad ]/_taxRates/bin/reduceArticlePrices
```
um die Artikelpreise zurückzusetzen:
```
[ Shoppfad ]/_taxRates/bin/raiseArtikelPrices
```
Führen Sie die Preisanpassungsscripte nur ein einziges Mal aus, da die Preise sonst mehrfach gesenkt / erhöht werden.
Bei Fragen zur Einrichtung der Cronjobs kontaktieren Sie bitte Ihren Hostingprovider.
Prüfen Sie nach Ausführung der Scripte Ihren Shop bitte zeitnah auf richtige Funktion.
@ -75,23 +113,20 @@ Sollen die Scripte über eine PHP-Version gestartet werden, die nicht als Standa
Entfernen Sie die eingerichteten Cronjobs nach den beiden Ausführungszeitpunkten, um versehentliche spätere Auslösungen zu vermeiden.
Nach heutigem Stand werden die Scripte nach dem Zurücksetzen der Steuersätze nicht mehr benötigt. Dann kann dieses Paket mit folgendem Befehl wieder aus der Installation entfernt werden:
```
composer remove d3/taxratesadjustment --update-no-dev
```
Nach heutigem Stand werden die Scripte nach dem Zurücksetzen der Steuersätze nicht mehr benötigt. Dann kann der Ordner `_taxRates` wieder komplett aus der Installation entfernt werden.
## Änderungshistorie
- 2.0.0:
- 1.0.0:
- scriptgesteuertes Ändern der Steuersätze (generell und artikelspezifisch) reduzierend und erhöhend für jeden Subshop
- per Argument übersteuerbare Ausführungsbeschränkung
- 2.1.0
- Subshopfilter eingefügt
- 2.1.1
- Composer Command korrigiert
- 2.1.2
- 1.0.1
- falsche Konvertierung der ShopId entfernt
- 1.0.2
- PHP-Versionshinweis angepasst
- unreleased
- Preisanpassungsscripte eingefügt
## Support

View File

@ -1,25 +0,0 @@
{
"name": "d3/taxratesadjustment",
"description": "adjusts the tax rates for the German economic stimulus package 2020 / 2021",
"type": "library",
"require": {
"oxid-esales/oxideshop-ce": "^6.0"
},
"license": "GPL-3.0",
"authors": [
{
"name": "D3 Data Development (Inh. Thomas Dartsch)",
"email": "info@shopmodule.com",
"homepage": "https://www.d3data.de"
}
],
"autoload": {
"psr-4": {
"D3\\TaxRatesAdjustment\\": ""
}
},
"bin": [
"bin/reduceTaxRate",
"bin/raiseTaxRate"
]
}

View File

@ -0,0 +1 @@
Deny from all

View File

@ -0,0 +1,149 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\TaxRatesAdjustment\Models;
use oxRegistry;
require_once('genericAbstract.php');
abstract class articlePricesAbstract extends genericAbstract
{
public $baseQueriesDefaultTax = [
//'UPDATE oxarticles SET oxprice = (oxprice / 1.19 * 1.16) WHERE oxshopid = 'oxbaseshop' AND (oxvat IS NULL);',
// default prices
'UPDATE oxarticles SET oxprice = (oxprice / ? * ?) WHERE oxshopid = ? AND (oxvat IS NULL)',
// recommended retail price
'UPDATE oxarticles SET oxtprice = (oxtprice / ? * ?) WHERE oxshopid = ? AND (oxvat IS NULL)',
// varminprices
'UPDATE oxarticles SET oxvarminprice = (oxvarminprice / ? * ?) WHERE oxshopid = ? AND (oxvat IS NULL)',
// varmaxprices
'UPDATE oxarticles SET oxvarmaxprice = (oxvarmaxprice / ? * ?) WHERE oxshopid = ? AND (oxvat IS NULL)'
];
public $baseQueriesCustomTax = [
//'UPDATE oxarticles SET oxprice = (oxprice / 1.19 * 1.16) WHERE oxshopid = 'oxbaseshop' AND (oxvat IN(16, 19));',
// default prices
'UPDATE oxarticles SET oxprice = (oxprice / ? * ?) WHERE oxshopid = ? AND (oxvat IN(?, ?))',
// recommended retail price
'UPDATE oxarticles SET oxtprice = (oxtprice / ? * ?) WHERE oxshopid = ? AND (oxvat IN(?, ?))',
// varminprices
'UPDATE oxarticles SET oxvarminprice = (oxvarminprice / ? * ?) WHERE oxshopid = ? AND (oxvat IN(?, ?))',
// varmaxprices
'UPDATE oxarticles SET oxvarmaxprice = (oxvarmaxprice / ? * ?) WHERE oxshopid = ? AND (oxvat IN(?, ?))'
];
public function run()
{
if (false === $this->isInExecutableTimeRange()) {
trigger_error("script shouldn't run outside the defined time range", E_USER_WARNING);
die();
};
$this->changeArticlePrices();
}
public function changeArticlePrices()
{
$shop = new \oxShop();
// use shop list, when parameter -d is set
$opts = getopt("s:");
$where = isset($opts['s']) ?
"oxid IN (".implode(', ', array_map(
function ($a) {return \oxDb::getDb()->quote(trim($a));},
explode(',', $opts['s']))
).")" :
"1";
$q = "SELECT oxid FROM " . $shop->getCoreTableName() . " WHERE ".$where ;
foreach ( \oxDb::getDb(\oxDb::FETCH_MODE_ASSOC)->getAll( $q ) as $record ) {
$shopId = (int) $record["oxid"];
$count = 0;
$count += $this->changeSubshopArticlePricesDefaultTax($shopId);
$count += $this->changeSubshopArticlePricesCustomTax($shopId);
echo "$count article prices in shop $shopId changed.".PHP_EOL;
}
}
public function changeSubshopArticlePricesDefaultTax($shopId)
{
$count = 0;
$oCurrConfig = oxRegistry::getConfig();
$oldTaxRate = (int) $oCurrConfig->getConfigParam('dDefaultVAT');
$newTaxRate = $this->rateChanges[$oldTaxRate];
if ($newTaxRate === null) {
$flipped = array_flip($this->rateChanges);
$oldTaxRate = $flipped[(int) $oCurrConfig->getConfigParam('dDefaultVAT')];
$newTaxRate = $this->rateChanges[$oldTaxRate];
}
foreach ($this->baseQueriesDefaultTax as $query) {
$db = \oxDb::getDb(\oxDb::FETCH_MODE_ASSOC);
$paramLength = substr_count($query, '?');
$allQueryParameters = [
1 + ($oldTaxRate / 100),
1 + ($newTaxRate / 100),
$shopId,
$oldTaxRate,
$newTaxRate,
];
$queryParameters = array_slice($allQueryParameters, 0, $paramLength);
$count += $db->execute($query, $queryParameters);
}
return $count;
}
public function changeSubshopArticlePricesCustomTax($shopId)
{
$count = 0;
foreach ($this->baseQueriesCustomTax as $query) {
foreach ($this->rateChanges as $oldTaxRate => $newTaxRate) {
$db = \oxDb::getDb(\oxDb::FETCH_MODE_ASSOC);
$paramLength = substr_count($query, '?');
$allQueryParameters = [
1 + ($oldTaxRate / 100),
1 + ($newTaxRate / 100),
$shopId,
$oldTaxRate,
$newTaxRate,
];
$queryParameters = array_slice($allQueryParameters, 0, $paramLength);
$count += $db->execute($query, $queryParameters);
}
}
return $count;
}
}

View File

@ -0,0 +1,65 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\TaxRatesAdjustment\Models;
use oxConfig;
use oxRegistry;
abstract class genericAbstract
{
public $rateChanges = [
19 => 16,
7 => 5
];
/**
* @return bool
*/
public function isInExecutableTimeRange()
{
// skip time check, when parameter -d is set
$opts = getopt("d");
if (is_array($opts) && isset($opts['d'])) {
return true;
}
list($from, $to) = $this->execPeriod;
return (time() > strtotime($from)) && (time() < strtotime($to));
}
/**
* @param int $id
*
* @throws \oxConnectionException
*/
public function switchToShop($id)
{
if (oxRegistry::getConfig()->isMall()
&& $id != oxRegistry::getConfig()->getActiveShop()->getId()
) {
/** @var oxConfig $oNewConf */
$oNewConf = new oxConfig();
$oNewConf->setShopId($id);
$oNewConf->init();
oxRegistry::getConfig()->onShopChange();
oxRegistry::getSession()->setVariable('actshop', $id);
oxRegistry::getSession()->setVariable('currentadminshop', $id);
oxRegistry::getConfig()->setShopId($id);
}
}
}

View File

@ -0,0 +1,24 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\TaxRatesAdjustment\Models;
require_once('articlePricesAbstract.php');
require_once('raiseTrait.php');
class raiseArticlePrices extends articlePricesAbstract
{
use raiseTrait;
}

View File

@ -0,0 +1,24 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\TaxRatesAdjustment\Models;
require_once 'taxRateAbstract.php';
require_once 'raiseTrait.php';
class raiseTaxRate extends taxRateAbstract
{
use raiseTrait;
}

View File

@ -13,13 +13,9 @@
* @link http://www.oxidmodule.com
*/
// ShopId
namespace D3\TaxRatesAdjustment\Models;
use OxidEsales\Eshop\Core\Registry;
class raiseTaxRate extends taxRateAbstract
trait raiseTrait
{
public $execPeriod = [
'2020-12-28',
@ -30,4 +26,4 @@ class raiseTaxRate extends taxRateAbstract
{
$this->rateChanges = array_flip($this->rateChanges);
}
}
}

View File

@ -0,0 +1,24 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\TaxRatesAdjustment\Models;
require_once('articlePricesAbstract.php');
require_once('reduceTrait.php');
class reduceArticlePrices extends articlePricesAbstract
{
use reduceTrait;
}

View File

@ -0,0 +1,24 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\TaxRatesAdjustment\Models;
require_once 'taxRateAbstract.php';
require_once 'reduceTrait.php';
class reduceTaxRate extends taxRateAbstract
{
use reduceTrait;
}

View File

@ -15,12 +15,10 @@
namespace D3\TaxRatesAdjustment\Models;
use OxidEsales\Eshop\Core\Registry;
class reduceTaxRate extends taxRateAbstract
trait reduceTrait
{
public $execPeriod = [
'2020-06-27',
'2020-07-03',
];
}
}

View File

@ -15,45 +15,16 @@
namespace D3\TaxRatesAdjustment\Models;
use OxidEsales\Eshop\Application\Model\Article;
use OxidEsales\Eshop\Application\Model\Shop;
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry;
use oxArticle;
use oxConfig;
use oxDb;
use oxRegistry;
use oxShop;
abstract class taxRateAbstract
require_once('genericAbstract.php');
abstract class taxRateAbstract extends genericAbstract
{
public $execPeriod = [
'2020-01-01',
'2019-12-31',
];
public $rateChanges = [
19 => 16,
7 => 5
];
/**
* @return bool
*/
public function isInExecutableTimeRange()
{
// skip time check, when parameter -d is set
$opts = getopt("d");
if (is_array($opts) && isset($opts['d'])) {
return true;
}
list($from, $to) = $this->execPeriod;
return (time() > strtotime($from)) && (time() < strtotime($to));
}
/**
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException
*/
public function run()
{
if (false === $this->isInExecutableTimeRange()) {
@ -64,62 +35,36 @@ abstract class taxRateAbstract
$this->changeTaxRates();
}
/**
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException
*/
public function changeTaxRates()
{
$shop = new Shop();
$shop = new oxShop();
// use shop list, when parameter -d is set
$opts = getopt("s:");
$where = isset($opts['s']) ?
"oxid IN (".implode(', ', array_map(
function ($a) {return DatabaseProvider::getDb()->quote(trim($a));},
function ($a) {return oxDb::getDb()->quote(trim($a));},
explode(',', $opts['s']))
).")" :
"1";
$q = "SELECT oxid FROM " . $shop->getCoreTableName() . " WHERE ".$where ;
foreach ( DatabaseProvider::getDb( DatabaseProvider::FETCH_MODE_ASSOC )->getAll( $q ) as $record ) {
$shopId = (int) $record["oxid"];
foreach (oxDb::getDb(oxDb::FETCH_MODE_ASSOC )->getAll( $q ) as $record ) {
$shopId = $record["oxid"];
$this->switchToShop($shopId);
$this->changeDefaultTaxRate( $shopId );
$this->changeArticlesTaxRate( $shopId );
}
}
/**
* @param int $id
*
* @throws \oxConnectionException
*/
public function switchToShop($id)
{
if (Registry::getConfig()->isMall()
&& $id != Registry::getConfig()->getActiveShop()->getId()
) {
/** @var Config $oNewConf */
$oNewConf = new Config();
$oNewConf->setShopId($id);
$oNewConf->init();
Registry::getConfig()->onShopChange();
Registry::getSession()->setVariable('actshop', $id);
Registry::getSession()->setVariable('currentadminshop', $id);
Registry::getConfig()->setShopId($id);
}
}
/**
* @param int $shopId
*/
public function changeDefaultTaxRate($shopId)
{
$oCurrConfig = new Config();
$oCurrConfig = new oxConfig();
$newVat = $this->rateChanges[(int) $oCurrConfig->getConfigParam('dDefaultVAT')];
if ($newVat) {
@ -132,21 +77,18 @@ abstract class taxRateAbstract
/**
* @param int $shopId
*
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException
*/
public function changeArticlesTaxRate($shopId)
{
$article = oxNew(Article::class);
$article = oxNew(oxArticle::class);
$q = "SELECT oxid FROM ".$article->getCoreTableName()."
WHERE oxvat IN (".implode(', ', array_keys($this->rateChanges)).")
AND oxshopid = ".DatabaseProvider::getDb()->quote($shopId);
AND oxshopid = ". oxDb::getDb()->quote($shopId);
$counter = 0;
foreach (DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getAll($q) as $articleRecord) {
foreach (oxDb::getDb(oxDb::FETCH_MODE_ASSOC)->getAll($q) as $articleRecord) {
$articleId = $articleRecord['oxid'];
$article = oxNew(Article::class);
$article = oxNew(oxArticle::class);
$article->load($articleId);
$article->assign(
[
@ -163,9 +105,9 @@ abstract class taxRateAbstract
$q = "SELECT count(*) FROM ".$article->getCoreTableName()."
WHERE oxvat IN (".implode(', ', array_keys($this->rateChanges)).")
AND oxshopid = ".DatabaseProvider::getDb()->quote($shopId);
AND oxshopid = ". oxDb::getDb()->quote($shopId);
if ($counter = DatabaseProvider::getDb()->getOne($q)) {
if ($counter = oxDb::getDb()->getOne($q)) {
echo "the tax rate update for " . $counter . " article(s) was failed in shop " . $shopId . PHP_EOL;
}
}

View File

@ -0,0 +1,16 @@
#!/usr/bin/env php
<?php
$filePath = '../bootstrap.php';
$currentDirectory = __DIR__ . '/';
$filePath = $currentDirectory . $filePath;
require($filePath);
require(__DIR__.'/../Models/raiseArticlePrices.php');
$change = new \D3\TaxRatesAdjustment\Models\raiseArticlePrices();
try {
$change->run();
} catch ( \Exception $e) {
echo $e->getMessage();
}

View File

@ -6,8 +6,10 @@ $currentDirectory = __DIR__ . '/';
$filePath = $currentDirectory . $filePath;
require($filePath);
require(__DIR__.'/../Models/raiseTaxRate.php');
$change = new \D3\TaxRatesAdjustment\Models\raiseTaxRate();
try {
$change->run();
} catch ( \Exception $e) {

View File

@ -0,0 +1,16 @@
#!/usr/bin/env php
<?php
$filePath = '../bootstrap.php';
$currentDirectory = __DIR__ . '/';
$filePath = $currentDirectory . $filePath;
require($filePath);
require(__DIR__.'/../Models/reduceArticlePrices.php');
$change = new \D3\TaxRatesAdjustment\Models\reduceArticlePrices();
try {
$change->run();
} catch ( \Exception $e) {
echo $e->getMessage();
}

View File

@ -6,6 +6,7 @@ $currentDirectory = __DIR__ . '/';
$filePath = $currentDirectory . $filePath;
require($filePath);
require(__DIR__.'/../Models/reduceTaxRate.php');
$change = new \D3\TaxRatesAdjustment\Models\reduceTaxRate();
try {

View File

@ -5,7 +5,7 @@ if (!empty($bootstrapFileName)) {
$bootstrapFileName = realpath(trim(getenv('ESHOP_BOOTSTRAP_PATH')));
} else {
$count = 0;
$bootstrapFileName = '../../source/bootstrap.php';
$bootstrapFileName = '../bootstrap.php';
$currentDirectory = __DIR__ . '/';
while ($count < 5) {
$count++;