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

Rework invoice template on pdf and admin show page #234

Merged
merged 19 commits into from
Aug 2, 2021

Conversation

Tomanhez
Copy link
Contributor

@Tomanhez Tomanhez commented Jul 14, 2021

PDF:
Before:
Screenshot 2021-07-14 at 15 12 57
After:
image

Show Page:
Before:
Screenshot 2021-07-14 at 15 12 48
After:
Zrzut ekranu 2021-07-29 o 12 36 44

@Tomanhez Tomanhez requested a review from a team as a code owner July 14, 2021 13:17
Copy link
Member

@GSadee GSadee left a comment

Choose a reason for hiding this comment

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

The invoice doesn't have the same columns as you have described in the task, I would be for changing them to be exactly the same.

What is more, there are missing tests for cases like:

  • items with a promotion applied
  • shipments with taxes
  • shipments with a promotion applied
  • shipments with taxes and a promotion applied

I also wonder if a view of invoice show should be the same as PDF file, it wasn't in the scope of task, so I'm not convinced to changing that in this PR 🤔 /cc @CoderMaggie

@Tomanhez Tomanhez force-pushed the rework-invoice-template branch 2 times, most recently from 3d5841d to c7f12b2 Compare July 21, 2021 07:18
@Tomanhez Tomanhez force-pushed the rework-invoice-template branch 16 times, most recently from 45ef97b to 6539dc5 Compare July 22, 2021 09:07
@Tomanhez Tomanhez force-pushed the rework-invoice-template branch 6 times, most recently from 23205ec to 65cb889 Compare July 22, 2021 11:36
@GSadee GSadee force-pushed the rework-invoice-template branch 3 times, most recently from 3c14b49 to 1c2fdb8 Compare July 29, 2021 11:42
@GSadee GSadee force-pushed the rework-invoice-template branch from 1c2fdb8 to 00d7b2c Compare July 29, 2021 11:53
@GSadee GSadee force-pushed the rework-invoice-template branch from 00d7b2c to 7a19695 Compare July 29, 2021 12:13
@GSadee GSadee dismissed their stale review July 29, 2021 12:15

I've already fixed that

@GSadee GSadee force-pushed the rework-invoice-template branch from 7a19695 to 2a8ceb0 Compare July 29, 2021 12:28
@GSadee GSadee force-pushed the rework-invoice-template branch from 2a8ceb0 to ee8ea4e Compare July 29, 2021 12:36
Copy link
Member

@CoderMaggie CoderMaggie left a comment

Choose a reason for hiding this comment

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

The "Name" column should be aligned to left, not right :)

@GSadee
Copy link
Member

GSadee commented Jul 30, 2021

The "Name" column should be aligned to left, not right :)

Done 👌🏻

src/Resources/views/Invoice/Download/pdf.html.twig Outdated Show resolved Hide resolved
Comment on lines +320 to +323
/**
* @Then it should have :quantity :name item with unit price :unitPrice, net value :netValue, tax total :taxTotal and total :total in :currencyCode currency
* @Then it should have :quantity :name items with unit price :unitPrice, net value :netValue, tax total :taxTotal and total :total in :currencyCode currency
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't here this funny structure with ?:s ( I don't remember it exactly :D ) work?

Copy link
Member

Choose a reason for hiding this comment

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

You are right, I would use the structure with optional s, but then I would have to change the whole definition to a regexp, which in my opinion is less readable with so many arguments

Copy link
Contributor

Choose a reason for hiding this comment

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

👌 I will stay with Team readable then 😄

tests/Behat/Page/Admin/Invoice/ShowPage.php Outdated Show resolved Hide resolved
@GSadee GSadee force-pushed the rework-invoice-template branch from 739088d to 10d34a0 Compare July 30, 2021 10:32
spec/Converter/OrderItemUnitsToLineItemsConverterSpec.php Outdated Show resolved Hide resolved
spec/Provider/TaxRatePercentageProviderSpec.php Outdated Show resolved Hide resolved
src/Generator/InvoiceGenerator.php Outdated Show resolved Hide resolved
}

if ($taxAdjustments->isEmpty()) {
return null;
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason why we throw an exception in one undesired situation (more tax adjustments than one), but return a null in another (no tax adjustments at all)?

Copy link
Member

Choose a reason for hiding this comment

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

no tax adjustment seems like totally ok situation. I'm considering if two tax adjustments are such an edge case, but I'm fine with this decision

Copy link
Member

Choose a reason for hiding this comment

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

No tax adjustment is the normal case, but more than 2 tax adjustments is the case not supported by default by Sylius, so this is the reason why this exception is thrown here. What is more, there is a similar behaviour in RefundPlugin.

Copy link
Member

Choose a reason for hiding this comment

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

Doubled taxation is not a particularly not supported feature of the main Sylius. We already support both included and excluded taxes on order items. Therefore it may happen. Nonetheless, I'm still fine with it for the first iteration. Especially, as RefundPlugin works in similar fashion

src/Resources/views/Invoice/show.html.twig Outdated Show resolved Hide resolved
src/Twig/PercentFromLabelExtension.php Outdated Show resolved Hide resolved
@@ -0,0 +1,30 @@
@managing_invoices
Feature: Seeing an invoice with items and shipment having promotion applied
In order to have items with proper amounts
Copy link
Member

Choose a reason for hiding this comment

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

I don't want to be picky 😄 But I feel we should work over these features descriptions a little bit 🚀 Having proper amounts is not a goal in the essence, it's more a way to... what? Not having legal problems? 🤯 I can leave with it, but I know we can do better 😄

Copy link
Member

Choose a reason for hiding this comment

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

Yup, you're 😄 For me, the intention of Administrator to have proper amounts on the invoice is enough, but feel free to refactor these features 😃

@GSadee GSadee force-pushed the rework-invoice-template branch from e0b0893 to ced4305 Compare August 2, 2021 10:30
$this->shouldImplement(LineItemsConverterInterface::class);
}

function it_extracts_line_items_from_orders_shipping_adjusments(
Copy link
Member

Choose a reason for hiding this comment

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

We could cover a few more cases here, like lack of tax adjustment or having two of them.

@Zales0123 Zales0123 merged commit 2ef31f2 into Sylius:master Aug 2, 2021
@Zales0123
Copy link
Member

Zales0123 commented Aug 2, 2021

Thank you, Tomasz and Grzegorz! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). UX/UI Issues and PRs aimed at improving User eXperience and User Interface.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants