Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
WarehouseManagement
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 install
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3 * Jingga
4 *
5 * PHP Version 8.1
6 *
7 * @package   Modules\Billing\Admin\Install
8 * @copyright Dennis Eichhorn
9 * @license   OMS License 2.0
10 * @version   1.0.0
11 * @link      https://jingga.app
12 */
13declare(strict_types=1);
14
15namespace Modules\Billing\Admin\Install;
16
17use phpOMS\Application\ApplicationAbstract;
18use phpOMS\Autoloader;
19use phpOMS\DataStorage\Database\Schema\Builder;
20
21/**
22 * WarehouseManagement class.
23 *
24 * @package Modules\Billing\Admin\Install
25 * @license OMS License 2.0
26 * @link    https://jingga.app
27 * @since   1.0.0
28 */
29class WarehouseManagement
30{
31    /**
32     * Install comment relation
33     *
34     * @param ApplicationAbstract $app  Application
35     * @param string              $path Module path
36     *
37     * @return void
38     *
39     * @throws \Exception
40     *
41     * @since 1.0.0
42     */
43    public static function install(ApplicationAbstract $app, string $path) : void
44    {
45        $builder = new Builder($app->dbPool->get('schema'));
46        $builder->alterTable('billing_bill')
47            ->addConstraint('billing_bill_stock_from', 'warehousemgmt_stocklocation', 'warehousemgmt_stocklocation_id')
48            ->execute();
49
50        $builder = new Builder($app->dbPool->get('schema'));
51        $builder->alterTable('billing_bill')
52            ->addConstraint('billing_bill_stock_to', 'warehousemgmt_stocklocation', 'warehousemgmt_stocklocation_id')
53            ->execute();
54
55        $mapper = \file_get_contents(__DIR__ . '/../../Models/BillMapper.php');
56        if ($mapper === false) {
57            throw new \Exception('Couldn\'t parse mapper');
58        }
59
60        $mapper = \str_replace([
61            '// @Module WarehouseManagement ',
62            '/* @Module WarehouseManagement ',
63            ' @Module WarehouseManagement */',
64            ], '', $mapper);
65        \file_put_contents(__DIR__ . '/../../Models/BillMapper.php', $mapper);
66
67        Autoloader::invalidate(__DIR__ . '/../../Models/BillMapper.php');
68    }
69}