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,116 @@
1
+
2
+ import { SharedPDFService } from '../../../../shared/shared-pdf.service';
3
+ import { MyDate } from '../../../../utils/my-date';
4
+ import { TrUtils } from '../../../../utils/tr-utils';
5
+ declare var pdfMake: any;
6
+
7
+ export class PaymentsReportPDFService {
8
+
9
+ static GetPaymentsReportPrint(InvoicesData: any, EntityData: any, HeaerName:any, ispur:boolean,isSale:boolean, searchValue:any) {
10
+ var dd = {
11
+ info: {
12
+ title: 'PaymentReport',
13
+ },
14
+ header: function (currentPage: any, pageCount: any) {
15
+ return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 7, fontSize: 8, marginTop: 2 };
16
+ },
17
+ pageMargins: [10, 15, 10, 15],
18
+ content: [
19
+ { text: '' + EntityData.Entity.DName + '', style: ['header'] },
20
+ { text: HeaerName, alignment: 'center', fontSize: 15, bold: true },
21
+ SharedPDFService.GetSearchValueDetails(searchValue),
22
+ this.GetInvoiceDataTable(InvoicesData, ispur, isSale, EntityData.User.TZ, EntityData.Entity.Settings.DecimalsNumber),
23
+
24
+ ],
25
+ styles: SharedPDFService.GetStyles()
26
+ };
27
+ return dd;
28
+
29
+ }
30
+
31
+ static GetInvoiceDataTable(InvoicesData: any, ispur:boolean, isSale:boolean, UserTimeZone: any, DecimalsNumber: number) {
32
+ let Data: any = []
33
+ // InvoicesData.forEach((invoice: any) => {
34
+ Data.push(this.GetItemsTable(InvoicesData, ispur, isSale, UserTimeZone, DecimalsNumber));
35
+ // });
36
+
37
+ return Data;
38
+ }
39
+
40
+ static getTableWidths() {
41
+ // if (isHC) {
42
+ return [22, 50, '*', 90,80, 70];
43
+ // } else {
44
+ // return [25, '*', 40, 40, 80];
45
+ // }
46
+ }
47
+
48
+ static GetItemsTable(InvoiceData: any, ispur:boolean, isSale:boolean, UserTimeZone: any, DecimalsNumber: number) {
49
+ // InvoicesData.forEach((InvoiceData: any) => {
50
+ return {
51
+ style: 'tableExample',
52
+ marginTop: 3,
53
+ marginBottom: 5,
54
+ table: {
55
+ widths: this.getTableWidths(),
56
+ headerRows: 1,
57
+ body: this.BuildTableBodyForLaborAndParts(InvoiceData, ispur, isSale, UserTimeZone, DecimalsNumber)
58
+ // body:[['fsdfsdf','asfafdas','asdasdas','asdasdasd','asddass']]
59
+ },
60
+ layout: {
61
+ hLineWidth: function (i:any, node:any) {
62
+
63
+ return (i === 0 || i === 1 || i === node.table.body.length) ? 1 : 0.5;
64
+ },
65
+ vLineWidth: function (i:any, node:any) {
66
+ return (i === 0 || i === node.table.widths.length) ? 1 : 0.5;
67
+ },
68
+ // hLineStyle: function (i, node) {
69
+ // return (i === 0 || i === 1) ? { dash: { length: 5, space: 5 } } : null;
70
+ // },
71
+ hLineColor: function (i: any, node: any) {
72
+ return (i === 0 || i === 1 || i === node.table.body.length) ? 'gray' : 'lightgrey';
73
+
74
+ },
75
+ vLineColor: function (i: any, node: any) {
76
+ return 'gray';
77
+ },
78
+ }
79
+ };
80
+ // });
81
+ }
82
+
83
+ static BuildTableBodyForLaborAndParts(InvoiceData: any, ispur:boolean, isSale:boolean, UserTimeZone: any, DecimalsNumber: number) {
84
+ let body: any = this.GetHeaderNames(ispur);
85
+ InvoiceData.forEach((invoice: any, index: any) => {
86
+ let dataRow: any = [];
87
+ dataRow.push({ text: index + 1 });
88
+ dataRow.push({ text:invoice.Code, style: ['headerstyle'], });
89
+ dataRow.push({ text: isSale?invoice.CustName:invoice.Name });
90
+
91
+ dataRow.push({ text:isSale? MyDate.ConvertUTCDateTimeToReadable(invoice.Pay.Dt, UserTimeZone):MyDate.ConvertUTCDateTimeToReadable(invoice.Date, UserTimeZone) });
92
+ dataRow.push({ text: isSale?invoice.Pay.Type:invoice.PType });
93
+ dataRow.push({ text: isSale?TrUtils.FixPriceValue(invoice.Pay?.Amt, DecimalsNumber):TrUtils.FixPriceValue(invoice.Amt, DecimalsNumber), alignment: 'right' });
94
+ body.push(dataRow);
95
+ });
96
+ return body;
97
+ }
98
+
99
+ static GetHeaderNames(ispur:boolean) {
100
+ let HeadingNames: any;
101
+ HeadingNames = [[{ text: 'S.No', style: 'tableheader1', Field: 'SNo', alignment: 'left', line: true },
102
+ { text: 'Transaction #', style: 'tableheader1', Field: 'Code' },
103
+ { text: ispur?'Vendor Name':'Customer Name', style: 'tableheader1', Field: 'Name',alignment: 'left' },
104
+
105
+ // { text: ispur?'Bill No':'Invoice No', style: 'tableheader1', Field: 'InvCode' },
106
+ { text: 'Payment Date', style: 'tableheader1', Field: 'Date' },
107
+ { text: 'Payment Type', style: 'tableheader1', Field: 'Type' },
108
+ // { text: 'Offer Qty', style: 'tableheader1', Field: 'OfQty', alignment: 'right' },
109
+ // { text: 'Amount', style: 'tableheader1', Field: 'UnAmt', alignment: 'right' },
110
+ { text: 'Amount Paid', style: 'tableheader1', Field: 'Total', alignment: 'right' }
111
+ // { text: 'Total', style: 'tableheader1', Field: 'Total', alignment: 'right' }
112
+ ]];
113
+ return HeadingNames;
114
+ }
115
+
116
+ }
@@ -0,0 +1,58 @@
1
+ import { TrUtils } from '../utils/tr-utils';
2
+ const Big = require('big.js');
3
+
4
+ export function addition(num1: number, num2: number, ...params: number[]) {
5
+ num1=TrUtils.SetValueToZeroIfNull(num1);
6
+ num2=TrUtils.SetValueToZeroIfNull(num2);
7
+ const bigNo1 = Big(num1);
8
+ const bigNo2 = Big(num2);
9
+ let resp = bigNo1.plus(bigNo2);
10
+ params.forEach((param: any) => {
11
+ param=TrUtils.SetValueToZeroIfNull(param);
12
+ const paramNo = Big(param);
13
+ resp = resp.plus(paramNo);
14
+ });
15
+ return resp.toNumber();
16
+ }
17
+
18
+ export function subtraction(num1: number, num2: number, ...params: number[]) {
19
+ num1=TrUtils.SetValueToZeroIfNull(num1);
20
+ num2=TrUtils.SetValueToZeroIfNull(num2);
21
+ const bigNo1 = Big(num1);
22
+ const bigNo2 = Big(num2);
23
+ let resp = bigNo1.minus(bigNo2);
24
+ params.forEach((param: any) => {
25
+ param=TrUtils.SetValueToZeroIfNull(param);
26
+ const paramNo = Big(param);
27
+ resp = resp.minus(paramNo);
28
+ });
29
+ return resp.toNumber();
30
+ }
31
+
32
+ export function multiply(num1: number, num2: number, ...params: number[]) {
33
+ num1=TrUtils.SetValueToZeroIfNull(num1);
34
+ num2=TrUtils.SetValueToZeroIfNull(num2);
35
+ const bigNo1 = Big(num1);
36
+ const bigNo2 = Big(num2);
37
+ let resp = bigNo1.mul(bigNo2);
38
+ params.forEach((param: any) => {
39
+ param=TrUtils.SetValueToZeroIfNull(param);
40
+ const paramNo = Big(param);
41
+ resp = resp.mul(paramNo);
42
+ });
43
+ return resp.toNumber();
44
+ }
45
+
46
+ export function division(num1: number, num2: number, ...params: number[]) {
47
+ num1=TrUtils.SetValueToZeroIfNull(num1);
48
+ num2=TrUtils.SetValueToZeroIfNull(num2);
49
+ const bigNo1 = Big(num1);
50
+ const bigNo2 = Big(num2);
51
+ let resp = bigNo1.div(bigNo2);
52
+ params.forEach((param: any) => {
53
+ param=TrUtils.SetValueToZeroIfNull(param);
54
+ const paramNo = Big(param);
55
+ resp = resp.div(paramNo);
56
+ });
57
+ return resp.toNumber();
58
+ }
@@ -0,0 +1,298 @@
1
+ import { LaborStatusEnum, PayTypeEnum } from "../../enums/enums";
2
+ import { Add, Subtract } from "../../shared/math-operations";
3
+ import { TrUtils } from "../../utils/tr-utils";
4
+
5
+
6
+
7
+
8
+ export class AppointmentTotalsService {
9
+
10
+ static GetTotalsValue(OriRecordData: any, TaxCodes: any[], detailedInfo: boolean, withItems: boolean, EntitySettings: any) {
11
+
12
+ let dupRecordData: any = TrUtils.Stringify(OriRecordData);
13
+
14
+ let argRecordData: any = {};
15
+
16
+ dupRecordData.Ops = this.CalculateLaborValues(dupRecordData.Ops, TrUtils.isTaxable(dupRecordData.Settings.Tax));
17
+
18
+ argRecordData = this.GetROTotalsData(argRecordData, dupRecordData, TaxCodes, withItems, detailedInfo, EntitySettings.DecimalsNumber);
19
+
20
+ return argRecordData;
21
+ }
22
+
23
+ static CalculateLaborValues(opCodesList: any, isTaxable: boolean) {
24
+
25
+ opCodesList = this.FilterValidLaborItems(opCodesList);
26
+
27
+ opCodesList = this.ResetLaborValuesIfInvalid(opCodesList);
28
+
29
+ opCodesList = this.GetOperationsDiscountPrice(opCodesList);
30
+
31
+ opCodesList = this.GetOperationsAfterDiscount(opCodesList);
32
+
33
+ opCodesList = this.GetOperationsAfterTax(opCodesList, isTaxable);
34
+
35
+ return opCodesList;
36
+ }
37
+
38
+ static FilterValidLaborItems(opCodesList: any[]) {
39
+ opCodesList = opCodesList.filter((Labor: any) => {
40
+ return Labor.Sts !== LaborStatusEnum.Cancelled && Labor.Sts !== LaborStatusEnum.Declined;
41
+ });
42
+ return opCodesList;
43
+ }
44
+
45
+ static ResetLaborValuesIfInvalid(opCodesList: any) {
46
+ opCodesList.forEach((Operation: any) => {
47
+ Operation = this.ResetLaborValueIfInvalid(Operation);
48
+ });
49
+ return opCodesList;
50
+ }
51
+
52
+ static ResetLaborValueIfInvalid(Operation: any) {
53
+ Operation.Perc = TrUtils.SetPercToStringIfNull(Operation.Perc);
54
+ Operation.Disc = TrUtils.SetValueToZeroIfNull(Operation.Disc);
55
+ Operation.Pr = TrUtils.SetValueToZeroIfNull(Operation.Pr);
56
+ Operation.CCGST = TrUtils.SetValueToZeroIfNull(Operation.CCGST);
57
+ Operation.CSGST = TrUtils.SetValueToZeroIfNull(Operation.CSGST);
58
+ Operation.CIGST = TrUtils.SetValueToZeroIfNull(Operation.CIGST);
59
+ Operation.NetAmt = TrUtils.SetValueToZeroIfNull(Operation.NetAmt);
60
+ Operation.RecDisc = TrUtils.SetValueToZeroIfNull(Operation.RecDisc);
61
+ return Operation;
62
+ }
63
+
64
+ static GetOperationsDiscountPrice(OperationsList: any) {
65
+ OperationsList.forEach((Operation: any) => {
66
+
67
+ Operation.CustDiscountedPrice = Operation.Disc + Operation.RecDisc;
68
+
69
+ });
70
+ return OperationsList;
71
+ }
72
+
73
+ static GetOperationsAfterDiscount(OperationsList: any) {
74
+ OperationsList.forEach((Operation: any) => {
75
+ let CustAfterLaborDisc: number = 0;
76
+ if (Operation.PBy === PayTypeEnum.Customer) {
77
+ CustAfterLaborDisc = Operation.NetAmt;
78
+
79
+ } else {
80
+ CustAfterLaborDisc = Operation.NetAmt;
81
+ }
82
+ Operation.CustAfterLaborDisc = CustAfterLaborDisc;
83
+ });
84
+ return OperationsList;
85
+ }
86
+
87
+ static GetOperationsAfterTax(OperationsList: any, isTaxable: boolean) {
88
+ OperationsList.forEach((Operation: any) => {
89
+ if (!isTaxable) {
90
+ Operation.CustAfterTax = Operation.CustAfterLaborDisc;
91
+ } else {
92
+ if (Operation.PBy === PayTypeEnum.Customer) {
93
+
94
+ Operation.CustAfterTax = Operation.CustAfterLaborDisc + Operation.CCGST + Operation.CSGST + Operation.CIGST;
95
+
96
+ } else {
97
+ Operation.CustAfterTax = Operation.CustAfterLaborDisc + Operation.CCGST + Operation.CSGST + Operation.CIGST;
98
+
99
+ }
100
+ }
101
+ });
102
+ return OperationsList;
103
+ }
104
+
105
+ static GetROTotalsData(argRecordData: any, dupRecordData: any, TaxCodes: any, withItems: boolean, detailedInfo: any, DecimalsNumber: number) {
106
+
107
+ dupRecordData = this.ResetDiscountValuesIfInvalid(dupRecordData);
108
+
109
+ argRecordData = this.SetMainDiscountValues(argRecordData, dupRecordData, detailedInfo);
110
+
111
+ argRecordData = this.GetFinalCustomerTotalsData(argRecordData, dupRecordData, detailedInfo, DecimalsNumber);
112
+
113
+ if (detailedInfo) {
114
+ argRecordData = this.GetDetailedTotalsData(argRecordData, dupRecordData, TaxCodes, DecimalsNumber);
115
+ }
116
+
117
+ if (withItems) {
118
+ argRecordData.Ops = dupRecordData.Ops;
119
+ }
120
+
121
+ return argRecordData;
122
+ }
123
+
124
+ static ResetDiscountValuesIfInvalid(dupRecordData: any) {
125
+ dupRecordData.LPerc = TrUtils.SetPercToStringIfNull(dupRecordData.LPerc);
126
+ dupRecordData.Perc = TrUtils.SetPercToStringIfNull(dupRecordData.Perc);
127
+ dupRecordData.LDisc = TrUtils.SetValueToZeroIfNull(dupRecordData.LDisc);
128
+ dupRecordData.Disc = TrUtils.SetValueToZeroIfNull(dupRecordData.Disc);
129
+ return dupRecordData;
130
+ }
131
+
132
+ static SetMainDiscountValues(argRecordData: any, dupRecordData: any, detailedInfo: boolean) {
133
+ argRecordData.LDisc = dupRecordData.LDisc;
134
+ argRecordData.LPerc = dupRecordData.LPerc;
135
+
136
+ argRecordData.PDisc = dupRecordData.PDisc;
137
+ argRecordData.PPerc = dupRecordData.PPerc;
138
+
139
+ argRecordData.Disc = dupRecordData.Disc;
140
+ argRecordData.Perc = dupRecordData.Perc;
141
+
142
+ if (detailedInfo) {
143
+ argRecordData.FixedLDisc = dupRecordData.LDisc;
144
+ argRecordData.FixedDisc = dupRecordData.Disc;
145
+ }
146
+ return argRecordData;
147
+ }
148
+
149
+ static GetFinalCustomerTotalsData(argRecordData: any, dupRecordData: any, detailedInfo: boolean, DecimalsNumber: number) {
150
+ let CustomerAfterDiscTotals: number = this.GetCustSubTotal(dupRecordData.Ops);
151
+
152
+ let CustLaborTaxTotal = this.GetCustLaborTaxTotal(dupRecordData.Ops, TrUtils.isTaxable(dupRecordData.Settings.Tax));
153
+ let CustLaborDiscTotal: any = this.GetCustLaborDiscountedTotal(dupRecordData.Ops, TrUtils.isTaxable(dupRecordData.Settings.Tax), dupRecordData, DecimalsNumber);
154
+ let CustLaborTotalAfterDisc: any = this.GetCustLaborTotalAfterDiscount(dupRecordData.Ops);
155
+ argRecordData.STotal = TrUtils.FixPriceValue(Add(CustLaborDiscTotal, CustLaborTotalAfterDisc), DecimalsNumber);
156
+ argRecordData.CustLaborTotalBeforeDisc = TrUtils.FixedTo(Add(argRecordData.CustLaborTotalAfterDisc
157
+ , argRecordData.CustLaborDiscTotal, DecimalsNumber));
158
+ argRecordData.SubTotal = TrUtils.FixedTo(CustomerAfterDiscTotals, DecimalsNumber);
159
+ let CustTotal: any = this.GetCustomerTotalBasedOnTaxType(dupRecordData, CustLaborTaxTotal, dupRecordData.Ops, TrUtils.isTaxable(dupRecordData.Settings.Tax), DecimalsNumber);
160
+ if (detailedInfo) {
161
+ argRecordData.FixedSubTotal = TrUtils.FixedTo(CustomerAfterDiscTotals, DecimalsNumber);
162
+ argRecordData.FixedTotal = TrUtils.FixedTo(CustTotal, DecimalsNumber);
163
+ }
164
+ argRecordData.Round = TrUtils.FixedTo(Subtract(Math.round(CustTotal), CustTotal), DecimalsNumber);
165
+ argRecordData.Total = Math.round(CustTotal);
166
+ return argRecordData;
167
+ }
168
+
169
+ static GetCustSubTotal(LaborList: any) {
170
+ let LaborTotalAfterDisc: any = this.GetCustLaborTotalAfterDiscount(LaborList);
171
+ return LaborTotalAfterDisc;
172
+ }
173
+
174
+ static GetCustLaborTotalAfterDiscount(LaborList: any) {
175
+ let LaborTotalAfterDisc: any = 0;
176
+ LaborList.forEach((Labor: any) => {
177
+ LaborTotalAfterDisc += Labor.CustAfterLaborDisc;
178
+ });
179
+ return LaborTotalAfterDisc;
180
+ }
181
+
182
+ static GetCustLaborTaxTotal(opCodesList: any, IsTaxable: boolean) {
183
+ let TotalTaxAmt: any = 0;
184
+ if (IsTaxable) {
185
+ opCodesList.forEach((Labor: any) => {
186
+ TotalTaxAmt = TotalTaxAmt + Labor.CCGST + Labor.CSGST + Labor.CIGST;
187
+ });
188
+ }
189
+ return TotalTaxAmt;
190
+ }
191
+
192
+ static GetCustomerTotalBasedOnTaxType(dupRecordData: any, LaborTaxAmount: number, LaborList: any, IsTaxable: boolean, DecimalsNumber: number) {
193
+ let SubTotalWithTax: any = 0;
194
+ let LaborTotalAfterDisc: any = this.GetCustLaborTotalAfterDiscount(LaborList);
195
+ if (IsTaxable) {
196
+ SubTotalWithTax = Add(LaborTotalAfterDisc, LaborTaxAmount);
197
+ } else {
198
+ SubTotalWithTax = TrUtils.FixedTo(Subtract(LaborTotalAfterDisc - dupRecordData.LDisc, dupRecordData.Disc), DecimalsNumber);
199
+ }
200
+ return SubTotalWithTax;
201
+ }
202
+
203
+ static GetDetailedTotalsData(argRecordData: any, dupRecordData: any, TaxCodes: any, DecimalsNumber: number) {
204
+ argRecordData.CustLaborDiscTotal = this.GetCustLaborDiscountedTotal(dupRecordData.Ops, TrUtils.isTaxable(dupRecordData.Settings.Tax), dupRecordData, DecimalsNumber);
205
+ argRecordData.CustLaborTotalAfterDisc = this.GetCustLaborTotalAfterDiscount(dupRecordData.Ops);
206
+ argRecordData.CustLaborTotalBeforeDisc = TrUtils.FixedTo(Add(argRecordData.CustLaborTotalAfterDisc, argRecordData.CustLaborDiscTotal), DecimalsNumber);
207
+ argRecordData.CustLaborITax = this.GetCustLaborTaxTotal(dupRecordData.Ops, TrUtils.isTaxable(dupRecordData.Settings.Tax));
208
+ argRecordData.CustLaborSGST = this.GetCustLaborSGSTTaxTotal(dupRecordData.Ops, TrUtils.isTaxable(dupRecordData.Settings.Tax));
209
+ argRecordData.CustLaborCGST = this.GetCustLaborCGSTTaxTotal(dupRecordData.Ops, TrUtils.isTaxable(dupRecordData.Settings.Tax));
210
+ argRecordData.CustLaborIGST = this.GetCustLaborIGSTTaxTotal(dupRecordData.Ops, TrUtils.isTaxable(dupRecordData.Settings.Tax));
211
+ argRecordData.CustLaborLDiscAmount = this.GetLaborLDiscAmount(argRecordData.CustLaborTotalAfterDisc, argRecordData.LDisc);
212
+ argRecordData.CustLaborAfterLDisc = argRecordData.CustLaborTotalAfterDisc;
213
+ argRecordData.CustLaborAfterTax = TrUtils.FixedTo(Add(argRecordData.CustLaborITax, argRecordData.CustLaborAfterLDisc), DecimalsNumber);
214
+ argRecordData.CustTotalRoundedBy = argRecordData.Round;
215
+ argRecordData.CustRoundedTotal = argRecordData.Total;
216
+ for (var key in argRecordData) {
217
+ if (key !== 'Total' && key !== 'SubTotal' &&
218
+ key !== 'LDisc' && key !== 'LPerc' && key !== 'PDisc' &&
219
+ key !== 'PPerc' && key !== 'Disc' && key !== 'Perc' && key !== 'Tax'
220
+ && typeof argRecordData[key] === 'number') {
221
+ argRecordData[key] = TrUtils.FixPriceValue(argRecordData[key], DecimalsNumber);
222
+ }
223
+ }
224
+ return argRecordData;
225
+ }
226
+
227
+ static GetCustLaborDiscountedTotal(LaborList: any, isTaxable: boolean, finalTotalsData: any, DecimalsNumber: number) {
228
+ let LaborDiscountedTotal: any = 0;
229
+ let overallLaborDisc: number = 0;
230
+ if (!isTaxable) {
231
+ overallLaborDisc = TrUtils.SetValueToZeroIfNull(finalTotalsData.LDisc)
232
+ }
233
+ LaborList.forEach((Labor: any) => {
234
+ LaborDiscountedTotal += Labor.CustDiscountedPrice;
235
+ });
236
+ return TrUtils.FixedTo(Add(LaborDiscountedTotal, overallLaborDisc), DecimalsNumber);
237
+ }
238
+
239
+ static GetCustLaborCGSTTaxTotal(opCodesList: any, IsTaxable: boolean) {
240
+ let TotalTaxAmt: any = 0;
241
+ if (IsTaxable) {
242
+ opCodesList.forEach((Labor: any) => {
243
+ TotalTaxAmt = Add(TotalTaxAmt, Labor.CCGST);
244
+ });
245
+ }
246
+ return TotalTaxAmt;
247
+ }
248
+
249
+ static GetCustLaborIGSTTaxTotal(opCodesList: any, IsTaxable: boolean) {
250
+ let TotalTaxAmt: any = 0;
251
+ if (IsTaxable) {
252
+ opCodesList.forEach((Labor: any) => {
253
+ TotalTaxAmt = Add(TotalTaxAmt, Labor.CIGST);
254
+ });
255
+ }
256
+ return TotalTaxAmt;
257
+ }
258
+
259
+ static GetCustLaborSGSTTaxTotal(opCodesList: any, IsTaxable: boolean) {
260
+ let TotalTaxAmt: any = 0;
261
+ if (IsTaxable) {
262
+ opCodesList.forEach((Labor: any) => {
263
+ TotalTaxAmt = Add(TotalTaxAmt, Labor.CSGST);
264
+ });
265
+ }
266
+ return TotalTaxAmt;
267
+ }
268
+
269
+ static GetLaborLDiscAmount(LaborTotalAfterDisc: any, LDisc: any) {
270
+ let LaborLDiscAmt: any = 0;
271
+ if (!TrUtils.IsZero(LaborTotalAfterDisc)) {
272
+ LaborLDiscAmt = LDisc;
273
+ }
274
+ return LaborLDiscAmt;
275
+ }
276
+
277
+ static GetGSTValueBasedOnTaxCode(TCode: any, TaxCodes: any) {
278
+ let CGST: number = 0;
279
+ let SGST: number = 0;
280
+ let IGST: number = 0;
281
+ if (TrUtils.IsNull(TCode)) {
282
+ return [CGST, SGST, IGST];
283
+ }
284
+ let TCodeIndex: any = TaxCodes.findIndex((TaxCode: any) => {
285
+ return TaxCode._id === Number(TCode);
286
+ });
287
+ if (TCodeIndex !== -1) {
288
+ if (TaxCodes[TCodeIndex].Type === 'Intra') {
289
+ return [TaxCodes[TCodeIndex].CGST, TaxCodes[TCodeIndex].SGST, 0];
290
+ } else {
291
+ return [0, 0, TaxCodes[TCodeIndex].IGST];
292
+ }
293
+ } else {
294
+ return [CGST, SGST, IGST];
295
+ }
296
+ }
297
+
298
+ }