-
Notifications
You must be signed in to change notification settings - Fork 71
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
[CreditMemo] Rework credit memo #179
Conversation
GSadee
commented
Jan 23, 2020
•
edited
Loading
edited
features/seeing_details_of_credit_memo_with_promotion_applied.feature
Outdated
Show resolved
Hide resolved
features/seeing_details_of_credit_memo_with_promotion_applied.feature
Outdated
Show resolved
Hide resolved
features/seeing_details_of_credit_memo_with_promotion_applied.feature
Outdated
Show resolved
Hide resolved
f92af2c
to
3eccda5
Compare
05d57f7
to
45c0c62
Compare
45c0c62
to
e6c7706
Compare
b9a6f57
to
981220d
Compare
src/Converter/LineItemsConverter.php
Outdated
|
||
$label = $taxAdjustments->first()->getLabel(); | ||
|
||
if (preg_match('#\((.*?)\)#', $label, $matches)) { |
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.
o.O What has happened here?
I don't have an idea what we try to achieve here.
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.
This is the simplest way to get tax rate from tax adjustment, as it is set in tax rate label, I was wondering if it is ok for now 😃
CreditMemoUnitGeneratorInterface $orderItemUnitCreditMemoUnitGenerator, | ||
CreditMemoUnitGeneratorInterface $shipmentCreditMemoUnitGenerator, | ||
LineItemsConverterInterface $lineItemsConverter, | ||
LineItemsConverterInterface $shipmentLineItemsConverter, |
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.
As the order of these services is important, I would recommend creating two interfaces instead of one. Otherwise, errors may be really misleading (when units
would be passed to shipmentLineItemsConvertera
and shipments
to lineItemsConverter
)
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.
I'm not convinced to that, the input and output are the same and having the same interface is logical to me
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.
Maybe the best would be the queue with priorities accepting only array of specific units 💃 But I would leave it as it is right now
<td>{{ loop.index }}</td> | ||
<td>{{ item.name }}</td> | ||
<td>{{ item.quantity }}</td> | ||
<td>{{ (item.unitNetPrice/100)|number_format(2) }}</td> |
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.
Why didn't you used sylius_format_money
?
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.
Because I want to have prices without currency 😢
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.
So the other question - why we want here prices without currency? 😄
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.
Because credit memo should look like this 😃 /cc @CoderMaggie
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.
Confirmed by PO 👩⚖
$this->addSql('CREATE TABLE sylius_refund_line_item (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, quantity INT NOT NULL, unit_net_price INT NOT NULL, unit_gross_price INT NOT NULL, net_value INT NOT NULL, gross_value INT NOT NULL, tax_amount INT NOT NULL, tax_rate VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('ALTER TABLE sylius_refund_credit_memo_line_items ADD CONSTRAINT FK_1453B90E8E574316 FOREIGN KEY (credit_memo_id) REFERENCES sylius_refund_credit_memo (id)'); | ||
$this->addSql('ALTER TABLE sylius_refund_credit_memo_line_items ADD CONSTRAINT FK_1453B90EA7CBD339 FOREIGN KEY (line_item_id) REFERENCES sylius_refund_line_item (id)'); | ||
$this->addSql('ALTER TABLE sylius_refund_credit_memo DROP units'); |
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.
Could we migrate those units to line items?
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.
IMO no, because I do not have enough information and also the old credit memos shouldn't be changed
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.
They'll be changed after we drop this column though
598c940
to
ee91d19
Compare
src/Converter/LineItemsConverter.php
Outdated
|
||
$grossValue = $unitRefund->total(); | ||
$taxAmount = (int) ($grossValue * $orderItemUnit->getTaxTotal() / $orderItemUnit->getTotal()); | ||
$netValue = $grossValue - $taxAmount; |
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.
I feel that there is a lot of things we could extract there - even if they're done only there, it still does not seem nice 😢 Maybe we could have some VO like CreditMemoValues
which would calculate these variables? Or some LineItemFactory
? It's not a must-have, for now, for me, but would definitely improve a DX 🖖
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.
For now, I've extracted creating line item to the separate private method, but I agree that in future some refactor could improve a DX
CreditMemoUnitGeneratorInterface $orderItemUnitCreditMemoUnitGenerator, | ||
CreditMemoUnitGeneratorInterface $shipmentCreditMemoUnitGenerator, | ||
LineItemsConverterInterface $lineItemsConverter, | ||
LineItemsConverterInterface $shipmentLineItemsConverter, |
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.
Maybe the best would be the queue with priorities accepting only array of specific units 💃 But I would leave it as it is right now
f9869ef
to
b7a1869
Compare
b7a1869
to
f62c77d
Compare
|
||
$label = $taxAdjustments->first()->getLabel(); | ||
|
||
if (preg_match('/\((.*?)\)/', $label, $matches)) { |
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.
We should definitely think how to handle it better (either here on on Sylius/Sylius
) but let's just open an issue for that :)
Thanks, Grzegorz! 🎉 |