Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
haitv282 committed May 23, 2019
2 parents d3cd9ff + 097a2e9 commit c406450
Show file tree
Hide file tree
Showing 10 changed files with 234 additions and 5 deletions.
17 changes: 16 additions & 1 deletion Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,39 @@ class Data extends AbstractData
{
const CONFIG_MODULE_PATH = 'mpsameordernumber';

/**
* @param null $storeId
* @return array
*/
public function getApplyForOption($storeId = null)
{
return explode(",", $this->getConfigGeneral('apply', $storeId));
}

/**
* @param null $storeId
* @return bool
*/
public function isApplyInvoice($storeId = null)
{
return in_array(Apply::INVOICE, $this->getApplyForOption($storeId));
}

/**
* @param null $storeId
* @return bool
*/
public function isApplyShipment($storeId = null)
{
return in_array(Apply::SHIPMENT, $this->getApplyForOption($storeId));
}

/**
* @param null $storeId
* @return bool
*/
public function isApplyCreditMemo($storeId = null)
{
return in_array(Apply::CREDIT_MEMO, $this->getApplyForOption($storeId));
}

}
4 changes: 4 additions & 0 deletions Model/System/Config/Source/Apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

use Magento\Framework\Option\ArrayInterface;

/**
* Class Apply
* @package Mageplaza\SameOrderNumber\Model\System\Config\Source
*/
class Apply implements ArrayInterface
{
const SHIPMENT = "shipment";
Expand Down
4 changes: 4 additions & 0 deletions Observer/InvoiceSaveBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
use Magento\Framework\Registry;
use Mageplaza\SameOrderNumber\Helper\Data as HelperData;

/**
* Class InvoiceSaveBefore
* @package Mageplaza\SameOrderNumber\Observer
*/
class InvoiceSaveBefore implements ObserverInterface
{
/**
Expand Down
132 changes: 131 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,131 @@
- User guide: https://docs.mageplaza.com/same-order-number/index.html
# Magento 2 Same Order Number Free Extensio

[Magento 2 Same Order Number Extension](https://www.mageplaza.com/magento-2-same-order-number/) by **Mageplaza** allows store owners to easily create the ID of Invoice, Shipment and Credit Memo the same as the ID of the original Order. This will significantly contribute to a well-managed order information system.

[![Latest Stable Version](https://poser.pugx.org/mageplaza/module-same-order-number/v/stable)](https://packagist.org/packages/mageplaza/module-same-order-number)
[![Total Downloads](https://poser.pugx.org/mageplaza/module-same-order-number/downloads)](https://packagist.org/packages/mageplaza/module-same-order-number)


## 1. Documentation
- [Installation guide](https://www.mageplaza.com/install-magento-2-extension/)
- [User guide](https://docs.mageplaza.com/same-order-number/index.html)
- [Introduction page](http://www.mageplaza.com/magento-2-same-order-number/)
- [Contribute on Github](https://github.com/mageplaza/magento-2-same-order-number)
- [Get Support](https://github.com/mageplaza/magento-2-same-order-number/issues)

## 2. FAQs

## 3. How to install Magento 2 Same Order Number Extension

- Install via composer (recommend)

Run the following command in Magento 2 root folder:

```
composer require mageplaza/module-same-order-number
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
```

## 4. Highlight Features

### Automatically same order ID update for billing documents

**Magento 2 Same Order Number by Mageplaza** helps create the ID number for billing documents, associated with the ID of the original order after customers purchase. Documents that are possible to be set with the same order number are Invoice, Shipment and Credit Memo.

![Magento 2 Same Order Number](https://i.imgur.com/5B3YhmK.png)

### Automatically add the extra suffix

In case there are more than one Shipments, Invoices or Credit Memos for a single Order, the system will automatically create an extra suffix for the next shipments, start from the second one. For instance, Order ID is #100, the ID of Invoice will accordingly be #100, and from the next one, the ID of the second Invoice will be #100-1, the third will be #100-2, and so on.

![Magento 2 Same Order Number extension](https://i.imgur.com/UaKwdCd.png)

### Billing documents united pack

The Invoice, Shipment and Credit Memo with the same increment IDs can be well displayed on the frontend. The united pack of billing documents allows both admin and customer to follow and track the order information easily and conveniently.

![Magento 2 Same Order Number module](https://i.imgur.com/1FOyZG1.png)

## 5. Full Magento 2 Same Order Number Features

### For store owners

- Enable/disable the module
- Select billing documents (Shipment/Invoice/Credit Memo) to set ID according to the Order ID
- Create an extra suffix for multiple billing documents of a single Order
- Be compatible with any payment methods that create automated invoices
- Work well with [Mageplaza PDF Invoice](https://www.mageplaza.com/magento-2-pdf-invoice-extension/)

### For customers

- Easy to follow and manage the relationships among billing documents
- View the record from the frontend, from the customer's login account.

## 6. Same Order Number User Guide

Login to your Magento Admin Panel, navigate to `Store > Settings > Configuration > Mageplaza Extensions > Same Order Number`.

![same order number4](https://i.imgur.com/J3ypdvW.png)

### 6.1. Same Order Number General Configuration

![Magento 2 Same Order Number General Configuration](https://i.imgur.com/Aj5GAKj.png)

- **Enable**: Select `Yes` to activate the extension
- **Apply for**: Choose the billing documents to apply the extension. It is possible to apply to Invoice, Shipment and Credit Memo at the same time.
- Apply to **Shipment**: ID increment of **Shipment** will be configured the same as ID of the Order. In case there are more than one Shipments for a single Order, the system will automatically create a following suffix for the next shipments, start from the second one. For instance, Order ID is #003, the ID of Shipment will accordingly be #003, and from the next one, the ID of Shipment will be in a format as follow: #003-1

![Magento 2 Same Order Number Configuration](https://i.imgur.com/Zrn0m0L.png)

- If you do not enable **Same Order Number** for Shipment ID, the ID of Shipment will be set as default.

- Apply to **Invoice**: The ID of the Invoice will be set according to the Order ID.

- **Same Order Number** is also possible to create Invoice ID automatically when purchasing via Paypal.

- In case there are more than one Invoices for a single Order, ID of every next invoice will be added with an extra suffix. For example, when the ID of Order is Order #003, the Invoice ID will be #003 and the second Invoice will be #003-1.

![Mageplaza Same Order Number](https://i.imgur.com/nrlWXgJ.png)

- If you do not enable **Same Order Number** for Invoice ID, the ID of Invoice will be set as default.

- Apply for **Credit Memo**: ID of Credit Memo will be set according to the Order ID. For Order that have more than one Credit Memos, ID of every next Credit Memo will be automatically added with a suffix. For example, ID of the Order is #003, ID of the Credit Memo will be #003, and the second Credit Memo ID will be #003-1.

![Mageplaza Same Order Number for Magento 2](https://i.imgur.com/6NCxY5U.png)

- If you do not enable **Same Order Number** for Credit Memo ID, the ID of Credit Memo will be set as default.

### 6.2. Configuration for multi-stores

- Stores will be set as Default Config.
- To configure the extension for each store, go to `Store View > Store`. Next, uncheck the box `Use Website` of each option.
- The configuration of each store will only be available right on that store, other stores are still unchanged.

### 6.3. Frontend

#### 6.3.1. Invoice after being applied Same Order Number Extension:

![Invoice after being applied Same Order Number Extension](https://i.imgur.com/cvnU6NW.png)

#### 6.3.2. Shipment after being applied Same Order Number Extension:

![Shipment after being applied Same Order Number Extension](https://i.imgur.com/m08y5B8.png)

#### 6.3.3. Credit Memo after being applied Same Order Number Extension:

![Credit Memo after being applied Same Order Number Extension](https://i.imgur.com/UWNA6OS.png)



**Other free extension on Github**
- [Magento 2 seo all in one solution](https://github.com/mageplaza/magento-2-seo)
- [Magento 2 ReCaptcha](https://github.com/mageplaza/magento-2-google-recaptcha)
- [Magento 2 Delete Orders](https://github.com/mageplaza/magento-2-delete-orders)
- [MAGENTO 2 ADVANCED REPORTS](https://github.com/mageplaza/magento-2-reports)
- [Magento 2 Blog](https://github.com/mageplaza/magento-2-blog)
- [Magento 2 Same Order Number](https://github.com/mageplaza/magento-2-same-order-number)
- [Magento 2 Ajax Layered Navigation](https://github.com/mageplaza/magento-2-ajax-layered-navigation)
- [Magento 2 security module](https://github.com/mageplaza/magento-2-security)


Binary file added UserGuide.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mageplaza/module-core": "^1.4.0"
},
"type": "magento2-module",
"version": "1.0.0",
"version": "1.0.1",
"license": "proprietary",
"authors": [
{
Expand Down
3 changes: 3 additions & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<mpsameordernumber>
<module>
<type>1</type>
</module>
<general>
<enabled>1</enabled>
</general>
Expand Down
2 changes: 1 addition & 1 deletion etc/events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_invoice_save_before">
<observer name="affiliateObserver" instance="Mageplaza\SameOrderNumber\Observer\InvoiceSaveBefore" />
<observer name="affiliateObserver" instance="Mageplaza\SameOrderNumber\Observer\InvoiceSaveBefore"/>
</event>
</config>
10 changes: 9 additions & 1 deletion i18n/en_US.csv
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
General,General
Shipment,Shipment
Invoice,Invoice
"Credit Memo","Credit Memo"
"Same Order Number","Same Order Number"
"General Configuration","General Configuration"
Enable,Enable
"Select <b>Yes</b> to enable this module.","Select <b>Yes</b> to enable this module."
"Apply for","Apply for"
"If increment id exist, a sufix number will be added. Ex: 100001-1, 100001-2","If increment id exist, a sufix number will be added. Ex: 100001-1, 100001-2"
65 changes: 65 additions & 0 deletions travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
language: php
php:
- 7.0
- 7.1
- 7.2
sudo: required
dist: trusty
env:
global:
- COMPOSER_BIN_DIR=~/bin
- INTEGRATION_SETS=3
- NODE_JS_VERSION=6
- MAGENTO_HOST_NAME="magento2.travis"
- COMPOSER_MODULE=mageplaza/module-same-order-number
matrix:
- MAGENTO_VERSION=2.2.1 TEST_SUITE=integration INTEGRATION_INDEX=1
- MAGENTO_VERSION=2.2.1 TEST_SUITE=integration INTEGRATION_INDEX=2
- MAGENTO_VERSION=2.2.1 TEST_SUITE=integration INTEGRATION_INDEX=3
- MAGENTO_VERSION=2.2.2 TEST_SUITE=static
- MAGENTO_VERSION=2.2.2 TEST_SUITE=js GRUNT_COMMAND=static
- MAGENTO_VERSION=2.2.2 TEST_SUITE=integration INTEGRATION_INDEX=1
- MAGENTO_VERSION=2.2.2 TEST_SUITE=integration INTEGRATION_INDEX=2
- MAGENTO_VERSION=2.2.2 TEST_SUITE=integration INTEGRATION_INDEX=3

matrix:
exclude:
- php: 7.0
env: MAGENTO_VERSION=2.2.2 TEST_SUITE=js GRUNT_COMMAND=static
- php: 7.0
env: MAGENTO_VERSION=2.2.2 TEST_SUITE=static
cache:
apt: true
directories:
- "$HOME/.composer/cache"
- "$HOME/.nvm"
addons:
apt:
packages:
- mysql-server-5.6
- mysql-client-core-5.6
- mysql-client-5.6
- postfix
firefox: '46.0'
hosts:
- magento2.travis
before_install:
- git clone https://github.com/magento/magento2 --branch $MAGENTO_VERSION
- cd magento2
- bash ./dev/travis/before_install.sh
install:
- composer install --no-interaction --prefer-dist
- composer require $COMPOSER_MODULE
before_script:
#- cp -f ${TRAVIS_BUILD_DIR}/dev/tests/integration/phpunit.xml.dist dev/tests/integration/
- echo "vendor/$COMPOSER_MODULE" > dev/tests/static/testsuite/Magento/Test/Less/_files/whitelist/common.txt
- echo "vendor/$COMPOSER_MODULE" > dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt
- echo "vendor/$COMPOSER_MODULE/**/*.js" > dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/magento.txt
- bash ./dev/travis/before_script.sh
script:
- test $TEST_SUITE = "static" && TEST_FILTER='--filter "Magento\\Test\\Php\\LiveCodeTest"' || true
- test $TEST_SUITE = "functional" && TEST_FILTER='dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests.php' || true
- if [ $TEST_SUITE == "functional" ]; then dev/tests/functional/vendor/phpunit/phpunit/phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi
- if [ $TEST_SUITE != "functional" ] && [ $TEST_SUITE != "js" ]; then phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi
- if [ $TEST_SUITE == "js" ]; then grunt $GRUNT_COMMAND; fi

0 comments on commit c406450

Please sign in to comment.