Skip to content

Commit

Permalink
Merge branch 'feature/MAR10001-880' into merge-service-points-30
Browse files Browse the repository at this point in the history
  • Loading branch information
24198 committed May 6, 2021
2 parents c23d429 + d7bf5f8 commit fdd1425
Show file tree
Hide file tree
Showing 159 changed files with 5,924 additions and 630 deletions.
4 changes: 2 additions & 2 deletions src/Marello/Bundle/CatalogBundle/Entity/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* @ORM\Table(name="marello_catalog_category",
* uniqueConstraints={
* @ORM\UniqueConstraint(
* name="marello_catalog_category_codeidx",
* columns={"code"}
* name="marello_catalog_category_codeorgidx",
* columns={"code", "organization_id"}
* )
* }
* )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MarelloCatalogBundleInstaller implements Installation, ActivityExtensionAw
*/
public function getMigrationVersion()
{
return 'v1_1_1';
return 'v1_2';
}

/**
Expand Down Expand Up @@ -61,7 +61,7 @@ protected function createCatalogCategoryTable(Schema $schema)
$table->addColumn('updated_at', 'datetime', ['notnull' => false]);
$table->addColumn('organization_id', 'integer', ['notnull' => false]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['code'], 'marello_catalog_category_codeidx');
$table->addUniqueIndex(['code', 'organization_id'], 'marello_catalog_category_codeorgidx');

$this->activityExtension->addActivityAssociation($schema, 'oro_note', 'marello_catalog_category');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Marello\Bundle\CatalogBundle\Migrations\Schema\v1_2;

use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

/**
* @SuppressWarnings(PHPMD.TooManyMethods)
*/
class MarelloCatalogBundle implements Migration
{
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$this->changeMarelloCatalogCategoryUniqueIndex($schema);
}

/**
* @param Schema $schema
*/
protected function changeMarelloCatalogCategoryUniqueIndex(Schema $schema)
{
$table = $schema->getTable('marello_catalog_category');
$table->dropIndex('marello_catalog_category_codeidx');
$table->addUniqueIndex(['code', 'organization_id'], 'marello_catalog_category_codeorgidx');
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Marello\Bundle\CatalogBundle\Entity\Category:
constraints:
- Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity:
fields: code
fields: [code, organization]
message: 'marello.catalog.category.messages.error.code'
properties:
name:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Marello\Bundle\CustomerBundle\Controller;

use Marello\Bundle\CustomerBundle\Entity\Customer;
use Oro\Bundle\NoteBundle\Entity\Note;
use Oro\Bundle\NoteBundle\Entity\Repository\NoteRepository;
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Marello\Bundle\CustomerBundle\Entity\Company:
message: 'marello.customer.company.number.message'
properties:
name:
- NotBlank: ~
- NotBlank: ~
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

namespace Marello\Bundle\DataGridBundle\Extension\Totals;

use Oro\Bundle\DataGridBundle\Extension\Formatter\Property\PropertyInterface;
use Oro\Bundle\DataGridBundle\Extension\Totals\Configuration;
use Oro\Bundle\DataGridBundle\Extension\Totals\OrmTotalsExtension as BaseOrmTotalsExtension;

class OrmTotalsExtension extends BaseOrmTotalsExtension
{
/**
* {@inheritDoc}
*/
protected function getTotalData($rowConfig, $data)
{
if (empty($data)) {
return [];
}

$columns = [];
foreach ($rowConfig['columns'] as $field => $total) {
$column = [];
if (isset($data[$field])) {
$totalValue = $data[$field];
if (isset($total[Configuration::TOTALS_DIVISOR_KEY])) {
$divisor = (int) $total[Configuration::TOTALS_DIVISOR_KEY];
if ($divisor != 0) {
$totalValue = $totalValue / $divisor;
}
}
if (isset($total[Configuration::TOTALS_FORMATTER_KEY])) {
if ($total[Configuration::TOTALS_FORMATTER_KEY] === 'currency' && isset($data['currency'])) {
$totalValue = $this->applyFrontendFormatting(
[$totalValue, $data['currency']],
$total[Configuration::TOTALS_FORMATTER_KEY]
);
} else {
$totalValue = $this->applyFrontendFormatting(
$totalValue,
$total[Configuration::TOTALS_FORMATTER_KEY]
);
}
}
$column['total'] = $totalValue;
}
if (isset($total[Configuration::TOTALS_LABEL_KEY])) {
$column[Configuration::TOTALS_LABEL_KEY] =
$this->translator->trans($total[Configuration::TOTALS_LABEL_KEY]);
}
$columns[$field] = $column;
};

return ['columns' => $columns];
}

/**
* {@inheritDoc}
*/
protected function applyFrontendFormatting($val = null, $formatter = null)
{
if (null === $formatter) {
return $val;
}

switch ($formatter) {
case PropertyInterface::TYPE_DATE:
$val = $this->dateTimeFormatter->formatDate($val);
break;
case PropertyInterface::TYPE_DATETIME:
$val = $this->dateTimeFormatter->format($val);
break;
case PropertyInterface::TYPE_TIME:
$val = $this->dateTimeFormatter->formatTime($val);
break;
case PropertyInterface::TYPE_DECIMAL:
$val = $this->numberFormatter->formatDecimal($val);
break;
case PropertyInterface::TYPE_INTEGER:
$val = $this->numberFormatter->formatDecimal($val);
break;
case PropertyInterface::TYPE_PERCENT:
$val = $this->numberFormatter->formatPercent($val);
break;
case PropertyInterface::TYPE_CURRENCY:
$val = is_array($val) ?
$this->numberFormatter->formatCurrency($val[0], $val[1]) :
$this->numberFormatter->formatCurrency($val);
break;
}

return $val;
}
}
13 changes: 12 additions & 1 deletion src/Marello/Bundle/DataGridBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ services:
class: 'Marello\Bundle\DataGridBundle\EventListener\Datagrid\RowSelectionSelectAllListener'
tags:
- { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after, method: onBuildAfter, priority: 250 }
- { name: kernel.event_listener, event: oro_datagrid.orm_datasource.result.after, method: onResultAfter }
- { name: kernel.event_listener, event: oro_datagrid.orm_datasource.result.after, method: onResultAfter }

marello_datagrid.extension.totals:
class: 'Marello\Bundle\DataGridBundle\Extension\Totals\OrmTotalsExtension'
decorates: oro_datagrid.extension.totals
arguments:
- '@translator'
- '@oro_locale.formatter.number'
- '@oro_locale.formatter.date_time'
- '@oro_security.acl_helper'
tags:
- { name: oro_datagrid.extension }
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Marello\Bundle\ProductBundle\Entity\Builder\ProductFamilyBuilder;
use Marello\Bundle\ProductBundle\Entity\Product;
use Marello\Bundle\ProductBundle\Migrations\Data\ORM\LoadDefaultAttributeFamilyData;
use Marello\Bundle\SalesBundle\Entity\SalesChannel;
use Oro\Bundle\EntityConfigBundle\Attribute\Entity\AttributeFamily;
use Oro\Bundle\LocaleBundle\Entity\LocalizedFallbackValue;
Expand Down Expand Up @@ -127,7 +127,7 @@ private function createProduct(array $data)
/** @var AttributeFamily $attributeFamily */
$attributeFamily = $this->manager
->getRepository(AttributeFamily::class)
->findOneByCode(LoadDefaultAttributeFamilyData::DEFAULT_FAMILY_CODE);
->findOneByCode(ProductFamilyBuilder::DEFAULT_FAMILY_CODE);
$product->setAttributeFamily($attributeFamily);

return $product;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Marello\Bundle\DemoDataBundle\Migrations\Data\Demo\ORM;

use Marello\Bundle\SalesBundle\Migrations\Data\ORM\LoadSalesChannelTypesData as BaseLoadSalesChannelTypesData;

class LoadSalesChannelTypesData extends BaseLoadSalesChannelTypesData
{
/** @var array */
protected $data = [
'pos' => 'Pos',
'webshop' => 'Webshop',
'marketplace' => 'Marketplace'
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;

use Marello\Bundle\SalesBundle\Entity\SalesChannel;
use Marello\Bundle\SalesBundle\Entity\SalesChannelGroup;
use Marello\Bundle\SalesBundle\Entity\SalesChannelType;
use Marello\Bundle\SalesBundle\Migrations\Data\ORM\LoadSalesChannelGroupData as MigrationLoadSalesChannelGroupData;

class LoadSalesData extends AbstractFixture implements DependentFixtureInterface
Expand Down Expand Up @@ -95,6 +95,7 @@ public function getDependencies()
{
return [
MigrationLoadSalesChannelGroupData::class,
LoadSalesChannelTypesData::class
];
}

Expand All @@ -118,7 +119,7 @@ protected function loadSalesChannels()

foreach ($this->data as $values) {
$channel = (new SalesChannel($values['name']))
->setChannelType($values['type'])
->setChannelType($this->findTypeByName($values['type']))
->setCode($values['code'])
->setCurrency($values['currency'])
->setOwner($organization)
Expand All @@ -131,4 +132,21 @@ protected function loadSalesChannels()

$this->manager->flush();
}

/**
* @param string $name
* @return null|SalesChannelType
*/
private function findTypeByName($name)
{
$type = $this->manager
->getRepository(SalesChannelType::class)
->find($name);

if ($type) {
return $type;
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class InventoryLevelLogRecord

/**
* @ORM\ManyToOne(targetEntity="Marello\Bundle\InventoryBundle\Entity\InventoryLevel")
* @ORM\JoinColumn(name="inventory_level_id", referencedColumnName="id")
* @ORM\JoinColumn(name="inventory_level_id", referencedColumnName="id", onDelete="SET NULL")
* @Oro\ConfigField(
* defaultValues={
* "entity"={
Expand All @@ -57,7 +57,7 @@ class InventoryLevelLogRecord
/**
* @ORM\ManyToOne(targetEntity="Marello\Bundle\InventoryBundle\Entity\InventoryItem",
* cascade={"persist", "remove"})
* @ORM\JoinColumn(name="inventory_item_id", referencedColumnName="id", onDelete="CASCADE")
* @ORM\JoinColumn(name="inventory_item_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)
* @Oro\ConfigField(
* defaultValues={
* "entity"={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,13 @@ protected function findInventoryBatch(InventoryBatch $entity)
protected function getProduct($entity)
{
return $this->databaseHelper
->findOneBy(Product::class, ['sku' => $entity->getInventoryItem()->getProduct()->getSku()]);
->findOneBy(
Product::class,
[
'sku' => $entity->getInventoryItem()->getProduct()->getSku(),
'organization' => $entity->getOrganization()
]
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ protected function createMarelloInventoryInventoryLogLevelTable(Schema $schema)
$table->addColumn('warehouse_name', 'string', ['notnull' => true, 'length' => 255]);
$table->setPrimaryKey(['id']);
$table->addIndex(['inventory_item_id']);
$table->addIndex(['inventory_level_id']);
$table->addIndex(['user_id'], 'IDX_32D13BA4F675F31B', []);
}

Expand Down Expand Up @@ -374,6 +375,12 @@ protected function addMarelloInventoryInventoryLevelLogForeignKeys(Schema $schem
['id'],
['onDelete' => 'CASCADE', 'onUpdate' => null]
);
$table->addForeignKeyConstraint(
$schema->getTable('marello_inventory_level'),
['inventory_level_id'],
['id'],
['onDelete' => 'SET NULL', 'onUpdate' => null]
);
$table->addForeignKeyConstraint(
$schema->getTable('oro_user'),
['user_id'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Marello\Bundle\InventoryBundle\Migrations\Schema\v2_5;

use Doctrine\DBAL\Schema\Schema;

use Oro\Bundle\MigrationBundle\Migration\QueryBag;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\OrderedMigrationInterface;

class UpdateInventoryLevelLogForeignKey implements Migration
{
const INVENTORY_LEVEL_LOG_TABLE_NAME = 'marello_inventory_level_log';
const INVENTORY_LEVEL_TABLE_NAME = 'marello_inventory_level';

/**
* @inheritdoc
*/
public function up(Schema $schema, QueryBag $queries)
{
$this->updateInventoryLevelLogForeignKeyConstraint($schema, $queries);
}

/**
* {@inheritdoc}
* @param Schema $schema
* @param QueryBag $queries
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
protected function updateInventoryLevelLogForeignKeyConstraint(Schema $schema, $queries)
{
$table = $schema->getTable(self::INVENTORY_LEVEL_LOG_TABLE_NAME);
$table->addIndex(['inventory_level_id']);
$table->addForeignKeyConstraint(
$schema->getTable(self::INVENTORY_LEVEL_TABLE_NAME),
['inventory_level_id'],
['id'],
['onDelete' => 'SET NULL', 'onUpdate' => null]
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
use Marello\Bundle\InventoryBundle\Tests\Functional\DataFixtures\LoadInventoryData;
use Marello\Bundle\PricingBundle\Tests\Functional\DataFixtures\LoadProductChannelPricingData;

/**
* @dbIsolationPerTest
* @nestTransactionsWithSavepoints
*/
class InventoryControllerTest extends WebTestCase
{
/**
Expand Down
Loading

0 comments on commit fdd1425

Please sign in to comment.