shareneus 1.7.3 → 1.7.5

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 (213) 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/shared/totals-section/pdf-totals.section.js +1 -1
  44. package/dist/{accounting/invoice/invoice-pdf.service.js → shared/transactions-pdf.service.js} +14 -14
  45. package/package.json +1 -1
  46. package/src/accounting/counter-sales/auto-sales-receipt-pdf.service.ts +569 -0
  47. package/src/accounting/counter-sales/pos-receipt-pdf.ts +577 -0
  48. package/src/accounting/counter-sales/sales-receipt-pdf.service.ts +628 -0
  49. package/src/accounting/counter-sales/sales-receipt-print.service.ts +506 -0
  50. package/src/accounting/credit-note/cn-print.service.ts +264 -0
  51. package/src/accounting/credit-note/credit-note-pdf.service.ts +602 -0
  52. package/src/accounting/credit-note/credit-note-totals.service.ts +424 -0
  53. package/src/accounting/debit-note/debit-note-pdf.service.ts +681 -0
  54. package/src/accounting/debit-note/debit-note-print.service.ts +276 -0
  55. package/src/accounting/debit-note/debit-note-totals.service.ts +361 -0
  56. package/src/accounting/invoice/hc-inv-pdf.service.ts +880 -0
  57. package/src/accounting/invoice/inv-pdf.service.ts +812 -0
  58. package/src/accounting/invoice/inv-print.service.ts +532 -0
  59. package/src/accounting/invoice/invoice-landscape-pdf.service.ts +947 -0
  60. package/src/accounting/invoice/invoice-letterhead-pdf.service.ts +813 -0
  61. package/src/accounting/invoice/invoice-pdf/invoice-pdf.service.ts +359 -0
  62. package/src/accounting/invoice/invoice-portrait-pdf.ts +972 -0
  63. package/src/accounting/invoice/invoice-print.service.ts +2906 -0
  64. package/src/accounting/invoice/invoice-total.service.ts +834 -0
  65. package/src/accounting/invoice/reports/excel/analysis-excel.service.ts +291 -0
  66. package/src/accounting/invoice/reports/excel/category-wise-item-excel.service.ts +267 -0
  67. package/src/accounting/invoice/reports/excel/cust-wise-sales-details.ts +321 -0
  68. package/src/accounting/invoice/reports/excel/cust-wise-sales-summary-excel.service.ts +300 -0
  69. package/src/accounting/invoice/reports/excel/invoice-wise-excel.service.ts +859 -0
  70. package/src/accounting/invoice/reports/excel/item-wise-doctor-sale-excel.service.ts +255 -0
  71. package/src/accounting/invoice/reports/excel/items-wise-sales-excel.service.ts +312 -0
  72. package/src/accounting/invoice/reports/excel/manf-wise-sales-excel.service.ts +273 -0
  73. package/src/accounting/invoice/reports/excel/operator-wise-details.ts +258 -0
  74. package/src/accounting/invoice/reports/excel/operator-wise-summary.ts +259 -0
  75. package/src/accounting/invoice/reports/excel/sa-wise-labor-sales-excel.service.ts +230 -0
  76. package/src/accounting/invoice/reports/excel/sa-wise-part-sales-excel.service.ts +231 -0
  77. package/src/accounting/invoice/reports/excel/sale-summary-excel.service.ts +326 -0
  78. package/src/accounting/invoice/reports/excel/sales-by-service-details-excel.service.ts +0 -0
  79. package/src/accounting/invoice/reports/excel/sales-by-service-summary-excel.service.ts +432 -0
  80. package/src/accounting/invoice/reports/excel/scheduled-drug-summary-excel.service.ts +373 -0
  81. package/src/accounting/invoice/reports/excel/scheduled-drugs-excel.service.ts +372 -0
  82. package/src/accounting/invoice/reports/pdf/analysis-pdf.service.ts +113 -0
  83. package/src/accounting/invoice/reports/pdf/category-wise-item-pdf.service.ts +107 -0
  84. package/src/accounting/invoice/reports/pdf/cust-wise-sales-details-pdf.service.ts +125 -0
  85. package/src/accounting/invoice/reports/pdf/cust-wise-sales-summary-pdf.service.ts +119 -0
  86. package/src/accounting/invoice/reports/pdf/item-wise-doctor-sale-pdf.service.ts +180 -0
  87. package/src/accounting/invoice/reports/pdf/item-wise-sales-pdf.service.ts +193 -0
  88. package/src/accounting/invoice/reports/pdf/manf-wise-sales-pdf.service.ts +188 -0
  89. package/src/accounting/invoice/reports/pdf/operator-wise-details-pdf.service.ts +118 -0
  90. package/src/accounting/invoice/reports/pdf/operator-wise-summary-pdf.ts +116 -0
  91. package/src/accounting/invoice/reports/pdf/sales-by-service-pdf.service.ts +132 -0
  92. package/src/accounting/invoice/reports/pdf/scheduled-drug-pdf.service.ts +191 -0
  93. package/src/accounting/invoice/reports/pdf/scheduled-drug-summary-pdf.service.ts +202 -0
  94. package/src/accounting/invoice/shared-inv-pdf.service.ts +787 -0
  95. package/src/accounting/invoice/unified-invoice-pdf.service.ts +937 -0
  96. package/src/accounting/payment-receive/payment-pdf.service.ts +410 -0
  97. package/src/accounting/payment-receive/payment-receipt-pdf/receipt-pdf.service.ts +470 -0
  98. package/src/accounting/payment-receive/receipt-print.service.ts +71 -0
  99. package/src/accounting/payment-receive/reports/excel/cust-balance-excel.service.ts +298 -0
  100. package/src/accounting/payment-receive/reports/excel/payment-receive-excel.service.ts +221 -0
  101. package/src/accounting/payment-receive/reports/pdf/customer-balances-pdf.service.ts +182 -0
  102. package/src/accounting/payment-receive/reports/pdf/payment-report-pdf.service.ts +116 -0
  103. package/src/aggregation/aggregation.ts +58 -0
  104. package/src/appointments/appointments/appointment-total.service.ts +298 -0
  105. package/src/appointments/consultations/consultation-fee-receipt.service.ts +407 -0
  106. package/src/appointments/consultations/consultation-full-pdf.service.ts +238 -0
  107. package/src/appointments/consultations/consultation-letterhead-pdf.service.ts +430 -0
  108. package/src/appointments/consultations/consultation-pdf.service.ts +417 -0
  109. package/src/common/reports/excel/product-without-owner-excel.service.ts +308 -0
  110. package/src/common/reports/pdf/product-without-owner-pdf.service.ts +146 -0
  111. package/src/enums/cache-enums.ts +33 -0
  112. package/src/enums/code-enums.ts +291 -0
  113. package/src/enums/country-enums.ts +9 -0
  114. package/src/enums/enums.ts +364 -0
  115. package/src/enums/industry-enums.ts +26 -0
  116. package/src/enums/treatment-enums.ts +9 -0
  117. package/src/gst/excel/GSTR-RO-excel.service.ts +926 -0
  118. package/src/gst/excel/GSTR1-excel.service.ts +313 -0
  119. package/src/gst/excel/GSTR2-excel.service.ts +314 -0
  120. package/src/gst/excel/hsn-summary.ts +314 -0
  121. package/src/gst/excel/tally-sales-import.service.ts +767 -0
  122. package/src/gst/pdf/hsn-summary-pdf.ts +176 -0
  123. package/src/index.ts +194 -0
  124. package/src/inventory/items/adjustment-pdf.service.ts +177 -0
  125. package/src/inventory/items/issue-parts-pdf.service.ts +795 -0
  126. package/src/inventory/items/item-bar-code-label-pdf.ts +194 -0
  127. package/src/inventory/items/item-detais-pdf.ts +141 -0
  128. package/src/inventory/items/item-price-for-pricelist.ts +368 -0
  129. package/src/inventory/items/reports/excel/expiring-drugs-excel.service.ts +290 -0
  130. package/src/inventory/items/reports/excel/item-wise-mout-details.ts +284 -0
  131. package/src/inventory/items/reports/excel/item-wise-mout-summary.ts +279 -0
  132. package/src/inventory/items/reports/excel/spares-issue-excel.service.ts +494 -0
  133. package/src/inventory/items/reports/excel/stock-excel.service.ts +319 -0
  134. package/src/inventory/items/reports/pdf/expiring-drugs-pdf.service.ts +172 -0
  135. package/src/inventory/items/reports/pdf/item-wise-mout-details-pdf.ts +122 -0
  136. package/src/inventory/items/reports/pdf/item-wise-mout-summary-pdf.ts +115 -0
  137. package/src/inventory/items/reports/pdf/reorder-point-pdf.service.ts +163 -0
  138. package/src/inventory/material-out/mout-pdf.service.ts +545 -0
  139. package/src/inventory/transfer-order/transfer-order-pdf.service.ts +154 -0
  140. package/src/purchases/bills/bill-pdf/bill-pdf.service.ts +211 -0
  141. package/src/purchases/bills/bill-pdf.service.ts +21 -0
  142. package/src/purchases/payment-made/reports/excel/payments-made-excel.service.ts +313 -0
  143. package/src/purchases/payment-made/reports/excel/ven-balance-excel.service.ts +307 -0
  144. package/src/purchases/payment-made/reports/pdf/vendor-balances-pdf.service.ts +114 -0
  145. package/src/purchases/purchase-order/po-totals.service.ts +343 -0
  146. package/src/purchases/purchase-order/purchase-order-pdf.service.ts +1016 -0
  147. package/src/purchases/purchase-order/purchase-order-print.service.ts +279 -0
  148. package/src/purchases/purchase-order/purchase-order-totals.service.ts +637 -0
  149. package/src/purchases/vendor-credit-note/vendor-credit-note-pdf.service.ts +1055 -0
  150. package/src/purchases/vendor-credit-note/vendor-credit-note-print.service.ts +145 -0
  151. package/src/purchases/vendor-credit-note/vendor-credit-note-totals.service.ts +399 -0
  152. package/src/purchases/vendor-debit-note/vendor-debit-note-pdf.service.ts +582 -0
  153. package/src/purchases/vendor-debit-note/vendor-debit-note-print.service.ts +295 -0
  154. package/src/purchases/vendor-debit-note/vendor-debit-note-totals.service.ts +377 -0
  155. package/src/sales/delivery-challan/dc-landscape-pdf.service.ts +922 -0
  156. package/src/sales/delivery-challan/dc-landscape-without-price-pdf.service.ts +869 -0
  157. package/src/sales/delivery-challan/dc-without-price-pdf.service.ts +505 -0
  158. package/src/sales/delivery-challan/delivery-challan-pdf.service.ts +461 -0
  159. package/src/sales/delivery-challan/delivery-challan-print.service.ts +229 -0
  160. package/src/sales/delivery-challan/delivery-challan-totals.ts +466 -0
  161. package/src/sales/sales/equipment-design-pdf.service.ts +153 -0
  162. package/src/sales/sales/pack-ship-pdf.service.ts +128 -0
  163. package/src/sales/sales/pack-ship-print.service.ts +198 -0
  164. package/src/sales/sales/sales-pdf.service.ts +658 -0
  165. package/src/sales/sales/sales-print.service.ts +376 -0
  166. package/src/sales/sales/sales-totals.service.ts +500 -0
  167. package/src/sales-receive/sales-receive-pdf.service.ts +602 -0
  168. package/src/sales-receive/sales-receive-print.service.ts +242 -0
  169. package/src/sales-receive/sales-receive-totals.service.ts +651 -0
  170. package/src/services/checklist-pdf.ts +151 -0
  171. package/src/services/checklists-pdf.ts +133 -0
  172. package/src/services/est.print-service.ts +1155 -0
  173. package/src/services/reports/excel/insurance-expire-excel.service.ts +292 -0
  174. package/src/services/reports/excel/next-service-date-excel.service.ts +317 -0
  175. package/src/services/reports/excel/repair-orders-excel.service.ts +249 -0
  176. package/src/services/reports/pdf/insurance-expire-pdf.service.ts +115 -0
  177. package/src/services/reports/pdf/next-service-date-pdf.service.ts +198 -0
  178. package/src/services/reports/pdf/repair-orders-pdf.service.ts +184 -0
  179. package/src/services/ro-pdf.service.ts +1917 -0
  180. package/src/services/ro-print-service.ts +881 -0
  181. package/src/services/ro-totals.service.ts +1314 -0
  182. package/src/services/separate-wo-print.service.ts +396 -0
  183. package/src/services/service-history-pdf.service.ts +145 -0
  184. package/src/services/service-price-for-pricelist.ts +649 -0
  185. package/src/services/technician-pdf.service.ts +234 -0
  186. package/src/services/technician-print.service.ts +95 -0
  187. package/src/shared/header-footer-section/pdf-header-footer.section.ts +519 -0
  188. package/src/shared/header-footer-section/pdf-shared.utils.ts +46 -0
  189. package/src/shared/math-operations.ts +208 -0
  190. package/src/shared/party-details-section/pdf-party-details.section.ts +602 -0
  191. package/src/shared/shared-pdf.service.ts +3042 -0
  192. package/src/shared/shared-print.service.ts +879 -0
  193. package/src/shared/table-section/pdf-table.config.ts +8 -0
  194. package/src/shared/table-section/pdf-table.header.ts +396 -0
  195. package/src/shared/table-section/pdf-table.row.ts +248 -0
  196. package/src/shared/table-section/pdf-table.section.ts +447 -0
  197. package/src/shared/totals-section/pdf-totals.section.ts +921 -0
  198. package/src/shared/transactions-pdf.service.ts +191 -0
  199. package/src/shared/util.ts +101 -0
  200. package/src/tasks/meetings/meeting-pdf.ts +410 -0
  201. package/src/tasks/tasks/task-pdf.service.ts +238 -0
  202. package/src/tasks/tasks/task-reports-pdf.service.ts +313 -0
  203. package/src/tax/index.ts +86 -0
  204. package/src/tax/tax-calculator.ts +1025 -0
  205. package/src/tax/tax.types.ts +535 -0
  206. package/src/transaction-calculations/discounts-distribution.ts +343 -0
  207. package/src/transaction-calculations/index.ts +3 -0
  208. package/src/transaction-calculations/total-calculation.ts +443 -0
  209. package/src/transaction-calculations/transaction-calculation-engine.ts +903 -0
  210. package/src/utils/my-date.ts +111 -0
  211. package/src/utils/tr-utils.ts +104 -0
  212. package/tsconfig.json +2 -2
  213. /package/dist/{accounting/invoice/invoice-pdf.service.d.ts → shared/transactions-pdf.service.d.ts} +0 -0
@@ -0,0 +1,506 @@
1
+ import { ROTypeEnum } from "../../enums/code-enums";
2
+ import { InvoiceStatusEnum, PayTypeEnum } from "../../enums/enums";
3
+ import { Add, Divide, Multiply, Subtract } from "../../shared/math-operations";
4
+ import { PrintSharedService } from "../../shared/shared-print.service";
5
+ import { MyDate } from "../../utils/my-date";
6
+ import { TrUtils } from "../../utils/tr-utils";
7
+ import { InvoiceTotalsService } from "../invoice/invoice-total.service";
8
+
9
+
10
+
11
+
12
+
13
+ export class SaleReceiptPrintService {
14
+
15
+ static GetTaxAmountFromTaxes(item: any, taxCode: string) {
16
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
17
+ const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
18
+ if (matchedTaxes.length !== 0) {
19
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Amt), 0);
20
+ }
21
+ return 0;
22
+ }
23
+
24
+ static GetTaxRateFromTaxes(item: any, taxCode: string) {
25
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
26
+ const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
27
+ if (matchedTaxes.length !== 0) {
28
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Rate), 0);
29
+ }
30
+ return 0;
31
+ }
32
+
33
+ static GetTCodeFromTaxes(item: any) {
34
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
35
+ const matchedTax = taxes.find((tax: any) => !TrUtils.IsNull(tax?.TaxCodeId));
36
+ if (!TrUtils.IsNull(matchedTax?.TaxCodeId)) {
37
+ return matchedTax.TaxCodeId;
38
+ }
39
+ return item?.TCode;
40
+ }
41
+
42
+ static GetSaleReceiptPrintInfo(OriginalInvoiceData: any, OriginalEntityData: any, image: any,
43
+ IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean, OBN: boolean) {
44
+
45
+ let ForInsurance: boolean = !TrUtils.IsNull(OriginalInvoiceData.BillTo) && !TrUtils.IsNull(OriginalInvoiceData.BillTo.InsId);
46
+
47
+ let InvoicePrintData: any = {};
48
+
49
+ let argInvoiceData = TrUtils.Stringify(OriginalInvoiceData);
50
+
51
+ if (!IncludeGST) {
52
+ if (argInvoiceData.Settings.Tax === 'TI') {
53
+ argInvoiceData.Settings.Tax = 'NO';
54
+ }
55
+ }
56
+
57
+ InvoicePrintData.IsProforma = IsProforma;
58
+
59
+ InvoicePrintData.Settings = TrUtils.Stringify(argInvoiceData.Settings);
60
+ InvoicePrintData.SType = TrUtils.Stringify(argInvoiceData.SType);
61
+
62
+ let SType: any = TrUtils.IsNull(argInvoiceData.SType) ? null : argInvoiceData.SType;
63
+
64
+ InvoicePrintData = this.GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, ForInsurance,
65
+ SType, argInvoiceData, IsProforma);
66
+
67
+ InvoicePrintData.Entity = PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalInvoiceData);
68
+
69
+ InvoicePrintData = PrintSharedService.GetEntityHeaderStyles(InvoicePrintData, OriginalEntityData, image);
70
+
71
+ InvoicePrintData = this.GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData);
72
+
73
+ let IsTaxable: boolean = (IncludeGST && TrUtils.isTaxable(argInvoiceData.Settings.Tax)) ? true : false;
74
+ if (TrUtils.IsNull(argInvoiceData.Ops)) {
75
+ argInvoiceData.Ops = [];
76
+ }
77
+
78
+ let finalTotalsData: any = InvoiceTotalsService.GetTotalsValue(argInvoiceData.Ops, argInvoiceData.Items, IsTaxable,
79
+ true, argInvoiceData.LDisc, argInvoiceData.LPerc, argInvoiceData.PDisc, argInvoiceData.PPerc,
80
+ argInvoiceData.Disc, argInvoiceData.Perc, TaxCodes, true, argInvoiceData.Settings, argInvoiceData.Adjust, InvoicePrintData.Entity.Round, InvoicePrintData.Entity);
81
+ if (ConsolidateGST) {
82
+ finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
83
+ finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
84
+ }
85
+
86
+ InvoicePrintData = TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
87
+
88
+ InvoicePrintData.Ops = this.GetLaborPrintInfo(InvoicePrintData.Ops, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
89
+
90
+ InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, OBN, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
91
+ // InvoicePrintData.Items = InvoicePrintData.Items.filter((item: any) => {
92
+ // return !item.Ret;
93
+ // })
94
+ argInvoiceData = this.ReverseItemsForInvoicePrint(argInvoiceData);
95
+
96
+ InvoicePrintData.PrintInfo = this.PrepareFormatForInvoicePrint(InvoicePrintData, ROTypeEnum.Invoice, argInvoiceData.Sts);
97
+
98
+ InvoicePrintData = this.GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
99
+
100
+ InvoicePrintData = this.GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData);
101
+
102
+ let PaymentData = this.GetPaymentsTotal(argInvoiceData.Pay, InvoicePrintData.Total, argInvoiceData.Sts, InvoicePrintData.Entity.DecimalsNumber);
103
+ // if (argInvoiceData.Settings.DiscLvl !== 'REC') {
104
+ // InvoicePrintData.FixedDisc = null;
105
+ // }
106
+ InvoicePrintData.Due = TrUtils.FixPriceValue(argInvoiceData.Due, InvoicePrintData.Entity.DecimalsNumber);
107
+ InvoicePrintData.Paid = argInvoiceData.Receipt ? argInvoiceData.Total : PaymentData.Paid;
108
+ if (!TrUtils.IsNull(PaymentData.Sts)) {
109
+ InvoicePrintData.Sts = PaymentData.Sts;
110
+ }
111
+ InvoicePrintData.Consolidate = ConsolidateGST;
112
+ InvoicePrintData.ShowDiscountColumn = false;
113
+ if (!ForInsurance && !ConsolidateGST) {
114
+ if (PrintSharedService.CheckItemIndexWithDisc(InvoicePrintData) !== -1) {
115
+ InvoicePrintData.ShowDiscountColumn = (InvoicePrintData.Settings.DiscLvl === 'ITM' || InvoicePrintData.Settings.DiscLvl === 'RECITM') ? true : false;
116
+
117
+ }
118
+ }
119
+ if (OriginalInvoiceData.Type === '1') {
120
+ InvoicePrintData.From = 'Sales';
121
+ }
122
+
123
+ // console.log('InvoicePrintData', InvoicePrintData);
124
+
125
+ return InvoicePrintData;
126
+ }
127
+
128
+ static GetPrintConditionsBasedOnInput(InvoicePrintData: any, IncludeGST: boolean, ConsolidateGST: boolean,
129
+ ForInsurance: boolean, SType: any, OriginalInvoiceData: any, IsProforma: boolean) {
130
+
131
+ InvoicePrintData.ForInsurance = ForInsurance;
132
+ InvoicePrintData.For = ForInsurance ? PayTypeEnum.Insurance : PayTypeEnum.Customer;
133
+ InvoicePrintData.IncludeGST = IncludeGST;
134
+ InvoicePrintData.ConsolidateGST = ConsolidateGST;
135
+
136
+ InvoicePrintData.ShowAccParts = false;
137
+
138
+ InvoicePrintData.ShowIGST = (TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
139
+
140
+ InvoicePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
141
+ // InvoicePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
142
+
143
+ InvoicePrintData = this.GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma);
144
+
145
+ InvoicePrintData.PrDate = TrUtils.IsNull(OriginalInvoiceData.PrDate) ? '' : MyDate.ConvertUTCDateToReadable(OriginalInvoiceData.PrDate);
146
+
147
+ return InvoicePrintData;
148
+ }
149
+
150
+ static GetInvoiceTypeHeading(InvoicePrintData: any, OriginalInvoiceData: any, IncludeGST: boolean,
151
+ ConsolidateGST: boolean, IsProforma: boolean) {
152
+ if (ConsolidateGST) {
153
+ InvoicePrintData.HeaderName = 'Sales Receipt';
154
+ } else if (IsProforma) {
155
+ InvoicePrintData.HeaderName = 'pro-forma Invoice';
156
+ } else {
157
+ if (OriginalInvoiceData.Type === 'Sales') {
158
+ // if (IncludeGST && !ConsolidateGST) {
159
+ // InvoicePrintData.HeaderName = 'Parts Tax Invoice';
160
+ // } else {
161
+ // InvoicePrintData.HeaderName = 'Parts Invoice';
162
+ // }
163
+ InvoicePrintData.PrintType = 'Parts Order';
164
+ if (InvoicePrintData.Settings.Tax === 'BS') {
165
+ InvoicePrintData.HeaderName = 'Bill of Supply';
166
+ } else {
167
+ if (InvoicePrintData.Settings.Tax === 'TI') {
168
+ InvoicePrintData.HeaderName = 'Parts Tax Invoice';
169
+ } else {
170
+ InvoicePrintData.HeaderName = 'Parts Invoice';
171
+ }
172
+ }
173
+ } else {
174
+ // if (IncludeGST && !ConsolidateGST) {
175
+ // InvoicePrintData.HeaderName = 'Tax Invoice';
176
+ // } else {
177
+ // InvoicePrintData.HeaderName = 'Invoice';
178
+ // }
179
+
180
+ if (InvoicePrintData.Settings.Tax === 'BS') {
181
+ InvoicePrintData.HeaderName = 'Bill of Supply';
182
+ } else {
183
+ if (InvoicePrintData.Settings.Tax === 'TI') {
184
+ if (OriginalInvoiceData.Receipt) {
185
+ InvoicePrintData.HeaderName = 'Tax Sales Receipt';
186
+ } else {
187
+ InvoicePrintData.HeaderName = 'Tax Invoice';
188
+ }
189
+
190
+ } else {
191
+ if (OriginalInvoiceData.Receipt) {
192
+ InvoicePrintData.HeaderName = 'Sales Receipt';
193
+
194
+ } else {
195
+ InvoicePrintData.HeaderName = 'Invoice';
196
+
197
+ }
198
+ }
199
+ }
200
+ }
201
+ }
202
+ return InvoicePrintData;
203
+ }
204
+
205
+ static GetInvoiceOtherDetailsForPrint(InvoicePrintData: any, OriginalInvoiceData: any) {
206
+ InvoicePrintData.Type = 'Invoice';
207
+ InvoicePrintData._id = OriginalInvoiceData.Code;
208
+ InvoicePrintData.Sts = OriginalInvoiceData.Sts;
209
+ InvoicePrintData.Name = OriginalInvoiceData.Name;
210
+ InvoicePrintData.CrDate = MyDate.ConvertUTCDateTimeToReadable(OriginalInvoiceData.CrDate, InvoicePrintData.Entity.User.TZ);
211
+ return InvoicePrintData;
212
+ }
213
+
214
+ static GetLaborPrintInfo(LaborList: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
215
+ LaborList.forEach((Labor: any) => {
216
+ Labor.HSN = Labor.SAC;
217
+ if (Consolidate) {
218
+ Labor.UnPr = TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
219
+ } else {
220
+ Labor.UnPr = TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
221
+ }
222
+ Labor.TCode = this.GetTCodeFromTaxes(Labor);
223
+ Labor.CGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'CGST'), DecimalsNumber);
224
+ Labor.SGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'SGST'), DecimalsNumber);
225
+ Labor.IGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'IGST'), DecimalsNumber);
226
+ Labor.CGSTPerc = this.GetTaxRateFromTaxes(Labor, 'CGST');
227
+ Labor.SGSTPerc = this.GetTaxRateFromTaxes(Labor, 'SGST');
228
+ Labor.IGSTPerc = this.GetTaxRateFromTaxes(Labor, 'IGST');
229
+ if (LineTotal === 'AT') {
230
+ Labor.LineTotal = TrUtils.FixPriceValue(Labor.AfterLaborTax, DecimalsNumber);
231
+ } else {
232
+ Labor.LineTotal = TrUtils.FixPriceValue(Subtract(Labor.Amt, Labor.Disc), DecimalsNumber);
233
+ }
234
+ });
235
+ return LaborList;
236
+ }
237
+
238
+ static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, OBN: boolean, LineTotal: string, DecimalsNumber: number) {
239
+ Items.forEach((Item: any) => {
240
+ const itemCGST = this.GetTaxAmountFromTaxes(Item, 'CGST');
241
+ const itemSGST = this.GetTaxAmountFromTaxes(Item, 'SGST');
242
+ const itemIGST = this.GetTaxAmountFromTaxes(Item, 'IGST');
243
+ if (Consolidate) {
244
+ let AfterDiscForEach = Divide(Item.AfterPartDisc, Item.Qty);
245
+ let CTaxAmtPerItem = Divide(itemCGST, Item.Qty);
246
+ let STaxAmtPerItem = Divide(itemSGST, Item.Qty);
247
+ let ITaxAmtPerItem = Divide(itemIGST, Item.Qty);
248
+ let DiscPerItem = Divide(Add(Item.Disc, Item.RecDisc), Item.Qty);
249
+ Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, DiscPerItem, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
250
+ } else {
251
+ Item.UnPr = TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
252
+ }
253
+ Item.ExDt = this.GetExpiryDate(Item);
254
+ Item.BN = this.GetBatchesData(Item, OBN);
255
+ Item.TCode = this.GetTCodeFromTaxes(Item);
256
+ Item.CGSTAmt = TrUtils.FixedTo(itemCGST, DecimalsNumber);
257
+ if (TrUtils.IsNull(Item.ConUt)) {
258
+ Item.ConUt = 1;
259
+ }
260
+ if (!TrUtils.IsNull(Item.Make)) {
261
+ Item.Make = Item.Make?.slice(0, 4).toUpperCase();
262
+ }
263
+ Item.Qty = TrUtils.FixedTo(Multiply(Item.Qty, Item.ConUt), DecimalsNumber);
264
+ Item.SGSTAmt = TrUtils.FixedTo(itemSGST, DecimalsNumber);
265
+ Item.IGSTAmt = TrUtils.FixedTo(itemIGST, DecimalsNumber);
266
+ Item.CGSTPerc = this.GetTaxRateFromTaxes(Item, 'CGST');
267
+ Item.SGSTPerc = this.GetTaxRateFromTaxes(Item, 'SGST');
268
+ Item.TaxName = this.getTaxName(Item.TCode, TaxCodes);
269
+ Item.IGSTPerc = this.GetTaxRateFromTaxes(Item, 'IGST');
270
+ if (Consolidate) {
271
+ Item.LineTotal = TrUtils.FixPriceValue(Multiply(Item.UnPr, Item.Qty), DecimalsNumber);
272
+ } else {
273
+ if (LineTotal === 'AT') {
274
+ Item.LineTotal = TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
275
+ } else {
276
+ Item.LineTotal = TrUtils.FixPriceValue(Subtract(Item.UnAmt, Item.Disc), DecimalsNumber);
277
+ }
278
+ }
279
+ if (!TrUtils.IsZero(Item.Qty) && !TrUtils.CheckInvalidSelect(Item.UoM)) {
280
+ Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
281
+ }
282
+ });
283
+ return Items;
284
+ }
285
+
286
+ static getTaxName(TCode: any, TaxCodes: any) {
287
+ let Index: any = TaxCodes.findIndex((TaxCode: any) => {
288
+ return Number(TCode) === TaxCode._id;
289
+ });
290
+ return (Index !== -1) ? TaxCodes[Index].Name : '';
291
+ }
292
+
293
+ static GetBatchesData(Item: any, OBN: boolean) {
294
+ if (!TrUtils.IsNull(Item.Batches)) {
295
+ let batchdata: any;
296
+ Item.Batches.forEach((batch: any) => {
297
+ if (OBN) {
298
+ let BN: any = TrUtils.IsNull(batch.MBN) ? batch.BN : batch.MBN;
299
+ if (!TrUtils.IsNull(batchdata)) {
300
+ batchdata = batchdata + ',' + BN;
301
+ } else {
302
+ batchdata = BN;
303
+ }
304
+ } else {
305
+ if (!TrUtils.IsNull(batchdata)) {
306
+ batchdata = batchdata + ',' + batch.BN;
307
+ } else {
308
+ batchdata = batch.BN;
309
+ }
310
+ }
311
+
312
+ });
313
+ return batchdata;
314
+ } else if (!TrUtils.IsNull(Item.Batch)) {
315
+ if (OBN) {
316
+ let BN: any = TrUtils.IsNull(Item.Batch.MBN) ? Item.Batch.BN : Item.Batch.MBN;
317
+ return BN
318
+ } else {
319
+ return Item.Batch.BN;
320
+ }
321
+ } else {
322
+ return '';
323
+ }
324
+ }
325
+
326
+ static GetExpiryDate(Item: any) {
327
+ if (!TrUtils.IsNull(Item.Batches)) {
328
+ let batchdata: any;
329
+ Item.Batches.forEach((batch: any) => {
330
+ if (!TrUtils.IsNull(batchdata)) {
331
+ batchdata = batchdata + ',' + MyDate.ConvertUTCDateToReadableExDate(batch.ExDt);
332
+ } else {
333
+ batchdata = MyDate.ConvertUTCDateToReadableExDate(batch.ExDt);
334
+ }
335
+ });
336
+ return batchdata;
337
+ } else if (!TrUtils.IsNull(Item.Batch)) {
338
+ return MyDate.ConvertUTCDateToReadableExDate(Item.Batch.ExDt);
339
+ } else {
340
+ return '';
341
+ }
342
+ }
343
+
344
+ static ReverseItemsForInvoicePrint(argInvoiceData: any) {
345
+ // argInvoiceData.Ops = argInvoiceData.Ops.reverse();
346
+ // argInvoiceData.Items = argInvoiceData.Items.reverse();
347
+ return argInvoiceData;
348
+ }
349
+
350
+ static PrepareFormatForInvoicePrint(InvoicePrintData: any, ROType: any, InvoiceStatus: any) {
351
+ let PrintInfo: any[] = [];
352
+
353
+ let ROLaborParts: any = {};
354
+
355
+ ROLaborParts.Ops = InvoicePrintData.Ops;
356
+
357
+ ROLaborParts.Items = InvoicePrintData.Items;
358
+
359
+ ROLaborParts.Sts = InvoiceStatus;
360
+ ROLaborParts.Type = ROType;
361
+
362
+ PrintInfo.push(ROLaborParts);
363
+ return PrintInfo;
364
+ }
365
+
366
+ static GetFormattedProductDataForPrint(OriginalInvoiceData: any, InvoicePrintData: any) {
367
+ if (!TrUtils.IsNull(OriginalInvoiceData.Prod)) {
368
+ InvoicePrintData.Product = OriginalInvoiceData.Prod;
369
+ if (TrUtils.IsNull(InvoicePrintData.Product.VIN)) {
370
+ InvoicePrintData.Product.VIN = '';
371
+ }
372
+ if (TrUtils.IsNull(InvoicePrintData.Product.RegNo)) {
373
+ InvoicePrintData.Product.RegNo = '';
374
+ }
375
+ if (TrUtils.IsNull(InvoicePrintData.Product.EngNo)) {
376
+ InvoicePrintData.Product.EngNo = '';
377
+ }
378
+ InvoicePrintData.MIn = OriginalInvoiceData.Prod.MIn;
379
+ InvoicePrintData.MOut = OriginalInvoiceData.Prod.MOut;
380
+ }
381
+ return InvoicePrintData;
382
+ }
383
+
384
+ static GetBillNameForInvoicePrint(OriginalInvoiceData: any, InvoicePrintData: any) {
385
+ let Customer: any = {};
386
+ if (!TrUtils.IsNull(OriginalInvoiceData.BillTo)) {
387
+ Customer.Name = OriginalInvoiceData.BillTo.Name;
388
+ Customer.Code = OriginalInvoiceData.BillTo.Code;
389
+ Customer.Doctor = TrUtils.IsNull(OriginalInvoiceData.Name) ? '' : OriginalInvoiceData.Name;
390
+ Customer.Adrs = [];
391
+ Customer.Cons = [];
392
+ if (!TrUtils.IsNull(OriginalInvoiceData.BillTo.Adrs)) {
393
+ Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.A1);
394
+ if (!TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Adrs.A2)) {
395
+ Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.A2);
396
+ }
397
+ if (!TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Adrs.Ct)) {
398
+ Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.Ct);
399
+ }
400
+ }
401
+ Customer.GSTIN = OriginalInvoiceData.BillTo.GSTIN;
402
+
403
+ if (!TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Ph)) {
404
+ Customer.Cons = [
405
+ {
406
+ Type: 'M',
407
+ No: OriginalInvoiceData.BillTo.Ph
408
+ }
409
+ ];
410
+ }
411
+ InvoicePrintData.Customer = Customer;
412
+
413
+
414
+ } else if (!TrUtils.IsNull(OriginalInvoiceData.BillTo)) {
415
+ Customer.Name = OriginalInvoiceData.BillTo.Name;
416
+ Customer.Adrs = [];
417
+ Customer.Cons = [];
418
+ InvoicePrintData.Customer = Customer;
419
+ } else {
420
+ InvoicePrintData.Customer = {};
421
+ }
422
+
423
+
424
+ if (!TrUtils.IsNull(OriginalInvoiceData.ShipTo)) {
425
+ let location: any = {};
426
+ location.Adrs = PrintSharedService.GetAddress(OriginalInvoiceData.ShipTo.Adrs);
427
+ let Name: any;
428
+ if (TrUtils.IsNull(OriginalInvoiceData.ShipTo.Name)) {
429
+ Name = OriginalInvoiceData.ShipTo.ConName;
430
+ } else {
431
+ Name = OriginalInvoiceData.ShipTo.Name;
432
+ }
433
+ if (TrUtils.IsNull(Name)) {
434
+ Name = '';
435
+ }
436
+ location.Name = Name;
437
+ if (!TrUtils.IsNull(OriginalInvoiceData.ShipTo.ConPh)) {
438
+ location.Cons = [
439
+ {
440
+ Type: 'M',
441
+ No: OriginalInvoiceData.ShipTo.ConPh
442
+ }
443
+ ];
444
+ }
445
+
446
+ InvoicePrintData.Location = location;
447
+ }
448
+ return InvoicePrintData;
449
+ }
450
+
451
+ static GetCustomerDetails(OriginalInvoiceData: any) {
452
+ let Customer: any = {};
453
+ Customer.Name = this.GetBillToName(OriginalInvoiceData.BillTo.Title, OriginalInvoiceData.BillTo.Name);
454
+ Customer.Cons = [];
455
+ if (!TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Ph)) {
456
+ Customer.Cons = [
457
+ {
458
+ Type: 'M',
459
+ No: OriginalInvoiceData.BillTo.Ph
460
+ }
461
+ ];
462
+ }
463
+ Customer.GSTIN = OriginalInvoiceData.BillTo.GSTIN;
464
+ Customer.Adrs = [];
465
+ if (!TrUtils.IsNull(OriginalInvoiceData.BillTo.Adrs)) {
466
+ Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.A1);
467
+ if (!TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Adrs.A2)) {
468
+ Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.A2);
469
+ }
470
+ Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.Ct);
471
+ }
472
+ Customer.ConName = OriginalInvoiceData.BillTo.ConName;
473
+ Customer.ConPh = OriginalInvoiceData.BillTo.ConPhone;
474
+ return Customer;
475
+ }
476
+
477
+ static GetBillToName(Title: any, Name: string) {
478
+ return TrUtils.IsEmpty(Title) ? Name : Title + ' ' + Name;
479
+ }
480
+
481
+ static GetPaymentsTotal(InvoicePayments: any, Total: number, InvoiceStatus: string, DecimalsNumber: number) {
482
+ if (TrUtils.IsNull(InvoicePayments)) {
483
+ InvoicePayments = [];
484
+ }
485
+ var i = 0;
486
+ let Data: any = {};
487
+ let PaidTotal: any = 0;
488
+ for (i = 0; i < InvoicePayments.length; i++) {
489
+ PaidTotal += InvoicePayments[i].Amt;
490
+ }
491
+ if (InvoiceStatus === InvoiceStatusEnum.Closed) {
492
+ Data.Due = 0;
493
+ } else {
494
+ Data.Due = TrUtils.FixedTo(Subtract(Total, PaidTotal), DecimalsNumber);
495
+ }
496
+ if (Data.Due < 0) {
497
+ Data.Due = 0;
498
+ }
499
+ if (Data.Due === 0) {
500
+ Data.Sts = InvoiceStatusEnum.Closed;
501
+ }
502
+ Data.Paid = TrUtils.FixedTo(PaidTotal, DecimalsNumber);
503
+ return Data;
504
+ }
505
+
506
+ }