@bookmypuja-tech/bmp-pdf 0.1.0 → 0.1.2

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
@@ -31,6 +31,19 @@ interface ITotalReceipt {
31
31
  totalAmount: Number;
32
32
  qrContent?: string;
33
33
  }
34
+ interface IPujaReport {
35
+ templeName: string;
36
+ dates: [Date, Date];
37
+ pujas: {
38
+ name: string;
39
+ repeatCount?: Number;
40
+ participantName: string;
41
+ participantNakshatra: string;
42
+ pujaDate: Date;
43
+ pujaAmount: Number;
44
+ prasadam?: string;
45
+ }[];
46
+ }
34
47
 
35
48
  declare const A4Print: ({ data, dates, }: {
36
49
  data: IPrintablePuja[];
@@ -50,5 +63,6 @@ declare const getPrintBlob: ({ size, data, dates, }: {
50
63
  }) => Promise<Blob>;
51
64
  declare const printDevoteeReceipt2Inch: (data: IPujaReceipt) => Promise<void>;
52
65
  declare const printTotalReceipt2Inch: (data: ITotalReceipt) => Promise<void>;
66
+ declare const printePujaReport2Inch: (data: IPujaReport) => Promise<void>;
53
67
 
54
- export { A4Print, type IPrintablePuja, type IPujaReceipt, T2Inch, getPrintBlob, printDevoteeReceipt2Inch, printTotalReceipt2Inch };
68
+ export { A4Print, type IPrintablePuja, type IPujaReceipt, T2Inch, getPrintBlob, printDevoteeReceipt2Inch, printTotalReceipt2Inch, printePujaReport2Inch };
package/dist/index.js CHANGED
@@ -213,7 +213,7 @@ var A4Print = ({
213
213
  var A4Print_default = A4Print;
214
214
 
215
215
  // src/index.tsx
216
- import React5 from "react";
216
+ import React6 from "react";
217
217
 
218
218
  // src/sizes/T2Inch.tsx
219
219
  import React2 from "react";
@@ -505,6 +505,47 @@ var getTotalReceipt2InchBase64Data = async (receiptData) => {
505
505
  return btoa(String.fromCharCode.apply(null, Array.from(data)));
506
506
  };
507
507
 
508
+ // src/sizes/receipt/PujaReport2Inch.tsx
509
+ import React5 from "react";
510
+ import {
511
+ Printer as Printer3,
512
+ Br as Br3,
513
+ Line as Line3,
514
+ render as render3,
515
+ Text as Text5
516
+ } from "react-thermal-printer";
517
+ var PujaReportReceipt2Inch = (data) => {
518
+ const timeRightNow = /* @__PURE__ */ new Date();
519
+ const isSingleDate = data.dates[0].toISOString().split("T")[0] === data.dates[1].toISOString().split("T")[0];
520
+ return /* @__PURE__ */ React5.createElement(Printer3, { type: "epson", width: 32, characterSet: "iso8859_15_latin9" }, /* @__PURE__ */ React5.createElement(Text5, { bold: true, align: "center" }, data.templeName), isSingleDate ? /* @__PURE__ */ React5.createElement(Text5, { align: "center" }, data.dates[0].toLocaleDateString("en-US", {
521
+ month: "short",
522
+ day: "numeric",
523
+ year: "numeric"
524
+ })) : /* @__PURE__ */ React5.createElement(Text5, { align: "center" }, data.dates[0].toLocaleDateString("en-US", {
525
+ month: "short",
526
+ day: "numeric",
527
+ year: "numeric"
528
+ }) + " - ", data.dates[1].toLocaleDateString("en-US", {
529
+ month: "short",
530
+ day: "numeric",
531
+ year: "numeric"
532
+ })), /* @__PURE__ */ React5.createElement(Line3, null), data.pujas.map((puja, index) => {
533
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(Text5, null, puja.name, " ", "(", "qty:", " ", Boolean(puja.repeatCount) ? String(puja.repeatCount) : String(1), ")"), puja.prasadam ? /* @__PURE__ */ React5.createElement(Text5, null, puja.prasadam) : null, /* @__PURE__ */ React5.createElement(Text5, { align: "right" }, "Price: ", String(puja.pujaAmount), ", ", puja.pujaDate.toLocaleDateString("en-US", {
534
+ month: "short",
535
+ day: "numeric",
536
+ year: "numeric"
537
+ })), /* @__PURE__ */ React5.createElement(Text5, null, puja.participantName), /* @__PURE__ */ React5.createElement(Text5, null, puja.participantNakshatra), /* @__PURE__ */ React5.createElement(Line3, null));
538
+ }), /* @__PURE__ */ React5.createElement(Text5, { align: "right" }, "Total Pujas: ", String(data.pujas.length)), /* @__PURE__ */ React5.createElement(Text5, { align: "right" }, "Total Amount:", " ", String(
539
+ data.pujas.reduce((acc, puja) => {
540
+ return acc + Number(puja.pujaAmount);
541
+ }, 0)
542
+ )), /* @__PURE__ */ React5.createElement(Line3, null), /* @__PURE__ */ React5.createElement(Text5, { align: "center" }, "Thank You"), /* @__PURE__ */ React5.createElement(Text5, { align: "center" }, "bookmypuja.app"), /* @__PURE__ */ React5.createElement(Br3, null));
543
+ };
544
+ var getPujaReportReceipt2InchBase64Data = async (receiptData) => {
545
+ const data = await render3(PujaReportReceipt2Inch(receiptData));
546
+ return btoa(String.fromCharCode.apply(null, Array.from(data)));
547
+ };
548
+
508
549
  // src/index.tsx
509
550
  var getPrintBlob = ({
510
551
  size,
@@ -512,10 +553,10 @@ var getPrintBlob = ({
512
553
  dates
513
554
  }) => {
514
555
  if (size === "A4") {
515
- const blob = pdf(/* @__PURE__ */ React5.createElement(A4Print_default, { data, dates })).toBlob();
556
+ const blob = pdf(/* @__PURE__ */ React6.createElement(A4Print_default, { data, dates })).toBlob();
516
557
  return blob;
517
558
  } else {
518
- const blob = pdf(/* @__PURE__ */ React5.createElement(T2Inch_default, { data, dates })).toBlob();
559
+ const blob = pdf(/* @__PURE__ */ React6.createElement(T2Inch_default, { data, dates })).toBlob();
519
560
  return blob;
520
561
  }
521
562
  };
@@ -531,10 +572,17 @@ var printTotalReceipt2Inch = async (data) => {
531
572
  var P = "package=ru.a402d.rawbtprinter;end;";
532
573
  window.location.href = "intent:base64," + base64DataObject + S + P;
533
574
  };
575
+ var printePujaReport2Inch = async (data) => {
576
+ const base64DataObject = await getPujaReportReceipt2InchBase64Data(data);
577
+ var S = "#Intent;scheme=rawbt;";
578
+ var P = "package=ru.a402d.rawbtprinter;end;";
579
+ window.location.href = "intent:base64," + base64DataObject + S + P;
580
+ };
534
581
  export {
535
582
  A4Print_default as A4Print,
536
583
  T2Inch_default as T2Inch,
537
584
  getPrintBlob,
538
585
  printDevoteeReceipt2Inch,
539
- printTotalReceipt2Inch
586
+ printTotalReceipt2Inch,
587
+ printePujaReport2Inch
540
588
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bookmypuja-tech/bmp-pdf",
3
3
  "description": "PDF Report Generation for Temple360 and T-360 by BookMyPuja",
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",