Qinvoice_Connect - Version 1.0.6

Version Notes

Added option to select calculation method (incl/excl VAT)

Download this release

Release Info

Developer Casper Mekel
Extension Qinvoice_Connect
Version 1.0.6
Comparing to
See all releases


Code changes from version 1.0.5 to 1.0.6

app/code/community/Qinvoice/CHANGELOG ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ CHANGELOG
2
+
3
+ v1.0.6 - 2014/01/22
4
+ - Removed double description lines
5
+
6
+ v1.0.1 - 2013/08/14
7
+ - Added support for productgroups/attributes (qinvoice_category)
8
+
9
+ v1.0.0 - 2013/08/13
10
+ - Initial release
app/code/community/Qinvoice/Connect/Model/Order/Observer.php CHANGED
@@ -8,7 +8,6 @@ class Qinvoice_Connect_Model_Order_Observer
8
  }
9
 
10
  public function sendOnComplete($observer){
11
- mail('casper@newday.sk', 'sendOnComplete', 'triggered');
12
  $order = $observer->getEvent()->getOrder();
13
  // GETTING TRIGGER SETTING
14
  $db = Mage::getSingleton('core/resource')->getConnection('core_write');
@@ -222,7 +221,13 @@ class Qinvoice_Connect_Model_Order_Observer
222
  $rowLayout = $resultLayout->fetch(PDO::FETCH_ASSOC);
223
  $invoice_layout = $rowLayout['value'];
224
 
225
-
 
 
 
 
 
 
226
 
227
  $invoice_layout_s = @unserialize($invoice_layout);
228
  if ($invoice_layout_s !== false) {
@@ -270,7 +275,7 @@ class Qinvoice_Connect_Model_Order_Observer
270
  {
271
  for($k=0; $k <count($arrItemOptions['options']); $k++)
272
  {
273
- $varDescription .= $arrItemOptions['options'][$k]['label'].": ".$arrItemOptions['options'][$k]['print_value']."\n";
274
  }
275
  }
276
  else
@@ -278,17 +283,20 @@ class Qinvoice_Connect_Model_Order_Observer
278
  {
279
  for($k=0; $k <count($arrItemOptions['attributes_info']); $k++)
280
  {
281
- $varDescription .= $arrItemOptions['attributes_info'][$k]['label'].": ".$arrItemOptions['attributes_info'][$k]['value']."\n";
282
  }
283
  }
284
  else
285
  {
286
- $varDescription = "[".$arrData[$i]['sku']."] ".trim($arrData[$i]['name']);
287
  }
 
288
  $params = array(
289
  'code' => $productcode,
290
- 'description' => $arrData[$i]['name'] ."\n". $varDescription,
291
  'price' => $arrData[$i]['base_price']*100,
 
 
292
  'vatpercentage' => trim(number_format($arrData[$i]['tax_percent'],2,'.', ''))*100,
293
  'discount' => trim(number_format($arrData[$i]['base_discount_amount'], 2, '.', '')/$arrData[$i]['base_price'])*100,
294
  'quantity' => $arrData[$i]['qty_ordered']*100,
@@ -303,6 +311,8 @@ class Qinvoice_Connect_Model_Order_Observer
303
  $params = array(
304
  'description' => trim($rowOne['shipping_description']),
305
  'price' => $rowOne['shipping_amount']*100,
 
 
306
  'vatpercentage' => ($rowOne['shipping_tax_amount']/$rowOne['shipping_amount'])*100,
307
  'discount' => 0,
308
  'quantity' => 100,
@@ -315,6 +325,7 @@ class Qinvoice_Connect_Model_Order_Observer
315
 
316
 
317
  $result = $invoice->sendRequest();
 
318
  if($result == 1){
319
  //notify_to_admin('Casper Mekel','casper@newday.sk','Invoice generated!');
320
  }else{
@@ -407,6 +418,8 @@ class qinvoice{
407
  $item['code'] = $params['code'];
408
  $item['description'] = $params['description'];
409
  $item['price'] = $params['price'];
 
 
410
  $item['vatpercentage'] = $params['vatpercentage'];
411
  $item['discount'] = $params['discount'];
412
  $item['quantity'] = $params['quantity'];
@@ -471,6 +484,7 @@ class qinvoice{
471
  <layout><![CDATA['. $this->layout .']]></layout>
472
  <paid><![CDATA['. $this->paid .']]></paid>
473
  <action><![CDATA['. $this->action .']]></action>
 
474
  <tags>';
475
  foreach($this->tags as $tag){
476
  $string .= '<tag><![CDATA['. $tag .']]></tag>';
@@ -485,6 +499,8 @@ class qinvoice{
485
  <quantity><![CDATA['. $i['quantity'] .']]></quantity>
486
  <description><![CDATA['. $i['description'] .']]></description>
487
  <price>'. $i['price'] .'</price>
 
 
488
  <vatpercentage>'. $i['vatpercentage'] .'</vatpercentage>
489
  <discount>'. $i['discount'] .'</discount>
490
  <categories><![CDATA['. $i['categories'] .']]></categories>
8
  }
9
 
10
  public function sendOnComplete($observer){
 
11
  $order = $observer->getEvent()->getOrder();
12
  // GETTING TRIGGER SETTING
13
  $db = Mage::getSingleton('core/resource')->getConnection('core_write');
221
  $rowLayout = $resultLayout->fetch(PDO::FETCH_ASSOC);
222
  $invoice_layout = $rowLayout['value'];
223
 
224
+ $varCalculationmethodPath = 'invoice_options/invoice/calculation_method';
225
+ $prefix = Mage::getConfig()->getTablePrefix();
226
+ $resultCalculationmethod = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varCalculationmethodPath."'");
227
+ $rowCalculationmethod = $resultCalculationmethod->fetch(PDO::FETCH_ASSOC);
228
+ $invoice_calculationmethod = $rowCalculationmethod['value'];
229
+
230
+ $invoice->calculation_method = $invoice_calculationmethod;
231
 
232
  $invoice_layout_s = @unserialize($invoice_layout);
233
  if ($invoice_layout_s !== false) {
275
  {
276
  for($k=0; $k <count($arrItemOptions['options']); $k++)
277
  {
278
+ $varDescription .= "\n".$arrItemOptions['options'][$k]['label'].": ".$arrItemOptions['options'][$k]['print_value']."\n";
279
  }
280
  }
281
  else
283
  {
284
  for($k=0; $k <count($arrItemOptions['attributes_info']); $k++)
285
  {
286
+ $varDescription .= "\n".$arrItemOptions['attributes_info'][$k]['label'].": ".$arrItemOptions['attributes_info'][$k]['value']."\n";
287
  }
288
  }
289
  else
290
  {
291
+ $varDescription = ''; //"[".$arrData[$i]['sku']."] ".trim($arrData[$i]['name']);
292
  }
293
+
294
  $params = array(
295
  'code' => $productcode,
296
+ 'description' => "[".$arrData[$i]['sku']."] ".trim($arrData[$i]['name']) . $varDescription,
297
  'price' => $arrData[$i]['base_price']*100,
298
+ 'price_incl' => ((($arrData[$i]['base_price']*$arrData[$i]['qty_ordered'])+$arrData[$i]['tax_amount'])/$arrData[$i]['qty_ordered'])*100,
299
+ 'price_vat' => ($arrData[$i]['tax_amount']/$arrData[$i]['qty_ordered'])*100,
300
  'vatpercentage' => trim(number_format($arrData[$i]['tax_percent'],2,'.', ''))*100,
301
  'discount' => trim(number_format($arrData[$i]['base_discount_amount'], 2, '.', '')/$arrData[$i]['base_price'])*100,
302
  'quantity' => $arrData[$i]['qty_ordered']*100,
311
  $params = array(
312
  'description' => trim($rowOne['shipping_description']),
313
  'price' => $rowOne['shipping_amount']*100,
314
+ 'price_inl' => $rowOne['shipping_amount']*100,
315
+ 'price_vat' => $rowOne['shipping_tax_amount']*100,
316
  'vatpercentage' => ($rowOne['shipping_tax_amount']/$rowOne['shipping_amount'])*100,
317
  'discount' => 0,
318
  'quantity' => 100,
325
 
326
 
327
  $result = $invoice->sendRequest();
328
+ die();
329
  if($result == 1){
330
  //notify_to_admin('Casper Mekel','casper@newday.sk','Invoice generated!');
331
  }else{
418
  $item['code'] = $params['code'];
419
  $item['description'] = $params['description'];
420
  $item['price'] = $params['price'];
421
+ $item['price_incl'] = $params['price_incl'];
422
+ $item['price_vat'] = $params['price_vat'];
423
  $item['vatpercentage'] = $params['vatpercentage'];
424
  $item['discount'] = $params['discount'];
425
  $item['quantity'] = $params['quantity'];
484
  <layout><![CDATA['. $this->layout .']]></layout>
485
  <paid><![CDATA['. $this->paid .']]></paid>
486
  <action><![CDATA['. $this->action .']]></action>
487
+ <calculation_method><![CDATA['. $this->calculation_method .']]></calculation_method>
488
  <tags>';
489
  foreach($this->tags as $tag){
490
  $string .= '<tag><![CDATA['. $tag .']]></tag>';
499
  <quantity><![CDATA['. $i['quantity'] .']]></quantity>
500
  <description><![CDATA['. $i['description'] .']]></description>
501
  <price>'. $i['price'] .'</price>
502
+ <price_incl>'. $i['price_incl'] .'</price_incl>
503
+ <price_vat>'. $i['price_vat'] .'</price_vat>
504
  <vatpercentage>'. $i['vatpercentage'] .'</vatpercentage>
505
  <discount>'. $i['discount'] .'</discount>
506
  <categories><![CDATA['. $i['categories'] .']]></categories>
app/code/community/Qinvoice/Connect/Model/Source/CalcMethod.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Qinvoice_Connect_Model_Source_Invoice
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value' => 0, 'label' => 'Save invoice as concept'),
8
+ array('value' => 1, 'label' => 'Finalize invoice'),
9
+ array('value' => 2, 'label' => 'Finalize and send via email')
10
+ );
11
+ }
12
+ }
13
+ ?>
app/code/community/Qinvoice/Connect/Model/Source/Calculationmethod.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Qinvoice_Connect_Model_Source_Calculationmethod
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value' => 'excl', 'label' => 'Prices without VAT are leading'),
8
+ array('value' => 'incl', 'label' => 'Prices with VAT included are leading')
9
+ );
10
+ }
11
+ }
12
+ ?>
app/code/community/Qinvoice/Connect/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
  <config>
4
  <modules>
5
  <Qinvoice_Connect>
6
- <version>1.0.5</version>
7
  </Qinvoice_Connect>
8
  </modules>
9
  <global>
3
  <config>
4
  <modules>
5
  <Qinvoice_Connect>
6
+ <version>1.0.6</version>
7
  </Qinvoice_Connect>
8
  </modules>
9
  <global>
app/code/community/Qinvoice/Connect/etc/system.xml CHANGED
@@ -49,6 +49,16 @@
49
  <show_in_website>1</show_in_website>
50
  <show_in_store>1</show_in_store>
51
  </api_password>
 
 
 
 
 
 
 
 
 
 
52
  <layout_code translate="label">
53
  <label>Layout Code</label>
54
  <frontend_type>text</frontend_type>
49
  <show_in_website>1</show_in_website>
50
  <show_in_store>1</show_in_store>
51
  </api_password>
52
+ <calculation_method translate="label">
53
+ <label>Calculation method</label>
54
+ <frontend_type>select</frontend_type>
55
+ <source_model>invoice/source_calculationmethod</source_model>
56
+ <sort_order>7</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ <comment><![CDATA[Select leading price type]]></comment>
61
+ </calculation_method>
62
  <layout_code translate="label">
63
  <label>Layout Code</label>
64
  <frontend_type>text</frontend_type>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Qinvoice_Connect</name>
4
- <version>1.0.5</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Connects to q-invoice for sending invoices.</summary>
10
  <description>Manage your financial adminstration with q-invoice. All orders are invoiced through q-invoice and automatically added to your administration.</description>
11
- <notes>Added support for custom table prefix</notes>
12
  <authors><author><name>Casper Mekel</name><user>caspermekel</user><email>info@q-invoice.com</email></author></authors>
13
- <date>2013-12-06</date>
14
- <time>00:05:49</time>
15
- <contents><target name="magecommunity"><dir name="Qinvoice"><dir name="Connect"><dir name="Helper"><file name="Data.php" hash="ccb4b09674319e8b20e9c06a94adfa38"/></dir><dir name="Model"><dir name="Order"><file name="Observer.php" hash="b4126d400791cc7325d3520af5442481"/></dir><dir name="Source"><file name="Invoice.php" hash="4661f369f7e116fd761e5fffac9efeaf"/><file name="Relation.php" hash="89ab031937b846ab5f0bcac7ccaa31b7"/><file name="Trigger.php" hash="e65427cc9773baaedae2b3897c7bf28a"/></dir></dir><dir name="etc"><file name="config.xml" hash="701b42e28b54e95475ef30400702383c"/><file name="system.xml" hash="7559f766d615a0fa291eaa2c2a85912c"/></dir><file name="readme.txt" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Qinvoice_Connect.xml" hash="fbedefa4e926092705c6941ad28f51f8"/></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7.0</max></package><extension><name>curl</name><min>5.1</min><max>6.0</max></extension></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Qinvoice_Connect</name>
4
+ <version>1.0.6</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Connects to q-invoice for sending invoices.</summary>
10
  <description>Manage your financial adminstration with q-invoice. All orders are invoiced through q-invoice and automatically added to your administration.</description>
11
+ <notes>Added option to select calculation method (incl/excl VAT)</notes>
12
  <authors><author><name>Casper Mekel</name><user>caspermekel</user><email>info@q-invoice.com</email></author></authors>
13
+ <date>2014-02-12</date>
14
+ <time>19:44:25</time>
15
+ <contents><target name="magecommunity"><dir name="Qinvoice"><file name="CHANGELOG" hash="b13454004c420dfb97201b73d79598f9"/><dir name="Connect"><dir name="Helper"><file name="Data.php" hash="ccb4b09674319e8b20e9c06a94adfa38"/></dir><dir name="Model"><dir name="Order"><file name="Observer.php" hash="4cf0a33359d871f463124ee651ba63b4"/></dir><dir name="Source"><file name="CalcMethod.php" hash="4661f369f7e116fd761e5fffac9efeaf"/><file name="Calculationmethod.php" hash="3d5113c09db3e27111229a7ded570f2d"/><file name="Invoice.php" hash="4661f369f7e116fd761e5fffac9efeaf"/><file name="Relation.php" hash="89ab031937b846ab5f0bcac7ccaa31b7"/><file name="Trigger.php" hash="e65427cc9773baaedae2b3897c7bf28a"/></dir></dir><dir name="etc"><file name="config.xml" hash="e1759d74b323bbe4df1b0318ab30b68f"/><file name="system.xml" hash="8ecfb337fbe3d7b8f192ac4b51494f22"/></dir><file name="readme.txt" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Qinvoice_Connect.xml" hash="fbedefa4e926092705c6941ad28f51f8"/></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.8.0</max></package><extension><name>curl</name><min>5.1</min><max>6.0</max></extension></required></dependencies>
18
  </package>