---
url: /gst-manager-acellemail/guides/apply-core-patches.md
description: >-
  A step-by-step guide to applying GST Manager's one-time core hook points in
  AcelleMail over SSH — what the script changes, how to run and verify it, and
  why you must re-run it after every AcelleMail upgrade.
---

# Apply the core hook points

GST Manager needs **four small, one-time extension points** in your AcelleMail installation. They
let the plugin slot into AcelleMail's invoicing flow — and one of them is a plain tax-calculation
fix. Without them the plugin still activates, but its GST features stay silent: invoices don't get
the GST PDF, the GSTIN field doesn't appear, export numbers aren't assigned, and — most
importantly — **tax isn't added to what your customers are charged**.

You apply them once, over SSH, with a script the plugin ships. The script is **idempotent**, so
running it again is always safe.

::: warning This step is required
GST Manager cannot work correctly until you run this. In particular, until the tax hook is in
place AcelleMail bills the **pre-tax subtotal**, so your **Default GST rate** has no effect on the
amount charged.
:::

## What it changes

The script adds four extension points to your AcelleMail code:

1. **Export invoice numbering** — when an export invoice is paid, the plugin can assign it an
   `EXP-YYYY-N` number in its own sequence.
2. **The GST invoice PDF** — invoice downloads (both admin and customer) render the plugin's
   GST-aware **Tax Invoice** / **Export Invoice** instead of the stock AcelleMail PDF while the
   plugin is active.
3. **The GSTIN field on the contact form** — the GSTIN capture-and-validation field appears next to
   the customer's Tax ID field on their contact page.
4. **Tax on order totals** — the configured tax is actually added to the order total. This is a
   correctness fix in AcelleMail's own total calculation; without it every tax rate you set is
   cosmetic and customers are undercharged.

## Before you run it

* **SSH access** to the server that runs AcelleMail.
* **The plugin files already on disk.** The patcher ships *inside* the plugin, so upload the plugin
  first — **Admin → Plugins → Upload Plugin** extracts it to
  `storage/app/plugins/relyweb/gstmanager/`. You don't have to activate it yet; the files just need
  to be present.
* **PHP on the command line.** The patcher is pure PHP — there's no python or other dependency.
* **A backup.** The script edits a handful of AcelleMail core files **in place** and does not keep
  its own backup. Snapshot your AcelleMail files (or make sure your normal backup is current) before
  you run it.

## Run the patcher

From your **AcelleMail Laravel root** — the directory that contains `artisan` and `composer.json`:

```bash
cd /path/to/acellemail
./storage/app/plugins/relyweb/gstmanager/scripts/apply-core-patches.sh .
```

The trailing `.` tells the script that your current directory is the AcelleMail root. If the shell
wrapper isn't executable on your host, call the PHP file directly — it does exactly the same thing:

```bash
php storage/app/plugins/relyweb/gstmanager/scripts/apply-core-patches.php .
```

## What you'll see

The script prints one line per file it touches:

* `✓ <file>` — patched successfully.
* `↺ <file> (already patched)` — the hook was already there, so nothing changed.
* `<file> not found, skipping` — that file isn't part of your build, which is usually fine.

It finishes with a reminder to clear AcelleMail's caches. Run those two commands so the changes take
effect:

```bash
php artisan view:clear && php artisan route:clear
```

## Verify it worked

Every patched section is tagged with a `gstmgr:hook` marker comment — that marker is also how the
script knows not to patch the same file twice. Once you've activated and licensed the plugin,
confirm the visible results:

* The **GSTIN field** appears on a customer's contact page, next to their Tax ID.
* Downloading an invoice produces the **GST invoice PDF** (Tax Invoice / Export Invoice), not the
  stock one.
* A new order's **total includes tax** at your configured rate.
* An invoice for a customer outside India receives an **EXP-YYYY-N** export number.

## It's safe to re-run

The patcher is **idempotent**. Because every change is fenced with the `gstmgr:hook` marker, a second
run reports `already patched` and changes nothing. If you're ever unsure whether it ran, just run it
again — you can't apply it twice.

## Re-run after every AcelleMail upgrade

::: warning Crucial — don't skip this
An AcelleMail core upgrade can **overwrite the files these hooks live in**, silently removing them.
The plugin keeps loading, but the GST PDF, the GSTIN field, export numbering, and tax-on-totals
quietly stop working. **After any AcelleMail upgrade, run the same command again** and clear the
caches. Because it's idempotent, it only re-applies whatever the upgrade removed.
:::

## If it can't apply a patch

* **`Not an AcelleMail root: …`** — you're in the wrong directory. Run the command from the folder
  that contains `artisan`, passing `.` as shown above.
* **`ERROR: could not patch <file>`** — a core file isn't the shape the patcher expects (an unusual
  or much newer AcelleMail build). Nothing is changed. Contact **support@relyweb.co** with your
  AcelleMail version.
* **Permission denied / cannot write** — run the command as a user that can edit the AcelleMail core
  files (usually the user that owns them), then run it again.
* **GST features still don't appear after activating** — you most likely skipped the cache clear, or
  a recent AcelleMail upgrade removed the hooks. Run the patcher again, then
  `php artisan view:clear && php artisan route:clear`.

## Related pages

* [Installation](/gst-manager-acellemail/installation) — where this step fits in the full setup
* [Requirements](/gst-manager-acellemail/requirements) — SSH access and the ionCube Loader
* [Troubleshooting](/gst-manager-acellemail/troubleshooting) — when GST features don't appear
* [How GST is applied](/gst-manager-acellemail/features/gst-classification) — what the tax hook enables
