shareneus 1.7.4 → 1.7.6

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.
Files changed (212) hide show
  1. package/README.md +1 -0
  2. package/dist/accounting/invoice/invoice-pdf/invoice-pdf.service.js +18 -45
  3. package/dist/accounting/invoice/reports/excel/analysis-excel.service.js +17 -7
  4. package/dist/accounting/invoice/reports/excel/category-wise-item-excel.service.js +17 -7
  5. package/dist/accounting/invoice/reports/excel/cust-wise-sales-details.js +17 -7
  6. package/dist/accounting/invoice/reports/excel/cust-wise-sales-summary-excel.service.js +17 -7
  7. package/dist/accounting/invoice/reports/excel/invoice-wise-excel.service.js +17 -7
  8. package/dist/accounting/invoice/reports/excel/item-wise-doctor-sale-excel.service.js +17 -7
  9. package/dist/accounting/invoice/reports/excel/items-wise-sales-excel.service.js +17 -7
  10. package/dist/accounting/invoice/reports/excel/manf-wise-sales-excel.service.js +17 -7
  11. package/dist/accounting/invoice/reports/excel/operator-wise-details.js +17 -7
  12. package/dist/accounting/invoice/reports/excel/operator-wise-summary.js +17 -7
  13. package/dist/accounting/invoice/reports/excel/sa-wise-labor-sales-excel.service.js +17 -7
  14. package/dist/accounting/invoice/reports/excel/sa-wise-part-sales-excel.service.js +17 -7
  15. package/dist/accounting/invoice/reports/excel/sale-summary-excel.service.js +17 -7
  16. package/dist/accounting/invoice/reports/excel/sales-by-service-summary-excel.service.js +17 -7
  17. package/dist/accounting/invoice/reports/excel/scheduled-drug-summary-excel.service.js +17 -7
  18. package/dist/accounting/invoice/reports/excel/scheduled-drugs-excel.service.js +17 -7
  19. package/dist/accounting/invoice/unified-invoice-pdf.service.d.ts +1 -1
  20. package/dist/accounting/payment-receive/reports/excel/cust-balance-excel.service.js +17 -7
  21. package/dist/accounting/payment-receive/reports/excel/payment-receive-excel.service.js +17 -7
  22. package/dist/common/reports/excel/product-without-owner-excel.service.js +17 -7
  23. package/dist/gst/excel/GSTR-RO-excel.service.js +17 -7
  24. package/dist/gst/excel/GSTR1-excel.service.js +17 -7
  25. package/dist/gst/excel/GSTR2-excel.service.js +17 -7
  26. package/dist/gst/excel/hsn-summary.js +17 -7
  27. package/dist/gst/excel/tally-sales-import.service.js +17 -7
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +6 -6
  30. package/dist/inventory/items/reports/excel/expiring-drugs-excel.service.js +17 -7
  31. package/dist/inventory/items/reports/excel/item-wise-mout-details.js +17 -7
  32. package/dist/inventory/items/reports/excel/item-wise-mout-summary.js +17 -7
  33. package/dist/inventory/items/reports/excel/spares-issue-excel.service.js +17 -7
  34. package/dist/inventory/items/reports/excel/stock-excel.service.js +17 -7
  35. package/dist/purchases/payment-made/reports/excel/payments-made-excel.service.js +17 -7
  36. package/dist/purchases/payment-made/reports/excel/ven-balance-excel.service.js +17 -7
  37. package/dist/services/reports/excel/insurance-expire-excel.service.js +17 -7
  38. package/dist/services/reports/excel/next-service-date-excel.service.js +17 -7
  39. package/dist/services/reports/excel/repair-orders-excel.service.js +17 -7
  40. package/dist/shared/table-section/pdf-table.header.d.ts +1 -1
  41. package/dist/shared/table-section/pdf-table.header.js +14 -2
  42. package/dist/shared/table-section/pdf-table.section.js +6 -13
  43. package/dist/{accounting/invoice/invoice-pdf.service.js → shared/transactions-pdf.service.js} +15 -15
  44. package/package.json +1 -1
  45. package/src/accounting/counter-sales/auto-sales-receipt-pdf.service.ts +569 -0
  46. package/src/accounting/counter-sales/pos-receipt-pdf.ts +577 -0
  47. package/src/accounting/counter-sales/sales-receipt-pdf.service.ts +628 -0
  48. package/src/accounting/counter-sales/sales-receipt-print.service.ts +506 -0
  49. package/src/accounting/credit-note/cn-print.service.ts +264 -0
  50. package/src/accounting/credit-note/credit-note-pdf.service.ts +602 -0
  51. package/src/accounting/credit-note/credit-note-totals.service.ts +424 -0
  52. package/src/accounting/debit-note/debit-note-pdf.service.ts +681 -0
  53. package/src/accounting/debit-note/debit-note-print.service.ts +276 -0
  54. package/src/accounting/debit-note/debit-note-totals.service.ts +361 -0
  55. package/src/accounting/invoice/hc-inv-pdf.service.ts +880 -0
  56. package/src/accounting/invoice/inv-pdf.service.ts +812 -0
  57. package/src/accounting/invoice/inv-print.service.ts +532 -0
  58. package/src/accounting/invoice/invoice-landscape-pdf.service.ts +947 -0
  59. package/src/accounting/invoice/invoice-letterhead-pdf.service.ts +813 -0
  60. package/src/accounting/invoice/invoice-pdf/invoice-pdf.service.ts +359 -0
  61. package/src/accounting/invoice/invoice-portrait-pdf.ts +972 -0
  62. package/src/accounting/invoice/invoice-print.service.ts +2906 -0
  63. package/src/accounting/invoice/invoice-total.service.ts +834 -0
  64. package/src/accounting/invoice/reports/excel/analysis-excel.service.ts +291 -0
  65. package/src/accounting/invoice/reports/excel/category-wise-item-excel.service.ts +267 -0
  66. package/src/accounting/invoice/reports/excel/cust-wise-sales-details.ts +321 -0
  67. package/src/accounting/invoice/reports/excel/cust-wise-sales-summary-excel.service.ts +300 -0
  68. package/src/accounting/invoice/reports/excel/invoice-wise-excel.service.ts +859 -0
  69. package/src/accounting/invoice/reports/excel/item-wise-doctor-sale-excel.service.ts +255 -0
  70. package/src/accounting/invoice/reports/excel/items-wise-sales-excel.service.ts +312 -0
  71. package/src/accounting/invoice/reports/excel/manf-wise-sales-excel.service.ts +273 -0
  72. package/src/accounting/invoice/reports/excel/operator-wise-details.ts +258 -0
  73. package/src/accounting/invoice/reports/excel/operator-wise-summary.ts +259 -0
  74. package/src/accounting/invoice/reports/excel/sa-wise-labor-sales-excel.service.ts +230 -0
  75. package/src/accounting/invoice/reports/excel/sa-wise-part-sales-excel.service.ts +231 -0
  76. package/src/accounting/invoice/reports/excel/sale-summary-excel.service.ts +326 -0
  77. package/src/accounting/invoice/reports/excel/sales-by-service-details-excel.service.ts +0 -0
  78. package/src/accounting/invoice/reports/excel/sales-by-service-summary-excel.service.ts +432 -0
  79. package/src/accounting/invoice/reports/excel/scheduled-drug-summary-excel.service.ts +373 -0
  80. package/src/accounting/invoice/reports/excel/scheduled-drugs-excel.service.ts +372 -0
  81. package/src/accounting/invoice/reports/pdf/analysis-pdf.service.ts +113 -0
  82. package/src/accounting/invoice/reports/pdf/category-wise-item-pdf.service.ts +107 -0
  83. package/src/accounting/invoice/reports/pdf/cust-wise-sales-details-pdf.service.ts +125 -0
  84. package/src/accounting/invoice/reports/pdf/cust-wise-sales-summary-pdf.service.ts +119 -0
  85. package/src/accounting/invoice/reports/pdf/item-wise-doctor-sale-pdf.service.ts +180 -0
  86. package/src/accounting/invoice/reports/pdf/item-wise-sales-pdf.service.ts +193 -0
  87. package/src/accounting/invoice/reports/pdf/manf-wise-sales-pdf.service.ts +188 -0
  88. package/src/accounting/invoice/reports/pdf/operator-wise-details-pdf.service.ts +118 -0
  89. package/src/accounting/invoice/reports/pdf/operator-wise-summary-pdf.ts +116 -0
  90. package/src/accounting/invoice/reports/pdf/sales-by-service-pdf.service.ts +132 -0
  91. package/src/accounting/invoice/reports/pdf/scheduled-drug-pdf.service.ts +191 -0
  92. package/src/accounting/invoice/reports/pdf/scheduled-drug-summary-pdf.service.ts +202 -0
  93. package/src/accounting/invoice/shared-inv-pdf.service.ts +787 -0
  94. package/src/accounting/invoice/unified-invoice-pdf.service.ts +937 -0
  95. package/src/accounting/payment-receive/payment-pdf.service.ts +410 -0
  96. package/src/accounting/payment-receive/payment-receipt-pdf/receipt-pdf.service.ts +470 -0
  97. package/src/accounting/payment-receive/receipt-print.service.ts +71 -0
  98. package/src/accounting/payment-receive/reports/excel/cust-balance-excel.service.ts +298 -0
  99. package/src/accounting/payment-receive/reports/excel/payment-receive-excel.service.ts +221 -0
  100. package/src/accounting/payment-receive/reports/pdf/customer-balances-pdf.service.ts +182 -0
  101. package/src/accounting/payment-receive/reports/pdf/payment-report-pdf.service.ts +116 -0
  102. package/src/aggregation/aggregation.ts +58 -0
  103. package/src/appointments/appointments/appointment-total.service.ts +298 -0
  104. package/src/appointments/consultations/consultation-fee-receipt.service.ts +407 -0
  105. package/src/appointments/consultations/consultation-full-pdf.service.ts +238 -0
  106. package/src/appointments/consultations/consultation-letterhead-pdf.service.ts +430 -0
  107. package/src/appointments/consultations/consultation-pdf.service.ts +417 -0
  108. package/src/common/reports/excel/product-without-owner-excel.service.ts +308 -0
  109. package/src/common/reports/pdf/product-without-owner-pdf.service.ts +146 -0
  110. package/src/enums/cache-enums.ts +33 -0
  111. package/src/enums/code-enums.ts +291 -0
  112. package/src/enums/country-enums.ts +9 -0
  113. package/src/enums/enums.ts +364 -0
  114. package/src/enums/industry-enums.ts +26 -0
  115. package/src/enums/treatment-enums.ts +9 -0
  116. package/src/gst/excel/GSTR-RO-excel.service.ts +926 -0
  117. package/src/gst/excel/GSTR1-excel.service.ts +313 -0
  118. package/src/gst/excel/GSTR2-excel.service.ts +314 -0
  119. package/src/gst/excel/hsn-summary.ts +314 -0
  120. package/src/gst/excel/tally-sales-import.service.ts +767 -0
  121. package/src/gst/pdf/hsn-summary-pdf.ts +176 -0
  122. package/src/index.ts +194 -0
  123. package/src/inventory/items/adjustment-pdf.service.ts +177 -0
  124. package/src/inventory/items/issue-parts-pdf.service.ts +795 -0
  125. package/src/inventory/items/item-bar-code-label-pdf.ts +194 -0
  126. package/src/inventory/items/item-detais-pdf.ts +141 -0
  127. package/src/inventory/items/item-price-for-pricelist.ts +368 -0
  128. package/src/inventory/items/reports/excel/expiring-drugs-excel.service.ts +290 -0
  129. package/src/inventory/items/reports/excel/item-wise-mout-details.ts +284 -0
  130. package/src/inventory/items/reports/excel/item-wise-mout-summary.ts +279 -0
  131. package/src/inventory/items/reports/excel/spares-issue-excel.service.ts +494 -0
  132. package/src/inventory/items/reports/excel/stock-excel.service.ts +319 -0
  133. package/src/inventory/items/reports/pdf/expiring-drugs-pdf.service.ts +172 -0
  134. package/src/inventory/items/reports/pdf/item-wise-mout-details-pdf.ts +122 -0
  135. package/src/inventory/items/reports/pdf/item-wise-mout-summary-pdf.ts +115 -0
  136. package/src/inventory/items/reports/pdf/reorder-point-pdf.service.ts +163 -0
  137. package/src/inventory/material-out/mout-pdf.service.ts +545 -0
  138. package/src/inventory/transfer-order/transfer-order-pdf.service.ts +154 -0
  139. package/src/purchases/bills/bill-pdf/bill-pdf.service.ts +211 -0
  140. package/src/purchases/bills/bill-pdf.service.ts +21 -0
  141. package/src/purchases/payment-made/reports/excel/payments-made-excel.service.ts +313 -0
  142. package/src/purchases/payment-made/reports/excel/ven-balance-excel.service.ts +307 -0
  143. package/src/purchases/payment-made/reports/pdf/vendor-balances-pdf.service.ts +114 -0
  144. package/src/purchases/purchase-order/po-totals.service.ts +343 -0
  145. package/src/purchases/purchase-order/purchase-order-pdf.service.ts +1016 -0
  146. package/src/purchases/purchase-order/purchase-order-print.service.ts +279 -0
  147. package/src/purchases/purchase-order/purchase-order-totals.service.ts +637 -0
  148. package/src/purchases/vendor-credit-note/vendor-credit-note-pdf.service.ts +1055 -0
  149. package/src/purchases/vendor-credit-note/vendor-credit-note-print.service.ts +145 -0
  150. package/src/purchases/vendor-credit-note/vendor-credit-note-totals.service.ts +399 -0
  151. package/src/purchases/vendor-debit-note/vendor-debit-note-pdf.service.ts +582 -0
  152. package/src/purchases/vendor-debit-note/vendor-debit-note-print.service.ts +295 -0
  153. package/src/purchases/vendor-debit-note/vendor-debit-note-totals.service.ts +377 -0
  154. package/src/sales/delivery-challan/dc-landscape-pdf.service.ts +922 -0
  155. package/src/sales/delivery-challan/dc-landscape-without-price-pdf.service.ts +869 -0
  156. package/src/sales/delivery-challan/dc-without-price-pdf.service.ts +505 -0
  157. package/src/sales/delivery-challan/delivery-challan-pdf.service.ts +461 -0
  158. package/src/sales/delivery-challan/delivery-challan-print.service.ts +229 -0
  159. package/src/sales/delivery-challan/delivery-challan-totals.ts +466 -0
  160. package/src/sales/sales/equipment-design-pdf.service.ts +153 -0
  161. package/src/sales/sales/pack-ship-pdf.service.ts +128 -0
  162. package/src/sales/sales/pack-ship-print.service.ts +198 -0
  163. package/src/sales/sales/sales-pdf.service.ts +658 -0
  164. package/src/sales/sales/sales-print.service.ts +376 -0
  165. package/src/sales/sales/sales-totals.service.ts +500 -0
  166. package/src/sales-receive/sales-receive-pdf.service.ts +602 -0
  167. package/src/sales-receive/sales-receive-print.service.ts +242 -0
  168. package/src/sales-receive/sales-receive-totals.service.ts +651 -0
  169. package/src/services/checklist-pdf.ts +151 -0
  170. package/src/services/checklists-pdf.ts +133 -0
  171. package/src/services/est.print-service.ts +1155 -0
  172. package/src/services/reports/excel/insurance-expire-excel.service.ts +292 -0
  173. package/src/services/reports/excel/next-service-date-excel.service.ts +317 -0
  174. package/src/services/reports/excel/repair-orders-excel.service.ts +249 -0
  175. package/src/services/reports/pdf/insurance-expire-pdf.service.ts +115 -0
  176. package/src/services/reports/pdf/next-service-date-pdf.service.ts +198 -0
  177. package/src/services/reports/pdf/repair-orders-pdf.service.ts +184 -0
  178. package/src/services/ro-pdf.service.ts +1917 -0
  179. package/src/services/ro-print-service.ts +881 -0
  180. package/src/services/ro-totals.service.ts +1314 -0
  181. package/src/services/separate-wo-print.service.ts +396 -0
  182. package/src/services/service-history-pdf.service.ts +145 -0
  183. package/src/services/service-price-for-pricelist.ts +649 -0
  184. package/src/services/technician-pdf.service.ts +234 -0
  185. package/src/services/technician-print.service.ts +95 -0
  186. package/src/shared/header-footer-section/pdf-header-footer.section.ts +519 -0
  187. package/src/shared/header-footer-section/pdf-shared.utils.ts +46 -0
  188. package/src/shared/math-operations.ts +208 -0
  189. package/src/shared/party-details-section/pdf-party-details.section.ts +602 -0
  190. package/src/shared/shared-pdf.service.ts +3042 -0
  191. package/src/shared/shared-print.service.ts +879 -0
  192. package/src/shared/table-section/pdf-table.config.ts +8 -0
  193. package/src/shared/table-section/pdf-table.header.ts +396 -0
  194. package/src/shared/table-section/pdf-table.row.ts +248 -0
  195. package/src/shared/table-section/pdf-table.section.ts +447 -0
  196. package/src/shared/totals-section/pdf-totals.section.ts +921 -0
  197. package/src/shared/transactions-pdf.service.ts +191 -0
  198. package/src/shared/util.ts +101 -0
  199. package/src/tasks/meetings/meeting-pdf.ts +410 -0
  200. package/src/tasks/tasks/task-pdf.service.ts +238 -0
  201. package/src/tasks/tasks/task-reports-pdf.service.ts +313 -0
  202. package/src/tax/index.ts +86 -0
  203. package/src/tax/tax-calculator.ts +1025 -0
  204. package/src/tax/tax.types.ts +535 -0
  205. package/src/transaction-calculations/discounts-distribution.ts +343 -0
  206. package/src/transaction-calculations/index.ts +3 -0
  207. package/src/transaction-calculations/total-calculation.ts +443 -0
  208. package/src/transaction-calculations/transaction-calculation-engine.ts +903 -0
  209. package/src/utils/my-date.ts +111 -0
  210. package/src/utils/tr-utils.ts +104 -0
  211. package/tsconfig.json +2 -2
  212. /package/dist/{accounting/invoice/invoice-pdf.service.d.ts → shared/transactions-pdf.service.d.ts} +0 -0
@@ -0,0 +1,470 @@
1
+ // import * as pdfMake from 'pdfmake/build/pdfmake';
2
+
3
+ import { getAvailablePageWidth } from '../../../shared/table-section/pdf-table.section';
4
+ import { toStr } from '../../../shared/header-footer-section/pdf-shared.utils';
5
+ import {
6
+ buildFooter,
7
+ buildDocumentHeaderSection,
8
+ buildDocumentHeadingSection,
9
+ buildLogoWatermarkBackground,
10
+ buildWatermark,
11
+ deriveHeaderDataFromInvoice,
12
+ normalizeHeaderStyle,
13
+ resolvePageMargins,
14
+ resolvePageOrientation
15
+ } from '../../../shared/header-footer-section/pdf-header-footer.section';
16
+
17
+ const PAGE_SIZE = 'A4';
18
+ const PAGE_MARGINS: [number, number, number, number] = [20, 20, 20, 20];
19
+
20
+ export function CreateReceiptPDFService(DocumentData: any = {}, PrintConfigData: any = {}) {
21
+ const dd = buildPdfDocDefinition(DocumentData, PrintConfigData);
22
+ return dd;
23
+ }
24
+
25
+ export function DownloadReceiptPDFService(filename: string = 'receipt.pdf', DocumentData: any = {}, PrintConfigData: any = {}) {
26
+ const dd = buildPdfDocDefinition(DocumentData, PrintConfigData);
27
+ // pdfMake.createPdf(dd).download(filename);
28
+ return dd;
29
+ }
30
+
31
+ export function GetReceiptPdfDataUrl(DocumentData: any = {}, PrintConfigData: any = {}) {
32
+ const dd = buildPdfDocDefinition(DocumentData, PrintConfigData);
33
+ // const pdfDoc: any = pdfMake.createPdf(dd);
34
+ return dd;
35
+ // return new Promise((resolve, reject) => {
36
+ // let settled = false;
37
+ // const done = (value: string) => {
38
+ // if (!settled) {
39
+ // settled = true;
40
+ // resolve(value);
41
+ // }
42
+ // };
43
+ // const fail = (error: any) => {
44
+ // if (!settled) {
45
+ // settled = true;
46
+ // reject(error);
47
+ // }
48
+ // };
49
+
50
+ // try {
51
+ // if (typeof pdfDoc.getDataUrl === 'function') {
52
+ // const result = pdfDoc.getDataUrl((dataUrl: string) => done(dataUrl));
53
+ // if (result && typeof result.then === 'function') {
54
+ // result.then((dataUrl: string) => done(dataUrl)).catch(fail);
55
+ // }
56
+ // return;
57
+ // }
58
+
59
+ // if (typeof pdfDoc.getBlob === 'function') {
60
+ // const result = pdfDoc.getBlob((blob: Blob) => done(URL.createObjectURL(blob)));
61
+ // if (result && typeof result.then === 'function') {
62
+ // result.then((blob: Blob) => done(URL.createObjectURL(blob))).catch(fail);
63
+ // }
64
+ // return;
65
+ // }
66
+
67
+ // fail(new Error('No supported preview API found on pdf document instance.'));
68
+ // } catch (error) {
69
+ // fail(error);
70
+ // }
71
+ // });
72
+ }
73
+
74
+ export function buildPdfDocDefinition(DocumentData: any = {}, PrintConfigData: any = {}) {
75
+ const PrintConfig = normalizePrintConfig(DocumentData, PrintConfigData);
76
+ const pageOrientation = resolvePageOrientation(PrintConfig?.pageOrientation);
77
+ const pageMargins = resolvePageMargins(PrintConfig?.Margin);
78
+ const availableWidth = getAvailablePageWidth(PAGE_SIZE, pageOrientation, pageMargins);
79
+ const watermark = buildWatermark(PrintConfig);
80
+ const background = buildLogoWatermarkBackground(PrintConfig, DocumentData);
81
+ const footer = buildFooter(PrintConfig);
82
+
83
+ const invoiceHeaderContent = buildDocumentHeaderSection(PrintConfig, DocumentData);
84
+ const invoiceHeadingContent = buildDocumentHeadingSection(DocumentData, PrintConfig, availableWidth);
85
+ const receiptMetaContent = buildReceiptMetaSection(DocumentData);
86
+
87
+ return {
88
+ pageSize: PAGE_SIZE,
89
+ pageOrientation,
90
+ pageMargins,
91
+ content: [
92
+ ...invoiceHeaderContent,
93
+ ...invoiceHeadingContent,
94
+ {
95
+ margin: [20, 0, 20, 0],
96
+ stack: receiptMetaContent
97
+ }
98
+ ],
99
+ info: {
100
+ title: 'receipt',
101
+ subject: toStr(PrintConfig?.subject) || 'receipt header and heading'
102
+ },
103
+ ...(background ? { background } : {}),
104
+ ...(watermark ? { watermark } : {}),
105
+ ...(footer ? { footer } : {})
106
+ };
107
+ }
108
+
109
+ function buildReceiptMetaSection(DocumentData: any) {
110
+ const receiptNo = toStr(DocumentData?.PaymentId).trim() || '-';
111
+ const paymentDate = formatDate(DocumentData?.PaidDate);
112
+ const fullName = toStr(DocumentData?.FullName).trim() || '-';
113
+ const paymentMode = toStr(DocumentData?.PaymentType).trim() || '-';
114
+ const amountInWords = amountToWords(DocumentData?.TotalAmount);
115
+ const totalAmount = formatAmount(DocumentData?.TotalAmount);
116
+
117
+ return [
118
+ {
119
+ columns: [
120
+ {
121
+ width: '*',
122
+ text: [
123
+ { text: 'Receipt No: ', color: '#6b7280' },
124
+ { text: receiptNo, bold: true, color: '#111827' }
125
+ ],
126
+ fontSize: 10,
127
+ margin: [0, 0, 0, 12]
128
+ },
129
+ {
130
+ width: '*',
131
+ text: [
132
+ { text: 'Payment Date: ', color: '#6b7280' },
133
+ { text: paymentDate, bold: true, color: '#111827' }
134
+ ],
135
+ fontSize: 10,
136
+ alignment: 'right',
137
+ margin: [0, 0, 0, 12]
138
+ }
139
+ ]
140
+ },
141
+ {
142
+ columns: [
143
+ {
144
+ width: 86,
145
+ text: 'Amount',
146
+ color: '#6b7280',
147
+ fontSize: 10,
148
+ alignment: 'left',
149
+ margin: [0, 9, 4, 0]
150
+ },
151
+ {
152
+ width: 10,
153
+ text: ':',
154
+ color: '#6b7280',
155
+ fontSize: 10,
156
+ alignment: 'center',
157
+ margin: [0, 9, 8, 0]
158
+ },
159
+ {
160
+ width: 'auto',
161
+ table: {
162
+ body: [[{
163
+ text: totalAmount,
164
+ bold: true,
165
+ fontSize: 18,
166
+ color: '#111827',
167
+ fillColor: '#f9fafb',
168
+ margin: [6, 3, 6, 3]
169
+ }]]
170
+ },
171
+ layout: {
172
+ hLineColor: () => '#d1d5db',
173
+ vLineColor: () => '#d1d5db',
174
+ hLineWidth: () => 1,
175
+ vLineWidth: () => 1,
176
+ paddingLeft: () => 6,
177
+ paddingRight: () => 6,
178
+ paddingTop: () => 3,
179
+ paddingBottom: () => 3
180
+ }
181
+ }
182
+ ],
183
+ margin: [0, 0, 0, 16]
184
+ },
185
+ createDottedValueRow('Received From', fullName),
186
+ createDottedValueRow('In Words', amountInWords),
187
+ createDottedValueRow('Payment Mode', paymentMode),
188
+ ...buildPaymentForSection(DocumentData),
189
+ // ...buildRefundForSection(DocumentData),
190
+ ...buildAuthorizedSignatureSection(DocumentData)
191
+ ];
192
+ }
193
+
194
+ function createDottedValueRow(label: string, value: string) {
195
+ const displayValue = toStr(value).trim() || '-';
196
+ return {
197
+ columns: [
198
+ {
199
+ width: 86,
200
+ text: label,
201
+ color: '#6b7280',
202
+ fontSize: 10,
203
+ alignment: 'left',
204
+ margin: [0, 0, 4, 0]
205
+ },
206
+ {
207
+ width: 10,
208
+ text: ':',
209
+ color: '#6b7280',
210
+ fontSize: 10,
211
+ alignment: 'center',
212
+ margin: [0, 0, 8, 0]
213
+ },
214
+ {
215
+ width: '*',
216
+ stack: [
217
+ {
218
+ canvas: [
219
+ { type: 'line', x1: 0, y1: 10, x2: 420, y2: 10, lineWidth: 0.8, lineColor: '#6b7280', dash: { length: 2, space: 2 } }
220
+ ]
221
+ },
222
+ { text: displayValue, bold: true, color: '#111827', fontSize: 10, margin: [4, -12, 0, 0] }
223
+ ],
224
+ margin: [0, 0, 0, 16]
225
+ }
226
+ ]
227
+ };
228
+ }
229
+
230
+ function buildPaymentForSection(DocumentData: any) {
231
+ const allocRefs = Array.isArray(DocumentData?.AllocRefs) ? DocumentData.AllocRefs : [];
232
+ const invoiceRefs = allocRefs.filter((entry: any) => String(entry?.Type || '').toUpperCase() === 'INV');
233
+ if (invoiceRefs.length === 0) {
234
+ return [];
235
+ }
236
+
237
+ const tableBody: any[] = [
238
+ [
239
+ { text: 'S.No', bold: true, fillColor: '#f3f4f6', fontSize: 9 },
240
+ { text: 'Invoice#', bold: true, fillColor: '#f3f4f6', fontSize: 9 },
241
+ { text: 'Amount', bold: true, fillColor: '#f3f4f6', fontSize: 9, alignment: 'right' }
242
+ ]
243
+ ];
244
+
245
+ invoiceRefs.forEach((entry: any, index: number) => {
246
+ const invoiceNo = toStr(entry?.Code || '-').trim() || '-';
247
+ const amount = formatTableAmount(entry?.Amt);
248
+ tableBody.push([
249
+ { text: `${index + 1}`, fontSize: 9 },
250
+ { text: invoiceNo, fontSize: 9 },
251
+ { text: amount, fontSize: 9, alignment: 'right' }
252
+ ]);
253
+ });
254
+
255
+ return [
256
+ {
257
+ text: 'Payment For',
258
+ bold: true,
259
+ fontSize: 11,
260
+ color: '#374151',
261
+ alignment: 'left',
262
+ margin: [0, 6, 0, 8]
263
+ },
264
+ {
265
+ table: {
266
+ headerRows: 1,
267
+ widths: [36, 124, 80],
268
+ body: tableBody
269
+ },
270
+ layout: {
271
+ hLineColor: () => '#e5e7eb',
272
+ vLineColor: () => '#e5e7eb',
273
+ hLineWidth: () => 0.5,
274
+ vLineWidth: () => 0.5,
275
+ paddingLeft: () => 5,
276
+ paddingRight: () => 5,
277
+ paddingTop: () => 4,
278
+ paddingBottom: () => 4
279
+ },
280
+ margin: [0, 0, 0, 8]
281
+ }
282
+ ];
283
+ }
284
+
285
+ // function buildRefundForSection(DocumentData: any) {
286
+ // const allocRefs = Array.isArray(DocumentData?.AllocRefs) ? DocumentData.AllocRefs : [];
287
+ // const refundRefs = allocRefs.filter((entry: any) => String(entry?.Type || '').toUpperCase() === 'REF');
288
+ // if (refundRefs.length === 0) {
289
+ // return [];
290
+ // }
291
+
292
+ // const tableBody: any[] = [
293
+ // [
294
+ // { text: 'S.No', bold: true, fillColor: '#f3f4f6', fontSize: 10 },
295
+ // { text: 'Refund#', bold: true, fillColor: '#f3f4f6', fontSize: 10 },
296
+ // { text: 'Amount', bold: true, fillColor: '#f3f4f6', fontSize: 10, alignment: 'right' }
297
+ // ]
298
+ // ];
299
+
300
+ // refundRefs.forEach((entry: any, index: number) => {
301
+ // const refundNo = toStr(entry?.RefundNo || entry?.RefNo || entry?.No || entry?.Code || entry?.Id || '-').trim() || '-';
302
+ // const amount = formatTableAmount(entry?.Amount ?? entry?.AllocAmt ?? entry?.Amt ?? entry?.Value);
303
+ // tableBody.push([
304
+ // { text: `${index + 1}`, fontSize: 10 },
305
+ // { text: refundNo, fontSize: 10 },
306
+ // { text: amount, fontSize: 10, alignment: 'right' }
307
+ // ]);
308
+ // });
309
+
310
+ // return [
311
+ // {
312
+ // text: 'Refund For',
313
+ // bold: true,
314
+ // fontSize: 11,
315
+ // color: '#374151',
316
+ // margin: [0, 6, 0, 8]
317
+ // },
318
+ // {
319
+ // table: {
320
+ // headerRows: 1,
321
+ // widths: [42, '*', 100],
322
+ // body: tableBody
323
+ // },
324
+ // layout: {
325
+ // hLineColor: () => '#e5e7eb',
326
+ // vLineColor: () => '#e5e7eb',
327
+ // hLineWidth: () => 0.5,
328
+ // vLineWidth: () => 0.5,
329
+ // paddingLeft: () => 6,
330
+ // paddingRight: () => 6,
331
+ // paddingTop: () => 5,
332
+ // paddingBottom: () => 5
333
+ // },
334
+ // margin: [0, 0, 0, 8]
335
+ // }
336
+ // ];
337
+ // }
338
+
339
+ function buildAuthorizedSignatureSection(DocumentData: any) {
340
+ const companyName = toStr(DocumentData?.Entity?.CName).trim();
341
+
342
+ return [
343
+ {
344
+ width: '*',
345
+ stack: [
346
+ {
347
+ text: [
348
+ { text: 'For ', color: '#6b7280' },
349
+ { text: companyName || '-', bold: true, color: '#111827' }
350
+ ],
351
+ alignment: 'right',
352
+ fontSize: 10,
353
+ margin: [0, 8, 0, 32]
354
+ },
355
+ { text: 'Authorized Signature', alignment: 'right', bold: true, color: '#111827', fontSize: 10 }
356
+ ]
357
+ }
358
+ ];
359
+ }
360
+
361
+ function formatDate(value: any) {
362
+ const raw = toStr(value).trim();
363
+ if (!raw) {
364
+ return '-';
365
+ }
366
+ const dt = new Date(raw);
367
+ if (Number.isNaN(dt.getTime())) {
368
+ return raw;
369
+ }
370
+ const day = String(dt.getDate()).padStart(2, '0');
371
+ const month = dt.toLocaleString('en-US', { month: 'short' });
372
+ const year = dt.getFullYear();
373
+ return `${day}-${month}-${year}`;
374
+ }
375
+
376
+ function formatAmount(value: any) {
377
+ const amount = Number(value);
378
+ if (!Number.isFinite(amount)) {
379
+ return '-';
380
+ }
381
+ if (Number.isInteger(amount)) {
382
+ return `Rs. ${amount}/-`;
383
+ }
384
+ return `Rs. ${amount.toFixed(2)}/-`;
385
+ }
386
+
387
+ function formatTableAmount(value: any) {
388
+ const amount = Number(value);
389
+ if (!Number.isFinite(amount)) {
390
+ return '-';
391
+ }
392
+ return Number.isInteger(amount) ? `${amount}` : `${amount.toFixed(2)}`;
393
+ }
394
+
395
+ function amountToWords(value: any) {
396
+ const amount = Number(value);
397
+ if (!Number.isFinite(amount) || amount < 0) {
398
+ return '-';
399
+ }
400
+ const integerPart = Math.floor(amount);
401
+ const decimalPart = Math.round((amount - integerPart) * 100);
402
+ const integerWords = numberToWords(integerPart);
403
+ if (!decimalPart) {
404
+ return `${integerWords} Rupee(s) Only`;
405
+ }
406
+ return `${integerWords} Rupee(s) and ${numberToWords(decimalPart)} Paise Only`;
407
+ }
408
+
409
+ function numberToWords(n: number): string {
410
+ if (n === 0) {
411
+ return 'Zero';
412
+ }
413
+
414
+ const belowTwenty = ['', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten',
415
+ 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'];
416
+ const tens = ['', '', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'];
417
+ const units = [
418
+ { value: 1000000000, label: 'Billion' },
419
+ { value: 1000000, label: 'Million' },
420
+ { value: 1000, label: 'Thousand' },
421
+ { value: 100, label: 'Hundred' }
422
+ ];
423
+
424
+ const toWords = (num: number): string => {
425
+ if (num < 20) {
426
+ return belowTwenty[num];
427
+ }
428
+ if (num < 100) {
429
+ return `${tens[Math.floor(num / 10)]}${num % 10 ? ' ' + belowTwenty[num % 10] : ''}`;
430
+ }
431
+ for (const unit of units) {
432
+ if (num >= unit.value) {
433
+ const quotient = Math.floor(num / unit.value);
434
+ const remainder = num % unit.value;
435
+ const left = `${toWords(quotient)} ${unit.label}`;
436
+ return remainder ? `${left} ${toWords(remainder)}` : left;
437
+ }
438
+ }
439
+ return '';
440
+ };
441
+
442
+ return toWords(n).trim();
443
+ }
444
+
445
+ function normalizePrintConfig(DocumentData: any, PrintConfigData: any) {
446
+ const config = PrintConfigData || {};
447
+ const headerData = config?.headerData ? config.headerData : deriveHeaderDataFromInvoice(DocumentData);
448
+ const pageMargins = resolvePageMargins(config?.pageMargins ?? PAGE_MARGINS);
449
+ const watermarkText = toStr(config?.watermarkText);
450
+ const watermark = !!config?.watermark;
451
+ const watermarkEnabled = !!config?.watermarkEnabled;
452
+ const footerText = toStr(config?.footerText);
453
+ const headerStyles = normalizeHeaderStyle(config?.headerStyles ?? {
454
+ OrgNameFsize: config?.OrgNameFsize,
455
+ OrgNameClr: config?.OrgNameClr,
456
+ AdrsFsize: config?.AdrsFsize,
457
+ AdrsClr: config?.AdrsClr
458
+ });
459
+
460
+ return {
461
+ ...config,
462
+ headerData,
463
+ pageMargins,
464
+ watermarkText,
465
+ watermark,
466
+ watermarkEnabled,
467
+ footerText,
468
+ headerStyles
469
+ };
470
+ }
@@ -0,0 +1,71 @@
1
+ import { Add } from "../../shared/math-operations";
2
+ import { PrintSharedService } from "../../shared/shared-print.service";
3
+ import { MyDate } from "../../utils/my-date";
4
+ import { TrUtils } from "../../utils/tr-utils";
5
+
6
+ declare var pdfMake: any;
7
+
8
+ export class ReceiptPrintService {
9
+
10
+ static GetReceiptPrint(argPaymentViewData: any, EntityData: any, image: any) {
11
+ let PaymentViewData = TrUtils.Stringify(argPaymentViewData);
12
+ let ReceiptData: any = {};
13
+ ReceiptData.Entity = PrintSharedService.GetFormattedEntityDataForPrint(EntityData, "Receipt", argPaymentViewData);
14
+ ReceiptData = PrintSharedService.GetEntityHeaderStyles(ReceiptData, EntityData, image);
15
+ ReceiptData.FullName = PaymentViewData.Name;
16
+ // if (PaymentViewData.PType === 'Cash') {
17
+ // ReceiptData.TypeNumber = PaymentViewData.Amt;
18
+ // } else
19
+ if (PaymentViewData.PType === 'Cheque' || PaymentViewData.PType === 'MasterCard') {
20
+ ReceiptData.TypeNumber = PaymentViewData.CNo;
21
+ } else if (PaymentViewData.PType === 'Visa') {
22
+ ReceiptData.TypeNumber = PaymentViewData.CNo;
23
+ } else {
24
+ ReceiptData.TypeNumber = '';
25
+ }
26
+ ReceiptData.TotalAmount = PaymentViewData.Amt;
27
+ ReceiptData.RemAmt = PaymentViewData.RemAmt;
28
+ let Refunds: any = PaymentViewData?.AllocRefs?.filter((ref: any) => ref.Type === 'CR');
29
+ if (!TrUtils.IsNull(Refunds) && Refunds.length > 0) {
30
+ let Amount: number = 0;
31
+ for (let i = 0; i < Refunds.length; i++) {
32
+ Amount = Add(Amount, Refunds[i].Amt);
33
+ }
34
+ ReceiptData.RefundAmount = Amount;
35
+ }
36
+ ReceiptData.PaidDate = MyDate.ConvertUTCDateToReadable(PaymentViewData.Date);
37
+ ReceiptData.Ids = this.GetRecordIds(PaymentViewData);
38
+ ReceiptData.AllocRefs = PaymentViewData.AllocRefs;
39
+ ReceiptData.Type = 'Receipt';
40
+ ReceiptData.HeaderName = 'Receipt';
41
+ ReceiptData.PaymentId = PaymentViewData.Code;
42
+ ReceiptData.PaymentType = PaymentViewData.PType;
43
+ return ReceiptData;
44
+ }
45
+
46
+ static GetRecordIds(PaymentViewData: any) {
47
+ let IdList: any = [];
48
+ var i = 0;
49
+ if (!TrUtils.IsNull(PaymentViewData.AllocRefs) && PaymentViewData.AllocRefs.length !== 0) {
50
+ let Invoices: any = PaymentViewData?.AllocRefs?.filter((ref: any) => ref.Type === 'INV');
51
+ for (i = 0; i < Invoices.length; i++) {
52
+ let Id: any = Invoices[i].Code;
53
+ if (!TrUtils.IsNull(Invoices[i].RegNo)) {
54
+ Id = Id + '(' + Invoices[i].RegNo + ')';
55
+ }
56
+ IdList.push(Id);
57
+ }
58
+ }
59
+ if (!TrUtils.IsNull(PaymentViewData.Invs) && PaymentViewData.Invs.length !== 0) {
60
+ for (i = 0; i < PaymentViewData.Invs.length; i++) {
61
+ let Id: any = PaymentViewData.Invs[i].Code;
62
+ if (!TrUtils.IsNull(PaymentViewData.Invs[i].RegNo)) {
63
+ Id = Id + '(' + PaymentViewData.Invs[i].RegNo + ')';
64
+ }
65
+ IdList.push(Id);
66
+ }
67
+ }
68
+ return IdList;
69
+ }
70
+
71
+ }