fix phpstan/phpcs

This commit is contained in:
Dennis Eichhorn 2021-06-26 14:38:08 +02:00
parent 3cc6b94a94
commit 2045b9b0bd
10 changed files with 121 additions and 60 deletions

View File

@ -29,8 +29,8 @@ class Navigation
/**
* Install navigation providing
*
* @param string $path Module path
* @param ApplicationAbstract $app Application
* @param string $path Module path
* @param ApplicationAbstract $app Application
*
* @return void
*

View File

@ -34,24 +34,31 @@ use Modules\WarehouseManagement\Models\StockLocationMapper;
*/
final class Installer extends InstallerAbstract
{
/**
/**
* {@inheritdoc}
*/
public static function install(DatabasePool $dbPool, ModuleInfo $info, SettingsInterface $cfgHandler) : void
{
parent::install($dbPool, $info, $cfgHandler);
self::createStock();
self::createDefaultStock();
}
private static function createStock() : void
/**
* Creates a default stock
*
* @return void
*
* @since 1.0.0
*/
private static function createDefaultStock() : void
{
$stock = new Stock('Default');
$stock->type = 0;
StockMapper::create($stock);
$stock = new Stock('Default');
$stock->type = 0;
StockMapper::create($stock);
$stockLocation = new StockLocation((string) ($stock->getId() . '-1'));
$stockLocation->stock = $stock;
StockLocationMapper::create($stockLocation);
$stockLocation = new StockLocation((string) ($stock->getId() . '-1'));
$stockLocation->stock = $stock;
StockLocationMapper::create($stockLocation);
}
}

View File

@ -32,8 +32,8 @@ use Modules\WarehouseManagement\Models\StockShelfMapper;
*/
final class ApiController extends Controller
{
public function eventStockCreateInternal(
int $account,
public function eventStockCreateInternal(
int $account,
mixed $old,
mixed $new,
int $type = 0,
@ -42,23 +42,23 @@ final class ApiController extends Controller
string $ref = null,
string $content = null,
string $ip = null
) : void
{
$stock = new Stock($new->number);
$stock->type = 1;
StockMapper::create($stock);
) : void
{
$stock = new Stock($new->number);
$stock->type = 1;
StockMapper::create($stock);
$stockLocation = new StockLocation($stock->name . '-1');
$stockLocation->stock = $stock->getId();
StockLocationMapper::create($stockLocation);
$stockLocation = new StockLocation($stock->name . '-1');
$stockLocation->stock = $stock->getId();
StockLocationMapper::create($stockLocation);
$stockShelf = new StockShelf($stockLocation->name . '-1');
$stockShelf->location = $stockLocation->getId();
StockShelfMapper::create($stockShelf);
}
$stockShelf = new StockShelf($stockLocation->name . '-1');
$stockShelf->location = $stockLocation->getId();
StockShelfMapper::create($stockShelf);
}
public function eventBillUpdateInternal(
int $account,
public function eventBillUpdateInternal(
int $account,
mixed $old,
mixed $new,
int $type = 0,
@ -67,24 +67,24 @@ final class ApiController extends Controller
string $ref = null,
string $content = null,
string $ip = null
) : void
{
if ($trigger === 'POST:Module:Billing-bill_element-create') {
// @todo: if is bill element create, create stock movement
) : void
{
if ($trigger === 'POST:Module:Billing-bill_element-create') {
// @todo: if is bill element create, create stock movement
} elseif ($trigger === 'POST:Module:Billing-bill_element-update') {
// quantity change
// lot changes
// stock changes
// all other changes ignore!
// check availability again, if not available abort bill
} elseif ($trigger === 'POST:Module:Billing-bill_element-delete') {
// @todo: delete stock movement
} elseif ($trigger === 'POST:Module:Billing-bill-delete') {
// @todo: delete stock movements
} elseif ($trigger === 'POST:Module:Billing-bill-update') {
// is receiver update -> change all movements
// is status update -> change all movements (delete = delete)
}
}
} elseif ($trigger === 'POST:Module:Billing-bill_element-update') {
// quantity change
// lot changes
// stock changes
// all other changes ignore!
// check availability again, if not available abort bill
} elseif ($trigger === 'POST:Module:Billing-bill_element-delete') {
// @todo: delete stock movement
} elseif ($trigger === 'POST:Module:Billing-bill-delete') {
// @todo: delete stock movements
} elseif ($trigger === 'POST:Module:Billing-bill-update') {
// is receiver update -> change all movements
// is status update -> change all movements (delete = delete)
}
}
}

View File

@ -31,7 +31,7 @@ use phpOMS\Views\View;
*/
final class BackendController extends Controller
{
/**
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request

View File

@ -27,5 +27,6 @@ use phpOMS\Stdlib\Base\Enum;
abstract class PermissionState extends Enum
{
public const STOCK = 1;
public const STOCK_LOCATION = 2;
}

View File

@ -32,17 +32,37 @@ class Stock
*/
private int $id = 0;
/**
* NAme.
*
* @var string
* @since 1.0.0
*/
public string $name = '';
public int $type = 0;
/**
* Constructor.
*
* @param string $name Stock name
*
* @since 1.0.0
*/
public function __construct(string $name = '')
{
$this->name = $name;
}
/**
* Get id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
return $this->id;
}
}

View File

@ -42,13 +42,27 @@ class StockLocation
public int $z = 0;
/**
* Constructor.
*
* @param string $name Stock name
*
* @since 1.0.0
*/
public function __construct(string $name = '')
{
$this->name = $name;
}
/**
* Get id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
return $this->id;
}
}

View File

@ -67,6 +67,11 @@ class StockMovement
*/
public \DateTimeImmutable $createdAt;
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
$this->createdBy = new NullAccount();

View File

@ -26,21 +26,21 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class StockMovementType extends Enum
{
public const MERGE = 1;
public const SPLIT = 2;
public const MERGE = 1;
public const SPLIT = 2;
public const INCREASE = 4;
public const DECREASE = 8;
public const TRANSFER = 16;
// @todo: subtypes, maybe creates as database subtypes during install.
public const DESTROY = 1; // 8
public const RETURN = 1; // 8
public const INVENTORY_PLUS = 1; // 4
public const INVENTORY_MINUS = 1; // 8
public const PURCHASE = 1; // 4
public const SALE = 1; // 4
public const DESTROY = 1; // 8
public const RETURN = 1; // 8
public const INVENTORY_PLUS = 1; // 4
public const INVENTORY_MINUS = 1; // 8
public const PURCHASE = 1; // 4
public const SALE = 1; // 4
public const MANUFACTURE_CREATE = 1; // 4
public const MANUFACTURE_USE = 1; // 8
public const MANUAL = 1; // 1-16
public const MANUFACTURE_USE = 1; // 8
public const MANUAL = 1; // 1-16
}

View File

@ -42,13 +42,27 @@ class StockShelf
public int $z = 0;
/**
* Constructor.
*
* @param string $name Shelf name
*
* @since 1.0.0
*/
public function __construct(string $name = '')
{
$this->name = $name;
}
/**
* Get id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
return $this->id;
}
}