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,532 @@
1
+
2
+
3
+ import { ROTypeEnum } from '../../enums/code-enums';
4
+ import { InvoiceStatusEnum, PayTypeEnum } from '../../enums/enums';
5
+ import { Add, Divide, Multiply, Subtract } from '../../shared/math-operations';
6
+ import { PrintSharedService } from '../../shared/shared-print.service';
7
+ import { MyDate } from '../../utils/my-date';
8
+ import { TrUtils } from '../../utils/tr-utils';
9
+ import { InvoiceTotalsService } from './invoice-total.service';
10
+
11
+ export function GetInvoicePrintInfo(OriginalInvoiceData: any, OriginalEntityData: any, image: any,
12
+ IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean, PartsPrint: boolean, LaborPrint: boolean) {
13
+
14
+ let ForInsurance: boolean = !TrUtils.IsNull(OriginalInvoiceData.BillTo) && !TrUtils.IsNull(OriginalInvoiceData.BillTo.Ins_Id);
15
+
16
+ let InvoicePrintData: any = {};
17
+
18
+ let argInvoiceData = TrUtils.Stringify(OriginalInvoiceData);
19
+
20
+ if (!IncludeGST) {
21
+ if (argInvoiceData.Settings.Tax === 'TI') {
22
+ argInvoiceData.Settings.Tax = 'NO';
23
+ }
24
+ }
25
+
26
+ InvoicePrintData.IsProforma = IsProforma;
27
+
28
+ InvoicePrintData.Settings = TrUtils.Stringify(argInvoiceData.Settings);
29
+ InvoicePrintData.SType = TrUtils.Stringify(argInvoiceData.SType);
30
+
31
+ let SType: any
32
+
33
+ if (!TrUtils.IsNull(argInvoiceData.SType)) {
34
+ SType = argInvoiceData.SType
35
+ }
36
+
37
+ InvoicePrintData = GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, ForInsurance,
38
+ SType, argInvoiceData, IsProforma, PartsPrint, LaborPrint);
39
+
40
+ InvoicePrintData.Entity = PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalInvoiceData);
41
+
42
+ InvoicePrintData = PrintSharedService.GetEntityHeaderStyles(InvoicePrintData, OriginalEntityData, image);
43
+
44
+ InvoicePrintData = GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData);
45
+
46
+ let IsTaxable: boolean = (IncludeGST && TrUtils.isTaxable(argInvoiceData.Settings.Tax)) ? true : false;
47
+
48
+ let finalTotalsData: any = InvoiceTotalsService.GetTotalsValue(argInvoiceData.Ops, argInvoiceData.Items, IsTaxable,
49
+ true, argInvoiceData.LDisc, argInvoiceData.LPerc, argInvoiceData.PDisc, argInvoiceData.PPerc,
50
+ argInvoiceData.Disc, argInvoiceData.Perc, TaxCodes, true, argInvoiceData.Settings, argInvoiceData.Adjust, InvoicePrintData.Entity.Round, InvoicePrintData.Entity);
51
+
52
+ if (ConsolidateGST) {
53
+ finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
54
+ finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
55
+ }
56
+
57
+ InvoicePrintData = TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
58
+
59
+ InvoicePrintData.Ops = GetLaborPrintInfo(InvoicePrintData.Ops, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
60
+
61
+ InvoicePrintData.Items = GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
62
+
63
+ argInvoiceData = ReverseItemsForInvoicePrint(argInvoiceData);
64
+
65
+ InvoicePrintData.PrintInfo = PrepareFormatForInvoicePrint(InvoicePrintData, ROTypeEnum.Invoice, argInvoiceData.Sts);
66
+
67
+ InvoicePrintData = GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
68
+
69
+ InvoicePrintData = GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData);
70
+
71
+ let PaymentData = GetPaymentsTotal(argInvoiceData.Credits, argInvoiceData.Payments, argInvoiceData.Total, argInvoiceData.Sts, InvoicePrintData.Entity.DecimalsNumber);
72
+ // if (argInvoiceData.Settings.DiscLvl !== 'REC') {
73
+ // InvoicePrintData.FixedDisc = null;
74
+ // }
75
+ InvoicePrintData.Due = PaymentData.Due;
76
+ InvoicePrintData.Paid = argInvoiceData.Receipt ? argInvoiceData.Total : PaymentData.Paid;
77
+ if (!TrUtils.IsNull(PaymentData.Sts)) {
78
+ InvoicePrintData.Sts = PaymentData.Sts;
79
+ }
80
+ InvoicePrintData.Consolidate = ConsolidateGST;
81
+ InvoicePrintData.ShowDiscountColumn = false;
82
+ if (!ForInsurance && !ConsolidateGST) {
83
+ if (PrintSharedService.CheckItemIndexWithDisc(InvoicePrintData) !== -1) {
84
+ // InvoicePrintData.ShowDiscountColumn = (InvoicePrintData.Settings.DiscLvl === 'ITM' || InvoicePrintData.Settings.DiscLvl === 'RECITM') ? true : false;
85
+ InvoicePrintData.ShowDiscountColumn = true;
86
+ }
87
+ }
88
+ if (OriginalInvoiceData.Type === '1') {
89
+ InvoicePrintData.From = 'Sales';
90
+ }
91
+
92
+ if (OriginalInvoiceData.isCountersale) {
93
+ InvoicePrintData.From = 'Countersale';
94
+ }
95
+
96
+ if (TrUtils.IsNull(OriginalInvoiceData.BL)) {
97
+ OriginalInvoiceData.BL = {};
98
+ }
99
+
100
+ InvoicePrintData.BL = TrUtils.Stringify(OriginalInvoiceData.BL);
101
+ OriginalInvoiceData.BL.RefNo = OriginalInvoiceData.RefNo;
102
+ // console.log('InvoicePrintData', InvoicePrintData);
103
+
104
+ return InvoicePrintData;
105
+ }
106
+
107
+ export function GetPrintConditionsBasedOnInput(InvoicePrintData: any, IncludeGST: boolean, ConsolidateGST: boolean,
108
+ ForInsurance: boolean, SType: any, OriginalInvoiceData: any, IsProforma: boolean, PartsPrint: boolean, LaborPrint: boolean) {
109
+
110
+ InvoicePrintData.ForInsurance = ForInsurance;
111
+ InvoicePrintData.For = ForInsurance ? PayTypeEnum.Insurance : PayTypeEnum.Customer;
112
+ InvoicePrintData.IncludeGST = IncludeGST;
113
+ InvoicePrintData.ConsolidateGST = ConsolidateGST;
114
+
115
+ InvoicePrintData.ShowAccParts = true;
116
+
117
+ InvoicePrintData.ShowIGST = (TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
118
+
119
+ InvoicePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
120
+ // InvoicePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
121
+
122
+ InvoicePrintData = GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma, PartsPrint, LaborPrint);
123
+
124
+ InvoicePrintData.PrDate = TrUtils.IsNull(OriginalInvoiceData.PrDate) ? '' : MyDate.ConvertUTCDateToReadable(OriginalInvoiceData.PrDate);
125
+
126
+ return InvoicePrintData;
127
+ }
128
+
129
+ export function GetInvoiceTypeHeading(InvoicePrintData: any, OriginalInvoiceData: any, IncludeGST: boolean,
130
+ ConsolidateGST: boolean, IsProforma: boolean, PartsPrint: boolean, LaborPrint: boolean) {
131
+ // console.log(IsProforma,PartsPrint,LaborPrint);
132
+ if (OriginalInvoiceData.CheckParts) {
133
+ InvoicePrintData.HeaderName = "Spares Issue";
134
+ } else if (OriginalInvoiceData.isCountersale) {
135
+ InvoicePrintData.HeaderName = 'Counter Sale Invoice';
136
+ } else if (IsProforma) {
137
+ // InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE';
138
+ if (PartsPrint && !LaborPrint) {
139
+ InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (PARTS)';
140
+ } else if (LaborPrint && !PartsPrint) {
141
+ InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (LABOR)';
142
+ } else {
143
+ InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE';
144
+ }
145
+ } else {
146
+ if (OriginalInvoiceData.Type === 'Sales') {
147
+ // if (IncludeGST && !ConsolidateGST) {
148
+ // InvoicePrintData.HeaderName = 'Parts Tax Invoice';
149
+ // } else {
150
+ // InvoicePrintData.HeaderName = 'Parts Invoice';
151
+ // }
152
+ InvoicePrintData.PrintType = 'PARTS ORDER';
153
+ if (InvoicePrintData.Settings.Tax === 'BS' || ConsolidateGST) {
154
+ InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
155
+ } else {
156
+ if (InvoicePrintData.Settings.Tax === 'TI') {
157
+ InvoicePrintData.HeaderName = 'PARTS TAX INVOICE';
158
+ } else {
159
+ InvoicePrintData.HeaderName = 'PARTS INVOICE';
160
+ }
161
+ }
162
+ } else {
163
+ // if (IncludeGST && !ConsolidateGST) {
164
+ // InvoicePrintData.HeaderName = 'Tax Invoice';
165
+ // } else {
166
+ // InvoicePrintData.HeaderName = 'Invoice';
167
+ // }
168
+
169
+ if (InvoicePrintData.Settings.Tax === 'BS') {
170
+ // InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
171
+ if (PartsPrint && !LaborPrint) {
172
+ InvoicePrintData.HeaderName = 'BILL OF SUPPLY (PARTS)';
173
+ } else if (LaborPrint && !PartsPrint) {
174
+ InvoicePrintData.HeaderName = 'BILL OF SUPPLY (LABOR)';
175
+ } else {
176
+ InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
177
+ }
178
+ } else {
179
+ if (InvoicePrintData.Settings.Tax === 'TI') {
180
+ if (OriginalInvoiceData.Receipt) {
181
+ InvoicePrintData.HeaderName = 'TAX SALES RECEIPT';
182
+ } else {
183
+ if (PartsPrint && !LaborPrint) {
184
+ InvoicePrintData.HeaderName = 'TAX INVOICE (PARTS)';
185
+ } else if (LaborPrint && !PartsPrint) {
186
+ InvoicePrintData.HeaderName = 'TAX INVOICE (LABOR)';
187
+ } else {
188
+ InvoicePrintData.HeaderName = 'TAX INVOICE';
189
+ }
190
+
191
+ }
192
+
193
+ } else {
194
+ if (OriginalInvoiceData.Receipt) {
195
+ InvoicePrintData.HeaderName = 'SALES RECEIPT';
196
+
197
+ } else {
198
+ // InvoicePrintData.HeaderName = 'INVOICE';
199
+ if (PartsPrint && !LaborPrint) {
200
+ InvoicePrintData.HeaderName = 'INVOICE (PARTS)';
201
+ } else if (LaborPrint && !PartsPrint) {
202
+ InvoicePrintData.HeaderName = 'INVOICE (LABOR)';
203
+ } else {
204
+ InvoicePrintData.HeaderName = 'INVOICE';
205
+ }
206
+ }
207
+ }
208
+ }
209
+ }
210
+ }
211
+ return InvoicePrintData;
212
+ }
213
+
214
+ export function GetInvoiceOtherDetailsForPrint(InvoicePrintData: any, argInvoiceData: any) {
215
+ InvoicePrintData.Type = argInvoiceData.isCountersale ? 'SalesReceipt' : argInvoiceData.CheckParts ? 'Work Order' : 'Invoice';
216
+ InvoicePrintData._id = argInvoiceData.Code;
217
+ InvoicePrintData.ROCode = argInvoiceData.OrdCode;
218
+ InvoicePrintData.ROCode = argInvoiceData.OrdCode;
219
+ InvoicePrintData.TypeName = argInvoiceData.TypeName;
220
+ InvoicePrintData.Sts = argInvoiceData.Sts;
221
+ InvoicePrintData.AdmNo = argInvoiceData.AdmNo;
222
+ InvoicePrintData.CrDate = MyDate.ConvertUTCDateToReadable(argInvoiceData.CrDate);
223
+ return InvoicePrintData;
224
+ }
225
+
226
+ export function GetTaxAmountFromTaxes(item: any, taxCode: string) {
227
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
228
+ const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
229
+ if (matchedTaxes.length !== 0) {
230
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Amt), 0);
231
+ }
232
+ return 0;
233
+ }
234
+
235
+ export function GetTaxRateFromTaxes(item: any, taxCode: string) {
236
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
237
+ const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
238
+ if (matchedTaxes.length !== 0) {
239
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Rate), 0);
240
+ }
241
+ return 0;
242
+ }
243
+
244
+ export function GetTCodeFromTaxes(item: any) {
245
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
246
+ const matchedTax = taxes.find((tax: any) => !TrUtils.IsNull(tax?.TaxCodeId));
247
+ if (!TrUtils.IsNull(matchedTax?.TaxCodeId)) {
248
+ return matchedTax.TaxCodeId;
249
+ }
250
+ return item?.TCode;
251
+ }
252
+
253
+ export function GetLaborPrintInfo(LaborList: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
254
+ LaborList.forEach((Labor: any) => {
255
+ Labor.HSN = Labor.SAC;
256
+ if (TrUtils.IsNull(Labor.Qty)) {
257
+ Labor.Qty = 1;
258
+ }
259
+ if (Consolidate) {
260
+ Labor.UnPr = TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
261
+ } else {
262
+ Labor.UnPr = TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
263
+ }
264
+ if (!TrUtils.IsEmpty(Labor.Perc)) {
265
+ Labor.DiscPerc = Labor.Perc;
266
+ } else {
267
+ Labor.DiscPerc = Labor.Perc;
268
+ if (!TrUtils.IsZero(Number(Labor.UnPr))) {
269
+ Labor.DiscPerc = Divide(Multiply(100, Labor.Disc), Labor.UnPr);
270
+ } else {
271
+ Labor.DiscPerc = 0;
272
+ }
273
+ }
274
+ Labor.TCode = GetTCodeFromTaxes(Labor);
275
+ Labor.CGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Labor, 'CGST'), DecimalsNumber);
276
+ Labor.SGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Labor, 'SGST'), DecimalsNumber);
277
+ Labor.IGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Labor, 'IGST'), DecimalsNumber);
278
+ Labor.QtyAndUoM = Labor.Qty.toString();
279
+ Labor.CGSTPerc = GetTaxRateFromTaxes(Labor, 'CGST');
280
+ Labor.SGSTPerc = GetTaxRateFromTaxes(Labor, 'SGST');
281
+ Labor.IGSTPerc = GetTaxRateFromTaxes(Labor, 'IGST');
282
+ Labor.TaxName = getTaxName(Labor.TCode, TaxCodes);
283
+ if (LineTotal === 'AT') {
284
+ Labor.LineTotal = TrUtils.FixPriceValue(Labor.AfterLaborTax, DecimalsNumber);
285
+ } else {
286
+ Labor.LineTotal = TrUtils.FixPriceValue(Subtract(Labor.Amt, Labor.Disc), DecimalsNumber);
287
+ }
288
+ });
289
+ return LaborList;
290
+ }
291
+
292
+ export function GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
293
+ Items.forEach((Item: any) => {
294
+ if (Consolidate) {
295
+ let AfterDiscForEach = Divide(Item.AfterPartDisc, Item.Qty);
296
+ let CTaxAmtPerItem = Divide(GetTaxAmountFromTaxes(Item, 'CGST'), Item.Qty);
297
+ let STaxAmtPerItem = Divide(GetTaxAmountFromTaxes(Item, 'SGST'), Item.Qty);
298
+ let ITaxAmtPerItem = Divide(GetTaxAmountFromTaxes(Item, 'IGST'), Item.Qty);
299
+ Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
300
+ } else {
301
+ Item.UnPr = TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
302
+ }
303
+
304
+ // let Index = Item['Desc'].indexOf('#{');
305
+ // if (Index !== -1) {
306
+ // Item.Desc1 = Item['Desc'].substring(Item['Desc'].indexOf('#{') + 2,
307
+ // Item['Desc'].lastIndexOf('}#'));
308
+ // }
309
+ // Item.Desc = Item['Desc'].split(' #{')[0];
310
+ Item.MRP = TrUtils.FixPriceValue(Item.MRP, DecimalsNumber);
311
+ Item.TCode = GetTCodeFromTaxes(Item);
312
+ Item.CGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Item, 'CGST'), DecimalsNumber);
313
+ Item.SGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Item, 'SGST'), DecimalsNumber);
314
+ Item.IGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Item, 'IGST'), DecimalsNumber);
315
+ Item.TaxName = getTaxName(Item.TCode, TaxCodes);
316
+ if (!TrUtils.IsEmpty(Item.Perc)) {
317
+ Item.DiscPerc = Item.Perc;
318
+ } else {
319
+ Item.DiscPerc = Item.Perc;
320
+ if (!TrUtils.IsZero(Number(Item.UnPr))) {
321
+ Item.DiscPerc = Divide(Multiply(100, Item.Disc), Item.UnPr);
322
+ } else {
323
+ Item.DiscPerc = 0;
324
+ }
325
+ }
326
+ Item.CGSTPerc = GetTaxRateFromTaxes(Item, 'CGST');
327
+ Item.SGSTPerc = GetTaxRateFromTaxes(Item, 'SGST');
328
+ Item.IGSTPerc = GetTaxRateFromTaxes(Item, 'IGST');
329
+ if (LineTotal === 'AT') {
330
+ Item.LineTotal = TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
331
+ } else {
332
+ Item.LineTotal = TrUtils.FixPriceValue(Subtract(Item.UnAmt, Item.Disc), DecimalsNumber);
333
+ }
334
+ if (!TrUtils.IsZero(Item.Qty) && !TrUtils.CheckInvalidSelect(Item.UoM)) {
335
+ Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
336
+ } else {
337
+ Item.QtyAndUoM = Item.Qty + '';
338
+ }
339
+ if (!TrUtils.IsZero(Item.OfQty) && !TrUtils.CheckInvalidSelect(Item.UoM)) {
340
+ Item.OfQtyAndUoM = Item.OfQty + ' ' + Item.UoM;
341
+ } else {
342
+ Item.OfQtyAndUoM = Item.OfQty + '';
343
+ }
344
+ });
345
+ return Items;
346
+ }
347
+
348
+ export function getTaxName(TCode: any, TaxCodes: any) {
349
+ let Index: any = TaxCodes.findIndex((TaxCode: any) => {
350
+ return Number(TCode) === TaxCode._id;
351
+ });
352
+ return (Index !== -1) ? TaxCodes[Index].Name : '';
353
+ }
354
+
355
+ export function ReverseItemsForInvoicePrint(argInvoiceData: any) {
356
+ argInvoiceData.Ops = argInvoiceData.Ops;
357
+ argInvoiceData.Items = argInvoiceData.Items;
358
+ return argInvoiceData;
359
+ }
360
+
361
+ export function PrepareFormatForInvoicePrint(InvoicePrintData: any, ROType: any, InvoiceStatus: any) {
362
+ let PrintInfo: any[] = [];
363
+
364
+ let ROLaborParts: any = {};
365
+
366
+ ROLaborParts.Ops = InvoicePrintData.Ops;
367
+
368
+ ROLaborParts.Items = InvoicePrintData.Items;
369
+
370
+ ROLaborParts.Sts = InvoiceStatus;
371
+ ROLaborParts.Type = ROType;
372
+
373
+ PrintInfo.push(ROLaborParts);
374
+ return PrintInfo;
375
+ }
376
+
377
+ export function GetFormattedProductDataForPrint(argInvoiceData: any, InvoicePrintData: any) {
378
+ if (!TrUtils.IsNull(argInvoiceData.Prod)) {
379
+ InvoicePrintData.Product = argInvoiceData.Prod;
380
+ if (TrUtils.IsNull(InvoicePrintData.Product.VIN)) {
381
+ InvoicePrintData.Product.VIN = '';
382
+ }
383
+ if (TrUtils.IsNull(InvoicePrintData.Product.RegNo)) {
384
+ InvoicePrintData.Product.RegNo = '';
385
+ }
386
+ if (TrUtils.IsNull(InvoicePrintData.Product.EngNo)) {
387
+ InvoicePrintData.Product.EngNo = '';
388
+ }
389
+ InvoicePrintData.MIn = argInvoiceData.Prod.MIn;
390
+ InvoicePrintData.MOut = argInvoiceData.Prod.MOut;
391
+ }
392
+ return InvoicePrintData;
393
+ }
394
+
395
+ export function GetBillNameForInvoicePrint(argInvoiceData: any, InvoicePrintData: any) {
396
+ let Customer: any = {};
397
+ if (!TrUtils.IsNull(argInvoiceData.BillTo)) {
398
+ Customer.Name = argInvoiceData.BillTo.Name;
399
+ if (!TrUtils.IsNull(argInvoiceData.BillTo.Sltn)) {
400
+ Customer.Name = argInvoiceData.BillTo.Sltn + ' ' + Customer.Name;
401
+ }
402
+ Customer.Code = argInvoiceData.Cust?.Code;
403
+ Customer.Adrs = [];
404
+ Customer.Cons = [];
405
+ if (!TrUtils.IsNull(argInvoiceData.BillTo.Adrs)) {
406
+ Customer.Adrs.push(argInvoiceData.BillTo.Adrs.A1);
407
+ if (!TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.A2)) {
408
+ Customer.Adrs.push(argInvoiceData.BillTo.Adrs.A2);
409
+ }
410
+ if (!TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.Ct)) {
411
+ let city: any = argInvoiceData.BillTo.Adrs.Ct;
412
+ if (!TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.Pin)) {
413
+ city = city + ', ' + argInvoiceData.BillTo.Adrs.StCode + '-' + argInvoiceData.BillTo.Adrs.Pin;
414
+ }
415
+ Customer.Adrs.push(city);
416
+ }
417
+ }
418
+ Customer.GSTIN = argInvoiceData.BillTo.GSTIN;
419
+ if (!TrUtils.IsNull(argInvoiceData.BillTo.DLNo)) {
420
+ Customer.DLNo = argInvoiceData.BillTo.DLNo;
421
+ }
422
+
423
+ if (!TrUtils.IsEmpty(argInvoiceData.BillTo.Ph)) {
424
+ Customer.Cons = [
425
+ {
426
+ Type: 'M',
427
+ No: argInvoiceData.BillTo.Ph
428
+ }
429
+ ];
430
+ }
431
+ InvoicePrintData.Customer = Customer;
432
+ InvoicePrintData.Name = argInvoiceData.Name;
433
+
434
+ if (!TrUtils.IsNull(argInvoiceData.BillTo.Ins_Id)) {
435
+ InvoicePrintData.Cust = GetCustomerDetails(argInvoiceData);
436
+ }
437
+ } else if (!TrUtils.IsNull(argInvoiceData.Cust)) {
438
+ Customer.Name = argInvoiceData.Cust.Name;
439
+ Customer.Code = argInvoiceData.Cust.Code;
440
+ Customer.Adrs = [];
441
+ Customer.Cons = [];
442
+ InvoicePrintData.Customer = Customer;
443
+ }
444
+
445
+
446
+ if (!TrUtils.IsNull(argInvoiceData.ShipTo)) {
447
+ let location: any = {};
448
+ location.Adrs = PrintSharedService.GetAddress(argInvoiceData.ShipTo.Adrs);
449
+ let Name: any;
450
+ if (TrUtils.IsNull(argInvoiceData.ShipTo.Name)) {
451
+ Name = argInvoiceData.ShipTo.ConName;
452
+ } else {
453
+ Name = argInvoiceData.ShipTo.Name;
454
+ }
455
+ if (TrUtils.IsNull(Name)) {
456
+ Name = '';
457
+ }
458
+ location.Name = Name;
459
+ if (!TrUtils.IsNull(argInvoiceData.ShipTo.ConPh)) {
460
+ location.Cons = [
461
+ {
462
+ Type: 'M',
463
+ No: argInvoiceData.ShipTo.ConPh
464
+ }
465
+ ];
466
+ }
467
+
468
+ InvoicePrintData.Location = location;
469
+ }
470
+ return InvoicePrintData;
471
+ }
472
+
473
+ export function GetCustomerDetails(argInvoiceData: any) {
474
+ let Customer: any = {};
475
+ Customer.Name = GetBillToName(argInvoiceData.Cust.Title, argInvoiceData.Cust.Name);
476
+ Customer.Cons = [];
477
+ if (!TrUtils.IsEmpty(argInvoiceData.Cust.Ph)) {
478
+ Customer.Cons = [
479
+ {
480
+ Type: 'M',
481
+ No: argInvoiceData.Cust.Ph
482
+ }
483
+ ];
484
+ }
485
+ Customer.GSTIN = argInvoiceData.Cust.GSTIN;
486
+ Customer.Adrs = [];
487
+ if (!TrUtils.IsNull(argInvoiceData.Cust.Adrs)) {
488
+ Customer.Adrs.push(argInvoiceData.Cust.Adrs.A1);
489
+ if (!TrUtils.IsEmpty(argInvoiceData.Cust.Adrs.A2)) {
490
+ Customer.Adrs.push(argInvoiceData.Cust.Adrs.A2);
491
+ }
492
+ Customer.Adrs.push(argInvoiceData.Cust.Adrs.Ct);
493
+ }
494
+ Customer.ConName = argInvoiceData.Cust.ConName;
495
+ Customer.ConPh = argInvoiceData.Cust.ConPhone;
496
+ return Customer;
497
+ }
498
+
499
+ export function GetBillToName(Title: any, Name: string) {
500
+ return TrUtils.IsEmpty(Title) ? Name : Title + ' ' + Name;
501
+ }
502
+
503
+ export function GetPaymentsTotal(Credits: any, InvoicePayments: any, Total: number, InvoiceStatus: string, DecimalsNumber: number) {
504
+ var i = 0;
505
+ let Data: any = {};
506
+ let PaidTotal: any = 0;
507
+ if (TrUtils.IsNull(InvoicePayments)) {
508
+ InvoicePayments = [];
509
+ }
510
+ if (TrUtils.IsNull(Credits)) {
511
+ Credits = [];
512
+ }
513
+ for (i = 0; i < InvoicePayments.length; i++) {
514
+ PaidTotal += InvoicePayments[i].Paid;
515
+ }
516
+ for (i = 0; i < Credits.length; i++) {
517
+ PaidTotal += Credits[i].Amt;
518
+ }
519
+ if (InvoiceStatus === InvoiceStatusEnum.Closed) {
520
+ Data.Due = 0;
521
+ } else {
522
+ Data.Due = TrUtils.FixedTo(Subtract(Total, PaidTotal), DecimalsNumber);
523
+ }
524
+ if (Data.Due < 0) {
525
+ Data.Due = 0;
526
+ }
527
+ if (Data.Due === 0) {
528
+ Data.Sts = InvoiceStatusEnum.Closed;
529
+ }
530
+ Data.Paid = TrUtils.FixedTo(PaidTotal, DecimalsNumber);
531
+ return Data;
532
+ }