Skip to content
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

[RefundPayment] Change order number to Order relation on RefundPayment #307

Merged
merged 8 commits into from
Jun 10, 2021

Conversation

GSadee
Copy link
Member

@GSadee GSadee commented Jun 9, 2021

Partially fixes #193

Similar to #306

@GSadee GSadee added Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). DX Issues and PRs aimed at improving Developer eXperience. labels Jun 9, 2021
@GSadee GSadee requested a review from a team as a code owner June 9, 2021 07:37
@GSadee GSadee force-pushed the relate-refund-payment-with-order branch from 46cec9a to 3a8afc2 Compare June 9, 2021 09:08
$this->entityManager = $entityManager;
$this->eventBus = $eventBus;
}

public function next(UnitsRefunded $unitsRefunded): void
{
/** @var OrderInterface|null $order */
$order = $this->orderRepository->findOneByNumber($unitsRefunded->orderNumber());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if I should find the order here or in RefundPaymentFactory 🤔 Especially that we are already finding the payment method by its id in the factory. Wdyt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, we should pass to the factory as final data as possible, to allow it to create the desired object and do nothing more 🚀

@GSadee GSadee force-pushed the relate-refund-payment-with-order branch from 3a8afc2 to 66ffcd1 Compare June 9, 2021 09:19
src/Resources/config/admin_routing.yml Outdated Show resolved Hide resolved
src/Resources/config/services/providers.xml Outdated Show resolved Hide resolved
@GSadee GSadee force-pushed the relate-refund-payment-with-order branch from 66ffcd1 to 781db9d Compare June 9, 2021 10:18
@GSadee GSadee force-pushed the relate-refund-payment-with-order branch from 781db9d to 4b25791 Compare June 9, 2021 10:53
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
use Sylius\RefundPlugin\Repository\RefundPaymentRepositoryInterface;

class RefundPaymentRepository extends EntityRepository implements RefundPaymentRepositoryInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we (similar to factories) provide trait that should be implemented in the repository? But I suppose it's not a case for this change but for all the repositories and plugin 💃

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, but this is the plugin, that defines RefundPayment, so creating a repository without traits makes sense here.

public function findByOrderNumber(string $orderNumber): array
{
return $this->createQueryBuilder('o')
->innerJoin('o.order', 'ord')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ord 😱 Is it because order is a banned name? 😄 maybe then refundPaymentOrder?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that is the reason 😃 And to be honest, it is a copy-pasted shortcut from Sylius, but I agree that refundPaymentOrder looks better 😃

@Zales0123 Zales0123 merged commit 69d43d2 into Sylius:master Jun 10, 2021
@Zales0123
Copy link
Member

Thanks, Grzegorz! 🎉

@GSadee GSadee deleted the relate-refund-payment-with-order branch June 10, 2021 07:24
GSadee added a commit to Sylius/InvoicingPlugin that referenced this pull request Jun 14, 2021
This PR was merged into the 1.0-dev branch.

Discussion
----------

Similar to Sylius/RefundPlugin#306 and Sylius/RefundPlugin#307.

Should be easier to operate on the Invoice with a proper relation rather than just an order number

Commits
-------

081b080 Add Order relation on Invoice (and remove order number field)
e480edc Use order instead of order number in invoice repository
0ab7fed Final fixes
ce949d3 Mention changes in the UPGRADE file
8411c18 Remove unneeded point in UPGRADE file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Issues and PRs aimed at improving Developer eXperience. Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] It's not possible to distinguish between refund requests; Incorrect DB design?
4 participants