<commit_before><?php
/**
 * This file is part of Mbiz_Reports for Magento.
 *
 * @license All rights reserved
 * @author <NAME> <@jacquesbh> <<EMAIL>> <@jacquesbh>
 * @category Mbiz
 * @package Mbiz_Reports
 * @copyright Copyright (c) 2015 Monsieur Biz (http://monsieurbiz.com/)
 */

/**
 * Sales_Journal_Result_Tax_Rate Model
 * @package Mbiz_Reports
 */
class Mbiz_Reports_Model_Sales_Journal_Result_Tax_Rate extends Mbiz_Reports_Model_Sales_Journal_Result_Abstract
{

// Monsieur Biz Tag NEW_CONST

// Monsieur Biz Tag NEW_VAR

    /**
     * Load the taxes by rates
     */
    protected function _load(\Mbiz_Reports_Model_Sales_Journal_Request $request, \Zend_Date $from, \Zend_Date $to)
    {
        $select = $this->getReadAdapter()->select();
        $select
            ->from(['tax' => $this->getTableName('sales/order_tax')], null)
            ->joinInner(
                ['invoice' => $this->getTableName('sales/invoice')],
                'invoice.order_id = tax.order_id',
                null
            )
            ->columns([
                "code" => "tax.code",
                "title" => "tax.title",
                "rate" => "ROUND(tax.percent, 2)",
                "nb_orders" => "COUNT(DISTINCT tax.order_id)",
                "amount" => "SUM(ROUND(IFNULL(tax.base_amount, 0), 2))",
            ])
            ->where("DATE(invoice.created_at) >= ?", $from->toString('y-MM-dd'))
            ->where("DATE(invoice.created_at) <= ?", $to->toString('y-MM-dd'))
            ->group("tax.code")
        ;

        $results = $select->query()->fetchAll();
        $taxByRate = [];
        foreach ($results as $result) {
            $taxByRate[$result['code']] = new Varien_Object($result);
        }

        return $taxByRate;
    }

// Monsieur Biz Tag NEW_METHOD

}<commit_msg>Sometimes the invoice is a 0 totals, but not the order (manual action)<commit_after><?php
/**
 * This file is part of Mbiz_Reports for Magento.
 *
 * @license All rights reserved
 * @author <NAME> <@jacquesbh> <<EMAIL>> <@jacquesbh>
 * @category Mbiz
 * @package Mbiz_Reports
 * @copyright Copyright (c) 2015 Monsieur Biz (http://monsieurbiz.com/)
 */

/**
 * Sales_Journal_Result_Tax_Rate Model
 * @package Mbiz_Reports
 */
class Mbiz_Reports_Model_Sales_Journal_Result_Tax_Rate extends Mbiz_Reports_Model_Sales_Journal_Result_Abstract
{

// Monsieur Biz Tag NEW_CONST

// Monsieur Biz Tag NEW_VAR

    /**
     * Load the taxes by rates
     */
    protected function _load(\Mbiz_Reports_Model_Sales_Journal_Request $request, \Zend_Date $from, \Zend_Date $to)
    {
        $select = $this->getReadAdapter()->select();
        $select
            ->from(['tax' => $this->getTableName('sales/order_tax')], null)
            ->joinInner(
                ['invoice' => $this->getTableName('sales/invoice')],
                'invoice.order_id = tax.order_id',
                null
            )
            ->columns([
                "code" => "tax.code",
                "title" => "tax.title",
                "rate" => "ROUND(tax.percent, 2)",
                "nb_orders" => "COUNT(DISTINCT tax.order_id)",
                "amount" => "SUM(ROUND(IFNULL(tax.base_amount, 0), 2))",
            ])
            ->where("DATE(invoice.created_at) >= ?", $from->toString('y-MM-dd'))
            ->where("DATE(invoice.created_at) <= ?", $to->toString('y-MM-dd'))
            ->where("ROUND(IFNULL(invoice.base_tax_amount, 0), 2) = ROUND(IFNULL(tax.base_amount, 0), 2)")
            ->group("tax.code")
        ;

        $results = $select->query()->fetchAll();
        $taxByRate = [];
        foreach ($results as $result) {
            $taxByRate[$result['code']] = new Varien_Object($result);
        }

        return $taxByRate;
    }

// <NAME> Tag NEW_METHOD

}
{'fraction_non_alphanumeric': 0.15764331210191082, 'fraction_numerical': 0.0050424628450106155, 'mean_word_length': 2.3532028469750887, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6273604', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1190, 'n_words': 229}