-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Ensure that invoice comments are returned when requested by GraphQL queries #31606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
magento-devops-reposync-svc
merged 8 commits into
magento:2.4-develop
from
aligent-lturner:feature/graphql_invoice_comments
Nov 24, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bdd8861
Ensure that invoice comments are returned when requested by GraphQL q…
aligent-lturner cf7b505
Merge branch '2.4-develop' into feature/graphql_invoice_comments
cpartica f2cb745
Merge branch '2.4-develop' into feature/graphql_invoice_comments
ishakhsuvarov 5e74597
Merge branch '2.4-develop' into feature/graphql_invoice_comments
ishakhsuvarov 12ecbb3
31606:Fixed static test failure
engcom-Echo 7f4668e
31606:Fixed static test failure
engcom-Echo 1e434db
31606:Added strict type declartion
engcom-Echo a5d5b8d
Merge branch '2.4-develop' into feature/graphql_invoice_comments
engcom-Echo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Sales\Test\Fixture; | ||
|
||
use Magento\Framework\DataObject; | ||
use Magento\Sales\Api\Data\CommentInterface; | ||
use Magento\Sales\Api\Data\EntityInterface; | ||
use Magento\Sales\Api\Data\InvoiceCommentInterface; | ||
use Magento\Sales\Api\InvoiceCommentRepositoryInterface; | ||
use Magento\TestFramework\Fixture\Api\ServiceFactory; | ||
use Magento\TestFramework\Fixture\RevertibleDataFixtureInterface; | ||
|
||
class InvoiceComment implements RevertibleDataFixtureInterface | ||
{ | ||
private const DEFAULT_DATA = [ | ||
InvoiceCommentInterface::IS_CUSTOMER_NOTIFIED => 0, | ||
InvoiceCommentInterface::PARENT_ID => 0, | ||
CommentInterface::COMMENT => 'Test Comment', | ||
CommentInterface::IS_VISIBLE_ON_FRONT => 0, | ||
EntityInterface::ENTITY_ID => 0, | ||
EntityInterface::CREATED_AT => "0000-00-00 00:00:00", | ||
]; | ||
|
||
/** | ||
* @var ServiceFactory | ||
*/ | ||
private $serviceFactory; | ||
|
||
/** | ||
* @var InvoiceCommentRepositoryInterface | ||
*/ | ||
private $invoiceCommentRepository; | ||
|
||
/** | ||
* @param ServiceFactory $serviceFactory | ||
* @param InvoiceCommentRepositoryInterface $invoiceCommentRepository | ||
*/ | ||
public function __construct( | ||
ServiceFactory $serviceFactory, | ||
InvoiceCommentRepositoryInterface $invoiceCommentRepository | ||
) { | ||
$this->serviceFactory = $serviceFactory; | ||
$this->invoiceCommentRepository = $invoiceCommentRepository; | ||
} | ||
|
||
public function apply(array $data = []): ?DataObject | ||
{ | ||
$service = $this->serviceFactory->create(InvoiceCommentRepositoryInterface::class, 'save'); | ||
$invoiceComment = $service->execute($this->prepareData($data)); | ||
|
||
return $this->invoiceCommentRepository->get($invoiceComment->getId()); | ||
} | ||
|
||
public function revert(DataObject $data): void | ||
{ | ||
$invoice = $this->invoiceCommentRepository->get($data->getId()); | ||
$this->invoiceCommentRepository->delete($invoice); | ||
} | ||
|
||
/** | ||
* Prepare invoice data | ||
* | ||
* @param array $data | ||
* @return array | ||
*/ | ||
private function prepareData(array $data): array | ||
{ | ||
$data['entity'] = array_merge(self::DEFAULT_DATA, $data); | ||
|
||
return $data; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually invoices should not expose comments
They are not in luma and we should deprecate comments in invoice graphql and don't do this fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpartica are you sure they're not present in Luma?
magento2/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml
Line 32 in 5f05166
magento2/app/code/Magento/Sales/view/frontend/templates/order/invoice/items.phtml
Line 51 in 5f05166
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also:
magento2/app/code/Magento/Sales/Block/Order/Invoice/Items.php
Lines 98 to 107 in 5f05166
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpartica I have confirmed that invoice comments are indeed visible in Luma - please see screenshot below taken from a fresh 2.4-develop instance.

Comments missing from the GraphQL response is clearly a bug, and I'm not sure why it's taking so long for this very simple PR to be merged - it's been over 4 months now since it was approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cpartica, indeed the invoice comments are shown on Luma. Probably you missed the following checkbox, which makes the comment visible on the storefront.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @cpartica! Looks like @aligent-lturner is right and invoice comments are available to view on the storefront (magento has a visibility modifier for the comments).