prepare for data import in demo

This commit is contained in:
Dennis Eichhorn 2020-07-11 20:26:50 +02:00
parent 5bddebd280
commit 7d33501b29
12 changed files with 452 additions and 43 deletions

View File

@ -21,17 +21,17 @@ use Modules\Accounting\Models\CostObjectMapper;
use Modules\ClientManagement\Models\Client;
use Modules\Exchange\Interfaces\GSD\Model\GSDCostCenterMapper;
use Modules\Exchange\Interfaces\GSD\Model\GSDCostObjectMapper;
use Modules\Exchange\Models\ImporterAbstract;
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
use phpOMS\DataStorage\Database\Connection\ConnectionFactory;
use phpOMS\DataStorage\Database\DatabaseStatus;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\Message\RequestAbstract;
use Modules\Exchange\Interfaces\GSD\Model\GSDAddressMapper;
use Modules\Exchange\Interfaces\GSD\Model\GSDCustomerMapper;
use Modules\ClientManagement\Models\ClientMapper;
use Modules\SupplierManagement\Models\SupplierMapper;
use Modules\Exchange\Interfaces\GSD\Model\GSDSupplierMapper;
use Modules\SupplierManagement\Models\Supplier;
/**
* GSD import class
@ -65,7 +65,6 @@ final class Importer extends ImporterAbstract
{
$this->importCostCenter($start, $end);
$this->importCostObject($start, $end);
$this->importAddress($start, $end);
$this->importCustomer($start, $end);
$this->importSupplier($start, $end);
$this->importArticle($start, $end);
@ -235,6 +234,21 @@ final class Importer extends ImporterAbstract
*/
public function importSupplier(\DateTime $start, \DateTime $end) : void
{
DataMapperAbstract::setConnection($this->remote);
$query = GSDSupplierMapper::getQuery();
$query->where('row_create_time', '=>', $start->format('Y-m-d H:i:s'))
->andWhere('row_create_time', '<=', $end->format('Y-m-d H:i:s'));
$suppliers = GSDSupplierMapper::getAllByQuery($query);
DataMapperAbstract::setConnection($this->local);
foreach ($suppliers as $supplier) {
$obj = new Supplier();
$obj->setNumber($supplier->getNumber());
SupplierMapper::create($obj);
}
}
/**

View File

@ -24,4 +24,82 @@ namespace Modules\Exchange\Interfaces\GSD\Model;
*/
final class GSDAddress
{
protected int $id = 0;
private string $name1 = '';
private string $name2 = '';
private string $name3 = '';
private string $city = '';
private string $country = '';
private string $zip = '';
private string $street = '';
private string $phone = '';
private string $fax = '';
private string $email = '';
private string $website = '';
public function getName1() : string
{
return $this->name1;
}
public function getName2() : string
{
return $this->name2;
}
public function getName3() : string
{
return $this->name3;
}
public function getCity() : string
{
return $this->city;
}
public function getZip() : string
{
return $this->zip;
}
public function getStreet() : string
{
return $this->street;
}
public function getCountry() : string
{
return $this->country;
}
public function getPhone() : string
{
return $this->phone;
}
public function getEmail() : string
{
return $this->email;
}
public function getFax() : string
{
return $this->fax;
}
public function getWebsite() : string
{
return $this->website;
}
}

View File

@ -44,6 +44,9 @@ final class GSDAddressMapper extends DataMapperAbstract
'STRASSE' => ['name' => 'STRASSE', 'type' => 'string', 'internal' => 'street'],
'LAND' => ['name' => 'LAND', 'type' => 'string', 'internal' => 'country'],
'TELEFON' => ['name' => 'TELEFON', 'type' => 'string', 'internal' => 'phone'],
'Fax' => ['name' => 'Fax', 'type' => 'string', 'internal' => 'fax'],
'Email' => ['name' => 'Email', 'type' => 'string', 'internal' => 'email'],
'InternetAdresse' => ['name' => 'InternetAdresse', 'type' => 'string', 'internal' => 'website'],
];
/**

View File

@ -24,4 +24,89 @@ namespace Modules\Exchange\Interfaces\GSD\Model;
*/
final class GSDArticle
{
protected int $id = 0;
private \DateTime $createdAt;
private string $number = '';
private string $info = '';
private string $name1 = '';
private string $name2 = '';
private string $name1Eng = '';
private string $name2Eng = '';
private int $status = 0;
private int $lotType = 0;
private float $weight = 0.0;
private int $leadTime = 0;
private string $EUitemgroup = '';
public function __construct()
{
$this->createdAt = new \DateTime('now');
}
public function getNumber() : string
{
return $this->number;
}
public function getInfo() : string
{
return $this->info;
}
public function getName1() : string
{
return $this->name1;
}
public function getName2() : string
{
return $this->name2;
}
public function getName1Eng() : string
{
return $this->name1Eng;
}
public function getName2Eng() : string
{
return $this->name2Eng;
}
public function getStatus() : int
{
return $this->status;
}
public function getLotType() : int
{
return $this->lotType;
}
public function getWeight() : float
{
return $this->weight;
}
public function getLeadTime() : int
{
return $this->leadTime;
}
public function getEUItemGroup() : string
{
return $this->EUitemgroup;
}
}

View File

@ -37,9 +37,12 @@ final class GSDArticleMapper extends DataMapperAbstract
'row_create_time' => ['name' => 'row_create_time', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
'row_create_user' => ['name' => 'row_create_user', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'Artikelnummer' => ['name' => 'Artikelnummer', 'type' => 'string', 'internal' => 'number'],
'Info' => ['name' => 'Info', 'type' => 'string', 'internal' => 'info'],
'Artikelbezeichnung' => ['name' => 'Artikelbezeichnung', 'type' => 'string', 'internal' => 'name1'],
'_Artikelbezeichnung2' => ['name' => '_Artikelbezeichnung2', 'type' => 'string', 'internal' => 'name2'],
'EUWarengruppe' => ['name' => 'EUWarengruppe', 'type' => 'string', 'internal' => 'euCustomId'],
'_Englisch1' => ['name' => '_Englisch1', 'type' => 'string', 'internal' => 'name1Eng'],
'_Englisch2' => ['name' => '_Englisch2', 'type' => 'string', 'internal' => 'name2Eng'],
'EUWarengruppe' => ['name' => 'EUWarengruppe', 'type' => 'string', 'internal' => 'EUitemgroup'],
];
/**

View File

@ -43,10 +43,10 @@ final class GSDCostCenter implements \JsonSerializable
/**
* Created.
*
* @var null|\DateTime
* @var \DateTime
* @since 1.0.0
*/
protected ?\DateTime $createdAt = null;
protected \DateTime $createdAt;
/**
* Description.

View File

@ -43,10 +43,10 @@ final class GSDCostObject implements \JsonSerializable
/**
* Created.
*
* @var null|\DateTime
* @var \DateTime
* @since 1.0.0
*/
protected ?\DateTime $createdAt = null;
protected \DateTime $createdAt;
/**
* Description.

View File

@ -37,15 +37,84 @@ final class GSDCustomer
/**
* Created.
*
* @var null|\DateTime
* @var \DateTime
* @since 1.0.0
*/
protected ?\DateTime $createdAt = null;
protected \DateTime $createdAt;
private string $number = '';
private string $info = '';
private float $creditlimit = 0.0;
private string $egustid = '';
private string $taxid = '';
private string $bic = '';
private string $iban = '';
private GSDAddress $addr;
private int $deliveryStatus = 0;
private int $salesRep = 0;
public function __construct()
{
$this->addr = new GSDAddress();
$this->createdAt = new \DateTime('now');
}
public function getNumber() : string
{
return $this->number;
}
public function getInfo() : string
{
return $this->info;
}
public function getCreditLimit() : float
{
return $this->creditlimit;
}
public function getEGUstId() : string
{
return $this->egustid;
}
public function getTaxId() : string
{
return $this->taxid;
}
public function getBIC() : string
{
return $this->bic;
}
public function getIban() : string
{
return $this->iban;
}
public function getAddress() : GSDAddress
{
return $this->addr;
}
public function getDeliveryStatus() : int
{
return $this->deliveryStatus;
}
public function getSalesRep() : int
{
return $this->salesRep;
}
}

View File

@ -33,14 +33,22 @@ final class GSDCustomerMapper extends DataMapperAbstract
* @since 1.0.0
*/
protected static array $columns = [
'row_id' => ['name' => 'row_id', 'type' => 'int', 'internal' => 'id'],
'row_create_time' => ['name' => 'row_create_time', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
'row_create_user' => ['name' => 'row_create_user', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'Kundennummer' => ['name' => 'Kundennummer', 'type' => 'string', 'internal' => 'number'],
'row_id' => ['name' => 'row_id', 'type' => 'int', 'internal' => 'id'],
'row_create_time' => ['name' => 'row_create_time', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
'row_create_user' => ['name' => 'row_create_user', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'Kundennummer' => ['name' => 'Kundennummer', 'type' => 'string', 'internal' => 'number'],
'Info' => ['name' => 'Info', 'type' => 'string', 'internal' => 'info'],
'Auftragssperre' => ['name' => 'Auftragssperre', 'type' => 'string', 'internal' => 'deliveryStatus'],
'KreditLimitintern' => ['name' => 'KreditLimitintern', 'type' => 'string', 'internal' => 'creditlimit'],
'EGUstId' => ['name' => 'EGUstId', 'type' => 'string', 'internal' => 'egustid'],
'Steuernummer' => ['name' => 'Steuernummer', 'type' => 'string', 'internal' => 'taxid'],
'BIC' => ['name' => 'BIC', 'type' => 'string', 'internal' => 'bic'],
'IBAN' => ['name' => 'IBAN', 'type' => 'string', 'internal' => 'iban'],
'Verkaeufer' => ['name' => 'Verkaeufer', 'type' => 'int', 'internal' => 'salesRep'],
];
protected static array $ownsOne = [
'mainAddress' => [
'addr' => [
'mapper' => GSDAddressMapper::class,
'self' => 'AddressId',
],

View File

@ -0,0 +1,99 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Exchange\Interfaces\GSD\Model
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Exchange\Interfaces\GSD\Model;
/**
* Model class.
*
* @package Modules\Exchange\Interfaces\GSD\Model
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class GSDSupplier
{
private int $id = 0;
/**
* Creator.
*
* @var int
* @since 1.0.0
*/
protected $createdBy = 0;
/**
* Created.
*
* @var \DateTime
* @since 1.0.0
*/
protected \DateTime $createdAt;
private string $number = '';
private string $info = '';
private string $taxid = '';
private string $bic = '';
private string $iban = '';
private GSDAddress $addr;
private int $deliveryStatus = 0;
public function __construct()
{
$this->addr = new GSDAddress();
$this->createdAt = new \DateTime('now');
}
public function getNumber() : string
{
return $this->number;
}
public function getInfo() : string
{
return $this->info;
}
public function getTaxId() : string
{
return $this->taxid;
}
public function getBIC() : string
{
return $this->bic;
}
public function getIban() : string
{
return $this->iban;
}
public function getAddress() : GSDAddress
{
return $this->addr;
}
public function getDeliveryStatus() : int
{
return $this->deliveryStatus;
}
}

View File

@ -0,0 +1,77 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Exchange\Interfaces\GSD\Model
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Exchange\Interfaces\GSD\Model;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Mapper class.
*
* @package Modules\Exchange\Interfaces\GSD\Model
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class GSDSupplierMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'row_id' => ['name' => 'row_id', 'type' => 'int', 'internal' => 'id'],
'row_create_time' => ['name' => 'row_create_time', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
'row_create_user' => ['name' => 'row_create_user', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'LieferantenNummer' => ['name' => 'LieferantenNummer', 'type' => 'string', 'internal' => 'number'],
'Info' => ['name' => 'Info', 'type' => 'string', 'internal' => 'info'],
'Auftragssperre' => ['name' => 'Auftragssperre', 'type' => 'string', 'internal' => 'deliveryStatus'],
'Steuernummer' => ['name' => 'Steuernummer', 'type' => 'string', 'internal' => 'taxid'],
'BIC' => ['name' => 'BIC', 'type' => 'string', 'internal' => 'bic'],
'IBAN' => ['name' => 'IBAN', 'type' => 'string', 'internal' => 'iban'],
];
protected static array $ownsOne = [
'addr' => [
'mapper' => GSDAddressMapper::class,
'self' => 'AddressId',
],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'Lieferanten';
/**
* Created at.
*
* @var string
* @since 1.0.0
*/
protected static string $createdAt = 'row_create_time';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'row_id';
}

View File

@ -1,27 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Exchange\Interfaces\GSD\Model
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Exchange\Interfaces\GSD\Model;
/**
* Model class.
*
* @package Modules\Exchange\Interfaces\GSD\Model
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class Supplier
{
}