Nicklasmoeller_BillysBilling - Version 0.2.3

Version Notes

Fixed product parents issue, removed empty shipping, added possibility to use a single Magento user (more if selling to different parts of the world) and as a fallback

Download this release

Release Info

Developer Nicklas Møller
Extension Nicklasmoeller_BillysBilling
Version 0.2.3
Comparing to
See all releases


Code changes from version 0.2.2 to 0.2.3

app/code/community/Nicklasmoeller/Billysbilling/Helper/Data.php CHANGED
@@ -4,7 +4,6 @@
4
  * Class Nicklasmoeller_Billysbilling_Helper_Data
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
7
- * @version 0.2.0
8
  */
9
  class Nicklasmoeller_Billysbilling_Helper_Data extends Mage_Core_Helper_Abstract {
10
  /**
@@ -22,4 +21,12 @@ class Nicklasmoeller_Billysbilling_Helper_Data extends Mage_Core_Helper_Abstract
22
  {
23
  return (boolean) Mage::getStoreConfig('billysbilling/api/key');
24
  }
 
 
 
 
 
 
 
 
25
  }
4
  * Class Nicklasmoeller_Billysbilling_Helper_Data
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
 
7
  */
8
  class Nicklasmoeller_Billysbilling_Helper_Data extends Mage_Core_Helper_Abstract {
9
  /**
21
  {
22
  return (boolean) Mage::getStoreConfig('billysbilling/api/key');
23
  }
24
+
25
+ /**
26
+ * @return bool
27
+ */
28
+ public function isSingleCustomer()
29
+ {
30
+ return (boolean) Mage::getStoreConfig('billysbilling/settings/singleuser');
31
+ }
32
  }
app/code/community/Nicklasmoeller/Billysbilling/Model/Abstract.php CHANGED
@@ -4,7 +4,6 @@
4
  * Abstract class Nicklasmoeller_Billysbilling_Model_Abstract
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
7
- * @version 0.2.0
8
  */
9
  abstract class Nicklasmoeller_Billysbilling_Model_Abstract extends Mage_Core_Model_Abstract
10
  {
@@ -20,4 +19,4 @@ abstract class Nicklasmoeller_Billysbilling_Model_Abstract extends Mage_Core_Mod
20
  {
21
  $this->client = Mage::getModel('billysbilling/client');
22
  }
23
- }
4
  * Abstract class Nicklasmoeller_Billysbilling_Model_Abstract
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
 
7
  */
8
  abstract class Nicklasmoeller_Billysbilling_Model_Abstract extends Mage_Core_Model_Abstract
9
  {
19
  {
20
  $this->client = Mage::getModel('billysbilling/client');
21
  }
22
+ }
app/code/community/Nicklasmoeller/Billysbilling/Model/Client.php CHANGED
@@ -4,7 +4,6 @@
4
  * Class Nicklasmoeller_Billysbilling_Model_Client
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
7
- * @version 0.2.0
8
  */
9
  class Nicklasmoeller_Billysbilling_Model_Client
10
  {
4
  * Class Nicklasmoeller_Billysbilling_Model_Client
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
 
7
  */
8
  class Nicklasmoeller_Billysbilling_Model_Client
9
  {
app/code/community/Nicklasmoeller/Billysbilling/Model/Contact.php CHANGED
@@ -4,11 +4,14 @@
4
  * Class Nicklasmoeller_Billysbilling_Model_Contact
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
7
- * @version 0.2.0
8
  */
9
  class Nicklasmoeller_Billysbilling_Model_Contact extends Nicklasmoeller_Billysbilling_Model_Abstract
10
  {
 
 
11
  protected $customer;
 
 
12
 
13
  /**
14
  * @param $billingAddress
@@ -21,7 +24,19 @@ class Nicklasmoeller_Billysbilling_Model_Contact extends Nicklasmoeller_Billysbi
21
  return $this->customer;
22
  }
23
 
24
- $res = $this->client->request("GET", "/contacts?contactNo=" . $billingAddress->getCustomerId());
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  if ($res->body->meta->paging->total > 0) {
27
  $this->customer = $res->body->contacts[0];
@@ -31,9 +46,9 @@ class Nicklasmoeller_Billysbilling_Model_Contact extends Nicklasmoeller_Billysbi
31
 
32
  $contact = $this->buildCustomer($billingAddress);
33
 
34
- $res = $this->client->request("POST", "/contacts", array(
35
  'contact' => $contact
36
- ));
37
 
38
  if ($res->status !== 200) {
39
  return false;
@@ -53,25 +68,45 @@ class Nicklasmoeller_Billysbilling_Model_Contact extends Nicklasmoeller_Billysbi
53
  {
54
  $contact = new stdClass();
55
 
56
- $contact->organizationId = Mage::getSingleton('billysbilling/organization')->getOrganizationId();
57
- $contact->contactNo = $billingAddress->getCustomerId();
58
- $contact->countryId = Mage::getSingleton('billysbilling/country')->getCountry($billingAddress->getCountryId());
59
- $contact->zipcodeText = $billingAddress->getPostcode();
60
- $contact->stateText = $billingAddress->getRegion();
61
- $contact->cityText = $billingAddress->getCity();
62
- $contact->street = $billingAddress->getStreetFull();
63
- $contact->registrationNo = $billingAddress->getVatId();
64
- $contact->phone = $billingAddress->getTelephone();
65
- $contact->isCustomer = true;
66
-
67
- if ($billingAddress->getCompany()) {
68
- $contact->type = 'company';
69
- $contact->name = $billingAddress->getCompany();
 
 
 
 
 
 
70
  } else {
71
- $contact->type = 'person';
72
- $contact->name = $billingAddress->getName();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
 
75
  return $contact;
76
  }
77
- }
4
  * Class Nicklasmoeller_Billysbilling_Model_Contact
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
 
7
  */
8
  class Nicklasmoeller_Billysbilling_Model_Contact extends Nicklasmoeller_Billysbilling_Model_Abstract
9
  {
10
+ public $id;
11
+
12
  protected $customer;
13
+ protected $prefix = "m_";
14
+ protected $country;
15
 
16
  /**
17
  * @param $billingAddress
24
  return $this->customer;
25
  }
26
 
27
+ $this->country = $billingAddress->getCountryId();
28
+
29
+ if (Mage::helper('billysbilling')->isSingleCustomer() || !$billingAddress->getCustomerId()) {
30
+ $this->id = $this->prefix . $this->country;
31
+
32
+ if ($billingAddress->getCompany()) {
33
+ $this->id .= '_c';
34
+ }
35
+ } else {
36
+ $this->id = $this->prefix . $billingAddress->getCustomerId();
37
+ }
38
+
39
+ $res = $this->client->request("GET", "/contacts?contactNo=" . $this->id);
40
 
41
  if ($res->body->meta->paging->total > 0) {
42
  $this->customer = $res->body->contacts[0];
46
 
47
  $contact = $this->buildCustomer($billingAddress);
48
 
49
+ $res = $this->client->request("POST", "/contacts", [
50
  'contact' => $contact
51
+ ]);
52
 
53
  if ($res->status !== 200) {
54
  return false;
68
  {
69
  $contact = new stdClass();
70
 
71
+ $contact->organizationId = Mage::getSingleton('billysbilling/organization')->getOrganizationId();
72
+ $contact->contactNo = $this->id;
73
+
74
+ if (Mage::helper('billysbilling')->isSingleCustomer() || !$billingAddress->getCustomerId()) {
75
+ $contact->type = 'person';
76
+ $contact->name = 'Magento Sales';
77
+
78
+ if ($this->country == "DK" || $this->country == "US") {
79
+ $contact->countryId = Mage::getSingleton('billysbilling/country')->getCountry($this->country);
80
+ $contact->name .= ' ' . $this->country;
81
+ } else {
82
+ $contact->countryId = Mage::getSingleton('billysbilling/country')->getCountry('DE');
83
+ $contact->name .= ' EU';
84
+ }
85
+
86
+ if ($billingAddress->getCompany()) {
87
+ $contact->type = 'company';
88
+ $contact->name .= ' company';
89
+ }
90
+
91
  } else {
92
+ $contact->countryId = Mage::getSingleton('billysbilling/country')->getCountry($this->country);
93
+ $contact->zipcodeText = $billingAddress->getPostcode();
94
+ $contact->stateText = $billingAddress->getRegion();
95
+ $contact->cityText = $billingAddress->getCity();
96
+ $contact->street = $billingAddress->getStreetFull();
97
+ $contact->registrationNo = $billingAddress->getVatId();
98
+ $contact->phone = $billingAddress->getTelephone();
99
+ $contact->isCustomer = true;
100
+
101
+ if ($billingAddress->getCompany()) {
102
+ $contact->type = 'company';
103
+ $contact->name = $billingAddress->getCompany();
104
+ } else {
105
+ $contact->type = 'person';
106
+ $contact->name = $billingAddress->getName();
107
+ }
108
  }
109
 
110
  return $contact;
111
  }
112
+ }
app/code/community/Nicklasmoeller/Billysbilling/Model/Country.php CHANGED
@@ -4,7 +4,6 @@
4
  * Class Nicklasmoeller_Billysbilling_Model_Country
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
7
- * @version 0.2.0
8
  */
9
  class Nicklasmoeller_Billysbilling_Model_Country extends Nicklasmoeller_Billysbilling_Model_Abstract
10
  {
@@ -44,5 +43,4 @@ class Nicklasmoeller_Billysbilling_Model_Country extends Nicklasmoeller_Billysbi
44
 
45
  return $this->country;
46
  }
47
-
48
- }
4
  * Class Nicklasmoeller_Billysbilling_Model_Country
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
 
7
  */
8
  class Nicklasmoeller_Billysbilling_Model_Country extends Nicklasmoeller_Billysbilling_Model_Abstract
9
  {
43
 
44
  return $this->country;
45
  }
46
+ }
 
app/code/community/Nicklasmoeller/Billysbilling/Model/Currency.php CHANGED
@@ -4,7 +4,6 @@
4
  * Class Nicklasmoeller_Billysbilling_Model_Currency
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
7
- * @version 0.2.0
8
  */
9
  class Nicklasmoeller_Billysbilling_Model_Currency extends Nicklasmoeller_Billysbilling_Model_Abstract
10
  {
@@ -31,4 +30,4 @@ class Nicklasmoeller_Billysbilling_Model_Currency extends Nicklasmoeller_Billysb
31
 
32
  return $this->currency;
33
  }
34
- }
4
  * Class Nicklasmoeller_Billysbilling_Model_Currency
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
 
7
  */
8
  class Nicklasmoeller_Billysbilling_Model_Currency extends Nicklasmoeller_Billysbilling_Model_Abstract
9
  {
30
 
31
  return $this->currency;
32
  }
33
+ }
app/code/community/Nicklasmoeller/Billysbilling/Model/Invoice.php CHANGED
@@ -4,7 +4,6 @@
4
  * Class Nicklasmoeller_Billysbilling_Model_Invoice
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
7
- * @version 0.2.0
8
  */
9
  class Nicklasmoeller_Billysbilling_Model_Invoice extends Nicklasmoeller_Billysbilling_Model_Abstract
10
  {
@@ -86,7 +85,7 @@ class Nicklasmoeller_Billysbilling_Model_Invoice extends Nicklasmoeller_Billysbi
86
  {
87
  $lines = array();
88
 
89
- $products = $orderData->getAllItems();
90
 
91
  $this->client->request("GET", "/invoices");
92
 
@@ -110,7 +109,9 @@ class Nicklasmoeller_Billysbilling_Model_Invoice extends Nicklasmoeller_Billysbi
110
  $i++;
111
  }
112
 
113
- $lines[$i] = Mage::getSingleton('billysbilling/shipment')->getShipping($orderData);
 
 
114
 
115
  return $lines;
116
  }
4
  * Class Nicklasmoeller_Billysbilling_Model_Invoice
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
 
7
  */
8
  class Nicklasmoeller_Billysbilling_Model_Invoice extends Nicklasmoeller_Billysbilling_Model_Abstract
9
  {
85
  {
86
  $lines = array();
87
 
88
+ $products = $orderData->getAllVisibleItems();
89
 
90
  $this->client->request("GET", "/invoices");
91
 
109
  $i++;
110
  }
111
 
112
+ if ($orderData->getShippingInvoiced() > 0) {
113
+ $lines[$i] = Mage::getSingleton('billysbilling/shipment')->getShipping($orderData);
114
+ }
115
 
116
  return $lines;
117
  }
app/code/community/Nicklasmoeller/Billysbilling/Model/Observer.php CHANGED
@@ -4,7 +4,6 @@
4
  * Class Nicklasmoeller_Billysbilling_Model_Observer
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
7
- * @version 0.2.0
8
  */
9
  class Nicklasmoeller_Billysbilling_Model_Observer extends Nicklasmoeller_Billysbilling_Model_Abstract
10
  {
4
  * Class Nicklasmoeller_Billysbilling_Model_Observer
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
 
7
  */
8
  class Nicklasmoeller_Billysbilling_Model_Observer extends Nicklasmoeller_Billysbilling_Model_Abstract
9
  {
app/code/community/Nicklasmoeller/Billysbilling/Model/Organization.php CHANGED
@@ -4,7 +4,6 @@
4
  * Class Nicklasmoeller_Billysbilling_Model_Organization
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
7
- * @version 0.2.0
8
  */
9
  class Nicklasmoeller_Billysbilling_Model_Organization extends Nicklasmoeller_Billysbilling_Model_Abstract
10
  {
@@ -29,4 +28,4 @@ class Nicklasmoeller_Billysbilling_Model_Organization extends Nicklasmoeller_Bil
29
 
30
  return $this->organizationId;
31
  }
32
- }
4
  * Class Nicklasmoeller_Billysbilling_Model_Organization
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
 
7
  */
8
  class Nicklasmoeller_Billysbilling_Model_Organization extends Nicklasmoeller_Billysbilling_Model_Abstract
9
  {
28
 
29
  return $this->organizationId;
30
  }
31
+ }
app/code/community/Nicklasmoeller/Billysbilling/Model/Product.php CHANGED
@@ -4,7 +4,6 @@
4
  * Class Nicklasmoeller_Billysbilling_Model_Product
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
7
- * @version 0.2.0
8
  */
9
  class Nicklasmoeller_Billysbilling_Model_Product extends Nicklasmoeller_Billysbilling_Model_Abstract
10
  {
4
  * Class Nicklasmoeller_Billysbilling_Model_Product
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
 
7
  */
8
  class Nicklasmoeller_Billysbilling_Model_Product extends Nicklasmoeller_Billysbilling_Model_Abstract
9
  {
app/code/community/Nicklasmoeller/Billysbilling/Model/Shipment.php CHANGED
@@ -4,7 +4,6 @@
4
  * Class Nicklasmoeller_Billysbilling_Model_Shipment
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
7
- * @version 0.2.0
8
  */
9
  class Nicklasmoeller_Billysbilling_Model_Shipment extends Nicklasmoeller_Billysbilling_Model_Abstract
10
  {
@@ -73,4 +72,4 @@ class Nicklasmoeller_Billysbilling_Model_Shipment extends Nicklasmoeller_Billysb
73
 
74
  return $newLine;
75
  }
76
- }
4
  * Class Nicklasmoeller_Billysbilling_Model_Shipment
5
  *
6
  * @author Nicklas Møller <hello@nicklasmoeller.com>
 
7
  */
8
  class Nicklasmoeller_Billysbilling_Model_Shipment extends Nicklasmoeller_Billysbilling_Model_Abstract
9
  {
72
 
73
  return $newLine;
74
  }
75
+ }
app/code/community/Nicklasmoeller/Billysbilling/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Nicklasmoeller_Billysbilling>
5
- <version>0.1.2</version>
6
  </Nicklasmoeller_Billysbilling>
7
  </modules>
8
 
2
  <config>
3
  <modules>
4
  <Nicklasmoeller_Billysbilling>
5
+ <version>0.2.3</version>
6
  </Nicklasmoeller_Billysbilling>
7
  </modules>
8
 
app/code/community/Nicklasmoeller/Billysbilling/etc/system.xml CHANGED
@@ -27,6 +27,16 @@
27
  <show_in_website>0</show_in_website>
28
  <show_in_store>0</show_in_store>
29
  </enabled>
 
 
 
 
 
 
 
 
 
 
30
  </fields>
31
  </settings>
32
  <api translate="label">
27
  <show_in_website>0</show_in_website>
28
  <show_in_store>0</show_in_store>
29
  </enabled>
30
+ <singleuser translate="label">
31
+ <label>Use Single User</label>
32
+ <comment><![CDATA[In order to use a single user for all your invoices and credit notas, enable this. The user will be called Magento Sales]]></comment>
33
+ <frontend_type>select</frontend_type>
34
+ <source_model>adminhtml/system_config_source_yesno</source_model>
35
+ <sort_order>20</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>0</show_in_website>
38
+ <show_in_store>0</show_in_store>
39
+ </singleuser>
40
  </fields>
41
  </settings>
42
  <api translate="label">
package.xml CHANGED
@@ -1,20 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Nicklasmoeller_BillysBilling</name>
4
- <version>0.2.2</version>
5
  <stability>stable</stability>
6
- <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Automatic creation of invoices in Billy's Billing v2</summary>
10
  <description>Billy's Billing enables you to keep your focus on selling, rather than all the hassle with accounting. It automatically sends your data through Billy's Billing API v2.&#xD;
11
  &#xD;
12
  It will trigger when you create credit memos and invoices, and submit the order data.</description>
13
- <notes>Fixed &lt; PHP 5.4 array issues. Removed an unwelcome log-line from the debugging process</notes>
14
  <authors><author><name>Nicklas M&#xF8;ller</name><user>nicklasmoeller</user><email>hello@nicklasmoeller.com</email></author></authors>
15
- <date>2015-01-08</date>
16
- <time>23:53:45</time>
17
- <contents><target name="mageetc"><dir name="modules"><file name="Nicklasmoeller_Billysbilling.xml" hash=""/></dir></target><target name="magecommunity"><dir name="Nicklasmoeller"><dir name="Billysbilling"><dir name="Helper"><file name="Data.php" hash="f4736eba20bc2d9c7fcedf64a7633204"/></dir><dir name="Model"><file name="Abstract.php" hash="5c6d911c3ffb7cb9b4a01ac110b6bb0b"/><file name="Client.php" hash="5a71e03f607e67d1787e5bfe31d6eb74"/><file name="Contact.php" hash="6cac465d3def83ecc5b7023ea1fce0f1"/><file name="Country.php" hash="00719daadf5e6b1bf33d20c871b88bbe"/><file name="Currency.php" hash="f0fc753816c8a701a3f4a2a77e538b19"/><file name="Invoice.php" hash="673c6ac4fb12e7fe8b20c70c91a84ffa"/><file name="Observer.php" hash="415a0dd2fa5a994f7cae110ae4d4a230"/><file name="Organization.php" hash="3c9878026777e83c37a0d6d5fbaa7bdd"/><file name="Product.php" hash="eb05e67dba21ee3aac0c929c583f9622"/><file name="Shipment.php" hash="f994dda14c629a2885de0af7a4b3a2e0"/></dir><dir name="etc"><file name="adminhtml.xml" hash="6a3fdd657b1c112c61bb2700564f34ad"/><file name="config.xml" hash="59d4ee6d454c3aa47eb24716e8c9c4f7"/><file name="system.xml" hash="9ff46b75b2ba25efa7fae13c9cbb376f"/></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.2.0</min><max>5.6.4</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Nicklasmoeller_BillysBilling</name>
4
+ <version>0.2.3</version>
5
  <stability>stable</stability>
6
+ <license>MIT</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Automatic creation of invoices in Billy's Billing v2</summary>
10
  <description>Billy's Billing enables you to keep your focus on selling, rather than all the hassle with accounting. It automatically sends your data through Billy's Billing API v2.&#xD;
11
  &#xD;
12
  It will trigger when you create credit memos and invoices, and submit the order data.</description>
13
+ <notes>Fixed product parents issue, removed empty shipping, added possibility to use a single Magento user (more if selling to different parts of the world) and as a fallback</notes>
14
  <authors><author><name>Nicklas M&#xF8;ller</name><user>nicklasmoeller</user><email>hello@nicklasmoeller.com</email></author></authors>
15
+ <date>2015-01-13</date>
16
+ <time>00:28:08</time>
17
+ <contents><target name="mageetc"><dir name="modules"><file name="Nicklasmoeller_Billysbilling.xml" hash=""/></dir></target><target name="magecommunity"><dir name="Nicklasmoeller"><dir name="Billysbilling"><dir name="Helper"><file name="Data.php" hash="dd9cc3789c89e26f1701d1d4e44c6f74"/></dir><dir name="Model"><file name="Abstract.php" hash="a4bf6d2ccbb4323089e8fab82cfeb1b2"/><file name="Client.php" hash="859c78f9547c9da81ac14e5e3b144c1c"/><file name="Contact.php" hash="c2ef4893ba39507b35e1f9935e728192"/><file name="Country.php" hash="f899dce07adafb543c1e0c3f629affd6"/><file name="Currency.php" hash="c2ac9dfdd11e35069e4deb3e00a9ab50"/><file name="Invoice.php" hash="cc0afdcef230f6faa8feff212bb929b4"/><file name="Observer.php" hash="c101e1893e5c16f90114aea9381ba88d"/><file name="Organization.php" hash="490f0689b0fa06f969b4fde69f20a152"/><file name="Product.php" hash="77910e6c26e94ae91bc29e3e15a34eae"/><file name="Shipment.php" hash="88ecc1bbbbecc5d098caa043ed549006"/></dir><dir name="etc"><file name="adminhtml.xml" hash="6a3fdd657b1c112c61bb2700564f34ad"/><file name="config.xml" hash="7d7f7b48c03145b93722b5db1b290494"/><file name="system.xml" hash="630086ac461ef5c402e6cc0561cffa19"/></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.2.0</min><max>5.6.4</max></php></required></dependencies>
20
  </package>