Initial xentral_oss_20.3.c9ffacf
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm;
|
||||
|
||||
use ApplicationCore;
|
||||
use Xentral\Core\DependencyInjection\ContainerInterface;
|
||||
use Xentral\Modules\Datanorm\Service\DatanormEnricher;
|
||||
use Xentral\Modules\Datanorm\Service\DatanormIntermediateGateway;
|
||||
use Xentral\Modules\Datanorm\Service\DatanormIntermediateService;
|
||||
use Xentral\Modules\Datanorm\Service\DatanormConverter;
|
||||
use Xentral\Modules\Datanorm\Service\ArticleService;
|
||||
use Xentral\Modules\Datanorm\Handler\DatanormReaderVersionFourHandler;
|
||||
use Xentral\Modules\Datanorm\Handler\DatanormReaderVersionFiveHandler;
|
||||
use Xentral\Modules\Datanorm\Wrapper\AddressWrapper;
|
||||
|
||||
final class Bootstrap
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function registerServices(): array
|
||||
{
|
||||
return [
|
||||
'DatanormImporter' => 'onInitDatanormImporter',
|
||||
'DatanormReaderFactory' => 'onInitDatanormReaderFactory',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*
|
||||
* @return DatanormImporter
|
||||
*/
|
||||
public static function onInitDatanormImporter(ContainerInterface $container): DatanormImporter
|
||||
{
|
||||
return new DatanormImporter(
|
||||
self::onInitDatanormIntermediateService($container),
|
||||
self::onInitDatanormIntermediateGateway($container),
|
||||
self::onInitDatanormConverter(),
|
||||
self::onInitArticleService($container),
|
||||
$container->get('SellingPriceService'),
|
||||
$container->get('PurchasePriceService'),
|
||||
self::onInitAdressWrapper($container),
|
||||
self::onInitDatanormEnricher($container)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*
|
||||
* @return DatanormReaderFactory
|
||||
*/
|
||||
public static function onInitDatanormReaderFactory(ContainerInterface $container): DatanormReaderFactory
|
||||
{
|
||||
$handlers[] = new DatanormReaderVersionFiveHandler();
|
||||
$handlers[] = new DatanormReaderVersionFourHandler();
|
||||
|
||||
return new DatanormReaderFactory(
|
||||
self::onInitDatanormIntermediateService($container),
|
||||
$handlers,
|
||||
$container->get('FilesystemFactory')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*
|
||||
* @return DatanormIntermediateService
|
||||
*/
|
||||
public static function onInitDatanormIntermediateService(ContainerInterface $container): DatanormIntermediateService
|
||||
{
|
||||
return new DatanormIntermediateService($container->get('Database'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*
|
||||
* @return DatanormIntermediateGateway
|
||||
*/
|
||||
public static function onInitDatanormIntermediateGateway(ContainerInterface $container): DatanormIntermediateGateway
|
||||
{
|
||||
return new DatanormIntermediateGateway($container->get('Database'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DatanormConverter
|
||||
*/
|
||||
public static function onInitDatanormConverter(): DatanormConverter
|
||||
{
|
||||
return new DatanormConverter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*
|
||||
* @return ArticleService
|
||||
*/
|
||||
public static function onInitArticleService(ContainerInterface $container): ArticleService
|
||||
{
|
||||
return new ArticleService($container->get('Database'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*
|
||||
* @return AddressWrapper
|
||||
*/
|
||||
private static function onInitAdressWrapper(ContainerInterface $container): AddressWrapper
|
||||
{
|
||||
/** @var ApplicationCore $app */
|
||||
$app = $container->get('LegacyApplication');
|
||||
|
||||
return new AddressWrapper(
|
||||
$container->get('Database'),
|
||||
$app->erp
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*
|
||||
* @return DatanormEnricher
|
||||
*/
|
||||
private static function onInitDatanormEnricher(ContainerInterface $container): DatanormEnricher
|
||||
{
|
||||
return new DatanormEnricher(
|
||||
self::onInitDatanormIntermediateGateway($container)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Data;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
abstract class AbstractDatanormTypeData implements JsonSerializable
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public abstract function jsonSerialize(): array;
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*/
|
||||
public abstract function fillByJson(string $data): void;
|
||||
}
|
||||
@@ -0,0 +1,636 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Data;
|
||||
|
||||
final class DatanormATypeData extends AbstractDatanormTypeData implements DatanormTypeDataInterface
|
||||
{
|
||||
/** @var string $workflowState */
|
||||
protected $workflowState = '';
|
||||
|
||||
/** @var string $articleNumber */
|
||||
protected $articleNumber = '';
|
||||
|
||||
/** @var string $shortDescription1 */
|
||||
protected $shortDescription1 = '';
|
||||
|
||||
/** @var string $shortDescription2 */
|
||||
protected $shortDescription2 = '';
|
||||
|
||||
/** @var string $matchcode */
|
||||
protected $matchcode = '';
|
||||
|
||||
/** @var string $ean */
|
||||
protected $ean = '';
|
||||
|
||||
/** @var string $discountGroup */
|
||||
protected $discountGroup = '';
|
||||
|
||||
/** @var string $mainProductGroup */
|
||||
protected $mainProductGroup = '';
|
||||
|
||||
/** @var string $productGroup */
|
||||
protected $productGroup = '';
|
||||
|
||||
/** @var string $minimumPackageAmount */
|
||||
protected $minimumPackageAmount = '';
|
||||
|
||||
/** @var string $priceMark */
|
||||
protected $priceMark = '';
|
||||
|
||||
/** @var float $price */
|
||||
protected $price = 0.0;
|
||||
|
||||
/** @var int $priceAmount */
|
||||
protected $priceAmount = 0;
|
||||
|
||||
/** @var string $packingUnit */
|
||||
protected $packingUnit = '';
|
||||
|
||||
/** @var string $producerToken1 */
|
||||
protected $producerToken1 = '';
|
||||
|
||||
/** @var string $producerToken2 */
|
||||
protected $producerToken2 = '';
|
||||
|
||||
/** @var string $producerToken3 */
|
||||
protected $producerToken3 = '';
|
||||
|
||||
/** @var string $altArticleNumber */
|
||||
protected $altArticleNumber = '';
|
||||
|
||||
/** @var string $producerModel */
|
||||
protected $producerModel = '';
|
||||
|
||||
/** @var string $connectionNumber */
|
||||
protected $connectionNumber = '';
|
||||
|
||||
/** @var string $cataloguePage */
|
||||
protected $cataloguePage = '';
|
||||
|
||||
/** @var string $longDecriptionKey */
|
||||
protected $longDecriptionKey = '';
|
||||
|
||||
/** @var string $costType */
|
||||
protected $costType = '';
|
||||
|
||||
/** @var string $articleType */
|
||||
protected $articleType = '';
|
||||
|
||||
/** @var string $referenceNumber */
|
||||
protected $referenceNumber = '';
|
||||
|
||||
/** @var int $mwstType */
|
||||
protected $mwstType = 1;
|
||||
|
||||
/** @var string $textkey */
|
||||
protected $textkey = '';
|
||||
|
||||
/** @var string $producerNumber */
|
||||
protected $producerNumber = '';
|
||||
|
||||
/**
|
||||
* Values : N:Neuanlage, L:Löschung, A:Änderung, X:Artikelnummernänderung
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWorkflowState(): string
|
||||
{
|
||||
return $this->workflowState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getArticleNumber(): string
|
||||
{
|
||||
return $this->articleNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getShortDescription1(): string
|
||||
{
|
||||
return $this->shortDescription1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getShortDescription2(): string
|
||||
{
|
||||
return $this->shortDescription2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMatchcode(): string
|
||||
{
|
||||
return $this->matchcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEan(): string
|
||||
{
|
||||
return $this->ean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscountGroup(): string
|
||||
{
|
||||
return $this->discountGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMainProductGroup(): string
|
||||
{
|
||||
return $this->mainProductGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProductGroup(): string
|
||||
{
|
||||
return $this->productGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMinimumPackageAmount(): string
|
||||
{
|
||||
return $this->minimumPackageAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Values: 1:Listenpreis, 2:Nettopreis
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPriceMark(): string
|
||||
{
|
||||
return $this->priceMark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getPrice(): float
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPriceAmount(): int
|
||||
{
|
||||
return $this->priceAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPackingUnit(): string
|
||||
{
|
||||
return $this->packingUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProducerToken1(): string
|
||||
{
|
||||
return $this->producerToken1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProducerToken2(): string
|
||||
{
|
||||
return $this->producerToken2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProducerToken3(): string
|
||||
{
|
||||
return $this->producerToken3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAltArticleNumber(): string
|
||||
{
|
||||
return $this->altArticleNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProducerModel(): string
|
||||
{
|
||||
return $this->producerModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getConnectionNumber(): string
|
||||
{
|
||||
return $this->connectionNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCataloguePage(): string
|
||||
{
|
||||
return $this->cataloguePage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLongDecriptionKey(): string
|
||||
{
|
||||
return $this->longDecriptionKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCostType(): string
|
||||
{
|
||||
return $this->costType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Values: 1:Lagerartikel, 2:Bestellartikel
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getArticleType(): string
|
||||
{
|
||||
return $this->articleType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReferenceNumber(): string
|
||||
{
|
||||
return $this->referenceNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Values: 1:normal 2:erhöht 3:reduziert
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMwstType(): int
|
||||
{
|
||||
return $this->mwstType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Values: 0:'KT1 + KT2', 1:'LT + KT2', 2:'KT1 + DT', 3: 'LT + DT', 4:'KT1 + KT2 + LT', 5:'KT1 + KT2 + DT', 6: 'KT1
|
||||
* + KT2 + LT + DT' KT1 = $shortDescription1, KT2 = $shortDescription2
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTextkey(): string
|
||||
{
|
||||
return $this->textkey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProducerNumber(): string
|
||||
{
|
||||
return $this->producerNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Values : N:Neuanlage, L:Löschung, A:Änderung, X:Artikelnummernänderung
|
||||
*
|
||||
* @param string $workflowState
|
||||
*/
|
||||
public function setWorkflowState(string $workflowState): void
|
||||
{
|
||||
$this->workflowState = $workflowState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $articleNumber
|
||||
*/
|
||||
public function setArticleNumber(string $articleNumber): void
|
||||
{
|
||||
$this->articleNumber = $articleNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $shortDescription1
|
||||
*/
|
||||
public function setShortDescription1(string $shortDescription1): void
|
||||
{
|
||||
$this->shortDescription1 = $shortDescription1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $shortDescription2
|
||||
*/
|
||||
public function setShortDescription2(string $shortDescription2): void
|
||||
{
|
||||
$this->shortDescription2 = $shortDescription2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $matchcode
|
||||
*/
|
||||
public function setMatchcode(string $matchcode): void
|
||||
{
|
||||
$this->matchcode = $matchcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $ean
|
||||
*/
|
||||
public function setEan(string $ean): void
|
||||
{
|
||||
$this->ean = $ean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $discountGroup
|
||||
*/
|
||||
public function setDiscountGroup(string $discountGroup): void
|
||||
{
|
||||
$this->discountGroup = $discountGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mainProductGroup
|
||||
*/
|
||||
public function setMainProductGroup(string $mainProductGroup): void
|
||||
{
|
||||
$this->mainProductGroup = $mainProductGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $productGroup
|
||||
*/
|
||||
public function setProductGroup(string $productGroup): void
|
||||
{
|
||||
$this->productGroup = $productGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $minimumPackageAmount
|
||||
*/
|
||||
public function setMinimumPackageAmount(string $minimumPackageAmount): void
|
||||
{
|
||||
$this->minimumPackageAmount = $minimumPackageAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Values: 1:Listenpreis, 2:Nettopreis
|
||||
*
|
||||
* @param string $priceMark
|
||||
*/
|
||||
public function setPriceMark(string $priceMark): void
|
||||
{
|
||||
$this->priceMark = $priceMark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $price
|
||||
*/
|
||||
public function setPrice(float $price): void
|
||||
{
|
||||
$this->price = $price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $priceAmount
|
||||
*/
|
||||
public function setPriceAmount(int $priceAmount): void
|
||||
{
|
||||
$this->priceAmount = $priceAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packingUnit
|
||||
*/
|
||||
public function setPackingUnit(string $packingUnit): void
|
||||
{
|
||||
$this->packingUnit = $packingUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $producerToken1
|
||||
*/
|
||||
public function setProducerToken1(string $producerToken1): void
|
||||
{
|
||||
$this->producerToken1 = $producerToken1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $producerToken2
|
||||
*/
|
||||
public function setProducerToken2(string $producerToken2): void
|
||||
{
|
||||
$this->producerToken2 = $producerToken2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $producerToken3
|
||||
*/
|
||||
public function setProducerToken3(string $producerToken3): void
|
||||
{
|
||||
$this->producerToken3 = $producerToken3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $altArticleNumber
|
||||
*/
|
||||
public function setAltArticleNumber(string $altArticleNumber): void
|
||||
{
|
||||
$this->altArticleNumber = $altArticleNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $producerModel
|
||||
*/
|
||||
public function setProducerModel(string $producerModel): void
|
||||
{
|
||||
$this->producerModel = $producerModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $connectionNumber
|
||||
*/
|
||||
public function setConnectionNumber(string $connectionNumber): void
|
||||
{
|
||||
$this->connectionNumber = $connectionNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $cataloguePage
|
||||
*/
|
||||
public function setCataloguePage(string $cataloguePage): void
|
||||
{
|
||||
$this->cataloguePage = $cataloguePage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $longDecriptionKey
|
||||
*/
|
||||
public function setLongDecriptionKey(string $longDecriptionKey): void
|
||||
{
|
||||
$this->longDecriptionKey = $longDecriptionKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $costType
|
||||
*/
|
||||
public function setCostType(string $costType): void
|
||||
{
|
||||
$this->costType = $costType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Values: 1:Lagerartikel, 2:Bestellartikel
|
||||
*
|
||||
* @param string $articleType
|
||||
*/
|
||||
public function setArticleType(string $articleType): void
|
||||
{
|
||||
$this->articleType = $articleType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $referenceNumber
|
||||
*/
|
||||
public function setReferenceNumber(string $referenceNumber): void
|
||||
{
|
||||
$this->referenceNumber = $referenceNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Values: 1:normal 2:erhöht 3:reduziert
|
||||
*
|
||||
* @param int $mwstType
|
||||
*/
|
||||
public function setMwstType(int $mwstType): void
|
||||
{
|
||||
$this->mwstType = $mwstType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Values: 0:'KT1 + KT2', 1:'LT + KT2', 2:'KT1 + DT', 3: 'LT + DT', 4:'KT1 + KT2 + LT', 5:'KT1 + KT2 + DT', 6: 'KT1
|
||||
* + KT2 + LT + DT' KT1 = $shortDescription1, KT2 = $shortDescription2
|
||||
*
|
||||
* @param string $textkey
|
||||
*/
|
||||
public function setTextkey(string $textkey): void
|
||||
{
|
||||
$this->textkey = $textkey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $producerNumber
|
||||
*/
|
||||
public function setProducerNumber(string $producerNumber): void
|
||||
{
|
||||
$this->producerNumber = $producerNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'workflowState' => $this->workflowState,
|
||||
'articleNumber' => $this->articleNumber,
|
||||
'shortDescription1' => $this->shortDescription1,
|
||||
'shortDescription2' => $this->shortDescription2,
|
||||
'matchcode' => $this->matchcode,
|
||||
'ean' => $this->ean,
|
||||
'discountGroup' => $this->discountGroup,
|
||||
'mainProductGroup' => $this->mainProductGroup,
|
||||
'productGroup' => $this->productGroup,
|
||||
'minimumPackageAmount' => $this->minimumPackageAmount,
|
||||
'priceMark' => $this->priceMark,
|
||||
'price' => $this->price,
|
||||
'priceAmount' => $this->priceAmount,
|
||||
'packingUnit' => $this->packingUnit,
|
||||
'producerToken1' => $this->producerToken1,
|
||||
'producerToken2' => $this->producerToken2,
|
||||
'producerToken3' => $this->producerToken3,
|
||||
'altArticleNumber' => $this->altArticleNumber,
|
||||
'producerModel' => $this->producerModel,
|
||||
'connectionNumber' => $this->connectionNumber,
|
||||
'cataloguePage' => $this->cataloguePage,
|
||||
'longDecriptionKey' => $this->longDecriptionKey,
|
||||
'costType' => $this->costType,
|
||||
'articleType' => $this->articleType,
|
||||
'referenceNumber' => $this->referenceNumber,
|
||||
'mwstType' => $this->mwstType,
|
||||
'textkey' => $this->textkey,
|
||||
'producerNumber' => $this->producerNumber,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*/
|
||||
public function fillByJson(string $data): void
|
||||
{
|
||||
$obj = json_decode($data);
|
||||
|
||||
$this->workflowState = $obj->workflowState;
|
||||
$this->articleNumber = $obj->articleNumber;
|
||||
$this->shortDescription1 = $obj->shortDescription1;
|
||||
$this->shortDescription2 = $obj->shortDescription2;
|
||||
$this->matchcode = $obj->matchcode;
|
||||
$this->ean = $obj->ean;
|
||||
$this->discountGroup = $obj->discountGroup;
|
||||
$this->mainProductGroup = $obj->mainProductGroup;
|
||||
$this->productGroup = $obj->productGroup;
|
||||
$this->minimumPackageAmount = $obj->minimumPackageAmount;
|
||||
$this->priceMark = $obj->priceMark;
|
||||
$this->price = (float)$obj->price;
|
||||
$this->priceAmount = (int)$obj->priceAmount;
|
||||
$this->packingUnit = $obj->packingUnit;
|
||||
$this->producerToken1 = $obj->producerToken1;
|
||||
$this->producerToken2 = $obj->producerToken2;
|
||||
$this->producerToken3 = $obj->producerToken3;
|
||||
$this->altArticleNumber = $obj->altArticleNumber;
|
||||
$this->producerModel = $obj->producerModel;
|
||||
$this->connectionNumber = $obj->connectionNumber;
|
||||
$this->cataloguePage = $obj->cataloguePage;
|
||||
$this->longDecriptionKey = $obj->longDecriptionKey;
|
||||
$this->costType = $obj->costType;
|
||||
$this->articleType = $obj->articleType;
|
||||
$this->referenceNumber = $obj->referenceNumber;
|
||||
$this->mwstType = (int)$obj->mwstType;
|
||||
$this->textkey = $obj->textkey;
|
||||
$this->producerNumber = $obj->producerNumber;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Data;
|
||||
|
||||
final class DatanormBTypeData extends AbstractDatanormTypeData implements DatanormTypeDataInterface
|
||||
{
|
||||
/** @var string $processingFlag */
|
||||
protected $processingFlag = '';
|
||||
|
||||
/** @var string $articleNumber */
|
||||
protected $articleNumber = '';
|
||||
|
||||
/** @var string $articleNumberNew */
|
||||
protected $articleNumberNew = '';
|
||||
|
||||
/** @var string $expirationDate */
|
||||
protected $expirationDate = '';
|
||||
|
||||
/** @var string $matchcode */
|
||||
protected $matchcode = '';
|
||||
|
||||
/** @var string $altArticleNumber */
|
||||
protected $altArticleNumber = '';
|
||||
|
||||
/** @var string $copperWeightIndicator */
|
||||
protected $copperWeightIndicator = '';
|
||||
|
||||
/** @var string $copperRawPrice */
|
||||
protected $copperRawPrice = '';
|
||||
|
||||
/** @var string $copperWeight */
|
||||
protected $copperWeight = '';
|
||||
|
||||
/** @var string $ean */
|
||||
protected $ean = '';
|
||||
|
||||
/** @var string $graphicNumber */
|
||||
protected $graphicNumber = '';
|
||||
|
||||
/** @var string $productGroup */
|
||||
protected $productGroup = '';
|
||||
|
||||
/** @var string $costIndicator */
|
||||
protected $costIndicator = '';
|
||||
|
||||
/** @var string $orderAmount */
|
||||
protected $orderAmount = '';
|
||||
|
||||
/** @var string $creatorReferenceNumber */
|
||||
protected $creatorReferenceNumber = '';
|
||||
|
||||
/** @var string $referenceNumber */
|
||||
protected $referenceNumber = '';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProcessingFlag(): string
|
||||
{
|
||||
return $this->processingFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getArticleNumber(): string
|
||||
{
|
||||
return $this->articleNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getArticleNumberNew(): string
|
||||
{
|
||||
return $this->articleNumberNew;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExpirationDate(): string
|
||||
{
|
||||
return $this->expirationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMatchcode(): string
|
||||
{
|
||||
return $this->matchcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAltArticleNumber(): string
|
||||
{
|
||||
return $this->altArticleNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCopperWeightIndicator(): string
|
||||
{
|
||||
return $this->copperWeightIndicator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCopperRawPrice(): string
|
||||
{
|
||||
return $this->copperRawPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCopperWeight(): string
|
||||
{
|
||||
return $this->copperWeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEan(): string
|
||||
{
|
||||
return $this->ean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getGraphicNumber(): string
|
||||
{
|
||||
return $this->graphicNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProductGroup(): string
|
||||
{
|
||||
return $this->productGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCostIndicator(): string
|
||||
{
|
||||
return $this->costIndicator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOrderAmount(): string
|
||||
{
|
||||
return $this->orderAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCreatorReferenceNumber(): string
|
||||
{
|
||||
return $this->creatorReferenceNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReferenceNumber(): string
|
||||
{
|
||||
return $this->referenceNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $processingFlag
|
||||
*/
|
||||
public function setProcessingFlag(string $processingFlag): void
|
||||
{
|
||||
$this->processingFlag = $processingFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $articleNumber
|
||||
*/
|
||||
public function setArticleNumber(string $articleNumber): void
|
||||
{
|
||||
$this->articleNumber = $articleNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $articleNumberNew
|
||||
*/
|
||||
public function setArticleNumberNew(string $articleNumberNew): void
|
||||
{
|
||||
$this->articleNumberNew = $articleNumberNew;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expirationDate
|
||||
*/
|
||||
public function setExpirationDate(string $expirationDate): void
|
||||
{
|
||||
$this->expirationDate = $expirationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $matchcode
|
||||
*/
|
||||
public function setMatchcode(string $matchcode): void
|
||||
{
|
||||
$this->matchcode = $matchcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $altArticleNumber
|
||||
*/
|
||||
public function setAltArticleNumber(string $altArticleNumber): void
|
||||
{
|
||||
$this->altArticleNumber = $altArticleNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $copperWeightIndicator
|
||||
*/
|
||||
public function setCopperWeightIndicator(string $copperWeightIndicator): void
|
||||
{
|
||||
$this->copperWeightIndicator = $copperWeightIndicator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $copperRawPrice
|
||||
*/
|
||||
public function setCopperRawPrice(string $copperRawPrice): void
|
||||
{
|
||||
$this->copperRawPrice = $copperRawPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $copperWeight
|
||||
*/
|
||||
public function setCopperWeight(string $copperWeight): void
|
||||
{
|
||||
$this->copperWeight = $copperWeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $ean
|
||||
*/
|
||||
public function setEan(string $ean): void
|
||||
{
|
||||
$this->ean = $ean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $graphicNumber
|
||||
*/
|
||||
public function setGraphicNumber(string $graphicNumber): void
|
||||
{
|
||||
$this->graphicNumber = $graphicNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $productGroup
|
||||
*/
|
||||
public function setProductGroup(string $productGroup): void
|
||||
{
|
||||
$this->productGroup = $productGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $costIndicator
|
||||
*/
|
||||
public function setCostIndicator(string $costIndicator): void
|
||||
{
|
||||
$this->costIndicator = $costIndicator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $orderAmount
|
||||
*/
|
||||
public function setOrderAmount(string $orderAmount): void
|
||||
{
|
||||
$this->orderAmount = $orderAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $creatorReferenceNumber
|
||||
*/
|
||||
public function setCreatorReferenceNumber(string $creatorReferenceNumber): void
|
||||
{
|
||||
$this->creatorReferenceNumber = $creatorReferenceNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $referenceNumber
|
||||
*/
|
||||
public function setReferenceNumber(string $referenceNumber): void
|
||||
{
|
||||
$this->referenceNumber = $referenceNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'processingFlag' => $this->processingFlag,
|
||||
'articleNumber' => $this->articleNumber,
|
||||
'articleNumberNew' => $this->articleNumberNew,
|
||||
'expirationDate' => $this->expirationDate,
|
||||
'matchcode' => $this->matchcode,
|
||||
'altArticleNumber' => $this->altArticleNumber,
|
||||
'copperWeightIndicator' => $this->copperWeightIndicator,
|
||||
'copperRawPrice' => $this->copperRawPrice,
|
||||
'copperWeight' => $this->copperWeight,
|
||||
'ean' => $this->ean,
|
||||
'graphicNumber' => $this->graphicNumber,
|
||||
'productGroup' => $this->productGroup,
|
||||
'costIndicator' => $this->costIndicator,
|
||||
'orderAmount' => $this->orderAmount,
|
||||
'creatorReferenceNumber' => $this->creatorReferenceNumber,
|
||||
'referenceNumber' => $this->referenceNumber,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*/
|
||||
public function fillByJson(string $data): void
|
||||
{
|
||||
$obj = json_decode($data);
|
||||
|
||||
$this->processingFlag = $obj->processingFlag;
|
||||
$this->articleNumber = $obj->articleNumber;
|
||||
$this->articleNumberNew = $obj->articleNumberNew;
|
||||
$this->expirationDate = $obj->expirationDate;
|
||||
$this->matchcode = $obj->matchcode;
|
||||
$this->altArticleNumber = $obj->altArticleNumber;
|
||||
$this->copperWeightIndicator = $obj->copperWeightIndicator;
|
||||
$this->copperRawPrice = $obj->copperRawPrice;
|
||||
$this->copperWeight = $obj->copperWeight;
|
||||
$this->ean = $obj->ean;
|
||||
$this->graphicNumber = $obj->graphicNumber;
|
||||
$this->productGroup = $obj->productGroup;
|
||||
$this->costIndicator = $obj->costIndicator;
|
||||
$this->orderAmount = $obj->orderAmount;
|
||||
$this->creatorReferenceNumber = $obj->creatorReferenceNumber;
|
||||
$this->referenceNumber = $obj->referenceNumber;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Data;
|
||||
|
||||
final class DatanormDTypeData extends AbstractDatanormTypeData implements DatanormTypeDataInterface
|
||||
{
|
||||
|
||||
/** @var string $processingFlag */
|
||||
private $processingFlag = '';
|
||||
|
||||
/** @var string $articleNumber */
|
||||
private $articleNumber = '';
|
||||
|
||||
/** @var string $lineNumber1 */
|
||||
private $lineNumber1 = '';
|
||||
|
||||
/** @var string $textIndicator1 */
|
||||
private $textIndicator1 = '';
|
||||
|
||||
/** @var string $text1 */
|
||||
private $text1 = '';
|
||||
|
||||
/** @var string $textblockNumber1 */
|
||||
private $textblockNumber1 = '';
|
||||
|
||||
/** @var string $lineNumber2 */
|
||||
private $lineNumber2 = '';
|
||||
|
||||
/** @var string $textIndicator2 */
|
||||
private $textIndicator2 = '';
|
||||
|
||||
/** @var string $text2 */
|
||||
private $text2 = '';
|
||||
|
||||
/** @var string $textblockNumber2 */
|
||||
private $textblockNumber2 = '';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProcessingFlag(): string
|
||||
{
|
||||
return $this->processingFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getArticleNumber(): string
|
||||
{
|
||||
return $this->articleNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLineNumber1(): string
|
||||
{
|
||||
return $this->lineNumber1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTextIndicator1(): string
|
||||
{
|
||||
return $this->textIndicator1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getText1(): string
|
||||
{
|
||||
return $this->text1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTextblockNumber1(): string
|
||||
{
|
||||
return $this->textblockNumber1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLineNumber2(): string
|
||||
{
|
||||
return $this->lineNumber2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTextIndicator2(): string
|
||||
{
|
||||
return $this->textIndicator2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getText2(): string
|
||||
{
|
||||
return $this->text2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTextblockNumber2(): string
|
||||
{
|
||||
return $this->textblockNumber2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $processingFlag
|
||||
*/
|
||||
public function setProcessingFlag($processingFlag): void
|
||||
{
|
||||
$this->processingFlag = $processingFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $articleNumber
|
||||
*/
|
||||
public function setArticleNumber(string $articleNumber): void
|
||||
{
|
||||
$this->articleNumber = $articleNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $lineNumber1
|
||||
*/
|
||||
public function setLineNumber1(string $lineNumber1): void
|
||||
{
|
||||
$this->lineNumber1 = $lineNumber1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $textIndicator1
|
||||
*/
|
||||
public function setTextIndicator1(string $textIndicator1): void
|
||||
{
|
||||
$this->textIndicator1 = $textIndicator1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $text1
|
||||
*/
|
||||
public function setText1(string $text1): void
|
||||
{
|
||||
$this->text1 = $text1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $textblockNumber1
|
||||
*/
|
||||
public function setTextblockNumber1(string $textblockNumber1): void
|
||||
{
|
||||
$this->textblockNumber1 = $textblockNumber1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $lineNumber2
|
||||
*/
|
||||
public function setLineNumber2(string $lineNumber2): void
|
||||
{
|
||||
$this->lineNumber2 = $lineNumber2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $textIndicator2
|
||||
*/
|
||||
public function setTextIndicator2(string $textIndicator2): void
|
||||
{
|
||||
$this->textIndicator2 = $textIndicator2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $text2
|
||||
*/
|
||||
public function setText2(string $text2): void
|
||||
{
|
||||
$this->text2 = $text2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $textblockNumber2
|
||||
*/
|
||||
public function setTextblockNumber2(string $textblockNumber2): void
|
||||
{
|
||||
$this->textblockNumber2 = $textblockNumber2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'processingFlag' => $this->processingFlag,
|
||||
'articleNumber' => $this->articleNumber,
|
||||
'lineNumber1' => $this->lineNumber1,
|
||||
'textIndicator1' => $this->textIndicator1,
|
||||
'text1' => $this->text1,
|
||||
'textblockNumber1' => $this->textblockNumber1,
|
||||
'lineNumber2' => $this->lineNumber2,
|
||||
'textIndicator2' => $this->textIndicator2,
|
||||
'text2' => $this->text2,
|
||||
'textblockNumber2' => $this->textblockNumber2,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*/
|
||||
public function fillByJson(string $data): void
|
||||
{
|
||||
$obj = json_decode($data);
|
||||
|
||||
$this->processingFlag = $obj->processingFlag;
|
||||
$this->articleNumber = $obj->articleNumber;
|
||||
$this->lineNumber1 = $obj->lineNumber1;
|
||||
$this->textIndicator1 = $obj->textIndicator1;
|
||||
$this->text1 = $obj->text1;
|
||||
$this->textblockNumber1 = $obj->textblockNumber1;
|
||||
$this->lineNumber2 = $obj->lineNumber2;
|
||||
$this->textIndicator2 = $obj->textIndicator2;
|
||||
$this->text2 = $obj->text2;
|
||||
$this->textblockNumber2 = $obj->textblockNumber2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,698 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Data;
|
||||
|
||||
final class DatanormPTypeData extends AbstractDatanormTypeData implements DatanormTypeDataInterface
|
||||
{
|
||||
/** @var string $discountGroup */
|
||||
protected $discountGroup = ''; //nur V5
|
||||
|
||||
/** @var string $articleNumber1 */
|
||||
protected $articleNumber1 = '';
|
||||
|
||||
/** @var string $priceMark1 */
|
||||
protected $priceMark1 = '';
|
||||
|
||||
/** @var int $priceAmount1 */
|
||||
protected $priceAmount1 = 0;
|
||||
|
||||
/** @var float $price1 */
|
||||
protected $price1 = 0.0;
|
||||
|
||||
/** @var string $discountKey1a */
|
||||
protected $discountKey1a = '';
|
||||
|
||||
/** @var float $discount1a */
|
||||
protected $discount1a = '';
|
||||
|
||||
/** @var string $discountGroup */
|
||||
protected $discountKey1b = '';
|
||||
|
||||
/** @var float $discount1b */
|
||||
protected $discount1b = '';
|
||||
|
||||
/** @var string $discountKey1c */
|
||||
protected $discountKey1c = '';
|
||||
|
||||
/** @var float $discount1c */
|
||||
protected $discount1c = '';
|
||||
|
||||
/** @var string $validFromDate */
|
||||
protected $validFromDate = '';
|
||||
|
||||
/** @var string $articleNumber2 */
|
||||
protected $articleNumber2 = '';
|
||||
|
||||
/** @var string $priceMark2 */
|
||||
protected $priceMark2 = '';
|
||||
|
||||
/** @var int $priceAmount2 */
|
||||
protected $priceAmount2 = 0;
|
||||
|
||||
/** @var float $price2 */
|
||||
protected $price2 = 0.0;
|
||||
|
||||
/** @var string $discountKey2a */
|
||||
protected $discountKey2a = '';
|
||||
|
||||
/** @var float $discount2a */
|
||||
protected $discount2a = '';
|
||||
|
||||
/** @var string $discountKey2b */
|
||||
protected $discountKey2b = '';
|
||||
|
||||
/** @var float $discount2b */
|
||||
protected $discount2b = '';
|
||||
|
||||
/** @var string $discountKey2c */
|
||||
protected $discountKey2c = '';
|
||||
|
||||
/** @var float $discount2c */
|
||||
protected $discount2c = '';
|
||||
|
||||
/** @var string $articleNumber3 */
|
||||
protected $articleNumber3 = '';
|
||||
|
||||
/** @var string $discountGroup */
|
||||
protected $priceMark3 = '';
|
||||
|
||||
/** @var int $priceAmount3 */
|
||||
protected $priceAmount3 = 0;
|
||||
|
||||
/** @var float $price3 */
|
||||
protected $price3 = 0.0;
|
||||
|
||||
/** @var string $discountKey3a */
|
||||
protected $discountKey3a = '';
|
||||
|
||||
/** @var float $discount3a */
|
||||
protected $discount3a = '';
|
||||
|
||||
/** @var string $discountKey3b */
|
||||
protected $discountKey3b = '';
|
||||
|
||||
/** @var float $discount3b */
|
||||
protected $discount3b = '';
|
||||
|
||||
/** @var string $discountKey3c */
|
||||
protected $discountKey3c = '';
|
||||
|
||||
/** @var float $discount3c */
|
||||
protected $discount3c = '';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscountGroup(): string
|
||||
{
|
||||
return $this->discountGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $discountGroup
|
||||
*/
|
||||
public function setDiscountGroup(string $discountGroup): void
|
||||
{
|
||||
$this->discountGroup = $discountGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getArticleNumber1(): string
|
||||
{
|
||||
return $this->articleNumber1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $articleNumber1
|
||||
*/
|
||||
public function setArticleNumber1(string $articleNumber1): void
|
||||
{
|
||||
$this->articleNumber1 = $articleNumber1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPriceMark1(): string
|
||||
{
|
||||
return $this->priceMark1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $priceMark1
|
||||
*/
|
||||
public function setPriceMark1(string $priceMark1): void
|
||||
{
|
||||
$this->priceMark1 = $priceMark1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPriceAmount1(): int
|
||||
{
|
||||
return $this->priceAmount1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $priceAmount1
|
||||
*/
|
||||
public function setPriceAmount1(int $priceAmount1): void
|
||||
{
|
||||
$this->priceAmount1 = $priceAmount1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getPrice1(): float
|
||||
{
|
||||
return $this->price1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $price1
|
||||
*/
|
||||
public function setPrice1(float $price1): void
|
||||
{
|
||||
$this->price1 = $price1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscountKey1a(): string
|
||||
{
|
||||
return $this->discountKey1a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $discountKey1a
|
||||
*/
|
||||
public function setDiscountKey1a(string $discountKey1a): void
|
||||
{
|
||||
$this->discountKey1a = $discountKey1a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount1a(): float
|
||||
{
|
||||
return $this->discount1a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $discount1a
|
||||
*/
|
||||
public function setDiscount1a(float $discount1a): void
|
||||
{
|
||||
$this->discount1a = $discount1a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscountKey1b(): string
|
||||
{
|
||||
return $this->discountKey1b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $discountKey1b
|
||||
*/
|
||||
public function setDiscountKey1b(string $discountKey1b): void
|
||||
{
|
||||
$this->discountKey1b = $discountKey1b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount1b(): float
|
||||
{
|
||||
return $this->discount1b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $discount1b
|
||||
*/
|
||||
public function setDiscount1b(float $discount1b): void
|
||||
{
|
||||
$this->discount1b = $discount1b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscountKey1c(): string
|
||||
{
|
||||
return $this->discountKey1c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $discountKey1c
|
||||
*/
|
||||
public function setDiscountKey1c(string $discountKey1c): void
|
||||
{
|
||||
$this->discountKey1c = $discountKey1c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount1c(): float
|
||||
{
|
||||
return $this->discount1c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $discount1c
|
||||
*/
|
||||
public function setDiscount1c(float $discount1c): void
|
||||
{
|
||||
$this->discount1c = $discount1c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValidFromDate(): string
|
||||
{
|
||||
return $this->validFromDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $validFromDate
|
||||
*/
|
||||
public function setValidFromDate(string $validFromDate): void
|
||||
{
|
||||
$this->validFromDate = $validFromDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getArticleNumber2(): string
|
||||
{
|
||||
return $this->articleNumber2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $articleNumber2
|
||||
*/
|
||||
public function setArticleNumber2(string $articleNumber2): void
|
||||
{
|
||||
$this->articleNumber2 = $articleNumber2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPriceMark2(): string
|
||||
{
|
||||
return $this->priceMark2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $priceMark2
|
||||
*/
|
||||
public function setPriceMark2(string $priceMark2): void
|
||||
{
|
||||
$this->priceMark2 = $priceMark2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPriceAmount2(): int
|
||||
{
|
||||
return $this->priceAmount2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $priceAmount2
|
||||
*/
|
||||
public function setPriceAmount2(int $priceAmount2): void
|
||||
{
|
||||
$this->priceAmount2 = $priceAmount2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getPrice2(): float
|
||||
{
|
||||
return $this->price2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $price2
|
||||
*/
|
||||
public function setPrice2(float $price2): void
|
||||
{
|
||||
$this->price2 = $price2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscountKey2a(): string
|
||||
{
|
||||
return $this->discountKey2a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $discountKey2a
|
||||
*/
|
||||
public function setDiscountKey2a(string $discountKey2a): void
|
||||
{
|
||||
$this->discountKey2a = $discountKey2a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount2a(): float
|
||||
{
|
||||
return $this->discount2a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $discount2a
|
||||
*/
|
||||
public function setDiscount2a(float $discount2a): void
|
||||
{
|
||||
$this->discount2a = $discount2a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscountKey2b(): string
|
||||
{
|
||||
return $this->discountKey2b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $discountKey2b
|
||||
*/
|
||||
public function setDiscountKey2b(string $discountKey2b): void
|
||||
{
|
||||
$this->discountKey2b = $discountKey2b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount2b(): float
|
||||
{
|
||||
return $this->discount2b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $discount2b
|
||||
*/
|
||||
public function setDiscount2b(float $discount2b): void
|
||||
{
|
||||
$this->discount2b = $discount2b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscountKey2c(): string
|
||||
{
|
||||
return $this->discountKey2c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $discountKey2c
|
||||
*/
|
||||
public function setDiscountKey2c(string $discountKey2c): void
|
||||
{
|
||||
$this->discountKey2c = $discountKey2c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount2c(): float
|
||||
{
|
||||
return $this->discount2c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $discount2c
|
||||
*/
|
||||
public function setDiscount2c(float $discount2c): void
|
||||
{
|
||||
$this->discount2c = $discount2c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getArticleNumber3(): string
|
||||
{
|
||||
return $this->articleNumber3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $articleNumber3
|
||||
*/
|
||||
public function setArticleNumber3(string $articleNumber3): void
|
||||
{
|
||||
$this->articleNumber3 = $articleNumber3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPriceMark3(): string
|
||||
{
|
||||
return $this->priceMark3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $priceMark3
|
||||
*/
|
||||
public function setPriceMark3(string $priceMark3): void
|
||||
{
|
||||
$this->priceMark3 = $priceMark3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPriceAmount3(): int
|
||||
{
|
||||
return $this->priceAmount3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $priceAmount3
|
||||
*/
|
||||
public function setPriceAmount3(int $priceAmount3): void
|
||||
{
|
||||
$this->priceAmount3 = $priceAmount3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getPrice3(): float
|
||||
{
|
||||
return $this->price3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $price3
|
||||
*/
|
||||
public function setPrice3(float $price3): void
|
||||
{
|
||||
$this->price3 = $price3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscountKey3a(): string
|
||||
{
|
||||
return $this->discountKey3a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $discountKey3a
|
||||
*/
|
||||
public function setDiscountKey3a(string $discountKey3a): void
|
||||
{
|
||||
$this->discountKey3a = $discountKey3a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount3a(): float
|
||||
{
|
||||
return $this->discount3a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $discount3a
|
||||
*/
|
||||
public function setDiscount3a(float $discount3a): void
|
||||
{
|
||||
$this->discount3a = $discount3a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscountKey3b(): string
|
||||
{
|
||||
return $this->discountKey3b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $discountKey3b
|
||||
*/
|
||||
public function setDiscountKey3b(string $discountKey3b): void
|
||||
{
|
||||
$this->discountKey3b = $discountKey3b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount3b(): float
|
||||
{
|
||||
return $this->discount3b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $discount3b
|
||||
*/
|
||||
public function setDiscount3b(float $discount3b): void
|
||||
{
|
||||
$this->discount3b = $discount3b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscountKey3c(): string
|
||||
{
|
||||
return $this->discountKey3c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $discountKey3c
|
||||
*/
|
||||
public function setDiscountKey3c(string $discountKey3c): void
|
||||
{
|
||||
$this->discountKey3c = $discountKey3c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount3c(): float
|
||||
{
|
||||
return $this->discount3c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $discount3c
|
||||
*/
|
||||
public function setDiscount3c(float $discount3c): void
|
||||
{
|
||||
$this->discount3c = $discount3c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'discountGroup' => $this->discountGroup,
|
||||
'articleNumber1' => $this->articleNumber1,
|
||||
'priceMark1' => $this->priceMark1,
|
||||
'priceAmount1' => $this->priceAmount1,
|
||||
'price1' => $this->price1,
|
||||
'discountKey1a' => $this->discountKey1a,
|
||||
'discount1a' => $this->discount1a,
|
||||
'discountKey1b' => $this->discountKey1b,
|
||||
'discount1b' => $this->discount1b,
|
||||
'discountKey1c' => $this->discountKey1c,
|
||||
'discount1c' => $this->discount1c,
|
||||
'validFromDate' => $this->validFromDate,
|
||||
'articleNumber2' => $this->articleNumber2,
|
||||
'priceMark2' => $this->priceMark2,
|
||||
'priceAmount2' => $this->priceAmount2,
|
||||
'price2' => $this->price2,
|
||||
'discountKey2a' => $this->discountKey2a,
|
||||
'discount2a' => $this->discount2a,
|
||||
'discountKey2b' => $this->discountKey2b,
|
||||
'discount2b' => $this->discount2b,
|
||||
'discountKey2c' => $this->discountKey2c,
|
||||
'discount2c' => $this->discount2c,
|
||||
'articleNumber3' => $this->articleNumber3,
|
||||
'priceMark3' => $this->priceMark3,
|
||||
'priceAmount3' => $this->priceAmount3,
|
||||
'price3' => $this->price3,
|
||||
'discountKey3a' => $this->discountKey3a,
|
||||
'discount3a' => $this->discount3a,
|
||||
'discountKey3b' => $this->discountKey3b,
|
||||
'discount3b' => $this->discount3b,
|
||||
'discountKey3c' => $this->discountKey3c,
|
||||
'discount3c' => $this->discount3c,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*/
|
||||
public function fillByJson(string $data): void
|
||||
{
|
||||
$obj = json_decode($data);
|
||||
|
||||
$this->discountGroup = $obj->discountGroup;
|
||||
$this->articleNumber1 = $obj->articleNumber1;
|
||||
$this->priceMark1 = $obj->priceMark1;
|
||||
$this->priceAmount1 = (int)$obj->priceAmount1;
|
||||
$this->price1 = (float)$obj->price1;
|
||||
$this->discountKey1a = $obj->discountKey1a;
|
||||
$this->discount1a = (float)$obj->discount1a;
|
||||
$this->discountKey1b = $obj->discountKey1b;
|
||||
$this->discount1b = (float)$obj->discount1b;
|
||||
$this->discountKey1c = $obj->discountKey1c;
|
||||
$this->discount1c = (float)$obj->discount1c;
|
||||
$this->validFromDate = $obj->validFromDate;
|
||||
$this->articleNumber2 = $obj->articleNumber2;
|
||||
$this->priceMark2 = $obj->priceMark2;
|
||||
$this->priceAmount2 = (int)$obj->priceAmount2;
|
||||
$this->price2 = (float)$obj->price2;
|
||||
$this->discountKey2a = $obj->discountKey2a;
|
||||
$this->discount2a = (float)$obj->discount2a;
|
||||
$this->discountKey2b = $obj->discountKey2b;
|
||||
$this->discount2b = (float)$obj->discount2b;
|
||||
$this->discountKey2c = $obj->discountKey2c;
|
||||
$this->discount2c = (float)$obj->discount2c;
|
||||
$this->articleNumber3 = $obj->articleNumber3;
|
||||
$this->priceMark3 = $obj->priceMark3;
|
||||
$this->priceAmount3 = (int)$obj->priceAmount3;
|
||||
$this->price3 = (float)$obj->price3;
|
||||
$this->discountKey3a = $obj->discountKey3a;
|
||||
$this->discount3a = (float)$obj->discount3a;
|
||||
$this->discountKey3b = $obj->discountKey3b;
|
||||
$this->discount3b = (float)$obj->discount3b;
|
||||
$this->discountKey3c = $obj->discountKey3c;
|
||||
$this->discount3c = (float)$obj->discount3c;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Data;
|
||||
|
||||
final class DatanormTTypeData extends AbstractDatanormTypeData implements DatanormTypeDataInterface
|
||||
{
|
||||
/** @var string $processingFlag */
|
||||
private $processingFlag = '';
|
||||
|
||||
/** @var string $textnumber */
|
||||
private $textnumber = '';
|
||||
|
||||
/** @var string $indicator */
|
||||
private $indicator = '';
|
||||
|
||||
/** @var string $linenumber1 */
|
||||
private $linenumber1 = '';
|
||||
|
||||
/** @var string $text1 */
|
||||
private $text1 = '';
|
||||
|
||||
/** @var string $linenumber2 */
|
||||
private $linenumber2 = '';
|
||||
|
||||
/** @var string $text2 */
|
||||
private $text2 = '';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProcessingFlag()
|
||||
{
|
||||
return $this->processingFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTextnumber()
|
||||
{
|
||||
return $this->textnumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIndicator()
|
||||
{
|
||||
return $this->indicator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLinenumber1()
|
||||
{
|
||||
return $this->linenumber1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getText1()
|
||||
{
|
||||
return $this->text1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLinenumber2()
|
||||
{
|
||||
return $this->linenumber2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getText2()
|
||||
{
|
||||
return $this->text2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $processingFlag
|
||||
*/
|
||||
public function setProcessingFlag(string $processingFlag): void
|
||||
{
|
||||
$this->processingFlag = $processingFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $textnumber
|
||||
*/
|
||||
public function setTextnumber(string $textnumber): void
|
||||
{
|
||||
$this->textnumber = $textnumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $indicator
|
||||
*/
|
||||
public function setIndicator(string $indicator): void
|
||||
{
|
||||
$this->indicator = $indicator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $linenumber1
|
||||
*/
|
||||
public function setLinenumber1(string $linenumber1): void
|
||||
{
|
||||
$this->linenumber1 = $linenumber1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $text1
|
||||
*/
|
||||
public function setText1(string $text1): void
|
||||
{
|
||||
$this->text1 = $text1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $linenumber2
|
||||
*/
|
||||
public function setLinenumber2(string $linenumber2): void
|
||||
{
|
||||
$this->linenumber2 = $linenumber2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $text2
|
||||
*/
|
||||
public function setText2(string $text2): void
|
||||
{
|
||||
$this->text2 = $text2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'processingFlag' => $this->processingFlag,
|
||||
'textnumber' => $this->textnumber,
|
||||
'indicator' => $this->indicator,
|
||||
'linenumber1' => $this->linenumber1,
|
||||
'text1' => $this->text1,
|
||||
'linenumber2' => $this->linenumber2,
|
||||
'text2' => $this->text2,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*/
|
||||
public function fillByJson(string $data): void
|
||||
{
|
||||
$obj = json_decode($data);
|
||||
|
||||
$this->processingFlag = $obj->processingFlag;
|
||||
$this->textnumber = $obj->textnumber;
|
||||
$this->indicator = $obj->indicator;
|
||||
$this->linenumber1 = $obj->linenumber1;
|
||||
$this->text1 = $obj->text1;
|
||||
$this->linenumber2 = $obj->linenumber2;
|
||||
$this->text2 = $obj->text2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Data;
|
||||
|
||||
interface DatanormTypeDataInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize();
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*/
|
||||
public function fillByJson(string $data): void;
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Data;
|
||||
|
||||
final class DatanormVTypeData extends AbstractDatanormTypeData implements DatanormTypeDataInterface
|
||||
{
|
||||
|
||||
/** @var string $dataMark */
|
||||
protected $dataMark = '';
|
||||
|
||||
/** @var string $date */
|
||||
protected $date = '';
|
||||
|
||||
/** @var string $currency */
|
||||
protected $currency = '';
|
||||
|
||||
/** @var string $description */
|
||||
protected $description = '';
|
||||
|
||||
/** @var string $producerToken */
|
||||
protected $producerToken = '';
|
||||
|
||||
/** @var string $adress1 */
|
||||
protected $adress1 = '';
|
||||
|
||||
/** @var string $adress2 */
|
||||
protected $adress2 = '';
|
||||
|
||||
/** @var string $adress3 */
|
||||
protected $adress3 = '';
|
||||
|
||||
/** @var string $street */
|
||||
protected $street = '';
|
||||
|
||||
/** @var string $countryId */
|
||||
protected $countryId = '';
|
||||
|
||||
/** @var string $zip */
|
||||
protected $zip = '';
|
||||
|
||||
/** @var string $city */
|
||||
protected $city = '';
|
||||
|
||||
/** @var int $userAddressId */
|
||||
protected $userAddressId;
|
||||
|
||||
/** @var int $supplierAddressId */
|
||||
protected $supplierAddressId;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDataMark(): string
|
||||
{
|
||||
return $this->dataMark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAdress3(): string
|
||||
{
|
||||
return $this->adress3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProducerToken(): string
|
||||
{
|
||||
return $this->producerToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDate(): string
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrency(): string
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAdress1(): string
|
||||
{
|
||||
return $this->adress1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAdress2(): string
|
||||
{
|
||||
return $this->adress2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStreet(): string
|
||||
{
|
||||
return $this->street;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCountryId(): string
|
||||
{
|
||||
return $this->countryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getZip(): string
|
||||
{
|
||||
return $this->zip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCity(): string
|
||||
{
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getUserAddressId(): int
|
||||
{
|
||||
return $this->userAddressId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSupplierAddressId(): int
|
||||
{
|
||||
return $this->supplierAddressId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dataMark
|
||||
*/
|
||||
public function setDataMark(string $dataMark): void
|
||||
{
|
||||
$this->dataMark = $dataMark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $date
|
||||
*/
|
||||
public function setDate(string $date): void
|
||||
{
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $currency
|
||||
*/
|
||||
public function setCurrency(string $currency): void
|
||||
{
|
||||
$this->currency = $currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
*/
|
||||
public function setDescription(string $description): void
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $adress1
|
||||
*/
|
||||
public function setAdress1(string $adress1): void
|
||||
{
|
||||
$this->adress1 = $adress1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $adress2
|
||||
*/
|
||||
public function setAdress2(string $adress2): void
|
||||
{
|
||||
$this->adress2 = $adress2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $street
|
||||
*/
|
||||
public function setStreet(string $street): void
|
||||
{
|
||||
$this->street = $street;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $countryId
|
||||
*/
|
||||
public function setCountryId(string $countryId): void
|
||||
{
|
||||
$this->countryId = $countryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $zip
|
||||
*/
|
||||
public function setZip(string $zip): void
|
||||
{
|
||||
$this->zip = $zip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $city
|
||||
*/
|
||||
public function setCity(string $city): void
|
||||
{
|
||||
$this->city = $city;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $producerToken
|
||||
*/
|
||||
public function setProducerToken(string $producerToken): void
|
||||
{
|
||||
$this->producerToken = $producerToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $adress3
|
||||
*/
|
||||
public function setAdress3(string $adress3): void
|
||||
{
|
||||
$this->adress3 = $adress3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userAddressId
|
||||
*/
|
||||
public function setUserAddressId(int $userAddressId): void
|
||||
{
|
||||
$this->userAddressId = $userAddressId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $supplierAddressId
|
||||
*/
|
||||
public function setSupplierAddressId(int $supplierAddressId): void
|
||||
{
|
||||
$this->supplierAddressId = $supplierAddressId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'dataMark' => $this->dataMark,
|
||||
'date' => $this->date,
|
||||
'currency' => $this->currency,
|
||||
'description' => $this->description,
|
||||
'adress1' => $this->adress1,
|
||||
'adress2' => $this->adress2,
|
||||
'adress3' => $this->adress3,
|
||||
'street' => $this->street,
|
||||
'countryId' => $this->countryId,
|
||||
'zip' => $this->zip,
|
||||
'city' => $this->city,
|
||||
'producerToken' => $this->producerToken,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*/
|
||||
public function fillByJson(string $data): void
|
||||
{
|
||||
$obj = json_decode($data);
|
||||
|
||||
$this->dataMark = $obj->dataMark;
|
||||
$this->date = $obj->date;
|
||||
$this->currency = $obj->currency;
|
||||
$this->description = $obj->description;
|
||||
$this->adress1 = $obj->adress1;
|
||||
$this->adress2 = $obj->adress2;
|
||||
$this->adress3 = $obj->adress3;
|
||||
$this->street = $obj->street;
|
||||
$this->countryId = $obj->countryId;
|
||||
$this->zip = $obj->zip;
|
||||
$this->city = $obj->city;
|
||||
$this->producerToken = $obj->producerToken;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm;
|
||||
|
||||
use Xentral\Components\Database\Exception\QueryFailureException;
|
||||
use Xentral\Modules\Article\Service\PurchasePriceService;
|
||||
use Xentral\Modules\Article\Service\SellingPriceService;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormATypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormBTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormPTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormVTypeData;
|
||||
use Xentral\Modules\Datanorm\Exception\ArticleNotFoundException;
|
||||
use Xentral\Modules\Datanorm\Exception\InvalidArgumentException;
|
||||
use Xentral\Modules\Datanorm\Service\ArticleService;
|
||||
use Xentral\Modules\Datanorm\Service\DatanormEnricher;
|
||||
use Xentral\Modules\Datanorm\Service\DatanormIntermediateGateway;
|
||||
use Xentral\Modules\Datanorm\Service\DatanormIntermediateService;
|
||||
use Xentral\Modules\Datanorm\Service\DatanormConverter;
|
||||
use Xentral\Modules\Datanorm\Wrapper\AddressWrapper;
|
||||
|
||||
|
||||
final class DatanormImporter
|
||||
{
|
||||
/** @var DatanormIntermediateService $intermediateService */
|
||||
private $intermediateService;
|
||||
|
||||
/** @var DatanormIntermediateGateway $intermediateGateway */
|
||||
private $intermediateGateway;
|
||||
|
||||
/** @var DatanormConverter $datanormConverter */
|
||||
private $datanormConverter;
|
||||
|
||||
/** @var ArticleService $articleService */
|
||||
private $articleService;
|
||||
|
||||
/** @var SellingPriceService $sellingPriceService */
|
||||
private $sellingPriceService;
|
||||
|
||||
/** @var PurchasePriceService $purchasePriceService */
|
||||
private $purchasePriceService;
|
||||
|
||||
/** @var AddressWrapper $addressWrapper */
|
||||
private $addressWrapper;
|
||||
|
||||
/** @var DatanormEnricher $enricher */
|
||||
private $enricher;
|
||||
|
||||
/**
|
||||
* @param DatanormIntermediateService $intermediateService
|
||||
* @param DatanormIntermediateGateway $intermediateGateway
|
||||
* @param DatanormConverter $datanormTransformer
|
||||
* @param ArticleService $articleService
|
||||
* @param SellingPriceService $sellingPriceService
|
||||
* @param PurchasePriceService $purchasePriceService
|
||||
* @param AddressWrapper $addressWrapper
|
||||
* @param DatanormEnricher $enrichService
|
||||
*/
|
||||
public function __construct(
|
||||
DatanormIntermediateService $intermediateService,
|
||||
DatanormIntermediateGateway $intermediateGateway,
|
||||
DatanormConverter $datanormTransformer,
|
||||
ArticleService $articleService,
|
||||
SellingPriceService $sellingPriceService,
|
||||
PurchasePriceService $purchasePriceService,
|
||||
AddressWrapper $addressWrapper,
|
||||
DatanormEnricher $enrichService
|
||||
) {
|
||||
$this->intermediateService = $intermediateService;
|
||||
$this->intermediateGateway = $intermediateGateway;
|
||||
$this->datanormConverter = $datanormTransformer;
|
||||
$this->articleService = $articleService;
|
||||
$this->sellingPriceService = $sellingPriceService;
|
||||
$this->purchasePriceService = $purchasePriceService;
|
||||
$this->addressWrapper = $addressWrapper;
|
||||
$this->enricher = $enrichService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasLines(): bool
|
||||
{
|
||||
return !empty($this->intermediateGateway->getLines(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*
|
||||
* @throws ArticleNotFoundException
|
||||
* @throws QueryFailureException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function handleLines(int $limit): void
|
||||
{
|
||||
$sellingPrices = [];
|
||||
$purchasePrices = [];
|
||||
$lastFileName = '';
|
||||
$doneIds = [];
|
||||
|
||||
$headData = null;
|
||||
$head = null;
|
||||
$supplierId = null;
|
||||
|
||||
$intermediateDatas = $this->intermediateGateway->getLines($limit);
|
||||
|
||||
foreach ($intermediateDatas as $intermediateData) {
|
||||
|
||||
$type = $intermediateData['type'];
|
||||
$content = $intermediateData['content'];
|
||||
$fileName = $intermediateData['fileName'];
|
||||
|
||||
if ($lastFileName !== $fileName) {
|
||||
$head = $this->getHeadLine(
|
||||
$this->intermediateGateway->getVType($fileName)
|
||||
);
|
||||
$supplierId = $head->getSupplierAddressId();
|
||||
if(empty($supplierId)){
|
||||
$supplierId = $this->addressWrapper->insertSupplierIfNotExists($head);
|
||||
}
|
||||
$lastFileName = $fileName;
|
||||
}
|
||||
|
||||
if ($type === 'A') {
|
||||
$aType = new DatanormATypeData();
|
||||
$aType->fillByJson($content);
|
||||
$articleArray = $this->datanormConverter->transformATypeToArticleArray($aType);
|
||||
|
||||
$articleId = $this->articleService->InsertUpdateArticle($articleArray);
|
||||
|
||||
if (!empty($aType->getPrice())) {
|
||||
$prices = $this->datanormConverter->transformToPriceArray(
|
||||
$articleId,
|
||||
$aType->getPriceMark(),
|
||||
$head->getCurrency(),
|
||||
$aType->getPriceAmount(),
|
||||
$aType->getPrice(),
|
||||
$supplierId,
|
||||
'',
|
||||
0,
|
||||
'',
|
||||
0,
|
||||
'',
|
||||
0
|
||||
);
|
||||
if (!empty($prices['sellingPrice'])) {
|
||||
$sellingPrices[] = $prices['sellingPrice'];
|
||||
}
|
||||
if (!empty($prices['purchasePrices'])) {
|
||||
foreach ($prices['purchasePrices'] as $purchasePrice) {
|
||||
$purchasePrices[] = $purchasePrice;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($type === 'P') {
|
||||
$pType = new DatanormPTypeData();
|
||||
$pType->fillByJson($content);
|
||||
|
||||
$articleId = $this->articleService->findArticleIdByNumber($pType->getArticleNumber1());
|
||||
|
||||
if (!empty($articleId)) {
|
||||
$prices = $this->datanormConverter->transformToPriceArray(
|
||||
$articleId,
|
||||
$pType->getPriceMark1(),
|
||||
$head->getCurrency(),
|
||||
$pType->getPriceAmount1(),
|
||||
$pType->getPrice1(),
|
||||
$supplierId,
|
||||
$pType->getDiscountKey1a(),
|
||||
$pType->getDiscount1a(),
|
||||
$pType->getDiscountKey1b(),
|
||||
$pType->getDiscount1b(),
|
||||
$pType->getDiscountKey1c(),
|
||||
$pType->getDiscount1c()
|
||||
);
|
||||
if (!empty($prices['sellingPrice'])) {
|
||||
$sellingPrices[] = $prices['sellingPrice'];
|
||||
}
|
||||
if (!empty($prices['purchasePrices'])) {
|
||||
foreach ($prices['purchasePrices'] as $purchasePrice) {
|
||||
$purchasePrices[] = $purchasePrice;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ArticleNotFoundException(
|
||||
'The article with the number ' . $pType->getArticleNumber1() . ' was not found.'
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($pType->getArticleNumber2())) {
|
||||
$articleId = $this->articleService->findArticleIdByNumber($pType->getArticleNumber2());
|
||||
|
||||
if (!empty($articleId)) {
|
||||
$prices = $this->datanormConverter->transformToPriceArray(
|
||||
$articleId,
|
||||
$pType->getPriceMark2(),
|
||||
$head->getCurrency(),
|
||||
$pType->getPriceAmount2(),
|
||||
$pType->getPrice2(),
|
||||
$supplierId,
|
||||
$pType->getDiscountKey2a(),
|
||||
$pType->getDiscount2a(),
|
||||
$pType->getDiscountKey2b(),
|
||||
$pType->getDiscount2b(),
|
||||
$pType->getDiscountKey2c(),
|
||||
$pType->getDiscount2c()
|
||||
);
|
||||
if (!empty($prices['sellingPrice'])) {
|
||||
$sellingPrices[] = $prices['sellingPrice'];
|
||||
}
|
||||
if (!empty($prices['purchasePrices'])) {
|
||||
foreach ($prices['purchasePrices'] as $purchasePrice) {
|
||||
$purchasePrices[] = $purchasePrice;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ArticleNotFoundException(
|
||||
'The article with the number ' . $pType->getArticleNumber2() . ' was not found.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($pType->getArticleNumber3())) {
|
||||
$articleId = $this->articleService->findArticleIdByNumber($pType->getArticleNumber3());
|
||||
|
||||
if (!empty($articleId)) {
|
||||
$prices = $this->datanormConverter->transformToPriceArray(
|
||||
$articleId,
|
||||
$pType->getPriceMark3(),
|
||||
$head->getCurrency(),
|
||||
$pType->getPriceAmount3(),
|
||||
$pType->getPrice3(),
|
||||
$supplierId,
|
||||
$pType->getDiscountKey3a(),
|
||||
$pType->getDiscount3a(),
|
||||
$pType->getDiscountKey3b(),
|
||||
$pType->getDiscount3b(),
|
||||
$pType->getDiscountKey3c(),
|
||||
$pType->getDiscount3c()
|
||||
);
|
||||
if (!empty($prices['sellingPrice'])) {
|
||||
$sellingPrices[] = $prices['sellingPrice'];
|
||||
}
|
||||
if (!empty($prices['purchasePrices'])) {
|
||||
foreach ($prices['purchasePrices'] as $purchasePrice) {
|
||||
$purchasePrices[] = $purchasePrice;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ArticleNotFoundException(
|
||||
'The article with the number ' . $pType->getArticleNumber3() . ' was not found.'
|
||||
);
|
||||
}
|
||||
}
|
||||
} elseif ($type === 'B') {
|
||||
$bType = new DatanormBTypeData();
|
||||
$bType->fillByJson($content);
|
||||
|
||||
$articleArray = $this->datanormConverter->transformBTypeToArticleArray($bType);
|
||||
if (!empty($articleArray)) {
|
||||
$this->articleService->InsertUpdateArticle($articleArray);
|
||||
}
|
||||
}
|
||||
|
||||
$doneIds[] = $intermediateData['id'];
|
||||
}
|
||||
|
||||
if (!empty($doneIds)) {
|
||||
$this->intermediateService->setMultipleDone($doneIds);
|
||||
}
|
||||
|
||||
if (!empty($sellingPrices)) {
|
||||
$this->sellingPriceService->setStandardPriceByArray($sellingPrices);
|
||||
}
|
||||
|
||||
if (!empty($purchasePrices)) {
|
||||
$this->purchasePriceService->setPurchasePriceByArray($purchasePrices);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $headdata
|
||||
*
|
||||
* @return DatanormVTypeData
|
||||
*/
|
||||
private function getHeadLine(array $headdata): DatanormVTypeData
|
||||
{
|
||||
$head = new DatanormVTypeData();
|
||||
$head->fillByJson($headdata['content']);
|
||||
$head->setUserAddressId($headdata['user_address_id']);
|
||||
$head->setSupplierAddressId($headdata['supplier_address_id']);
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkFilesEnrichState(): bool
|
||||
{
|
||||
$lines = $this->intermediateGateway->getLinesToEnrich(1);
|
||||
if (count($lines) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*/
|
||||
public function enrich(int $limit): void
|
||||
{
|
||||
$lines = $this->intermediateGateway->getLinesToEnrich($limit);
|
||||
$enrichData = [];
|
||||
|
||||
if (!empty($lines)) {
|
||||
foreach ($lines as $line) {
|
||||
$type = $line['type'];
|
||||
$content = $line['content'];
|
||||
$id = $line['id'];
|
||||
|
||||
if ($type === 'A') {
|
||||
$aType = new DatanormATypeData();
|
||||
$aType->fillByJson($content);
|
||||
|
||||
$aTypeMod = $this->enricher->enrichArticle($aType);
|
||||
$content = json_encode($aTypeMod);
|
||||
} elseif ($type === 'P') {
|
||||
$pType = new DatanormPTypeData();
|
||||
$pType->fillByJson($content);
|
||||
|
||||
$pTypeMod = $this->enricher->enrichPrice($pType);
|
||||
$content = json_encode($pTypeMod);
|
||||
}
|
||||
|
||||
if (!empty($content)) {
|
||||
$enrichData[$id] = [
|
||||
'content' => $content,
|
||||
'hash' => md5($content),
|
||||
'enrich' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($enrichData)) {
|
||||
$this->intermediateService->saveEnrichData($enrichData);
|
||||
}
|
||||
}
|
||||
|
||||
public function setTAndDTypeDone(): void
|
||||
{
|
||||
$this->intermediateService->setTAndDTypeDone();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $vId
|
||||
* @param string $supplierNumber
|
||||
*/
|
||||
public function saveSupplierToVType(int $vId, string $supplierNumber)
|
||||
{
|
||||
$this->intermediateService->saveSupplierToVType($vId,$supplierNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $vId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function findSupplierNumberByVid(int $vId)
|
||||
{
|
||||
return $this->intermediateGateway->findSupplierNumberByVid($vId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm;
|
||||
|
||||
use Config;
|
||||
use Xentral\Components\Filesystem\FilesystemFactory;
|
||||
use Xentral\Components\Filesystem\FilesystemInterface;
|
||||
use Xentral\Core\LegacyConfig\ConfigLoader;
|
||||
use Xentral\Modules\Datanorm\Handler\DatanormReaderHandlerInterface;
|
||||
use Xentral\Modules\Datanorm\Service\DatanormIntermediateService;
|
||||
use Xentral\Modules\Datanorm\Service\DatanormReader;
|
||||
|
||||
final class DatanormReaderFactory
|
||||
{
|
||||
/** @var DatanormIntermediateService $intermediateService */
|
||||
private $intermediateService;
|
||||
|
||||
/** @var DatanormReaderHandlerInterface[] $readerHandlers */
|
||||
private $readerHandlers;
|
||||
|
||||
/** @var FilesystemFactory $fileSystemFactory */
|
||||
private $fileSystemFactory;
|
||||
|
||||
/**
|
||||
* @param DatanormIntermediateService $intermediateService
|
||||
* @param array $readerHandlers
|
||||
* @param FilesystemFactory $fileSystemFactory
|
||||
*/
|
||||
public function __construct(
|
||||
DatanormIntermediateService $intermediateService,
|
||||
array $readerHandlers,
|
||||
FilesystemFactory $fileSystemFactory
|
||||
) {
|
||||
$this->intermediateService = $intermediateService;
|
||||
$this->readerHandlers = $readerHandlers;
|
||||
$this->fileSystemFactory = $fileSystemFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $uploadDir
|
||||
* @param string $baseDir
|
||||
*
|
||||
* @return DatanormReader
|
||||
*/
|
||||
public function createDatanormReader(string $uploadDir, string $baseDir = ''): DatanormReader
|
||||
{
|
||||
return new DatanormReader(
|
||||
$this->getFileSystem($baseDir),
|
||||
$this->intermediateService,
|
||||
$this->readerHandlers,
|
||||
$uploadDir
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseDir
|
||||
*
|
||||
* @return FilesystemInterface
|
||||
*/
|
||||
private function getFileSystem(string $baseDir = ''): FilesystemInterface
|
||||
{
|
||||
$config = ConfigLoader::load();
|
||||
|
||||
if (empty($baseDir)) {
|
||||
$baseDir = $config->WFuserdata !== null
|
||||
? $config->WFuserdata
|
||||
: dirname(dirname(dirname(__DIR__))) . '/userdata';
|
||||
}
|
||||
|
||||
$fileSystemConfig = [
|
||||
'permissions' => [
|
||||
'file' => [
|
||||
'public' => 0664,
|
||||
'private' => 0664,
|
||||
],
|
||||
'dir' => [
|
||||
'public' => 0775,
|
||||
'private' => 0775,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $this->fileSystemFactory->createLocal($baseDir, $fileSystemConfig);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Exception;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class ArticleNotFoundException extends InvalidArgumentException implements DatanormExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Exception;
|
||||
|
||||
use Xentral\Core\Exception\ModuleExceptionInterface;
|
||||
|
||||
interface DatanormExceptionInterface extends ModuleExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
final class FileSystemException extends RuntimeException implements DatanormExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class InvalidArgumentException extends RuntimeException implements DatanormExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
final class InvalidLineException extends RuntimeException implements DatanormExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Exception;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class LineTypeNotKnownException extends InvalidArgumentException implements DatanormExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Exception;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class NoAddressIdFoundException extends InvalidArgumentException implements DatanormExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Exception;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class WrongDiscountFormatException extends InvalidArgumentException implements DatanormExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Exception;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class WrongPriceFormatException extends InvalidArgumentException implements DatanormExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Exception;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class WrongVersionException extends InvalidArgumentException implements DatanormExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Handler;
|
||||
|
||||
use Xentral\Modules\Datanorm\Exception\WrongDiscountFormatException;
|
||||
use Xentral\Modules\Datanorm\Exception\WrongPriceFormatException;
|
||||
|
||||
class AbstractDatanormReaderHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $price
|
||||
*
|
||||
* @throws WrongPriceFormatException
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
protected function convertPrice(string $price): float
|
||||
{
|
||||
if (empty($price)) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (preg_match('/[^0-9]/', $price)) {
|
||||
throw new WrongPriceFormatException('price has a wrong format: ' . $price);
|
||||
}
|
||||
|
||||
return (float)$price / 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $discountKey
|
||||
* @param string $discount
|
||||
*
|
||||
* @throws WrongDiscountFormatException
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
protected function convertDiscount(string $discountKey, string $discount): float
|
||||
{
|
||||
if (preg_match('/[^0-9]/', $discount)) {
|
||||
throw new WrongDiscountFormatException('discount has a wrong format: ' . $discount);
|
||||
}
|
||||
|
||||
// Discount
|
||||
if ($discountKey === '1') {
|
||||
$formatted = (float)$discount / 100;
|
||||
} // Factor
|
||||
elseif ($discountKey === '2') {
|
||||
$formatted = (float)$discount / 1000;
|
||||
} // Surcharge
|
||||
elseif ($discountKey === '3') {
|
||||
$formatted = (float)$discount / 100;
|
||||
} else {
|
||||
throw new WrongDiscountFormatException(
|
||||
'DiscountKey has wrong format. Only 1,2,3 are allowed. ' . $discountKey . ' given'
|
||||
);
|
||||
}
|
||||
|
||||
return (float)$formatted;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Handler;
|
||||
|
||||
use Xentral\Modules\Datanorm\Data\DatanormATypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormBTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormDTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormPTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormTTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormVTypeData;
|
||||
use Xentral\Modules\Datanorm\Exception\WrongPriceFormatException;
|
||||
|
||||
interface DatanormReaderHandlerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @throws WrongPriceFormatException
|
||||
*
|
||||
* @return DatanormATypeData
|
||||
*/
|
||||
public function transformToTypeA(string $line): DatanormATypeData;
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @throws WrongPriceFormatException
|
||||
*
|
||||
* @return DatanormPTypeData
|
||||
*/
|
||||
public function transformToTypeP(string $line): DatanormPTypeData;
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @return DatanormVTypeData
|
||||
*/
|
||||
public function transformToTypeV(string $line): DatanormVTypeData;
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @return DatanormBTypeData
|
||||
*/
|
||||
public function transformToTypeB(string $line): DatanormBTypeData;
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @return DatanormTTypeData
|
||||
*/
|
||||
public function transformToTypeT(string $line): DatanormTTypeData;
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @return DatanormDTypeData
|
||||
*/
|
||||
public function transformToTypeD(string $line): DatanormDTypeData;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getVersion(): int;
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Handler;
|
||||
|
||||
use Xentral\Modules\Datanorm\Data\DatanormATypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormBTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormDTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormPTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormTTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormVTypeData;
|
||||
use Xentral\Modules\Datanorm\Exception\InvalidLineException;
|
||||
use Xentral\Modules\Datanorm\Exception\WrongDiscountFormatException;
|
||||
use Xentral\Modules\Datanorm\Exception\WrongPriceFormatException;
|
||||
|
||||
final class DatanormReaderVersionFiveHandler extends AbstractDatanormReaderHandler
|
||||
implements DatanormReaderHandlerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @throws WrongPriceFormatException
|
||||
* @throws InvalidLineException
|
||||
*
|
||||
* @return DatanormATypeData
|
||||
*/
|
||||
public function transformToTypeA(string $line): DatanormATypeData
|
||||
{
|
||||
$split = explode(';', $line);
|
||||
|
||||
if (count($split) < 29) {
|
||||
throw new InvalidLineException('The A-record has not the right amount of columns.');
|
||||
}
|
||||
|
||||
/** @var DatanormATypeData */
|
||||
$atype = new DatanormATypeData();
|
||||
|
||||
$atype->setWorkflowState($split[1]);
|
||||
$atype->setArticleNumber($split[2]);
|
||||
$atype->setShortdescription1($split[3]);
|
||||
$atype->setShortDescription2($split[4]);
|
||||
$atype->setPackingUnit($split[5]);
|
||||
$atype->setPriceMark($split[6]);
|
||||
$atype->setPriceAmount((int)$split[7]);
|
||||
$atype->setPrice($this->convertPrice($split[8]) / (int)$split[7]);
|
||||
$atype->setDiscountGroup($split[9]);
|
||||
$atype->setMainProductGroup($split[10]);
|
||||
$atype->setProductGroup($split[11]);
|
||||
$atype->setMatchcode($split[12]);
|
||||
$atype->setProducerToken1($split[13]);
|
||||
$atype->setAltArticleNumber($split[14]);
|
||||
$atype->setProducerToken2($split[15]);
|
||||
$atype->setProducerNumber($split[16]);
|
||||
$atype->setProducerModel($split[17]);
|
||||
$atype->setEan($split[18]);
|
||||
$atype->setConnectionNumber($split[19]);
|
||||
$atype->setMinimumPackageAmount($split[20]);
|
||||
$atype->setCataloguePage($split[21]);
|
||||
$atype->setTextkey($split[22]);
|
||||
$atype->setLongDecriptionKey($split[23]);
|
||||
$atype->setCostType($split[24]);
|
||||
$atype->setArticleType($split[25]);
|
||||
$atype->setProducerToken3($split[26]);
|
||||
$atype->setReferenceNumber($split[27]);
|
||||
$atype->setMwstType((int)$split[28]);
|
||||
|
||||
return $atype;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @throws WrongPriceFormatException
|
||||
* @throws InvalidLineException
|
||||
* @throws WrongDiscountFormatException
|
||||
*
|
||||
* @return DatanormPTypeData
|
||||
*/
|
||||
public function transformToTypeP(string $line): DatanormPTypeData
|
||||
{
|
||||
$split = explode(';', $line);
|
||||
|
||||
if (count($split) < 6) {
|
||||
throw new InvalidLineException('The P-record has not the right amount of columns.');
|
||||
}
|
||||
|
||||
/** @var DatanormPTypeData */
|
||||
$pType = new DatanormPTypeData();
|
||||
|
||||
$pType->setArticleNumber1($split[1]);
|
||||
$pType->setPriceMark1($split[2]);
|
||||
$pType->setPriceAmount1((int)$split[3]);
|
||||
$pType->setPrice1($this->convertPrice($split[4]) / (int)$split[3]);
|
||||
|
||||
$pType->setDiscountGroup($split[5]);
|
||||
|
||||
if (isset($split[6])) {
|
||||
$pType->setDiscountKey1a($split[6]);
|
||||
}
|
||||
|
||||
if (isset($split[7])) {
|
||||
$pType->setDiscount1a($this->convertDiscount($split[6], $split[7]));
|
||||
}
|
||||
|
||||
if (isset($split[8])) {
|
||||
$pType->setDiscountKey1b($split[8]);
|
||||
}
|
||||
|
||||
if (isset($split[9])) {
|
||||
$pType->setDiscount1b($this->convertDiscount($split[8], $split[9]));
|
||||
}
|
||||
|
||||
if (isset($split[10])) {
|
||||
$pType->setDiscountKey1c($split[10]);
|
||||
}
|
||||
|
||||
if (isset($split[11])) {
|
||||
$pType->setDiscount1c($this->convertDiscount($split[10], $split[11]));
|
||||
}
|
||||
|
||||
if (isset($split[12])) {
|
||||
$pType->setValidFromDate($split[12]);
|
||||
}
|
||||
|
||||
return $pType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @throws InvalidLineException
|
||||
*
|
||||
* @return DatanormVTypeData
|
||||
*/
|
||||
public function transformToTypeV(string $line): DatanormVTypeData
|
||||
{
|
||||
$split = explode(';', $line);
|
||||
|
||||
if (count($split) < 15) {
|
||||
throw new InvalidLineException('The V-record has not the right amount of columns.');
|
||||
}
|
||||
|
||||
/** @var DatanormVTypeData */
|
||||
$vType = new DatanormVTypeData();
|
||||
|
||||
$vType->setDataMark($split[2]);
|
||||
$vType->setDate($split[3]);
|
||||
$vType->setCurrency($split[4]);
|
||||
$vType->setDescription($split[5]);
|
||||
$vType->setProducerToken($split[7]);
|
||||
$vType->setAdress1($split[8]);
|
||||
$vType->setAdress2($split[9]);
|
||||
$vType->setAdress3($split[10]);
|
||||
$vType->setStreet($split[11]);
|
||||
$vType->setCountryId($split[12]);
|
||||
$vType->setZip($split[13]);
|
||||
$vType->setCity($split[14]);
|
||||
|
||||
return $vType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @throws InvalidLineException
|
||||
*
|
||||
* @return DatanormBTypeData
|
||||
*/
|
||||
public function transformToTypeB(string $line): DatanormBTypeData
|
||||
{
|
||||
$split = explode(';', $line);
|
||||
|
||||
if (count($split) < 3) {
|
||||
throw new InvalidLineException('The B-record has not the right amount of columns.');
|
||||
}
|
||||
|
||||
$bType = new DatanormBTypeData();
|
||||
|
||||
$bType->setProcessingFlag($split[1]);
|
||||
$bType->setArticleNumber($split[2]);
|
||||
|
||||
if (isset($split[3])) {
|
||||
$bType->setArticleNumberNew($split[3]);
|
||||
}
|
||||
|
||||
if (isset($split[4])) {
|
||||
$bType->setExpirationDate($split[4]);
|
||||
}
|
||||
|
||||
return $bType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getVersion(): int
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @return DatanormTTypeData
|
||||
*/
|
||||
public function transformToTypeT(string $line): DatanormTTypeData
|
||||
{
|
||||
$split = explode(';', $line);
|
||||
|
||||
$tType = new DatanormTTypeData();
|
||||
if (isset($split[1])) {
|
||||
$tType->setProcessingFlag($split[1]);
|
||||
}
|
||||
if (isset($split[2])) {
|
||||
$tType->setTextnumber($split[2]);
|
||||
}
|
||||
if (isset($split[3])) {
|
||||
$tType->setIndicator($split[3]);
|
||||
}
|
||||
if (isset($split[4])) {
|
||||
$tType->setLinenumber1($split[4]);
|
||||
}
|
||||
if (isset($split[5])) {
|
||||
$tType->setText1($split[5]);
|
||||
}
|
||||
|
||||
return $tType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @return DatanormDTypeData
|
||||
*/
|
||||
public function transformToTypeD(string $line): DatanormDTypeData
|
||||
{
|
||||
$split = explode(';', $line);
|
||||
|
||||
$dType = new DatanormDTypeData();
|
||||
|
||||
if (isset($split[1])) {
|
||||
$dType->setProcessingFlag($split[1]);
|
||||
}
|
||||
if (isset($split[2])) {
|
||||
$dType->setArticleNumber($split[2]);
|
||||
}
|
||||
if (isset($split[3])) {
|
||||
$dType->setLineNumber1($split[3]);
|
||||
}
|
||||
if (isset($split[4])) {
|
||||
$dType->setTextIndicator1($split[4]);
|
||||
}
|
||||
if (isset($split[5])) {
|
||||
$dType->setText1($split[5]);
|
||||
}
|
||||
if (isset($split[6])) {
|
||||
$dType->setTextblockNumber1($split[6]);
|
||||
}
|
||||
|
||||
return $dType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Handler;
|
||||
|
||||
use Xentral\Modules\Datanorm\Data\DatanormATypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormBTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormDTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormPTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormTTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormVTypeData;
|
||||
use Xentral\Modules\Datanorm\Exception\InvalidLineException;
|
||||
use Xentral\Modules\Datanorm\Exception\WrongDiscountFormatException;
|
||||
use Xentral\Modules\Datanorm\Exception\WrongPriceFormatException;
|
||||
|
||||
final class DatanormReaderVersionFourHandler extends AbstractDatanormReaderHandler
|
||||
implements DatanormReaderHandlerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @throws WrongPriceFormatException
|
||||
*
|
||||
* @return DatanormATypeData
|
||||
*/
|
||||
public function transformToTypeA(string $line): DatanormATypeData
|
||||
{
|
||||
$split = explode(';', $line);
|
||||
|
||||
if (count($split) < 12) {
|
||||
throw new InvalidLineException('The A-record has not the right amount of columns.');
|
||||
}
|
||||
|
||||
$atype = new DatanormATypeData();
|
||||
|
||||
$atype->setWorkflowState($split[1]);
|
||||
$atype->setArticleNumber($split[2]);
|
||||
$atype->setTextkey($split[3]);
|
||||
$atype->setShortdescription1($split[4]);
|
||||
$atype->setShortDescription2($split[5]);
|
||||
$atype->setPriceMark($split[6]);
|
||||
$atype->setPriceAmount($this->transformPriceAmountCode($split[7]));
|
||||
$atype->setPackingUnit($split[8]);
|
||||
$atype->setPrice($this->convertPrice($split[9]) / $this->transformPriceAmountCode($split[7]));
|
||||
$atype->setDiscountGroup($split[10]);
|
||||
$atype->setMainProductGroup($split[11]);
|
||||
$atype->setLongDecriptionKey($split[12]);
|
||||
|
||||
return $atype;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @throws WrongPriceFormatException
|
||||
* @throws WrongDiscountFormatException
|
||||
*
|
||||
* @return DatanormPTypeData
|
||||
*/
|
||||
public function transformToTypeP(string $line): DatanormPTypeData
|
||||
{
|
||||
$split = explode(';', $line);
|
||||
|
||||
if (count($split) < 29) {
|
||||
throw new InvalidLineException('The P-record has not the right amount of columns.');
|
||||
}
|
||||
|
||||
$pType = new DatanormPTypeData();
|
||||
|
||||
$pType->setArticleNumber1($split[2]);
|
||||
$pType->setPriceMark1($split[3]);
|
||||
$pType->setPriceAmount1(1);
|
||||
$pType->setPrice1($this->convertPrice($split[4]));
|
||||
|
||||
$pType->setDiscountKey1a($split[5]);
|
||||
if (!empty($split[5]) && $split[5] !== '0') {
|
||||
$pType->setDiscount1a($this->convertDiscount($split[5], $split[6]));
|
||||
}
|
||||
|
||||
$pType->setDiscountKey1b($split[7]);
|
||||
if (!empty($split[7]) && $split[7] !== '0') {
|
||||
$pType->setDiscount1b($this->convertDiscount($split[7], $split[8]));
|
||||
}
|
||||
|
||||
$pType->setDiscountKey1c($split[9]);
|
||||
if (!empty($split[9]) && $split[9] !== '0') {
|
||||
$pType->setDiscount1c($this->convertDiscount($split[9], $split[10]));
|
||||
}
|
||||
|
||||
$pType->setArticleNumber2($split[11]);
|
||||
$pType->setPriceMark2($split[12]);
|
||||
$pType->setPriceAmount2(1);
|
||||
$pType->setPrice2($this->convertPrice($split[13]));
|
||||
|
||||
$pType->setDiscountKey2a($split[14]);
|
||||
if (!empty($split[14]) && $split[14] !== '0') {
|
||||
$pType->setDiscount2a($this->convertDiscount($split[14], $split[15]));
|
||||
}
|
||||
|
||||
$pType->setDiscountKey2b($split[16]);
|
||||
if (!empty($split[16]) && $split[16] !== '0') {
|
||||
$pType->setDiscount2b($this->convertDiscount($split[16], $split[17]));
|
||||
}
|
||||
|
||||
$pType->setDiscountKey2c($split[18]);
|
||||
if (!empty($split[18]) && $split[18] !== '0') {
|
||||
$pType->setDiscount2c($this->convertDiscount($split[18], $split[19]));
|
||||
}
|
||||
|
||||
$pType->setArticleNumber3($split[20]);
|
||||
$pType->setPriceMark3($split[21]);
|
||||
$pType->setPriceAmount3(1);
|
||||
$pType->setPrice3($this->convertPrice($split[22]));
|
||||
|
||||
$pType->setDiscountKey3a($split[23]);
|
||||
if (!empty($split[23]) && $split[23] !== '0') {
|
||||
$pType->setDiscount3a($this->convertDiscount($split[23], $split[24]));
|
||||
}
|
||||
|
||||
$pType->setDiscountKey3b($split[25]);
|
||||
if (!empty($split[25]) && $split[25] !== '0') {
|
||||
$pType->setDiscount3b($this->convertDiscount($split[25], $split[26]));
|
||||
}
|
||||
|
||||
$pType->setDiscountKey3c($split[27]);
|
||||
if (!empty($split[27]) && $split[27] !== '0') {
|
||||
$pType->setDiscount3c($this->convertDiscount($split[27], $split[28]));
|
||||
}
|
||||
|
||||
return $pType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @param InvalidLineException
|
||||
*
|
||||
* @return DatanormVTypeData
|
||||
*/
|
||||
public function transformToTypeV(string $line): DatanormVTypeData
|
||||
{
|
||||
if (strlen($line) > 130) {
|
||||
throw new InvalidLineException('The V-record has the wrong length.');
|
||||
}
|
||||
|
||||
$creationDate = trim(substr($line, 2, 6));
|
||||
$info1 = trim(substr($line, 8, 40));
|
||||
$info2 = trim(substr($line, 48, 40));
|
||||
$info3 = trim(substr($line, 88, 35));
|
||||
$currency = trim(substr($line, 125, 3));
|
||||
|
||||
$creationDateFormat = '';
|
||||
if (!empty($creationDate)) {
|
||||
$creationDateFormat =
|
||||
'20' . substr($creationDate, 4, 2) .
|
||||
substr($creationDate, 2, 2) .
|
||||
substr($creationDate, 0, 2);
|
||||
}
|
||||
|
||||
$vType = new DatanormVTypeData();
|
||||
|
||||
$vType->setAdress2($info2);
|
||||
$vType->setDate($creationDateFormat);
|
||||
$vType->setCurrency($currency);
|
||||
$vType->setDescription(trim($info1 . ' ' . $info2 . ' ' . $info3));
|
||||
|
||||
return $vType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @throws InvalidLineException
|
||||
*
|
||||
* @return DatanormBTypeData
|
||||
*/
|
||||
public function transformToTypeB(string $line): DatanormBTypeData
|
||||
{
|
||||
$split = explode(';', $line);
|
||||
|
||||
if (count($split) < 16) {
|
||||
throw new InvalidLineException('The B-record has not the right amount of columns.');
|
||||
}
|
||||
|
||||
$bType = new DatanormBTypeData();
|
||||
|
||||
$bType->setProcessingFlag($split[1]);
|
||||
$bType->setArticleNumber($split[2]);
|
||||
$bType->setMatchcode($split[3]);
|
||||
$bType->setAltArticleNumber($split[4]);
|
||||
$bType->setCopperWeightIndicator($split[6]);
|
||||
$bType->setCopperRawPrice($split[7]);
|
||||
$bType->setCopperWeight($split[8]);
|
||||
$bType->setEan($split[9]);
|
||||
$bType->setGraphicNumber($split[10]);
|
||||
$bType->setProductGroup($split[11]);
|
||||
$bType->setCostIndicator($split[12]);
|
||||
$bType->setOrderAmount($split[13]);
|
||||
$bType->setCreatorReferenceNumber($split[14]);
|
||||
$bType->setReferenceNumber($split[15]);
|
||||
|
||||
return $bType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $priceAmountCode
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function transformPriceAmountCode(string $priceAmountCode): int
|
||||
{
|
||||
$priceAmount = 1;
|
||||
|
||||
if ($priceAmountCode === '1') {
|
||||
$priceAmount = 10;
|
||||
} elseif ($priceAmountCode === '2') {
|
||||
$priceAmount = 100;
|
||||
} elseif ($priceAmountCode === '3') {
|
||||
$priceAmount = 1000;
|
||||
}
|
||||
|
||||
return $priceAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getVersion(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @return DatanormTTypeData
|
||||
*/
|
||||
public function transformToTypeT(string $line): DatanormTTypeData
|
||||
{
|
||||
$split = explode(';', $line);
|
||||
|
||||
$tType = new DatanormTTypeData();
|
||||
|
||||
if (isset($split[1])) {
|
||||
$tType->setProcessingFlag($split[1]);
|
||||
}
|
||||
if (isset($split[2])) {
|
||||
$tType->setTextnumber($split[2]);
|
||||
}
|
||||
if (isset($split[4])) {
|
||||
$tType->setLinenumber1($split[4]);
|
||||
}
|
||||
if (isset($split[6])) {
|
||||
$tType->setText1($split[6]);
|
||||
}
|
||||
if (isset($split[7])) {
|
||||
$tType->setLinenumber2($split[7]);
|
||||
}
|
||||
if (isset($split[9])) {
|
||||
$tType->setText2($split[9]);
|
||||
}
|
||||
|
||||
return $tType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @return DatanormDTypeData
|
||||
*/
|
||||
public function transformToTypeD(string $line): DatanormDTypeData
|
||||
{
|
||||
$split = explode(';', $line);
|
||||
|
||||
$dType = new DatanormDTypeData();
|
||||
|
||||
if (isset($split[1])) {
|
||||
$dType->setProcessingFlag($split[1]);
|
||||
}
|
||||
if (isset($split[2])) {
|
||||
$dType->setArticleNumber($split[2]);
|
||||
}
|
||||
if (isset($split[3])) {
|
||||
$dType->setLineNumber1($split[3]);
|
||||
}
|
||||
if (isset($split[4])) {
|
||||
$dType->setTextIndicator1($split[4]);
|
||||
}
|
||||
if (isset($split[5])) {
|
||||
$dType->setTextblockNumber1($split[5]);
|
||||
}
|
||||
if (isset($split[6])) {
|
||||
$dType->setText1($split[6]);
|
||||
}
|
||||
if (isset($split[8])) {
|
||||
$dType->setTextIndicator2($split[8]);
|
||||
}
|
||||
if (isset($split[9])) {
|
||||
$dType->setTextblockNumber2($split[9]);
|
||||
}
|
||||
if (isset($split[10])) {
|
||||
$dType->setText2($split[10]);
|
||||
}
|
||||
|
||||
return $dType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Service;
|
||||
|
||||
use Xentral\Components\Database\Database;
|
||||
use Xentral\Components\Database\Exception\QueryFailureException;
|
||||
use Xentral\Modules\Datanorm\Exception\ArticleNotFoundException;
|
||||
use Xentral\Modules\Datanorm\Exception\InvalidArgumentException;
|
||||
|
||||
|
||||
final class ArticleService
|
||||
{
|
||||
|
||||
/** @var Database */
|
||||
private $db;
|
||||
|
||||
/**
|
||||
* @param Database $db
|
||||
*/
|
||||
public function __construct(Database $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $articleArray
|
||||
*
|
||||
* @throws ArticleNotFoundException
|
||||
* @throws QueryFailureException
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function InsertUpdateArticle(array $articleArray): ?int
|
||||
{
|
||||
if (empty($articleArray['nummer'])) {
|
||||
throw new ArticleNotFoundException('No article number found.');
|
||||
}
|
||||
|
||||
$articleId = $this->findArticleIdByNumber($articleArray['nummer']);
|
||||
|
||||
if (empty($articleId)) {
|
||||
$articleId = $this->insertArrayIntoTable($articleArray, 'artikel');
|
||||
} else {
|
||||
$this->updateArrayIntoTable($articleArray, 'artikel', $articleId);
|
||||
}
|
||||
|
||||
return $articleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param string $table
|
||||
*
|
||||
* @throws QueryFailureException
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function insertArrayIntoTable(array $data, string $table): ?int
|
||||
{
|
||||
if (empty($data)) {
|
||||
throw new InvalidArgumentException('No data to insert into ' . $table . ' given');
|
||||
}
|
||||
|
||||
$insert = $this->db->insert();
|
||||
$insert
|
||||
->cols($data)
|
||||
->into($table);
|
||||
$this->db->perform($insert->getStatement(), $insert->getBindValues());
|
||||
|
||||
return $this->db->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param string $table
|
||||
* @param int $id
|
||||
*
|
||||
* @throws QueryFailureException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function updateArrayIntoTable(array $data, string $table, int $id): void
|
||||
{
|
||||
if (empty($data)) {
|
||||
throw new InvalidArgumentException('No data to update in ' . $table . ' given');
|
||||
}
|
||||
|
||||
if (empty($id)) {
|
||||
throw new InvalidArgumentException('No id for update in ' . $table . ' given');
|
||||
}
|
||||
|
||||
$update = $this->db->update()
|
||||
->table($table)
|
||||
->cols($data)
|
||||
->where('id=?', $id);
|
||||
|
||||
$this->db->perform($update->getStatement(), $update->getBindValues());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $number
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function findArticleIdByNumber(string $number): ?int
|
||||
{
|
||||
$select = $this->db->select()
|
||||
->cols(['id'])
|
||||
->from('artikel')
|
||||
->where('nummer=?', $number)
|
||||
->limit(1);
|
||||
|
||||
$result = $this->db->fetchCol(
|
||||
$select->getStatement(),
|
||||
$select->getBindValues()
|
||||
);
|
||||
|
||||
if (!empty($result)) {
|
||||
return $result[0];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Service;
|
||||
|
||||
use Xentral\Modules\Datanorm\Data\DatanormATypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormBTypeData;
|
||||
|
||||
final class DatanormConverter
|
||||
{
|
||||
/**
|
||||
* @param DatanormATypeData $aType
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transformATypeToArticleArray(DatanormATypeData $aType): array
|
||||
{
|
||||
$article = [];
|
||||
$article['nummer'] = $aType->getArticleNumber();
|
||||
$article['name_de'] = $aType->getShortDescription1();
|
||||
$article['anabregs_text'] = $aType->getShortDescription2();
|
||||
$article['ean'] = $aType->getEan();
|
||||
$article['herstellernummer'] = $aType->getProducerNumber();
|
||||
$article['einheit'] = $aType->getPackingUnit();
|
||||
|
||||
if ($aType->getArticleType() === '1') {
|
||||
$article['lagerartikel'] = 1;
|
||||
}
|
||||
|
||||
if ($aType->getWorkflowState() === 'L') {
|
||||
$article['intern_gesperrt'] = 1;
|
||||
$article['intern_gesperrtgrund'] = 'DATANORM';
|
||||
}
|
||||
|
||||
$article['umsatzsteuer'] = 'normal';
|
||||
if ($aType->getMwstType() === 3) {
|
||||
$article['umsatzsteuer'] = 'ermaessigt';
|
||||
}
|
||||
|
||||
return $article;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DatanormBTypeData $bType
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transformBTypeToArticleArray(DatanormBTypeData $bType): array
|
||||
{
|
||||
$article = [];
|
||||
|
||||
if (!empty($bType->getEan())) {
|
||||
$article['ean'] = $bType->getEan();
|
||||
}
|
||||
|
||||
if ($bType->getProcessingFlag() === 'L') {
|
||||
$article['intern_gesperrt'] = 1;
|
||||
$article['intern_gesperrtgrund'] = 'DATANORM';
|
||||
}
|
||||
|
||||
if (!empty($bType->getAltArticleNumber())) {
|
||||
$article['herstellernummer'] = $bType->getAltArticleNumber();
|
||||
}
|
||||
|
||||
if ($bType->getCopperWeightIndicator() != '0' && $bType->getCopperWeightIndicator() != '') {
|
||||
$article['internerkommentar'] =
|
||||
'Kupfer-Gewichtsmerker: ' . $bType->getCopperWeightIndicator() . PHP_EOL .
|
||||
'Kupfer-Kennzahl: ' . $bType->getCopperWeightIndicator() . PHP_EOL .
|
||||
'Kupfer-Gewicht: ' . $bType->getCopperWeightIndicator();
|
||||
}
|
||||
|
||||
if (!empty($article)) {
|
||||
$article['nummer'] = $bType->getArticleNumber();
|
||||
}
|
||||
|
||||
return $article;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $articleId
|
||||
* @param string $priceMark
|
||||
* @param string $currency
|
||||
* @param int $amount
|
||||
* @param float $price
|
||||
* @param int $supplierId
|
||||
* @param string $discountFlag1
|
||||
* @param float $discount1
|
||||
* @param string $discountFlag2
|
||||
* @param float $discount2
|
||||
* @param string $discountFlag3
|
||||
* @param float $discount3
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transformToPriceArray(
|
||||
int $articleId,
|
||||
string $priceMark,
|
||||
string $currency,
|
||||
int $amount,
|
||||
float $price,
|
||||
int $supplierId,
|
||||
string $discountFlag1,
|
||||
float $discount1,
|
||||
string $discountFlag2,
|
||||
float $discount2,
|
||||
string $discountFlag3,
|
||||
float $discount3
|
||||
): array {
|
||||
$sellingPrice = [];
|
||||
$purchasePrices = [];
|
||||
|
||||
if ($priceMark === '2') {
|
||||
$purchasePrices[] = [
|
||||
'article_id' => $articleId,
|
||||
'address_id' => $supplierId,
|
||||
'currency_code' => $currency,
|
||||
'quantity_from' => $amount,
|
||||
'price' => $price,
|
||||
];
|
||||
} else {
|
||||
$sellingPrice = [
|
||||
'currency_code' => $currency,
|
||||
'quantity_from' => $amount,
|
||||
'article_id' => $articleId,
|
||||
'price' => $price,
|
||||
];
|
||||
|
||||
if ($priceMark === '1') {
|
||||
if (!empty($discountFlag1)) {
|
||||
$discountPrice1 = $this->calculateDiscountPrice($price, $discountFlag1, $discount1);
|
||||
if (!empty($discountPrice1)) {
|
||||
$purchasePrices[] = [
|
||||
'article_id' => $articleId,
|
||||
'address_id' => $supplierId,
|
||||
'currency_code' => $currency,
|
||||
'quantity_from' => $amount,
|
||||
'price' => $discountPrice1,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($discountFlag2)) {
|
||||
$discountPrice2 = $this->calculateDiscountPrice($price, $discountFlag2, $discount2);
|
||||
if (!empty($discountPrice2)) {
|
||||
$purchasePrices[] = [
|
||||
'article_id' => $articleId,
|
||||
'address_id' => $supplierId,
|
||||
'currency_code' => $currency,
|
||||
'quantity_from' => $amount,
|
||||
'price' => $discountPrice2,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($discountFlag3)) {
|
||||
$discountPrice3 = $this->calculateDiscountPrice($price, $discountFlag3, $discount3);
|
||||
if (!empty($discountPrice3)) {
|
||||
$purchasePrices[] = [
|
||||
'article_id' => $articleId,
|
||||
'address_id' => $supplierId,
|
||||
'currency_code' => $currency,
|
||||
'quantity_from' => $amount,
|
||||
'price' => $discountPrice3,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'sellingPrice' => $sellingPrice,
|
||||
'purchasePrices' => $purchasePrices,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $price
|
||||
* @param string $discountFlag
|
||||
* @param float $discount
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
private function calculateDiscountPrice(float $price, string $discountFlag, float $discount)
|
||||
{
|
||||
$discountPrice = 0.0;
|
||||
|
||||
// Discount
|
||||
if ($discountFlag === '1') {
|
||||
$discountPrice = $price - ($price * ($discount / 100));
|
||||
} // Factor
|
||||
elseif ($discountFlag === '2') {
|
||||
$discountPrice = $price * $discount;
|
||||
} // Surcharge
|
||||
elseif ($discountFlag === '3') {
|
||||
$discountPrice = $price + ($price * ($discount / 100));
|
||||
}
|
||||
|
||||
return $discountPrice;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Service;
|
||||
|
||||
use Xentral\Modules\Datanorm\Data\DatanormATypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormDTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormPTypeData;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormTTypeData;
|
||||
|
||||
final class DatanormEnricher
|
||||
{
|
||||
/** @var DatanormIntermediateGateway $intermediateGateway */
|
||||
private $intermediateGateway;
|
||||
|
||||
/**
|
||||
* @param DatanormIntermediateGateway $intermediateGateway
|
||||
*/
|
||||
public function __construct(DatanormIntermediateGateway $intermediateGateway)
|
||||
{
|
||||
$this->intermediateGateway = $intermediateGateway;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DatanormPTypeData $pType
|
||||
*
|
||||
* @return DatanormPTypeData
|
||||
*/
|
||||
public function enrichPrice(DatanormPTypeData $pType): DatanormPTypeData
|
||||
{
|
||||
$articleNumber = $pType->getArticleNumber1();
|
||||
$data = $this->intermediateGateway->findArticleLineByNumber($articleNumber);
|
||||
$amount = $this->getPriceAmount($data);
|
||||
$pType->setPriceAmount1($amount);
|
||||
$price = $pType->getPrice1();
|
||||
$pType->setPrice1($price / $amount);
|
||||
|
||||
$articleNumber2 = $pType->getArticleNumber2();
|
||||
if (!empty($articleNumber2)) {
|
||||
$data = $this->intermediateGateway->findArticleLineByNumber($articleNumber2);
|
||||
if (isset($data['content'])) {
|
||||
$amount = $this->getPriceAmount($data);
|
||||
$pType->setPriceAmount2($amount);
|
||||
$price = $pType->getPrice2();
|
||||
$pType->setPrice2($price / $amount);
|
||||
}
|
||||
}
|
||||
|
||||
$articleNumber3 = $pType->getArticleNumber3();
|
||||
if (!empty($articleNumber3)) {
|
||||
$data = $this->intermediateGateway->findArticleLineByNumber($articleNumber3);
|
||||
if (isset($data['content'])) {
|
||||
$amount = $this->getPriceAmount($data);
|
||||
$pType->setPriceAmount3($amount);
|
||||
$price = $pType->getPrice3();
|
||||
$pType->setPrice3($price / $amount);
|
||||
}
|
||||
}
|
||||
|
||||
return $pType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getPriceAmount(array $data): int
|
||||
{
|
||||
$aType = new DatanormATypeData();
|
||||
$aType->fillByJson($data['content']);
|
||||
|
||||
return (int)$aType->getPriceAmount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DatanormATypeData $aType
|
||||
*
|
||||
* @return DatanormATypeData
|
||||
*/
|
||||
public function enrichArticle(DatanormATypeData $aType): DatanormATypeData
|
||||
{
|
||||
$longTextBlockNumber = $aType->getLongDecriptionKey();
|
||||
$textFlag = substr($aType->getTextkey(), 0, 1);
|
||||
|
||||
$text = '';
|
||||
$longtText = '';
|
||||
$dimensionText = '';
|
||||
|
||||
if (!empty($longTextBlockNumber)) {
|
||||
$longtextData = $this->intermediateGateway->findTTypeContentByBlocknumber($longTextBlockNumber);
|
||||
if (!empty($longtextData)) {
|
||||
$longtText = $this->createLongText($longtextData);
|
||||
}
|
||||
}
|
||||
|
||||
$dimensionTextData = $this->intermediateGateway->findDTypeContentByArticleNumer($aType->getArticleNumber());
|
||||
if (!empty($dimensionTextData)) {
|
||||
$dimensionText = $this->getDimensionText($dimensionTextData);
|
||||
}
|
||||
|
||||
if ($textFlag === '0') { //KT1 + KT2
|
||||
$text .= $aType->getShortDescription1() . PHP_EOL;
|
||||
$text .= $aType->getShortDescription2();
|
||||
} elseif ($textFlag === '1') { //LT + KT2
|
||||
$text .= $longtText . PHP_EOL;
|
||||
$text .= $aType->getShortDescription2();
|
||||
} elseif ($textFlag === '2') { //KT1 + DT
|
||||
$text .= $aType->getShortDescription1() . PHP_EOL;
|
||||
$text .= $dimensionText;
|
||||
} elseif ($textFlag === '3') { //LT + DT
|
||||
$text .= $longtText . PHP_EOL;
|
||||
$text .= $dimensionText;
|
||||
} elseif ($textFlag === '4') { //KT1 + KT2 + LT
|
||||
$text .= $aType->getShortDescription1() . PHP_EOL;
|
||||
$text .= $aType->getShortDescription2() . PHP_EOL;
|
||||
$text .= $longtText;
|
||||
} elseif ($textFlag === '5') { //KT1 + KT2 + DT
|
||||
$text .= $aType->getShortDescription1() . PHP_EOL;
|
||||
$text .= $aType->getShortDescription2() . PHP_EOL;
|
||||
$text .= $dimensionText;
|
||||
} elseif ($textFlag === '6') { //KT1 + KT2 + LT + DT
|
||||
$text .= $aType->getShortDescription1() . PHP_EOL;
|
||||
$text .= $aType->getShortDescription2() . PHP_EOL;
|
||||
$text .= $longtText . PHP_EOL;
|
||||
$text .= $dimensionText;
|
||||
}
|
||||
|
||||
if (!empty($text)) {
|
||||
$aType->setShortDescription2(trim($text));
|
||||
}
|
||||
|
||||
return $aType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $longTextData
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function createLongText(array $longTextData): string
|
||||
{
|
||||
$longtext = '';
|
||||
foreach ($longTextData as $d) {
|
||||
$tType = new DatanormTTypeData();
|
||||
$tType->fillByJson($d['content']);
|
||||
|
||||
if (!empty($tType->getText1())) {
|
||||
$longtext .= $tType->getText1() . PHP_EOL;
|
||||
}
|
||||
|
||||
if (!empty($tType->getText2())) {
|
||||
$longtext .= $tType->getText2() . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
return trim($longtext);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $dimensionTextData
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getDimensionText(array $dimensionTextData): string
|
||||
{
|
||||
$dimensionText = '';
|
||||
|
||||
foreach ($dimensionTextData as $d) {
|
||||
$dType = new DatanormDTypeData();
|
||||
$dType->fillByJson($d['content']);
|
||||
|
||||
$textIndicator1 = $dType->getTextIndicator1();
|
||||
$textIndicator2 = $dType->getTextIndicator2();
|
||||
|
||||
if (!empty($textIndicator1)) {
|
||||
$txt = $this->createDimensionText(
|
||||
$textIndicator1,
|
||||
$dType->getText1(),
|
||||
$dType->getTextblockNumber1()
|
||||
);
|
||||
if (!empty($txt)) {
|
||||
$dimensionText .= $txt . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($textIndicator2)) {
|
||||
$txt = $this->createDimensionText(
|
||||
$textIndicator2,
|
||||
$dType->getText2(),
|
||||
$dType->getTextblockNumber2()
|
||||
);
|
||||
if (!empty($txt)) {
|
||||
$dimensionText .= $txt . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return trim($dimensionText);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $textIndicator
|
||||
* @param string $text
|
||||
* @param string $textBlockNumber
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function createDimensionText(string $textIndicator, string $text, string $textBlockNumber): string
|
||||
{
|
||||
$dimensionText = '';
|
||||
|
||||
if ($textIndicator === 'F') {
|
||||
$dimensionText = $text;
|
||||
} else {
|
||||
$longTextData = $this->intermediateGateway->findTTypeContentByBlocknumber(
|
||||
$textBlockNumber
|
||||
);
|
||||
|
||||
if ($textIndicator === 'T') {
|
||||
$dimensionText .= $this->createLongText($longTextData);
|
||||
} elseif ($textIndicator === 'E') {
|
||||
$dimensionText .= $this->createInsertingText($text, $longTextData);
|
||||
}
|
||||
}
|
||||
|
||||
return $dimensionText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fillementText
|
||||
* @param array $longTextData
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function createInsertingText(string $fillementText, array $longTextData): string
|
||||
{
|
||||
$tType = new DatanormTTypeData();
|
||||
$tType->fillByJson($longTextData[0]['content']);
|
||||
$pattern = $tType->getText1();
|
||||
|
||||
$patternExp = explode('$$$', $pattern);
|
||||
$fillmentExp = explode('$', $fillementText);
|
||||
|
||||
$text = '';
|
||||
for ($i = 0; $i < count($patternExp); $i++) {
|
||||
$text .= $patternExp[$i] . $fillmentExp[$i];
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Service;
|
||||
|
||||
use Xentral\Components\Database\Database;
|
||||
|
||||
final class DatanormIntermediateGateway
|
||||
{
|
||||
|
||||
/** @var Database */
|
||||
private $db;
|
||||
|
||||
/**
|
||||
* @param Database $db
|
||||
*/
|
||||
public function __construct(Database $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLines(int $limit): array
|
||||
{
|
||||
$sqlOnlyA =
|
||||
'SELECT d.id, d.fileName, d.type, d.content
|
||||
FROM `datanorm_intermediate` AS `d`
|
||||
WHERE d.type = \'A\'
|
||||
AND d.errorFlag = 0
|
||||
AND d.doneFlag = 0
|
||||
AND d.ready = 1
|
||||
ORDER BY d.id DESC
|
||||
LIMIT ' . $limit;
|
||||
|
||||
$sqlNotV =
|
||||
'SELECT d.id, d.fileName, d.type, d.content
|
||||
FROM `datanorm_intermediate` AS `d`
|
||||
WHERE d.type != \'V\'
|
||||
AND d.errorFlag = 0
|
||||
AND d.doneFlag = 0
|
||||
AND d.ready = 1
|
||||
ORDER BY d.id DESC
|
||||
LIMIT ' . $limit;
|
||||
|
||||
// Articles (type A) MUST be imported before anything else;
|
||||
// 'ORDER BY type' makes the query slower than 2 single querys
|
||||
$rows = $this->db->fetchAll($sqlOnlyA);
|
||||
|
||||
if (empty($rows)) {
|
||||
$rows = $this->db->fetchAll($sqlNotV);
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLinesToEnrich(int $limit): array
|
||||
{
|
||||
$sql =
|
||||
'SELECT d.id, d.fileName, d.type, d.content
|
||||
FROM `datanorm_intermediate` AS `d`
|
||||
WHERE d.enrich = 1
|
||||
AND d.doneFlag = 0
|
||||
ORDER BY d.id DESC
|
||||
LIMIT ' . $limit;
|
||||
|
||||
return $this->db->fetchAll($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fileName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getVType(string $fileName): array
|
||||
{
|
||||
$select = $this->db->select()
|
||||
->cols(['id', 'fileName', 'type', 'content', 'supplier_address_id', 'user_address_id'])
|
||||
->from('datanorm_intermediate')
|
||||
->where('fileName = ?', $fileName)
|
||||
->where('type = ?', 'V')
|
||||
->limit(1);
|
||||
|
||||
return $this->db->fetchRow(
|
||||
$select->getStatement(),
|
||||
$select->getBindValues()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $articleNumber
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function findArticleLineByNumber(string $articleNumber): array
|
||||
{
|
||||
$sql =
|
||||
'SELECT di.content
|
||||
FROM `datanorm_intermediate` AS `di`
|
||||
WHERE di.type = \'A\'
|
||||
AND di.nummer = :articleNumber
|
||||
ORDER BY di.id DESC
|
||||
LIMIT 1';
|
||||
|
||||
$values = [
|
||||
'articleNumber' => $articleNumber,
|
||||
];
|
||||
|
||||
return $this->db->fetchRow($sql, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $longTextBlockNumber
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function findTTypeContentByBlocknumber(string $longTextBlockNumber): array
|
||||
{
|
||||
$sql =
|
||||
'SELECT di.content
|
||||
FROM `datanorm_intermediate` AS `di`
|
||||
WHERE di.type = \'T\'
|
||||
AND di.nummer = :longTextBlockNumber
|
||||
AND di.doneFlag = 0
|
||||
ORDER BY di.id';
|
||||
|
||||
$values = [
|
||||
'longTextBlockNumber' => $longTextBlockNumber,
|
||||
];
|
||||
|
||||
return $this->db->fetchAll($sql, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $articleNumber
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function findDTypeContentByArticleNumer(string $articleNumber): array
|
||||
{
|
||||
$sql =
|
||||
'SELECT di.content
|
||||
FROM `datanorm_intermediate` AS `di`
|
||||
WHERE di.type = \'D\'
|
||||
AND di.nummer = :articleNumber
|
||||
AND di.doneFlag = 0
|
||||
ORDER BY di.id';
|
||||
|
||||
$values = [
|
||||
'articleNumber' => $articleNumber,
|
||||
];
|
||||
|
||||
return $this->db->fetchAll($sql, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $vId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function findSupplierNumberByVid(int $vId)
|
||||
{
|
||||
$sql =
|
||||
'SELECT a.lieferantennummer
|
||||
FROM `adresse` AS `a`
|
||||
LEFT JOIN `datanorm_intermediate` AS `di` ON di.supplier_address_id = a.id
|
||||
WHERE di.id = :v_id';
|
||||
|
||||
$values = [
|
||||
'v_id' => $vId,
|
||||
];
|
||||
|
||||
$result = $this->db->fetchRow($sql, $values);
|
||||
|
||||
if (!empty($result)) {
|
||||
return (string)$result['lieferantennummer'];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Service;
|
||||
|
||||
use Xentral\Components\Database\Database;
|
||||
|
||||
final class DatanormIntermediateService
|
||||
{
|
||||
/** @var Database */
|
||||
private $db;
|
||||
|
||||
/**
|
||||
* @param Database $db
|
||||
*/
|
||||
public function __construct(Database $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $intermediateEntries
|
||||
*/
|
||||
public function writeMultiple(array $intermediateEntries): void
|
||||
{
|
||||
if (!empty($intermediateEntries)) {
|
||||
$sql =
|
||||
'INSERT IGNORE INTO `datanorm_intermediate` (`fileName`, `type`, `content` ,`hash`, `doneFlag`, `nummer`,`enrich`, `user_address_id`)
|
||||
VALUES';
|
||||
$values = [];
|
||||
$sqlParams = [];
|
||||
|
||||
foreach ($intermediateEntries as $index => $entry) {
|
||||
$fileName = $entry['fileName'];
|
||||
$type = $entry['type'];
|
||||
$content = json_encode($entry['obj']);
|
||||
$doneFlag = ($type === 'V' ? 1 : 0);
|
||||
$hash = ($type === 'V' ? $fileName : md5($content));
|
||||
$nummer = $entry['nummer'];
|
||||
$enrich = $entry['enrich'];
|
||||
$userAddressId = $entry['user_address_id'];
|
||||
|
||||
$values['fileName' . $index] = $fileName;
|
||||
$values['type' . $index] = $type;
|
||||
$values['content' . $index] = $content;
|
||||
$values['hash' . $index] = $hash;
|
||||
$values['doneFlag' . $index] = $doneFlag;
|
||||
$values['nummer' . $index] = $nummer;
|
||||
$values['enrich' . $index] = $enrich;
|
||||
$values['user_address_id' . $index] = $userAddressId;
|
||||
|
||||
$sqlParams[] =
|
||||
'(:fileName' . $index .
|
||||
',:type' . $index .
|
||||
',:content' . $index .
|
||||
',:hash' . $index .
|
||||
',:doneFlag' . $index .
|
||||
',:nummer' . $index .
|
||||
',:enrich' . $index .
|
||||
',:user_address_id' . $index . ')';
|
||||
}
|
||||
|
||||
$sql .= implode(',', $sqlParams);
|
||||
$this->db->perform($sql, $values);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $intermdiateIds
|
||||
* @param bool $done
|
||||
*/
|
||||
public function setMultipleDone(array $intermdiateIds, bool $done = true): void
|
||||
{
|
||||
if (!empty($intermdiateIds)) {
|
||||
$sql = 'UPDATE `datanorm_intermediate` SET `doneFlag` = :done WHERE `id` IN (';
|
||||
|
||||
$values = [
|
||||
'done' => $done,
|
||||
];
|
||||
|
||||
$idStrs = [];
|
||||
for ($i = 0; $i < count($intermdiateIds); $i++) {
|
||||
$idStrs[] = ':id' . $i;
|
||||
$values['id' . $i] = $intermdiateIds[$i];
|
||||
}
|
||||
$sql .= implode(',', $idStrs);
|
||||
$sql .= ')';
|
||||
|
||||
$this->db->perform($sql, $values);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $enrichData
|
||||
*/
|
||||
public function saveEnrichData(array $enrichData): void
|
||||
{
|
||||
foreach ($enrichData as $id => $data) {
|
||||
$sql =
|
||||
'UPDATE `datanorm_intermediate`
|
||||
SET
|
||||
`content` = :content,
|
||||
`hash` = :hash,
|
||||
`enrich` = :enrich
|
||||
WHERE `id` = :id';
|
||||
|
||||
$values = [
|
||||
'content' => $data['content'],
|
||||
'hash' => $data['hash'],
|
||||
'enrich' => $data['enrich'],
|
||||
'id' => $id,
|
||||
];
|
||||
$this->db->perform($sql, $values);
|
||||
}
|
||||
}
|
||||
|
||||
public function setTAndDTypeDone(): void
|
||||
{
|
||||
$sql =
|
||||
'UPDATE `datanorm_intermediate`
|
||||
SET
|
||||
`doneFlag` = :done
|
||||
WHERE (`type` = \'T\' OR `type` = \'D\')
|
||||
AND `doneFlag` = 0';
|
||||
|
||||
$values = ['done' => true];
|
||||
$this->db->perform($sql, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $vId
|
||||
* @param string $supplierNumber
|
||||
*/
|
||||
public function saveSupplierToVType(int $vId, string $supplierNumber)
|
||||
{
|
||||
$sql =
|
||||
'UPDATE `datanorm_intermediate`
|
||||
SET
|
||||
`supplier_address_id` =
|
||||
(
|
||||
SELECT a.id
|
||||
FROM `adresse` AS `a`
|
||||
WHERE a.lieferantennummer = :supplier_number
|
||||
LIMIT 1
|
||||
)
|
||||
WHERE `id` = :v_id';
|
||||
|
||||
$values = ['v_id' => $vId, 'supplier_number' => $supplierNumber];
|
||||
$this->db->perform($sql, $values);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,358 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Service;
|
||||
|
||||
use Generator;
|
||||
use Xentral\Components\Filesystem\Exception\FileNotFoundException;
|
||||
use Xentral\Components\Filesystem\FilesystemInterface;
|
||||
use Xentral\Components\Filesystem\PathInfo;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormTypeDataInterface;
|
||||
use Xentral\Modules\Datanorm\Exception\FileSystemException;
|
||||
use Xentral\Modules\Datanorm\Exception\InvalidLineException;
|
||||
use Xentral\Modules\Datanorm\Exception\NoAddressIdFoundException;
|
||||
use Xentral\Modules\Datanorm\Exception\WrongDiscountFormatException;
|
||||
use Xentral\Modules\Datanorm\Exception\WrongPriceFormatException;
|
||||
use Xentral\Modules\Datanorm\Exception\WrongVersionException;
|
||||
use Xentral\Modules\Datanorm\Handler\DatanormReaderHandlerInterface;
|
||||
|
||||
|
||||
final class DatanormReader
|
||||
{
|
||||
/** @var FilesystemInterface $filesystem */
|
||||
private $filesystem;
|
||||
|
||||
/** @var string $uploadDir */
|
||||
private $uploadDir;
|
||||
|
||||
/** @var DatanormReaderHandlerInterface[] $readerHandlers */
|
||||
private $readerHandlers;
|
||||
|
||||
/** @var int[] $readerVersions */
|
||||
private $readerVersions;
|
||||
|
||||
/** @var DatanormIntermediateService $intermediateService */
|
||||
private $intermediateService;
|
||||
|
||||
/**
|
||||
* @param FilesystemInterface $filesystem
|
||||
* @param DatanormIntermediateService $intermediateService
|
||||
* @param DatanormReaderHandlerInterface[] $readerHandlers
|
||||
* @param string $uploadDir Relative dir to filesystem-class root
|
||||
*/
|
||||
public function __construct(
|
||||
FilesystemInterface $filesystem,
|
||||
DatanormIntermediateService $intermediateService,
|
||||
array $readerHandlers,
|
||||
$uploadDir
|
||||
) {
|
||||
$this->filesystem = $filesystem;
|
||||
$this->uploadDir = $uploadDir;
|
||||
$this->readerHandlers = [];
|
||||
$this->intermediateService = $intermediateService;
|
||||
|
||||
foreach ($readerHandlers as $r) {
|
||||
$this->readerVersions[] = $r->getVersion();
|
||||
$this->readerHandlers[] = $r;
|
||||
}
|
||||
|
||||
if (!$filesystem->has($this->uploadDir)) {
|
||||
$filesystem->createDir($this->uploadDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PathInfo $file
|
||||
* @param int $limit
|
||||
* @param int $lastLineNumber
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
* @throws WrongVersionException
|
||||
* @throws InvalidLineException
|
||||
* @throws FileSystemException
|
||||
* @throws WrongPriceFormatException
|
||||
* @throws WrongDiscountFormatException
|
||||
* @throws NoAddressIdFoundException
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function read(PathInfo $file, int $limit, int $lastLineNumber): int
|
||||
{
|
||||
$iterator = $this->getFileIterator($file->getPath());
|
||||
$counter = 0;
|
||||
$nextLastLineNumber = $lastLineNumber + $limit;
|
||||
$intermediateEntries = [];
|
||||
$version = 0;
|
||||
|
||||
foreach ($iterator as $line) {
|
||||
if ($counter === 0) {
|
||||
$version = $this->getVersionByTypV($line);
|
||||
}
|
||||
|
||||
if ($counter >= $lastLineNumber && $counter < $nextLastLineNumber) {
|
||||
$type = $this->getLineType($line);
|
||||
$obj = $this->parseLine($line, $version);
|
||||
if (!empty($obj)) {
|
||||
$isEnrich = false;
|
||||
if ($type === 'A' || $type === 'P') {
|
||||
$isEnrich = $this->needsEnrichement($type, $obj, $version);
|
||||
} elseif ($type === 'E' && $version === 4) {
|
||||
$type = 'T';
|
||||
}
|
||||
|
||||
$articleNumber = '';
|
||||
if (method_exists($obj, 'getArticleNumber')) {
|
||||
$articleNumber = $obj->getArticleNumber();
|
||||
} elseif (method_exists($obj, 'getTextnumber')) {
|
||||
$articleNumber = $obj->getTextnumber();
|
||||
}
|
||||
|
||||
$intermediateEntries[] = [
|
||||
'fileName' => $file->getFilename(),
|
||||
'type' => $type,
|
||||
'obj' => $obj,
|
||||
'nummer' => $articleNumber,
|
||||
'enrich' => $isEnrich,
|
||||
'directory' => $file->getDir(),
|
||||
'user_address_id' => $this->getUserIdFromPath($file->getFilename()),
|
||||
];
|
||||
}
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
|
||||
if (count($intermediateEntries) > 0) {
|
||||
$this->intermediateService->writeMultiple($intermediateEntries);
|
||||
}
|
||||
|
||||
if ($nextLastLineNumber - $counter >= 0) {
|
||||
$isDeleted = $this->deleteFile($file->getPath());
|
||||
|
||||
if (!$isDeleted) {
|
||||
$scriptOwner = @posix_getpwuid(@fileowner(__FILE__));
|
||||
$scriptGroup = @posix_getgrgid(@filegroup(__FILE__));
|
||||
$phpUsername = get_current_user();
|
||||
|
||||
$msg =
|
||||
'Could not delete file: ' . $file->getPath() .
|
||||
', scriptowner: ' . $scriptOwner[0] .
|
||||
', scriptGroup: ' . $scriptGroup[0] .
|
||||
', phpUsername: ' . $phpUsername;
|
||||
|
||||
throw new FileSystemException($msg);
|
||||
}
|
||||
$nextLastLineNumber = -1;
|
||||
}
|
||||
|
||||
return $nextLastLineNumber;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $fileName
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getUserIdFromPath(string $fileName): int
|
||||
{
|
||||
$pos = strstr($fileName, '_', true);
|
||||
if (strstr($fileName, '_') === false) {
|
||||
throw new NoAddressIdFoundException('No user-id found in filename: ' . $fileName);
|
||||
} else {
|
||||
return (int)$pos;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
* @param int $version
|
||||
*
|
||||
* @throws WrongVersionException
|
||||
* @throws WrongPriceFormatException
|
||||
* @throws WrongDiscountFormatException
|
||||
*
|
||||
* @return null|DatanormTypeDataInterface
|
||||
*/
|
||||
private function parseLine(string $line, int $version): ?DatanormTypeDataInterface
|
||||
{
|
||||
$readerHandler = $this->getReaderHandler($version);
|
||||
|
||||
$line = iconv('CP850', 'UTF-8', $line);
|
||||
|
||||
$obj = null;
|
||||
$type = $this->getLineType($line);
|
||||
switch ($type) {
|
||||
case 'A':
|
||||
$obj = $readerHandler->transformToTypeA($line);
|
||||
break;
|
||||
case'P':
|
||||
$obj = $readerHandler->transformToTypeP($line);
|
||||
break;
|
||||
case'V':
|
||||
$obj = $readerHandler->transformToTypeV($line);
|
||||
break;
|
||||
case'B':
|
||||
$obj = $readerHandler->transformToTypeB($line);
|
||||
break;
|
||||
case'E':
|
||||
if ($version === 4) {
|
||||
$obj = $readerHandler->transformToTypeT($line);
|
||||
}
|
||||
break;
|
||||
case'T':
|
||||
$obj = $readerHandler->transformToTypeT($line);
|
||||
break;
|
||||
case'D':
|
||||
$obj = $readerHandler->transformToTypeD($line);
|
||||
break;
|
||||
}
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $version
|
||||
*
|
||||
* @throws WrongVersionException
|
||||
*
|
||||
* @return DatanormReaderHandlerInterface
|
||||
*/
|
||||
private function getReaderHandler(int $version): DatanormReaderHandlerInterface
|
||||
{
|
||||
$readerHandler = null;
|
||||
foreach ($this->readerHandlers as $r) {
|
||||
if ($r->getVersion() === $version) {
|
||||
$readerHandler = $r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($readerHandler)) {
|
||||
throw new WrongVersionException(
|
||||
'The DATANORM-Version is not supported. Only ' .
|
||||
implode(', ', $this->readerVersions) . ' are allowed. Requested version was: ' . $version
|
||||
);
|
||||
}
|
||||
|
||||
return $readerHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filePath Relative path to filesystem-class root
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
private function getFileIterator(string $filePath): Generator
|
||||
{
|
||||
$stream = $this->filesystem->readStream($filePath);
|
||||
|
||||
while ($line = fgets($stream)) {
|
||||
yield $line;
|
||||
}
|
||||
|
||||
if (is_resource($stream)) {
|
||||
fclose($stream);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @throws InvalidLineException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getLineType(string $line): string
|
||||
{
|
||||
$lineType = substr(trim($line), 0, 1);
|
||||
|
||||
if ($lineType === false || empty($lineType)) {
|
||||
throw new InvalidLineException('Unknown linetype in this line: ' . $line);
|
||||
}
|
||||
|
||||
return $lineType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @throws WrongVersionException
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getVersionByTypV(string $line): int
|
||||
{
|
||||
$v5indicator = false;
|
||||
$split = explode(';', $line);
|
||||
if (isset($split[1])) {
|
||||
$v5indicator = $split[1] === '050';
|
||||
}
|
||||
|
||||
$v4indicator = false;
|
||||
if (strlen($line) > 123) {
|
||||
$v4indicator = trim(substr($line, 123, 2)) === '04';
|
||||
}
|
||||
|
||||
|
||||
if ($v5indicator) {
|
||||
return 5;
|
||||
} elseif ($v4indicator) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
throw new WrongVersionException('DATANORM-Version not found.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteFile(string $path): bool
|
||||
{
|
||||
return $this->filesystem->delete($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|PathInfo[]
|
||||
*/
|
||||
public function listUploadedDatanormFiles(): array
|
||||
{
|
||||
return $this->filesystem->listFiles($this->uploadDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param DatanormTypeDataInterface $object
|
||||
* @param int $version
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function needsEnrichement(string $type, DatanormTypeDataInterface $object, int $version): bool
|
||||
{
|
||||
if ($version === 4 && $type === 'P') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($type === 'A' && method_exists($object, 'getTextkey')) {
|
||||
$textFlag = '0';
|
||||
|
||||
if (!empty($object->getTextkey())) {
|
||||
$textFlag = substr($object->getTextkey(), 0, 1);
|
||||
}
|
||||
|
||||
if ($textFlag != '0') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Datanorm\Wrapper;
|
||||
|
||||
use erpAPI;
|
||||
use Xentral\Components\Database\Database;
|
||||
use Xentral\Modules\Datanorm\Data\DatanormVTypeData;
|
||||
|
||||
class AddressWrapper
|
||||
{
|
||||
/** @var erpAPI $erp */
|
||||
private $erp;
|
||||
|
||||
/** @var Database */
|
||||
private $db;
|
||||
|
||||
/**
|
||||
* @param Database $db
|
||||
* @param erpAPI $erp
|
||||
*/
|
||||
public function __construct(Database $db, erpAPI $erp)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->erp = $erp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DatanormVTypeData $supplierData
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function insertSupplierIfNotExists(DatanormVTypeData $supplierData): int
|
||||
{
|
||||
$supplierName =
|
||||
trim(
|
||||
$supplierData->getAdress1() . ' ' .
|
||||
$supplierData->getAdress2() . ' ' .
|
||||
$supplierData->getAdress3()
|
||||
);
|
||||
|
||||
if (empty($supplierName)) {
|
||||
$supplierName = $supplierData->getDescription();
|
||||
}
|
||||
|
||||
$supplierId = $this->findAdressByName($supplierName);
|
||||
|
||||
if (empty($supplierId)) {
|
||||
$sql =
|
||||
'INSERT INTO `adresse`
|
||||
(`typ`,`name`,`ort`,`strasse`,`plz`,`land`,`sonstiges`,`lieferantennummer`) VALUES
|
||||
(:type, :name , :city, :street, :zip, :country, :miscellaneous, :supplier_number)
|
||||
';
|
||||
|
||||
$this->db->perform(
|
||||
$sql,
|
||||
[
|
||||
'type' => 'firma',
|
||||
'name' => $supplierName,
|
||||
'city' => $supplierData->getCity(),
|
||||
'street' => $supplierData->getStreet(),
|
||||
'zip' => $supplierData->getZip(),
|
||||
'country' => $this->mapCountryId($supplierData->getCountryId()),
|
||||
'miscellaneous' => $supplierData->getProducerToken(),
|
||||
'supplier_number' => $this->erp->GetNextLieferantennummer(),
|
||||
'sonstiges' => $supplierData->getDescription(),
|
||||
]
|
||||
);
|
||||
|
||||
$supplierId = $this->db->lastInsertId();
|
||||
}
|
||||
|
||||
return $supplierId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function findAdressByName(string $name)
|
||||
{
|
||||
$select = $this->db->select()
|
||||
->cols(['id'])
|
||||
->from('adresse')
|
||||
->where('name=?', $name)
|
||||
->limit(1);
|
||||
|
||||
$result = $this->db->fetchCol(
|
||||
$select->getStatement(),
|
||||
$select->getBindValues()
|
||||
);
|
||||
|
||||
if (!empty($result)) {
|
||||
return $result[0];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Need more examples
|
||||
*
|
||||
* @param string $countryId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function mapCountryId(string $countryId)
|
||||
{
|
||||
$mapping = [
|
||||
'D' => 'DE',
|
||||
];
|
||||
if (array_key_exists($countryId, $mapping)) {
|
||||
return $mapping[$countryId];
|
||||
}
|
||||
|
||||
return $countryId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
var Datanorm = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
selector: {
|
||||
datanormIntermediate: '#datanorm_intermediate',
|
||||
datanormEdit: '#datanorm-edit',
|
||||
datanormVidHidden: '#datanorm-edit-vid',
|
||||
datanormMsg: '#datanorm-msg',
|
||||
datanormForm: '#datanorm-form',
|
||||
datanormEditDialog: '.datanorm-edit-dialog',
|
||||
supplierInput: '#datanorm-supplier'
|
||||
},
|
||||
|
||||
storage: {
|
||||
$dialog: null
|
||||
},
|
||||
|
||||
init: function () {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
$('#chunkyfile').chunkedUpload({
|
||||
upload: {
|
||||
url: 'index.php?module=datanorm&action=list&cmd=upload',
|
||||
view: 'sidebar'
|
||||
}
|
||||
});
|
||||
me.storage.$dialog = $(me.selector.datanormEdit);
|
||||
me.dialogInit();
|
||||
me.registerEvents();
|
||||
|
||||
me.isInitialized = true;
|
||||
},
|
||||
|
||||
registerEvents: function () {
|
||||
|
||||
$(me.selector.datanormIntermediate).on('click', me.selector.datanormEditDialog, function (event) {
|
||||
event.preventDefault();
|
||||
me.dialogOpen(this.id.replace('dn-', ''));
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
dialogInit: function () {
|
||||
me.storage.$dialog.dialog({
|
||||
modal: true,
|
||||
bgiframe: true,
|
||||
closeOnEscape: false,
|
||||
minWidth: 650,
|
||||
minHeight: 250,
|
||||
autoOpen: false,
|
||||
open: function () {},
|
||||
close: function () {
|
||||
me.dialogReset();
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
id: 'button-ok',
|
||||
text: 'SPEICHERN',
|
||||
click: function () {
|
||||
$(me.selector.datanormForm).submit();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
},
|
||||
|
||||
dialogOpen: function (id) {
|
||||
|
||||
me.dialogReset();
|
||||
me.storage.$dialog.find(me.selector.datanormVidHidden).val(id);
|
||||
|
||||
$.ajax({
|
||||
url: 'index.php?module=datanorm&action=list&cmd=settings',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
vid: id
|
||||
},
|
||||
success: function (data) {
|
||||
|
||||
if (data.error) {
|
||||
me.storage.$dialog.find(me.selector.datanormMsg).text(data.error);
|
||||
} else {
|
||||
me.storage.$dialog.find(me.selector.supplierInput).val(data.supplier_number);
|
||||
me.storage.$dialog.dialog('open');
|
||||
}
|
||||
},
|
||||
beforeSend: function () {}
|
||||
});
|
||||
},
|
||||
|
||||
dialogClose: function () {
|
||||
me.storage.$dialog.dialog('close');
|
||||
},
|
||||
|
||||
dialogReset: function () {
|
||||
me.storage.$dialog.find(me.selector.datanormVidHidden).val(null);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
init: me.init
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
$(document).ready(function () {
|
||||
Datanorm.init();
|
||||
});
|
||||
Reference in New Issue
Block a user