Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3666078
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:50:14+00:00 2026-05-19T01:50:14+00:00

Our client has a Magento-powered store and needs the ability to create tax reports

  • 0

Our client has a Magento-powered store and needs the ability to create tax reports based on a specified date-range with a break down of how many much was refunded via credits.

Essentially they want a table that looks like this.

To save time, and since they only need these reports twice a year, I really don’t want to build it within Magento. Instead, I’m opting to just create a script to search through the MySQL tables based on the date range. I constructed what I thought should be a query to gather the necessary numbers from the database. Since they only charge sales tax in the state of Texas, I grouped the taxed and non-taxed pieces together using the boolean expression: fi.tax_amount > 0. I’m referencing the following tables in my query:

  1. mag_sales_flat_order: used to indicate order date ranges (identified as fo in MySQL query)
  2. mag_sales_flat_invoice: table containing all the actual invoice data (identified as fi in MySQL query)
  3. mag_sales_flat_creditmemo: table containing all the credit memo data (identified as fc in MySQL query)

Most of the fields seem to be okay, but I keep getting numbers showing that the credits for shipping tax exceed the shipping tax for the gross. Perhaps I’m using the wrong fields in my query or doing something else incorrectly. Here is the query I’m using:

SELECT 
    fi.tax_amount > 0 as `taxed`, 
    sum(fi.grand_total) as `sales_total`,
    sum(fi.tax_amount) as `sales_tax`, 
    sum(fi.shipping_tax_amount) as `shipping_tax`, 
    sum(fc.grand_total) as `credit_total`, 
    sum(fc.tax_amount) as `credit_sales_tax`,
    sum(fc.shipping_tax_amount) as `credit_shipping_tax`    
FROM 
    `mag_sales_flat_invoice` fi 
LEFT JOIN 
    `mag_sales_flat_order` fo ON fo.entity_id = fi.order_id     
LEFT JOIN 
    `mag_sales_flat_creditmemo` fc ON fc.order_id = fi.order_id 
WHERE     
    fo.created_at <= '2010-12-31 00:00:00' AND 
    fo.created_at >= '2010-07-01 00:00:00'     
GROUP BY
    fi.tax_amount > 0

Does anybody have any clue as to what I’m doing wrong? Let me know if you need any more information.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:50:15+00:00Added an answer on May 19, 2026 at 1:50 am

    Figured out my problem. It wasn’t the actual numbers returned from Magento I was having problems with. I had switched the order of 2 numbers in the calculation and it got me confused. For those interested in my solution, I’ve posted it here: Annual Tax Reports based on a Magento 1.4.1.0+ store

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our application runs off MySQL, but a client has another application that requires SQL.
At one of our client's site we have the following topology of BizTalk 2006
We are trying to come up with our client and server standard and there
We have developed our website(Business users website) in .net Framework 2.0 Our client us
We need to build an administration portal website to support our client/server application. Since
I'm thinking about exploring the idea of having our client software run as a
We're about to start a new project, and our client's current application is .NET
I build websites for a small-ish media company. Unfortunately, around 45-50% of our client
I am investigating GDI leaks issue in one of our smart-client application. I am
Our rails app is designed as a single code base linking to multiple client

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.