@awadheshs109/billing 1.0.29 → 2.0.12
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 +136 -132
- package/dist/index.d.mts +128 -46
- package/dist/index.d.ts +128 -46
- package/dist/index.js +941 -106
- package/dist/index.mjs +928 -106
- package/package.json +14 -8
package/README.md
CHANGED
|
@@ -1,227 +1,231 @@
|
|
|
1
1
|
# Zentris Billing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Modern TypeScript billing & invoice generation library for Angular, React, Vue, Node.js and JavaScript applications.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Generate professional invoices in:
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
✅ PDF export
|
|
12
|
-
✅ CSV export
|
|
13
|
-
✅ JSON export
|
|
14
|
-
✅ HTML invoice templates
|
|
15
|
-
✅ Browser + Node support
|
|
16
|
-
✅ CI/CD npm publishing
|
|
7
|
+
- HTML
|
|
8
|
+
- PDF
|
|
9
|
+
- CSV
|
|
10
|
+
- JSON
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install @awadheshs109/billing
|
|
24
|
-
```
|
|
12
|
+
Supports GST invoices, tax calculation, discounts, payment tracking, invoice templates and multi-framework integration.
|
|
25
13
|
|
|
26
14
|
---
|
|
27
15
|
|
|
28
|
-
##
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- TypeScript-first architecture
|
|
19
|
+
- Framework independent
|
|
20
|
+
- GST & tax calculation utilities
|
|
21
|
+
- Invoice summary calculations
|
|
22
|
+
- Professional HTML invoice templates
|
|
23
|
+
- PDF invoice generation using Puppeteer
|
|
24
|
+
- CSV & JSON export support
|
|
25
|
+
- Multi-payment transaction support
|
|
26
|
+
- Currency formatting
|
|
27
|
+
- Custom branding & themes
|
|
28
|
+
- Lightweight API
|
|
29
|
+
- ESM + CommonJS support
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
---
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
## Installation
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
```bash
|
|
36
|
+
npm install @awadheshs109/billing
|
|
38
37
|
```
|
|
39
38
|
|
|
40
39
|
---
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
## Quick Example
|
|
43
42
|
|
|
44
43
|
```ts
|
|
45
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
InvoiceGenerator
|
|
46
|
+
} from "@awadheshs109/billing";
|
|
46
47
|
|
|
47
48
|
const invoice = {
|
|
48
49
|
invoiceNo: "INV-1001",
|
|
49
50
|
|
|
50
|
-
date: "
|
|
51
|
+
date: "25-05-2026",
|
|
52
|
+
|
|
53
|
+
currency: "INR",
|
|
51
54
|
|
|
52
55
|
company: {
|
|
53
56
|
name: "Zentris Pvt Ltd",
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
phone: "+91 999999999",
|
|
57
|
+
address: "Mumbai, India",
|
|
58
|
+
phone: "+91 9999999999"
|
|
58
59
|
},
|
|
59
60
|
|
|
60
61
|
customer: {
|
|
61
|
-
name: "
|
|
62
|
-
|
|
63
|
-
company: "Client Company",
|
|
64
|
-
|
|
65
|
-
address: "Bangalore",
|
|
62
|
+
name: "Rahul Verma",
|
|
63
|
+
email: "rahul@example.com"
|
|
66
64
|
},
|
|
67
65
|
|
|
68
66
|
items: [
|
|
69
67
|
{
|
|
70
|
-
description: "Angular
|
|
71
|
-
|
|
72
|
-
quantity: 5,
|
|
73
|
-
|
|
74
|
-
rate: 75,
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
description: "Invoice Setup",
|
|
79
|
-
|
|
68
|
+
description: "Angular Dashboard",
|
|
80
69
|
quantity: 2,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
},
|
|
70
|
+
rate: 12000
|
|
71
|
+
}
|
|
84
72
|
],
|
|
85
73
|
|
|
86
74
|
tax: 18,
|
|
87
|
-
|
|
88
|
-
discount: 5,
|
|
75
|
+
discount: 5
|
|
89
76
|
};
|
|
77
|
+
|
|
78
|
+
const html =
|
|
79
|
+
InvoiceGenerator.toHTML(invoice);
|
|
80
|
+
|
|
81
|
+
console.log(html);
|
|
90
82
|
```
|
|
91
83
|
|
|
92
84
|
---
|
|
93
85
|
|
|
94
|
-
|
|
86
|
+
## Generate PDF
|
|
95
87
|
|
|
96
88
|
```ts
|
|
97
|
-
|
|
89
|
+
import fs from "node:fs";
|
|
90
|
+
|
|
91
|
+
const pdf =
|
|
92
|
+
await InvoiceGenerator.toPDF(invoice);
|
|
93
|
+
|
|
94
|
+
fs.writeFileSync(
|
|
95
|
+
"invoice.pdf",
|
|
96
|
+
pdf
|
|
97
|
+
);
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
---
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
## Generate GST Invoice Template
|
|
103
103
|
|
|
104
104
|
```ts
|
|
105
|
-
const
|
|
105
|
+
const html =
|
|
106
|
+
InvoiceGenerator.toHTML(
|
|
107
|
+
invoice,
|
|
108
|
+
{
|
|
109
|
+
template: "gst"
|
|
110
|
+
}
|
|
111
|
+
);
|
|
106
112
|
```
|
|
107
113
|
|
|
108
114
|
---
|
|
109
115
|
|
|
110
|
-
|
|
116
|
+
## Export Formats
|
|
117
|
+
|
|
118
|
+
### HTML
|
|
111
119
|
|
|
112
120
|
```ts
|
|
113
|
-
|
|
121
|
+
InvoiceGenerator.toHTML(invoice);
|
|
114
122
|
```
|
|
115
123
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
# Generate PDF
|
|
124
|
+
### PDF
|
|
119
125
|
|
|
120
126
|
```ts
|
|
121
|
-
|
|
127
|
+
await InvoiceGenerator.toPDF(invoice);
|
|
122
128
|
```
|
|
123
129
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
# Save PDF in Node
|
|
130
|
+
### CSV
|
|
127
131
|
|
|
128
132
|
```ts
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const pdf = InvoiceGenerator.toPDF(invoice);
|
|
133
|
+
InvoiceGenerator.toCSV(invoice);
|
|
134
|
+
```
|
|
132
135
|
|
|
133
|
-
|
|
136
|
+
### JSON
|
|
134
137
|
|
|
135
|
-
|
|
138
|
+
```ts
|
|
139
|
+
InvoiceGenerator.toJSON(invoice);
|
|
136
140
|
```
|
|
137
141
|
|
|
138
142
|
---
|
|
139
143
|
|
|
140
|
-
##
|
|
144
|
+
## Tax Utilities
|
|
141
145
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
| calculateGST(amount,tax) | Calculate GST |
|
|
147
|
-
| calculateDiscount(amount,discount) | Calculate discount |
|
|
148
|
-
| formatCurrency(amount,currency) | Currency formatter |
|
|
149
|
-
|
|
150
|
-
---
|
|
146
|
+
```ts
|
|
147
|
+
import {
|
|
148
|
+
Billing
|
|
149
|
+
} from "@awadheshs109/billing";
|
|
151
150
|
|
|
152
|
-
|
|
151
|
+
const gst =
|
|
152
|
+
Billing.calculateGST(
|
|
153
|
+
1000,
|
|
154
|
+
18
|
|
155
|
+
);
|
|
153
156
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
| toHTML() | Generate invoice HTML |
|
|
157
|
-
| toCSV() | Export CSV |
|
|
158
|
-
| toJSON() | Export JSON |
|
|
159
|
-
| toPDF() | Export PDF |
|
|
157
|
+
console.log(gst);
|
|
158
|
+
```
|
|
160
159
|
|
|
161
160
|
---
|
|
162
161
|
|
|
163
|
-
##
|
|
162
|
+
## Currency Formatting
|
|
164
163
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
```ts
|
|
165
|
+
Billing.formatCurrency(
|
|
166
|
+
15000,
|
|
167
|
+
"INR"
|
|
168
|
+
);
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
npm run test:run
|
|
175
|
-
```
|
|
171
|
+
---
|
|
176
172
|
|
|
177
|
-
|
|
173
|
+
## Supported Frameworks
|
|
178
174
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
175
|
+
- Angular
|
|
176
|
+
- React
|
|
177
|
+
- Vue
|
|
178
|
+
- Next.js
|
|
179
|
+
- Node.js
|
|
180
|
+
- Express
|
|
181
|
+
- NestJS
|
|
182
|
+
- Vanilla JavaScript
|
|
182
183
|
|
|
183
184
|
---
|
|
184
185
|
|
|
185
|
-
##
|
|
186
|
+
## Invoice Templates
|
|
186
187
|
|
|
187
|
-
|
|
188
|
+
### Classic Template
|
|
188
189
|
|
|
189
|
-
|
|
190
|
-
npm version patch --no-git-tag-version
|
|
191
|
-
```
|
|
190
|
+
Professional clean invoice layout.
|
|
192
191
|
|
|
193
|
-
|
|
192
|
+
### GST Template
|
|
194
193
|
|
|
195
|
-
|
|
196
|
-
git add .
|
|
197
|
-
git commit -m "development: add feature"
|
|
198
|
-
```
|
|
194
|
+
Indian GST-compliant invoice design.
|
|
199
195
|
|
|
200
|
-
|
|
196
|
+
---
|
|
201
197
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
198
|
+
## Package Exports
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
import {
|
|
202
|
+
InvoiceGenerator,
|
|
203
|
+
Billing,
|
|
204
|
+
TAX_RATES,
|
|
205
|
+
VERSION
|
|
206
|
+
} from "@awadheshs109/billing";
|
|
206
207
|
```
|
|
207
208
|
|
|
208
|
-
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Version
|
|
209
212
|
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
→ test
|
|
213
|
-
→ publish npm
|
|
213
|
+
```ts
|
|
214
|
+
console.log(VERSION);
|
|
214
215
|
```
|
|
215
216
|
|
|
216
217
|
---
|
|
217
218
|
|
|
218
|
-
##
|
|
219
|
-
|
|
220
|
-
See:
|
|
219
|
+
## Roadmap
|
|
221
220
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
- QR payment generation
|
|
222
|
+
- Razorpay integration
|
|
223
|
+
- UPI invoice QR
|
|
224
|
+
- Multi-language invoice support
|
|
225
|
+
- Thermal receipt template
|
|
226
|
+
- Email invoice sender
|
|
227
|
+
- React invoice viewer
|
|
228
|
+
- Angular invoice component
|
|
225
229
|
|
|
226
230
|
---
|
|
227
231
|
|
|
@@ -233,8 +237,8 @@ MIT
|
|
|
233
237
|
|
|
234
238
|
## Repository
|
|
235
239
|
|
|
236
|
-
:
|
|
237
|
-
|
|
238
|
-
Package:
|
|
240
|
+
GitHub:
|
|
241
|
+
https://github.com/Awadheshs109/zentris-billing
|
|
239
242
|
|
|
240
|
-
:
|
|
243
|
+
npm:
|
|
244
|
+
https://www.npmjs.com/package/@awadheshs109/billing
|
package/dist/index.d.mts
CHANGED
|
@@ -6,13 +6,23 @@ declare function calculateDiscount(amount: number, percent: number): number;
|
|
|
6
6
|
type CurrencyType = 'INR' | 'USD' | 'EUR' | 'GBP';
|
|
7
7
|
declare function formatCurrency(amount: number, currency?: CurrencyType): string;
|
|
8
8
|
|
|
9
|
+
interface BillingSummary {
|
|
10
|
+
subtotal: number;
|
|
11
|
+
taxAmount: number;
|
|
12
|
+
discountAmount: number;
|
|
13
|
+
total: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface InvoiceItem {
|
|
17
|
+
description: string;
|
|
18
|
+
quantity: number;
|
|
19
|
+
rate: number;
|
|
20
|
+
hsn?: string;
|
|
21
|
+
taxRate?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
9
24
|
declare class InvoiceCalculator {
|
|
10
|
-
static summary(items:
|
|
11
|
-
subtotal: any;
|
|
12
|
-
discount: number;
|
|
13
|
-
tax: number;
|
|
14
|
-
total: number;
|
|
15
|
-
};
|
|
25
|
+
static summary(items: InvoiceItem[], tax?: number, discount?: number): BillingSummary;
|
|
16
26
|
}
|
|
17
27
|
|
|
18
28
|
declare class Billing {
|
|
@@ -34,6 +44,20 @@ declare class InvoiceError extends Error {
|
|
|
34
44
|
constructor(message: string);
|
|
35
45
|
}
|
|
36
46
|
|
|
47
|
+
declare const TAX_RATES: {
|
|
48
|
+
readonly GST_5: 5;
|
|
49
|
+
readonly GST_12: 12;
|
|
50
|
+
readonly GST_18: 18;
|
|
51
|
+
readonly GST_28: 28;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
declare function formatDate(date?: Date, locale?: string): string;
|
|
55
|
+
declare function getCurrentTimestamp(): number;
|
|
56
|
+
|
|
57
|
+
declare function isValidEmail(email: string): boolean;
|
|
58
|
+
declare function isValidPhone(phone: string): boolean;
|
|
59
|
+
declare function isValidGST(gst: string): boolean;
|
|
60
|
+
|
|
37
61
|
interface Customer {
|
|
38
62
|
id?: string;
|
|
39
63
|
name: string;
|
|
@@ -43,31 +67,95 @@ interface Customer {
|
|
|
43
67
|
address?: string;
|
|
44
68
|
}
|
|
45
69
|
|
|
46
|
-
interface
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
70
|
+
interface BankDetails {
|
|
71
|
+
bankName: string;
|
|
72
|
+
accountName: string;
|
|
73
|
+
accountNumber: string;
|
|
74
|
+
ifscCode?: string;
|
|
75
|
+
upiId?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface Branch {
|
|
79
|
+
id?: string;
|
|
80
|
+
name: string;
|
|
81
|
+
address?: string;
|
|
82
|
+
phone?: string;
|
|
83
|
+
gstNumber?: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface Company {
|
|
87
|
+
name: string;
|
|
88
|
+
address: string;
|
|
89
|
+
phone: string;
|
|
90
|
+
email?: string;
|
|
91
|
+
gstNumber?: string;
|
|
92
|
+
panNumber?: string;
|
|
93
|
+
website?: string;
|
|
94
|
+
bankDetails?: BankDetails;
|
|
95
|
+
branches?: Branch[];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
type PaymentMode = "cash" | "upi" | "bank" | "mixed";
|
|
99
|
+
type PaymentStatus = "paid" | "partial" | "pending";
|
|
100
|
+
interface PaymentTransaction {
|
|
101
|
+
mode: string;
|
|
102
|
+
amount: number;
|
|
103
|
+
reference?: string;
|
|
104
|
+
}
|
|
105
|
+
interface Payment {
|
|
106
|
+
mode: PaymentMode;
|
|
107
|
+
paidAmount: number;
|
|
108
|
+
dueAmount: number;
|
|
109
|
+
status: PaymentStatus;
|
|
110
|
+
udhar: boolean;
|
|
111
|
+
transactions?: PaymentTransaction[];
|
|
50
112
|
}
|
|
51
113
|
|
|
114
|
+
interface InvoiceTheme {
|
|
115
|
+
primaryColor?: string;
|
|
116
|
+
accentColor?: string;
|
|
117
|
+
}
|
|
118
|
+
interface InvoiceBranding {
|
|
119
|
+
showSoftwareCredit?: boolean;
|
|
120
|
+
softwareCreditText?: string;
|
|
121
|
+
logoText?: string;
|
|
122
|
+
logoSubText?: string;
|
|
123
|
+
}
|
|
124
|
+
interface InvoiceFeatures {
|
|
125
|
+
showSellerGST?: boolean;
|
|
126
|
+
showBuyerGST?: boolean;
|
|
127
|
+
showPAN?: boolean;
|
|
128
|
+
showTransport?: boolean;
|
|
129
|
+
showEWay?: boolean;
|
|
130
|
+
showBankDetails?: boolean;
|
|
131
|
+
showTerms?: boolean;
|
|
132
|
+
showSignature?: boolean;
|
|
133
|
+
showSoftwareCredit?: boolean;
|
|
134
|
+
showBranchDetails?: boolean;
|
|
135
|
+
showPaymentDetails?: boolean;
|
|
136
|
+
showPaymentTransactions?: boolean;
|
|
137
|
+
showAmountWords?: boolean;
|
|
138
|
+
}
|
|
52
139
|
interface Invoice {
|
|
53
140
|
invoiceNo: string;
|
|
54
141
|
date: string;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
phone: string;
|
|
59
|
-
email?: string;
|
|
60
|
-
};
|
|
61
|
-
customer: {
|
|
62
|
-
name: string;
|
|
63
|
-
company?: string;
|
|
64
|
-
address: string;
|
|
65
|
-
email?: string;
|
|
66
|
-
};
|
|
142
|
+
dueDate?: string;
|
|
143
|
+
company: Company;
|
|
144
|
+
customer: Customer;
|
|
67
145
|
items: InvoiceItem[];
|
|
68
|
-
|
|
146
|
+
payment?: Payment;
|
|
147
|
+
features?: InvoiceFeatures;
|
|
148
|
+
branding?: InvoiceBranding;
|
|
149
|
+
theme?: InvoiceTheme;
|
|
69
150
|
tax?: number;
|
|
151
|
+
discount?: number;
|
|
152
|
+
transport?: string;
|
|
153
|
+
eway?: string;
|
|
154
|
+
amountWords?: string;
|
|
70
155
|
notes?: string;
|
|
156
|
+
signature?: string;
|
|
157
|
+
terms?: string[];
|
|
158
|
+
currency?: string;
|
|
71
159
|
}
|
|
72
160
|
|
|
73
161
|
interface Tax {
|
|
@@ -75,32 +163,26 @@ interface Tax {
|
|
|
75
163
|
rate: number;
|
|
76
164
|
}
|
|
77
165
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
taxAmount: number;
|
|
81
|
-
discountAmount: number;
|
|
82
|
-
total: number;
|
|
166
|
+
declare class InvoiceNormalizer {
|
|
167
|
+
static normalize(invoice: Partial<Invoice>): Invoice;
|
|
83
168
|
}
|
|
84
169
|
|
|
85
|
-
|
|
86
|
-
declare
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
declare function isValidPhone(phone: string): boolean;
|
|
90
|
-
declare function isValidGST(gst: string): boolean;
|
|
91
|
-
|
|
92
|
-
declare const TAX_RATES: {
|
|
93
|
-
readonly GST_5: 5;
|
|
94
|
-
readonly GST_12: 12;
|
|
95
|
-
readonly GST_18: 18;
|
|
96
|
-
readonly GST_28: 28;
|
|
97
|
-
};
|
|
170
|
+
type InvoiceTemplate = (invoice: Invoice, summary: BillingSummary) => string;
|
|
171
|
+
declare class InvoiceRenderer {
|
|
172
|
+
static renderHTML(invoice: Invoice, summary: BillingSummary, template: InvoiceTemplate): string;
|
|
173
|
+
}
|
|
98
174
|
|
|
99
175
|
declare class InvoiceGenerator {
|
|
100
|
-
static
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
static
|
|
176
|
+
static toHTML(invoice: Partial<Invoice>, options?: {
|
|
177
|
+
template?: "classic" | "gst";
|
|
178
|
+
}): string;
|
|
179
|
+
static toCSV(invoice: Invoice): string;
|
|
180
|
+
static toJSON(invoice: Invoice): string;
|
|
181
|
+
static toPDF(invoice: Partial<Invoice>, options?: {
|
|
182
|
+
template?: "classic" | "gst";
|
|
183
|
+
}): Promise<Buffer>;
|
|
104
184
|
}
|
|
105
185
|
|
|
106
|
-
|
|
186
|
+
declare const VERSION = "2.0.1";
|
|
187
|
+
|
|
188
|
+
export { type BankDetails, Billing, BillingError, type BillingSummary, type Branch, type Company, type CurrencyType, type Customer, type Invoice, type InvoiceBranding, InvoiceCalculator, InvoiceError, type InvoiceFeatures, InvoiceGenerator, type InvoiceItem, InvoiceNormalizer, InvoiceRenderer, type InvoiceTemplate, type InvoiceTheme, type Payment, type PaymentMode, type PaymentStatus, type PaymentTransaction, TAX_RATES, type Tax, VERSION, ValidationError, calculateDiscount, calculateGST, calculateTax, formatCurrency, formatDate, getCurrentTimestamp, isValidEmail, isValidGST, isValidPhone };
|