From 63f5e481b1b580ab73bcf6fd1d98fa0ba7595542 Mon Sep 17 00:00:00 2001 From: Hotlander Date: Tue, 25 Aug 2020 10:22:35 +0200 Subject: [PATCH] Squashed 'package/marello/' changes from e2134fdd6..0bc0152d4 0bc0152d4 - added additional check on order view to make sure a customer exists on the order before trying to render properties of the customer 633f25913 MM-42: Test and fix functionality (#66) 6d656f838 MM-42: Test and fix functionality (#65) a62f4b7f9 MM-40: Test and fix import order functionality (#63) 49b65509c MM-38: Implement sync processors (#61) 1d6be06cb MM-35: Fix issue 'Removed special product price won't sync on Magento side' (#58) d0d640da1 - added non proxy class of the Marello Product Unit as without this it can cause issues when the 'normal' class is used to send templates instead of the Proxy class of the product unit ad177b07e - Added default value for $data property as in most cases it will expect an array even if the data is not set on an Entity 4ce14c756 - updated email templates with name variable for ProductUnit - updated migration version for the application to load the new templates 0a23414cc - added ProductUnit variable provider for rendering the product unit in the email templates as this is an enum field which is behaving as an extended entity with a proxy class that wasn't allowed in the email templates f23050815 - Added the shipping origin based on WFA rules back for shipping methods that use the origin to determine shipping costs, the addres of the warehouse remains an estimation 1f44fe29e - updated field to check for available inventory, it used the balanced inventory instead of the inventory qty which is the qty that is left from the balanced inventory 224ba3458 - removed check that was going through the WFA rules that wasn't necessary for either Payment methods and Shipping methods on the Order creation a287a3ae9 - fixed renaming email templates for Order and Invoice notifications 361a7651a - Updated email templates with new style 88337f551 - updated WorkflowstartListener test to check new behaviour of the OrderWorkflowStart 87716bd00 - Fixed issue with WorkflowStartListener where only the last order id (which came in batches) was getting a workflow start 1f318b4a0 - Removed statuses that are NULL from the OrderItemStatus dashboard widget as they cannot be displayed correctly 04a60f850 - added Order status to Order which will serve as preparation for the next step in the Order Management - currently no critical parts are relying on the new Order status as of yet, it's also not visibile in the current implementation 3d518511d - renamed table alias as the datagrid was confused which one was the actual table and which one was the column of the ProductUnit in the InventoryItem grid 8b9df7516 - split the SalesBundle migrations as v1_3 was already released... 36e9e92ab Merge branch 'task/ZON20001-0-update-m2-bundle' into maintenance/3.0 044200010 Merge branch 'feature/magento2-integr' into task/ZON20001-0-update-m2-bundle 9ac3f0641 MM-29: Add functionality to map relation between website and sales_channel on the integration form (#54) git-subtree-dir: package/marello git-subtree-split: 0bc0152d406e055bb48cb0b0f9703209cffe90ca --- .../EventListener/RefreshContextListener.php | 51 ++++ .../CoreBundle/Resources/config/services.yml | 7 +- .../Provider/AvailableInventoryProvider.php | 2 +- .../Resources/config/oro/datagrids.yml | 4 +- .../Data/ORM/UpdateEmailTemplates.php | 48 +++ .../marello_send_invoice.html.twig | 176 +++++------ .../Bundle/OrderBundle/Entity/Order.php | 73 ++++- .../Bundle/OrderBundle/Entity/OrderItem.php | 4 + .../Doctrine/OrderWorkflowStartListener.php | 37 +-- .../Doctrine/PendingOrderStatusListener.php | 46 +++ .../Factory/OrderPaymentContextFactory.php | 84 +++--- .../Factory/OrderShippingContextFactory.php | 91 +++--- .../Data/ORM/LoadOrderStatusData.php | 48 +++ .../ORM/UpdateEmailTemplatesProductUnit.php | 2 +- .../Migrations/Data/ORM/data/.DS_Store | Bin 0 -> 6148 bytes ...ello_order_accepted_confirmation.html.twig | 215 +++++++------ .../emails/marello_order_cancelled.html.twig | 248 ++++++++------- .../emails/marello_order_credited.html.twig | 250 ++++++++-------- .../emails/marello_order_invoiced.html.twig | 282 ++++++++---------- .../data/emails/marello_order_paid.html.twig | 272 ++++++++--------- .../marello_order_payment_reminder.html.twig | 205 +++++++------ ...rello_order_shipped_confirmation.html.twig | 201 ++++++++----- .../marello_order_shipping_prepared.html.twig | 215 ++++++++----- ...rder_shipping_prepared_warehouse.html.twig | 195 ++++++------ .../Schema/MarelloOrderBundleInstaller.php | 27 +- .../Schema/v1_13/MarelloOrderBundle.php | 63 ++++ .../Schema/v1_13_1/MarelloOrderBundle.php | 33 ++ .../Model/OrderStatusesInterface.php | 20 ++ ...derDashboardOrderItemsByStatusProvider.php | 1 + .../Resources/config/oro/actions.yml | 11 + .../Resources/config/oro/workflows.yml | 80 +++++ .../OrderBundle/Resources/config/services.yml | 7 + .../Resources/config/validation.yml | 8 +- .../Resources/translations/jsmessages.en.yml | 2 +- .../Resources/translations/messages.en.yml | 2 + .../Resources/views/Order/view.html.twig | 14 +- .../OrderWorkflowStartListenerTest.php | 131 ++++---- ...ashboardOrderItemsByStatusProviderTest.php | 2 + .../AvailableInventoryValidatorTest.php | 72 ----- .../Validator/AvailableInventoryValidator.php | 30 +- .../CompositePaymentMethodProvider.php | 19 +- .../Method/RemotePaymentMethod.php | 67 +++++ .../Resources/config/services.yml | 2 + .../CompositePaymentMethodProviderTest.php | 13 +- .../ChannelPricingSubscriber.php | 17 +- .../Form/EventListener/PricingSubscriber.php | 24 +- .../EmailTwigSandboxConfigurationPass.php | 40 +++ .../Bundle/ProductBundle/Entity/Product.php | 2 +- .../Entity/Repository/ProductRepository.php | 2 +- .../ProductBundle/MarelloProductBundle.php | 14 +- .../Resources/config/services.yml | 13 + .../Unit/Twig/ProductUnitExtensionTest.php | 160 ++++++++++ .../Twig/ProductUnitExtension.php | 106 +++++++ .../Provider/ProductUnitVariablesProvider.php | 43 +++ .../Entity/PurchaseOrder.php | 2 +- .../Entity/PurchaseOrderItem.php | 2 +- .../UpdateEmailTemplatesHtmlEscapeTags.php | 2 +- .../marello_purchase_order_advice.html.twig | 85 +++--- .../marello_purchase_order_supplier.html.twig | 101 ++++--- .../Data/ORM/UpdateEmailTemplates.php | 48 +++ .../emails/marello_refund_credited.html.twig | 64 ++-- .../ORM/UpdateEmailTemplatesProductUnit.php | 2 +- .../emails/marello_return_created.html.twig | 123 ++++---- ...marello_return_inspection_not_ok.html.twig | 89 +++--- .../marello_return_not_verified.html.twig | 90 +++--- .../emails/marello_return_received.html.twig | 90 +++--- .../emails/marello_return_reminder.html.twig | 89 +++--- ..._return_shipping_label_warehouse.html.twig | 89 +++--- .../Acl/Voter/SalesChannelGroupVoter.php | 2 +- .../Autocomplete/GroupSalesChannelHandler.php | 32 +- .../SalesChannelGroupRepository.php | 17 ++ .../Repository/SalesChannelRepository.php | 28 ++ .../SalesBundle/Entity/SalesChannelGroup.php | 2 - .../Form/Type/SalesChannelType.php | 1 - .../Schema/MarelloSalesBundleInstaller.php | 2 +- .../Schema/v1_3_1/MarelloSalesBundle.php | 47 +++ .../SalesBundle/Resources/config/form.yml | 2 +- .../SalesBundle/Resources/config/services.yml | 2 +- .../Bundle/TaxBundle/Entity/TaxCode.php | 2 +- .../TaxBundle/Entity/TaxJurisdiction.php | 2 +- .../Bundle/TaxBundle/Entity/TaxRate.php | 2 +- .../Bundle/TaxBundle/Entity/TaxRule.php | 2 +- 82 files changed, 2913 insertions(+), 1887 deletions(-) create mode 100644 src/Marello/Bundle/CoreBundle/EventListener/RefreshContextListener.php create mode 100644 src/Marello/Bundle/InvoiceBundle/Migrations/Data/ORM/UpdateEmailTemplates.php create mode 100644 src/Marello/Bundle/OrderBundle/EventListener/Doctrine/PendingOrderStatusListener.php create mode 100644 src/Marello/Bundle/OrderBundle/Migrations/Data/ORM/LoadOrderStatusData.php create mode 100644 src/Marello/Bundle/OrderBundle/Migrations/Data/ORM/data/.DS_Store create mode 100644 src/Marello/Bundle/OrderBundle/Migrations/Schema/v1_13/MarelloOrderBundle.php create mode 100644 src/Marello/Bundle/OrderBundle/Migrations/Schema/v1_13_1/MarelloOrderBundle.php create mode 100644 src/Marello/Bundle/OrderBundle/Model/OrderStatusesInterface.php create mode 100644 src/Marello/Bundle/PaymentBundle/Method/RemotePaymentMethod.php create mode 100644 src/Marello/Bundle/ProductBundle/DependencyInjection/Compiler/EmailTwigSandboxConfigurationPass.php create mode 100644 src/Marello/Bundle/ProductBundle/Tests/Unit/Twig/ProductUnitExtensionTest.php create mode 100644 src/Marello/Bundle/ProductBundle/Twig/ProductUnitExtension.php create mode 100644 src/Marello/Bundle/ProductBundle/Twig/Provider/ProductUnitVariablesProvider.php create mode 100644 src/Marello/Bundle/RefundBundle/Migrations/Data/ORM/UpdateEmailTemplates.php create mode 100644 src/Marello/Bundle/SalesBundle/Migrations/Schema/v1_3_1/MarelloSalesBundle.php diff --git a/src/Marello/Bundle/CoreBundle/EventListener/RefreshContextListener.php b/src/Marello/Bundle/CoreBundle/EventListener/RefreshContextListener.php new file mode 100644 index 000000000..d4bbd679e --- /dev/null +++ b/src/Marello/Bundle/CoreBundle/EventListener/RefreshContextListener.php @@ -0,0 +1,51 @@ +getOrganization(); + if (!is_object($organization)) { + return; + } + $organizationClass = ClassUtils::getClass($organization); + if ($event->getEntityClass() && $event->getEntityClass() !== $organizationClass) { + return; + } + /** + * Start customization + */ + $em = $event->getEntityManager(); + $classEm = $this->doctrine->getManagerForClass($organizationClass); + if ($classEm instanceof VirtualProxyInterface) { + $classEm = $classEm->getWrappedValueHolderValue(); + } + if ($em !== $classEm) { + return; + } + /** + * End customization + */ + $organization = $this->refreshEntity($organization, $organizationClass, $em); + if (!$organization) { + return; + } + $token->setOrganization($organization); + } +} diff --git a/src/Marello/Bundle/CoreBundle/Resources/config/services.yml b/src/Marello/Bundle/CoreBundle/Resources/config/services.yml index dd4569f4e..7db82f13e 100644 --- a/src/Marello/Bundle/CoreBundle/Resources/config/services.yml +++ b/src/Marello/Bundle/CoreBundle/Resources/config/services.yml @@ -75,4 +75,9 @@ services: arguments: - '@oro_entity.doctrine_helper' tags: - - { name: twig.extension } \ No newline at end of file + - { name: twig.extension } + + marello_core.event_listener.refresh_context: + class: Marello\Bundle\CoreBundle\EventListener\RefreshContextListener + decorates: oro_security.listener.refresh_context_listener + parent: oro_security.listener.refresh_context_listener diff --git a/src/Marello/Bundle/InventoryBundle/Provider/AvailableInventoryProvider.php b/src/Marello/Bundle/InventoryBundle/Provider/AvailableInventoryProvider.php index a324d8999..d28a564be 100644 --- a/src/Marello/Bundle/InventoryBundle/Provider/AvailableInventoryProvider.php +++ b/src/Marello/Bundle/InventoryBundle/Provider/AvailableInventoryProvider.php @@ -49,7 +49,7 @@ private function getAvailableBalancedInventory(Product $product, SalesChannel $s $salesChannelGroup = $salesChannel->getGroup(); $result = $this->getBalancedInventoryLevel($product, $salesChannelGroup); - return ($result) ? $result->getBalancedInventoryQty() : 0; + return ($result) ? $result->getInventoryQty() : 0; } /** diff --git a/src/Marello/Bundle/InventoryBundle/Resources/config/oro/datagrids.yml b/src/Marello/Bundle/InventoryBundle/Resources/config/oro/datagrids.yml index 507aee6bd..9fba1a0c6 100644 --- a/src/Marello/Bundle/InventoryBundle/Resources/config/oro/datagrids.yml +++ b/src/Marello/Bundle/InventoryBundle/Resources/config/oro/datagrids.yml @@ -8,7 +8,7 @@ datagrids: - p.denormalizedDefaultName as productName - p.sku as productSku - i.enableBatchInventory as enableBatchInventory - - productUnit.name as productUnit + - pu.name as productUnit - COALESCE(SUM(il.inventory), 0) AS inventoryQty - COALESCE(SUM(il.allocatedInventory), 0) AS allocatedInventoryQty - COALESCE(SUM(il.inventory - il.allocatedInventory), 0) AS virtualInventoryQty @@ -18,7 +18,7 @@ datagrids: left: - { join: i.product, alias: p } - { join: i.inventoryLevels, alias: il } - - { join: i.productUnit, alias: productUnit } + - { join: i.productUnit, alias: pu } groupBy: i.id columns: productSku: diff --git a/src/Marello/Bundle/InvoiceBundle/Migrations/Data/ORM/UpdateEmailTemplates.php b/src/Marello/Bundle/InvoiceBundle/Migrations/Data/ORM/UpdateEmailTemplates.php new file mode 100644 index 000000000..c03c22222 --- /dev/null +++ b/src/Marello/Bundle/InvoiceBundle/Migrations/Data/ORM/UpdateEmailTemplates.php @@ -0,0 +1,48 @@ +getRepository('OroEmailBundle:EmailTemplate')->findOneBy([ + 'name' => $template['params']['name'], + 'entityName' => 'Marello\Bundle\InvoiceBundle\Entity\Invoice' + ]); + } + + /** + * Return path to email templates + * + * @return string + */ + public function getEmailsDir() + { + return $this->container + ->get('kernel') + ->locateResource('@MarelloInvoiceBundle/Migrations/Data/ORM/data/email_templates'); + } + + /** + * {@inheritdoc} + */ + public function getVersion() + { + return '1.2'; + } +} diff --git a/src/Marello/Bundle/InvoiceBundle/Migrations/Data/ORM/data/email_templates/marello_send_invoice.html.twig b/src/Marello/Bundle/InvoiceBundle/Migrations/Data/ORM/data/email_templates/marello_send_invoice.html.twig index ec46a18e1..45c509f4d 100644 --- a/src/Marello/Bundle/InvoiceBundle/Migrations/Data/ORM/data/email_templates/marello_send_invoice.html.twig +++ b/src/Marello/Bundle/InvoiceBundle/Migrations/Data/ORM/data/email_templates/marello_send_invoice.html.twig @@ -5,12 +5,12 @@ @isEditable = 1 - -