FarApp_Connector - Version 1.2.4

Version Notes

Added support for posting online credit memos.

Download this release

Release Info

Developer FarApp
Extension FarApp_Connector
Version 1.2.4
Comparing to
See all releases


Code changes from version 1.2.3 to 1.2.4

app/code/community/FarApp/Connector/Model/Order/Creditmemo/Api.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class FarApp_Connector_Model_Order_Creditmemo_Api extends Mage_Sales_Model_Order_Creditmemo_Api
3
+ {
4
+ public function create($orderIncrementId, $creditmemoData = null, $comment = null, $notifyCustomer = false,
5
+ $includeComment = false, $refundToStoreCreditAmount = null, $online = true)
6
+ {
7
+ /** @var $order Mage_Sales_Model_Order */
8
+ $order = Mage::getModel('sales/order')->load($orderIncrementId, 'increment_id');
9
+ if (!$order->getId()) {
10
+ $this->_fault('order_not_exists');
11
+ }
12
+ if (!$order->canCreditmemo()) {
13
+ $this->_fault('cannot_create_creditmemo');
14
+ }
15
+ $creditmemoData = $this->_prepareCreateData($creditmemoData);
16
+
17
+ /** @var $service Mage_Sales_Model_Service_Order */
18
+ $service = Mage::getModel('sales/service_order', $order);
19
+ /** @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
20
+ if ($online) {
21
+ $invoices = $order->getInvoiceCollection();
22
+ if ($invoices) {
23
+ $creditmemo = $service->prepareInvoiceCreditmemo($invoices->getFirstItem(), $creditmemoData);
24
+ } else {
25
+ $creditmemo = $service->prepareCreditmemo($creditmemoData);
26
+ }
27
+ }
28
+ else {
29
+ $creditmemo = $service->prepareCreditmemo($creditmemoData);
30
+ }
31
+
32
+ // refund to Store Credit
33
+ if ($refundToStoreCreditAmount) {
34
+ // check if refund to Store Credit is available
35
+ if ($order->getCustomerIsGuest()) {
36
+ $this->_fault('cannot_refund_to_storecredit');
37
+ }
38
+ $refundToStoreCreditAmount = max(
39
+ 0,
40
+ min($creditmemo->getBaseCustomerBalanceReturnMax(), $refundToStoreCreditAmount)
41
+ );
42
+ if ($refundToStoreCreditAmount) {
43
+ $refundToStoreCreditAmount = $creditmemo->getStore()->roundPrice($refundToStoreCreditAmount);
44
+ $creditmemo->setBaseCustomerBalanceTotalRefunded($refundToStoreCreditAmount);
45
+ $refundToStoreCreditAmount = $creditmemo->getStore()->roundPrice(
46
+ $refundToStoreCreditAmount*$order->getStoreToOrderRate()
47
+ );
48
+ // this field can be used by customer balance observer
49
+ $creditmemo->setBsCustomerBalTotalRefunded($refundToStoreCreditAmount);
50
+ // setting flag to make actual refund to customer balance after credit memo save
51
+ $creditmemo->setCustomerBalanceRefundFlag(true);
52
+ }
53
+ }
54
+ if ($online) {
55
+ $creditmemo->register();
56
+ }
57
+ else {
58
+ $creditmemo->setPaymentRefundDisallowed(true)->register();
59
+ }
60
+ // add comment to creditmemo
61
+ if (!empty($comment)) {
62
+ $creditmemo->addComment($comment, $notifyCustomer);
63
+ }
64
+ try {
65
+ if ($online) {
66
+ $transactionSave = Mage::getModel('core/resource_transaction')
67
+ ->addObject($creditmemo)
68
+ ->addObject($order);
69
+ if ($creditmemo->getInvoice()) {
70
+ $transactionSave->addObject($creditmemo->getInvoice());
71
+ }
72
+ $transactionSave->save();
73
+ }
74
+ else {
75
+ Mage::getModel('core/resource_transaction')
76
+ ->addObject($creditmemo)
77
+ ->addObject($order)
78
+ ->save();
79
+ }
80
+ // send email notification
81
+ $creditmemo->sendEmail($notifyCustomer, ($includeComment ? $comment : ''));
82
+ } catch (Mage_Core_Exception $e) {
83
+ $this->_fault('data_invalid', $e->getMessage());
84
+ }
85
+ return $creditmemo->getIncrementId();
86
+ }
87
+ }
app/code/community/FarApp/Connector/etc/config.xml CHANGED
@@ -9,7 +9,7 @@
9
  <config>
10
  <modules>
11
  <FarApp_Connector>
12
- <version>1.2.3</version>
13
  </FarApp_Connector>
14
  </modules>
15
  <global>
@@ -20,6 +20,7 @@
20
  <sales>
21
  <rewrite>
22
  <order_invoice_api>FarApp_Connector_Model_Order_Invoice_Api</order_invoice_api>
 
23
  </rewrite>
24
  </sales>
25
  </models>
9
  <config>
10
  <modules>
11
  <FarApp_Connector>
12
+ <version>1.2.4</version>
13
  </FarApp_Connector>
14
  </modules>
15
  <global>
20
  <sales>
21
  <rewrite>
22
  <order_invoice_api>FarApp_Connector_Model_Order_Invoice_Api</order_invoice_api>
23
+ <order_creditmemo_api>FarApp_Connector_Model_Order_Creditmemo_Api</order_creditmemo_api>
24
  </rewrite>
25
  </sales>
26
  </models>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>FarApp_Connector</name>
4
- <version>1.2.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.farapp.com/p/farapp-subscription-form">Commercial</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Connector to sync product data from FarApp to Magento. FarApp currently supports NetSuite and other backends.</summary>
10
  <description>FarApp is a cloud-based solution for posting product data to storefronts, retrieving orders from storefront and posting fulfillments to storefronts. We support various backends including NetSuite, X-Cart, 3D-Cart, and more. This connector allows full product data posting to Magento from FarApp. It has the the extra benefits of allowing FarApp to dynamically push new product data, automatically creating new attribute options and importing external images (features not provided by Magento).</description>
11
- <notes>Fixed issue with loading child rows and parent is invalid.</notes>
12
  <authors><author><name>FarApp</name><user>FarApp</user><email>support@farapp.com</email></author></authors>
13
- <date>2015-09-01</date>
14
- <time>22:51:57</time>
15
- <contents><target name="magecommunity"><dir name="FarApp"><dir name="Connector"><dir name="Model"><dir name="Export"><dir name="Adapter"><file name="Abstract.php" hash="765dc8fbab996f17b9f049cc8aa906a0"/><file name="Array.php" hash="6ca62c702dcb9512ec429563ac1ce1a2"/></dir><dir name="Entity"><file name="Order.php" hash="14a2f735cf8fc5e8f2bcd6682a1e56b1"/></dir></dir><file name="Export.php" hash="01643ef101731c6d98bbc523642f95a0"/><dir name="Import"><dir name="Entity"><file name="Customer.php" hash="376978f635c73605d428037cca8cf594"/><file name="Order.php" hash="38579396825a1bd3ad59de84278085f6"/><file name="Product.php" hash="b1b6b5cbbd4799889ff87e06e38567e8"/><file name="minVersion2.php" hash="8df670fd68516ba1629304ae8ab6c812"/></dir></dir><file name="Import.php" hash="5f226d5505bf8e258a4e61f43b09b25a"/><dir name="Order"><dir name="Invoice"><file name="Api.php" hash="f133255dae51ab9c44c71ca9cc702d0a"/></dir></dir></dir><dir name="controllers"><file name="ExportController.php" hash="c51395789ff9eed363f20d5ab08ff528"/><file name="ImportController.php" hash="ec66abaf46073b9491889a199d665992"/><file name="IndexController.php" hash="93918848d3ce7f6ad05688f89a730e75"/></dir><dir name="etc"><file name="api.xml" hash="25b50336e5bfbd139eeb81bbf321dd78"/><file name="config.xml" hash="6e7c44e640d63becfbb097414d3a1376"/><file name="wsdl.xml" hash="831bf87f9939132a9d9be6327d1b6a8e"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="FarApp_Connector.xml" hash="ff3fe315c70239229cb5ff3a49d40967"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.0.0</min><max>5.7.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>FarApp_Connector</name>
4
+ <version>1.2.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.farapp.com/p/farapp-subscription-form">Commercial</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Connector to sync product data from FarApp to Magento. FarApp currently supports NetSuite and other backends.</summary>
10
  <description>FarApp is a cloud-based solution for posting product data to storefronts, retrieving orders from storefront and posting fulfillments to storefronts. We support various backends including NetSuite, X-Cart, 3D-Cart, and more. This connector allows full product data posting to Magento from FarApp. It has the the extra benefits of allowing FarApp to dynamically push new product data, automatically creating new attribute options and importing external images (features not provided by Magento).</description>
11
+ <notes>Added support for posting online credit memos.</notes>
12
  <authors><author><name>FarApp</name><user>FarApp</user><email>support@farapp.com</email></author></authors>
13
+ <date>2015-10-02</date>
14
+ <time>21:33:37</time>
15
+ <contents><target name="magecommunity"><dir name="FarApp"><dir name="Connector"><dir name="Model"><dir name="Export"><dir name="Adapter"><file name="Abstract.php" hash="765dc8fbab996f17b9f049cc8aa906a0"/><file name="Array.php" hash="6ca62c702dcb9512ec429563ac1ce1a2"/></dir><dir name="Entity"><file name="Order.php" hash="14a2f735cf8fc5e8f2bcd6682a1e56b1"/></dir></dir><file name="Export.php" hash="01643ef101731c6d98bbc523642f95a0"/><dir name="Import"><dir name="Entity"><file name="Customer.php" hash="376978f635c73605d428037cca8cf594"/><file name="Order.php" hash="38579396825a1bd3ad59de84278085f6"/><file name="Product.php" hash="b1b6b5cbbd4799889ff87e06e38567e8"/><file name="minVersion2.php" hash="8df670fd68516ba1629304ae8ab6c812"/></dir></dir><file name="Import.php" hash="5f226d5505bf8e258a4e61f43b09b25a"/><dir name="Order"><dir name="Creditmemo"><file name="Api.php" hash="edb85d34679eab92e8990a0dd065632e"/></dir><dir name="Invoice"><file name="Api.php" hash="f133255dae51ab9c44c71ca9cc702d0a"/></dir></dir></dir><dir name="controllers"><file name="ExportController.php" hash="c51395789ff9eed363f20d5ab08ff528"/><file name="ImportController.php" hash="ec66abaf46073b9491889a199d665992"/><file name="IndexController.php" hash="93918848d3ce7f6ad05688f89a730e75"/></dir><dir name="etc"><file name="api.xml" hash="25b50336e5bfbd139eeb81bbf321dd78"/><file name="config.xml" hash="6cf085440e5593959e82036771f3ee10"/><file name="wsdl.xml" hash="831bf87f9939132a9d9be6327d1b6a8e"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="FarApp_Connector.xml" hash="ff3fe315c70239229cb5ff3a49d40967"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.0.0</min><max>5.7.0</max></php></required></dependencies>
18
  </package>