Version Notes
- Making the changes required for magento patch SUPEE-6788
- rework on the sales export to eboekhouden.nl
Download this release
Release Info
Developer | Ronald Kas |
Extension | EBoekhouden_Export |
Version | 4.1.40 |
Comparing to | |
See all releases |
Code changes from version 4.1.39 to 4.1.40
- app/code/community/Eboekhouden/Export/Block/Sales/Creditmemo/Grid.php +2 -2
- app/code/community/Eboekhouden/Export/Block/Sales/Invoice/Grid.php +2 -2
- app/code/community/Eboekhouden/Export/Block/Sales/Order/Grid.php +2 -2
- app/code/community/Eboekhouden/Export/Helper/Export.php +304 -0
- app/code/community/Eboekhouden/Export/Model/Export/Sales.php +336 -18
- app/code/community/Eboekhouden/Export/controllers/{Catalog → Adminhtml/Eboekhouden/Catalog}/ProductController.php +1 -1
- app/code/community/Eboekhouden/Export/controllers/{Export → Adminhtml/Eboekhouden/Export}/SaleController.php +2 -2
- app/code/community/Eboekhouden/Export/controllers/{MutatieController.php → Adminhtml/Eboekhouden/MutatieController.php} +1 -1
- app/code/community/Eboekhouden/Export/etc/config.xml +7 -9
- app/code/community/Eboekhouden/Export/sql/eboekhouden_setup/{mysql4-install-4.1.39.php → mysql4-install-4.1.40.php} +0 -0
- package.xml +7 -5
app/code/community/Eboekhouden/Export/Block/Sales/Creditmemo/Grid.php
CHANGED
@@ -38,7 +38,7 @@ class Eboekhouden_Export_Block_Sales_Creditmemo_Grid extends Mage_Adminhtml_Bloc
|
|
38 |
$this->getMassactionBlock()->addItem(
|
39 |
'eboekhouden',
|
40 |
array('label' => Mage::helper('Eboekhouden_Export')->__('Export naar e-Boekhouden.nl'),
|
41 |
-
'url' => $this->getUrl('
|
42 |
);
|
43 |
}
|
44 |
|
@@ -94,4 +94,4 @@ class Eboekhouden_Export_Block_Sales_Creditmemo_Grid extends Mage_Adminhtml_Bloc
|
|
94 |
|
95 |
}
|
96 |
|
97 |
-
?>
|
38 |
$this->getMassactionBlock()->addItem(
|
39 |
'eboekhouden',
|
40 |
array('label' => Mage::helper('Eboekhouden_Export')->__('Export naar e-Boekhouden.nl'),
|
41 |
+
'url' => $this->getUrl('adminhtml/eboekhouden_export_sale/creditmemoexport'))
|
42 |
);
|
43 |
}
|
44 |
|
94 |
|
95 |
}
|
96 |
|
97 |
+
?>
|
app/code/community/Eboekhouden/Export/Block/Sales/Invoice/Grid.php
CHANGED
@@ -37,7 +37,7 @@ class Eboekhouden_Export_Block_Sales_Invoice_Grid extends Mage_Adminhtml_Block_S
|
|
37 |
$this->getMassactionBlock()->addItem(
|
38 |
'eboekhouden',
|
39 |
array('label' => Mage::helper('Eboekhouden_Export')->__('Export naar e-Boekhouden.nl'),
|
40 |
-
'url' => $this->getUrl('
|
41 |
);
|
42 |
}
|
43 |
|
@@ -93,4 +93,4 @@ class Eboekhouden_Export_Block_Sales_Invoice_Grid extends Mage_Adminhtml_Block_S
|
|
93 |
|
94 |
}
|
95 |
|
96 |
-
?>
|
37 |
$this->getMassactionBlock()->addItem(
|
38 |
'eboekhouden',
|
39 |
array('label' => Mage::helper('Eboekhouden_Export')->__('Export naar e-Boekhouden.nl'),
|
40 |
+
'url' => $this->getUrl('adminhtml/eboekhouden_export_sale/invoiceexport'))
|
41 |
);
|
42 |
}
|
43 |
|
93 |
|
94 |
}
|
95 |
|
96 |
+
?>
|
app/code/community/Eboekhouden/Export/Block/Sales/Order/Grid.php
CHANGED
@@ -40,7 +40,7 @@ class Eboekhouden_Export_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sal
|
|
40 |
$this->getMassactionBlock()->addItem(
|
41 |
'eboekhouden',
|
42 |
array('label' => Mage::helper('Eboekhouden_Export')->__('Export naar e-Boekhouden.nl'),
|
43 |
-
'url' => $this->getUrl('
|
44 |
);
|
45 |
|
46 |
$sExtensionFile = BP . DS . 'app' . DS . 'code' . DS . 'community' . DS . 'BoutikCircus' . DS . 'DeleteOrders' . DS . 'Block' . DS . 'Grid.php';
|
@@ -56,4 +56,4 @@ class Eboekhouden_Export_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sal
|
|
56 |
|
57 |
}
|
58 |
|
59 |
-
?>
|
40 |
$this->getMassactionBlock()->addItem(
|
41 |
'eboekhouden',
|
42 |
array('label' => Mage::helper('Eboekhouden_Export')->__('Export naar e-Boekhouden.nl'),
|
43 |
+
'url' => $this->getUrl('adminhtml/eboekhouden_export_sale/orderexport'))
|
44 |
);
|
45 |
|
46 |
$sExtensionFile = BP . DS . 'app' . DS . 'code' . DS . 'community' . DS . 'BoutikCircus' . DS . 'DeleteOrders' . DS . 'Block' . DS . 'Grid.php';
|
56 |
|
57 |
}
|
58 |
|
59 |
+
?>
|
app/code/community/Eboekhouden/Export/Helper/Export.php
ADDED
@@ -0,0 +1,304 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
Class Eboekhouden_Export_Helper_Export {
|
5 |
+
|
6 |
+
public function createXml($oContainer){
|
7 |
+
$oHelper = Mage::helper('Eboekhouden_Export');
|
8 |
+
/* @var $oHelper Eboekhouden_Export_Helper_Data */
|
9 |
+
$oAccountNumberHelper = Mage::helper('Eboekhouden_Export/accountNumber');
|
10 |
+
/* @var Eboekhouden_Export_Helper_AccountNumber $oAccountNumberHelper */
|
11 |
+
$iStoreId = $oContainer->getStoreId();
|
12 |
+
if (empty($iStoreId))
|
13 |
+
{
|
14 |
+
$iStoreId = 0;
|
15 |
+
}
|
16 |
+
|
17 |
+
$iOrderTime = strtotime($oContainer->getCreatedAt());
|
18 |
+
|
19 |
+
$oOrder = $oContainer->getOrder();
|
20 |
+
/* @var $oOrder Mage_Sales_Model_Order */
|
21 |
+
$sOrderNr = $oOrder->getIncrementId();
|
22 |
+
$sInvoiceNr = 'X' . $oContainer->getIncrementId();
|
23 |
+
$sExportType = Mage::helper('Eboekhouden_Export')->__('object');
|
24 |
+
if ($oContainer instanceof Mage_Sales_Model_Order_Invoice)
|
25 |
+
{
|
26 |
+
$sExportType = Mage::helper('Eboekhouden_Export')->__('factuur');
|
27 |
+
$sInvoiceNr = $oContainer->getIncrementId();
|
28 |
+
}
|
29 |
+
elseif ($oContainer instanceof Mage_Sales_Model_Order_Creditmemo)
|
30 |
+
{
|
31 |
+
$sExportType = Mage::helper('Eboekhouden_Export')->__('creditering');
|
32 |
+
$sInvoiceNr = 'C' . $oContainer->getIncrementId();
|
33 |
+
}
|
34 |
+
|
35 |
+
$aSettings = $oHelper->getConnectorSettings($oContainer->getStore());
|
36 |
+
$oBillingAddress = $oContainer->getBillingAddress();
|
37 |
+
|
38 |
+
if (empty($aSettings['bConOK']))
|
39 |
+
{
|
40 |
+
# Skip the rest
|
41 |
+
}
|
42 |
+
elseif (empty($oBillingAddress))
|
43 |
+
{
|
44 |
+
$sErrorMsg .= Mage::helper('Eboekhouden_Export')
|
45 |
+
->__('Fout in %s %s: geen factuuradres gevonden. ' . "\n", $sExportType,
|
46 |
+
$oContainer->getIncrementId());
|
47 |
+
}
|
48 |
+
else
|
49 |
+
{
|
50 |
+
$sCompanyName = $oBillingAddress->getCompany();
|
51 |
+
if (empty($sCompanyName))
|
52 |
+
{
|
53 |
+
$sCompanyName = $oBillingAddress->getName();
|
54 |
+
}
|
55 |
+
|
56 |
+
$iExistingMutatieNr = $oContainer->getEboekhoudenMutatie();
|
57 |
+
|
58 |
+
$aTaxInfo = $oOrder->getFullTaxInfo();
|
59 |
+
$aValidTaxPerc = array();
|
60 |
+
foreach ( $aTaxInfo as $aTaxInfoItem )
|
61 |
+
{
|
62 |
+
foreach ( $aTaxInfoItem['rates'] as $aRateInfo )
|
63 |
+
{
|
64 |
+
$aValidTaxPerc[ $aRateInfo['percent'] ] = 1;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
$sObjectDescription = Mage::helper('Eboekhouden_Export')->__('Magento %s %s, order %s'
|
69 |
+
, $sExportType
|
70 |
+
, $oContainer->getIncrementId()
|
71 |
+
, $sOrderNr);
|
72 |
+
|
73 |
+
$sXml .= '
|
74 |
+
<MUTATIE>';
|
75 |
+
if (!empty($iExistingMutatieNr))
|
76 |
+
{
|
77 |
+
$sXml .= '
|
78 |
+
<MUTNR>' . $oHelper->xmlPrepare($iExistingMutatieNr) . '</MUTNR>';
|
79 |
+
}
|
80 |
+
$sStreetFull = $oBillingAddress->getStreetFull();
|
81 |
+
$sStreetFull = str_replace("\n", ' ', $sStreetFull);
|
82 |
+
$sEmail = $oOrder->getCustomerEmail();
|
83 |
+
$sTaxvat = $oOrder->getCustomerTaxvat();
|
84 |
+
$sTaxvat = strtoupper(preg_replace('|\W|', '', $sTaxvat));
|
85 |
+
|
86 |
+
$iBalanceAccount = 1300;
|
87 |
+
$iBalanceAccount = $oAccountNumberHelper->getBalanceAccountNumber($iBalanceAccount,$oContainer);
|
88 |
+
if (empty($iBalanceAccount))
|
89 |
+
{
|
90 |
+
$iBalanceAccount = 1300;
|
91 |
+
}
|
92 |
+
$sXml .= '
|
93 |
+
<NAW>
|
94 |
+
<BEDRIJF>' . $oHelper->xmlPrepare($sCompanyName) . '</BEDRIJF>
|
95 |
+
<ADRES>' . $oHelper->xmlPrepare($sStreetFull) . '</ADRES>
|
96 |
+
<POSTCODE>' . $oHelper->xmlPrepare($oBillingAddress->getPostcode()) . '</POSTCODE>
|
97 |
+
<PLAATS>' . $oHelper->xmlPrepare($oBillingAddress->getCity()) . '</PLAATS>
|
98 |
+
<LAND>' . $oHelper->xmlPrepare($oBillingAddress->getCountryModel()->getName()) . '</LAND>
|
99 |
+
<LANDCODE>' . $oHelper->xmlPrepare($oBillingAddress->getCountry()) . '</LANDCODE>
|
100 |
+
<TELEFOON>' . $oHelper->xmlPrepare($oBillingAddress->getTelephone()) . '</TELEFOON>
|
101 |
+
<EMAIL>' . $oHelper->xmlPrepare($sEmail) . '</EMAIL>
|
102 |
+
<OBNUMMER>' . $oHelper->xmlPrepare($sTaxvat) . '</OBNUMMER>
|
103 |
+
</NAW>
|
104 |
+
<SOORT>' . $oHelper->xmlPrepare(2) . '</SOORT>
|
105 |
+
<REKENING>' . $oHelper->xmlPrepare($iBalanceAccount) . '</REKENING>
|
106 |
+
<OMSCHRIJVING>' . $oHelper->xmlPrepare($sObjectDescription) . '</OMSCHRIJVING>
|
107 |
+
<FACTUUR>' . $oHelper->xmlPrepare($sInvoiceNr) . '</FACTUUR>
|
108 |
+
<BETALINGSKENMERK>' . $oHelper->xmlPrepare($sOrderNr) . '</BETALINGSKENMERK>
|
109 |
+
<BETALINGSTERMIJN>' . $oHelper->xmlPrepare(30) . '</BETALINGSTERMIJN>
|
110 |
+
<DATUM>' . $oHelper->xmlPrepare(date('d-m-Y', $iOrderTime)) . '</DATUM>
|
111 |
+
<INEX>' . $oHelper->xmlPrepare('EX') . '</INEX>
|
112 |
+
<MUTATIEREGELS>';
|
113 |
+
|
114 |
+
$aOrderItems = $oContainer->getItemsCollection();
|
115 |
+
$fDiscountLeft = $oContainer->getBaseDiscountAmount();
|
116 |
+
|
117 |
+
$totalBaseAmountItems = 0;
|
118 |
+
$totalBaseAmountInclTaxItems = 0;
|
119 |
+
$totalBaseTaxItems = 0;
|
120 |
+
|
121 |
+
foreach ($aOrderItems as $oItem) {
|
122 |
+
$fDbProductTaxAmount = $oItem->getBaseTaxAmount();
|
123 |
+
//add to order totals
|
124 |
+
$totalBaseTaxItems += $fDbProductTaxAmount;
|
125 |
+
$totalBaseAmountItems += $oItem->getBaseRowTotal();
|
126 |
+
$totalBaseAmountInclTaxItems += $oItem->getBaseRowTotalInclTax();
|
127 |
+
|
128 |
+
$aWeeItems = $this->_oWeeeHelper->getApplied( $oItem );
|
129 |
+
foreach ( $aWeeItems as $aWeeData )
|
130 |
+
{
|
131 |
+
$oWeeeItem = new Mage_Sales_Model_Order_Item();
|
132 |
+
$oWeeeItem->setData( $aWeeData );
|
133 |
+
$oWeeeItem->setStoreId( $iStoreId );
|
134 |
+
|
135 |
+
///// Bugfix for Magento not saving tax in serialezed weee data in order item
|
136 |
+
if ( 0 < $fDbProductTaxAmount // Tax used + prevent devide by zero
|
137 |
+
&& $this->_oWeeeHelper->isTaxable($iStoreId)
|
138 |
+
&& $oWeeeItem->getBaseRowTotal() == $oWeeeItem->getBaseRowTotalInclTax() // No tax calculated for WEEE
|
139 |
+
)
|
140 |
+
{
|
141 |
+
|
142 |
+
$fRowAllTotalEx = $oItem->getBaseRowTotal() - $oItem->getBaseDiscountAmount() + $oItem->getWeeeTaxAppliedRowAmount();
|
143 |
+
$fAllTaxPerc = 100 * $fDbProductTaxAmount / $fRowAllTotalEx;
|
144 |
+
$fAllTaxPerc = $this->_vatPercRound( $fAllTaxPerc );
|
145 |
+
if ( empty($aValidTaxPerc[$fAllTaxPerc]) ) // It is not a valid tax percentage yet
|
146 |
+
{
|
147 |
+
$fAllTaxPerc = $this->_getItemVatPerc( $oContainer, $oItem );
|
148 |
+
}
|
149 |
+
if ( !empty($aValidTaxPerc[$fAllTaxPerc]) ) // It is a valid tax percentage
|
150 |
+
{
|
151 |
+
$fVatFactor = (100+$fAllTaxPerc) / 100;
|
152 |
+
$oItem->setTaxPercent( $fAllTaxPerc );
|
153 |
+
$oItem->setBaseTaxAmount( $oItem->getBaseRowTotal() * $fAllTaxPerc / 100 );
|
154 |
+
$oItem->setBaseRowTotalInclTax( $oItem->getBaseRowTotal() + $oItem->getBaseTaxAmount() );
|
155 |
+
|
156 |
+
$oWeeeItem->setTaxPercent( $fAllTaxPerc );
|
157 |
+
if ( $this->_oTaxConfig->priceIncludesTax($iStoreId) )
|
158 |
+
{
|
159 |
+
$oWeeeItem->setBaseAmount( $oWeeeItem->getBaseAmountInclTax() / $fVatFactor );
|
160 |
+
$oWeeeItem->setBaseRowAmount( $oWeeeItem->getBaseRowAmountInclTax() / $fVatFactor );
|
161 |
+
}
|
162 |
+
else
|
163 |
+
{
|
164 |
+
$oWeeeItem->setBaseAmountInclTax( $oWeeeItem->getBaseAmount() * $fVatFactor );
|
165 |
+
$oWeeeItem->setBaseRowAmountInclTax( $oWeeeItem->getBaseRowAmount() * $fVatFactor );
|
166 |
+
}
|
167 |
+
$oWeeeItem->setBaseTaxAmount( $oWeeeItem->getBaseRowAmountInclTax() - $oWeeeItem->getBaseRowAmount() );
|
168 |
+
|
169 |
+
}
|
170 |
+
}
|
171 |
+
///// /Bugfix for Magento not saving tax in serialezed weee data in order item
|
172 |
+
|
173 |
+
$oWeeeItem->setProductId( 'weee_'.$oItem->getProductId() );
|
174 |
+
$oWeeeItem->setBaseRowTotal( $oWeeeItem->getBaseRowAmount() );
|
175 |
+
$oWeeeItem->setBaseRowTotalInclTax( $oWeeeItem->getBaseRowAmountInclTax() );
|
176 |
+
|
177 |
+
$sXml .= $this->_getItemXml($oContainer, $oWeeeItem);
|
178 |
+
}
|
179 |
+
|
180 |
+
$sXml .= $this->_getItemXml($oContainer, $oItem); // Add XML for normal item
|
181 |
+
$fDiscountLeft -= $oItem->getBaseDiscountAmount();
|
182 |
+
}
|
183 |
+
// Add shipping
|
184 |
+
if (0 < $oContainer->getBaseShippingAmount())
|
185 |
+
{
|
186 |
+
$fShipFactor = 1;
|
187 |
+
if ($oContainer instanceof Mage_Sales_Model_Order_Creditmemo)
|
188 |
+
{
|
189 |
+
// We need to find out which part of the shippingcost is refunded.
|
190 |
+
// Magento only updates the BaseShippingAmount for a CreditMemo.
|
191 |
+
$fBaseShippingAmount = $oOrder->getBaseShippingAmount();
|
192 |
+
if ( !empty($fBaseShippingAmount)
|
193 |
+
&& is_numeric($fBaseShippingAmount)
|
194 |
+
&& 0 != 1 * $fBaseShippingAmount
|
195 |
+
) // prevent divivsion by zero
|
196 |
+
{
|
197 |
+
$fShipFactor = $oContainer->getBaseShippingAmount() / $fBaseShippingAmount;
|
198 |
+
}
|
199 |
+
}
|
200 |
+
//add to order totals
|
201 |
+
$totalBaseTaxItems += $fShipFactor * $oContainer->getBaseShippingTaxAmount();
|
202 |
+
$totalBaseAmountItems += $fShipFactor * $oContainer->getBaseShippingAmount();
|
203 |
+
$totalBaseAmountInclTaxItems += $fShipFactor * $oContainer->getBaseShippingInclTax();
|
204 |
+
|
205 |
+
// Shipping & Handling cost, create a virtual order_item
|
206 |
+
$oShippingItem = new Mage_Sales_Model_Order_Item();
|
207 |
+
$oShippingItem->setStoreId($iStoreId);
|
208 |
+
$oShippingItem->setProductId('shipping');
|
209 |
+
$oShippingItem->setBaseRowTotal($fShipFactor * $oContainer->getBaseShippingAmount());
|
210 |
+
$oShippingItem->setBaseRowTotalInclTax($fShipFactor * $oContainer->getBaseShippingInclTax());
|
211 |
+
$oShippingItem->setBaseTaxAmount($fShipFactor * $oContainer->getBaseShippingTaxAmount());
|
212 |
+
$oShippingItem->setBaseDiscountAmount($fShipFactor * $oContainer->getBaseShippingDiscountAmount());
|
213 |
+
if ( 0 == $oShippingItem->getBaseDiscountAmount()
|
214 |
+
&& 0 < $oContainer->getBaseDiscountAmount()
|
215 |
+
&& $fDiscountLeft >= 0.01 )
|
216 |
+
{
|
217 |
+
// There is discount applied on the order but not on the shipping cost
|
218 |
+
// and there is discount left. That discount must be for the shipping, so let's add it.
|
219 |
+
$oShippingItem->setBaseDiscountAmount($fDiscountLeft);
|
220 |
+
}
|
221 |
+
$oShippingItem->setTaxClassId(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS,
|
222 |
+
$iStoreId));
|
223 |
+
$sXml .= $this->_getItemXml($oContainer, $oShippingItem);
|
224 |
+
}
|
225 |
+
|
226 |
+
// Add adjustment in case it exists (for credit memos)
|
227 |
+
if ((float)$oContainer->getAdjustment() !== 0) {
|
228 |
+
$oAdjustmentItem = new Mage_Sales_Model_Order_Item();
|
229 |
+
$oAdjustmentItem->setStoreId($iStoreId);
|
230 |
+
$oAdjustmentItem->setProductId('adjustment_fee');
|
231 |
+
$oAdjustmentItem->setBaseRowTotal($oContainer->getAdjustment());
|
232 |
+
$oAdjustmentItem->setBaseRowTotalInclTax($oContainer->getAdjustment());
|
233 |
+
$oAdjustmentItem->setBaseTaxAmount(0);
|
234 |
+
|
235 |
+
$sXml .= $this->_getItemXml($oContainer, $oAdjustmentItem);
|
236 |
+
}
|
237 |
+
|
238 |
+
//add additional fee price (in case invoice price is higher then itemprice + shipping)
|
239 |
+
$orderGrandTotal = round(floatval($oOrder->getGrandTotal()), 4) - $oOrder->getBaseDiscountAmount();
|
240 |
+
if (0.0001 < abs($orderGrandTotal - round($totalBaseAmountInclTaxItems, 4))) {
|
241 |
+
|
242 |
+
# debug($oOrder->debug());
|
243 |
+
|
244 |
+
$orderSubtotal = round(floatval($oOrder->getSubtotal()) + floatval($oOrder->getBaseShippingAmount()), 4);
|
245 |
+
$orderTaxAmount = round(floatval($oOrder->getTaxAmount()), 4);
|
246 |
+
|
247 |
+
$feeRowTotal = $orderSubtotal - round($totalBaseAmountItems, 4);
|
248 |
+
$feeRowTotalInclTax = $orderGrandTotal - round($totalBaseAmountInclTaxItems, 4);
|
249 |
+
$feeTaxAmount = $orderTaxAmount - round($totalBaseTaxItems, 4);
|
250 |
+
|
251 |
+
$feeItem = new Mage_Sales_Model_Order_Item();
|
252 |
+
$feeItem->setStoreId($iStoreId);
|
253 |
+
$feeItem->setProductId('payment_fee');
|
254 |
+
$feeItem->setBaseRowTotal($feeRowTotal);
|
255 |
+
$feeItem->setBaseRowTotalInclTax($feeRowTotalInclTax);
|
256 |
+
$feeItem->setBaseTaxAmount($feeTaxAmount);
|
257 |
+
$feeItem->setBaseDiscountAmount(0);
|
258 |
+
|
259 |
+
$sXml .= $this->_getItemXml($oContainer, $feeItem);
|
260 |
+
}
|
261 |
+
|
262 |
+
$sXml .= '
|
263 |
+
</MUTATIEREGELS>
|
264 |
+
</MUTATIE>';
|
265 |
+
$sPostAction = (!empty($iExistingMutatieNr)) ? 'ALTER_MUTATIE' : 'ADD_MUTATIE';
|
266 |
+
list($sThisMutatieNr, $iThisExist, $sThisErrorMsg, $sThisInfoMsg) = $this->_postMutatieXml($sXml,
|
267 |
+
$aSettings,
|
268 |
+
$sPostAction);
|
269 |
+
$iCountExist += $iThisExist;
|
270 |
+
$sErrorMsg .= $sThisErrorMsg;
|
271 |
+
$sInfoMsg .= $sThisInfoMsg;
|
272 |
+
if (!empty($sThisMutatieNr)) # can be boolean or string
|
273 |
+
{
|
274 |
+
$iCountAdded++;
|
275 |
+
if (is_string($sThisMutatieNr))
|
276 |
+
{
|
277 |
+
// Do NOT save whole $oContainer, because the fixes to all items will be written to database!
|
278 |
+
$oContainer->setEboekhoudenMutatie($sThisMutatieNr);
|
279 |
+
$oContainer->getResource()->saveAttribute( $oContainer, 'eboekhouden_mutatie' );
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
if ($oContainer instanceof Mage_Sales_Model_Order_Invoice)
|
284 |
+
{
|
285 |
+
$oCreditMemoColl = $oOrder->getCreditmemosCollection();
|
286 |
+
/* @var $oCreditMemoColl Mage_Sales_Model_Mysql4_Order_Creditmemo_Collection */
|
287 |
+
if (!empty($oCreditMemoColl) && $oCreditMemoColl->count())
|
288 |
+
{
|
289 |
+
foreach ($oCreditMemoColl as $oCreditMemo)
|
290 |
+
/* @var $oCreditMemo Mage_Sales_Model_Order_Creditmemo */
|
291 |
+
{
|
292 |
+
list($sThisAdded, $iThisExist, $sThisErrorMsg, $sThisInfoMsg) = $this->_exportObject($oCreditMemo,
|
293 |
+
$aSettings);
|
294 |
+
$iCountAdded += $sThisAdded;
|
295 |
+
$iCountExist += $iThisExist;
|
296 |
+
$sErrorMsg .= $sThisErrorMsg;
|
297 |
+
$sInfoMsg .= $sThisInfoMsg;
|
298 |
+
}
|
299 |
+
}
|
300 |
+
}
|
301 |
+
}
|
302 |
+
return array($iCountAdded, $iCountExist, $sErrorMsg, $sInfoMsg);
|
303 |
+
}
|
304 |
+
}
|
app/code/community/Eboekhouden/Export/Model/Export/Sales.php
CHANGED
@@ -137,7 +137,8 @@ class Eboekhouden_Export_Model_Export_Sales
|
|
137 |
{
|
138 |
$oInvoice = Mage::getModel('sales/order_invoice')->load($sInvoiceId);
|
139 |
/* @var $oInvoice Mage_Sales_Model_Order_Invoice */
|
140 |
-
|
|
|
141 |
$iCountAdded += $iThisAdded;
|
142 |
$iCountExist += $iThisExist;
|
143 |
$sErrorMsg .= $sThisErrorMsg;
|
@@ -174,6 +175,316 @@ class Eboekhouden_Export_Model_Export_Sales
|
|
174 |
return array($iCountAdded, $iCountExist, $sErrorMsg, $sInfoMsg);
|
175 |
}
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
/**
|
178 |
* Export one Invoice or Creditmemo
|
179 |
*
|
@@ -182,6 +493,11 @@ class Eboekhouden_Export_Model_Export_Sales
|
|
182 |
*/
|
183 |
protected function _exportObject($oContainer)
|
184 |
{
|
|
|
|
|
|
|
|
|
|
|
185 |
$sXml = '';
|
186 |
$iCountAdded = 0;
|
187 |
$iCountExist = 0;
|
@@ -422,28 +738,30 @@ class Eboekhouden_Export_Model_Export_Sales
|
|
422 |
$sXml .= $this->_getItemXml($oContainer, $oAdjustmentItem);
|
423 |
}
|
424 |
|
425 |
-
|
426 |
-
|
427 |
-
|
|
|
428 |
|
429 |
-
|
430 |
|
431 |
-
|
432 |
-
|
433 |
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
|
446 |
-
|
|
|
447 |
}
|
448 |
|
449 |
$sXml .= '
|
137 |
{
|
138 |
$oInvoice = Mage::getModel('sales/order_invoice')->load($sInvoiceId);
|
139 |
/* @var $oInvoice Mage_Sales_Model_Order_Invoice */
|
140 |
+
$response = $this->_exportObject($oInvoice);
|
141 |
+
list($iThisAdded, $iThisExist, $sThisErrorMsg, $sThisInfoMsg) = $response;
|
142 |
$iCountAdded += $iThisAdded;
|
143 |
$iCountExist += $iThisExist;
|
144 |
$sErrorMsg .= $sThisErrorMsg;
|
175 |
return array($iCountAdded, $iCountExist, $sErrorMsg, $sInfoMsg);
|
176 |
}
|
177 |
|
178 |
+
/**
|
179 |
+
* Export one Invoice or Creditmemo for 1.9.0 >=
|
180 |
+
*
|
181 |
+
* @param Mage_Sales_Model_Order_Invoice $oContainer
|
182 |
+
* @return array with values ($iOrdersAdded,$iOrdersExist,$sErrorMsg)
|
183 |
+
*/
|
184 |
+
protected function __exportObject($oContainer){
|
185 |
+
|
186 |
+
$oHelper = Mage::helper('Eboekhouden_Export');
|
187 |
+
/* @var $oHelper Eboekhouden_Export_Helper_Data */
|
188 |
+
$oAccountNumberHelper = Mage::helper('Eboekhouden_Export/accountNumber');
|
189 |
+
/* @var Eboekhouden_Export_Helper_AccountNumber $oAccountNumberHelper */
|
190 |
+
|
191 |
+
$sXml = '';
|
192 |
+
$iCountAdded = 0;
|
193 |
+
$iCountExist = 0;
|
194 |
+
$sErrorMsg = '';
|
195 |
+
$sInfoMsg = '';
|
196 |
+
|
197 |
+
|
198 |
+
$iStoreId = $oContainer->getStoreId();
|
199 |
+
if (empty($iStoreId))
|
200 |
+
{
|
201 |
+
$iStoreId = 0;
|
202 |
+
}
|
203 |
+
|
204 |
+
$iOrderTime = strtotime($oContainer->getCreatedAt());
|
205 |
+
|
206 |
+
$oOrder = $oContainer->getOrder();
|
207 |
+
/* @var $oOrder Mage_Sales_Model_Order */
|
208 |
+
$sOrderNr = $oOrder->getIncrementId();
|
209 |
+
$sInvoiceNr = 'X' . $oContainer->getIncrementId();
|
210 |
+
$sExportType = Mage::helper('Eboekhouden_Export')->__('object');
|
211 |
+
if ($oContainer instanceof Mage_Sales_Model_Order_Invoice)
|
212 |
+
{
|
213 |
+
$sExportType = Mage::helper('Eboekhouden_Export')->__('factuur');
|
214 |
+
$sInvoiceNr = $oContainer->getIncrementId();
|
215 |
+
}
|
216 |
+
elseif ($oContainer instanceof Mage_Sales_Model_Order_Creditmemo)
|
217 |
+
{
|
218 |
+
$sExportType = Mage::helper('Eboekhouden_Export')->__('creditering');
|
219 |
+
$sInvoiceNr = 'C' . $oContainer->getIncrementId();
|
220 |
+
}
|
221 |
+
|
222 |
+
$aSettings = $oHelper->getConnectorSettings($oContainer->getStore());
|
223 |
+
$oBillingAddress = $oContainer->getBillingAddress();
|
224 |
+
|
225 |
+
if (empty($aSettings['bConOK']))
|
226 |
+
{
|
227 |
+
# Skip the rest
|
228 |
+
}
|
229 |
+
elseif (empty($oBillingAddress))
|
230 |
+
{
|
231 |
+
$sErrorMsg .= Mage::helper('Eboekhouden_Export')->__('Fout in %s %s: geen factuuradres gevonden. ' . "\n"
|
232 |
+
,$sExportType
|
233 |
+
,$oContainer->getIncrementId()
|
234 |
+
);
|
235 |
+
}
|
236 |
+
else
|
237 |
+
{
|
238 |
+
$sCompanyName = $oBillingAddress->getCompany();
|
239 |
+
if (empty($sCompanyName))
|
240 |
+
{
|
241 |
+
$sCompanyName = $oBillingAddress->getName();
|
242 |
+
}
|
243 |
+
|
244 |
+
$iExistingMutatieNr = $oContainer->getEboekhoudenMutatie();
|
245 |
+
|
246 |
+
$sObjectDescription = Mage::helper('Eboekhouden_Export')->__('Magento %s %s, order %s'
|
247 |
+
, $sExportType
|
248 |
+
, $oContainer->getIncrementId()
|
249 |
+
, $sOrderNr);
|
250 |
+
|
251 |
+
$sXml .= '
|
252 |
+
<MUTATIE>';
|
253 |
+
if (!empty($iExistingMutatieNr))
|
254 |
+
{
|
255 |
+
$sXml .= '
|
256 |
+
<MUTNR>' . $oHelper->xmlPrepare($iExistingMutatieNr) . '</MUTNR>';
|
257 |
+
}
|
258 |
+
$sStreetFull = $oBillingAddress->getStreetFull();
|
259 |
+
$sStreetFull = str_replace("\n", ' ', $sStreetFull);
|
260 |
+
$sEmail = $oOrder->getCustomerEmail();
|
261 |
+
$sTaxvat = $oOrder->getCustomerTaxvat();
|
262 |
+
$sTaxvat = strtoupper(preg_replace('|\W|', '', $sTaxvat));
|
263 |
+
|
264 |
+
$iBalanceAccount = 1300;
|
265 |
+
$iBalanceAccount = $oAccountNumberHelper->getBalanceAccountNumber($iBalanceAccount,$oContainer);
|
266 |
+
if (empty($iBalanceAccount))
|
267 |
+
{
|
268 |
+
$iBalanceAccount = 1300;
|
269 |
+
}
|
270 |
+
$sXml .= '
|
271 |
+
<NAW>
|
272 |
+
<BEDRIJF>' . $oHelper->xmlPrepare($sCompanyName) . '</BEDRIJF>
|
273 |
+
<ADRES>' . $oHelper->xmlPrepare($sStreetFull) . '</ADRES>
|
274 |
+
<POSTCODE>' . $oHelper->xmlPrepare($oBillingAddress->getPostcode()) . '</POSTCODE>
|
275 |
+
<PLAATS>' . $oHelper->xmlPrepare($oBillingAddress->getCity()) . '</PLAATS>
|
276 |
+
<LAND>' . $oHelper->xmlPrepare($oBillingAddress->getCountryModel()->getName()) . '</LAND>
|
277 |
+
<LANDCODE>' . $oHelper->xmlPrepare($oBillingAddress->getCountry()) . '</LANDCODE>
|
278 |
+
<TELEFOON>' . $oHelper->xmlPrepare($oBillingAddress->getTelephone()) . '</TELEFOON>
|
279 |
+
<EMAIL>' . $oHelper->xmlPrepare($sEmail) . '</EMAIL>
|
280 |
+
<OBNUMMER>' . $oHelper->xmlPrepare($sTaxvat) . '</OBNUMMER>
|
281 |
+
</NAW>
|
282 |
+
<SOORT>' . $oHelper->xmlPrepare(2) . '</SOORT>
|
283 |
+
<REKENING>' . $oHelper->xmlPrepare($iBalanceAccount) . '</REKENING>
|
284 |
+
<OMSCHRIJVING>' . $oHelper->xmlPrepare($sObjectDescription) . '</OMSCHRIJVING>
|
285 |
+
<FACTUUR>' . $oHelper->xmlPrepare($sInvoiceNr) . '</FACTUUR>
|
286 |
+
<BETALINGSKENMERK>' . $oHelper->xmlPrepare($sOrderNr) . '</BETALINGSKENMERK>
|
287 |
+
<BETALINGSTERMIJN>' . $oHelper->xmlPrepare(30) . '</BETALINGSTERMIJN>
|
288 |
+
<DATUM>' . $oHelper->xmlPrepare(date('d-m-Y', $iOrderTime)) . '</DATUM>
|
289 |
+
<INEX>' . $oHelper->xmlPrepare('EX') . '</INEX>
|
290 |
+
<MUTATIEREGELS>';
|
291 |
+
|
292 |
+
$aOrderItems = $oContainer->getItemsCollection();
|
293 |
+
$fDiscountLeft = $oContainer->getBaseDiscountAmount();
|
294 |
+
|
295 |
+
$totalBaseAmountItems = 0;
|
296 |
+
$totalBaseAmountInclTaxItems = 0;
|
297 |
+
$totalBaseTaxItems = 0;
|
298 |
+
|
299 |
+
$aTaxInfo = $oOrder->getFullTaxInfo();
|
300 |
+
$aValidTaxPerc = array();
|
301 |
+
foreach ( $aTaxInfo as $aTaxInfoItem )
|
302 |
+
{
|
303 |
+
foreach ( $aTaxInfoItem['rates'] as $aRateInfo )
|
304 |
+
{
|
305 |
+
#debug($aRateInfo);
|
306 |
+
$aValidTaxPerc[ $aRateInfo['percent'] ] = 1;
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
$iGbRekening = $iCostcenter = 0;
|
311 |
+
foreach ($aOrderItems as $oItem) {
|
312 |
+
$pType = $this->_getItemType($oItem);
|
313 |
+
|
314 |
+
$BEDRAGINCL = $oItem->getRowTotal() + $oItem->getTaxAmount() + $oItem->getHiddenTaxAmount() + Mage::helper('weee')->getRowWeeeAmountAfterDiscount($oItem) - $oItem->getDiscountAmount();
|
315 |
+
$BEDRAGEXCL = $BEDRAGINCL / (1 + ($oItem->getOrderItem()->getTaxPercent() / 100));
|
316 |
+
|
317 |
+
$sVatCode = $this->_Find_Ebvatcode((int) $oItem->getOrderItem()->getTaxPercent(), $oOrder, $oItem->getOrderItem()->getProduct()->getTaxClassId());
|
318 |
+
|
319 |
+
|
320 |
+
$iGbRekening = $oAccountNumberHelper->getLedgerAccountNumber($iGbRekening,$oContainer,$oItem);
|
321 |
+
if (empty($iGbRekening))
|
322 |
+
{
|
323 |
+
$iGbRekening = 8000;
|
324 |
+
}
|
325 |
+
$iCostcenter = $oAccountNumberHelper->getCostCenterNumber($iCostcenter,$oContainer,$oItem);
|
326 |
+
if (empty($iCostcenter))
|
327 |
+
{
|
328 |
+
$iCostcenter = 0;
|
329 |
+
}
|
330 |
+
$sComment = 'type:'. $pType . ' [BTW '. (int) $oItem->getOrderItem()->getTaxPercent() . '%]';
|
331 |
+
|
332 |
+
if ($oContainer instanceof Mage_Sales_Model_Order_Creditmemo) {
|
333 |
+
$BEDRAGINCL = -1 * $BEDRAGINCL;
|
334 |
+
$BEDRAGEXCL = -1 * $BEDRAGEXCL;
|
335 |
+
|
336 |
+
}
|
337 |
+
$sXml .= '
|
338 |
+
<MUTATIEREGEL>
|
339 |
+
<!-- ' . $oHelper->xmlPrepare($sComment) . ' -->
|
340 |
+
<BEDRAGINCL>' . $this->_xmlAmountPrepare($BEDRAGINCL) . '</BEDRAGINCL>
|
341 |
+
<BEDRAGEXCL>' . $this->_xmlAmountPrepare($BEDRAGEXCL) . '</BEDRAGEXCL>
|
342 |
+
<BTWBEDRAG>' . $this->_xmlAmountPrepare($BEDRAGINCL - $BEDRAGEXCL) . '</BTWBEDRAG>
|
343 |
+
<BTWPERC>' . $oHelper->xmlPrepare($sVatCode) . '</BTWPERC>
|
344 |
+
<TEGENREKENING>' . $oHelper->xmlPrepare($iGbRekening) . '</TEGENREKENING>
|
345 |
+
<KOSTENPLAATS>' . $oHelper->xmlPrepare($iCostcenter) . '</KOSTENPLAATS>
|
346 |
+
</MUTATIEREGEL>';
|
347 |
+
|
348 |
+
$totalBaseAmountItems += $BEDRAGEXCL;
|
349 |
+
$totalBaseAmountInclTaxItems += $BEDRAGINCL;
|
350 |
+
$totalBaseTaxItems += $BEDRAGINCL - $BEDRAGEXCL;
|
351 |
+
|
352 |
+
}
|
353 |
+
|
354 |
+
|
355 |
+
// Add shipping
|
356 |
+
if (0 < $oContainer->getBaseShippingAmount())
|
357 |
+
{
|
358 |
+
$fShipFactor = 1;
|
359 |
+
if ($oContainer instanceof Mage_Sales_Model_Order_Creditmemo)
|
360 |
+
{
|
361 |
+
// We need to find out which part of the shippingcost is refunded.
|
362 |
+
// Magento only updates the BaseShippingAmount for a CreditMemo.
|
363 |
+
$fBaseShippingAmount = $oOrder->getBaseShippingAmount();
|
364 |
+
if ( !empty($fBaseShippingAmount)
|
365 |
+
&& is_numeric($fBaseShippingAmount)
|
366 |
+
&& 0 != 1 * $fBaseShippingAmount
|
367 |
+
) // prevent divivsion by zero
|
368 |
+
{
|
369 |
+
$fShipFactor = $oContainer->getBaseShippingAmount() / $fBaseShippingAmount;
|
370 |
+
}
|
371 |
+
}
|
372 |
+
//add to order totals
|
373 |
+
$totalBaseTaxItems += $fShipFactor * $oContainer->getBaseShippingTaxAmount();
|
374 |
+
$totalBaseAmountItems += $fShipFactor * $oContainer->getBaseShippingAmount();
|
375 |
+
$totalBaseAmountInclTaxItems += $fShipFactor * $oContainer->getBaseShippingInclTax();
|
376 |
+
|
377 |
+
// Shipping & Handling cost, create a virtual order_item
|
378 |
+
$oShippingItem = new Mage_Sales_Model_Order_Item();
|
379 |
+
$oShippingItem->setStoreId($iStoreId);
|
380 |
+
$oShippingItem->setProductId('shipping');
|
381 |
+
$oShippingItem->setBaseRowTotal($fShipFactor * $oContainer->getBaseShippingAmount());
|
382 |
+
$oShippingItem->setBaseRowTotalInclTax($fShipFactor * $oContainer->getBaseShippingInclTax());
|
383 |
+
$oShippingItem->setBaseTaxAmount($fShipFactor * $oContainer->getBaseShippingTaxAmount());
|
384 |
+
$oShippingItem->setBaseDiscountAmount($fShipFactor * $oContainer->getBaseShippingDiscountAmount());
|
385 |
+
if ( 0 == $oShippingItem->getBaseDiscountAmount()
|
386 |
+
&& 0 < $oContainer->getBaseDiscountAmount()
|
387 |
+
&& $fDiscountLeft >= 0.01 )
|
388 |
+
{
|
389 |
+
// There is discount applied on the order but not on the shipping cost
|
390 |
+
// and there is discount left. That discount must be for the shipping, so let's add it.
|
391 |
+
$oShippingItem->setBaseDiscountAmount($fDiscountLeft);
|
392 |
+
}
|
393 |
+
$oShippingItem->setTaxClassId(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS,
|
394 |
+
$iStoreId));
|
395 |
+
$sXml .= $this->_getItemXml($oContainer, $oShippingItem);
|
396 |
+
}
|
397 |
+
|
398 |
+
// Add adjustment in case it exists (for credit memos)
|
399 |
+
if ((float)$oContainer->getAdjustment() !== 0) {
|
400 |
+
$oAdjustmentItem = new Mage_Sales_Model_Order_Item();
|
401 |
+
$oAdjustmentItem->setStoreId($iStoreId);
|
402 |
+
$oAdjustmentItem->setProductId('adjustment_fee');
|
403 |
+
$oAdjustmentItem->setBaseRowTotal($oContainer->getAdjustment());
|
404 |
+
$oAdjustmentItem->setBaseRowTotalInclTax($oContainer->getAdjustment());
|
405 |
+
$oAdjustmentItem->setBaseTaxAmount(0);
|
406 |
+
|
407 |
+
$sXml .= $this->_getItemXml($oContainer, $oAdjustmentItem);
|
408 |
+
}
|
409 |
+
|
410 |
+
|
411 |
+
# debug($oContainer->getData());
|
412 |
+
if (!$oContainer instanceof Mage_Sales_Model_Order_Creditmemo) {
|
413 |
+
$total = $oContainer->getGrandTotal();
|
414 |
+
$subtotal = $total - $totalBaseTaxItems;
|
415 |
+
//add additional fee price (in case invoice price is higher then itemprice + shipping)
|
416 |
+
$orderGrandTotal = round(floatval($oContainer->getGrandTotal()), 4);
|
417 |
+
if (0.0001 < abs($total - $totalBaseAmountInclTaxItems)) {
|
418 |
+
|
419 |
+
$orderTotal = $total - $totalBaseAmountInclTaxItems;
|
420 |
+
$orderSubtotal = $subtotal - $totalBaseAmountItems; //round(floatval($oContainer->getSubtotal()) + floatval($oContainer->getBaseShippingAmount()), 4);
|
421 |
+
$orderTaxAmount = $orderTotal - $orderSubtotal;// round(floatval($oContainer->getTaxAmount()), 4);
|
422 |
+
|
423 |
+
# echo $orderSubtotal. ' : '. $totalBaseAmountItems;
|
424 |
+
|
425 |
+
$feeRowTotal = $orderSubtotal; #$orderSubtotal - round($totalBaseAmountItems, 4);
|
426 |
+
$feeRowTotalInclTax = $orderTotal; #$orderGrandTotal - round($totalBaseAmountInclTaxItems, 4);
|
427 |
+
$feeTaxAmount = $orderTaxAmount; #$orderTaxAmount - round($totalBaseTaxItems, 4);
|
428 |
+
|
429 |
+
# echo $feeRowTotal . '-'. $feeRowTotalInclTax . '-' . $feeTaxAmount;
|
430 |
+
|
431 |
+
$feeItem = new Mage_Sales_Model_Order_Item();
|
432 |
+
$feeItem->setStoreId($iStoreId);
|
433 |
+
$feeItem->setProductId('payment_fee');
|
434 |
+
$feeItem->setBaseRowTotal($feeRowTotal);
|
435 |
+
$feeItem->setBaseRowTotalInclTax($feeRowTotalInclTax);
|
436 |
+
$feeItem->setBaseTaxAmount($feeTaxAmount);
|
437 |
+
$feeItem->setBaseDiscountAmount(0);
|
438 |
+
|
439 |
+
$sXml .= $this->_getItemXml($oContainer, $feeItem);
|
440 |
+
}
|
441 |
+
}
|
442 |
+
|
443 |
+
$sXml .= '
|
444 |
+
</MUTATIEREGELS>
|
445 |
+
</MUTATIE>';
|
446 |
+
|
447 |
+
|
448 |
+
$sPostAction = (!empty($iExistingMutatieNr)) ? 'ALTER_MUTATIE' : 'ADD_MUTATIE';
|
449 |
+
list($sThisMutatieNr, $iThisExist, $sThisErrorMsg, $sThisInfoMsg) = $this->_postMutatieXml($sXml,
|
450 |
+
$aSettings,
|
451 |
+
$sPostAction);
|
452 |
+
$iCountExist += $iThisExist;
|
453 |
+
$sErrorMsg .= $sThisErrorMsg;
|
454 |
+
$sInfoMsg .= $sThisInfoMsg;
|
455 |
+
if (!empty($sThisMutatieNr)) # can be boolean or string
|
456 |
+
{
|
457 |
+
$iCountAdded++;
|
458 |
+
if (is_string($sThisMutatieNr))
|
459 |
+
{
|
460 |
+
// Do NOT save whole $oContainer, because the fixes to all items will be written to database!
|
461 |
+
$oContainer->setEboekhoudenMutatie($sThisMutatieNr);
|
462 |
+
$oContainer->getResource()->saveAttribute( $oContainer, 'eboekhouden_mutatie' );
|
463 |
+
}
|
464 |
+
}
|
465 |
+
|
466 |
+
if ($oContainer instanceof Mage_Sales_Model_Order_Invoice)
|
467 |
+
{
|
468 |
+
$oCreditMemoColl = $oOrder->getCreditmemosCollection();
|
469 |
+
/* @var $oCreditMemoColl Mage_Sales_Model_Mysql4_Order_Creditmemo_Collection */
|
470 |
+
if (!empty($oCreditMemoColl) && $oCreditMemoColl->count())
|
471 |
+
{
|
472 |
+
foreach ($oCreditMemoColl as $oCreditMemo)
|
473 |
+
/* @var $oCreditMemo Mage_Sales_Model_Order_Creditmemo */
|
474 |
+
{
|
475 |
+
list($sThisAdded, $iThisExist, $sThisErrorMsg, $sThisInfoMsg) = $this->_exportObject($oCreditMemo,
|
476 |
+
$aSettings);
|
477 |
+
$iCountAdded += $sThisAdded;
|
478 |
+
$iCountExist += $iThisExist;
|
479 |
+
$sErrorMsg .= $sThisErrorMsg;
|
480 |
+
$sInfoMsg .= $sThisInfoMsg;
|
481 |
+
}
|
482 |
+
}
|
483 |
+
}
|
484 |
+
}
|
485 |
+
return array($iCountAdded, $iCountExist, $sErrorMsg, $sInfoMsg);
|
486 |
+
}
|
487 |
+
|
488 |
/**
|
489 |
* Export one Invoice or Creditmemo
|
490 |
*
|
493 |
*/
|
494 |
protected function _exportObject($oContainer)
|
495 |
{
|
496 |
+
// @mediaversa reworked this code to be more normal
|
497 |
+
if(version_compare ( Mage::getVersion(), '1.9.0', '>=' )){
|
498 |
+
return $this->__exportObject($oContainer);
|
499 |
+
}
|
500 |
+
|
501 |
$sXml = '';
|
502 |
$iCountAdded = 0;
|
503 |
$iCountExist = 0;
|
738 |
$sXml .= $this->_getItemXml($oContainer, $oAdjustmentItem);
|
739 |
}
|
740 |
|
741 |
+
if (!$oContainer instanceof Mage_Sales_Model_Order_Creditmemo) {
|
742 |
+
//add additional fee price (in case invoice price is higher then itemprice + shipping)
|
743 |
+
$orderGrandTotal = round(floatval($oOrder->getGrandTotal()), 4) - $oOrder->getBaseDiscountAmount();
|
744 |
+
if (0.0001 < abs($orderGrandTotal - round($totalBaseAmountInclTaxItems, 4))) {
|
745 |
|
746 |
+
# debug($oOrder->debug());
|
747 |
|
748 |
+
$orderSubtotal = round(floatval($oOrder->getSubtotal()) + floatval($oOrder->getBaseShippingAmount()), 4);
|
749 |
+
$orderTaxAmount = round(floatval($oOrder->getTaxAmount()), 4);
|
750 |
|
751 |
+
$feeRowTotal = $orderSubtotal - round($totalBaseAmountItems, 4);
|
752 |
+
$feeRowTotalInclTax = $orderGrandTotal - round($totalBaseAmountInclTaxItems, 4);
|
753 |
+
$feeTaxAmount = $orderTaxAmount - round($totalBaseTaxItems, 4);
|
754 |
|
755 |
+
$feeItem = new Mage_Sales_Model_Order_Item();
|
756 |
+
$feeItem->setStoreId($iStoreId);
|
757 |
+
$feeItem->setProductId('payment_fee');
|
758 |
+
$feeItem->setBaseRowTotal($feeRowTotal);
|
759 |
+
$feeItem->setBaseRowTotalInclTax($feeRowTotalInclTax);
|
760 |
+
$feeItem->setBaseTaxAmount($feeTaxAmount);
|
761 |
+
$feeItem->setBaseDiscountAmount(0);
|
762 |
|
763 |
+
$sXml .= $this->_getItemXml($oContainer, $feeItem);
|
764 |
+
}
|
765 |
}
|
766 |
|
767 |
$sXml .= '
|
app/code/community/Eboekhouden/Export/controllers/{Catalog → Adminhtml/Eboekhouden/Catalog}/ProductController.php
RENAMED
@@ -31,7 +31,7 @@
|
|
31 |
*/
|
32 |
require_once 'Mage/Adminhtml/controllers/Catalog/ProductController.php';
|
33 |
|
34 |
-
class
|
35 |
{
|
36 |
|
37 |
public function eboekhoudenAction()
|
31 |
*/
|
32 |
require_once 'Mage/Adminhtml/controllers/Catalog/ProductController.php';
|
33 |
|
34 |
+
class Eboekhouden_Export_Adminhtml_Eboekhouden_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController
|
35 |
{
|
36 |
|
37 |
public function eboekhoudenAction()
|
app/code/community/Eboekhouden/Export/controllers/{Export → Adminhtml/Eboekhouden/Export}/SaleController.php
RENAMED
@@ -29,7 +29,7 @@
|
|
29 |
* @license http://opensource.org/licenses/mit-license.php The MIT License
|
30 |
* @author e-Boekhouden.nl
|
31 |
*/
|
32 |
-
class
|
33 |
{
|
34 |
|
35 |
public function orderExportAction()
|
@@ -110,4 +110,4 @@ class Eboekhouden_Export_Export_SaleController extends Mage_Adminhtml_Controller
|
|
110 |
|
111 |
}
|
112 |
|
113 |
-
?>
|
29 |
* @license http://opensource.org/licenses/mit-license.php The MIT License
|
30 |
* @author e-Boekhouden.nl
|
31 |
*/
|
32 |
+
class Eboekhouden_Export_Adminhtml_Eboekhouden_Export_SaleController extends Mage_Adminhtml_Controller_Action
|
33 |
{
|
34 |
|
35 |
public function orderExportAction()
|
110 |
|
111 |
}
|
112 |
|
113 |
+
?>
|
app/code/community/Eboekhouden/Export/controllers/{MutatieController.php → Adminhtml/Eboekhouden/MutatieController.php}
RENAMED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
// index.php/eboekhouden/mutatie/reset_all/key/XXXXXXXXXX/
|
4 |
-
class
|
5 |
{
|
6 |
public function indexAction()
|
7 |
{
|
1 |
<?php
|
2 |
|
3 |
// index.php/eboekhouden/mutatie/reset_all/key/XXXXXXXXXX/
|
4 |
+
class Eboekhouden_Export_Adminhtml_Eboekhouden_MutatieController extends Mage_Adminhtml_Controller_Action
|
5 |
{
|
6 |
public function indexAction()
|
7 |
{
|
app/code/community/Eboekhouden/Export/etc/config.xml
CHANGED
@@ -35,7 +35,7 @@
|
|
35 |
<modules>
|
36 |
<Eboekhouden_Export>
|
37 |
<!-- When changing version: Don't forget to rename the mysql4-install script in sql/eboekhouden_setup -->
|
38 |
-
<version>4.1.
|
39 |
</Eboekhouden_Export>
|
40 |
</modules>
|
41 |
|
@@ -91,19 +91,17 @@
|
|
91 |
</resources>
|
92 |
|
93 |
</global>
|
94 |
-
|
95 |
<admin>
|
96 |
<routers>
|
97 |
-
<
|
98 |
-
<use>admin</use>
|
99 |
<args>
|
100 |
-
<
|
101 |
-
|
|
|
102 |
</args>
|
103 |
-
</
|
104 |
</routers>
|
105 |
</admin>
|
106 |
-
|
107 |
<adminhtml>
|
108 |
<menu>
|
109 |
<system>
|
@@ -114,7 +112,7 @@
|
|
114 |
<children>
|
115 |
<eboekhouden_reset_mutatie_nummers translate="title" module="Eboekhouden_Export">
|
116 |
<title>Reset alle mutatie nummers</title>
|
117 |
-
<action>
|
118 |
<sort_order>10</sort_order>
|
119 |
</eboekhouden_reset_mutatie_nummers>
|
120 |
<eboekhouden_config translate="title" module="Eboekhouden_Export">
|
35 |
<modules>
|
36 |
<Eboekhouden_Export>
|
37 |
<!-- When changing version: Don't forget to rename the mysql4-install script in sql/eboekhouden_setup -->
|
38 |
+
<version>4.1.40</version>
|
39 |
</Eboekhouden_Export>
|
40 |
</modules>
|
41 |
|
91 |
</resources>
|
92 |
|
93 |
</global>
|
|
|
94 |
<admin>
|
95 |
<routers>
|
96 |
+
<adminhtml>
|
|
|
97 |
<args>
|
98 |
+
<modules>
|
99 |
+
<Eboekhouden_Export before="Mage_Adminhtml">Eboekhouden_Export_Adminhtml</Eboekhouden_Export>
|
100 |
+
</modules>
|
101 |
</args>
|
102 |
+
</adminhtml>
|
103 |
</routers>
|
104 |
</admin>
|
|
|
105 |
<adminhtml>
|
106 |
<menu>
|
107 |
<system>
|
112 |
<children>
|
113 |
<eboekhouden_reset_mutatie_nummers translate="title" module="Eboekhouden_Export">
|
114 |
<title>Reset alle mutatie nummers</title>
|
115 |
+
<action>adminhtml/eboekhouden_mutatie/reset_all</action>
|
116 |
<sort_order>10</sort_order>
|
117 |
</eboekhouden_reset_mutatie_nummers>
|
118 |
<eboekhouden_config translate="title" module="Eboekhouden_Export">
|
app/code/community/Eboekhouden/Export/sql/eboekhouden_setup/{mysql4-install-4.1.39.php → mysql4-install-4.1.40.php}
RENAMED
File without changes
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>EBoekhouden_Export</name>
|
4 |
-
<version>4.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/mit-license.php">MIT</license>
|
7 |
<channel>community</channel>
|
@@ -31,11 +31,13 @@ Meer informatie over deze koppeling met Magento kunt u terugvinden als u ingelog
|
|
31 |
-----------------------------------------------------
|
32 |
Info about uninstalling can be found in 
|
33 |
app/code/community/Eboekhouden/Export/sql/HOWTO_UnInstall.sql</description>
|
34 |
-
<notes
|
|
|
|
|
35 |
<authors><author><name>Ronald Kas</name><user>eboekhoudennl</user><email>info@e-boekhouden.nl</email></author></authors>
|
36 |
-
<date>2015-10
|
37 |
-
<time>
|
38 |
-
<contents><target name="magecommunity"><dir name="Eboekhouden"><dir name="Export"><dir name="Block"><dir name="Config"><dir name="Info"><file name="Version.php" hash="e8957685d4f906457d1eb45853702e1f"/></dir></dir><dir name="Sales"><dir name="Creditmemo"><file name="Grid.php" hash="
|
39 |
<compatible/>
|
40 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
41 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>EBoekhouden_Export</name>
|
4 |
+
<version>4.1.40</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/mit-license.php">MIT</license>
|
7 |
<channel>community</channel>
|
31 |
-----------------------------------------------------
|
32 |
Info about uninstalling can be found in 
|
33 |
app/code/community/Eboekhouden/Export/sql/HOWTO_UnInstall.sql</description>
|
34 |
+
<notes>- Making the changes required for magento patch SUPEE-6788
|
35 |
+
- rework on the sales export to eboekhouden.nl
|
36 |
+
</notes>
|
37 |
<authors><author><name>Ronald Kas</name><user>eboekhoudennl</user><email>info@e-boekhouden.nl</email></author></authors>
|
38 |
+
<date>2015-11-10</date>
|
39 |
+
<time>13:22:05</time>
|
40 |
+
<contents><target name="magecommunity"><dir name="Eboekhouden"><dir name="Export"><dir name="Block"><dir name="Config"><dir name="Info"><file name="Version.php" hash="e8957685d4f906457d1eb45853702e1f"/></dir></dir><dir name="Sales"><dir name="Creditmemo"><file name="Grid.php" hash="6d777d678ae6f496497acc35e5b88a7d"/></dir><dir name="Invoice"><file name="Grid.php" hash="25a464357b8a9f0f54d69c4847f40faa"/></dir><dir name="Order"><file name="Grid.php" hash="7f19644546932debc14bf7a77ee0c40a"/></dir></dir><dir name="Tax"><dir name="Rate"><file name="Form.php" hash="ea36d8fde2272e24f5187c0bfd9deb76"/><dir name="Grid"><dir name="Renderer"><file name="Ebvatcode.php" hash="d34d2edd9593e4d2c23a20c8e0864c95"/></dir></dir><file name="Grid.php" hash="ca50f669ccd75b1365d5937d0390fe3e"/></dir></dir></dir><dir name="Helper"><file name="AccountNumber.php" hash="599c8af6b93e2206c631aa79e9ba5dd4"/><file name="Data.php" hash="74a043943649eeab7f204f333e50219f"/><file name="Export.php" hash="6158668d554b363d4df3f7869e1ce780"/></dir><dir name="Model"><dir name="Config"><file name="Costcenter.php" hash="7f280ef51e003de0bf80f0ab2b9685f0"/><file name="Ledgeraccount.php" hash="318e87f5932d4bd898d1552d27c50bc7"/><file name="Taxcalculationrate.php" hash="9871b70f56e8fee7cd3364bc8b3de2c5"/></dir><dir name="Export"><file name="Sales.php" hash="3c91abbc576c828b2fc899fccfba67ec"/></dir><dir name="Import"><file name="Costcenter.php" hash="593b1a269583073098f5c1f52002058f"/><file name="Ebcode.php" hash="4127f3460ccb06e800f88baf86a58008"/><file name="Gbcodes.php" hash="d513db427803e3c079f6577b7b240219"/></dir><file name="Info.php" hash="c8dbbbaeead14393cb36c0eec5706882"/><dir name="Product"><dir name="Attribute"><file name="Costcenter.php" hash="3b1e02791a8ff9782d18f14afdc90221"/><file name="Ledgeraccount.php" hash="132f16b2407b579605cb24de6ea5b6ab"/></dir></dir><dir name="Tax"><dir name="Attribute"><file name="Ebtaxcode.php" hash="0b34f8d566896c3fbab02ddaabf55536"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Eboekhouden"><dir name="Catalog"><file name="ProductController.php" hash="20e6690c7553a4f71691195862f9fabe"/></dir><dir name="Export"><file name="SaleController.php" hash="8fedb06d7d656fb3f39380cfb7390e3d"/></dir><file name="MutatieController.php" hash="57c2ca660be12f8d06357b89122f1541"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="8d294deba3736d3e8bdf2773d120415d"/><file name="system.xml" hash="aed3ba1bbe341d0cbed0d2b8b848339d"/></dir><dir name="sql"><file name="HOWTO_UnInstall.sql" hash="691131453816d890630a6d3a21b6c7bf"/><dir name="eboekhouden_setup"><dir name="includes"><file name="install-current.php" hash="ddb3ff7895f4ec22fc6b4866207c9575"/></dir><file name="mysql4-install-4.1.40.php" hash="8febe17420f3a5a2e99eb86605ab3dd3"/><file name="mysql4-upgrade-1.0.2-4.0.php" hash="8febe17420f3a5a2e99eb86605ab3dd3"/><file name="mysql4-upgrade-1.0.7-4.0.php" hash="8febe17420f3a5a2e99eb86605ab3dd3"/><file name="mysql4-upgrade-1.1.5-4.0.php" hash="8febe17420f3a5a2e99eb86605ab3dd3"/><file name="mysql4-upgrade-1.2.0-4.0.php" hash="8febe17420f3a5a2e99eb86605ab3dd3"/><file name="mysql4-upgrade-1.2.2-4.0.php" hash="e0ce8dbd2e1de28479e90505abbc6297"/><file name="mysql4-upgrade-1.2.6-4.0.php" hash="8febe17420f3a5a2e99eb86605ab3dd3"/><file name="mysql4-upgrade-1.3-4.0.php" hash="8febe17420f3a5a2e99eb86605ab3dd3"/><file name="mysql4-upgrade-1.4-4.0.php" hash="8febe17420f3a5a2e99eb86605ab3dd3"/><file name="mysql4-upgrade-1.5-4.0.php" hash="8febe17420f3a5a2e99eb86605ab3dd3"/><file name="mysql4-upgrade-1.6-4.0.php" hash="8febe17420f3a5a2e99eb86605ab3dd3"/><file name="mysql4-upgrade-2.0-4.0.php" hash="b1b333b3815368af7d599e5126eca26e"/><file name="mysql4-upgrade-3.0-4.0.php" hash="b1b333b3815368af7d599e5126eca26e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Eboekhouden_Export.xml" hash="9ced450b54f7225a83049f6bff3adbae"/></dir></target></contents>
|
41 |
<compatible/>
|
42 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
43 |
</package>
|