too many changes

This commit is contained in:
Dennis Eichhorn 2023-03-11 23:38:19 +01:00
parent d2c701b897
commit bd78091c8e
18 changed files with 127 additions and 38 deletions

View File

@ -141,6 +141,50 @@
"default_value": "",
"values": []
},
{
"name": "purchase_tax_code",
"l11n": {
"en": "Purchse tax code",
"de": "VSt. code"
},
"value_type": 2,
"is_custom_allowed": false,
"validation_pattern": "",
"is_required": true,
"default_value": "",
"values": [
{ "value": "AT" },
{ "value": "BE" },
{ "value": "BG" },
{ "value": "HR" },
{ "value": "CY" },
{ "value": "CZ" },
{ "value": "DK" },
{ "value": "EE" },
{ "value": "FI" },
{ "value": "FR" },
{ "value": "DE" },
{ "value": "GR" },
{ "value": "HU" },
{ "value": "IE" },
{ "value": "IT" },
{ "value": "LV" },
{ "value": "LT" },
{ "value": "LU" },
{ "value": "MT" },
{ "value": "NL" },
{ "value": "PL" },
{ "value": "PT" },
{ "value": "RO" },
{ "value": "SK" },
{ "value": "SI" },
{ "value": "ES" },
{ "value": "SE" },
{ "value": "GB" },
{ "value": "INT" },
{ "value": "EU" }
]
},
{
"name": "order_limit",
"l11n": {
@ -166,5 +210,31 @@
"is_required": false,
"default_value": "",
"values": []
},
{
"name": "bill_match_pattern",
"l11n": {
"en": "Bill match pattern",
"de": "Beleg-Zeichenkette"
},
"value_type": 2,
"is_custom_allowed": true,
"validation_pattern": "",
"is_required": false,
"default_value": "",
"values": []
},
{
"name": "bill_date_format",
"l11n": {
"en": "Bill date format",
"de": "Beleg-Datumsformat"
},
"value_type": 2,
"is_custom_allowed": true,
"validation_pattern": "",
"is_required": false,
"default_value": "",
"values": []
}
]

View File

@ -39,12 +39,12 @@
"type": "DATETIME",
"null": false
},
"suppliermgmt_supplier_profile": {
"name": "suppliermgmt_supplier_profile",
"suppliermgmt_supplier_account": {
"name": "suppliermgmt_supplier_account",
"type": "INT",
"null": false,
"foreignTable": "profile_account",
"foreignKey": "profile_account_id"
"foreignTable": "account",
"foreignKey": "account_id"
},
"suppliermgmt_supplier_address": {
"name": "suppliermgmt_supplier_address",

View File

@ -203,8 +203,8 @@ final class Installer extends InstallerAbstract
$request->header->account = 1;
$request->setData('value', $value['value'] ?? '');
$request->setData('unit', $value['unit'] ?? '');
$request->setData('default', isset($attribute['values']) && !empty($attribute['values']));
$request->setData('attributetype', $supplierAttrType[$attribute['name']]['id']);
$request->setData('default', true);
$request->setData('type', $supplierAttrType[$attribute['name']]['id']);
if (isset($value['l11n']) && !empty($value['l11n'])) {
$request->setData('title', \reset($value['l11n']));

View File

@ -97,11 +97,9 @@ final class ApiController extends Controller
$account->name1 = (string) ($request->getData('name1') ?? '');
$account->name2 = (string) ($request->getData('name2') ?? '');
$profile = new Profile($account);
$supplier = new Supplier();
$supplier->number = (string) ($request->getData('number') ?? '');
$supplier->profile = $profile;
$supplier->account = $account;
$addr = new Address();
$addr->address = (string) ($request->getData('address') ?? '');
@ -161,7 +159,7 @@ final class ApiController extends Controller
$supplierL11n = $this->createSupplierL11nFromRequest($request);
$this->createModel($request->header->account, $supplierL11n, SupplierL11nMapper::class, 'supplier_l11n', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Supplier localization', 'Supplier localization successfully created', $supplierL11n);
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Localization successfully created', $supplierL11n);
}
/**
@ -232,7 +230,7 @@ final class ApiController extends Controller
$supplierL11nType = $this->createSupplierL11nTypeFromRequest($request);
$this->createModel($request->header->account, $supplierL11nType, SupplierL11nTypeMapper::class, 'supplier_l11n_type', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Supplier localization type', 'Supplier localization type successfully created', $supplierL11nType);
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization type', 'Localization type successfully created', $supplierL11nType);
}
/**
@ -364,7 +362,7 @@ final class ApiController extends Controller
$attrL11n = $this->createSupplierAttributeTypeL11nFromRequest($request);
$this->createModel($request->header->account, $attrL11n, SupplierAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute type localization', 'Attribute type localization successfully created', $attrL11n);
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Localization successfully created', $attrL11n);
}
/**
@ -589,7 +587,7 @@ final class ApiController extends Controller
$attrL11n = $this->createSupplierAttributeValueL11nFromRequest($request);
$this->createModel($request->header->account, $attrL11n, SupplierAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute type localization', 'Attribute type localization successfully created', $attrL11n);
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Localization successfully created', $attrL11n);
}
/**

View File

@ -145,9 +145,7 @@ final class BackendController extends Controller
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003202001, $request, $response));
$supplier = SupplierMapper::getAll()
->with('profile')
->with('profile/account')
->with('profile/image')
->with('account')
->with('mainAddress')
->limit(25)
->execute();
@ -204,8 +202,7 @@ final class BackendController extends Controller
/** @var \Modules\SupplierManagement\Models\Supplier $supplier */
$supplier = SupplierMapper::get()
->with('profile')
->with('profile/account')
->with('account')
->with('contactElements')
->with('mainAddress')
->with('files')->limit(5, 'files')->sort('files/id', OrderType::DESC)

View File

@ -54,7 +54,7 @@ class Supplier
public \DateTimeImmutable $createdAt;
public Profile $profile;
public Account $account;
/**
* Attributes.
@ -104,7 +104,7 @@ class Supplier
public function __construct()
{
$this->createdAt = new \DateTimeImmutable('now');
$this->profile = new Profile();
$this->account = new Account();
$this->mainAddress = new NullAddress();
}
@ -276,6 +276,17 @@ class Supplier
return $this->attributes;
}
public function getAttributeByTypeName(string $name) : SupplierAttribute
{
foreach ($this->attributes as $attribute) {
if ($attribute->type->name === $name) {
return $attribute;
}
}
return new NullSupplierAttribute();
}
/**
* Get contacts.
*

View File

@ -70,5 +70,5 @@ final class SupplierAttributeMapper extends DataMapperFactory
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD ='suppliermgmt_supplier_attr_id';
public const PRIMARYFIELD = 'suppliermgmt_supplier_attr_id';
}

View File

@ -109,6 +109,17 @@ class SupplierAttributeType implements \JsonSerializable
return $this->id;
}
public function getDefaultByValue(mixed $value) : SupplierAttributeValue
{
foreach ($this->defaults as $default) {
if ($default->getValue() === $value) {
return $default;
}
}
return new NullSupplierAttributeValue();
}
/**
* Set l11n
*

View File

@ -54,7 +54,7 @@ final class SupplierAttributeTypeL11nMapper extends DataMapperFactory
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD ='suppliermgmt_attr_type_l11n_id';
public const PRIMARYFIELD = 'suppliermgmt_attr_type_l11n_id';
/**
* Model to use by the mapper.

View File

@ -78,5 +78,5 @@ final class SupplierAttributeTypeMapper extends DataMapperFactory
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD ='suppliermgmt_attr_type_id';
public const PRIMARYFIELD = 'suppliermgmt_attr_type_id';
}

View File

@ -54,7 +54,7 @@ final class SupplierAttributeValueL11nMapper extends DataMapperFactory
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD ='suppliermgmt_attr_value_l11n_id';
public const PRIMARYFIELD = 'suppliermgmt_attr_value_l11n_id';
/**
* Model to use by the mapper.

View File

@ -73,5 +73,5 @@ final class SupplierAttributeValueMapper extends DataMapperFactory
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD ='suppliermgmt_attr_value_id';
public const PRIMARYFIELD = 'suppliermgmt_attr_value_id';
}

View File

@ -67,5 +67,5 @@ final class SupplierL11nMapper extends DataMapperFactory
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD ='suppliermgmt_supplier_l11n_id';
public const PRIMARYFIELD = 'suppliermgmt_supplier_l11n_id';
}

View File

@ -52,5 +52,5 @@ final class SupplierL11nTypeMapper extends DataMapperFactory
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD ='suppliermgmt_supplier_l11n_type_id';
public const PRIMARYFIELD = 'suppliermgmt_supplier_l11n_type_id';
}

View File

@ -14,11 +14,11 @@ declare(strict_types=1);
namespace Modules\SupplierManagement\Models;
use Modules\Admin\Models\AccountMapper;
use Modules\Admin\Models\AddressMapper;
use Modules\Editor\Models\EditorDocMapper;
use Modules\Media\Models\MediaMapper;
use Modules\Profile\Models\ContactElementMapper;
use Modules\Profile\Models\ProfileMapper;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
@ -45,7 +45,7 @@ final class SupplierMapper extends DataMapperFactory
'suppliermgmt_supplier_type' => ['name' => 'suppliermgmt_supplier_type', 'type' => 'int', 'internal' => 'type'],
'suppliermgmt_supplier_info' => ['name' => 'suppliermgmt_supplier_info', 'type' => 'string', 'internal' => 'info'],
'suppliermgmt_supplier_created_at' => ['name' => 'suppliermgmt_supplier_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
'suppliermgmt_supplier_profile' => ['name' => 'suppliermgmt_supplier_profile', 'type' => 'int', 'internal' => 'profile'],
'suppliermgmt_supplier_account' => ['name' => 'suppliermgmt_supplier_account', 'type' => 'int', 'internal' => 'account'],
'suppliermgmt_supplier_address' => ['name' => 'suppliermgmt_supplier_address', 'type' => 'int', 'internal' => 'mainAddress'],
'suppliermgmt_supplier_unit' => ['name' => 'suppliermgmt_supplier_unit', 'type' => 'int', 'internal' => 'unit'],
];
@ -64,7 +64,7 @@ final class SupplierMapper extends DataMapperFactory
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD ='suppliermgmt_supplier_id';
public const PRIMARYFIELD = 'suppliermgmt_supplier_id';
/**
* Created at column
@ -81,9 +81,9 @@ final class SupplierMapper extends DataMapperFactory
* @since 1.0.0
*/
public const OWNS_ONE = [
'profile' => [
'mapper' => ProfileMapper::class,
'external' => 'suppliermgmt_supplier_profile',
'account' => [
'mapper' => AccountMapper::class,
'external' => 'suppliermgmt_supplier_account',
],
'mainAddress' => [
'mapper' => AddressMapper::class,

View File

@ -69,11 +69,11 @@ echo $this->getData('nav')->render();
<tr><td><label for="iId"><?= $this->getHtml('ID', '0', '0'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="number" id="iId" min="1" name="id" value="<?= $this->printHtml($supplier->number); ?>" disabled></span>
<tr><td><label for="iName1"><?= $this->getHtml('Name1'); ?></label>
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($supplier->profile->account->name1); ?>" required>
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($supplier->account->name1); ?>" required>
<tr><td><label for="iName2"><?= $this->getHtml('Name2'); ?></label>
<tr><td><input type="text" id="iName2" name="name2" value="<?= $this->printHtml($supplier->profile->account->name2); ?>">
<tr><td><input type="text" id="iName2" name="name2" value="<?= $this->printHtml($supplier->account->name2); ?>">
<tr><td><label for="iName3"><?= $this->getHtml('Name3'); ?></label>
<tr><td><input type="text" id="iName3" name="name3" value="<?= $this->printHtml($supplier->profile->account->name3); ?>">
<tr><td><input type="text" id="iName3" name="name3" value="<?= $this->printHtml($supplier->account->name3); ?>">
</table>
</div>
<div class="portlet-foot">

View File

@ -1,6 +1,6 @@
{
"name": "karaka/karaka",
"description": "PHP Framework for Karaka.",
"description": "PHP Framework for Jingga.",
"authors": [
{
"name": "Dennis Eichhorn",

View File

@ -11,13 +11,15 @@
"phpOMS-db": "1.0.0"
},
"creator": {
"name": "Karaka",
"name": "Jingga",
"website": "jingga.app"
},
"description": "Supplier management module.",
"directory": "SupplierManagement",
"dependencies": {
"Admin": "1.0.0",
"Media": "1.0.0",
"Payment": "1.0.0",
"Editor": "1.0.0"
},
"providing": {