Skip to content

Commit 7d530c8

Browse files
committed
Squashed 'package/marello/' changes from dac3d53..e2134fd
e2134fd Merge commit 'e2af974edb72ae5923ecdf4dd34249e13ebf9f31' into maintenance/3.0 324cba8 - renamed migrations to take newer versions of migrations into account on the develop branch 7fc60c7 - updated return notifications with ProductUnit on line items - added migration to update existing templates 4e71779 - updated email templates with Product Unit on the line items - Added migration to update email templates in existing installations 7b7407c - updated grids to include productUnit - updated PDF providers to include ProductUnit in PDF's - updated mappers either get the unit from the OrderItem or null d20075c - renamed unitOfMeasurement in InventoryItem to use the ProducUnit to keep it consistent in all entities having this relation - added ProductUnit to PackingSlipItem and InvoiceItem, InvoiceItem uses a different approach because it has a inheritance table and the EntityExtendBundle didn't really like this setup by adding an Extended field 544f773 - updated test to check for the Unit Of Measurement being set on the OrderItem after the Order is saved 3e39516 - Updated OrderItemProductUnitListener to first check the InventoryItem for a UnitOfMeasurement before going straight to the default, the previous logic for checking it's empty before assigning is still in place - Updated service definition of the OrderItemProductUnitListener to use the InventoryItemManager and get the necessary data from there instead of only using the DoctrineHelper 34cb160 - Added unitOfMeasurement to the InventoryItem view b5ab255 - added unitOfMeasurement to InventoryItem grid with filters and sorters db865d0 - Added unitOfMeasurement to InventoryItem - Updated tests for UoM - Added translations for inventory item UoM - Added default UoM when product is created (which is followed by creating and attaching the InventoryItem) 3cc166c - removed unique index on Customer primary/shipping address as it is a theoretical posibility that they are exactly the same address 584f866 Merge branch 'task/MAR10001-0-add-replenishment-field-to-variant-grid' into maintenance/3.0 f0b0ccd Merge branch 'task/MAR10001-932-add-validation-to-Order-delivery-date' into maintenance/3.0 e170548 - Added the replenishment field to the variant grid for seeing continuation of the product b6d7f17 - fixed some price alignment, not specifically to the right, but at least in line with each others TH; - even though Oro's right aligment did work, it only worked with a 'crowed' table, as soon as only a few columns are in the grid, the whole things 'falls apart' and are not actually aligned to the right b150ac8 - added validation message for DeliveryDate if date is not set in the future 5b6426f - Added deliveryDate validation to make sure the date is set in the future and not in the past 32f7b4c Merge branch 'bugfix/MAR10001-941-po-recalculation-advised-products' into maintenance/3.0 1f2c18c - updated condition to trigger the tax calculations for Order rows when creating an Order through the GUI - previously the calculation wouldn't trigger because the region was not set in the customer's shippingAddress f26ffdd - fixed issue with recalculation not being triggered when items in the advised grid are either updated with an amount or quantity - added additional trigger / listener to trigger the recalculation in this collection 6490937 Merge commit '0434749faa01bc372d0f6507d95e6c63b21d687a' into maintenance/3.0 a913e8d - remove disabled code from SalesChannelType form type af094b9 Merge branch 'feature/magento2-integr' into testmerge-magentoint 0a5c725 - removing BC break from order view regarding payments 3baf789 - fixed issue with Migration where it was trying to create the order table on updating the application while it already exists - fixed issue with association name in the Enum field being inconsistent between the installer and the migration - Added additional enum options such as Box and Pallet 4a509e5 MAR10001-931: Update Order and OrderItem entities with additional fields ba7bed3 Merge commit '2d726c233b9ee46e8df989abddab3e08d8d7a417' into maintenance/3.0 27b7007 - fixed issue with checking companyNumber on null while trying to render the PDF template f16cfe6 - fixed issue with misquoting the columns on the unique constraint in the Company entity f5ed9ad Merge commit '171e747c96d54e8f0821d6c20507350aafa607d3' into maintenance/3.0 7bd2784 MM-26: Test and stabilize product sync feature - Fixed issue with check connection on existing integration - Fixed issue with invalid transformations of pricing value triggers update prices on every save of product form 125bbe8 - removed commit reference in validation file 1c0060e Merge commit 'eb90b8fcfaedb948656084d945666cfebbe15532' into maintenance/3.0 34dbdfe - renamed Company code to Company number - added pdf translation - moved company number on the PDF 68d20ae MAR10001-909: Add Company ID to Company d719683 MM-25: Add logic for product prices and inventory synchronization (#50) bdf568e - fixed issue with installing by updating the OrderBundle Installer by updating the migration version to the correct version - fixed issue with shipping_method_reference setter on the Order entity, the setter needed to accept that it can be null 4c54cd3 - Added Shippingmethod reference as new field to the Order entity - Removed shippingmethod validation from the commerce validation group on the Order entity - added translation for shipping method reference - updated Order view layout to have all the source references (order reference, invoice reference and shippingmethod reference) in the same block and below the customer information 229daed Merge commit 'c3d7d6c1d492f690fe42956c139d0ead4c8a26cf' into maintenance/3.0 96e7019 Merge commit 'b065d549972a67f4a7ee98e2774243a9e2b80092' into maintenance/3.0 cd128f1 - Removed replenishment enum field from InventoryItem form type as this has already been added through the DynamicFieldsExtension c019a6c Merge commit '39e05989e588eb7890665615fcc9b727f1c1f47e' into maintenance/3.0 c4b1b9e Merge branch 'task/MAR10001-0-qol-fixes-orocommerce-bridge' into maintenance/3.0 a61f403 - added missing validator translations regarding shipping method rules and configs 357cc70 - updated validation regarding Customer, Company and Address - moved the validation to the correct bundles instead of having it all in the OrderBundle validation file 3929205 MM-13: Implement initial products export (#49) 7478a59 Merge commit '04ca95074be3a990fed20bc103c82c73a59c7ef7' into maintenance/3.0 e2a0f48 - updated email SendProcessor to do not send emails or try to send emails when the recipients array is empty - updated validation groups for the Order entity to be able to save Orders without a Customer for the commerce group c9bb1d0 - updated data attribute of order to make sure when creating a new order via `new Order()` will have the data attribute as an array instead of null ad17b0a - Updated OrderWorkflowStart event listener's service definition to inject doctrinehelper a2215e6 - updated OrderWorkflowStart listener to use the doctrine helper from Oro to get the correct entity manager for the class instead of the event's entity manager df0ac89 - fixed issue with product duplication error when the action group registry is not a public service anymore, created a provider that injects said service and retrieving it via the provider that has been created as a public service 592e2e7 MM-23: Add logic to process changes in integration (#47) d543090 - dropped unique index on integration ID on SalesChannel to allow a SalesChannelGroup with multiple SC's be connected to the integration - moved some fields around in the integration settings form - updated the OroCommerce integration event listener to take into account the integration is now linked to a SalesChannelGroup and not a single SalesChannel 9f3d6dc - removed required asterisk from Description on SalesChannel as this is not a required field 5cc3984 - removed required asterisk from description as this is not required in the SCG d9db8bb MM-22: Add logic to process changes in Sales Channel (#46) 854eab6 MM-8: Add logic for tax class dictionary synchronization (#45) e2ebbb0 MM-6: Prepare logic for dictionary synchronization (#40) 9968fae MM-4: Create Magento2 integration form - Added missed constraints 4ce69ce MM-4: Create Magento2 integration form git-subtree-dir: package/marello git-subtree-split: e2134fd
1 parent e2af974 commit 7d530c8

File tree

65 files changed

+762
-108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+762
-108
lines changed

src/Marello/Bundle/CustomerBundle/Migrations/Schema/MarelloCustomerBundleInstaller.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MarelloCustomerBundleInstaller implements
3434
*/
3535
public function getMigrationVersion()
3636
{
37-
return 'v1_4';
37+
return 'v1_4_1';
3838
}
3939

4040
/**
@@ -106,8 +106,6 @@ protected function createMarelloCustomerTable(Schema $schema)
106106
$table->addColumn('tax_identification_number', 'string', ['notnull' => false, 'length' => 255]);
107107
$table->addColumn('company_id', 'integer', ['notnull' => false]);
108108
$table->setPrimaryKey(['id']);
109-
$table->addUniqueIndex(['primary_address_id'], 'UNIQ_75C456C9F5B7AF75');
110-
$table->addUniqueIndex(['shipping_address_id'], 'UNIQ_75C456C94D4CFF2B');
111109
$table->addIndex(['organization_id']);
112110

113111
$this->attachmentExtension->addAttachmentAssociation($schema, $table->getName());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace Marello\Bundle\CustomerBundle\Migrations\Schema\v1_4_1;
4+
5+
use Doctrine\DBAL\Schema\Schema;
6+
7+
use Oro\Bundle\MigrationBundle\Migration\Migration;
8+
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
9+
use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtension;
10+
use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtensionAwareInterface;
11+
12+
use Marello\Bundle\CustomerBundle\Migrations\Schema\MarelloCustomerBundleInstaller;
13+
14+
class MarelloCustomerBundle implements Migration
15+
{
16+
/**
17+
* @inheritDoc
18+
*/
19+
public function up(Schema $schema, QueryBag $queries)
20+
{
21+
$table = $schema->getTable(MarelloCustomerBundleInstaller::MARELLO_CUSTOMER_TABLE);
22+
// drop unique indexes for customer primary and shipping address
23+
if ($table->hasIndex('UNIQ_75C456C9F5B7AF75')) {
24+
$table->dropIndex('UNIQ_75C456C9F5B7AF75');
25+
}
26+
27+
if ($table->hasIndex('UNIQ_75C456C94D4CFF2B')) {
28+
$table->dropIndex('UNIQ_75C456C94D4CFF2B');
29+
}
30+
31+
if ($table->hasForeignKey('FK_AD0CE5A24D4CFF2B')) {
32+
$table->removeForeignKey('FK_AD0CE5A24D4CFF2B');
33+
$table->addForeignKeyConstraint(
34+
$schema->getTable('marello_address'),
35+
['shipping_address_id'],
36+
['id'],
37+
['onDelete' => null, 'onUpdate' => null]
38+
);
39+
}
40+
if ($table->hasForeignKey('FK_AD0CE5A2CB134313')) {
41+
$table->removeForeignKey('FK_AD0CE5A2CB134313');
42+
$table->addForeignKeyConstraint(
43+
$schema->getTable('marello_address'),
44+
['primary_address_id'],
45+
['id'],
46+
['onDelete' => null, 'onUpdate' => null]
47+
);
48+
}
49+
}
50+
}

src/Marello/Bundle/InventoryBundle/Entity/InventoryItem.php

+34
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,21 @@ class InventoryItem extends ExtendInventoryItem implements ProductAwareInterface
282282
*/
283283
protected $enableBatchInventory;
284284

285+
/**
286+
* @var \Extend\Entity\EV_Marello_Product_Unit
287+
* @Oro\ConfigField(
288+
* defaultValues={
289+
* "dataaudit"={
290+
* "auditable"=true
291+
* },
292+
* "importexport"={
293+
* "excluded"=true
294+
* }
295+
* }
296+
* )
297+
*/
298+
protected $productUnit;
299+
285300
/**
286301
* InventoryItem constructor.
287302
*
@@ -594,4 +609,23 @@ public function setEnableBatchInventory($enableBatchInventory)
594609

595610
return $this;
596611
}
612+
613+
/**
614+
* @return \Extend\Entity\EV_Marello_Product_Unit
615+
*/
616+
public function getProductUnit()
617+
{
618+
return $this->productUnit;
619+
}
620+
621+
/**
622+
* @param string $productUnit
623+
* @return $this
624+
*/
625+
public function setProductUnit($productUnit)
626+
{
627+
$this->productUnit = $productUnit;
628+
629+
return $this;
630+
}
597631
}

src/Marello/Bundle/InventoryBundle/EventListener/OnProductCreateEventListener.php

+18
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ protected function createInventoryItem(Product $entity)
5858
$result = $this->inventoryItemManager->createInventoryItem($entity);
5959
if ($result) {
6060
$inventoryItem = $this->checkReplenishment($result);
61+
$inventoryItem = $this->checkProductUnit($inventoryItem);
6162
$this->em->persist($inventoryItem);
6263
$classMeta = $this->em->getClassMetadata(get_class($inventoryItem));
6364
$this->unitOfWork->computeChangeSet($classMeta, $inventoryItem);
@@ -81,6 +82,23 @@ protected function checkReplenishment($item)
8182
return $item;
8283
}
8384

85+
/**
86+
* @param InventoryItem $item
87+
* @return mixed
88+
*/
89+
protected function checkProductUnit($item)
90+
{
91+
if (!$item->getProductUnit()) {
92+
// get default product unit option
93+
$productUnit = $this->inventoryItemManager->getDefaultProductUnit();
94+
if ($productUnit) {
95+
$item->setProductUnit($productUnit);
96+
}
97+
}
98+
99+
return $item;
100+
}
101+
84102
/**
85103
* @param array $records
86104
* @return array

src/Marello/Bundle/InventoryBundle/Form/Type/InventoryItemType.php

+9
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ public function buildForm(FormBuilderInterface $builder, array $options)
126126
'label' => 'marello.inventory.inventoryitem.enable_batch_inventory.label'
127127
]
128128
)
129+
->add(
130+
'productUnit',
131+
EnumChoiceType::class,
132+
[
133+
'enum_code' => 'marello_product_unit',
134+
'required' => false,
135+
'label' => 'marello.inventory.inventoryitem.product_unit.label',
136+
]
137+
)
129138
->addEventListener(FormEvents::PRE_SET_DATA, [$this, 'preSetDataListener']);
130139
if ($this->subscriber !== null) {
131140
$builder->addEventSubscriber($this->subscriber);

src/Marello/Bundle/InventoryBundle/Manager/InventoryItemManager.php

+17-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
namespace Marello\Bundle\InventoryBundle\Manager;
44

5-
use Marello\Bundle\InventoryBundle\Entity\InventoryItem;
6-
use Marello\Bundle\ProductBundle\Entity\Product;
75
use Oro\Bundle\EntityBundle\ORM\DoctrineHelper;
86
use Oro\Bundle\EntityExtendBundle\Tools\ExtendHelper;
7+
use Oro\Bundle\EntityExtendBundle\Entity\Repository\EnumValueRepository;
8+
9+
use Marello\Bundle\ProductBundle\Entity\Product;
10+
use Marello\Bundle\InventoryBundle\Entity\InventoryItem;
11+
use Marello\Bundle\ProductBundle\Migrations\Data\ORM\LoadProductUnitData;
912

1013
class InventoryItemManager implements InventoryItemManagerInterface
1114
{
@@ -76,6 +79,18 @@ public function getDefaultReplenishment()
7679
return $repo->findOneBy(['default' => 1]);
7780
}
7881

82+
/**
83+
* Get default product unit for InventoryItem
84+
* @return null|object
85+
*/
86+
public function getDefaultProductUnit()
87+
{
88+
$productUnit = ExtendHelper::buildEnumValueClassName(LoadProductUnitData::PRODUCT_UNIT_ENUM_CLASS);
89+
/** @var EnumValueRepository $repo */
90+
$repo = $this->doctrineHelper->getEntityRepository($productUnit);
91+
return $repo->findOneByDefault(true);
92+
}
93+
7994
/**
8095
* Get an InventoryItem to delete based on the Product
8196
* @param $product

src/Marello/Bundle/InventoryBundle/Manager/InventoryItemManagerInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Marello\Bundle\InventoryBundle\Manager;
44

5+
// @todo next release add getDefaultUnitOfMeasurement() as interface method
6+
57
interface InventoryItemManagerInterface
68
{
79
public function createInventoryItem($product);

src/Marello/Bundle/InventoryBundle/Migrations/Schema/MarelloInventoryBundleInstaller.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MarelloInventoryBundleInstaller implements Installation, ExtendExtensionAw
2525
*/
2626
public function getMigrationVersion()
2727
{
28-
return 'v2_4';
28+
return 'v2_5_1';
2929
}
3030

3131
/**
@@ -89,6 +89,17 @@ protected function createMarelloInventoryItemTable(Schema $schema)
8989
'extend' => ['owner' => ExtendScope::OWNER_CUSTOM],
9090
]
9191
);
92+
$this->extendExtension->addEnumField(
93+
$schema,
94+
$table,
95+
'productUnit',
96+
'marello_product_unit',
97+
false,
98+
false,
99+
[
100+
'extend' => ['owner' => ExtendScope::OWNER_SYSTEM],
101+
]
102+
);
92103

93104
$table->setPrimaryKey(['id']);
94105
$table->addUniqueIndex(['product_id'], 'UNIQ_40B8D0414584665A', []);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace Marello\Bundle\InventoryBundle\Migrations\Schema\v2_5_1;
4+
5+
use Doctrine\DBAL\Schema\Schema;
6+
7+
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
8+
use Oro\Bundle\MigrationBundle\Migration\Migration;
9+
use Oro\Bundle\EntityExtendBundle\EntityConfig\ExtendScope;
10+
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtension;
11+
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtensionAwareInterface;
12+
13+
class UpdateInventoryItemTable implements Migration, ExtendExtensionAwareInterface
14+
{
15+
const INVENTORY_ITEM_TABLE_NAME = 'marello_inventory_item';
16+
/**
17+
* @var ExtendExtension
18+
*/
19+
protected $extendExtension;
20+
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
public function up(Schema $schema, QueryBag $queries)
25+
{
26+
$this->updateInventoryItemTable($schema);
27+
}
28+
29+
/**
30+
* {@inheritdoc}
31+
* @param Schema $schema
32+
* @param QueryBag $queries
33+
* @throws \Doctrine\DBAL\Schema\SchemaException
34+
*/
35+
protected function updateInventoryItemTable(Schema $schema)
36+
{
37+
$table = $schema->getTable(self::INVENTORY_ITEM_TABLE_NAME);
38+
$this->extendExtension->addEnumField(
39+
$schema,
40+
$table,
41+
'productUnit',
42+
'marello_product_unit',
43+
false,
44+
false,
45+
[
46+
'extend' => ['owner' => ExtendScope::OWNER_SYSTEM],
47+
]
48+
);
49+
}
50+
51+
/**
52+
* Sets the ExtendExtension
53+
*
54+
* @param ExtendExtension $extendExtension
55+
*/
56+
public function setExtendExtension(ExtendExtension $extendExtension)
57+
{
58+
$this->extendExtension = $extendExtension;
59+
}
60+
}

src/Marello/Bundle/InventoryBundle/Resources/config/oro/datagrids.yml

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ datagrids:
88
- p.denormalizedDefaultName as productName
99
- p.sku as productSku
1010
- i.enableBatchInventory as enableBatchInventory
11+
- productUnit.name as productUnit
1112
- COALESCE(SUM(il.inventory), 0) AS inventoryQty
1213
- COALESCE(SUM(il.allocatedInventory), 0) AS allocatedInventoryQty
1314
- COALESCE(SUM(il.inventory - il.allocatedInventory), 0) AS virtualInventoryQty
@@ -17,6 +18,7 @@ datagrids:
1718
left:
1819
- { join: i.product, alias: p }
1920
- { join: i.inventoryLevels, alias: il }
21+
- { join: i.productUnit, alias: productUnit }
2022
groupBy: i.id
2123
columns:
2224
productSku:
@@ -29,6 +31,10 @@ datagrids:
2931
label: marello.product.names.label
3032
frontend_type: string
3133
data_name: productName
34+
productUnit:
35+
label: marello.inventory.inventoryitem.product_unit.label
36+
frontend_type: string
37+
data_name: productUnit
3238
enableBatchInventory:
3339
label: marello.inventory.inventoryitem.enable_batch_inventory.label
3440
frontend_type: boolean
@@ -49,6 +55,7 @@ datagrids:
4955
columns:
5056
productSku: { data_name: p.sku }
5157
productName: { data_name: p.denormalizedDefaultName }
58+
productUnit: { data_name: productUnit }
5259
enableBatchInventory: { data_name: enableBatchInventory }
5360
inventoryQty: { data_name: inventoryQty }
5461
allocatedInventoryQty: { data_name: allocatedInventoryQty }
@@ -63,6 +70,10 @@ datagrids:
6370
productName:
6471
type: string
6572
data_name: p.denormalizedDefaultName
73+
productUnit:
74+
type: enum
75+
data_name: productUnit
76+
enum_code: marello_product_unit
6677
enableBatchInventory:
6778
type: boolean
6879
data_name: enableBatchInventory

src/Marello/Bundle/InventoryBundle/Resources/translations/messages.en.yml

+2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ marello:
7676
pre_orders_datetime.label: Pre-orders Datetime
7777
order_on_demand_allowed.label: Order on demand allowed
7878
enable_batch_inventory.label: Enable Batch Inventory
79+
product_unit.label: Unit
7980

8081
section:
82+
unit_of_measurement.label: Unit of Measurement
8183
backorder_preorder.label: Backorder/Pre-order
8284
backorder.label: Backorder
8385
preorder.label: Pre-order

src/Marello/Bundle/InventoryBundle/Resources/views/Inventory/update.html.twig

+12
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@
4747
'title': 'marello.product.product_information'|trans
4848
}) }}
4949
</div>
50+
<div class="box-type1">
51+
<div class="title">
52+
<span class="widget-title">{{ 'marello.inventory.inventoryitem.section.unit_of_measurement.label'|trans }}</span>
53+
</div>
54+
<div class="widget-content">
55+
<div class="row-fluid form-horizontal">
56+
<div class="responsive-block">
57+
{{ form_row(form.productUnit) }}
58+
</div>
59+
</div>
60+
</div>
61+
</div>
5062
</div>
5163
</div>
5264
</div>

src/Marello/Bundle/InventoryBundle/Resources/views/Inventory/view.html.twig

+12
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@
4040
'title': 'marello.product.product_information'|trans
4141
}) }}
4242
</div>
43+
<div class="box-type1">
44+
<div class="title">
45+
<span class="widget-title">{{ 'marello.inventory.inventoryitem.section.unit_of_measurement.label'|trans }}</span>
46+
</div>
47+
<div class="widget-content">
48+
<div class="row-fluid form-horizontal">
49+
<div class="responsive-block">
50+
{{ UI.renderProperty('marello.inventory.inventoryitem.product_unit.label'|trans, entity.productUnit|default('N/A')) }}
51+
</div>
52+
</div>
53+
</div>
54+
</div>
4355
</div>
4456
</div>
4557
</div>

0 commit comments

Comments
 (0)