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

Wrong invoice prefix in multistore setup due to default store id #14063

Closed
shinesoftware opened this issue Mar 12, 2018 · 5 comments
Closed

Wrong invoice prefix in multistore setup due to default store id #14063

shinesoftware opened this issue Mar 12, 2018 · 5 comments
Labels
Event: dmcdindia Fixed in 2.3.x The issue has been fixed in 2.3 release line good first issue Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Progress: PR Created Indicates that Pull Request has been created to fix issue Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@shinesoftware
Copy link

shinesoftware commented Mar 12, 2018

Preconditions

Ubuntu, Standard LAMP (Apache, MySQL, ....)
Magento ver. 2.1.9 - Clean setup by command line
PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
mysql Ver 14.14 Distrib 5.7.17, for Linux (x86_64) using EditLine wrapper

Steps to reproduce

Magento Store Configuration

The magento store has been configured as multistore with multiviews.

  • Store A
    • Store View Italian (default) - id:1 - invoice prefix: S-
    • Store View English - id:3 - invoice prefix: SS-
  • Store B
    • Store View Italian (default) - id:2 - invoice prefix: Z-
    • Store View English - id:4 - invoice prefix: ZZ-

I have discovered that Magento 2 set the DefaultStoreId in the second getSequence() parameter but this is not good if you need to set a correct prefix for the invoices. Look at https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Sales/Model/ResourceModel/EntityAbstract.php#L129

If create an order from the administration panel for the Store B English Store View you'll get the Default Store Id equals to 2 but the correct value is 4.

Expected result

I would like to set the correct invoice prefix when I try to create a new invoice from a specific store view.

Actual result

Magento creates the invoice number using the default store view id

I suggest to change the storeid parameter:

protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
{
    /** @var \Magento\Sales\Model\AbstractModel $object */
    if ($object instanceof EntityInterface && $object->getIncrementId() == null) {
        $object->setIncrementId(
            $this->sequenceManager->getSequence(
                $object->getEntityType(),
                $object->getStore()->getId() // <<< This parameter will be get from the invoice object
            )->getNextValue()
        );
    }
    parent::_beforeSave($object);
    return $this;
}

thanks

@magento-engcom-team magento-engcom-team added Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed labels Mar 12, 2018
@magento-engcom-team
Copy link
Contributor

@shinesoftware, thank you for your report.
We've acknowledged the issue and added to our backlog.

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Mar 13, 2018
@sanjay-wagento sanjay-wagento self-assigned this May 19, 2018
@sanjay-wagento
Copy link
Contributor

I am working on this at #dmcdindia

magento-team pushed a commit that referenced this issue May 22, 2018
… default stor… #15332

 - Merge Pull Request #15332 from sanjay-wagento/magento2:feature-wrong-invoice-prefix
 - Merged commits:
   1. 75f62bc
magento-team pushed a commit that referenced this issue May 22, 2018
magento-team pushed a commit that referenced this issue May 22, 2018
Accepted Public Pull Requests:
 - #15372: Fixed Purchased Order Form button should visible properly (by @vgelani)
 - #15336: #12820 - Wrong annotation in _toOptionArray - magento/framework/Data/� (by @sanjay-wagento)
 - #15332: #14063 - Wrong invoice prefix in multistore setup due to default stor� (by @sanjay-wagento)
 - #15347: Fixed breadcrumb quote issue in product page #15037 (by @jignesh-baldha)
 - #15275: [fix] typo in method name _exportAddress[s]es (by @mhauri)
 - #15247: ISSUE-14747 Newsletter subscription confirmation message does not dis� (by @KaushikChavda)
 - #15089: Fix unnecessary recalculation of product list pricing (by @JeroenVanLeusden)


Fixed GitHub Issues:
 - #15334: Purchased Order Form button should visible properly (reported by @neeta-wagento) has been fixed in #15372 by @vgelani in 2.2-develop branch
   Related commits:
     1. 35b2cdf
     2. be8c6cb

 - #15037: Product Details Page breadcrumbs cause syntax error on products containing quotes (reported by @brian-labelle) has been fixed in #15347 by @jignesh-baldha in 2.2-develop branch
   Related commits:
     1. 6fcfb88
     2. bfb39b5
     3. 8e93b0d

 - #14747: Newsletter subscription confirmation message does not display after clicking link in email (reported by @tohann) has been fixed in #15247 by @KaushikChavda in 2.2-develop branch
   Related commits:
     1. 6eb96c6

 - #14941: Unnecessary recalculation of product list pricing causes huge slowdowns (reported by @paales) has been fixed in #15089 by @JeroenVanLeusden in 2.2-develop branch
   Related commits:
     1. c5536d3
@magento-engcom-team magento-engcom-team added the Progress: PR Created Indicates that Pull Request has been created to fix issue label May 26, 2018
gelanivishal pushed a commit to gelanivishal/magento2 that referenced this issue Jun 1, 2018
gelanivishal added a commit to gelanivishal/magento2 that referenced this issue Jun 1, 2018
[Forwardport] magento#14063 - Wrong invoice prefix in multistore setup due to default stor…
gelanivishal pushed a commit to gelanivishal/magento2 that referenced this issue Jun 1, 2018
gelanivishal added a commit to gelanivishal/magento2 that referenced this issue Jun 1, 2018
[Backport] magento#14063 - Wrong invoice prefix in multistore setup due to default stor…
@sidolov sidolov added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Jun 5, 2018
@sidolov
Copy link
Contributor

sidolov commented Jun 5, 2018

Hi @shinesoftware. Thank you for your report.
The issue has been fixed in #15665 by @vgelani in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

magento-engcom-team added a commit that referenced this issue Jun 20, 2018
…etup due to default stor… #15821

 - Merge Pull Request #15821 from sanjay-wagento/magento2:2.1-develop-PR-port-15332
 - Merged commits:
   1. 2fcaf53
magento-engcom-team pushed a commit that referenced this issue Jun 20, 2018
…etup due to default store id (fix order increment id)
magento-engcom-team pushed a commit that referenced this issue Jun 20, 2018
magento-engcom-team pushed a commit that referenced this issue Jun 20, 2018
Accepted Public Pull Requests:
 - #15287: [Backport] Handle empty or incorrect lines in a language CSV (by @VitaliyBoyko)
 - #15860: [Backport] ISSUE-14747 Newsletter subscription confirmation message does not dis� (by @rahul-kachhadiya)
 - #15236: [Backport] Add price calculation improvement for product option value price (by @VitaliyBoyko)
 - #15821: [Backport] #14063 - Wrong invoice prefix in multistore setup due to default stor� (by @sanjay-wagento)
 - #15289: [Backport] Naming collision in Javascript ui registry (backend) (by @VitaliyBoyko)
 - #15699: [Backport] Variant product image in sidebar wishlist block (by @dmytro-ch)
 - #15722: [Backport] Fix Magento_ImportExport not supporting unicode characters in column names (by @tdgroot)


Fixed GitHub Issues:
 - #14747: Newsletter subscription confirmation message does not display after clicking link in email (reported by @tohann) has been fixed in #15860 by @rahul-kachhadiya in 2.1-develop branch
   Related commits:
     1. 1839f97
@TomashKhamlai TomashKhamlai self-assigned this Nov 15, 2018
@magento-engcom-team
Copy link
Contributor

Hi @TomashKhamlai. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@magento-engcom-team magento-engcom-team added Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Nov 15, 2018
@TomashKhamlai
Copy link
Contributor

The issue was re-tested and we can confirm that it was fixed on the 2.3 release branch. We closing this issue as fixed due to upcoming 2.3 release that will be available soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Event: dmcdindia Fixed in 2.3.x The issue has been fixed in 2.3 release line good first issue Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Progress: PR Created Indicates that Pull Request has been created to fix issue Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

6 participants