@codemind.ec/medusa-plugin-invoice 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # @codemind.ec/medusa-plugin-invoice
2
+
3
+ Invoice & quotation **PDF widget** for the Medusa v2 admin dashboard — download order receipts and manage company billing configuration.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@codemind.ec/medusa-plugin-invoice.svg)](https://www.npmjs.com/package/@codemind.ec/medusa-plugin-invoice)
6
+ [![Medusa v2](https://img.shields.io/badge/medusa-v2-blueviolet)](https://docs.medusajs.com)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ ---
10
+
11
+ ## Features
12
+
13
+ - **Order invoice widget** — "Download Receipt" button injected into the order detail sidebar in the Medusa admin.
14
+ - **PDF generation** — fetches and downloads invoices as PDF files (`comprobante-pedido-{orderId}.pdf`).
15
+ - **Invoice config page** — admin route for managing billing/invoicing settings.
16
+ - **Medusa SDK integration** — uses the official `@medusajs/js-sdk` for authenticated API calls.
17
+
18
+ ---
19
+
20
+ ## Prerequisites
21
+
22
+ | Requirement | Version |
23
+ |-------------|---------|
24
+ | Node.js | >= 20 |
25
+ | Medusa | >= 2.4.0 |
26
+
27
+ ---
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ npm install @codemind.ec/medusa-plugin-invoice
33
+ # or
34
+ pnpm add @codemind.ec/medusa-plugin-invoice
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Configuration
40
+
41
+ Add the plugin to your `medusa-config.ts`:
42
+
43
+ ```typescript
44
+ import { defineConfig } from "@medusajs/framework/utils"
45
+
46
+ export default defineConfig({
47
+ // ...
48
+ plugins: [
49
+ {
50
+ resolve: "@codemind.ec/medusa-plugin-invoice",
51
+ options: {},
52
+ },
53
+ ],
54
+ })
55
+ ```
56
+
57
+ No environment variables are required. The admin widget uses `VITE_BACKEND_URL` if set, otherwise defaults to `"/"`.
58
+
59
+ ---
60
+
61
+ ## Admin UI
62
+
63
+ ### Order Invoice Widget
64
+
65
+ **Zone:** `order.details.side.before`
66
+
67
+ When viewing an order in the Medusa admin, a widget appears in the sidebar with a **"Descargar Comprobante"** (Download Receipt) button. Clicking it:
68
+
69
+ 1. Calls `GET /admin/orders/{orderId}/invoices`
70
+ 2. Downloads the response as a PDF file
71
+ 3. Filename: `comprobante-pedido-{orderId}.pdf`
72
+
73
+ ### Invoice Configuration Page
74
+
75
+ **Route:** `/invoice-config`
76
+
77
+ A dedicated admin page for managing company billing and invoicing settings.
78
+
79
+ ---
80
+
81
+ ## Architecture
82
+
83
+ This is an **admin-only** plugin — it does not register backend modules, API routes, or database models. It provides:
84
+
85
+ | Component | Location | Purpose |
86
+ |-----------|----------|---------|
87
+ | Order widget | `widgets/order-invoice.tsx` | PDF download button in order sidebar |
88
+ | Config page | `routes/invoice-config/page.tsx` | Billing configuration UI |
89
+ | SDK client | `lib/sdk.ts` | Authenticated Medusa client for API calls |
90
+
91
+ The PDF generation endpoint (`/admin/orders/:id/invoices`) should be provided by your Medusa backend (e.g., via a custom API route or another plugin).
92
+
93
+ ---
94
+
95
+ ## SDK Configuration
96
+
97
+ The built-in SDK client is pre-configured for the admin:
98
+
99
+ ```typescript
100
+ import Medusa from "@medusajs/js-sdk"
101
+
102
+ const sdk = new Medusa({
103
+ baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
104
+ debug: import.meta.env.DEV,
105
+ auth: { type: "session" },
106
+ })
107
+ ```
108
+
109
+ ---
110
+
111
+ ## License
112
+
113
+ MIT — [CodeMind](https://codemind.ec)
package/package.json CHANGED
@@ -1,69 +1,72 @@
1
1
  {
2
- "name": "@codemind.ec/medusa-plugin-invoice",
3
- "version": "1.0.0",
4
- "description": "Invoice & quotation PDF widget for Medusa v2 admin — download order receipts and manage company billing config.",
5
- "author": "Kollor <dev@codemind.ec> (https://codemind.ec)",
6
- "license": "MIT",
7
- "files": [
8
- ".medusa/server"
9
- ],
10
- "exports": {
11
- "./package.json": "./package.json",
12
- "./admin": {
13
- "import": "./.medusa/server/src/admin/index.mjs",
14
- "require": "./.medusa/server/src/admin/index.js",
15
- "default": "./.medusa/server/src/admin/index.js"
16
- }
17
- },
18
- "keywords": [
19
- "medusa",
20
- "medusa-plugin",
21
- "medusa-v2",
22
- "plugin",
23
- "invoice",
24
- "pdf",
25
- "comprobante",
26
- "codemind",
27
- "kollor"
28
- ],
29
- "scripts": {
30
- "build": "medusa plugin:build",
31
- "dev": "medusa plugin:develop",
32
- "prepublishOnly": "medusa plugin:build"
33
- },
34
- "devDependencies": {
35
- "@medusajs/admin-sdk": "2.13.3",
36
- "@medusajs/admin-shared": "2.13.3",
37
- "@medusajs/cli": "2.13.3",
38
- "@medusajs/framework": "2.13.3",
39
- "@medusajs/icons": "^2.13.3",
40
- "@medusajs/js-sdk": "^2.13.3",
41
- "@medusajs/medusa": "2.13.3",
42
- "@medusajs/test-utils": "2.13.3",
43
- "@medusajs/ui": "^4.1.3",
44
- "@swc/core": "^1.7.28",
45
- "@tanstack/react-query": "^5.64.2",
46
- "@types/node": "^20",
47
- "@types/react": "^18.3.3",
48
- "@types/react-dom": "^18.3.0",
49
- "prop-types": "^15.8.1",
50
- "react": "^18.3.1",
51
- "react-dom": "^18.3.1",
52
- "react-hook-form": "^7.54.2",
53
- "ts-node": "^10.9.2",
54
- "typescript": "^5",
55
- "vite": "^5.4.14"
56
- },
57
- "peerDependencies": {
58
- "@medusajs/admin-sdk": "2.13.3",
59
- "@medusajs/cli": "2.13.3",
60
- "@medusajs/framework": "2.13.3",
61
- "@medusajs/icons": "^2.13.3",
62
- "@medusajs/medusa": "2.13.3",
63
- "@medusajs/test-utils": "2.13.3",
64
- "@medusajs/ui": "^4.1.3"
65
- },
66
- "engines": {
67
- "node": ">=20"
2
+ "name": "@codemind.ec/medusa-plugin-invoice",
3
+ "version": "1.0.1",
4
+ "description": "Invoice & quotation PDF widget for Medusa v2 admin — download order receipts and manage company billing config.",
5
+ "author": "Kollor <dev@codemind.ec> (https://codemind.ec)",
6
+ "license": "MIT",
7
+ "files": [
8
+ ".medusa/server"
9
+ ],
10
+ "exports": {
11
+ "./package.json": "./package.json",
12
+ "./admin": {
13
+ "import": "./.medusa/server/src/admin/index.mjs",
14
+ "require": "./.medusa/server/src/admin/index.js",
15
+ "default": "./.medusa/server/src/admin/index.js"
68
16
  }
69
- }
17
+ },
18
+ "keywords": [
19
+ "medusa",
20
+ "medusa-plugin",
21
+ "medusa-v2",
22
+ "plugin",
23
+ "invoice",
24
+ "pdf",
25
+ "comprobante",
26
+ "codemind",
27
+ "kollor"
28
+ ],
29
+ "devDependencies": {
30
+ "@codemirror/lang-html": "^6.4.11",
31
+ "@codemirror/theme-one-dark": "^6.1.3",
32
+ "@medusajs/admin-sdk": "2.13.3",
33
+ "@medusajs/admin-shared": "2.13.3",
34
+ "@medusajs/cli": "2.13.3",
35
+ "@medusajs/framework": "2.13.3",
36
+ "@medusajs/icons": "^2.13.3",
37
+ "@medusajs/js-sdk": "^2.13.3",
38
+ "@medusajs/medusa": "2.13.3",
39
+ "@medusajs/test-utils": "2.13.3",
40
+ "@medusajs/ui": "^4.1.3",
41
+ "@swc/core": "^1.7.28",
42
+ "@tanstack/react-query": "^5.64.2",
43
+ "@types/node": "^20",
44
+ "@types/react": "^18.3.3",
45
+ "@types/react-dom": "^18.3.0",
46
+ "@uiw/react-codemirror": "^4.25.8",
47
+ "handlebars": "^4.7.8",
48
+ "prop-types": "^15.8.1",
49
+ "react": "^18.3.1",
50
+ "react-dom": "^18.3.1",
51
+ "react-hook-form": "^7.54.2",
52
+ "ts-node": "^10.9.2",
53
+ "typescript": "^5",
54
+ "vite": "^5.4.14"
55
+ },
56
+ "peerDependencies": {
57
+ "@medusajs/admin-sdk": "2.13.3",
58
+ "@medusajs/cli": "2.13.3",
59
+ "@medusajs/framework": "2.13.3",
60
+ "@medusajs/icons": "^2.13.3",
61
+ "@medusajs/medusa": "2.13.3",
62
+ "@medusajs/test-utils": "2.13.3",
63
+ "@medusajs/ui": "^4.1.3"
64
+ },
65
+ "engines": {
66
+ "node": ">=20"
67
+ },
68
+ "scripts": {
69
+ "build": "medusa plugin:build",
70
+ "dev": "medusa plugin:develop"
71
+ }
72
+ }