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

[CreditMemo] Rework credit memo #179

Merged
merged 6 commits into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
### UPGRADE FROM 1.0.0-RC.1 TO 1.0.0-RC.2

1. `CreditMemoUnit` changed to `LineItem` which is a resource entity now
GSadee marked this conversation as resolved.
Show resolved Hide resolved

2. `CreditMemoUnitGeneratorInterface` changed to `LineItemsConverterInterface` and moved from `Generator` to `Converter` directory
GSadee marked this conversation as resolved.
Show resolved Hide resolved

3. `OrderItemUnitCreditMemoUnitGenerator` changed to `LineItemsConverter` and moved from `Generator` to `Converter` directory

4. `ShipmentCreditMemoUnitGenerator` changed to `ShipmentLineItemsConverter` and moved from `Generator` to `Converter` directory

There are no migrations that provide backward compatibility, save current credit memos before upgrading the version of plugin.

### UPGRADE FROM 0.10.1 TO 1.0.0-RC.1

1. `OfflineRefundPaymentMethodsProvider` renamed to `SupportedRefundPaymentMethodsProvider` with the supported gateways array as the 2nd argument
(by default only `offline` gateway is passed and therefore supported).
(by default only `offline` gateway is passed and therefore supported).

### UPGRADE FROM 0.8.0 TO 0.9.0

Expand Down
51 changes: 4 additions & 47 deletions features/having_credit_memo_generated.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,19 @@ Feature: Having credit memo generated
Background:
Given the store operates on a single green channel in "United States"
And channel "United States" billing data is "Haas & Milan", "Pacific Coast Hwy", "90003" "Los Angeles", "United States" with "1100110011" tax ID
And default tax zone is "US"
And the store has "US VAT" tax rate of 10% for "Clothes" within the "US" zone
And the store has a product "Mr. Meeseeks T-Shirt" priced at "$10.00"
And it belongs to "Clothes" tax category
And the store has a product "PHP T-Shirt" priced at "$10.00"
And the store has "Galaxy Post" shipping method with "$10.00" fee
And the store allows paying with "Space money"
And there is a promotion "Anatomy Park Promotion"
And this promotion gives "$1.00" off on every product with minimum price at "$5.00"
And there is a customer "[email protected]" that placed an order "#00000022"
And the customer bought 2 "Mr. Meeseeks T-Shirt" products
And the customer bought 2 "PHP T-Shirt" products
GSadee marked this conversation as resolved.
Show resolved Hide resolved
And the customer "Rick Sanchez" addressed it to "Seaside Fwy", "90802" "Los Angeles" in the "United States" with identical billing address
And the customer chose "Galaxy Post" shipping method with "Space money" payment
And there is a customer "[email protected]" that placed an order "#00000023"
And the customer bought 2 "Mr. Meeseeks T-Shirt" products
And the customer "Morty Smith" addressed it to "Main St.", "90100" "Los Angeles" in the "United States" with identical billing address
And the customer chose "Galaxy Post" shipping method with "Space money" payment
And the order "#00000023" is already paid
And I am logged in as an administrator
And the order "#00000022" is already paid
And I am logged in as an administrator

@ui @application
Scenario: Having credit memo generated after refund process
When I want to refund some units of order "#00000022"
And I decide to refund 1st "Mr. Meeseeks T-Shirt" product with "Space money" payment
And I decide to refund 1st "PHP T-Shirt" product with "Space money" payment
Then I should be notified that selected order units have been successfully refunded
And I should have 1 credit memo generated for order "#00000022"

@ui @application
Scenario: Seeing the details of generated credit memo
Given all units from the order "#00000022" are refunded with "Space money" payment
And I browse the details of the only credit memo generated for order "#00000022"
And it should have sequential number generated from current date
Then this credit memo should contain 2 "Mr. Meeseeks T-Shirt" products with "$0.90" tax applied
And it should be issued in "United States" channel
And it should be issued from "Rick Sanchez", "Seaside Fwy", "90802" "Los Angeles" in the "United States"
And it should be issued to "Haas & Milan", "Pacific Coast Hwy", "90003" "Los Angeles" in the "United States" with "1100110011" tax ID
And its subtotal should be "$18.00"
And it should have a tax item "US VAT (10%)" with amount "$1.80"
And its total should be "$19.80"

@ui @application
Scenario: Seeing the details of generated credit memo with partial price
Given 1st "Mr. Meeseeks T-Shirt" product from order "#00000022" has already "$5.50" refunded with "Space money" payment
When I browse the details of the only credit memo generated for order "#00000022"
And it should have sequential number generated from current date
Then this credit memo should contain 1 "Mr. Meeseeks T-Shirt" product with "$0.50" tax applied
And it should be issued in "United States" channel
And its subtotal should be "$5.00"
And it should have a tax item "US VAT (10%)" with amount "$0.50"
And its total should be "$5.50"

@ui @application
Scenario: Seeing the details of generated credit memo with partial shipment price
Given shipment from order "#00000023" has already "$4.50" refunded with "Space money" payment
When I browse the details of the only credit memo generated for order "#00000023"
And it should have sequential number generated from current date
Then this credit memo should contain 1 "Galaxy Post" shipment with "$4.50" total
And it should be issued in "United States" channel
And its total should be "$4.50"
2 changes: 1 addition & 1 deletion features/having_order_partially_refunded.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Feature: Having order partially refunded

@ui
Scenario: Having order partially refunded when its shipping is refunded
When shipment from order "#00000022" has already "$1.00" refunded with "Space money" payment
Given the "#00000022" order's shipping cost already has a refund of "$1.00" with "Space money" payment
Then this order's payment state should be "Partially refunded"
4 changes: 2 additions & 2 deletions features/providing_comment_for_credit_memo.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Feature: Providing comment for credit memo
When I want to refund some units of order "#00000022"
And I decide to refund 1st "Mr. Meeseeks T-Shirt" product with "Space money" payment and "Money for nothing" comment
And I browse the details of the only credit memo generated for order "#00000022"
Then this credit memo should contain 1 "Mr. Meeseeks T-Shirt" product with "$0.00" tax applied
And its total should be "$10.00"
Then it should contain 1 "Mr. Meeseeks T-Shirt" product with "10.00" net value, "0.00" tax amount and "10.00" gross value in "USD" currency
And its total should be "10.00" in "USD" currency
And it should be commented with "Money for nothing"

@ui
Expand Down
6 changes: 3 additions & 3 deletions features/refunding_part_of_order_unit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ Feature: Refunding a part of an order unit

@ui @application
Scenario: Refunding the whole order unit price after partial refund
Given 1st "Mr. Meeseeks T-Shirt" product from order "#00000022" has already "$5.00" refunded with "Space money" payment
Given the 1st "Mr. Meeseeks T-Shirt" product from order "#00000022" already has a refund of "$5.00" with "Space money" payment
GSadee marked this conversation as resolved.
Show resolved Hide resolved
When I want to refund some units of order "#00000022"
And I decide to refund 1st "Mr. Meeseeks T-Shirt" product with "Space money" payment
Then I should be notified that selected order units have been successfully refunded
And this order refunded total should be "$12.30"

@ui @javascript
Scenario: Refunding the whole order price after partial refund
Given 1st "Mr. Meeseeks T-Shirt" product from order "#00000022" has already "$5.00" refunded with "Space money" payment
Given the 1st "Mr. Meeseeks T-Shirt" product from order "#00000022" already has a refund of "$5.00" with "Space money" payment
When I want to refund some units of order "#00000022"
And I decide to refund all units of this order with "Space money" payment
Then I should be notified that selected order units have been successfully refunded
And this order refunded total should be "$44.60"

@ui @application
Scenario: Not being able to refund more money than order unit total
Given 1st "Mr. Meeseeks T-Shirt" product from order "#00000022" has already "$5.00" refunded with "Space money" payment
Given the 1st "Mr. Meeseeks T-Shirt" product from order "#00000022" already has a refund of "$5.00" with "Space money" payment
When I want to refund some units of order "#00000022"
And I decide to refund "$10.00" from 1st "Mr. Meeseeks T-Shirt" product with "Space money" payment
Then I should be notified that I cannot refund more money than the order unit total
Expand Down
4 changes: 2 additions & 2 deletions features/refunding_part_of_shipment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ Feature: Refunding a part of an shipment

@ui @application
Scenario: Refunding the whole order unit price after partial refund
Given shipment from order "#00000022" has already "$5.00" refunded with "Space money" payment
Given the "#00000022" order's shipping cost already has a refund of "$5.00" with "Space money" payment
When I want to refund some units of order "#00000022"
And I decide to refund order shipment with "Space money" payment
Then this order refunded total should be "$20.00"

@ui @application
Scenario: Not being able to refund more money than shipment total
Given shipment from order "#00000022" has already "$5.00" refunded with "Space money" payment
Given the "#00000022" order's shipping cost already has a refund of "$5.00" with "Space money" payment
When I want to refund some units of order "#00000022"
And I try to refund "$18.00" from order shipment with "Space money" payment
Then I should be notified that I cannot refund more money than the shipment total
Expand Down
57 changes: 57 additions & 0 deletions features/viewing_details_of_credit_memo.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@refunds
Feature: Viewing details of a credit memo
In order to be aware of what order units have been refunded
As an Administrator
I want to be able to view details of a credit memo

Background:
Given the store operates on a single green channel in "United States"
And channel "United States" billing data is "Haas & Milan", "Pacific Coast Hwy", "90003" "Los Angeles", "United States" with "1100110011" tax ID
And default tax zone is "US"
And the store has "US VAT" tax rate of 10% for "Clothes" within the "US" zone
And the store has included in price "VAT" tax rate of 20% for "Mugs" within the "US" zone
And the store has "Galaxy Post" shipping method with "$10.00" fee
And the store allows paying with "Space money"
And the store has a product "PHP T-Shirt" priced at "$10.00"
And it belongs to "Clothes" tax category
And the store has a product "Symfony Mug" priced at "$21.00"
And it belongs to "Mugs" tax category
And there is a customer "[email protected]" that placed an order "#00000022"
And the customer bought a "PHP T-Shirt" and a "Symfony Mug"
And the customer "Rick Sanchez" addressed it to "Seaside Fwy", "90802" "Los Angeles" in the "United States" with identical billing address
And the customer chose "Galaxy Post" shipping method with "Space money" payment
And the order "#00000022" is already paid
And I am logged in as an administrator

@ui @application
Scenario: Viewing details of a credit memo issued for a full refund
Given all units from the order "#00000022" are refunded with "Space money" payment
When I browse the details of the only credit memo generated for order "#00000022"
Then it should have sequential number generated from current date
And it should be issued in "United States" channel
And it should be issued to "Haas & Milan", "Pacific Coast Hwy", "90003" "Los Angeles" in the "United States" with "1100110011" tax ID
And it should be issued from "Rick Sanchez", "Seaside Fwy", "90802" "Los Angeles" in the "United States"
And it should contain 1 "PHP T-Shirt" product with "10.00" net value, "1.00" tax amount and "11.00" gross value in "USD" currency
And it should contain 1 "Symfony Mug" product with "17.50" net value, "3.50" tax amount and "21.00" gross value in "USD" currency
And it should contain a tax item "10%" with amount "1.00" in "USD" currency
And it should contain a tax item "20%" with amount "3.50" in "USD" currency
And its total should be "32.00" in "USD" currency

@ui @application
Scenario: Viewing details of a credit memo issued for a partial refund
Given the 1st "PHP T-Shirt" product from order "#00000022" already has a refund of "$5.50" with "Space money" payment
When I browse the details of the only credit memo generated for order "#00000022"
Then it should have sequential number generated from current date
And it should be issued in "United States" channel
And it should contain 1 "PHP T-Shirt" product with "5.00" net value, "0.50" tax amount and "5.50" gross value in "USD" currency
And it should contain a tax item "10%" with amount "0.50" in "USD" currency
And its total should be "5.50" in "USD" currency

@ui @application
Scenario: Viewing details of a credit memo issued for a partial shipping cost refund
Given the "#00000022" order's shipping cost already has a refund of "$4.50" with "Space money" payment
When I browse the details of the only credit memo generated for order "#00000022"
Then it should have sequential number generated from current date
And it should contain 1 "Galaxy Post" shipment with "4.50" gross value in "USD" currency
And it should be issued in "United States" channel
And its total should be "4.50" in "USD" currency
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@refunds
Feature: Viewing details of a credit memo for order with a promotion applied
In order to be aware of what order units have been refunded
As an Administrator
I want to be able to view details of a credit memo

Background:
Given the store operates on a single green channel in "United States"
And channel "United States" billing data is "Haas & Milan", "Pacific Coast Hwy", "90003" "Los Angeles", "United States" with "1100110011" tax ID
And default tax zone is "US"
And the store has "US VAT" tax rate of 10% for "Clothes" within the "US" zone
And the store has a product "PHP T-Shirt" priced at "$10.00"
And it belongs to "Clothes" tax category
And the store has "Galaxy Post" shipping method with "$10.00" fee
And the store allows paying with "Space money"
And there is a promotion "Anatomy Park Promotion"
And this promotion gives "$3.99" discount to every order with quantity at least 4
And there is a customer "[email protected]" that placed an order "#00000022"
And the customer bought 4 "PHP T-Shirt" products
And the customer "Rick Sanchez" addressed it to "Seaside Fwy", "90802" "Los Angeles" in the "United States" with identical billing address
And the customer chose "Galaxy Post" shipping method with "Space money" payment
And the order "#00000022" is already paid
And I am logged in as an administrator

@ui @application
Scenario: Viewing details of a credit memo issued for an order with a promotion applied
Given all units from the order "#00000022" are refunded with "Space money" payment
When I browse the details of the only credit memo generated for order "#00000022"
Then it should have sequential number generated from current date
And it should be issued in "United States" channel
And it should be issued to "Haas & Milan", "Pacific Coast Hwy", "90003" "Los Angeles" in the "United States" with "1100110011" tax ID
And it should be issued from "Rick Sanchez", "Seaside Fwy", "90802" "Los Angeles" in the "United States"
And it should contain 3 "PHP T-Shirt" products with "27.00" net value, "2.70" tax amount and "29.70" gross value in "USD" currency
And it should contain 1 "PHP T-Shirt" product with "9.01" net value, "0.90" tax amount and "9.91" gross value in "USD" currency
And it should contain a tax item "10%" with amount "3.60" in "USD" currency
And its total should be "39.61" in "USD" currency
32 changes: 32 additions & 0 deletions migrations/Version20200125182414.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20200125182414 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('CREATE TABLE sylius_refund_credit_memo_line_items (credit_memo_id VARCHAR(255) NOT NULL, line_item_id INT NOT NULL, INDEX IDX_1453B90E8E574316 (credit_memo_id), UNIQUE INDEX UNIQ_1453B90EA7CBD339 (line_item_id), PRIMARY KEY(credit_memo_id, line_item_id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
$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');
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

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

}

public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE sylius_refund_credit_memo_line_items DROP FOREIGN KEY FK_1453B90EA7CBD339');
$this->addSql('DROP TABLE sylius_refund_credit_memo_line_items');
$this->addSql('DROP TABLE sylius_refund_line_item');
$this->addSql('ALTER TABLE sylius_refund_credit_memo ADD units LONGTEXT CHARACTER SET utf8 NOT NULL COLLATE `utf8_unicode_ci` COMMENT \'(DC2Type:json)\'');
}
}
Loading