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

  • SEARCH
  • Home
  • 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

We've built a javascript based widget that our client has embedded in their website.
Our client-server product has the protocol between them as XML over HTTP. Here, the
In our client's website , favicon.ico file has several sizes from 8x8 to 32x32.
Our application runs off MySQL, but a client has another application that requires SQL.
this is quite a simple question hopefully. Our client currently has a Flash banner
our main client solution has 111 projects. When I first started on this team
I have a dillema where our client relations department has been brought in for
Our client wants to give us a database. The original database has a phone
Our client has an application that stores blobs in database which has now grown
I have a Drupal site, site.com , and our client has a campaign that

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.