=== MyInvois e-Invoice for WooCommerce ===
Contributors: catcodestudio
Tags: myinvois, e-invoice, malaysia, lhdn, woocommerce
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sends WooCommerce orders to LHDN MyInvois as e-Invoices: submit from the order, track the status, share the validation link.

== Description ==

Malaysian businesses issue e-Invoices through the **MyInvois** system of the Inland Revenue Board (LHDN). This plugin connects your WooCommerce shop to it, using the public MyInvois SDK (sdk.myinvois.hasil.gov.my) and your own client ID and secret:

* **Submit an order from its screen** — one button builds the invoice (UBL 2.1, JSON, document version 1.0) from the order and sends it. Products, shipping and fees become lines; discounts, tax rates and totals are taken from the order.
* **Status and validation link** — MyInvois validates asynchronously. The plugin looks again by itself and shows Submitted, Valid or Invalid; for a valid document it shows the public validation link, and for an invalid one the reasons LHDN gave.
* **Sandbox and production** — the sandbox (preprod) is the default. Switching to production is one setting; a document sent to the sandbox does not count in production.
* **Buyer TIN** — optional fields at the checkout (classic and block checkout) and in the order box: TIN, ID type and ID number. When the data is incomplete, the message names exactly what is missing.
* **Your business data** — name, TIN, registration number, MSIC code, SST and tourism-tax numbers, address, state — all entered by you; nothing is guessed.
* **Order list column** with the e-Invoice status. HPOS (custom order tables) supported.
// @pro-begin
* Malay (Bahasa Melayu) translation included.
// @pro-end

This version does not sign documents: it sends document version 1.0, which the SDK describes as "available for submission of documents without digital signature validation". Check with your tax adviser whether that is enough for your business.

// @pro-begin
= Pro =

The Pro version is sold on [catcode.com.ua](https://catcode.com.ua/modules/myinvois-woocommerce/), with a 7-day trial that never starts by itself:

* **Automatic submission** when an order is completed.
* **Refund notes** for WooCommerce refunds, pointing to the original invoice.
* **Cancel** an e-Invoice from the order screen (LHDN allows it within 72 hours of validation).
* **Buyer TIN check** with LHDN before the document is sent.
* **Monthly consolidated e-Invoice** for the orders of buyers who gave no TIN.
* **Orders in other currencies**, with the exchange rates you enter.
* **Bulk action** in the orders list.

The licence runs for 1-5 years and includes updates and support for that term; a purchased licence keeps its Pro features after the term ends.
// @pro-end

= Not tax advice =

The plugin builds the documents from your settings and your orders. Which classification code, tax type and exemption applies is for you and your tax adviser to decide. MyInvois is a system of LHDN; this plugin is not made or endorsed by LHDN.

== Installation ==

1. Install and activate the plugin. WooCommerce must be active.
2. In the MyInvois sandbox portal register your system and copy the client ID and secret to WooCommerce → MyInvois. Fill in your business data and use "Test the connection".
3. Open an order, enter the buyer TIN and ID number if the buyer gave them, and press "Submit e-Invoice".

== Frequently Asked Questions ==

= Do I need credentials from LHDN? =

Yes. Every taxpayer registers their own system in the MyInvois portal and gets a client ID and secret there. The sandbox and the production portal issue different credentials.

= Which document format is sent? =

UBL 2.1 as JSON, document version 1.0 (unsigned), submitted with the Submit Documents API.

= An order has no buyer TIN. What happens? =

The document cannot be built for that order: the message names what is missing.
// @pro-begin
In Pro you can switch on the monthly consolidated e-Invoice for such orders.
// @pro-end

= Why was my document marked Invalid? =

LHDN checks every document after the submission. The order box and the order notes show the reasons LHDN returned; fix the data and submit again.

== Changelog ==

= 1.0.0 =
* First release: submit orders to MyInvois (sandbox and production), status and validation link, buyer TIN fields, order column.
// @pro-begin
* Malay translation.
// @pro-end
