按客户分组发票
我试图按他们的增值税 ID 对所有客户进行分组,并显示向他们开具了多少税款,所以我的结果应该如下所示,
TAXVAT | Tax Sum
ATU321 | 365.50
ATU123 | 120.00
但我对 magento 的 groupBy 功能很困惑,我尝试了这个:
$objInvoiceCollection = Mage::getModel('sales/order/invoice')->getCollection();
$objInvoiceCollection
->addAttributeToSelect('customer_taxvat');
->addExpressionAttributeToSelect('tax_invoiced','SUM({{tax_invoiced}})','tax')
->addFieldToFilter('customer_taxvat', array('notnull'=>true))
->addFieldToFilter('tax_invoiced', array('notnull'=>true))
->groupByAttribute('customer_taxvat');
但是我收到此错误:
Call to undefined method Mage_Sales_Model_Resource_Order_Collection::addExpressionAttributeToSelect() ...
我认为每个基于 eav 的模型都提供方法 addAttributeToSelect 和 groupByAttribute - 但显然在我的情况下这不是真的:(
I'm trying to group all customers by their tax-vat id and show how much tax was invoiced to them, so my result should look like this
TAXVAT | Tax Sum
ATU321 | 365.50
ATU123 | 120.00
but I'm pretty stuck with the groupBy function of magento, i tried this:
$objInvoiceCollection = Mage::getModel('sales/order/invoice')->getCollection();
$objInvoiceCollection
->addAttributeToSelect('customer_taxvat');
->addExpressionAttributeToSelect('tax_invoiced','SUM({{tax_invoiced}})','tax')
->addFieldToFilter('customer_taxvat', array('notnull'=>true))
->addFieldToFilter('tax_invoiced', array('notnull'=>true))
->groupByAttribute('customer_taxvat');
but i get this error:
Call to undefined method Mage_Sales_Model_Resource_Order_Collection::addExpressionAttributeToSelect() ...
I thought every eav-based model provides the methods addAttributeToSelect and groupByAttribute - but obviously thats not true in my case :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Magento 在几个版本之前就停止使用 EAV 来存储销售情况。此外,customer_taxvat 不存储为发票的一部分,而是存储为订单的一部分。
您可以通过以下方式获得相同的结果:
Magento stopped using EAV for storing sales several versions ago. Also, the customer_taxvat is not stored as part of the invoice, but as part of the order.
You can get the same results this way: