@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 CHANGED
@@ -1,227 +1,231 @@
1
1
  # Zentris Billing
2
2
 
3
- Framework-independent TypeScript billing and invoice generation library for Angular, React, Vue, Node.js and JavaScript applications.
3
+ Modern TypeScript billing & invoice generation library for Angular, React, Vue, Node.js and JavaScript applications.
4
4
 
5
- Supports:
5
+ Generate professional invoices in:
6
6
 
7
- GST / Tax calculations
8
- Discount calculations
9
- Currency formatting
10
- Invoice generation
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
- ## Quick Start
29
-
30
- ```ts
31
- import { Billing } from "@awadheshs109/billing";
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
- const gst = Billing.calculateGST(1000, 18);
31
+ ---
34
32
 
35
- console.log(gst);
33
+ ## Installation
36
34
 
37
- //180
35
+ ```bash
36
+ npm install @awadheshs109/billing
38
37
  ```
39
38
 
40
39
  ---
41
40
 
42
- # Invoice Example
41
+ ## Quick Example
43
42
 
44
43
  ```ts
45
- import { InvoiceGenerator } from "@awadheshs109/billing";
44
+ import {
45
+ InvoiceGenerator
46
+ } from "@awadheshs109/billing";
46
47
 
47
48
  const invoice = {
48
49
  invoiceNo: "INV-1001",
49
50
 
50
- date: "21-05-2026",
51
+ date: "25-05-2026",
52
+
53
+ currency: "INR",
51
54
 
52
55
  company: {
53
56
  name: "Zentris Pvt Ltd",
54
-
55
- address: "Mumbai",
56
-
57
- phone: "+91 999999999",
57
+ address: "Mumbai, India",
58
+ phone: "+91 9999999999"
58
59
  },
59
60
 
60
61
  customer: {
61
- name: "Awadhesh Sharma",
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 Development",
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
- rate: 100,
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
- # Generate HTML Invoice
86
+ ## Generate PDF
95
87
 
96
88
  ```ts
97
- const html = InvoiceGenerator.toHTML(invoice);
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
- # Generate CSV
102
+ ## Generate GST Invoice Template
103
103
 
104
104
  ```ts
105
- const csv = InvoiceGenerator.toCSV(invoice);
105
+ const html =
106
+ InvoiceGenerator.toHTML(
107
+ invoice,
108
+ {
109
+ template: "gst"
110
+ }
111
+ );
106
112
  ```
107
113
 
108
114
  ---
109
115
 
110
- # Generate JSON
116
+ ## Export Formats
117
+
118
+ ### HTML
111
119
 
112
120
  ```ts
113
- const json = InvoiceGenerator.toJSON(invoice);
121
+ InvoiceGenerator.toHTML(invoice);
114
122
  ```
115
123
 
116
- ---
117
-
118
- # Generate PDF
124
+ ### PDF
119
125
 
120
126
  ```ts
121
- const pdf = InvoiceGenerator.toPDF(invoice);
127
+ await InvoiceGenerator.toPDF(invoice);
122
128
  ```
123
129
 
124
- ---
125
-
126
- # Save PDF in Node
130
+ ### CSV
127
131
 
128
132
  ```ts
129
- import fs from "fs";
130
-
131
- const pdf = InvoiceGenerator.toPDF(invoice);
133
+ InvoiceGenerator.toCSV(invoice);
134
+ ```
132
135
 
133
- const buffer = Buffer.from(await pdf.arrayBuffer());
136
+ ### JSON
134
137
 
135
- fs.writeFileSync("invoice.pdf", buffer);
138
+ ```ts
139
+ InvoiceGenerator.toJSON(invoice);
136
140
  ```
137
141
 
138
142
  ---
139
143
 
140
- ## Available APIs
144
+ ## Tax Utilities
141
145
 
142
- ### Billing
143
-
144
- | Method | Description |
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
- ### InvoiceGenerator
151
+ const gst =
152
+ Billing.calculateGST(
153
+ 1000,
154
+ 18
155
+ );
153
156
 
154
- | Method | Description |
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
- ## Development
162
+ ## Currency Formatting
164
163
 
165
- Build:
166
-
167
- ```bash
168
- npm run build
164
+ ```ts
165
+ Billing.formatCurrency(
166
+ 15000,
167
+ "INR"
168
+ );
169
169
  ```
170
170
 
171
- Run tests:
172
-
173
- ```bash
174
- npm run test:run
175
- ```
171
+ ---
176
172
 
177
- Local invoice validation:
173
+ ## Supported Frameworks
178
174
 
179
- ```bash
180
- npx tsx test-invoice.ts
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
- ## Release Process
186
+ ## Invoice Templates
186
187
 
187
- Version update:
188
+ ### Classic Template
188
189
 
189
- ```bash
190
- npm version patch --no-git-tag-version
191
- ```
190
+ Professional clean invoice layout.
192
191
 
193
- Commit:
192
+ ### GST Template
194
193
 
195
- ```bash
196
- git add .
197
- git commit -m "development: add feature"
198
- ```
194
+ Indian GST-compliant invoice design.
199
195
 
200
- Tag:
196
+ ---
201
197
 
202
- ```bash
203
- git tag v1.1.0
204
- git push
205
- git push --tags
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
- GitHub Actions automatically:
209
+ ---
210
+
211
+ ## Version
209
212
 
210
- ```txt
211
- build
212
- → test
213
- → publish npm
213
+ ```ts
214
+ console.log(VERSION);
214
215
  ```
215
216
 
216
217
  ---
217
218
 
218
- ## Changelog
219
-
220
- See:
219
+ ## Roadmap
221
220
 
222
- ```txt
223
- CHANGELOG.md
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
- :contentReference[oaicite:0]{index=0}
237
-
238
- Package:
240
+ GitHub:
241
+ https://github.com/Awadheshs109/zentris-billing
239
242
 
240
- :contentReference[oaicite:1]{index=1}
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: any[], tax?: number, discount?: number): {
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 InvoiceItem {
47
- description: string;
48
- quantity: number;
49
- rate: number;
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
- company: {
56
- name: string;
57
- address: string;
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
- discount?: number;
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
- interface BillingSummary {
79
- subtotal: number;
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
- declare function formatDate(date?: Date, locale?: string): string;
86
- declare function getCurrentTimestamp(): number;
87
-
88
- declare function isValidEmail(email: string): boolean;
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 toPDF(invoice: any): Blob;
101
- static toCSV(invoice: any): string;
102
- static toJSON(invoice: any): string;
103
- static toHTML(invoice: any): string;
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
- export { Billing, BillingError, type BillingSummary, type CurrencyType, type Customer, type Invoice, InvoiceCalculator, InvoiceError, InvoiceGenerator, type InvoiceItem, TAX_RATES, type Tax, ValidationError, calculateDiscount, calculateGST, calculateTax, formatCurrency, formatDate, getCurrentTimestamp, isValidEmail, isValidGST, isValidPhone };
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 };