-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti_invoice_generator.html
More file actions
1309 lines (1160 loc) · 45.4 KB
/
multi_invoice_generator.html
File metadata and controls
1309 lines (1160 loc) · 45.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>InvoiceFlow — Multi-Client Invoice Generator</title>
<link href="https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=Karla:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #F3F0E8;
--surface: #FFFFFF;
--border: #DDD9CF;
--green: #1B4332;
--green-mid: #2D6A4F;
--green-light: #52B788;
--green-pale: #D8F3DC;
--coral: #E85D26;
--amber: #F59E0B;
--text: #1A1A18;
--muted: #6B7060;
--faint: #9CA390;
}
body { font-family: 'Karla', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
/* ── Header ───────────────────────────────────── */
header {
background: var(--green);
color: white;
padding: 0 28px;
height: 54px;
display: flex;
align-items: center;
justify-content: space-between;
position: sticky;
top: 0;
z-index: 50;
box-shadow: 0 2px 20px rgba(0,0,0,0.25);
}
.logo { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; }
.logo em { color: var(--green-light); font-style: normal; }
.header-tagline { font-size: 0.75rem; color: rgba(255,255,255,0.45); letter-spacing: 0.03em; }
/* ── Main shell ───────────────────────────────── */
.shell {
display: grid;
grid-template-columns: 320px 1fr;
min-height: calc(100vh - 54px);
}
/* ── Entity Panel (left) ──────────────────────── */
.entity-panel {
background: white;
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
overflow-y: auto;
max-height: calc(100vh - 54px);
position: sticky;
top: 54px;
}
.entity-inner { padding: 20px 18px; flex: 1; }
.sec-title {
font-size: 0.62rem;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--faint);
margin-bottom: 10px;
display: flex;
align-items: center;
gap: 8px;
}
.sec-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.field { margin-bottom: 10px; }
.field label {
display: block;
font-size: 0.65rem;
font-weight: 700;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.07em;
margin-bottom: 3px;
}
.field input, .field textarea {
width: 100%;
border: 1.5px solid var(--border);
border-radius: 7px;
padding: 7px 9px;
font-family: 'Karla', sans-serif;
font-size: 0.82rem;
color: var(--text);
background: var(--bg);
transition: border-color 0.15s, background 0.15s;
resize: none;
}
.field input:focus, .field textarea:focus {
outline: none;
border-color: var(--green-light);
background: white;
}
.field textarea { min-height: 56px; line-height: 1.5; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.save-indicator {
font-size: 0.7rem;
color: var(--green-light);
text-align: right;
margin-top: -6px;
margin-bottom: 8px;
min-height: 14px;
transition: opacity 0.3s;
}
/* ── Workspace (right) ────────────────────────── */
.workspace { display: flex; flex-direction: column; overflow: hidden; }
/* Settings bar */
.settings-bar {
background: white;
border-bottom: 1px solid var(--border);
padding: 10px 24px;
display: flex;
align-items: center;
gap: 18px;
flex-wrap: wrap;
box-shadow: 0 1px 0 var(--border);
}
.sbar-field {
display: flex;
align-items: center;
gap: 7px;
}
.sbar-field label {
font-size: 0.65rem;
font-weight: 700;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.07em;
white-space: nowrap;
}
.sbar-field input {
border: 1.5px solid var(--border);
border-radius: 6px;
padding: 5px 9px;
font-family: 'Karla', sans-serif;
font-size: 0.82rem;
background: var(--bg);
color: var(--text);
width: 110px;
}
.sbar-field input:focus { outline: none; border-color: var(--green-light); background: white; }
.sbar-field input.narrow { width: 64px; }
/* Table section */
.table-section { flex: 1; padding: 18px 24px; overflow-y: auto; }
.table-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
gap: 8px;
}
.toolbar-left { display: flex; align-items: center; gap: 8px; }
.toolbar-right { display: flex; gap: 6px; }
.table-label {
font-family: 'Syne', sans-serif;
font-weight: 700;
font-size: 0.85rem;
}
.count-badge {
background: var(--green-pale);
color: var(--green);
padding: 2px 9px;
border-radius: 20px;
font-size: 0.7rem;
font-weight: 700;
}
/* Buttons */
.btn {
padding: 7px 14px;
border-radius: 7px;
font-family: 'Karla', sans-serif;
font-size: 0.78rem;
font-weight: 600;
cursor: pointer;
border: none;
display: inline-flex;
align-items: center;
gap: 5px;
transition: all 0.15s;
white-space: nowrap;
}
.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: var(--green-mid); }
.btn-coral { background: var(--coral); color: white; }
.btn-coral:hover { background: #CA4D1B; }
.btn-ghost { background: transparent; color: var(--green); border: 1.5px solid var(--green); }
.btn-ghost:hover { background: var(--green-pale); }
.btn-outline { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--green); color: var(--green); }
.btn-danger { background: #FEE2E2; color: #DC2626; border: none; }
.btn-danger:hover { background: #FECACA; }
.btn-sm { padding: 5px 9px; font-size: 0.72rem; border-radius: 6px; }
/* Client table */
.client-table { width: 100%; border-collapse: collapse; min-width: 900px; }
.client-table thead tr th {
background: var(--green);
color: rgba(255,255,255,0.85);
padding: 9px 10px;
text-align: left;
font-size: 0.62rem;
font-weight: 700;
letter-spacing: 0.09em;
text-transform: uppercase;
white-space: nowrap;
}
.client-table thead tr th:first-child { border-radius: 8px 0 0 8px; }
.client-table thead tr th:last-child { border-radius: 0 8px 8px 0; text-align: center; }
.client-table tbody tr { border-bottom: 1px solid var(--border); }
.client-table tbody tr:hover { background: #F9F7F1; }
.client-table tbody tr:last-child { border-bottom: none; }
.client-table td { padding: 0; vertical-align: middle; }
.client-table td.cell-num {
padding: 8px 10px;
font-family: 'JetBrains Mono', monospace;
font-size: 0.7rem;
color: var(--faint);
white-space: nowrap;
}
.client-table td input {
width: 100%;
border: none;
background: transparent;
padding: 8px 10px;
font-family: 'Karla', sans-serif;
font-size: 0.82rem;
color: var(--text);
}
.client-table td input:focus { outline: none; background: #FFFDF5; }
.client-table td input.mono { font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; }
.client-table td input.right { text-align: right; }
.row-actions { padding: 4px 8px !important; display: flex; gap: 4px; justify-content: center; white-space: nowrap; }
.table-empty {
text-align: center;
padding: 60px 20px;
color: var(--muted);
}
.table-empty .empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.table-empty p { font-size: 0.83rem; }
.table-empty small { font-size: 0.72rem; color: var(--faint); margin-top: 4px; display: block; }
/* Bottom bar */
.bottom-bar {
background: var(--green);
padding: 12px 24px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.bottom-info { color: rgba(255,255,255,0.6); font-size: 0.78rem; }
.bottom-info strong { color: white; font-size: 1rem; font-family: 'Syne', sans-serif; display: block; }
.bottom-actions { display: flex; gap: 8px; }
/* ── Modals ───────────────────────────────────── */
.overlay {
position: fixed;
inset: 0;
background: rgba(15, 25, 18, 0.55);
backdrop-filter: blur(6px);
z-index: 200;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.modal {
background: white;
border-radius: 16px;
width: min(600px, 100%);
max-height: 88vh;
overflow-y: auto;
box-shadow: 0 24px 80px rgba(0,0,0,0.3);
}
.modal-header {
padding: 22px 24px 16px;
border-bottom: 1px solid var(--border);
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
}
.modal-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1rem; }
.modal-sub { font-size: 0.78rem; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 1.2rem; padding: 2px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.paste-area {
width: 100%;
min-height: 160px;
border: 1.5px solid var(--border);
border-radius: 8px;
padding: 12px;
font-family: 'JetBrains Mono', monospace;
font-size: 0.73rem;
line-height: 1.7;
color: var(--text);
background: var(--bg);
resize: vertical;
}
.paste-area:focus { outline: none; border-color: var(--green-light); background: white; }
.col-guide {
display: flex;
gap: 6px;
flex-wrap: wrap;
margin-top: 10px;
}
.col-tag {
padding: 3px 10px;
border-radius: 20px;
font-size: 0.65rem;
font-weight: 600;
background: var(--green-pale);
color: var(--green);
}
.col-tag.optional { background: #F3F0E8; color: var(--muted); }
/* ── Preview Modal ────────────────────────────── */
.preview-overlay {
position: fixed;
inset: 0;
background: rgba(15, 25, 18, 0.6);
backdrop-filter: blur(8px);
z-index: 300;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.preview-shell {
background: white;
border-radius: 14px;
width: min(780px, 100%);
max-height: 92vh;
display: flex;
flex-direction: column;
overflow: hidden;
box-shadow: 0 32px 100px rgba(0,0,0,0.4);
}
.preview-header {
padding: 14px 20px;
border-bottom: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: space-between;
background: white;
z-index: 1;
}
.preview-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.9rem; }
.preview-actions { display: flex; gap: 8px; }
.preview-scroll {
flex: 1;
overflow-y: auto;
padding: 28px 24px;
background: #E8E5DC;
}
/* ── Invoice card (preview) ───────────────────── */
.inv-card {
background: white;
border-radius: 10px;
max-width: 680px;
margin: 0 auto;
overflow: hidden;
box-shadow: 0 6px 32px rgba(0,0,0,0.14);
font-family: 'Karla', sans-serif;
}
.inv-head {
background: var(--green);
padding: 22px 28px;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 16px;
}
.inv-head-left {}
.inv-ename { font-family: 'Syne', sans-serif; font-size: 1.05rem; font-weight: 800; color: white; }
.inv-eaddr { font-size: 0.72rem; color: rgba(255,255,255,0.6); margin-top: 3px; line-height: 1.5; }
.inv-egstin { font-size: 0.68rem; color: var(--green-light); font-family: 'JetBrains Mono', monospace; margin-top: 5px; }
.inv-head-right { text-align: right; flex-shrink: 0; }
.inv-word { font-family: 'Syne', sans-serif; font-size: 1.6rem; font-weight: 800; color: rgba(255,255,255,0.1); letter-spacing: 0.06em; line-height: 1; }
.inv-num { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; color: var(--green-light); margin-top: -4px; }
.inv-date { font-size: 0.7rem; color: rgba(255,255,255,0.45); margin-top: 3px; }
.inv-meta {
padding: 18px 28px;
display: grid;
grid-template-columns: 1fr auto;
gap: 20px;
background: #FAFAF7;
border-bottom: 1px solid var(--border);
}
.inv-meta-label { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-bottom: 7px; }
.inv-cname { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.inv-caddr { font-size: 0.75rem; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.inv-ctaxid { font-size: 0.7rem; color: var(--green); font-family: 'JetBrains Mono', monospace; margin-top: 5px; }
.inv-detail-row { font-size: 0.75rem; color: var(--text); margin-bottom: 4px; display: flex; gap: 8px; justify-content: flex-end; }
.inv-detail-row span { color: var(--faint); }
.inv-body { padding: 22px 28px; }
.inv-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.inv-table th {
background: #F3F0E8;
padding: 8px 12px;
text-align: left;
font-size: 0.6rem;
font-weight: 700;
letter-spacing: 0.09em;
text-transform: uppercase;
color: var(--muted);
}
.inv-table th:first-child { border-radius: 6px 0 0 6px; }
.inv-table th:last-child { border-radius: 0 6px 6px 0; text-align: right; }
.inv-table td { padding: 13px 12px; font-size: 0.85rem; border-bottom: 1px solid var(--border); }
.inv-table td:last-child { text-align: right; font-family: 'JetBrains Mono', monospace; }
.inv-fx-note { font-size: 0.7rem; color: var(--faint); font-style: italic; padding: 4px 12px 8px; }
.inv-total-row { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.inv-total {
background: var(--green);
color: white;
padding: 12px 20px;
border-radius: 10px;
text-align: right;
min-width: 200px;
}
.inv-total-label { font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255,255,255,0.5); margin-bottom: 4px; }
.inv-total-amount { font-family: 'Syne', sans-serif; font-size: 1.3rem; font-weight: 800; color: var(--green-light); }
.inv-note { background: #F3F0E8; border-radius: 7px; padding: 10px 14px; font-size: 0.75rem; color: var(--muted); margin-bottom: 0; }
.inv-note strong { color: var(--text); }
.inv-pay {
background: #F3F0E8;
padding: 18px 28px;
border-top: 2px solid var(--green);
}
.inv-pay-title { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--green); margin-bottom: 8px; }
.inv-pay-warn { font-size: 0.75rem; font-weight: 700; color: var(--coral); margin-bottom: 12px; }
.inv-pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; }
.inv-pay-row { display: flex; gap: 8px; align-items: baseline; }
.inv-pay-key { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); min-width: 72px; flex-shrink: 0; }
.inv-pay-val { font-size: 0.75rem; font-family: 'JetBrains Mono', monospace; color: var(--text); }
.inv-foot {
background: var(--green);
padding: 9px 28px;
text-align: center;
font-size: 0.7rem;
color: rgba(255,255,255,0.4);
}
/* ── Toast ────────────────────────────────────── */
.toast {
position: fixed;
bottom: 24px;
right: 24px;
background: var(--green);
color: white;
padding: 11px 18px;
border-radius: 10px;
font-size: 0.82rem;
font-weight: 600;
z-index: 999;
transform: translateY(80px);
opacity: 0;
transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
box-shadow: 0 8px 32px rgba(0,0,0,0.25);
pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
/* ── Scrollbar ────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
/* ── Table wrapper (horizontal scroll) ────────── */
.table-wrapper { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); background: white; }
</style>
</head>
<body>
<!-- ═══ HEADER ════════════════════════════════════════ -->
<header>
<div class="logo">Invoice<em>Flow</em></div>
<div class="header-tagline">Multi-client · Browser-native · Privacy-first</div>
</header>
<!-- ═══ MAIN SHELL ════════════════════════════════════ -->
<div class="shell">
<!-- ═══ LEFT: ENTITY PANEL ═══════════════════════════ -->
<aside class="entity-panel">
<div class="entity-inner">
<div class="sec-title">Your Entity</div>
<div class="field">
<label>Company / Entity Name</label>
<input type="text" id="eName" placeholder="ACME CORP LTD.">
</div>
<div class="field">
<label>Address</label>
<textarea id="eAddress" placeholder="123 Business Road City, Country — ZIP"></textarea>
</div>
<div class="field">
<label>Tax ID / GSTIN / VAT</label>
<input type="text" id="eTaxId" placeholder="e.g. VAT123456789">
</div>
<div class="field">
<label>Contact Email</label>
<input type="email" id="eEmail" placeholder="billing@yourcompany.com">
</div>
<div class="divider"></div>
<div class="sec-title">Payment Details</div>
<div class="field">
<label>Bank Name</label>
<input type="text" id="eBankName" placeholder="e.g. HSBC Bank, Canary Wharf">
</div>
<div class="field-row">
<div class="field">
<label>SWIFT / BIC</label>
<input type="text" id="eSwift" placeholder="HBUKGB4B">
</div>
<div class="field">
<label>IFSC / Sort Code</label>
<input type="text" id="eIfsc" placeholder="40-02-50">
</div>
</div>
<div class="field">
<label>Account Number</label>
<input type="text" id="eAccNo" placeholder="12345678">
</div>
<div class="field">
<label>Beneficiary Name</label>
<input type="text" id="eBene" placeholder="Acme Corp Ltd.">
</div>
<div class="save-indicator" id="saveIndicator"></div>
<button class="btn btn-ghost" style="width:100%;justify-content:center" onclick="saveEntityToStorage()">
💾 Save Entity to Browser
</button>
</div>
</aside>
<!-- ═══ RIGHT: WORKSPACE ══════════════════════════════ -->
<section class="workspace">
<!-- Settings bar -->
<div class="settings-bar">
<div class="sbar-field">
<label>Invoice # Prefix</label>
<input type="text" id="sPrefix" value="INV" style="width:80px" oninput="renderTable()">
</div>
<div class="sbar-field">
<label>Start #</label>
<input type="number" id="sStartNum" value="1" class="narrow" min="1" oninput="renderTable()">
</div>
<div class="sbar-field">
<label>Date</label>
<input type="text" id="sDate" value="" placeholder="01 Apr 2026" style="width:120px">
</div>
<div class="sbar-field" style="flex:1">
<label>Footer Note</label>
<input type="text" id="sNotes" placeholder="e.g. Payment due within 30 days" style="width:100%;max-width:340px">
</div>
</div>
<!-- Table section -->
<div class="table-section">
<div class="table-toolbar">
<div class="toolbar-left">
<span class="table-label">Client Roster</span>
<span class="count-badge" id="clientCount">0 clients</span>
</div>
<div class="toolbar-right">
<button class="btn btn-outline btn-sm" onclick="openPasteModal()">📋 Paste from Excel</button>
<button class="btn btn-ghost btn-sm" onclick="addRow()">+ Add Row</button>
<button class="btn btn-outline btn-sm" onclick="clearTable()" style="color:#DC2626;border-color:#FECACA">🗑 Clear All</button>
</div>
</div>
<div class="table-wrapper">
<table class="client-table">
<thead>
<tr>
<th style="min-width:90px">Inv #</th>
<th style="min-width:180px">Client Name</th>
<th style="min-width:160px">Address</th>
<th style="min-width:130px">Tax ID</th>
<th style="min-width:110px;text-align:right">Amount (USD)</th>
<th style="min-width:200px">Description</th>
<th style="min-width:160px">FX Note</th>
<th style="min-width:130px">Actions</th>
</tr>
</thead>
<tbody id="clientTableBody">
<tr>
<td colspan="8">
<div class="table-empty">
<div class="empty-icon">📄</div>
<p>No clients yet — add a row or paste from Excel</p>
<small>Columns: Client Name · Tax ID · Address · Amount · Description · FX Note (optional)</small>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Bottom bar -->
<div class="bottom-bar">
<div class="bottom-info">
<strong id="bottomCount">0 invoices ready</strong>
All generation happens in your browser — nothing is uploaded
</div>
<div class="bottom-actions">
<button class="btn" style="background:rgba(255,255,255,0.12);color:white;border:1px solid rgba(255,255,255,0.2)" onclick="previewFirst()">
👁 Preview First
</button>
<button class="btn" style="background:var(--green-light);color:var(--green)" onclick="downloadAll()">
⬇ Download All PDFs
</button>
</div>
</div>
</section>
</div>
<!-- ═══ PASTE MODAL ════════════════════════════════════ -->
<div class="overlay" id="pasteModal" style="display:none">
<div class="modal">
<div class="modal-header">
<div>
<div class="modal-title">📋 Paste from Excel / Sheets</div>
<div class="modal-sub">Copy your client rows in Excel, then paste below. Tab-separated values are auto-detected.</div>
</div>
<button class="modal-close" onclick="closePasteModal()">✕</button>
</div>
<div class="modal-body">
<div style="margin-bottom:8px;font-size:0.72rem;font-weight:600;color:var(--muted)">Expected column order:</div>
<div class="col-guide" style="margin-bottom:14px">
<span class="col-tag">A: Client Name</span>
<span class="col-tag">B: Tax ID</span>
<span class="col-tag">C: Address</span>
<span class="col-tag">D: Amount</span>
<span class="col-tag optional">E: Description</span>
<span class="col-tag optional">F: FX Note</span>
</div>
<textarea class="paste-area" id="pasteText" placeholder="Paste your Excel rows here (Ctrl+V) Example Corp Ltd.	VAT123456	London, UK	5000	Consulting Services Q1	GBP 4000 @ 1.25 Another Client Inc.	EIN98-7654321	New York, USA	8000	Design Retainer"></textarea>
<div style="margin-top:8px;font-size:0.7rem;color:var(--faint)">
Tip: Select multiple cells in Excel → Ctrl+C → paste here. Each row becomes one client invoice.
</div>
</div>
<div class="modal-footer">
<button class="btn btn-outline" onclick="closePasteModal()">Cancel</button>
<button class="btn btn-green" onclick="importPaste()">Import Clients →</button>
</div>
</div>
</div>
<!-- ═══ PREVIEW MODAL ══════════════════════════════════ -->
<div class="preview-overlay" id="previewModal" style="display:none">
<div class="preview-shell">
<div class="preview-header">
<div class="preview-title" id="previewTitle">Invoice Preview</div>
<div class="preview-actions">
<button class="btn btn-green btn-sm" onclick="downloadCurrentPreview()">⬇ Download This PDF</button>
<button class="btn btn-outline btn-sm" onclick="closePreview()">✕ Close</button>
</div>
</div>
<div class="preview-scroll" id="previewContent"></div>
</div>
</div>
<!-- ═══ TOAST ══════════════════════════════════════════ -->
<div class="toast" id="toast"></div>
<script>
// ══════════════════════════════════════════════════════
// STATE
// ══════════════════════════════════════════════════════
let rows = [];
let rowIdCounter = 0;
let currentPreviewRowId = null;
// ══════════════════════════════════════════════════════
// ENTITY
// ══════════════════════════════════════════════════════
function getEntity() {
return {
name: v('eName'),
address: v('eAddress'),
taxId: v('eTaxId'),
email: v('eEmail'),
bankName: v('eBankName'),
swift: v('eSwift'),
ifsc: v('eIfsc'),
accNo: v('eAccNo'),
bene: v('eBene'),
};
}
function saveEntityToStorage() {
const entity = getEntity();
localStorage.setItem('invoiceflow_entity', JSON.stringify(entity));
si('saveIndicator', '✓ Saved to browser');
showToast('Entity saved to browser storage');
}
function loadEntityFromStorage() {
try {
const stored = localStorage.getItem('invoiceflow_entity');
if (stored) {
const e = JSON.parse(stored);
sv('eName', e.name || '');
sv('eAddress', e.address || '');
sv('eTaxId', e.taxId || '');
sv('eEmail', e.email || '');
sv('eBankName', e.bankName || '');
sv('eSwift', e.swift || '');
sv('eIfsc', e.ifsc || '');
sv('eAccNo', e.accNo || '');
sv('eBene', e.bene || '');
return true;
}
} catch(e) {}
return false;
}
// ══════════════════════════════════════════════════════
// SETTINGS
// ══════════════════════════════════════════════════════
function getSettings() {
return {
prefix: v('sPrefix') || 'INV',
startNum: parseInt(v('sStartNum')) || 1,
date: v('sDate') || todayStr(),
notes: v('sNotes') || ''
};
}
function todayStr() {
return new Date().toLocaleDateString('en-GB', { day:'2-digit', month:'short', year:'numeric' });
}
// ══════════════════════════════════════════════════════
// ROW MANAGEMENT
// ══════════════════════════════════════════════════════
function addRow(data = {}) {
rows.push({ id: rowIdCounter++, name:'', address:'', taxId:'', amount:'', description:'', fxNote:'', ...data });
renderTable();
}
function deleteRow(id) {
rows = rows.filter(r => r.id !== id);
renderTable();
}
function updateRow(id, field, value) {
const row = rows.find(r => r.id === id);
if (row) row[field] = value;
updateCounts();
}
function clearTable() {
if (rows.length === 0) return;
if (confirm('Clear all clients? This cannot be undone.')) { rows = []; renderTable(); }
}
function getInvNum(rowId) {
const s = getSettings();
const idx = rows.findIndex(r => r.id === rowId);
return `${s.prefix}-${String(s.startNum + idx).padStart(3, '0')}`;
}
function renderTable() {
const tbody = document.getElementById('clientTableBody');
if (rows.length === 0) {
tbody.innerHTML = `<tr><td colspan="8"><div class="table-empty">
<div class="empty-icon">📄</div>
<p>No clients yet — add a row or paste from Excel</p>
<small>Columns: Client Name · Tax ID · Address · Amount · Description · FX Note (optional)</small>
</div></td></tr>`;
updateCounts();
return;
}
tbody.innerHTML = rows.map((row, idx) => {
const s = getSettings();
const invNum = `${s.prefix}-${String(s.startNum + idx).padStart(3, '0')}`;
return `<tr data-id="${row.id}">
<td class="cell-num">${invNum}</td>
<td><input value="${eh(row.name)}" onchange="updateRow(${row.id},'name',this.value)" placeholder="Client company name"></td>
<td><input value="${eh(row.address)}" onchange="updateRow(${row.id},'address',this.value)" placeholder="City, Country"></td>
<td><input value="${eh(row.taxId)}" onchange="updateRow(${row.id},'taxId',this.value)" placeholder="VAT / GST / CRN" class="mono"></td>
<td><input value="${eh(row.amount)}" onchange="updateRow(${row.id},'amount',this.value)" placeholder="0.00" class="mono right"></td>
<td><input value="${eh(row.description)}" onchange="updateRow(${row.id},'description',this.value)" placeholder="Service description"></td>
<td><input value="${eh(row.fxNote)}" onchange="updateRow(${row.id},'fxNote',this.value)" placeholder="EUR 1000 @ 1.10 = USD 1100"></td>
<td class="row-actions">
<button class="btn btn-outline btn-sm" onclick="previewInvoice(${row.id})" title="Preview">👁</button>
<button class="btn btn-coral btn-sm" onclick="downloadInvoice(${row.id})" title="Download PDF">⬇</button>
<button class="btn btn-danger btn-sm" onclick="deleteRow(${row.id})" title="Delete">✕</button>
</td>
</tr>`;
}).join('');
updateCounts();
}
function updateCounts() {
const n = rows.length;
si('clientCount', n + ' client' + (n !== 1 ? 's' : ''));
si('bottomCount', n + ' invoice' + (n !== 1 ? 's' : '') + ' ready');
}
// ══════════════════════════════════════════════════════
// PREVIEW
// ══════════════════════════════════════════════════════
function previewInvoice(rowId) {
const row = rows.find(r => r.id === rowId);
if (!row) return;
currentPreviewRowId = rowId;
const entity = getEntity();
const settings = getSettings();
const invNum = getInvNum(rowId);
document.getElementById('previewTitle').textContent = `Preview — ${invNum}`;
document.getElementById('previewContent').innerHTML = buildPreviewHTML(entity, row, settings, invNum);
document.getElementById('previewModal').style.display = 'flex';
}
function previewFirst() {
if (rows.length === 0) { showToast('Add at least one client first'); return; }
previewInvoice(rows[0].id);
}
function closePreview() {
document.getElementById('previewModal').style.display = 'none';
}
function downloadCurrentPreview() {
if (currentPreviewRowId === null) return;
downloadInvoice(currentPreviewRowId);
}
function buildPreviewHTML(entity, client, settings, invNum) {
const addrLines = (entity.address || '').split('\n').filter(Boolean);
const cAddrLines = (client.address || '').split('\n').filter(Boolean);
const amt = parseFloat(client.amount || 0);
const payRows = [
['Bank', entity.bankName],
['SWIFT', entity.swift],
['IFSC', entity.ifsc],
['Account', entity.accNo],
['Beneficiary', entity.bene],
['Reference', 'Invoice # ' + invNum],
].filter(([,v]) => v);
return `<div class="inv-card">
<div class="inv-head">
<div class="inv-head-left">
<div class="inv-ename">${eh(entity.name || 'YOUR COMPANY')}</div>
<div class="inv-eaddr">${addrLines.map(l => eh(l)).join('<br>')}</div>
${entity.taxId ? `<div class="inv-egstin">GSTIN: ${eh(entity.taxId)}</div>` : ''}
</div>
<div class="inv-head-right">
<div class="inv-word">INVOICE</div>
<div class="inv-num">${invNum}</div>
<div class="inv-date">${settings.date}</div>
</div>
</div>
<div class="inv-meta">
<div>
<div class="inv-meta-label">Bill To</div>
<div class="inv-cname">${eh(client.name || '—')}</div>
<div class="inv-caddr">${cAddrLines.map(l => eh(l)).join('<br>')}</div>
${client.taxId ? `<div class="inv-ctaxid">Tax ID: ${eh(client.taxId)}</div>` : ''}
</div>
<div>
<div class="inv-meta-label" style="text-align:right">Invoice Details</div>
<div class="inv-detail-row"><span>Number:</span> <strong style="font-family:'JetBrains Mono',monospace">${invNum}</strong></div>
<div class="inv-detail-row"><span>Date:</span> ${settings.date}</div>
<div class="inv-detail-row"><span>Currency:</span> USD</div>
</div>
</div>
<div class="inv-body">
<table class="inv-table">
<thead><tr><th>Description</th><th>Amount (USD)</th></tr></thead>
<tbody>
<tr>
<td>${eh(client.description || 'Professional Services')}</td>
<td>$${fmt(amt)}</td>
</tr>
${client.fxNote ? `<tr><td colspan="2" class="inv-fx-note">FX Note: ${eh(client.fxNote)}</td></tr>` : ''}
</tbody>
</table>
<div class="inv-total-row">
<div class="inv-total">
<div class="inv-total-label">Total Due</div>
<div class="inv-total-amount">USD ${fmt(amt)}</div>
</div>
</div>
${settings.notes ? `<div class="inv-note"><strong>Note:</strong> ${eh(settings.notes)}</div>` : ''}
</div>
<div class="inv-pay">
<div class="inv-pay-title">Payment Instructions</div>
<div class="inv-pay-grid">
${payRows.map(([k,v]) => `<div class="inv-pay-row"><span class="inv-pay-key">${k}</span><span class="inv-pay-val">${eh(v)}</span></div>`).join('')}
</div>
</div>
<div class="inv-foot">${eh(entity.email || '')}</div>
</div>`;
}
// ══════════════════════════════════════════════════════
// PDF GENERATION
// ══════════════════════════════════════════════════════
function generatePDF(entity, client, settings, invNum) {
const { jsPDF } = window.jspdf;
const doc = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' });
const W = 210; const H = 297;
const GREEN = [27, 67, 50];
const GMID = [45, 106, 79];
const GLIGHT = [82, 183, 136];
const CORAL = [232, 93, 38];
const TEXT = [26, 26, 24];
const MUTED = [107, 112, 96];
const FAINT = [156, 163, 144];
const BG = [243, 240, 232];
const WHITE = [255, 255, 255];
let y = 0;
// ── Header bar ──────────────────────────────────────
doc.setFillColor(...GREEN);
doc.rect(0, 0, W, 44, 'F');
doc.setFont('helvetica', 'bold');
doc.setFontSize(12);
doc.setTextColor(...WHITE);
doc.text((entity.name || 'YOUR COMPANY').toUpperCase(), 14, 14);
const addrLines = (entity.address || '').split('\n').filter(Boolean);