@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/dist/index.d.ts 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 };