id)>'
attributes:
- taxIdentificationNumber: null
namePrefix: null
firstName: James
middleName: null
diff --git a/src/Marello/Bundle/CustomerBundle/Tests/Unit/Autocomplete/ParentCompanySearchHandlerTest.php b/src/Marello/Bundle/CustomerBundle/Tests/Unit/Autocomplete/ParentCompanySearchHandlerTest.php
index 6aef4d9ee..4e94db197 100644
--- a/src/Marello/Bundle/CustomerBundle/Tests/Unit/Autocomplete/ParentCompanySearchHandlerTest.php
+++ b/src/Marello/Bundle/CustomerBundle/Tests/Unit/Autocomplete/ParentCompanySearchHandlerTest.php
@@ -337,10 +337,6 @@ protected function assertSearchCall(
$queryBuilder->expects($this->once())
->method('getQuery')
->will($this->returnValue($query));
- $this->aclHelper->expects($this->once())
- ->method('apply')
- ->with($query)
- ->will($this->returnValue($query));
$this->entityRepository
->expects($this->any())
->method('createQueryBuilder')
diff --git a/src/Marello/Bundle/DataGridBundle/Extension/Totals/OrmTotalsExtension.php b/src/Marello/Bundle/DataGridBundle/Extension/Totals/OrmTotalsExtension.php
new file mode 100644
index 000000000..2aae85c53
--- /dev/null
+++ b/src/Marello/Bundle/DataGridBundle/Extension/Totals/OrmTotalsExtension.php
@@ -0,0 +1,93 @@
+ $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;
+ }
+}
diff --git a/src/Marello/Bundle/DataGridBundle/Resources/config/services.yml b/src/Marello/Bundle/DataGridBundle/Resources/config/services.yml
index 9ca7fb00c..d0b491e69 100644
--- a/src/Marello/Bundle/DataGridBundle/Resources/config/services.yml
+++ b/src/Marello/Bundle/DataGridBundle/Resources/config/services.yml
@@ -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 }
\ No newline at end of file
+ - { 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 }
diff --git a/src/Marello/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadProductData.php b/src/Marello/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadProductData.php
index b6bfa942b..575d87d3f 100644
--- a/src/Marello/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadProductData.php
+++ b/src/Marello/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadProductData.php
@@ -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;
@@ -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;
diff --git a/src/Marello/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadProductImageData.php b/src/Marello/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadProductImageData.php
index 72ab3ecf7..90b62718c 100644
--- a/src/Marello/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadProductImageData.php
+++ b/src/Marello/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadProductImageData.php
@@ -79,7 +79,7 @@ public function loadProductImages()
}
/**
- * @param $sku
+ * @param $sku
* @return null
*/
protected function getProductImage($sku)
@@ -87,13 +87,15 @@ protected function getProductImage($sku)
try {
$imagePath = $this->getImagePath($sku);
$fileManager = $this->container->get('oro_attachment.file_manager');
- $image = $fileManager->createFileEntity($imagePath);
- if ($image) {
- $this->manager->persist($image);
- $image->setOwner($this->adminUser);
- }
+ if ($imagePath) {
+ $image = $fileManager->createFileEntity($imagePath);
+ if ($image) {
+ $this->manager->persist($image);
+ $image->setOwner($this->adminUser);
+ }
- return $image;
+ return $image;
+ }
} catch (\Exception $e) {
//image not found
}
diff --git a/src/Marello/Bundle/FilterBundle/DependencyInjection/MarelloFilterExtension.php b/src/Marello/Bundle/FilterBundle/DependencyInjection/MarelloFilterExtension.php
new file mode 100644
index 000000000..34a3ea6b7
--- /dev/null
+++ b/src/Marello/Bundle/FilterBundle/DependencyInjection/MarelloFilterExtension.php
@@ -0,0 +1,26 @@
+load('services.yml');
+ }
+}
diff --git a/src/Marello/Bundle/FilterBundle/Filter/ChoiceLikeFilter.php b/src/Marello/Bundle/FilterBundle/Filter/ChoiceLikeFilter.php
new file mode 100644
index 000000000..4238cd266
--- /dev/null
+++ b/src/Marello/Bundle/FilterBundle/Filter/ChoiceLikeFilter.php
@@ -0,0 +1,52 @@
+getQueryBuilder();
+ $parameter = $qb->getParameter($parameterName);
+ $value = $parameter->getValue();
+ if (is_array($value)) {
+ $comparisonExpressions = [];
+ foreach ($value as $key => $valueItem) {
+ if ($key !== 0) {
+ $parameterName = sprintf('%s%d', $parameterName, $key);
+ }
+ $qb->setParameter($parameterName, '%|' . $valueItem . '|%');
+ switch ($comparisonType) {
+ case ChoiceFilterType::TYPE_NOT_CONTAINS:
+ $comparisonExpressions[] = $ds->expr()->notLike($fieldName, $parameterName, true);
+ break;
+ default:
+ $comparisonExpressions[] = $ds->expr()->like($fieldName, $parameterName, true);
+ }
+ }
+
+ return call_user_func_array([$ds->expr(), 'andX'], $comparisonExpressions);
+ } else {
+ switch ($comparisonType) {
+ case ChoiceFilterType::TYPE_NOT_CONTAINS:
+ return $ds->expr()->notLike($fieldName, $parameterName, true);
+ default:
+ return $ds->expr()->like($fieldName, $parameterName, true);
+ }
+ }
+ }
+}
diff --git a/src/Marello/Bundle/FilterBundle/Resources/config/services.yml b/src/Marello/Bundle/FilterBundle/Resources/config/services.yml
new file mode 100644
index 000000000..74f91ae18
--- /dev/null
+++ b/src/Marello/Bundle/FilterBundle/Resources/config/services.yml
@@ -0,0 +1,9 @@
+services:
+ marello_filter.choice_like_filter:
+ class: Marello\Bundle\FilterBundle\Filter\ChoiceLikeFilter
+ public: false
+ arguments:
+ - '@form.factory'
+ - '@oro_filter.filter_utility'
+ tags:
+ - { name: oro_filter.extension.orm_filter.filter, type: choice_like }
diff --git a/src/Marello/Bundle/InventoryBundle/Controller/InventoryLevelController.php b/src/Marello/Bundle/InventoryBundle/Controller/InventoryLevelController.php
index e9c4c3428..7b08946c7 100644
--- a/src/Marello/Bundle/InventoryBundle/Controller/InventoryLevelController.php
+++ b/src/Marello/Bundle/InventoryBundle/Controller/InventoryLevelController.php
@@ -115,4 +115,23 @@ public function manageBatchesAction(InventoryLevel $inventoryLevel, Request $req
$request
);
}
+
+ /**
+ * @Route(
+ * path="/manage-batches/view/{id}",
+ * requirements={"id"="\d+"},
+ * name="marello_inventory_inventorylevel_batches_view"
+ * )
+ * @Template("MarelloInventoryBundle:InventoryLevel:batchesView.html.twig")
+ *
+ * @param InventoryLevel $inventoryLevel
+ *
+ * @return array
+ */
+ public function viewAction(InventoryLevel $inventoryLevel)
+ {
+ return [
+ 'entity' => $inventoryLevel
+ ];
+ }
}
diff --git a/src/Marello/Bundle/InventoryBundle/Entity/InventoryBatch.php b/src/Marello/Bundle/InventoryBundle/Entity/InventoryBatch.php
index 3968d7f2c..dccf9f59c 100644
--- a/src/Marello/Bundle/InventoryBundle/Entity/InventoryBatch.php
+++ b/src/Marello/Bundle/InventoryBundle/Entity/InventoryBatch.php
@@ -14,9 +14,6 @@
/**
* @ORM\Entity()
* @Oro\Config(
- * routeView="marello_inventory_batch_view",
- * routeName="marello_inventory_batch_index",
- * routeCreate="marello_inventory_batch_create",
* defaultValues={
* "entity"={
* "icon"="fa-cubes"
diff --git a/src/Marello/Bundle/InventoryBundle/Entity/InventoryLevelLogRecord.php b/src/Marello/Bundle/InventoryBundle/Entity/InventoryLevelLogRecord.php
index da464135b..a710028a8 100644
--- a/src/Marello/Bundle/InventoryBundle/Entity/InventoryLevelLogRecord.php
+++ b/src/Marello/Bundle/InventoryBundle/Entity/InventoryLevelLogRecord.php
@@ -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"={
@@ -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"={
diff --git a/src/Marello/Bundle/InventoryBundle/EventListener/Datagrid/InventoryLevelGridListener.php b/src/Marello/Bundle/InventoryBundle/EventListener/Datagrid/InventoryLevelGridListener.php
new file mode 100644
index 000000000..36c4b6c13
--- /dev/null
+++ b/src/Marello/Bundle/InventoryBundle/EventListener/Datagrid/InventoryLevelGridListener.php
@@ -0,0 +1,68 @@
+doctrineHelper = $helper;
+ }
+
+ /**
+ * @param BuildBefore $event
+ */
+ public function onBuildBefore(BuildBefore $event)
+ {
+ $inventoryItemId = $this->getParameter($event->getDatagrid(), 'inventoryItemId');
+ /** @var InventoryItem $inventoryItem */
+ $inventoryItem = $this->doctrineHelper
+ ->getEntityRepositoryForClass(InventoryItem::class)
+ ->find($inventoryItemId);
+ if ($inventoryItem->isEnableBatchInventory()) {
+ $config = $event->getConfig();
+ $columns = $config->offsetGetByPath('[columns]');
+ $columns = array_merge(
+ $columns,
+ [
+ 'manageBatches' => [
+ 'label' => 'marello.inventory.inventorylevel.grid.batches.label',
+ 'type' => 'twig',
+ 'frontend_type' => 'html',
+ 'template' => 'MarelloInventoryBundle:Inventory/Datagrid:manageBatches.html.twig',
+ ]
+ ]
+ );
+ $config->offsetSetByPath('[columns]', $columns);
+ }
+ }
+
+ /**
+ * @param DatagridInterface $datagrid
+ * @param string $parameterName
+ * @return mixed
+ */
+ protected function getParameter(DatagridInterface $datagrid, $parameterName)
+ {
+ $value = $datagrid->getParameters()->get($parameterName);
+
+ if ($value === null) {
+ throw new \LogicException(sprintf('Parameter "%s" must be set', $parameterName));
+ }
+
+ return $value;
+ }
+}
diff --git a/src/Marello/Bundle/InventoryBundle/Form/Type/InventoryBatchType.php b/src/Marello/Bundle/InventoryBundle/Form/Type/InventoryBatchType.php
index 8e3419cc0..c98608e50 100644
--- a/src/Marello/Bundle/InventoryBundle/Form/Type/InventoryBatchType.php
+++ b/src/Marello/Bundle/InventoryBundle/Form/Type/InventoryBatchType.php
@@ -76,6 +76,13 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'disabled' => true
]
)
+ ->add(
+ 'deliveryDate',
+ OroDateType::class,
+ [
+ 'required' => false
+ ]
+ )
->add(
'purchasePrice',
NumberType::class,
diff --git a/src/Marello/Bundle/InventoryBundle/ImportExport/Strategy/InventoryLevelUpdateStrategy.php b/src/Marello/Bundle/InventoryBundle/ImportExport/Strategy/InventoryLevelUpdateStrategy.php
index e440ea43d..c09621acc 100644
--- a/src/Marello/Bundle/InventoryBundle/ImportExport/Strategy/InventoryLevelUpdateStrategy.php
+++ b/src/Marello/Bundle/InventoryBundle/ImportExport/Strategy/InventoryLevelUpdateStrategy.php
@@ -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()
+ ]
+ );
}
/**
diff --git a/src/Marello/Bundle/InventoryBundle/Migrations/Schema/MarelloInventoryBundleInstaller.php b/src/Marello/Bundle/InventoryBundle/Migrations/Schema/MarelloInventoryBundleInstaller.php
index 554d7b846..818dbce7e 100644
--- a/src/Marello/Bundle/InventoryBundle/Migrations/Schema/MarelloInventoryBundleInstaller.php
+++ b/src/Marello/Bundle/InventoryBundle/Migrations/Schema/MarelloInventoryBundleInstaller.php
@@ -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', []);
}
@@ -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'],
diff --git a/src/Marello/Bundle/InventoryBundle/Migrations/Schema/v2_5/UpdateInventoryLevelLogForeignKey.php b/src/Marello/Bundle/InventoryBundle/Migrations/Schema/v2_5/UpdateInventoryLevelLogForeignKey.php
new file mode 100644
index 000000000..e74871fc2
--- /dev/null
+++ b/src/Marello/Bundle/InventoryBundle/Migrations/Schema/v2_5/UpdateInventoryLevelLogForeignKey.php
@@ -0,0 +1,41 @@
+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]
+ );
+ }
+}
diff --git a/src/Marello/Bundle/InventoryBundle/Resources/config/eventlistener.yml b/src/Marello/Bundle/InventoryBundle/Resources/config/eventlistener.yml
index 494fbd959..81f28de56 100644
--- a/src/Marello/Bundle/InventoryBundle/Resources/config/eventlistener.yml
+++ b/src/Marello/Bundle/InventoryBundle/Resources/config/eventlistener.yml
@@ -99,3 +99,10 @@ services:
- { name: doctrine.orm.entity_listener, entity: 'Marello\Bundle\InventoryBundle\Entity\InventoryItem', event: postPersist }
- { name: doctrine.orm.entity_listener, entity: 'Marello\Bundle\InventoryBundle\Entity\InventoryItem', event: preUpdate }
- { name: doctrine.event_listener, event: postFlush }
+
+ marello_inventory.event_listener.datagrid.inventory_level_grid:
+ class: 'Marello\Bundle\InventoryBundle\EventListener\Datagrid\InventoryLevelGridListener'
+ arguments:
+ - '@oro_entity.doctrine_helper'
+ tags:
+ - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.marello-inventory-levels, method: onBuildBefore }
\ No newline at end of file
diff --git a/src/Marello/Bundle/InventoryBundle/Resources/config/oro/datagrids.yml b/src/Marello/Bundle/InventoryBundle/Resources/config/oro/datagrids.yml
index 89595beae..50548077f 100644
--- a/src/Marello/Bundle/InventoryBundle/Resources/config/oro/datagrids.yml
+++ b/src/Marello/Bundle/InventoryBundle/Resources/config/oro/datagrids.yml
@@ -6,7 +6,6 @@ datagrids:
query:
select:
- i.id
- - p.denormalizedDefaultName as productName
- p.sku as productSku
- i.enableBatchInventory as enableBatchInventory
- pu.name as productUnit
@@ -30,8 +29,6 @@ datagrids:
template: MarelloProductBundle:Product/Datagrid:productSku.html.twig
productName:
label: marello.product.names.label
- frontend_type: string
- data_name: productName
productUnit:
label: marello.inventory.inventoryitem.product_unit.label
frontend_type: string
@@ -55,7 +52,7 @@ datagrids:
sorters:
columns:
productSku: { data_name: p.sku }
- productName: { data_name: p.denormalizedDefaultName }
+ productName: { data_name: productName }
productUnit: { data_name: productUnit }
enableBatchInventory: { data_name: enableBatchInventory }
inventoryQty: { data_name: inventoryQty }
@@ -70,7 +67,7 @@ datagrids:
data_name: p.sku
productName:
type: string
- data_name: p.denormalizedDefaultName
+ data_name: productName
productUnit:
type: enum
data_name: productUnit
@@ -92,6 +89,9 @@ datagrids:
filter_by_having: true
properties:
id: ~
+ productName:
+ type: localized_value
+ data_name: p.names
inventory_view_link:
type: url
route: marello_inventory_inventory_view
@@ -211,6 +211,7 @@ datagrids:
- il.updatedAt
- wht.label as warehouseTypeLabel
- wh.label as warehouse
+ - wh.code as warehouseCode
- COALESCE(il.inventory, 0) AS inventoryQty
- COALESCE(il.allocatedInventory, 0) AS allocatedInventoryQty
- COALESCE(il.inventory - il.allocatedInventory, 0) AS virtualInventoryQty
@@ -223,19 +224,23 @@ datagrids:
where:
and:
- IDENTITY(il.inventoryItem) = :inventoryItemId
- groupBy: il.id, wh.label, wht.label
+ groupBy: il.id, wh.code, wh.label, wht.label
bind_parameters:
inventoryItemId: inventoryItemId
columns:
warehouse:
label: marello.inventory.inventorylevel.warehouse.label
frontend_type: string
+ warehouseCode:
+ label: marello.inventory.inventorylevel.grid.warehouse_code.label
+ frontend_type: string
pickLocation:
label: marello.inventory.inventorylevel.pick_location.label
frontend_type: string
warehouseTypeLabel:
label: marello.inventory.warehousetype.entity_label
frontend_type: string
+ renderable: false
inventoryQty:
label: marello.inventory.inventorylevel.inventory.label
frontend_type: number
@@ -248,9 +253,18 @@ datagrids:
label: marello.inventory.inventorylevel.virtual_inventory.label
frontend_type: number
data_name: virtualInventoryQty
- updatedAt:
- label: oro.ui.updated_at
- frontend_type: datetime
+ filters:
+ columns:
+ warehouse:
+ type: string
+ data_name: warehouse
+ warehouseCode:
+ type: string
+ data_name: warehouseCode
+ warehouseTypeLabel:
+ type: string
+ data_name: warehouseTypeLabel
+ enabled: false
marello-balanced-inventory-levels-grid:
extended_entity_name: Marello\Bundle\InventoryBundle\Entity\BalancedInventoryLevel
@@ -259,7 +273,6 @@ datagrids:
query:
select:
- balancedInventoryLevel
- - p.denormalizedDefaultName as productName
- p.sku as productSku
- scg.name as salesChannelGroupName
from:
@@ -277,8 +290,6 @@ datagrids:
template: MarelloProductBundle:Product/Datagrid:productSku.html.twig
productName:
label: marello.product.names.label
- frontend_type: string
- data_name: productName
inventoryQty:
label: marello.inventory.balancedinventorylevel.inventory.label
frontend_type: integer
@@ -346,3 +357,50 @@ datagrids:
data_name: balancedInventoryLevel.reservedInventory
default:
productName: 'DESC'
+ properties:
+ productName:
+ type: localized_value
+ data_name: p.names
+
+ marello-inventory-batches:
+ extended_entity_name: Marello\Bundle\InventoryBundle\Entity\InventoryBatch
+ source:
+ type: orm
+ query:
+ select:
+ - ib
+ from:
+ - { table: MarelloInventoryBundle:InventoryBatch, alias: ib }
+ where:
+ and:
+ - IDENTITY(ib.inventoryLevel) = :inventoryLevelId
+ bind_parameters:
+ inventoryLevelId: inventoryLevelId
+ columns:
+ batchNumber:
+ label: marello.inventory.inventorybatch.batch_number.label
+ frontend_type: string
+ data_name: batchNumber
+ quantity:
+ label: marello.inventory.inventorybatch.quantity.label
+ frontend_type: integer
+ data_name: quantity
+ receivedDate:
+ label: marello.inventory.inventorybatch.date_received.label
+ frontend_type: datetime
+ data_name: deliveryDate
+ expirationDate:
+ label: marello.inventory.inventorybatch.expiration_date.label
+ frontend_type: datetime
+ data_name: expirationDate
+ purchasePrice:
+ label: marello.inventory.inventorybatch.purchase_price.label
+ frontend_type: currency
+ data_name: purchasePrice
+ options:
+ export: false
+ mass_actions: ~
+ toolbarOptions:
+ hide: true
+ pagination:
+ hide: true
\ No newline at end of file
diff --git a/src/Marello/Bundle/InventoryBundle/Resources/public/css/scss/main.scss b/src/Marello/Bundle/InventoryBundle/Resources/public/css/scss/main.scss
index 0f2612614..0c0477af9 100644
--- a/src/Marello/Bundle/InventoryBundle/Resources/public/css/scss/main.scss
+++ b/src/Marello/Bundle/InventoryBundle/Resources/public/css/scss/main.scss
@@ -16,7 +16,7 @@
.inventorylevel-warehouse {
.select2-container {
- width: 190px;
+ width: 300px;
.select2-choice {
.select2-arrow {
@@ -30,7 +30,7 @@
}
}
-.inventorylevel-adjustment {
+.inventorylevel-adjustment, .inventorybatch-adjustment {
.selector {
width: 100px !important;
@@ -48,6 +48,12 @@
}
}
+.inventorybatch-delivery-date, .inventorybatch-purchase-price, .inventorybatch-expiration-date {
+ input[type=text] {
+ width: 100px !important;
+ }
+}
+
// Font Awesome
.fa-caret-down:before {
content: "\f0d7";
diff --git a/src/Marello/Bundle/InventoryBundle/Resources/translations/messages.en.yml b/src/Marello/Bundle/InventoryBundle/Resources/translations/messages.en.yml
index cdf44347d..0eebca7b5 100644
--- a/src/Marello/Bundle/InventoryBundle/Resources/translations/messages.en.yml
+++ b/src/Marello/Bundle/InventoryBundle/Resources/translations/messages.en.yml
@@ -108,6 +108,11 @@ marello:
pick_location.label: Pick Location
inventory_batches.label: Inventory Batches
+ grid:
+ warehouse_code.label: Warehouse Code
+ batches.label: Batches
+ view_batches.label: View Batches
+
form:
manage_batches.label: Manage Batches
@@ -120,11 +125,12 @@ marello:
batch_reference.label: Batch Reference
purchase_reference.label: Purchase Reference
quantity.label: Quantity
- delivery_date.label: Delivery Date
+ date_received.label: Date Received
expiration_date.label: Expiration Date
purchase_price.label: Purchase Price
total_price.label: Total Price
organization.label: Organization
+ delivery_date.label: Delivery Date
inventorylevellogrecord:
id.label: Id
diff --git a/src/Marello/Bundle/InventoryBundle/Resources/views/Form/fields.html.twig b/src/Marello/Bundle/InventoryBundle/Resources/views/Form/fields.html.twig
index 47124c3be..613f4e6d7 100644
--- a/src/Marello/Bundle/InventoryBundle/Resources/views/Form/fields.html.twig
+++ b/src/Marello/Bundle/InventoryBundle/Resources/views/Form/fields.html.twig
@@ -108,7 +108,7 @@
-
+
{{ form_widget(form.adjustmentOperator) }}
@@ -118,14 +118,20 @@
{{ form_errors(form.adjustmentQuantity) }}
|
-
-
+
+
+ {{ form_widget(form.deliveryDate) }}
+
+ {{ form_errors(form.deliveryDate) }}
+ |
+
+
{{ form_widget(form.purchasePrice) }}
{{ form_errors(form.purchasePrice) }}
|
-
-
+
+
{{ form_widget(form.expirationDate) }}
{{ form_errors(form.expirationDate) }}
@@ -172,6 +178,7 @@
| {{ 'marello.inventory.inventorybatch.batch_number.label'|trans }} |
{{ 'marello.inventory.inventorybatch.quantity.label'|trans }} |
{{ 'marello.inventory.model.warehouse.adjustment.label'|trans }} |
+ {{ 'marello.inventory.inventorybatch.date_received.label'|trans }} |
{{ 'marello.inventory.inventorybatch.purchase_price.label'|trans }} |
{{ 'marello.inventory.inventorybatch.expiration_date.label'|trans }} |
diff --git a/src/Marello/Bundle/InventoryBundle/Resources/views/Inventory/Datagrid/manageBatches.html.twig b/src/Marello/Bundle/InventoryBundle/Resources/views/Inventory/Datagrid/manageBatches.html.twig
new file mode 100644
index 000000000..06e005d81
--- /dev/null
+++ b/src/Marello/Bundle/InventoryBundle/Resources/views/Inventory/Datagrid/manageBatches.html.twig
@@ -0,0 +1,5 @@
+
diff --git a/src/Marello/Bundle/InventoryBundle/Resources/views/InventoryLevel/batchesView.html.twig b/src/Marello/Bundle/InventoryBundle/Resources/views/InventoryLevel/batchesView.html.twig
new file mode 100644
index 000000000..541749a3f
--- /dev/null
+++ b/src/Marello/Bundle/InventoryBundle/Resources/views/InventoryLevel/batchesView.html.twig
@@ -0,0 +1,85 @@
+{% extends 'OroUIBundle:actions:view.html.twig' %}
+{% import 'OroUIBundle::macros.html.twig' as UI %}
+{% import 'OroDataGridBundle::macros.html.twig' as dataGrid %}
+
+{% block navButtons %}
+ {{ UI.cancelButton(path('marello_inventory_inventory_view', { 'id': entity.inventoryItem.id }), 'Back'|trans) }}
+ {% if is_granted('EDIT', entity) %}
+ {{ UI.editButton({
+ 'path' : path('marello_inventory_inventorylevel_manage_batches', { id: entity.id }),
+ 'entity_label': 'marello.inventory.inventorybatch.entity_label'|trans
+ }) }}
+ {% endif %}
+{% endblock navButtons %}
+
+{% block pageHeader %}
+ {% set breadcrumbs = {
+ 'entity': form.vars.value,
+ 'indexPath': path('marello_inventory_inventory_index'),
+ 'indexLabel': 'marello.inventory.label'|trans,
+ 'entityTitle': 'marello.inventory.inventorybatch.entity_plural_label'|trans,
+ 'additional': [{
+ 'indexPath': path('marello_inventory_inventory_view', {'id': entity.inventoryItem.id}),
+ 'indexLabel': entity.inventoryItem.product.sku
+ }]
+ } %}
+ {{ parent() }}
+{% endblock pageHeader %}
+
+{% block content_data %}
+ {% set id = 'marello-inventory-batches-view' %}
+ {% set generalSubblocks = [] %}
+
+ {% set productInformationWidget %}
+
+ {% endset %}
+ {% set generalSubblocks = generalSubblocks|merge([{'data' : [productInformationWidget] }]) %}
+
+ {% set inventoryLevelInformationWidget %}
+
+
+
+ {{ 'marello.inventory.information.label'|trans }}
+
+ {{ UI.renderProperty('marello.inventory.inventorylevel.warehouse.label'|trans, entity.warehouse.label) }}
+ {{ UI.renderProperty('marello.inventory.inventorylevel.pick_location.label'|trans, entity.picklocation) }}
+ {{ UI.renderProperty('marello.inventory.inventorylevel.inventory.label'|trans, entity.inventoryQty) }}
+
+
+ {% endset %}
+ {% set generalSubblocks = generalSubblocks|merge([{'data' : [inventoryLevelInformationWidget]}]) %}
+
+ {% set dataBlocks = [
+ {
+ 'title': 'General Information'|trans,
+ 'class': 'active',
+ 'subblocks': generalSubblocks
+ }
+ ] %}
+
+ {% set dataBlocks = dataBlocks|merge([{
+ 'title' : 'marello.inventory.inventorybatch.entity_plural_label'|trans,
+ 'subblocks': [{
+ 'title' : null,
+ 'data' : [
+ dataGrid.renderGrid('marello-inventory-batches', {'inventoryLevelId': entity.id})
+ ]
+ }]
+ }])
+ %}
+
+ {% set data = { 'dataBlocks': dataBlocks } %}
+ {{ parent() }}
+{% endblock content_data %}
diff --git a/src/Marello/Bundle/InventoryBundle/Resources/views/InventoryLevel/manageBatches.html.twig b/src/Marello/Bundle/InventoryBundle/Resources/views/InventoryLevel/manageBatches.html.twig
index f7afc52be..d61285fe2 100644
--- a/src/Marello/Bundle/InventoryBundle/Resources/views/InventoryLevel/manageBatches.html.twig
+++ b/src/Marello/Bundle/InventoryBundle/Resources/views/InventoryLevel/manageBatches.html.twig
@@ -9,8 +9,8 @@
{% if entity.id and is_granted('marello_inventory_inventory_update') %}
{% set html = '' %}
{% set html = UI.saveAndCloseButton({
- 'route': 'marello_inventory_inventory_update',
- 'params': {'id': entity.inventoryItem.id}
+ 'route': 'marello_inventory_inventorylevel_batches_view',
+ 'params': {'id': entity.id}
}) %}
{% set html = html ~ UI.saveAndStayButton({
'route': 'marello_inventory_inventorylevel_manage_batches',
@@ -26,10 +26,10 @@
'entity': form.vars.value,
'indexPath': path('marello_inventory_inventory_index'),
'indexLabel': 'marello.inventory.label'|trans,
- 'entityTitle': 'marello.inventory.inventorybatch.entity_plural_label'|trans ~ ' - ' ~ entity.inventoryItem.product.sku,
+ 'entityTitle': 'marello.inventory.inventorybatch.entity_plural_label'|trans,
'additional': [{
'indexPath': path('marello_inventory_inventory_update', {'id': entity.inventoryItem.id}),
- 'indexLabel': 'marello.inventory.inventorylevel.entity_plural_label'|trans,
+ 'indexLabel': entity.inventoryItem.product.sku
}]
} %}
{{ parent() }}
@@ -55,15 +55,6 @@
{% endset %}
{% set generalSubblocks = generalSubblocks|merge([{'data' : [productInformationWidget] }]) %}
- {% set totalsWidget %}
-
-
- {% placeholder marello_inventory_levels_totals with {'entity' : entity.inventoryItem} %}
-
-
- {% endset %}
- {% set generalSubblocks = generalSubblocks|merge([{'data' : [totalsWidget] }]) %}
-
{% set inventoryLevelInformationWidget %}
@@ -72,6 +63,7 @@
{{ UI.renderProperty('marello.inventory.inventorylevel.warehouse.label'|trans, entity.warehouse.label) }}
{{ UI.renderProperty('marello.inventory.inventorylevel.pick_location.label'|trans, entity.picklocation) }}
+ {{ UI.renderProperty('marello.inventory.inventorylevel.inventory.label'|trans, entity.inventoryQty) }}
{% endset %}
diff --git a/src/Marello/Bundle/InventoryBundle/Tests/Functional/Controller/InventoryControllerTest.php b/src/Marello/Bundle/InventoryBundle/Tests/Functional/Controller/InventoryControllerTest.php
index 7a42ef1d5..7bb70b357 100644
--- a/src/Marello/Bundle/InventoryBundle/Tests/Functional/Controller/InventoryControllerTest.php
+++ b/src/Marello/Bundle/InventoryBundle/Tests/Functional/Controller/InventoryControllerTest.php
@@ -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
{
/**
diff --git a/src/Marello/Bundle/InvoiceBundle/Entity/AbstractInvoice.php b/src/Marello/Bundle/InvoiceBundle/Entity/AbstractInvoice.php
index 02883a604..e9b3dfdcc 100644
--- a/src/Marello/Bundle/InvoiceBundle/Entity/AbstractInvoice.php
+++ b/src/Marello/Bundle/InvoiceBundle/Entity/AbstractInvoice.php
@@ -6,6 +6,7 @@
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
+use Marello\Bundle\PaymentBundle\Entity\Payment;
use Oro\Bundle\AddressBundle\Entity\AbstractAddress;
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation as Oro;
use Oro\Bundle\OrganizationBundle\Entity\OrganizationAwareInterface;
@@ -23,7 +24,7 @@
use Marello\Bundle\SalesBundle\Model\SalesChannelAwareInterface;
/**
- * @ORM\Entity
+ * @ORM\Entity(repositoryClass="Marello\Bundle\InvoiceBundle\Entity\Repository\AbstractInvoiceRepository")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap({"invoice" = "Invoice", "creditmemo" = "Creditmemo"})
@@ -172,33 +173,6 @@ abstract class AbstractInvoice implements
*/
protected $paymentMethod;
- /**
- * @var string
- * @ORM\Column(name="payment_reference", type="string", length=255, nullable=true)
- * @Oro\ConfigField(
- * defaultValues={
- * "dataaudit"={
- * "auditable"=true
- * }
- * }
- * )
- */
- protected $paymentReference;
-
- /**
- * @var string
- *
- * @ORM\Column(name="payment_details", type="text", nullable=true)
- * @Oro\ConfigField(
- * defaultValues={
- * "dataaudit"={
- * "auditable"=true
- * }
- * }
- * )
- */
- protected $paymentDetails;
-
/**
* @var string
*
@@ -302,6 +276,30 @@ abstract class AbstractInvoice implements
*/
protected $items;
+ /**
+ * @var Collection|Payment[]
+ *
+ * @ORM\ManyToMany(targetEntity="Marello\Bundle\PaymentBundle\Entity\Payment", cascade={"persist"})
+ * @ORM\JoinTable(name="marello_invoice_payments",
+ * joinColumns={@ORM\JoinColumn(name="invoice_id", referencedColumnName="id", onDelete="CASCADE")},
+ * inverseJoinColumns={
+ * @ORM\JoinColumn(name="payment_id", referencedColumnName="id", unique=true, onDelete="CASCADE")
+ * }
+ * )
+ * @ORM\OrderBy({"id" = "ASC"})
+ * @Oro\ConfigField(
+ * defaultValues={
+ * "email"={
+ * "available_in_template"=true
+ * },
+ * "dataaudit"={
+ * "auditable"=true
+ * }
+ * }
+ * )
+ */
+ protected $payments;
+
/**
* @var int
*
@@ -372,6 +370,34 @@ abstract class AbstractInvoice implements
*/
protected $shippingAmountExclTax;
+ /**
+ * @var int
+ *
+ * @ORM\Column(name="total_due", type="money", nullable=true)
+ * @Oro\ConfigField(
+ * defaultValues={
+ * "dataaudit"={
+ * "auditable"=true
+ * }
+ * }
+ * )
+ */
+ protected $totalDue = 0;
+
+ /**
+ * @var int
+ *
+ * @ORM\Column(name="total_paid", type="money", nullable=true)
+ * @Oro\ConfigField(
+ * defaultValues={
+ * "dataaudit"={
+ * "auditable"=true
+ * }
+ * }
+ * )
+ */
+ protected $totalPaid = 0;
+
/**
* @param AbstractAddress|null $billingAddress
* @param AbstractAddress|null $shippingAddress
@@ -381,6 +407,7 @@ public function __construct(
AbstractAddress $shippingAddress = null
) {
$this->items = new ArrayCollection();
+ $this->payments = new ArrayCollection();
$this->billingAddress = $billingAddress;
$this->shippingAddress = $shippingAddress;
}
@@ -526,44 +553,6 @@ public function setPaymentMethod($paymentMethod)
return $this;
}
- /**
- * @return string
- */
- public function getPaymentReference()
- {
- return $this->paymentReference;
- }
-
- /**
- * @param string $paymentReference
- * @return AbstractInvoice
- */
- public function setPaymentReference($paymentReference)
- {
- $this->paymentReference = $paymentReference;
-
- return $this;
- }
-
- /**
- * @return string
- */
- public function getPaymentDetails()
- {
- return $this->paymentDetails;
- }
-
- /**
- * @param string $paymentDetails
- * @return AbstractInvoice
- */
- public function setPaymentDetails($paymentDetails)
- {
- $this->paymentDetails = $paymentDetails;
-
- return $this;
- }
-
/**
* @return string
*/
@@ -734,6 +723,52 @@ public function removeItem(AbstractInvoiceItem $item)
return $this;
}
+ /**
+ * @return Collection|Payment[]
+ */
+ public function getPayments()
+ {
+ return $this->payments;
+ }
+
+ /**
+ * @param Payment $payment
+ *
+ * @return $this
+ */
+ public function addPayment(Payment $payment)
+ {
+ if (!$this->payments->contains($payment)) {
+ $this->payments->add($payment);
+ $totalPaid = $this->getTotalPaid() ? : 0;
+ $grandTotal = $this->getGrandTotal() ? : 0;
+
+ $this->setTotalPaid($payment->getTotalPaid() + $totalPaid);
+ $this->setTotalDue($grandTotal - $this->getTotalPaid());
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Payment $payment
+ *
+ * @return $this
+ */
+ public function removePayment(Payment $payment)
+ {
+ if ($this->payments->contains($payment)) {
+ $this->payments->removeElement($payment);
+ $totalPaid = $this->getTotalPaid() ? : 0;
+ $grandTotal = $this->getGrandTotal() ? : 0;
+
+ $this->setTotalPaid($totalPaid - $payment->getTotalPaid());
+ $this->setTotalDue($grandTotal - $this->getTotalPaid());
+ }
+
+ return $this;
+ }
+
/**
* @return int
*/
@@ -839,6 +874,44 @@ public function setDerivedProperty($id)
}
}
+ /**
+ * @return float
+ */
+ public function getTotalDue()
+ {
+ return $this->totalDue;
+ }
+
+ /**
+ * @param float $totalDue
+ * @return $this
+ */
+ public function setTotalDue($totalDue)
+ {
+ $this->totalDue = $totalDue;
+
+ return $this;
+ }
+
+ /**
+ * @return float
+ */
+ public function getTotalPaid()
+ {
+ return $this->totalPaid;
+ }
+
+ /**
+ * @param float $totalPaid
+ * @return $this
+ */
+ public function setTotalPaid($totalPaid)
+ {
+ $this->totalPaid = $totalPaid;
+
+ return $this;
+ }
+
/**
* @return string
*/
diff --git a/src/Marello/Bundle/InvoiceBundle/Entity/Repository/AbstractInvoiceRepository.php b/src/Marello/Bundle/InvoiceBundle/Entity/Repository/AbstractInvoiceRepository.php
new file mode 100644
index 000000000..1e0a25123
--- /dev/null
+++ b/src/Marello/Bundle/InvoiceBundle/Entity/Repository/AbstractInvoiceRepository.php
@@ -0,0 +1,24 @@
+createQueryBuilder('i');
+ $qb
+ ->where(
+ $qb->expr()->isMemberOf(':payment', 'i.payments')
+ )
+ ->setParameter('payment', $payment->getId());
+
+ return $qb->getQuery()->getOneOrNullResult();
+ }
+}
diff --git a/src/Marello/Bundle/InvoiceBundle/Form/Type/InvoiceSelectType.php b/src/Marello/Bundle/InvoiceBundle/Form/Type/InvoiceSelectType.php
new file mode 100644
index 000000000..5b8748d2a
--- /dev/null
+++ b/src/Marello/Bundle/InvoiceBundle/Form/Type/InvoiceSelectType.php
@@ -0,0 +1,33 @@
+setDefaults([
+ 'class' => AbstractInvoice::class,
+ 'choice_label' => function (AbstractInvoice $invoice) {
+ return sprintf('%s: %s', $invoice->getInvoiceType(), $invoice->getInvoiceNumber());
+ },
+ ]);
+ }
+
+ public function getParent()
+ {
+ return EntityType::class;
+ }
+
+ public function getBlockPrefix()
+ {
+ return self::BLOCK_PREFIX;
+ }
+}
diff --git a/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/MarelloInvoiceBundleInstaller.php b/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/MarelloInvoiceBundleInstaller.php
index 3791ebb6b..f769f9384 100644
--- a/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/MarelloInvoiceBundleInstaller.php
+++ b/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/MarelloInvoiceBundleInstaller.php
@@ -29,10 +29,12 @@ public function up(Schema $schema, QueryBag $queries)
/** Tables generation **/
$this->createMarelloInvoiceInvoiceTable($schema);
$this->createMarelloInvoiceInvoiceItemTable($schema);
+ $this->createMarelloInvoicePaymentsTable($schema);
/** Foreign keys generation **/
$this->addMarelloInvoiceInvoiceForeignKeys($schema);
$this->addMarelloInvoiceInvoiceItemForeignKeys($schema);
+ $this->addMarelloInvoicePaymentsForeignKeys($schema);
}
/**
@@ -51,8 +53,6 @@ protected function createMarelloInvoiceInvoiceTable(Schema $schema)
$table->addColumn('invoiced_at', 'datetime', ['notnull' => false]);
$table->addColumn('invoice_due_date', 'datetime', ['notnull' => false]);
$table->addColumn('payment_method', 'string', ['notnull' => false, 'length' => 255]);
- $table->addColumn('payment_reference', 'string', ['notnull' => false, 'length' => 255]);
- $table->addColumn('payment_details', 'text', ['notnull' => false]);
$table->addColumn('shipping_method', 'string', ['notnull' => false, 'length' => 255]);
$table->addColumn('shipping_method_type', 'string', ['notnull' => false, 'length' => 255]);
$table->addColumn('order_id', 'integer', ['notnull' => true]);
@@ -66,6 +66,8 @@ protected function createMarelloInvoiceInvoiceTable(Schema $schema)
$table->addColumn('subtotal', 'money', ['precision' => 19, 'scale' => 4, 'comment' => '(DC2Type:money)']);
$table->addColumn('total_tax', 'money', ['precision' => 19, 'scale' => 4, 'comment' => '(DC2Type:money)']);
$table->addColumn('grand_total', 'money', ['precision' => 19, 'scale' => 4, 'comment' => '(DC2Type:money)']);
+ $table->addColumn('total_due', 'money', ['notnull' => false, 'precision' => 19, 'scale' => 4, 'comment' => '(DC2Type:money)']);
+ $table->addColumn('total_paid', 'money', ['notnull' => false, 'precision' => 19, 'scale' => 4, 'comment' => '(DC2Type:money)']);
$table->addColumn(
'shipping_amount_incl_tax',
'money',
@@ -139,7 +141,21 @@ protected function createMarelloInvoiceInvoiceItemTable(Schema $schema)
$table->setPrimaryKey(['id']);
}
-
+
+ /**
+ * Create marello_invoice_invoice_item table
+ *
+ * @param Schema $schema
+ */
+ protected function createMarelloInvoicePaymentsTable(Schema $schema)
+ {
+ $table = $schema->createTable('marello_invoice_payments');
+ $table->addColumn('invoice_id', 'integer', ['notnull' => true]);
+ $table->addColumn('payment_id', 'integer', ['notnull' => true]);
+ $table->addUniqueIndex(['payment_id'], null);
+ $table->setPrimaryKey(['invoice_id', 'payment_id']);
+ }
+
/**
* Add marello_invoice_invoice foreign keys.
*
@@ -219,4 +235,24 @@ protected function addMarelloInvoiceInvoiceItemForeignKeys(Schema $schema)
['onDelete' => 'SET NULL', 'onUpdate' => null]
);
}
+
+ /**
+ * @param Schema $schema
+ */
+ protected function addMarelloInvoicePaymentsForeignKeys(Schema $schema)
+ {
+ $table = $schema->getTable('marello_invoice_payments');
+ $table->addForeignKeyConstraint(
+ $schema->getTable('marello_invoice_invoice'),
+ ['invoice_id'],
+ ['id'],
+ ['onDelete' => 'CASCADE', 'onUpdate' => null]
+ );
+ $table->addForeignKeyConstraint(
+ $schema->getTable('marello_payment_payment'),
+ ['payment_id'],
+ ['id'],
+ ['onDelete' => 'CASCADE', 'onUpdate' => null]
+ );
+ }
}
diff --git a/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/v2_0/MarelloInvoiceBundleAddColumns.php b/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/v2_0/MarelloInvoiceBundleAddColumns.php
new file mode 100644
index 000000000..967919d74
--- /dev/null
+++ b/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/v2_0/MarelloInvoiceBundleAddColumns.php
@@ -0,0 +1,75 @@
+updateInvoiceTable($schema);
+ if (!$schema->hasTable('marello_invoice_payments')) {
+ $this->createMarelloInvoicePaymentsTable($schema);
+ $this->addMarelloInvoicePaymentsForeignKeys($schema);
+ }
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function updateInvoiceTable(Schema $schema)
+ {
+ $table = $schema->getTable('marello_invoice_invoice');
+ $table->addColumn('total_due', 'money', ['notnull' => false, 'precision' => 19, 'scale' => 4, 'comment' => '(DC2Type:money)']);
+ $table->addColumn('total_paid', 'money', ['notnull' => false, 'precision' => 19, 'scale' => 4, 'comment' => '(DC2Type:money)']);
+ }
+
+ /**
+ * Create marello_invoice_invoice_item table
+ *
+ * @param Schema $schema
+ */
+ protected function createMarelloInvoicePaymentsTable(Schema $schema)
+ {
+ $table = $schema->createTable('marello_invoice_payments');
+ $table->addColumn('invoice_id', 'integer', ['notnull' => true]);
+ $table->addColumn('payment_id', 'integer', ['notnull' => true]);
+ $table->addUniqueIndex(['payment_id'], null);
+ $table->setPrimaryKey(['invoice_id', 'payment_id']);
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ protected function addMarelloInvoicePaymentsForeignKeys(Schema $schema)
+ {
+ $table = $schema->getTable('marello_invoice_payments');
+ $table->addForeignKeyConstraint(
+ $schema->getTable('marello_invoice_invoice'),
+ ['invoice_id'],
+ ['id'],
+ ['onDelete' => 'CASCADE', 'onUpdate' => null]
+ );
+ $table->addForeignKeyConstraint(
+ $schema->getTable('marello_payment_payment'),
+ ['payment_id'],
+ ['id'],
+ ['onDelete' => 'CASCADE', 'onUpdate' => null]
+ );
+ }
+}
diff --git a/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/v2_0/MarelloInvoiceBundleAddQuery.php b/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/v2_0/MarelloInvoiceBundleAddQuery.php
new file mode 100644
index 000000000..d670dd174
--- /dev/null
+++ b/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/v2_0/MarelloInvoiceBundleAddQuery.php
@@ -0,0 +1,26 @@
+addQuery(new PaymentsCreationQuery());
+ }
+}
diff --git a/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/v2_0/MarelloInvoiceBundleRemoveColumns.php b/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/v2_0/MarelloInvoiceBundleRemoveColumns.php
new file mode 100644
index 000000000..de17a5ed8
--- /dev/null
+++ b/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/v2_0/MarelloInvoiceBundleRemoveColumns.php
@@ -0,0 +1,37 @@
+updateInvoiceTable($schema);
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function updateInvoiceTable(Schema $schema)
+ {
+ $table = $schema->getTable('marello_invoice_invoice');
+ $table->dropColumn('payment_reference');
+ $table->dropColumn('payment_details');
+ }
+}
diff --git a/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/v2_0/PaymentsCreationQuery.php b/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/v2_0/PaymentsCreationQuery.php
new file mode 100644
index 000000000..b1678a010
--- /dev/null
+++ b/src/Marello/Bundle/InvoiceBundle/Migrations/Schema/v2_0/PaymentsCreationQuery.php
@@ -0,0 +1,66 @@
+createPayments($logger, true);
+
+ return $logger->getMessages();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function execute(LoggerInterface $logger)
+ {
+ $this->createPayments($logger);
+ }
+
+ /**
+ * @param LoggerInterface $logger
+ * @param bool $dryRun
+ */
+ protected function createPayments(LoggerInterface $logger, $dryRun = false)
+ {
+ $invoices = $this->loadInvoices($logger);
+ foreach ($invoices as $invoice) {
+ $query = "
+INSERT INTO marello_payment_payment
+(payment_method, payment_reference, payment_details, total_paid, organization_id, payment_date, created_at)
+VALUES
+('" . $invoice['payment_method'] . "', '" . $invoice['payment_reference'] . "', '" .$invoice['payment_details'] . "', '" . $invoice['grand_total'] . "', '" . $invoice['organization_id'] . "', '" . $invoice['created_at'] . "', '" . $invoice['created_at'] . "')";
+ $this->logQuery($logger, $query);
+ if (!$dryRun) {
+ $this->connection->executeQuery($query);
+
+ $paymentId = $this->connection->lastInsertId();
+ $query2 = "INSERT INTO marello_invoice_payments (invoice_id, payment_id) VALUES ('" . $invoice['id'] . "', '" . $paymentId . "')";
+ $this->connection->executeQuery($query2);
+ }
+ }
+ }
+
+ /**
+ * @param LoggerInterface $logger
+ *
+ * @return array
+ */
+ protected function loadInvoices(LoggerInterface $logger)
+ {
+ $sql = 'SELECT id, payment_method, payment_reference, payment_details, grand_total, organization_id, created_at FROM marello_invoice_invoice';
+ $this->logQuery($logger, $sql);
+
+ return $this->connection->fetchAll($sql);
+ }
+}
diff --git a/src/Marello/Bundle/InvoiceBundle/Pdf/Logo/InvoiceLogoPathProvider.php b/src/Marello/Bundle/InvoiceBundle/Pdf/Logo/InvoiceLogoPathProvider.php
index f0008fb5a..7fc99035e 100644
--- a/src/Marello/Bundle/InvoiceBundle/Pdf/Logo/InvoiceLogoPathProvider.php
+++ b/src/Marello/Bundle/InvoiceBundle/Pdf/Logo/InvoiceLogoPathProvider.php
@@ -58,6 +58,17 @@ public function getInvoiceLogo(SalesChannel $salesChannel, $absolute = false)
return $path;
}
+ /**
+ * @param SalesChannel $salesChannel
+ * @return mixed
+ */
+ public function getInvoiceLogoWidth(SalesChannel $salesChannel)
+ {
+ $key = sprintf('%s.%s', Configuration::CONFIG_NAME, Configuration::CONFIG_KEY_LOGO_WIDTH);
+
+ return $this->configManager->get($key, false, false, $salesChannel);
+ }
+
/**
* @param SalesChannel $salesChannel
* @return mixed
@@ -69,6 +80,7 @@ protected function getInvoiceLogoId(SalesChannel $salesChannel)
return $this->configManager->get($key, false, false, $salesChannel);
}
+
/**
* @param $id
* @return object|null
diff --git a/src/Marello/Bundle/InvoiceBundle/Pdf/Logo/InvoiceLogoRenderParameterProvider.php b/src/Marello/Bundle/InvoiceBundle/Pdf/Logo/InvoiceLogoRenderParameterProvider.php
index a5e30e5fd..592f5736d 100644
--- a/src/Marello/Bundle/InvoiceBundle/Pdf/Logo/InvoiceLogoRenderParameterProvider.php
+++ b/src/Marello/Bundle/InvoiceBundle/Pdf/Logo/InvoiceLogoRenderParameterProvider.php
@@ -30,6 +30,9 @@ public function getParams($entity, array $options)
$salesChannel = $options[self::OPTION_KEY];
}
- return ['logo' => $this->logoProvider->getInvoiceLogo($salesChannel, true)];
+ return [
+ 'logo' => $this->logoProvider->getInvoiceLogo($salesChannel, true),
+ 'logo_width' => $this->logoProvider->getInvoiceLogoWidth($salesChannel),
+ ];
}
}
diff --git a/src/Marello/Bundle/InvoiceBundle/Provider/InvoicePaidAmountProvider.php b/src/Marello/Bundle/InvoiceBundle/Provider/InvoicePaidAmountProvider.php
new file mode 100644
index 000000000..9f04cdc34
--- /dev/null
+++ b/src/Marello/Bundle/InvoiceBundle/Provider/InvoicePaidAmountProvider.php
@@ -0,0 +1,18 @@
+getPayments() as $payment) {
+ $amount += $payment->getTotalPaid();
+ }
+
+ return $amount;
+ }
+}
diff --git a/src/Marello/Bundle/InvoiceBundle/Resources/config/oro/actions.yml b/src/Marello/Bundle/InvoiceBundle/Resources/config/oro/actions.yml
new file mode 100644
index 000000000..59d941be7
--- /dev/null
+++ b/src/Marello/Bundle/InvoiceBundle/Resources/config/oro/actions.yml
@@ -0,0 +1,89 @@
+operations:
+ marello_payment_add:
+ label: marello.payment.button.add_payment.label
+ applications: [default]
+ acl_resource: [EDIT, $.data]
+ order: 20
+ routes:
+ - marello_invoice_invoice_view
+ attributes:
+ invoice_paid_amount:
+ label: marello.payment.total_paid.label
+ type: float
+ payment_method:
+ label: marello.payment.payment_method.label
+ type: string
+ payment_date:
+ label: marello.payment.payment_date.label
+ type: object
+ options:
+ class: \DateTime
+ payment_reference:
+ label: marello.payment.payment_reference.label
+ type: string
+ payment_details:
+ label: marello.payment.payment_details.label
+ type: string
+ total_paid:
+ label: marello.payment.total_paid.label
+ type: object
+ options:
+ class: Oro\Bundle\CurrencyBundle\Entity\Price
+ action_result:
+ label: 'result'
+ type: array
+ form_options:
+ attribute_fields:
+ payment_method:
+ form_type: Marello\Bundle\PaymentBundle\Form\Type\PaymentMethodSelectType
+ options:
+ required: true
+ constraints:
+ - NotBlank: ~
+ payment_date:
+ form_type: Oro\Bundle\FormBundle\Form\Type\OroDateTimeType
+ options:
+ required: true
+ constraints:
+ - NotBlank: ~
+ - DateTime: ~
+ payment_reference:
+ form_type: Symfony\Component\Form\Extension\Core\Type\TextType
+ options:
+ required: true
+ constraints:
+ - NotBlank: ~
+ payment_details:
+ form_type: Symfony\Component\Form\Extension\Core\Type\TextType
+ options:
+ required: true
+ constraints:
+ - NotBlank: ~
+ total_paid:
+ form_type: Marello\Bundle\OrderBundle\Form\Type\OrderTotalPaidType
+ options:
+ required: true
+ currency: $.data.currency
+ frontend_options:
+ options:
+ width: 2000
+ show_dialog: true
+ template: MarelloPaymentBundle:Action:payment_popup.html.twig
+ preactions:
+ - '@call_service_method':
+ service: marello_invoice.provider.invoice_paid_amount
+ method: getPaidAmount
+ method_parameters: [$.data]
+ attribute: $.invoice_paid_amount
+ preconditions:
+ '@and':
+ - '@less': [$.invoice_paid_amount, $.data.grandTotal]
+ actions:
+ - '@call_service_method':
+ service: marello_payment.action.handler.add_payment
+ method: handleAction
+ method_parameters: [$.data, $.payment_method, $.payment_date, $.payment_reference, $.payment_details, $.total_paid.value]
+ attribute: $.action_result
+ - '@flash_message':
+ message: $.action_result.message
+ type: $.action_result.type
diff --git a/src/Marello/Bundle/InvoiceBundle/Resources/config/oro/datagrids.yml b/src/Marello/Bundle/InvoiceBundle/Resources/config/oro/datagrids.yml
index a2f3717a0..ef230af46 100644
--- a/src/Marello/Bundle/InvoiceBundle/Resources/config/oro/datagrids.yml
+++ b/src/Marello/Bundle/InvoiceBundle/Resources/config/oro/datagrids.yml
@@ -38,10 +38,21 @@ datagrids:
method: formatCurrency
context_resolver: Marello\Bundle\DataGridBundle\Grid\FormatterContextResolver::getResolverCurrencyClosure
align: right
+ totalPaid:
+ label: marello.invoice.total_paid.label
+ type: localized_number
+ method: formatCurrency
+ context_resolver: Marello\Bundle\DataGridBundle\Grid\FormatterContextResolver::getResolverCurrencyClosure
+ align: right
+ totalDue:
+ label: marello.invoice.total_due.label
+ type: localized_number
+ method: formatCurrency
+ context_resolver: Marello\Bundle\DataGridBundle\Grid\FormatterContextResolver::getResolverCurrencyClosure
+ align: right
invoicedAt:
frontend_type: datetime
label: marello.invoice.invoiced_at.label
- renderable: false
createdAt:
label: oro.ui.created_at
frontend_type: datetime
@@ -62,6 +73,10 @@ datagrids:
data_name: billingName
grandTotal:
data_name: i.grandTotal
+ totalPaid:
+ data_name: i.totalPaid
+ totalDue:
+ data_name: i.totalDue
invoicedAt:
data_name: i.purchaseDate
createdAt:
diff --git a/src/Marello/Bundle/InvoiceBundle/Resources/config/services.yml b/src/Marello/Bundle/InvoiceBundle/Resources/config/services.yml
index 849ff0d47..410c3f69c 100644
--- a/src/Marello/Bundle/InvoiceBundle/Resources/config/services.yml
+++ b/src/Marello/Bundle/InvoiceBundle/Resources/config/services.yml
@@ -60,6 +60,10 @@ services:
tags:
- { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.marello-invoices-base-grid, method: onBuildBefore }
+ marello_invoice.provider.invoice_paid_amount:
+ class: 'Marello\Bundle\InvoiceBundle\Provider\InvoicePaidAmountProvider'
+ public: true
+
marello_invoice.provider.invoice_type_choices:
class: 'Marello\Bundle\InvoiceBundle\Provider\InvoiceTypeChoicesProvider'
public: true
@@ -122,4 +126,16 @@ services:
arguments:
- '@marello_invoice.pdf.provider.table_size'
tags:
- - { name: marello_pdf.document_table_provider }
\ No newline at end of file
+ - { name: marello_pdf.document_table_provider }
+
+ marello_invoice.form_type.invoice_select:
+ class: 'Marello\Bundle\InvoiceBundle\Form\Type\InvoiceSelectType'
+ tags:
+ - { name: form.type }
+
+ marello_invoice.twig.invoice_extension:
+ class: 'Marello\Bundle\InvoiceBundle\Twig\InvoiceExtension'
+ arguments:
+ - '@doctrine'
+ tags:
+ - { name: twig.extension }
diff --git a/src/Marello/Bundle/InvoiceBundle/Resources/translations/messages.en.yml b/src/Marello/Bundle/InvoiceBundle/Resources/translations/messages.en.yml
index 27b5910a4..5d89cd675 100644
--- a/src/Marello/Bundle/InvoiceBundle/Resources/translations/messages.en.yml
+++ b/src/Marello/Bundle/InvoiceBundle/Resources/translations/messages.en.yml
@@ -13,9 +13,10 @@ marello:
name.label: Ship to Name
invoiced_at.label: Invoiced At
invoice_due_date.label: Invoice Due Date
+ payments.label: Payments
+ total_due.label: Total Due
+ total_paid.label: Total Paid
payment_method.label: Payment Method
- payment_reference.label: Payment Reference
- payment_details.label: Payment Details
payment_term.label: Payment Term
shipping_method.label: Shipping Method
shipping_method_type.label: Shipping Method Type
@@ -52,9 +53,10 @@ marello:
name.label: Ship to Name
invoiced_at.label: Invoiced At
invoice_due_date.label: Invoice Due Date
+ payments.label: Payments
+ total_due.label: Total Due
+ total_paid.label: Total Paid
payment_method.label: Payment Method
- payment_reference.label: Payment Reference
- payment_details.label: Payment Details
shipping_method.label: Shipping Method
shipping_method_type.label: Shipping Method Type
order.label: Order
@@ -75,7 +77,7 @@ marello:
datablock:
general: General
- billing_and_payment: Billing & Payment
+ billing_address: Billing Address
delivery: Delivery
invoice_items: Invoice Items
creditmemo_items: Credit Memo Items
@@ -85,6 +87,7 @@ marello:
customer_information: Customer Information
invoice_totals: Invoice Totals
creditmemo_totals: Credit Memo Totals
+ payments: Payments
invoiceitem:
id.label: Id
@@ -106,10 +109,10 @@ marello:
creditmemoitem:
id.label: Id
- entity_label: Creditmemo Item
- entity_plural_label: Creditmemo Items
+ entity_label: Credit Memo Item
+ entity_plural_label: Credit Memo Items
entity_grid_all_view_label: All %entity_plural_label%
- invoice.label: Creditmemo
+ invoice.label: Invoice
quantity.label: Quantity
price.label: Price
product.label: Product
@@ -136,9 +139,10 @@ marello:
name.label: Ship to Name
invoiced_at.label: Invoiced At
invoice_due_date.label: Invoice Due Date
+ payments.label: Payments
+ total_due.label: Total Due
+ total_paid.label: Total Paid
payment_method.label: Payment Method
- payment_reference.label: Payment Reference
- payment_details.label: Payment Details
shipping_method.label: Shipping Method
shipping_method_type.label: Shipping Method Type
order.label: Order
diff --git a/src/Marello/Bundle/InvoiceBundle/Resources/translations/pdf.en.yml b/src/Marello/Bundle/InvoiceBundle/Resources/translations/pdf.en.yml
index 51491d074..0b1b0fe0f 100644
--- a/src/Marello/Bundle/InvoiceBundle/Resources/translations/pdf.en.yml
+++ b/src/Marello/Bundle/InvoiceBundle/Resources/translations/pdf.en.yml
@@ -4,6 +4,7 @@ marello:
invoice_date.label: "Invoice date"
invoice_number.label: "Invoice number"
debtor_number.label: "Debtor number"
+ payment_term.label: "Payment term"
subtotal.label: "Subtotal"
total.label: "Total"
page_number.label: "Page %pageNumber% of %totalPages%"
diff --git a/src/Marello/Bundle/InvoiceBundle/Resources/views/Invoice/view.html.twig b/src/Marello/Bundle/InvoiceBundle/Resources/views/Invoice/view.html.twig
index 4799e021a..4b5a1a40b 100644
--- a/src/Marello/Bundle/InvoiceBundle/Resources/views/Invoice/view.html.twig
+++ b/src/Marello/Bundle/InvoiceBundle/Resources/views/Invoice/view.html.twig
@@ -16,9 +16,13 @@
{% endblock pageHeader %}
{% block navButtons %}
-
- {{ 'marello.invoice.pdf.download.label'|trans }}
-
+ {% if is_granted('VIEW', entity) %}
+
+ {% endif %}
{% endblock %}
{% block content_data %}
@@ -57,6 +61,10 @@
{{ UI.renderProperty('marello.invoice.shipping_amount_incl_tax.label'|trans, entity.shippingAmountInclTax|oro_format_currency({'currency':entity.currency})) }}
{{ UI.renderProperty('marello.invoice.total_tax.label'|trans, entity.totalTax|oro_format_currency({'currency':entity.currency})) }}
{{ UI.renderProperty('marello.invoice.grand_total.label'|trans, entity.grandTotal|oro_format_currency({'currency':entity.currency})) }}
+ {{ UI.renderProperty('marello.invoice.total_paid.label'|trans, entity.totalPaid|oro_format_currency({'currency':entity.currency})) }}
+ {{ UI.renderProperty('marello.invoice.total_due.label'|trans, entity.totalDue|oro_format_currency({'currency':entity.currency})) }}
+
+
{% endset %}
@@ -78,6 +86,9 @@
{% if entity.customer.company.companyNumber %}
{{ UI.renderProperty('marello.customer.company.company_number.label'|trans, entity.customer.company.companyNumber) }}
{% endif %}
+ {% if entity.customer.company.taxIdentificationNumber %}
+ {{ UI.renderProperty('marello.customer.company.tax_identification_number.label'|trans, entity.customer.company.taxIdentificationNumber) }}
+ {% endif %}
{% endif %}
{{ UI.renderHtmlProperty(
'marello.customer.entity_label'|trans,
@@ -91,28 +102,24 @@
{% endset %}
{% set generalSubblocks = generalSubblocks|merge([{'data' : [customerInformation] }]) %}
- {% set paymentSubblocks = [] %}
+ {% set billingSubblocks = [] %}
{% set billingAddressBlock %}
{{ oro_widget_render({
'widgetType': 'block',
'url': path('marello_order_order_address', {id: entity.billingAddress.id, typeId: 1}),
}) }}
{% endset %}
- {% set paymentSubblocks = paymentSubblocks|merge([{'data' : [billingAddressBlock] }]) %}
+ {% set billingSubblocks = billingSubblocks|merge([{'data' : [billingAddressBlock] }]) %}
- {% set paymentWidget %}
+ {% set emptyWidget %}
{% endset %}
- {% set paymentSubblocks = paymentSubblocks|merge([{'data' : [paymentWidget] }]) %}
+ {% set billingSubblocks = billingSubblocks|merge([{'data' : [emptyWidget] }]) %}
{% set shippingSubblocks = [] %}
{% set shippingAddressBlock %}
@@ -146,6 +153,10 @@
{% endset %}
+ {% set payments %}
+ {{ dataGrid.renderGrid('marello-invoice-payments-grid', {'invoiceId': entity.id}) }}
+ {% endset %}
+
{% set dataBlocks = [
{
'title': 'marello.invoice.datablock.general'|trans,
@@ -153,9 +164,9 @@
'subblocks': generalSubblocks
},
{
- 'title': 'marello.invoice.datablock.billing_and_payment'|trans,
+ 'title': 'marello.invoice.datablock.billing_address'|trans,
'class': 'active',
- 'subblocks': paymentSubblocks
+ 'subblocks': billingSubblocks
},
{
'title': 'marello.invoice.datablock.delivery'|trans,
@@ -168,6 +179,13 @@
'subblocks': [
{ 'data' : [items] }
]
+ },
+ {
+ 'title': 'marello.invoice.datablock.payments'|trans,
+ 'class': 'active',
+ 'subblocks': [
+ { 'data' : [payments] }
+ ]
}
] %}
diff --git a/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/creditmemo.html.twig b/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/creditmemo.html.twig
index c36265499..0a31984d3 100644
--- a/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/creditmemo.html.twig
+++ b/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/creditmemo.html.twig
@@ -249,6 +249,10 @@
{{ 'marello.customer.company.pdf.company_number.label'|trans({}, 'pdf', language) }}:
{{ entity.customer.company.companyNumber }}
{% endif %}
+ {% if entity.customer.company and entity.customer.company.taxIdentificationNumber %}
+ {{ 'marello.customer.company.pdf.tax_identification_number.label'|trans({}, 'pdf', language) }}:
+ {{ entity.customer.company.taxIdentificationNumber }}
+ {% endif %}
diff --git a/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/invoice.html.twig b/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/invoice.html.twig
index 915b1f83c..c38722281 100644
--- a/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/invoice.html.twig
+++ b/src/Marello/Bundle/InvoiceBundle/Resources/views/Pdf/invoice.html.twig
@@ -237,7 +237,7 @@
{{ address.postalCode }} {{ address.city }}
{{ ('country.' ~ address.country.iso2code)|trans({}, 'entities', language) }}
-
+ {% set paymentTerm = marello_get_payment_term_for_customer(entity.customer) %}
{# Invoice details #}
@@ -249,6 +249,14 @@
{{ 'marello.customer.company.pdf.company_number.label'|trans({}, 'pdf', language) }}:
{{ entity.customer.company.companyNumber }}
{% endif %}
+ {% if entity.customer.company and entity.customer.company.taxIdentificationNumber %}
+ {{ 'marello.customer.company.pdf.tax_identification_number.label'|trans({}, 'pdf', language) }}:
+ {{ entity.customer.company.taxIdentificationNumber }}
+ {% endif %}
+ {% if paymentTerm %}
+ {{ 'marello.pdf.invoice.payment_term.label'|trans({}, 'pdf', language) }}:
+ {{ 'marello.payment_term.ui.payment_term.term_days'|trans({'%days%': paymentTerm.term }) }}
+ {% endif %}
diff --git a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_creditmemo_list.yml b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_creditmemo_list.yml
index 4f5457203..36ac54310 100644
--- a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_creditmemo_list.yml
+++ b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_creditmemo_list.yml
@@ -7,8 +7,6 @@ data:
invoicedAt: '@marello_creditmemo_0->invoicedAt->format("Y-m-d\TH:i:s\Z")'
invoiceDueDate: null
paymentMethod: 'Credit Card'
- paymentReference: null
- paymentDetails: 'American Express refnr. 371449635398431'
shippingMethod: null
shippingMethodType: null
currency: USD
@@ -56,8 +54,6 @@ data:
invoicedAt: '@marello_creditmemo_1->invoicedAt->format("Y-m-d\TH:i:s\Z")'
invoiceDueDate: null
paymentMethod: Paypal
- paymentReference: null
- paymentDetails: null
shippingMethod: null
shippingMethodType: null
currency: GBP
diff --git a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_creditmemo_list_by_order.yml b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_creditmemo_list_by_order.yml
index 148b9ccfd..4f4a3d80d 100644
--- a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_creditmemo_list_by_order.yml
+++ b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_creditmemo_list_by_order.yml
@@ -7,8 +7,6 @@ data:
invoicedAt: '@marello_creditmemo_1->invoicedAt->format("Y-m-d\TH:i:s\Z")'
invoiceDueDate: null
paymentMethod: Paypal
- paymentReference: null
- paymentDetails: null
shippingMethod: null
shippingMethodType: null
currency: GBP
diff --git a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_invoice_list.yml b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_invoice_list.yml
index 9057e501b..249e13be3 100644
--- a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_invoice_list.yml
+++ b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_invoice_list.yml
@@ -7,8 +7,6 @@ data:
invoicedAt: '@marello_invoice_0->invoicedAt->format("Y-m-d\TH:i:s\Z")'
invoiceDueDate: null
paymentMethod: 'Credit Card'
- paymentReference: null
- paymentDetails: 'American Express refnr. 371449635398431'
shippingMethod: null
shippingMethodType: null
currency: USD
@@ -56,8 +54,6 @@ data:
invoicedAt: '@marello_invoice_1->invoicedAt->format("Y-m-d\TH:i:s\Z")'
invoiceDueDate: null
paymentMethod: Paypal
- paymentReference: null
- paymentDetails: null
shippingMethod: null
shippingMethodType: null
currency: GBP
@@ -114,8 +110,6 @@ data:
invoicedAt: '@marello_invoice_2->invoicedAt->format("Y-m-d\TH:i:s\Z")'
invoiceDueDate: null
paymentMethod: 'Credit Card'
- paymentReference: null
- paymentDetails: 'American Express refnr. 371449635398431'
shippingMethod: null
shippingMethodType: null
currency: USD
@@ -169,8 +163,6 @@ data:
invoicedAt: '@marello_invoice_3->invoicedAt->format("Y-m-d\TH:i:s\Z")'
invoiceDueDate: null
paymentMethod: Paypal
- paymentReference: null
- paymentDetails: null
shippingMethod: null
shippingMethodType: null
currency: GBP
diff --git a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_invoice_list_by_order.yml b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_invoice_list_by_order.yml
index 82650d8b6..49a6c6df0 100644
--- a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_invoice_list_by_order.yml
+++ b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/cget_invoice_list_by_order.yml
@@ -7,8 +7,6 @@ data:
invoicedAt: '@marello_invoice_2->invoicedAt->format("Y-m-d\TH:i:s\Z")'
invoiceDueDate: null
paymentMethod: 'Credit Card'
- paymentReference: null
- paymentDetails: 'American Express refnr. 371449635398431'
shippingMethod: null
shippingMethodType: null
currency: USD
diff --git a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_creditmemo_by_id.yml b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_creditmemo_by_id.yml
index 850783795..ba6c76ba4 100644
--- a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_creditmemo_by_id.yml
+++ b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_creditmemo_by_id.yml
@@ -6,8 +6,6 @@ data:
invoicedAt: '@marello_creditmemo_0->invoicedAt->format("Y-m-d\TH:i:s\Z")'
invoiceDueDate: null
paymentMethod: 'Credit Card'
- paymentReference: null
- paymentDetails: 'American Express refnr. 371449635398431'
shippingMethod: null
shippingMethodType: null
currency: USD
diff --git a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_creditmemo_by_invoiceNumber.yml b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_creditmemo_by_invoiceNumber.yml
index 66e18c5f3..115352ced 100644
--- a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_creditmemo_by_invoiceNumber.yml
+++ b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_creditmemo_by_invoiceNumber.yml
@@ -6,8 +6,6 @@ data:
invoicedAt: '@marello_creditmemo_1->invoicedAt->format("Y-m-d\TH:i:s\Z")'
invoiceDueDate: null
paymentMethod: Paypal
- paymentReference: null
- paymentDetails: null
shippingMethod: null
shippingMethodType: null
currency: GBP
diff --git a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_invoice_by_id.yml b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_invoice_by_id.yml
index 66efd1b98..2fde1b2ee 100644
--- a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_invoice_by_id.yml
+++ b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_invoice_by_id.yml
@@ -6,8 +6,6 @@ data:
invoicedAt: '@marello_invoice_1->invoicedAt->format("Y-m-d\TH:i:s\Z")'
invoiceDueDate: null
paymentMethod: Paypal
- paymentReference: null
- paymentDetails: null
shippingMethod: null
shippingMethodType: null
currency: GBP
diff --git a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_invoice_by_invoiceNumber.yml b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_invoice_by_invoiceNumber.yml
index 66efd1b98..2fde1b2ee 100644
--- a/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_invoice_by_invoiceNumber.yml
+++ b/src/Marello/Bundle/InvoiceBundle/Tests/Functional/Api/responses/get_invoice_by_invoiceNumber.yml
@@ -6,8 +6,6 @@ data:
invoicedAt: '@marello_invoice_1->invoicedAt->format("Y-m-d\TH:i:s\Z")'
invoiceDueDate: null
paymentMethod: Paypal
- paymentReference: null
- paymentDetails: null
shippingMethod: null
shippingMethodType: null
currency: GBP
diff --git a/src/Marello/Bundle/InvoiceBundle/Tests/Unit/Pdf/Logo/InvoiceLogoRenderParameterProviderTest.php b/src/Marello/Bundle/InvoiceBundle/Tests/Unit/Pdf/Logo/InvoiceLogoRenderParameterProviderTest.php
index 2f87a0170..7ad7ae5d4 100644
--- a/src/Marello/Bundle/InvoiceBundle/Tests/Unit/Pdf/Logo/InvoiceLogoRenderParameterProviderTest.php
+++ b/src/Marello/Bundle/InvoiceBundle/Tests/Unit/Pdf/Logo/InvoiceLogoRenderParameterProviderTest.php
@@ -69,7 +69,7 @@ public function testGetParams($entity, $options, $salesChannel, $logoPath)
->willReturn($logoPath)
;
- $this->assertEquals(['logo' => $logoPath], $this->provider->getParams($entity, $options));
+ $this->assertEquals(['logo' => $logoPath, 'logo_width' => null], $this->provider->getParams($entity, $options));
}
public function getParamsProvider()
diff --git a/src/Marello/Bundle/InvoiceBundle/Tests/Unit/Pdf/Table/InvoiceTableProviderTest.php b/src/Marello/Bundle/InvoiceBundle/Tests/Unit/Pdf/Table/InvoiceTableProviderTest.php
index 952b4f938..20b565b2c 100644
--- a/src/Marello/Bundle/InvoiceBundle/Tests/Unit/Pdf/Table/InvoiceTableProviderTest.php
+++ b/src/Marello/Bundle/InvoiceBundle/Tests/Unit/Pdf/Table/InvoiceTableProviderTest.php
@@ -126,8 +126,6 @@ public function testGetTables(
'invoicedAt' => new \DateTime('2019-01-01 12:34:56'),
'invoiceDueDate' => new \DateTime('2019-01-02 23:45:01'),
'paymentMethod' => 'payment method',
- 'paymentReference' => 'payment reference',
- 'paymentDetails' => 'payment details',
'shippingMethod' => 'shipping method',
'shippingMethodType' => 'shipping',
'status' => 'open',
diff --git a/src/Marello/Bundle/InvoiceBundle/Twig/InvoiceExtension.php b/src/Marello/Bundle/InvoiceBundle/Twig/InvoiceExtension.php
new file mode 100644
index 000000000..80eb03499
--- /dev/null
+++ b/src/Marello/Bundle/InvoiceBundle/Twig/InvoiceExtension.php
@@ -0,0 +1,65 @@
+doctrine = $doctrine;
+ }
+
+ /**
+ * Returns the name of the extension.
+ *
+ * @return string The extension name
+ */
+ public function getName()
+ {
+ return self::NAME;
+ }
+
+ /**
+ * Returns a list of functions to add to the existing list.
+ *
+ * @return array An array of functions
+ */
+ public function getFunctions()
+ {
+ return [
+ new TwigFunction(
+ 'marello_get_payment_source',
+ [$this, 'getPaymentSource']
+ )
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ * @param Payment $payment
+ * @return AbstractInvoice
+ */
+ public function getPaymentSource(Payment $payment)
+ {
+ return $this->doctrine
+ ->getManagerForClass(AbstractInvoice::class)
+ ->getRepository(AbstractInvoice::class)
+ ->findOneByPayment($payment);
+ }
+}
diff --git a/src/Marello/Bundle/LayoutBundle/Resources/public/css/scss/main.scss b/src/Marello/Bundle/LayoutBundle/Resources/public/css/scss/main.scss
index c807e4367..10b739996 100644
--- a/src/Marello/Bundle/LayoutBundle/Resources/public/css/scss/main.scss
+++ b/src/Marello/Bundle/LayoutBundle/Resources/public/css/scss/main.scss
@@ -42,7 +42,7 @@
}
.marello-line-item-related-field {
- margin: 5px 0 0 5px;
+ margin: 0 0 0 5px;
float:left;
}
diff --git a/src/Marello/Bundle/NotificationBundle/Migrations/Schema/MarelloNotificationBundleInstaller.php b/src/Marello/Bundle/NotificationBundle/Migrations/Schema/MarelloNotificationBundleInstaller.php
index 6656c66b8..03897227d 100644
--- a/src/Marello/Bundle/NotificationBundle/Migrations/Schema/MarelloNotificationBundleInstaller.php
+++ b/src/Marello/Bundle/NotificationBundle/Migrations/Schema/MarelloNotificationBundleInstaller.php
@@ -17,7 +17,7 @@ class MarelloNotificationBundleInstaller implements Installation
*/
public function getMigrationVersion()
{
- return 'v1_1';
+ return 'v1_2';
}
/**
@@ -103,7 +103,7 @@ protected function addAttachmentForeignKeys(Schema $schema)
['id']
);
$table->addForeignKeyConstraint(
- $schema->getTable('oro_attachment_file'),
+ $schema->getTable('oro_attachment'),
['attachment_id'],
['id']
);
diff --git a/src/Marello/Bundle/NotificationBundle/Migrations/Schema/v1_2/MarelloNotificationBundle.php b/src/Marello/Bundle/NotificationBundle/Migrations/Schema/v1_2/MarelloNotificationBundle.php
new file mode 100644
index 000000000..45bbc31c9
--- /dev/null
+++ b/src/Marello/Bundle/NotificationBundle/Migrations/Schema/v1_2/MarelloNotificationBundle.php
@@ -0,0 +1,34 @@
+updateAttachmentForeignKeys($schema);
+ }
+
+ /**
+ * Add foreign keys.
+ *
+ * @param Schema $schema
+ */
+ protected function updateAttachmentForeignKeys(Schema $schema)
+ {
+ $table = $schema->getTable('marello_notification_attach');
+ $table->removeForeignKey('FK_70347799464E68B');
+ $table->addForeignKeyConstraint(
+ $schema->getTable('oro_attachment'),
+ ['attachment_id'],
+ ['id']
+ );
+ }
+}
diff --git a/src/Marello/Bundle/OrderBundle/Controller/OrderController.php b/src/Marello/Bundle/OrderBundle/Controller/OrderController.php
index 34c0fa5cf..674b18b4e 100644
--- a/src/Marello/Bundle/OrderBundle/Controller/OrderController.php
+++ b/src/Marello/Bundle/OrderBundle/Controller/OrderController.php
@@ -13,7 +13,6 @@
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Routing\Annotation\Route;
class OrderController extends AbstractController
diff --git a/src/Marello/Bundle/OrderBundle/Entity/Order.php b/src/Marello/Bundle/OrderBundle/Entity/Order.php
index c30d6e340..e806c952d 100644
--- a/src/Marello/Bundle/OrderBundle/Entity/Order.php
+++ b/src/Marello/Bundle/OrderBundle/Entity/Order.php
@@ -223,33 +223,6 @@ class Order extends ExtendOrder implements
*/
protected $paymentMethodOptions;
- /**
- * @var string
- * @ORM\Column(name="payment_reference", type="string", length=255, nullable=true)
- * @Oro\ConfigField(
- * defaultValues={
- * "dataaudit"={
- * "auditable"=true
- * }
- * }
- * )
- */
- protected $paymentReference;
-
- /**
- * @var string
- *
- * @ORM\Column(name="payment_details", type="text", nullable=true)
- * @Oro\ConfigField(
- * defaultValues={
- * "dataaudit"={
- * "auditable"=true
- * }
- * }
- * )
- */
- protected $paymentDetails;
-
/**
* @var double
*
@@ -925,26 +898,6 @@ public function setPaymentMethodOptions(array $paymentMethodOptions)
return $this;
}
- /**
- * @return string
- */
- public function getPaymentDetails()
- {
- return $this->paymentDetails;
- }
-
- /**
- * @param string $paymentDetails
- *
- * @return $this
- */
- public function setPaymentDetails($paymentDetails)
- {
- $this->paymentDetails = $paymentDetails;
-
- return $this;
- }
-
/**
* @return string
*/
@@ -1041,26 +994,6 @@ public function setInvoicedAt($invoicedAt)
return $this;
}
- /**
- * @return string
- */
- public function getPaymentReference()
- {
- return $this->paymentReference;
- }
-
- /**
- * @param string $paymentReference
- *
- * @return $this
- */
- public function setPaymentReference($paymentReference)
- {
- $this->paymentReference = $paymentReference;
-
- return $this;
- }
-
/**
* @param int $id
*/
diff --git a/src/Marello/Bundle/OrderBundle/EventListener/Doctrine/OrderWorkflowStartListener.php b/src/Marello/Bundle/OrderBundle/EventListener/Doctrine/OrderWorkflowStartListener.php
index 079ebaaab..a2edecb6f 100644
--- a/src/Marello/Bundle/OrderBundle/EventListener/Doctrine/OrderWorkflowStartListener.php
+++ b/src/Marello/Bundle/OrderBundle/EventListener/Doctrine/OrderWorkflowStartListener.php
@@ -97,7 +97,9 @@ protected function getDefaultWorkflowNames(): array
{
return [
WorkflowNameProviderInterface::ORDER_WORKFLOW_1,
- WorkflowNameProviderInterface::ORDER_WORKFLOW_2
+ WorkflowNameProviderInterface::ORDER_WORKFLOW_2,
+ WorkflowNameProviderInterface::ORDER_DEPRECATED_WORKFLOW_1,
+ WorkflowNameProviderInterface::ORDER_DEPRECATED_WORKFLOW_2
];
}
diff --git a/src/Marello/Bundle/OrderBundle/Form/Type/OrderItemCollectionType.php b/src/Marello/Bundle/OrderBundle/Form/Type/OrderItemCollectionType.php
index 707425eb5..82921b3e3 100644
--- a/src/Marello/Bundle/OrderBundle/Form/Type/OrderItemCollectionType.php
+++ b/src/Marello/Bundle/OrderBundle/Form/Type/OrderItemCollectionType.php
@@ -27,7 +27,7 @@ public function configureOptions(OptionsResolver $resolver)
$resolver->setDefaults([
'entry_type' => OrderItemType::class,
'show_form_when_empty' => false,
- 'error_bubbling' => false,
+ 'error_bubbling' => true,
'constraints' => [new Valid()],
'prototype_name' => '__nameorderitem__',
'prototype' => true,
diff --git a/src/Marello/Bundle/OrderBundle/Form/Type/OrderItemType.php b/src/Marello/Bundle/OrderBundle/Form/Type/OrderItemType.php
index 38dfcab61..603bb8af5 100644
--- a/src/Marello/Bundle/OrderBundle/Form/Type/OrderItemType.php
+++ b/src/Marello/Bundle/OrderBundle/Form/Type/OrderItemType.php
@@ -47,39 +47,45 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('product', ProductSalesChannelAwareSelectType::class, [
'required' => true,
'label' => 'marello.product.entity_label',
- 'create_enabled' => false,
+ 'create_enabled' => false
])
->add('quantity', NumberType::class, [
- 'data' => 1,
- ])->add('availableInventory', NumberType::class, [
+ 'data' => 1
+ ])
+ ->add('availableInventory', NumberType::class, [
'mapped' => false,
'attr' => [
- 'readonly' => true,
+ 'readonly' => true
+ ]
+ ])
+ ->add('productUnit', TextType::class, [
+ 'attr' => [
+ 'readonly' => true
]
])
->add('price', TextType::class, [
'attr' => [
- 'readonly' => true,
+ 'readonly' => true
]
])
->add('tax', TextType::class, [
'attr' => [
- 'readonly' => true,
+ 'readonly' => true
]
])
->add('taxCode', TextType::class, [
'attr' => [
- 'readonly' => true,
+ 'readonly' => true
]
])
->add('rowTotalExclTax', TextType::class, [
'attr' => [
- 'readonly' => true,
+ 'readonly' => true
]
])
->add('rowTotalInclTax', TextType::class, [
'attr' => [
- 'readonly' => true,
+ 'readonly' => true
]
])
;
diff --git a/src/Marello/Bundle/OrderBundle/Form/Type/OrderTotalPaidType.php b/src/Marello/Bundle/OrderBundle/Form/Type/OrderTotalPaidType.php
new file mode 100644
index 000000000..ed29022d6
--- /dev/null
+++ b/src/Marello/Bundle/OrderBundle/Form/Type/OrderTotalPaidType.php
@@ -0,0 +1,93 @@
+localeSettings = $localeSettings;
+ $this->currencyListProvider = $currencyListProvider;
+ }
+
+ /**
+ * @param FormBuilderInterface $builder
+ * @param array $options
+ */
+ public function buildForm(FormBuilderInterface $builder, array $options)
+ {
+ $currencyChoices = [];
+ if (isset($options['currency']) && $options['currency'] !== null) {
+ $currencyChoices[$this->localeSettings->getCurrencySymbolByCurrency($options['currency'])] =
+ $options['currency'];
+ } else {
+ foreach ($this->currencyListProvider->getCurrencyList() as $currency) {
+ $currencyChoices[$this->localeSettings->getCurrencySymbolByCurrency($currency)] =
+ $currency;
+ }
+ }
+
+ $builder
+ ->add(
+ 'value',
+ NumberType::class,
+ [
+ 'grouping' => true,
+ 'required' => true,
+ 'constraints' => new NotNull
+ ]
+ )
+ ->add(
+ 'currency',
+ ChoiceType::class,
+ [
+ 'choices' => $currencyChoices
+ ]
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver->setDefaults([
+ 'data_class' => Price::class,
+ 'currency' => null
+ ]);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBlockPrefix()
+ {
+ return self::BLOCK_PREFIX;
+ }
+}
diff --git a/src/Marello/Bundle/OrderBundle/Migrations/Schema/MarelloOrderBundleInstaller.php b/src/Marello/Bundle/OrderBundle/Migrations/Schema/MarelloOrderBundleInstaller.php
index 0678baba2..362535355 100644
--- a/src/Marello/Bundle/OrderBundle/Migrations/Schema/MarelloOrderBundleInstaller.php
+++ b/src/Marello/Bundle/OrderBundle/Migrations/Schema/MarelloOrderBundleInstaller.php
@@ -46,7 +46,7 @@ class MarelloOrderBundleInstaller implements
*/
public function getMigrationVersion()
{
- return 'v1_13_2';
+ return 'v3_1_2';
}
/**
@@ -92,8 +92,6 @@ protected function createMarelloOrderOrderTable(Schema $schema)
'notnull' => false, 'comment' => '(DC2Type:json_array)'
]
);
- $table->addColumn('payment_reference', 'string', ['notnull' => false, 'length' => 255]);
- $table->addColumn('payment_details', 'text', ['notnull' => false]);
$table->addColumn('data', 'json_array', ['notnull' => false, 'comment' => '(DC2Type:json_array)']);
$table->addColumn(
'shipping_amount_incl_tax',
diff --git a/src/Marello/Bundle/OrderBundle/Migrations/Schema/v3_1/MarelloOrderBundle.php b/src/Marello/Bundle/OrderBundle/Migrations/Schema/v3_1/MarelloOrderBundle.php
new file mode 100644
index 000000000..18caf1371
--- /dev/null
+++ b/src/Marello/Bundle/OrderBundle/Migrations/Schema/v3_1/MarelloOrderBundle.php
@@ -0,0 +1,29 @@
+updateOrderTable($schema);
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function updateOrderTable(Schema $schema)
+ {
+ $table = $schema->getTable('marello_order_order');
+ $table->dropColumn('payment_reference');
+ $table->dropColumn('payment_details');
+ }
+}
diff --git a/src/Marello/Bundle/OrderBundle/Migrations/Schema/v3_1_1/MarelloOrderBundle.php b/src/Marello/Bundle/OrderBundle/Migrations/Schema/v3_1_1/MarelloOrderBundle.php
new file mode 100644
index 000000000..92b31b802
--- /dev/null
+++ b/src/Marello/Bundle/OrderBundle/Migrations/Schema/v3_1_1/MarelloOrderBundle.php
@@ -0,0 +1,73 @@
+updateOrderTable($schema);
+ $this->updateOrderItemTable($schema);
+ }
+
+ private function updateOrderTable(Schema $schema)
+ {
+ $table = $schema->getTable('marello_order_order');
+ if (!$table->hasColumn('delivery_date')) {
+ $table->addColumn('delivery_date', 'datetime', ['notnull' => false]);
+ }
+ if (!$table->hasColumn('order_note')) {
+ $table->addColumn('order_note', 'text', ['notnull' => false]);
+ }
+ if (!$table->hasColumn('po_number')) {
+ $table->addColumn('po_number', 'string', ['length' => 255, 'notnull' => false]);
+ }
+ }
+
+ private function updateOrderItemTable(Schema $schema)
+ {
+ $tableName = $this->extendExtension->getNameGenerator()->generateEnumTableName('marello_product_unit');
+ // enum table is already available and created...
+ if ($schema->hasTable($tableName)) {
+ return;
+ }
+
+ $table = $schema->getTable('marello_order_order_item');
+ $this->extendExtension->addEnumField(
+ $schema,
+ $table,
+ 'productUnit',
+ 'marello_product_unit',
+ false,
+ false,
+ [
+ 'extend' => ['owner' => ExtendScope::OWNER_SYSTEM],
+ ]
+ );
+ }
+
+ /**
+ * Sets the ExtendExtension
+ *
+ * @param ExtendExtension $extendExtension
+ */
+ public function setExtendExtension(ExtendExtension $extendExtension)
+ {
+ $this->extendExtension = $extendExtension;
+ }
+}
diff --git a/src/Marello/Bundle/OrderBundle/Migrations/Schema/v1_13_1/MarelloOrderBundle.php b/src/Marello/Bundle/OrderBundle/Migrations/Schema/v3_1_2/MarelloOrderBundle.php
similarity index 77%
rename from src/Marello/Bundle/OrderBundle/Migrations/Schema/v1_13_1/MarelloOrderBundle.php
rename to src/Marello/Bundle/OrderBundle/Migrations/Schema/v3_1_2/MarelloOrderBundle.php
index 69560bd4b..d64955a37 100644
--- a/src/Marello/Bundle/OrderBundle/Migrations/Schema/v1_13_1/MarelloOrderBundle.php
+++ b/src/Marello/Bundle/OrderBundle/Migrations/Schema/v3_1_2/MarelloOrderBundle.php
@@ -1,6 +1,6 @@
getTable('marello_order_order');
- $table->addColumn('locale_id', 'string', ['notnull' => false, 'length' => 255]);
-
+ if (!$table->hasColumn('locale_id')) {
+ $table->addColumn('locale_id', 'string', ['notnull' => false, 'length' => 255]);
+ }
$queries->addQuery(
new UpdateEntityConfigFieldValueQuery(
Order::class,
diff --git a/src/Marello/Bundle/OrderBundle/Model/WorkflowNameProviderInterface.php b/src/Marello/Bundle/OrderBundle/Model/WorkflowNameProviderInterface.php
index e951aef0e..79c2d1389 100644
--- a/src/Marello/Bundle/OrderBundle/Model/WorkflowNameProviderInterface.php
+++ b/src/Marello/Bundle/OrderBundle/Model/WorkflowNameProviderInterface.php
@@ -4,6 +4,8 @@
interface WorkflowNameProviderInterface
{
- const ORDER_WORKFLOW_1 = 'marello_order_b2c_workflow_1';
- const ORDER_WORKFLOW_2 = 'marello_order_b2c_workflow_2';
+ const ORDER_DEPRECATED_WORKFLOW_1 = 'marello_order_b2c_workflow_1';
+ const ORDER_DEPRECATED_WORKFLOW_2 = 'marello_order_b2c_workflow_2';
+ const ORDER_WORKFLOW_1 = 'marello_order_b2c_new_workflow_1';
+ const ORDER_WORKFLOW_2 = 'marello_order_b2c_new_workflow_2';
}
diff --git a/src/Marello/Bundle/OrderBundle/Resources/config/form.yml b/src/Marello/Bundle/OrderBundle/Resources/config/form.yml
index 9058b368e..17718fbe8 100644
--- a/src/Marello/Bundle/OrderBundle/Resources/config/form.yml
+++ b/src/Marello/Bundle/OrderBundle/Resources/config/form.yml
@@ -6,6 +6,14 @@ services:
tags:
- { name: form.type }
+ marello_order.form.type.total_paid:
+ class: Marello\Bundle\OrderBundle\Form\Type\OrderTotalPaidType
+ arguments:
+ - '@oro_locale.settings'
+ - '@oro_currency.config.currency'
+ tags:
+ - { name: form.type }
+
marello_order.form.type.order_update:
class: Marello\Bundle\OrderBundle\Form\Type\OrderUpdateType
tags:
diff --git a/src/Marello/Bundle/OrderBundle/Resources/config/oro/api.yml b/src/Marello/Bundle/OrderBundle/Resources/config/oro/api.yml
index 0e33250c1..3e69395ac 100644
--- a/src/Marello/Bundle/OrderBundle/Resources/config/oro/api.yml
+++ b/src/Marello/Bundle/OrderBundle/Resources/config/oro/api.yml
@@ -60,6 +60,11 @@ api:
allow_array: true
property_path: order
description: 'Filter by order ID'
+ status_id:
+ data_type: string
+ allow_array: true
+ property_path: status_id
+ description: 'Filter by status'
actions:
delete: false
delete_list: false
diff --git a/src/Marello/Bundle/OrderBundle/Resources/config/oro/datagrids.yml b/src/Marello/Bundle/OrderBundle/Resources/config/oro/datagrids.yml
index 677da9169..39c1a5d0c 100644
--- a/src/Marello/Bundle/OrderBundle/Resources/config/oro/datagrids.yml
+++ b/src/Marello/Bundle/OrderBundle/Resources/config/oro/datagrids.yml
@@ -471,7 +471,7 @@ datagrids:
from:
- { table: MarelloOrderBundle:OrderItem, alias: oi }
join:
- left:
+ inner:
- { join: oi.order, alias: o }
columns:
productSku:
diff --git a/src/Marello/Bundle/OrderBundle/Resources/config/oro/workflows.yml b/src/Marello/Bundle/OrderBundle/Resources/config/oro/workflows.yml
index ce650eb67..7fe3385f8 100644
--- a/src/Marello/Bundle/OrderBundle/Resources/config/oro/workflows.yml
+++ b/src/Marello/Bundle/OrderBundle/Resources/config/oro/workflows.yml
@@ -621,3 +621,632 @@ workflows:
parameters_mapping:
order: $order
current_transition: payment_reminder
+
+ marello_order_b2c_new_workflow_1:
+ entity: Marello\Bundle\OrderBundle\Entity\Order
+ entity_attribute: order
+ exclusive_record_groups: [order_b2c]
+ priority: 5
+ defaults:
+ active: true
+
+ attributes:
+ payment_reference:
+ type: string
+ payment_details:
+ type: string
+ total_paid:
+ type: object
+ options:
+ class: Oro\Bundle\CurrencyBundle\Entity\Price
+ invoiced_at:
+ type: object
+ options:
+ class: \DateTime
+ note:
+ type: string
+ update_balanced_inventory:
+ type: boolean
+ steps:
+ pending:
+ allowed_transitions:
+ - invoice
+ - hold_pending
+ - cancel
+ cancelled:
+ allowed_transitions: []
+ pending_on_hold:
+ allowed_transitions:
+ - un_hold_pending
+ invoice_on_hold:
+ allowed_transitions:
+ - un_hold_invoice
+ paid:
+ allowed_transitions:
+ - prepare_shipping
+ invoice:
+ allowed_transitions:
+ - hold_invoice
+ - payment_reminder
+ - payment_received
+ pick_and_pack:
+ allowed_transitions:
+ - ship
+ shipped:
+ allowed_transitions: []
+
+ transitions:
+ pending:
+ step_to: pending
+ is_start: true
+ transition_definition: pending_definition
+ cancel:
+ step_to: cancelled
+ transition_definition: cancel_definition
+ hold_pending:
+ step_to: pending_on_hold
+ transition_definition: hold_definition
+ form_options:
+ attribute_fields:
+ note:
+ form_type: Symfony\Component\Form\Extension\Core\Type\TextareaType
+ options:
+ required: false
+ un_hold_pending:
+ step_to: pending
+ transition_definition: un_hold_definition
+ hold_invoice:
+ step_to: invoice_on_hold
+ transition_definition: hold_definition
+ form_options:
+ attribute_fields:
+ note:
+ form_type: Symfony\Component\Form\Extension\Core\Type\TextareaType
+ options:
+ required: false
+ un_hold_invoice:
+ step_to: invoice
+ transition_definition: un_hold_definition
+ invoice:
+ step_to: invoice
+ transition_definition: invoice_definition
+ form_options:
+ attribute_fields:
+ invoiced_at:
+ form_type: Oro\Bundle\FormBundle\Form\Type\OroDateTimeType
+ options:
+ required: true
+ constraints:
+ - NotBlank: ~
+ - DateTime: ~
+ payment_received:
+ step_to: paid
+ transition_definition: payment_received_definition
+ form_options:
+ attribute_fields:
+ payment_reference:
+ form_type: Symfony\Component\Form\Extension\Core\Type\TextType
+ options:
+ required: true
+ constraints:
+ - NotBlank: ~
+ payment_details:
+ form_type: Symfony\Component\Form\Extension\Core\Type\TextType
+ options:
+ required: true
+ constraints:
+ - NotBlank: ~
+ total_paid:
+ form_type: Marello\Bundle\OrderBundle\Form\Type\OrderTotalPaidType
+ options:
+ required: true
+ currency: $order.currency
+ ship:
+ step_to: shipped
+ transition_definition: ship_definition
+ prepare_shipping:
+ step_to: pick_and_pack
+ transition_definition: prepare_shipping_definition
+ payment_reminder:
+ step_to: invoice
+ transition_definition: payment_reminder_definition
+
+ transition_definitions:
+ pending_definition:
+ actions:
+ - '@assign_value':
+ - [$update_balanced_inventory, true]
+ post_actions:
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: pending
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'pending'
+ cancel_definition:
+ conditions:
+ '@and':
+ - '@sales_channel_has_valid_integration':
+ salesChannel: $order.salesChannel
+ actions:
+ - '@extendable':
+ events: [extendable_action.order_cancel]
+ post_actions:
+ - '@marello_cancel_order':
+ update_balanced_inventory: $update_balanced_inventory
+ - '@marello_notification_send':
+ entity: $order
+ recipient: $order.customer
+ template: marello_order_cancelled
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: cancel
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'cancelled'
+ hold_definition:
+ actions:
+ - '@tree':
+ conditions:
+ '@not_empty': $note
+ actions:
+ - '@create_note':
+ message: $note
+ target_entity: $order
+ - '@assign_value': [$note, ~]
+ post_actions:
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: hold
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'hold'
+ un_hold_definition:
+ post_actions:
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: un_hold
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'processing'
+ invoice_definition:
+ conditions:
+ '@and':
+ - '@sales_channel_has_valid_integration':
+ salesChannel: $order.salesChannel
+ post_actions:
+ - '@assign_value':
+ attribute: $order.invoicedAt
+ value: $invoiced_at
+ - '@marello_notification_send':
+ entity: $order
+ recipient: $order.customer
+ template: marello_order_invoiced
+ - '@extendable':
+ events: [extendable_action.order_invoiced]
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: invoice
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'invoiced'
+ payment_received_definition:
+ conditions:
+ '@and':
+ - '@sales_channel_has_valid_integration':
+ salesChannel: $order.salesChannel
+ post_actions:
+ - '@extendable':
+ events: [extendable_action.order_paid]
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: payment_received
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'paid'
+ prepare_shipping_definition:
+ conditions:
+ '@and':
+ - '@not_empty': $order.shippingMethod
+ - '@not_empty': $order.shippingAddress.country
+ - '@not_empty': $order.shippingAddress.postalCode
+ - '@not_empty': $order.shippingAddress.city
+ - '@not_empty': $order.shippingAddress.street
+ post_actions:
+ - '@call_service_method':
+ service: marello_order.factory.shipping_context
+ method: create
+ method_parameters: [$order]
+ attribute: $.result.orderShippingContext
+ - '@marello_shipment_create':
+ context: $.result.orderShippingContext
+ method: $order.shippingMethod
+ methodType: $order.shippingMethodType
+ - '@extendable':
+ events: [extendable_action.create_packingslip]
+ - '@marello_pick_pack_order': ~
+ - '@marello_notification_send':
+ entity: $order
+ recipient: $order.customer
+ template: marello_order_shipping_prepared
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: prepare_shipping
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'pick_and_pack'
+ ship_definition:
+ conditions:
+ '@and':
+ - '@not_empty': $order.shippingAddress.country
+ - '@not_empty': $order.shippingAddress.postalCode
+ - '@not_empty': $order.shippingAddress.city
+ - '@not_empty': $order.shippingAddress.street
+ - '@sales_channel_has_valid_integration':
+ salesChannel: $order.salesChannel
+ post_actions:
+ - '@extendable':
+ events: [extendable_action.order_ship]
+ - '@marello_ship_order': ~
+ - '@marello_notification_send':
+ entity: $order
+ recipient: $order.customer
+ template: marello_order_shipped_confirmation
+ - '@extendable':
+ events: [extendable_action.order_shipped]
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: ship
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'shipped'
+ payment_reminder_definition:
+ post_actions:
+ - '@marello_notification_send':
+ entity: $order
+ recipient: $order.customer
+ template: marello_order_payment_reminder
+ - '@flash_message':
+ message: 'Reminder has been sent.'
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: payment_reminder
+
+ marello_order_b2c_new_workflow_2:
+ entity: Marello\Bundle\OrderBundle\Entity\Order
+ entity_attribute: order
+ priority: 8
+ exclusive_record_groups: [order_b2c]
+ attributes:
+ payment_reference:
+ type: string
+ payment_details:
+ type: string
+ total_paid:
+ type: object
+ options:
+ class: Oro\Bundle\CurrencyBundle\Entity\Price
+ invoiced_at:
+ type: object
+ options:
+ class: \DateTime
+ note:
+ type: string
+ steps:
+ pending:
+ allowed_transitions:
+ - invoice
+ invoice:
+ allowed_transitions:
+ - prepare_shipping
+ pick_and_pack:
+ allowed_transitions:
+ - ship
+ shipped:
+ allowed_transitions:
+ - payment_received
+ cancelled:
+ allowed_transitions: []
+ pending_on_hold:
+ allowed_transitions:
+ - un_hold_pending
+ invoice_on_hold:
+ allowed_transitions:
+ - un_hold_invoice
+ paid:
+ allowed_transitions: []
+ transitions:
+ pending:
+ step_to: pending
+ is_start: true
+ transition_definition: pending_definition
+ cancel:
+ step_to: cancelled
+ transition_definition: cancel_definition
+ hold_pending:
+ step_to: pending_on_hold
+ transition_definition: hold_definition
+ form_options:
+ attribute_fields:
+ note:
+ form_type: Symfony\Component\Form\Extension\Core\Type\TextAreaType
+ options:
+ required: false
+ un_hold_pending:
+ step_to: pending
+ transition_definition: un_hold_definition
+ hold_invoice:
+ step_to: invoice_on_hold
+ transition_definition: hold_definition
+ form_options:
+ attribute_fields:
+ note:
+ form_type: Symfony\Component\Form\Extension\Core\Type\TextAreaType
+ options:
+ required: false
+ un_hold_invoice:
+ step_to: invoice
+ transition_definition: un_hold_definition
+ invoice:
+ step_to: invoice
+ transition_definition: invoice_definition
+ form_options:
+ attribute_fields:
+ invoiced_at:
+ form_type: Oro\Bundle\FormBundle\Form\Type\OroDateTimeType
+ options:
+ required: true
+ constraints:
+ - NotBlank: ~
+ - DateTime: ~
+ payment_received:
+ step_to: paid
+ transition_definition: payment_received_definition
+ form_options:
+ attribute_fields:
+ payment_reference:
+ form_type: Symfony\Component\Form\Extension\Core\Type\TextType
+ options:
+ required: true
+ constraints:
+ - NotBlank: ~
+ payment_details:
+ form_type: Symfony\Component\Form\Extension\Core\Type\TextType
+ options:
+ required: true
+ constraints:
+ - NotBlank: ~
+ total_paid:
+ form_type: Marello\Bundle\OrderBundle\Form\Type\OrderTotalPaidType
+ options:
+ required: true
+ currency: $order.currency
+ ship:
+ step_to: shipped
+ transition_definition: ship_definition
+ prepare_shipping:
+ step_to: pick_and_pack
+ transition_definition: prepare_shipping_definition
+ payment_reminder:
+ step_to: pending
+ transition_definition: payment_reminder_definition
+
+ transition_definitions:
+ pending_definition:
+ post_actions:
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: pending
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'pending'
+ cancel_definition:
+ conditions:
+ '@and':
+ - '@sales_channel_has_valid_integration':
+ salesChannel: $order.salesChannel
+ actions:
+ - '@extendable':
+ events: [extendable_action.order_cancel]
+ post_actions:
+ - '@marello_cancel_order': ~
+ - '@marello_notification_send':
+ entity: $order
+ recipient: $order.customer
+ template: marello_order_cancelled
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: cancel
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'cancelled'
+ hold_definition:
+ post_actions:
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: hold
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'hold'
+ un_hold_definition:
+ post_actions:
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: un_hold
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'processing'
+ invoice_definition:
+ conditions:
+ '@and':
+ - '@sales_channel_has_valid_integration':
+ salesChannel: $order.salesChannel
+ post_actions:
+ - '@assign_value':
+ attribute: $order.invoicedAt
+ value: $invoiced_at
+ - '@marello_notification_send':
+ entity: $order
+ recipient: $order.customer
+ template: marello_order_invoiced
+ - '@extendable':
+ events: [extendable_action.order_invoiced]
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: invoice
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'invoiced'
+ payment_received_definition:
+ conditions:
+ '@and':
+ - '@sales_channel_has_valid_integration':
+ salesChannel: $order.salesChannel
+ post_actions:
+ - '@marello_notification_send':
+ entity: $order
+ recipient: $order.customer
+ template: marello_order_invoiced
+ - '@extendable':
+ events: [extendable_action.order_paid]
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: payment_received
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'paid'
+ prepare_shipping_definition:
+ conditions:
+ '@and':
+ - '@not_empty': $order.shippingMethod
+ - '@not_empty': $order.shippingAddress.country
+ - '@not_empty': $order.shippingAddress.postalCode
+ - '@not_empty': $order.shippingAddress.city
+ - '@not_empty': $order.shippingAddress.street
+ post_actions:
+ - '@call_service_method':
+ service: marello_order.factory.shipping_context
+ method: create
+ method_parameters: [$order]
+ attribute: $.result.orderShippingContext
+ - '@marello_shipment_create':
+ context: $.result.orderShippingContext
+ method: $order.shippingMethod
+ methodType: $order.shippingMethodType
+ - '@extendable':
+ events: [extendable_action.create_packingslip]
+ - '@marello_pick_pack_order': ~
+ - '@marello_notification_send':
+ entity: $order
+ recipient: $order.customer
+ template: marello_order_shipping_prepared
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: prepare_shipping
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'pick_and_pack'
+ ship_definition:
+ conditions:
+ '@and':
+ - '@not_empty': $order.shippingAddress.country
+ - '@not_empty': $order.shippingAddress.postalCode
+ - '@not_empty': $order.shippingAddress.city
+ - '@not_empty': $order.shippingAddress.street
+ - '@sales_channel_has_valid_integration':
+ salesChannel: $order.salesChannel
+ post_actions:
+ - '@extendable':
+ events: [extendable_action.order_ship]
+ - '@marello_ship_order': ~
+ - '@marello_notification_send':
+ entity: $order
+ recipient: $order.customer
+ template: marello_order_shipped_confirmation
+ - '@extendable':
+ events: [extendable_action.order_shipped]
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: ship
+ - '@run_action_group':
+ action_group: marello_order_status_change
+ parameters_mapping:
+ order: $order
+ status: 'shipped'
+ payment_reminder_definition:
+ post_actions:
+ - '@marello_notification_send':
+ entity: $order
+ recipient: $order.customer
+ template: marello_order_payment_reminder
+ - '@flash_message':
+ message: 'Reminder has been sent.'
+ - '@run_action_group':
+ action_group: send_order_invoice_email
+ parameters_mapping:
+ order: $order
+ current_transition: payment_reminder
diff --git a/src/Marello/Bundle/OrderBundle/Resources/doc/api/order.md b/src/Marello/Bundle/OrderBundle/Resources/doc/api/order.md
index 70cf8ada3..b536a295c 100644
--- a/src/Marello/Bundle/OrderBundle/Resources/doc/api/order.md
+++ b/src/Marello/Bundle/OrderBundle/Resources/doc/api/order.md
@@ -44,8 +44,6 @@ Example without address:
"grandTotal": "60.5000",
"currency": "EUR",
"paymentMethod": null,
- "paymentReference": null,
- "paymentDetails": null,
"shippingAmountInclTax": "10.0000",
"shippingAmountExclTax": "10.0000",
"shippingMethod": null,
diff --git a/src/Marello/Bundle/OrderBundle/Resources/public/css/scss/style.scss b/src/Marello/Bundle/OrderBundle/Resources/public/css/scss/style.scss
index cd5f123a2..097ad83e5 100644
--- a/src/Marello/Bundle/OrderBundle/Resources/public/css/scss/style.scss
+++ b/src/Marello/Bundle/OrderBundle/Resources/public/css/scss/style.scss
@@ -29,46 +29,26 @@
width: 315px;
}
-.order-line-item-quantity {
+.order-line-item-tax-code,
+.order-line-item-product-unit {
width: 243px;
input[type="text"] {
width:80px;
- text-align:right;
- float: left;
- }
-}
-
-.order-line-item-price {
- line-height: 2.3;
- width: 243px;
-
- input[type="text"] {
- width:80px;
- text-align:right;
- padding-left: 17px;
- float: left;
- }
-}
-
-.order-line-item-tax {
- width: 243px;
-
- input[type="text"] {
- width:80px;
- text-align:right;
- padding-left: 17px;
+ text-align:left;
float: left;
}
}
+.order-line-item-tax,
+.order-line-item-price,
+.order-line-item-quantity,
.order-line-item-total-price {
width: 243px;
input[type="text"] {
width:80px;
text-align:right;
- padding-left: 17px;
float: left;
}
}
diff --git a/src/Marello/Bundle/OrderBundle/Resources/public/js/app/views/order-item-view.js b/src/Marello/Bundle/OrderBundle/Resources/public/js/app/views/order-item-view.js
index c4445671e..46e8549eb 100644
--- a/src/Marello/Bundle/OrderBundle/Resources/public/js/app/views/order-item-view.js
+++ b/src/Marello/Bundle/OrderBundle/Resources/public/js/app/views/order-item-view.js
@@ -92,6 +92,7 @@ define(function(require) {
this.fieldsByName.price.val($priceValue);
this.fieldsByName.taxCode.val(this.getTaxCode());
+ this.fieldsByName.productUnit.val(this.getProductUnit());
this.setRowTotals();
this.setAvailableInventory();
@@ -124,6 +125,13 @@ define(function(require) {
return !_.isEmpty(this.data['row_totals'][this.getRowItemIdentifier()]) ? this.data['row_totals'][this.getRowItemIdentifier()] : null;
},
+ /**
+ * @returns {Array|Null}
+ */
+ getProductUnit: function() {
+ return !_.isEmpty(this.data['product_unit']) ? this.data['product_unit'].unit : null;
+ },
+
/**
* @returns {Array|Null}
*/
@@ -152,7 +160,7 @@ define(function(require) {
setAvailableInventory: function() {
if (this.getProductInventory() === null) {
- return
+ return;
}
this.fieldsByName.availableInventory.val(this.getProductInventory());
diff --git a/src/Marello/Bundle/OrderBundle/Resources/translations/messages.en.yml b/src/Marello/Bundle/OrderBundle/Resources/translations/messages.en.yml
index ec1d8a3fd..52320c3b1 100644
--- a/src/Marello/Bundle/OrderBundle/Resources/translations/messages.en.yml
+++ b/src/Marello/Bundle/OrderBundle/Resources/translations/messages.en.yml
@@ -59,7 +59,7 @@ marello:
edit_action: Edit Address
datablock:
general: General
- billing_and_payment: Billing & Payment
+ billing_address: Billing Address
delivery: Delivery
order_items: Order Items
activity: Activity
@@ -68,6 +68,7 @@ marello:
order_totals: Order Totals
packing_slips: Packing Slips
invoices: Invoices
+ payments: Payments
source_references_information: Source References
optional: Optional
# OrderItem entity
diff --git a/src/Marello/Bundle/OrderBundle/Resources/translations/workflows.en.yml b/src/Marello/Bundle/OrderBundle/Resources/translations/workflows.en.yml
index e765e3040..fef518cfa 100644
--- a/src/Marello/Bundle/OrderBundle/Resources/translations/workflows.en.yml
+++ b/src/Marello/Bundle/OrderBundle/Resources/translations/workflows.en.yml
@@ -1,7 +1,7 @@
oro:
workflow:
marello_order_b2c_workflow_1:
- label: 'Order B2C Workflow #1'
+ label: 'Order B2C Workflow #1(Deprecated)'
attribute:
payment_reference:
label: 'Payment Reference'
@@ -23,7 +23,7 @@ oro:
invoice:
label: 'Invoiced'
paid:
- label: 'Order Payed'
+ label: 'Order Paid'
credit:
label: 'Closed'
pick_and_pack:
@@ -57,7 +57,7 @@ oro:
label: 'Payment Reminder'
marello_order_b2c_workflow_2:
- label: 'Order B2C Workflow #2'
+ label: 'Order B2C Workflow #2(Deprecated)'
attribute:
payment_reference:
label: 'Payment Reference'
@@ -79,7 +79,7 @@ oro:
invoice:
label: 'Complete'
paid:
- label: 'Order Payed'
+ label: 'Order Paid'
credit:
label: 'Closed'
pick_and_pack:
@@ -115,3 +115,123 @@ oro:
label: 'Prepare Shipping'
payment_reminder:
label: 'Payment Reminder'
+
+ marello_order_b2c_new_workflow_1:
+ label: 'Order B2C Workflow #1'
+ attribute:
+ payment_reference:
+ label: 'Payment Reference'
+ payment_details:
+ label: 'Payment Details'
+ total_paid:
+ label: 'Paid Amount'
+ invoiced_at:
+ label: 'Invoiced At'
+ note:
+ label: 'Note'
+ step:
+ pending:
+ label: 'Pending Order'
+ cancelled:
+ label: 'Cancelled'
+ pending_on_hold:
+ label: 'On Hold'
+ invoice_on_hold:
+ label: 'On Hold'
+ invoice:
+ label: 'Invoiced'
+ paid:
+ label: 'Order Paid'
+ credit:
+ label: 'Closed'
+ pick_and_pack:
+ label: 'Pick and Pack'
+ shipped:
+ label: 'Complete'
+ transition:
+ pending:
+ label: 'Pending'
+ cancel:
+ label: 'Cancel'
+ hold_pending:
+ label: 'Hold'
+ un_hold_pending:
+ label: 'Un-Hold'
+ hold_invoice:
+ label: 'Hold'
+ un_hold_invoice:
+ label: 'Un-Hold'
+ invoice:
+ label: 'Invoice'
+ payment_received:
+ label: 'Payment Received'
+ ship:
+ label: 'Ship'
+ credit:
+ label: 'Credit'
+ prepare_shipping:
+ label: 'Prepare Shipping'
+ payment_reminder:
+ label: 'Payment Reminder'
+
+ marello_order_b2c_new_workflow_2:
+ label: 'Order B2C Workflow #2'
+ attribute:
+ payment_reference:
+ label: 'Payment Reference'
+ payment_details:
+ label: 'Payment Details'
+ total_paid:
+ label: 'Paid Amount'
+ invoiced_at:
+ label: 'Invoiced At'
+ note:
+ label: 'Note'
+ step:
+ pending:
+ label: 'Pending Order'
+ cancelled:
+ label: 'Cancelled'
+ pending_on_hold:
+ label: 'On Hold'
+ invoice_on_hold:
+ label: 'On Hold'
+ invoice:
+ label: 'Invoiced'
+ paid:
+ label: 'Complete'
+ credit:
+ label: 'Closed'
+ pick_and_pack:
+ label: 'Pick and Pack'
+ shipped:
+ label: 'Shipped'
+ transition:
+ pending:
+ label: 'Pending'
+ cancel:
+ label: 'Cancel'
+ hold_pending:
+ label: 'Hold'
+ un_hold_pending:
+ label: 'Un-Hold'
+ hold_invoice:
+ label: 'Hold'
+ un_hold_invoice:
+ label: 'Un-Hold'
+ hold_shipped:
+ label: 'Hold'
+ un_hold_shipped:
+ label: 'Un-Hold'
+ invoice:
+ label: 'Invoice'
+ payment_received:
+ label: 'Payment Received'
+ ship:
+ label: 'Ship'
+ credit:
+ label: 'Credit'
+ prepare_shipping:
+ label: 'Prepare Shipping'
+ payment_reminder:
+ label: 'Payment Reminder'
\ No newline at end of file
diff --git a/src/Marello/Bundle/OrderBundle/Resources/views/Form/fields.html.twig b/src/Marello/Bundle/OrderBundle/Resources/views/Form/fields.html.twig
index e25fc6a96..d5907e7a4 100644
--- a/src/Marello/Bundle/OrderBundle/Resources/views/Form/fields.html.twig
+++ b/src/Marello/Bundle/OrderBundle/Resources/views/Form/fields.html.twig
@@ -17,6 +17,12 @@
{{ form_errors(form.availableInventory) }}
|
+
+
+ {{ form_widget(form.productUnit) }}
+
+ {{ form_errors(form.productUnit) }}
+ |
{{ form_widget(form.price) }}
@@ -29,7 +35,7 @@
{{ form_errors(form.tax) }}
|
-
+ |
{{ form_widget(form.taxCode) }}
@@ -109,6 +115,7 @@
| {{ 'marello.product.entity_label'|trans }} |
{{ 'marello.order.orderitem.quantity.label'|trans }} |
{{ 'marello.order.orderitem.inventory.label'|trans }} |
+ {{ 'marello.order.orderitem.product_unit.label'|trans }} |
{{ marello_pricing_vat_aware_label('marello.order.orderitem.price.per_unit.label'|trans) }} |
{{ 'marello.order.orderitem.tax.label'|trans }} |
{{ 'marello.order.orderitem.tax_code.label'|trans }} |
@@ -162,3 +169,15 @@
{{ form_rest(form) }}
{% endif %}
{% endblock %}
+
+{% block marello_order_total_paid_widget %}
+
+
+ {{ form_widget(form.value) }}
+ {{ form_widget(form.currency) }}
+ {{ form_errors(form.value) }}
+ {{ form_errors(form.currency) }}
+
+
+{% endblock %}
+
diff --git a/src/Marello/Bundle/OrderBundle/Resources/views/Order/view.html.twig b/src/Marello/Bundle/OrderBundle/Resources/views/Order/view.html.twig
index 00d4fad59..7a6370dfb 100644
--- a/src/Marello/Bundle/OrderBundle/Resources/views/Order/view.html.twig
+++ b/src/Marello/Bundle/OrderBundle/Resources/views/Order/view.html.twig
@@ -104,6 +104,8 @@
{{ UI.renderProperty('marello.order.total_tax.label'|trans, entity.totalTax|oro_format_currency({'currency':entity.currency})) }}
{{ UI.renderProperty('marello.order.discount_amount.label'|trans, entity.discountAmount|oro_format_currency({'currency':entity.currency})) }}
{{ UI.renderProperty('marello.order.grand_total.label'|trans, entity.grandTotal|oro_format_currency({'currency':entity.currency})) }}
+ {{ UI.renderProperty('marello.invoice.total_paid.label'|trans, marello_get_order_total_paid(entity)|oro_format_currency({'currency':entity.currency})) }}
+ {{ UI.renderProperty('marello.invoice.total_due.label'|trans, marello_get_order_total_due(entity)|oro_format_currency({'currency':entity.currency})) }}
{{ UI.renderProperty('marello.order.coupon_code.label'|trans, entity.couponCode) }}
@@ -111,42 +113,24 @@
{% endset %}
{% set generalSubblocks = generalSubblocks|merge([{'data' : [totalsWidget] }]) %}
- {% set paymentSubblocks = [] %}
+ {% set billingSubblocks = [] %}
{% set billingAddressWidget %}
{{ oro_widget_render({
'widgetType': 'block',
'url': path('marello_order_order_address', {id: entity.billingAddress.id, typeId: 1}),
}) }}
{% endset %}
- {% set paymentSubblocks = paymentSubblocks|merge([{'data' : [billingAddressWidget] }]) %}
+ {% set billingSubblocks = billingSubblocks|merge([{'data' : [billingAddressWidget] }]) %}
- {% set paymentWidget %}
+ {% set emptyWidget %}
{% endset %}
- {% set paymentSubblocks = paymentSubblocks|merge([{'data' : [paymentWidget] }]) %}
+ {% set billingSubblocks = billingSubblocks|merge([{'data' : [emptyWidget] }]) %}
{% set shippingSubblocks = [] %}
{% set shippingAddressWidget %}
@@ -182,6 +166,10 @@
{{ dataGrid.renderGrid('marello-order-invoices-grid', {'orderId': entity.id}) }}
{% endset %}
+ {% set payments %}
+ {{ dataGrid.renderGrid('marello-order-payments-grid', {'orderId': entity.id}) }}
+ {% endset %}
+
{% set optionalWidget %}
diff --git a/src/Marello/Bundle/RefundBundle/Resources/views/Refund/view.html.twig b/src/Marello/Bundle/RefundBundle/Resources/views/Refund/view.html.twig
index b5145d7d2..3f53e0642 100644
--- a/src/Marello/Bundle/RefundBundle/Resources/views/Refund/view.html.twig
+++ b/src/Marello/Bundle/RefundBundle/Resources/views/Refund/view.html.twig
@@ -38,7 +38,6 @@
)}}
{{ UI.renderProperty('marello.order.order_reference.label'|trans, entity.order.orderReference) }}
{{ UI.renderProperty('marello.order.payment_method.label'|trans, entity.order.paymentMethod) }}
- {{ UI.renderProperty('marello.order.payment_reference.label'|trans, entity.order.paymentReference) }}
{{ UI.renderProperty('oro.ui.created_at'|trans, entity.order.createdAt|date) }}
{{ UI.renderProperty('oro.ui.updated_at'|trans, entity.order.updatedAt|date) }}
@@ -74,7 +73,6 @@
{{ UI.renderProperty('oro.ui.created_at'|trans, entity.createdAt|date) }}
{{ UI.renderProperty('oro.ui.updated_at'|trans, entity.updatedAt|date) }}
{{ UI.renderProperty('marello.order.payment_method.label'|trans, entity.order.paymentMethod) }}
- {{ UI.renderProperty('marello.order.payment_reference.label'|trans, entity.order.paymentReference) }}
{{ totals }}
diff --git a/src/Marello/Bundle/RefundBundle/Tests/Functional/Controller/RefundControllerTest.php b/src/Marello/Bundle/RefundBundle/Tests/Functional/Controller/RefundControllerTest.php
index a9f8a63c0..9108151b0 100644
--- a/src/Marello/Bundle/RefundBundle/Tests/Functional/Controller/RefundControllerTest.php
+++ b/src/Marello/Bundle/RefundBundle/Tests/Functional/Controller/RefundControllerTest.php
@@ -55,8 +55,9 @@ public function testUpdateRefund()
$this->assertHtmlResponseStatusCodeEquals($result, Response::HTTP_OK);
$form = $crawler->selectButton('Save and Close')->form();
- $form['marello_refund[items][0][quantity]'] = 1;
- $form['marello_refund[items][0][refundAmount]'] = 100;
+ $key = array_key_first ($form->get('marello_refund[items]'));
+ $form[sprintf('marello_refund[items][%d][quantity]', $key)] = 1;
+ $form[sprintf('marello_refund[items][%d][refundAmount]', $key)] = 100;
$result = $this->client->getResponse();
$this->assertHtmlResponseStatusCodeEquals($result, Response::HTTP_OK);
diff --git a/src/Marello/Bundle/ReportBundle/Resources/config/oro/datagrids.yml b/src/Marello/Bundle/ReportBundle/Resources/config/oro/datagrids.yml
index 680f51a55..ef58d9cbb 100644
--- a/src/Marello/Bundle/ReportBundle/Resources/config/oro/datagrids.yml
+++ b/src/Marello/Bundle/ReportBundle/Resources/config/oro/datagrids.yml
@@ -96,13 +96,9 @@ datagrids:
select:
- oi.productName
- oi.productSku
- - product.createdAt as createdAt
- SUM(oi.quantity) AS quantitySold
from:
- { table: MarelloOrderBundle:OrderItem, alias: oi }
- join:
- left:
- - { join: oi.product, alias: product }
groupBy: oi.productSku, oi.productName
columns:
productSku:
@@ -111,9 +107,6 @@ datagrids:
productName:
label: marello.product.name.label
frontend_type: string
- createdAt:
- label: oro.ui.created_at
- frontend_type: datetime
quantitySold:
label: marello.report.datagrid.columns.quantity_sold.label
frontend_type: number
@@ -122,7 +115,6 @@ datagrids:
columns:
productSku: { data_name: oi.productSku }
productName: { data_name: oi.productName }
- createdAt: { data_name: createdAt }
quantitySold: { data_name: quantitySold }
default:
quantitySold: 'DESC'
@@ -144,13 +136,9 @@ datagrids:
select:
- oi.productName
- oi.productSku
- - product.createdAt as createdAt
- SUM(oi.quantity) AS quantitySold
from:
- { table: MarelloOrderBundle:OrderItem, alias: oi }
- join:
- left:
- - { join: oi.product, alias: product }
groupBy: oi.productSku, oi.productName
columns:
productSku:
@@ -159,9 +147,6 @@ datagrids:
productName:
label: marello.product.name.label
frontend_type: string
- createdAt:
- label: oro.ui.created_at
- frontend_type: datetime
quantitySold:
label: marello.report.datagrid.columns.quantity_sold.label
frontend_type: number
@@ -170,7 +155,6 @@ datagrids:
columns:
productSku: { data_name: oi.productSku }
productName: { data_name: oi.productName }
- createdAt: { data_name: createdAt }
quantitySold: { data_name: quantitySold }
default:
quantitySold: 'ASC'
@@ -253,7 +237,7 @@ datagrids:
from:
- { table: MarelloOrderBundle:OrderItem, alias: oi }
join:
- left:
+ inner:
- { join: MarelloReturnBundle:ReturnItem, alias: ri, conditionType: 'WITH', condition: 'oi.id = ri.orderItem' }
groupBy: oi.productSku, oi.productName
columns:
diff --git a/src/Marello/Bundle/ReturnBundle/Controller/ReturnController.php b/src/Marello/Bundle/ReturnBundle/Controller/ReturnController.php
index 80ba0d1c6..df1003b5a 100644
--- a/src/Marello/Bundle/ReturnBundle/Controller/ReturnController.php
+++ b/src/Marello/Bundle/ReturnBundle/Controller/ReturnController.php
@@ -81,10 +81,9 @@ public function createAction(Order $order, Request $request)
}
return [
- 'form' => $form->createView(),
+ 'form' => $form->createView()
];
} else {
-
throw new AccessDeniedException(
$this->get('translator')->trans(
'marello.return.returnentity.messages.error.return.cannot_be_returned_without_shipment'
diff --git a/src/Marello/Bundle/SalesBundle/Entity/Repository/SalesChannelRepository.php b/src/Marello/Bundle/SalesBundle/Entity/Repository/SalesChannelRepository.php
index e376fafa2..a4b2269e0 100644
--- a/src/Marello/Bundle/SalesBundle/Entity/Repository/SalesChannelRepository.php
+++ b/src/Marello/Bundle/SalesBundle/Entity/Repository/SalesChannelRepository.php
@@ -5,6 +5,7 @@
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Marello\Bundle\PricingBundle\Entity\ProductChannelPrice;
+use Marello\Bundle\ProductBundle\Entity\Product;
use Marello\Bundle\SalesBundle\Entity\SalesChannel;
use Oro\Bundle\SecurityBundle\ORM\Walker\AclHelper;
@@ -122,4 +123,17 @@ public function getDefaultActiveChannels()
return $this->aclHelper->apply($qb)->getResult();
}
+
+ /**
+ * @param Product $product
+ * @return SalesChannel[]
+ */
+ public function findByProduct(Product $product)
+ {
+ $qb = $this->createQueryBuilder('sc')
+ ->where(':product MEMBER OF sc.products')
+ ->setParameters(['product' => $product]);
+
+ return $qb->getQuery()->getResult();
+ }
}
diff --git a/src/Marello/Bundle/SalesBundle/Entity/SalesChannel.php b/src/Marello/Bundle/SalesBundle/Entity/SalesChannel.php
index 0575137e8..c2e2e3d39 100644
--- a/src/Marello/Bundle/SalesBundle/Entity/SalesChannel.php
+++ b/src/Marello/Bundle/SalesBundle/Entity/SalesChannel.php
@@ -2,11 +2,13 @@
namespace Marello\Bundle\SalesBundle\Entity;
+use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Marello\Bundle\CoreBundle\Model\EntityCreatedUpdatedAtTrait;
use Marello\Bundle\LocaleBundle\Model\LocalizationAwareInterface;
use Marello\Bundle\LocaleBundle\Model\LocalizationTrait;
use Marello\Bundle\PricingBundle\Model\CurrencyAwareInterface;
+use Marello\Bundle\ProductBundle\Entity\Product;
use Marello\Bundle\SalesBundle\Model\ExtendSalesChannel;
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation as Oro;
use Oro\Bundle\IntegrationBundle\Entity\Channel;
@@ -198,6 +200,28 @@ class SalesChannel extends ExtendSalesChannel implements
*/
protected $integrationChannel;
+ /**
+ * @var ArrayCollection
+ * @ORM\ManyToMany(targetEntity="Marello\Bundle\ProductBundle\Entity\Product", mappedBy="channels")
+ * @Oro\ConfigField(
+ * defaultValues={
+ * "dataaudit"={
+ * "auditable"=true
+ * },
+ * "importexport"={
+ * "excluded"=true
+ * },
+ * "attribute"={
+ * "is_attribute"=true
+ * },
+ * "extend"={
+ * "owner"="System"
+ * }
+ * }
+ * )
+ */
+ protected $products;
+
/**
* @param string|null $name
*/
@@ -206,6 +230,15 @@ public function __construct($name = null)
parent::__construct();
$this->name = $name;
+ $this->products = new ArrayCollection();
+ }
+
+ public function __clone()
+ {
+ if ($this->id) {
+ $this->id = null;
+ $this->products = new ArrayCollection();
+ }
}
/**
@@ -409,4 +442,29 @@ public function setIntegrationChannel(Channel $integrationChannel = null)
return $this;
}
+
+ /**
+ * @return bool
+ */
+ public function hasProducts()
+ {
+ return count($this->products) > 0;
+ }
+
+ /**
+ * @param Product $product
+ * @return bool
+ */
+ public function hasProduct(Product $product)
+ {
+ return $this->products->contains($product);
+ }
+
+ /**
+ * @return ArrayCollection|SalesChannel|Product[]
+ */
+ public function getProducts()
+ {
+ return $this->products;
+ }
}
diff --git a/src/Marello/Bundle/SalesBundle/EventListener/Datagrid/SalesChannelsDatagridListener.php b/src/Marello/Bundle/SalesBundle/EventListener/Datagrid/SalesChannelsDatagridListener.php
deleted file mode 100644
index d5dd24d18..000000000
--- a/src/Marello/Bundle/SalesBundle/EventListener/Datagrid/SalesChannelsDatagridListener.php
+++ /dev/null
@@ -1,172 +0,0 @@
-relatedEntityClass = $relatedEntityClass;
- $this->salesChannelsChoicesProvider = $salesChannelsChoicesProvider;
-
- $this->expressionBuilder = new Expr();
- }
-
- /**
- * @param BuildBefore $event
- */
- public function onBuildBefore(BuildBefore $event)
- {
- $config = $event->getConfig();
-
- $this->addSelect($config);
- $this->addJoin($config);
- $this->addColumn($config);
- $this->addSorter($config);
- $this->addFilter($config);
- }
-
- /**
- * @param DatagridConfiguration $configuration
- * @return string
- * @throws \InvalidArgumentException when a root entity not found in the grid
- */
- protected function getAlias(DatagridConfiguration $configuration)
- {
- $rootAlias = $configuration->getOrmQuery()->getRootAlias();
- if (!$rootAlias) {
- throw new \InvalidArgumentException(
- sprintf(
- 'A root entity is missing for grid "%s"',
- $configuration->getName()
- )
- );
- }
-
- return $rootAlias;
- }
-
- /**
- * @return string
- */
- protected function getColumnLabel()
- {
- return 'marello.product.channels.label';
- }
-
- /**
- * @return string
- */
- protected function getDataName()
- {
- return self::DATA_NAME;
- }
-
- /**
- * @return string
- */
- protected function getJoinAlias()
- {
- return self::JOIN_ALIAS;
- }
-
- /**
- * @param DatagridConfiguration $config
- */
- protected function addSelect(DatagridConfiguration $config)
- {
- $config->getOrmQuery()
- ->addSelect(
- sprintf(
- 'GROUP_CONCAT(
- DISTINCT CONCAT_WS(\'|\', %1$s.name, %1$s.code) SEPARATOR \';\'
- ) as channels',
- $this->getJoinAlias()
- )
- )
- ->addSelect(
- sprintf('count(%s.code) AS channelsCount', $this->getJoinAlias())
- );
- }
-
- /**
- * @param DatagridConfiguration $config
- */
- protected function addJoin(DatagridConfiguration $config)
- {
- $config->getOrmQuery()->addLeftJoin(
- $this->getAlias($config).'.channels',
- $this->getJoinAlias()
- );
- }
-
- /**
- * @param DatagridConfiguration $config
- */
- protected function addColumn(DatagridConfiguration $config)
- {
- $config->offsetSetByPath(sprintf('[columns][%s]', $this->getDataName()), [
- 'label' => $this->getColumnLabel(),
- 'type' => 'twig',
- 'frontend_type' => 'html',
- 'template' => 'MarelloSalesBundle:SalesChannel/Datagrid/Property:channels.html.twig',
- 'renderable' => true,
- 'inline_editing' => ['enable' => false]
- ]);
- }
-
- /**
- * @param DatagridConfiguration $config
- */
- protected function addSorter(DatagridConfiguration $config)
- {
- $config->offsetSetByPath(
- sprintf('[sorters][columns][%s]', $this->getDataName()),
- ['data_name' => 'channelsCount']
- );
- }
-
- /**
- * @param DatagridConfiguration $config
- */
- protected function addFilter(DatagridConfiguration $config)
- {
- $config->offsetSetByPath(
- sprintf('[filters][columns][%s]', $this->getDataName()),
- [
- 'type' => 'choice',
- 'data_name' => $this->getJoinAlias() . '.code',
- 'enabled' => false,
- 'options' => [
- 'field_options' => [
- 'multiple' => true,
- 'choices' => $this->salesChannelsChoicesProvider->getChannels()
- ]
- ]
- ]
- );
- }
-}
diff --git a/src/Marello/Bundle/SalesBundle/Resources/config/services.yml b/src/Marello/Bundle/SalesBundle/Resources/config/services.yml
index 3603147bf..7e9f7ebe2 100644
--- a/src/Marello/Bundle/SalesBundle/Resources/config/services.yml
+++ b/src/Marello/Bundle/SalesBundle/Resources/config/services.yml
@@ -119,14 +119,6 @@ services:
tags:
- { name: kernel.event_listener, event: oro_datagrid.orm_datasource.result.after.marello-sales-channel-groups, method: onResultAfter }
- marello_sales.event_listener.datagrid.products_grid:
- class: 'Marello\Bundle\SalesBundle\EventListener\Datagrid\SalesChannelsDatagridListener'
- arguments:
- - 'Marello\Bundle\ProductBundle\Entity\Product'
- - '@marello_sales.provider.basic_sales_channels_choices'
- tags:
- - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.marello-products-grid, method: onBuildBefore }
-
marello_sales.datagrid.saleschannelgroup.action_permission_provider:
class: 'Marello\Bundle\SalesBundle\Datagrid\SalesChannelGroupActionPermissionProvider'
public: true
diff --git a/src/Marello/Bundle/SalesBundle/Resources/translations/messages.en.yml b/src/Marello/Bundle/SalesBundle/Resources/translations/messages.en.yml
index ffeac0c76..fc869bebd 100644
--- a/src/Marello/Bundle/SalesBundle/Resources/translations/messages.en.yml
+++ b/src/Marello/Bundle/SalesBundle/Resources/translations/messages.en.yml
@@ -19,6 +19,7 @@ marello:
channel_type.label: Type
owner.label: Owner
localization.label: Localization
+ products.label: Products
controller.message.saved: Sales Channel saved
form.select_saleschannels: Select Sales Channels
form.select_saleschannel: Select Sales Channel
diff --git a/src/Marello/Bundle/SalesBundle/Resources/views/SalesChannel/Datagrid/Property/channels.html.twig b/src/Marello/Bundle/SalesBundle/Resources/views/SalesChannel/Datagrid/Property/channels.html.twig
deleted file mode 100644
index 95cd7252c..000000000
--- a/src/Marello/Bundle/SalesBundle/Resources/views/SalesChannel/Datagrid/Property/channels.html.twig
+++ /dev/null
@@ -1,7 +0,0 @@
-{% set channels = record.getValue('channels')|split(';') %}
-{% for index, channelSet in channels %}
- {% set values = channelSet|split('|') %}
- {% if values|length > 0 %}
- {{ values[0] }}
- {% endif %}
-{% endfor %}
\ No newline at end of file
diff --git a/src/Marello/Bundle/SalesBundle/Tests/Unit/Twig/SalesExtensionTest.php b/src/Marello/Bundle/SalesBundle/Tests/Unit/Twig/SalesExtensionTest.php
index 88ce57f1f..eda508a65 100644
--- a/src/Marello/Bundle/SalesBundle/Tests/Unit/Twig/SalesExtensionTest.php
+++ b/src/Marello/Bundle/SalesBundle/Tests/Unit/Twig/SalesExtensionTest.php
@@ -35,6 +35,10 @@ public function testGetFunctions()
new TwigFunction(
'marello_sales_has_active_channels',
[$this->extension, 'checkActiveChannels']
+ ),
+ new TwigFunction(
+ 'marello_get_sales_channel_name_by_code',
+ [$this->extension, 'getChannelNameByCode']
)
],
$this->extension->getFunctions()
@@ -81,4 +85,41 @@ public function checkActiveChannelsDataProvider()
],
];
}
+
+ /**
+ * @param $expectedChannel
+ * @param $code
+ * @param $expectedResult
+ * @dataProvider getChannelNameByCodeDataProvider
+ */
+ public function testGetChannelNameByCode($expectedChannel, $code, $expectedResult)
+ {
+ $this->salesChannelRepository
+ ->expects(static::once())
+ ->method('findOneBy')
+ ->willReturn($expectedChannel);
+
+ static::assertEquals($expectedResult, $this->extension->getChannelNameByCode($code));
+ }
+
+ /**
+ * @return array[]
+ */
+ public function getChannelNameByCodeDataProvider()
+ {
+ $channel = new SalesChannel('channel1');
+ $channel->setCode('test');
+ return [
+ 'with active channels' => [
+ 'expectedChannel' => $channel,
+ 'code' => 'test',
+ 'expectedResult' => 'channel1',
+ ],
+ 'without active channels' => [
+ 'expectedChannel' => null,
+ 'code' => 'MySalesChannelCode',
+ 'expectedResult' => 'MySalesChannelCode'
+ ],
+ ];
+ }
}
diff --git a/src/Marello/Bundle/SalesBundle/Twig/SalesExtension.php b/src/Marello/Bundle/SalesBundle/Twig/SalesExtension.php
index dc1926c1b..df7d8e28a 100644
--- a/src/Marello/Bundle/SalesBundle/Twig/SalesExtension.php
+++ b/src/Marello/Bundle/SalesBundle/Twig/SalesExtension.php
@@ -32,6 +32,10 @@ public function getFunctions()
new TwigFunction(
'marello_sales_has_active_channels',
[$this, 'checkActiveChannels']
+ ),
+ new TwigFunction(
+ 'marello_get_sales_channel_name_by_code',
+ [$this, 'getChannelNameByCode']
)
];
}
@@ -48,6 +52,21 @@ public function checkActiveChannels()
return false;
}
+ /**
+ * @param string $code
+ * @return string
+ */
+ public function getChannelNameByCode($code)
+ {
+ $channel = $this->salesChannelRepository
+ ->findOneBy(['code' => $code]);
+ if ($channel) {
+ return $channel->getName();
+ }
+
+ return $code;
+ }
+
/**
* Returns the name of the extension.
*
diff --git a/src/Marello/Bundle/TaxBundle/EventListener/Datagrid/TaxCodeDatagridListener.php b/src/Marello/Bundle/TaxBundle/EventListener/Datagrid/TaxCodeDatagridListener.php
index d1976f7cd..0a529b546 100644
--- a/src/Marello/Bundle/TaxBundle/EventListener/Datagrid/TaxCodeDatagridListener.php
+++ b/src/Marello/Bundle/TaxBundle/EventListener/Datagrid/TaxCodeDatagridListener.php
@@ -96,7 +96,7 @@ protected function addSelect(DatagridConfiguration $config)
{
$config->getOrmQuery()->addSelect(
sprintf('%s.code AS %s', $this->getJoinAlias(), $this->getDataName())
- );
+ )->addGroupBy(sprintf('%s.code', $this->getJoinAlias()));
}
/**
|