/**
  * Gets the total discount from $order
  * inkl. and excl. tax
  * Data is returned as a Varien_Object with these data-keys set:
  *  - discount_incl_tax
  *  - discount_excl_tax
  *
  * @param Mage_Sales_Model_Order $order
  *
  * @return Varien_Object
  */
 public function getOrderDiscountData(Mage_Sales_Model_Order $order)
 {
     // if catalog-prices includes tax
     $CatPriceIncl = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $order->getStore());
     $discountIncl = 0;
     $discountExcl = 0;
     // find discount on the items
     foreach ($order->getItemsCollection() as $item) {
         /** @var Mage_Sales_Model_Quote_Item $item */
         if (!$CatPriceIncl) {
             $discountExcl += $item->getDiscountAmount();
             $discountIncl += $item->getDiscountAmount() * ($item->getTaxPercent() / 100 + 1);
         } else {
             $discountExcl += $item->getDiscountAmount() / ($item->getTaxPercent() / 100 + 1);
             $discountIncl += $item->getDiscountAmount();
         }
     }
     // find out tax-rate for the shipping
     if ((double) $order->getShippingInclTax() && (double) $order->getShippingAmount()) {
         $shippingTaxRate = $order->getShippingInclTax() / $order->getShippingAmount();
     } else {
         $shippingTaxRate = 1;
     }
     // get discount amount for shipping
     $shippingDiscount = (double) $order->getShippingDiscountAmount();
     // apply/remove tax to shipping-discount
     if (!$CatPriceIncl) {
         $discountIncl += $shippingDiscount * $shippingTaxRate;
         $discountExcl += $shippingDiscount;
     } else {
         $discountIncl += $shippingDiscount;
         $discountExcl += $shippingDiscount / $shippingTaxRate;
     }
     $return = new Varien_Object();
     return $return->setDiscountInclTax($discountIncl)->setDiscountExclTax($discountExcl);
 }