Schedule MacroRIS-SM-2030 – TaxBreakdown

Tax Breakdown Report

Automatically calculate taxes (GST, PST, HST, Quebec PST) for processed orders, generate CSV reports, upload them to FTP, and send via email.

Overview

The RIS-SM-2030 –TaxBreakdown macro automates tax reporting for Canadian orders by calculating province-wise taxes and generating structured CSV reports.

It processes recent orders, handles refunds, and distributes reports via FTP and email—ensuring accurate and timely financial reporting.

Ensure province tax rates and FTP/SMTP configurations are correctly set before running this macro.

Purpose

This macro:

  • Calculates GST, PST, HST, and Quebec PST

  • Generates CSV tax reports

  • Uploads reports to FTP

  • Sends reports via email

👉 In short:
Calculate taxes → generate reports → share automatically.

When It Runs

Used for tax reporting and accounting

Typically runs:

  • Scheduled execution (recommended daily)

  • Manually triggered

Parameters

path
ProvinceTaxRatesstring
Required

GST, PST, HST values configured for each province.

path
portnumber
Required

SMTP port number.

path
usernamestring
Required

Email account username.

path
passwordstring
Required

Email account password.

path
fromEmailstring
Required

Sender email address.

path
toEmailstring
Required

Recipient email address.

The macro processes only recently processed orders (last 1 day).

How It Works

Fetch Processed Orders

Retrieve processed orders from the last 24 hours.

Fetch Refund Data

Retrieve refund orders for adjustment calculations.

Split by Currency

Separate orders into USD and CAD groups.

Prepare CSV Structure

Define headers and format for report generation.

Calculate Taxes

Apply province-wise tax rules:

  • GST

  • PST

  • HST

  • Quebec PST

Handle Refunds

Convert refund values to negative and adjust totals.

Build CSV Rows

Create one row per order with calculated values.

Calculate Totals

Summarize totals at the end of each report.

Upload to FTP

Upload generated USD and CAD CSV files to FTP server.

Send Email Reports

Send reports as email attachments to recipients.

Log Execution

Record processing status, success, and errors.

Final Result

  • Taxes calculated for all eligible orders

  • CSV reports generated for USD and CAD

  • Files uploaded to FTP server

  • Email sent with report attachments

  • Execution logs available for tracking

Usefulness

This macro is highly beneficial for:

  • Automating tax reporting

  • Ensuring accurate tax calculations

  • Handling refunds correctly

  • Reducing manual accounting effort

  • Providing ready-to-use financial reports

Important Notes

  • Processes only recent orders (last 1 day)

  • Requires accurate province tax configuration

  • Depends on correct province data in orders

  • Refund matching is based on Order ID

  • FTP and email credentials must be secured

  • No retry mechanism for failed email delivery

  • Large datasets may impact performance

Example Scenario

Key Insight

By automating province-wise tax calculations and report distribution, this macro ensures compliance with Canadian tax regulations while significantly reducing manual accounting effort.