Version Notes
prevent duplicates is now mandatory
Download this release
Release Info
Developer | Magento Core Team |
Extension | Fooman_SameOrderInvoiceNumber |
Version | 2.0.5 |
Comparing to | |
See all releases |
Code changes from version 2.0.1 to 2.0.5
- app/code/community/Fooman/SameOrderInvoiceNumber/Model/Observer.php +71 -71
- app/code/community/Fooman/SameOrderInvoiceNumber/Model/Observer.php~ +0 -117
- app/code/community/Fooman/SameOrderInvoiceNumber/etc/config.xml +1 -1
- app/code/community/Fooman/SameOrderInvoiceNumber/etc/system.xml +1 -11
- package.xml +5 -5
app/code/community/Fooman/SameOrderInvoiceNumber/Model/Observer.php
CHANGED
@@ -20,95 +20,95 @@
|
|
20 |
* @copyright Copyright (c) 2010 Fooman Limited (http://www.fooman.co.nz)
|
21 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
22 |
*/
|
23 |
-
|
24 |
class Fooman_SameOrderInvoiceNumber_Model_Observer
|
25 |
{
|
26 |
-
|
|
|
27 |
{
|
28 |
|
29 |
$invoice = $observer->getInvoice();
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
$
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
49 |
}
|
50 |
-
}
|
51 |
-
} else {
|
52 |
-
$invoice->setIncrementId($prefix.$order->getIncrementId());
|
53 |
}
|
54 |
}
|
55 |
|
56 |
-
public function sales_order_shipment_save_before($observer)
|
57 |
{
|
58 |
$shipment = $observer->getShipment();
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
71 |
-
$collection = Mage::getModel('sales/order_shipment')->getCollection()->addFieldToFilter('increment_id',$newShipmentNr);
|
72 |
-
if($collection->getAllIds()){
|
73 |
-
//number already exists
|
74 |
-
$newShipmentNr = 0;
|
75 |
-
$currentPostfix++;
|
76 |
-
} else {
|
77 |
-
$shipment->setIncrementId($newShipmentNr);
|
78 |
-
}
|
79 |
-
}
|
80 |
-
} else {
|
81 |
-
$shipment->setIncrementId($prefix.$order->getIncrementId());
|
82 |
}
|
83 |
}
|
84 |
|
85 |
-
public function sales_order_creditmemo_save_before($observer)
|
86 |
{
|
87 |
$creditmemo = $observer->getCreditmemo();
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
$
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
107 |
}
|
108 |
-
}
|
109 |
-
} else {
|
110 |
-
$creditmemo->setIncrementId($prefix.$order->getIncrementId());
|
111 |
}
|
112 |
}
|
113 |
|
114 |
-
}
|
20 |
* @copyright Copyright (c) 2010 Fooman Limited (http://www.fooman.co.nz)
|
21 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
22 |
*/
|
|
|
23 |
class Fooman_SameOrderInvoiceNumber_Model_Observer
|
24 |
{
|
25 |
+
|
26 |
+
public function sales_order_invoice_save_before ($observer)
|
27 |
{
|
28 |
|
29 |
$invoice = $observer->getInvoice();
|
30 |
+
if (!$invoice->getId()) {
|
31 |
+
$order = $invoice->getOrder();
|
32 |
+
$storeId = $order->getStore()->getStoreId();
|
33 |
+
$prefix = Mage::getStoreConfig('sameorderinvoicenumber/settings/invoiceprefix',
|
34 |
+
$storeId);
|
35 |
+
$newInvoiceNr = 0;
|
36 |
+
$currentPostfix = 0;
|
37 |
+
while (!$newInvoiceNr) {
|
38 |
+
if ($currentPostfix) {
|
39 |
+
$newInvoiceNr = $prefix . $order->getIncrementId() . '-' . $currentPostfix;
|
40 |
+
} else {
|
41 |
+
$newInvoiceNr = $prefix . $order->getIncrementId();
|
42 |
+
}
|
43 |
+
$collection = Mage::getModel('sales/order_invoice')->getCollection()->addFieldToFilter('increment_id',
|
44 |
+
$newInvoiceNr);
|
45 |
+
if ($collection->getAllIds()) {
|
46 |
+
//number already exists
|
47 |
+
$newInvoiceNr = 0;
|
48 |
+
$currentPostfix++;
|
49 |
+
} else {
|
50 |
+
$invoice->setIncrementId($newInvoiceNr);
|
51 |
+
}
|
52 |
}
|
|
|
|
|
|
|
53 |
}
|
54 |
}
|
55 |
|
56 |
+
public function sales_order_shipment_save_before ($observer)
|
57 |
{
|
58 |
$shipment = $observer->getShipment();
|
59 |
+
if (!$shipment->getId()) {
|
60 |
+
$order = $shipment->getOrder();
|
61 |
+
$storeId = $order->getStore()->getStoreId();
|
62 |
+
$prefix = Mage::getStoreConfig('sameorderinvoicenumber/settings/shipmentprefix',
|
63 |
+
$storeId);
|
64 |
+
$newShipmentNr = 0;
|
65 |
+
$currentPostfix = 0;
|
66 |
+
while (!$newShipmentNr) {
|
67 |
+
if ($currentPostfix) {
|
68 |
+
$newShipmentNr = $prefix . $order->getIncrementId() . '-' . $currentPostfix;
|
69 |
+
} else {
|
70 |
+
$newShipmentNr = $prefix . $order->getIncrementId();
|
71 |
+
}
|
72 |
+
$collection = Mage::getModel('sales/order_shipment')->getCollection()->addFieldToFilter('increment_id',
|
73 |
+
$newShipmentNr);
|
74 |
+
if ($collection->getAllIds()) {
|
75 |
+
//number already exists
|
76 |
+
$newShipmentNr = 0;
|
77 |
+
$currentPostfix++;
|
78 |
+
} else {
|
79 |
+
$shipment->setIncrementId($newShipmentNr);
|
80 |
+
}
|
81 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
}
|
84 |
|
85 |
+
public function sales_order_creditmemo_save_before ($observer)
|
86 |
{
|
87 |
$creditmemo = $observer->getCreditmemo();
|
88 |
+
if (!$creditmemo->getId()) {
|
89 |
+
$order = $creditmemo->getOrder();
|
90 |
+
$storeId = $order->getStore()->getStoreId();
|
91 |
+
$prefix = Mage::getStoreConfig('sameorderinvoicenumber/settings/creditmemoprefix',
|
92 |
+
$storeId);
|
93 |
+
$newCreditmemoNr = 0;
|
94 |
+
$currentPostfix = 0;
|
95 |
+
while (!$newCreditmemoNr) {
|
96 |
+
if ($currentPostfix) {
|
97 |
+
$newCreditmemoNr = $prefix . $order->getIncrementId() . '-' . $currentPostfix;
|
98 |
+
} else {
|
99 |
+
$newCreditmemoNr = $prefix . $order->getIncrementId();
|
100 |
+
}
|
101 |
+
$collection = Mage::getModel('sales/order_creditmemo')->getCollection()->addFieldToFilter('increment_id',
|
102 |
+
$newCreditmemoNr);
|
103 |
+
if ($collection->getAllIds()) {
|
104 |
+
//number already exists
|
105 |
+
$newCreditmemoNr = 0;
|
106 |
+
$currentPostfix++;
|
107 |
+
} else {
|
108 |
+
$creditmemo->setIncrementId($newCreditmemoNr);
|
109 |
+
}
|
110 |
}
|
|
|
|
|
|
|
111 |
}
|
112 |
}
|
113 |
|
114 |
+
}
|
app/code/community/Fooman/SameOrderInvoiceNumber/Model/Observer.php~
DELETED
@@ -1,117 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Fooman Order = Invoice Number
|
5 |
-
*
|
6 |
-
* Magento
|
7 |
-
*
|
8 |
-
* NOTICE OF LICENSE
|
9 |
-
*
|
10 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
11 |
-
* that is bundled with this package in the file LICENSE.txt.
|
12 |
-
* It is also available through the world-wide-web at this URL:
|
13 |
-
* http://opensource.org/licenses/osl-3.0.php
|
14 |
-
* If you did not receive a copy of the license and are unable to
|
15 |
-
* obtain it through the world-wide-web, please send an email
|
16 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
17 |
-
*
|
18 |
-
* @category Fooman
|
19 |
-
* @package SameOrderInvoiceNumber
|
20 |
-
* @copyright Copyright (c) 2010 Fooman Limited (http://www.fooman.co.nz)
|
21 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
22 |
-
*/
|
23 |
-
|
24 |
-
class Fooman_SameOrderInvoiceNumber_Model_Observer
|
25 |
-
{
|
26 |
-
public function sales_order_invoice_save_before($observer)
|
27 |
-
{
|
28 |
-
|
29 |
-
$invoice = $observer->getInvoice();
|
30 |
-
$order = $invoice->getOrder();
|
31 |
-
$storeId = $order->getStore()->getStoreId();
|
32 |
-
$prefix = Mage::getStoreConfig('sameorderinvoicenumber/settings/invoiceprefix',$storeId);
|
33 |
-
if (Mage::getStoreConfig('sameorderinvoicenumber/settings/preventduplicates',$storeId)) {
|
34 |
-
$newInvoiceNr = 0;
|
35 |
-
$currentPostfix = 0;
|
36 |
-
while (!$newInvoiceNr) {
|
37 |
-
if ($currentPostfix) {
|
38 |
-
$newInvoiceNr = $prefix.$order->getIncrementId().'-'.$currentPostfix;
|
39 |
-
} else {
|
40 |
-
$newInvoiceNr = $prefix.$order->getIncrementId();
|
41 |
-
}
|
42 |
-
Mage::log('$newInvoiceNr'.$newInvoiceNr);
|
43 |
-
$collection = Mage::getModel('sales/order_invoice')->getCollection()->addFieldToFilter('increment_id',$newInvoiceNr);
|
44 |
-
if($collection->getAllIds()){
|
45 |
-
Mage::log('exists');
|
46 |
-
Mage::log($collection->getAllIds());
|
47 |
-
//number already exists
|
48 |
-
$newInvoiceNr = 0;
|
49 |
-
$currentPostfix++;
|
50 |
-
} else {
|
51 |
-
$invoice->setIncrementId($newInvoiceNr);
|
52 |
-
}
|
53 |
-
}
|
54 |
-
} else {
|
55 |
-
$invoice->setIncrementId($prefix.$order->getIncrementId());
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
public function sales_order_shipment_save_before($observer)
|
60 |
-
{
|
61 |
-
$shipment = $observer->getShipment();
|
62 |
-
$order = $shipment->getOrder();
|
63 |
-
$storeId = $order->getStore()->getStoreId();
|
64 |
-
$prefix = Mage::getStoreConfig('sameorderinvoicenumber/settings/shipmentprefix',$storeId);
|
65 |
-
if (Mage::getStoreConfig('sameorderinvoicenumber/settings/preventduplicates',$storeId)) {
|
66 |
-
$newShipmentNr = 0;
|
67 |
-
$currentPostfix = 0;
|
68 |
-
while (!$newShipmentNr) {
|
69 |
-
if ($currentPostfix) {
|
70 |
-
$newShipmentNr = $prefix.$order->getIncrementId().'-'.$currentPostfix;
|
71 |
-
} else {
|
72 |
-
$newShipmentNr = $prefix.$order->getIncrementId();
|
73 |
-
}
|
74 |
-
$collection = Mage::getModel('sales/order_shipment')->getCollection()->addFieldToFilter('increment_id',$newShipmentNr);
|
75 |
-
if($collection->getAllIds()){
|
76 |
-
//number already exists
|
77 |
-
$newShipmentNr = 0;
|
78 |
-
$currentPostfix++;
|
79 |
-
} else {
|
80 |
-
$shipment->setIncrementId($newShipmentNr);
|
81 |
-
}
|
82 |
-
}
|
83 |
-
} else {
|
84 |
-
$shipment->setIncrementId($prefix.$order->getIncrementId());
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
public function sales_order_creditmemo_save_before($observer)
|
89 |
-
{
|
90 |
-
$creditmemo = $observer->getCreditmemo();
|
91 |
-
$order = $creditmemo->getOrder();
|
92 |
-
$storeId = $order->getStore()->getStoreId();
|
93 |
-
$prefix = Mage::getStoreConfig('sameorderinvoicenumber/settings/creditmemoprefix',$storeId);
|
94 |
-
if (Mage::getStoreConfig('sameorderinvoicenumber/settings/preventduplicates',$storeId)) {
|
95 |
-
$newCreditmemoNr = 0;
|
96 |
-
$currentPostfix = 0;
|
97 |
-
while (!$newCreditmemoNr) {
|
98 |
-
if ($currentPostfix) {
|
99 |
-
$newCreditmemoNr = $prefix.$order->getIncrementId().'-'.$currentPostfix;
|
100 |
-
} else {
|
101 |
-
$newCreditmemoNr = $prefix.$order->getIncrementId();
|
102 |
-
}
|
103 |
-
$collection = Mage::getModel('sales/order_creditmemo')->getCollection()->addFieldToFilter('increment_id',$newCreditmemoNr);
|
104 |
-
if($collection->getAllIds()){
|
105 |
-
//number already exists
|
106 |
-
$newCreditmemoNr = 0;
|
107 |
-
$currentPostfix++;
|
108 |
-
} else {
|
109 |
-
$creditmemo->setIncrementId($newCreditmemoNr);
|
110 |
-
}
|
111 |
-
}
|
112 |
-
} else {
|
113 |
-
$creditmemo->setIncrementId($prefix.$order->getIncrementId());
|
114 |
-
}
|
115 |
-
}
|
116 |
-
|
117 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Fooman/SameOrderInvoiceNumber/etc/config.xml
CHANGED
@@ -23,7 +23,7 @@
|
|
23 |
<config>
|
24 |
<modules>
|
25 |
<Fooman_SameOrderInvoiceNumber>
|
26 |
-
<version>2.0.
|
27 |
<depends>
|
28 |
<Mage_Sales />
|
29 |
</depends>
|
23 |
<config>
|
24 |
<modules>
|
25 |
<Fooman_SameOrderInvoiceNumber>
|
26 |
+
<version>2.0.4</version>
|
27 |
<depends>
|
28 |
<Mage_Sales />
|
29 |
</depends>
|
app/code/community/Fooman/SameOrderInvoiceNumber/etc/system.xml
CHANGED
@@ -18,16 +18,6 @@
|
|
18 |
<show_in_website>1</show_in_website>
|
19 |
<show_in_store>1</show_in_store>
|
20 |
<fields>
|
21 |
-
<preventduplicates translate="label">
|
22 |
-
<label>Prevent Duplicates</label>
|
23 |
-
<frontend_type>select</frontend_type>
|
24 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
25 |
-
<comment>For orders with multiple invoices, shipments or creditmemos the numbers will be appended by -1,-2,...</comment>
|
26 |
-
<sort_order>10</sort_order>
|
27 |
-
<show_in_default>1</show_in_default>
|
28 |
-
<show_in_website>1</show_in_website>
|
29 |
-
<show_in_store>1</show_in_store>
|
30 |
-
</preventduplicates>
|
31 |
<invoiceprefix translate="label">
|
32 |
<label>Invoice Prefix</label>
|
33 |
<frontend_type>text</frontend_type>
|
@@ -57,4 +47,4 @@
|
|
57 |
</groups>
|
58 |
</sameorderinvoicenumber>
|
59 |
</sections>
|
60 |
-
</config>
|
18 |
<show_in_website>1</show_in_website>
|
19 |
<show_in_store>1</show_in_store>
|
20 |
<fields>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
<invoiceprefix translate="label">
|
22 |
<label>Invoice Prefix</label>
|
23 |
<frontend_type>text</frontend_type>
|
47 |
</groups>
|
48 |
</sameorderinvoicenumber>
|
49 |
</sections>
|
50 |
+
</config>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Fooman_SameOrderInvoiceNumber</name>
|
4 |
-
<version>2.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
@@ -10,11 +10,11 @@
|
|
10 |
<description><p>Use the order number as invoice,shipment and creditmemo number.</p>
|
11 |
|
12 |
<p>By default Magento keeps separate counts for order and invoice numbers. This extension ensures that when an invoice is created it uses the related order number as invoice number.</p></description>
|
13 |
-
<notes>
|
14 |
<authors><author><name>Kristof Ringleff</name><user>auto-converted</user><email>kristof@fooman.co.nz</email></author></authors>
|
15 |
-
<date>
|
16 |
-
<time>
|
17 |
-
<contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Fooman_SameOrderInvoiceNumber.xml" hash="9c647ab0671752cda14b95db99dd7805"/></dir></dir></dir></target><target name="magecommunity"><dir name="Fooman"><dir name="SameOrderInvoiceNumber"><dir name="etc"><file name="config.xml" hash="
|
18 |
<compatible/>
|
19 |
<dependencies/>
|
20 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Fooman_SameOrderInvoiceNumber</name>
|
4 |
+
<version>2.0.5</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
10 |
<description><p>Use the order number as invoice,shipment and creditmemo number.</p>
|
11 |
|
12 |
<p>By default Magento keeps separate counts for order and invoice numbers. This extension ensures that when an invoice is created it uses the related order number as invoice number.</p></description>
|
13 |
+
<notes>prevent duplicates is now mandatory</notes>
|
14 |
<authors><author><name>Kristof Ringleff</name><user>auto-converted</user><email>kristof@fooman.co.nz</email></author></authors>
|
15 |
+
<date>2012-02-05</date>
|
16 |
+
<time>20:50:29</time>
|
17 |
+
<contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Fooman_SameOrderInvoiceNumber.xml" hash="9c647ab0671752cda14b95db99dd7805"/></dir></dir></dir></target><target name="magecommunity"><dir name="Fooman"><dir name="SameOrderInvoiceNumber"><dir name="etc"><file name="config.xml" hash="cccd6bc82bb56fe6ab70210fb2eda5c7"/><file name="system.xml" hash="902bc08c44d3473fa86fbbc8968a7f26"/></dir><dir name="Helper"><file name="Data.php" hash="2902afb6f8362656b9e1212091d04550"/></dir><dir name="Model"><file name="Observer.php" hash="9fe79ff9d71a0b91440afece4b5f5fe5"/></dir><file name="LICENSE.txt" hash="59563e7be45096d0833dade102989042"/><file name="LICENSE_AFL.txt" hash="45a399f2095030865fb962263ccd7506"/></dir></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies/>
|
20 |
</package>
|