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

Unit net price and discounted unit net price on the invoice #287

Merged
merged 11 commits into from
Aug 18, 2022

Conversation

Rafikooo
Copy link
Contributor

@Rafikooo Rafikooo commented Aug 16, 2022

Fixes #273

@Rafikooo Rafikooo added the Feature New feature proposals. label Aug 16, 2022
@Rafikooo Rafikooo requested a review from a team as a code owner August 16, 2022 08:31
@Zales0123 Zales0123 force-pushed the original-unit-net-price branch from ead0105 to e9a42e4 Compare August 17, 2022 14:52
@Zales0123 Zales0123 force-pushed the original-unit-net-price branch from 80c3296 to f5e6dc7 Compare August 17, 2022 21:11
@Zales0123 Zales0123 changed the title [WIP] Original unit net price Unit net price and discounted unit net price on the invoice Aug 18, 2022
Comment on lines +64 to +65
$unitNetPrice = $grossValue - $taxAmount - $shipment->getAdjustmentsTotal(AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT);
$discountedUnitNetPrice = $grossValue - $taxAmount;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$unitNetPrice = $grossValue - $taxAmount - $shipment->getAdjustmentsTotal(AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT);
$discountedUnitNetPrice = $grossValue - $taxAmount;
$discountedUnitNetPrice = $grossValue - $taxAmount;
$unitNetPrice = $discountedUnitNetPrice - $shipment->getAdjustmentsTotal(AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT);


public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE sylius_invoicing_plugin_line_item ADD discounted_unit_net_price INT DEFAULT NULL');
Copy link
Member

Choose a reason for hiding this comment

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

@@ -59,13 +61,15 @@ private function convertShippingAdjustmentToLineItem(AdjustmentInterface $shippi
$grossValue = $shipment->getAdjustmentsTotal();
$taxAdjustment = $this->getShipmentTaxAdjustment($shipment);
$taxAmount = $taxAdjustment !== null ? $taxAdjustment->getAmount() : 0;
$netValue = $grossValue - $taxAmount;
$unitNetPrice = $grossValue - $taxAmount - $shipment->getAdjustmentsTotal(AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT);
Copy link
Member

Choose a reason for hiding this comment

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

I have the feeling, that it is small de-cohesion, that in the units to line items converter we have dedicated service for net price calculation and here we don't

Copy link
Member

Choose a reason for hiding this comment

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

Indeed 👍 we could probably refactor (could be done in a separate PR IMO) 🖖

@lchrusciel lchrusciel merged commit 2d89764 into Sylius:master Aug 18, 2022
AdamKasp added a commit that referenced this pull request Sep 12, 2022
…er last changes (GSadee)

This PR was merged into the main branch.

Discussion
----------

After #287

Commits
-------

bc67635 [Behat][Invoice] Fix usage of method checking line items after last changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature proposals.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

catalog unit price
4 participants