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.
- package/README.md +1 -0
- package/dist/accounting/invoice/invoice-pdf/invoice-pdf.service.js +18 -45
- package/dist/accounting/invoice/reports/excel/analysis-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/category-wise-item-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/cust-wise-sales-details.js +17 -7
- package/dist/accounting/invoice/reports/excel/cust-wise-sales-summary-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/invoice-wise-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/item-wise-doctor-sale-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/items-wise-sales-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/manf-wise-sales-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/operator-wise-details.js +17 -7
- package/dist/accounting/invoice/reports/excel/operator-wise-summary.js +17 -7
- package/dist/accounting/invoice/reports/excel/sa-wise-labor-sales-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/sa-wise-part-sales-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/sale-summary-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/sales-by-service-summary-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/scheduled-drug-summary-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/scheduled-drugs-excel.service.js +17 -7
- package/dist/accounting/invoice/unified-invoice-pdf.service.d.ts +1 -1
- package/dist/accounting/payment-receive/reports/excel/cust-balance-excel.service.js +17 -7
- package/dist/accounting/payment-receive/reports/excel/payment-receive-excel.service.js +17 -7
- package/dist/common/reports/excel/product-without-owner-excel.service.js +17 -7
- package/dist/gst/excel/GSTR-RO-excel.service.js +17 -7
- package/dist/gst/excel/GSTR1-excel.service.js +17 -7
- package/dist/gst/excel/GSTR2-excel.service.js +17 -7
- package/dist/gst/excel/hsn-summary.js +17 -7
- package/dist/gst/excel/tally-sales-import.service.js +17 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/inventory/items/reports/excel/expiring-drugs-excel.service.js +17 -7
- package/dist/inventory/items/reports/excel/item-wise-mout-details.js +17 -7
- package/dist/inventory/items/reports/excel/item-wise-mout-summary.js +17 -7
- package/dist/inventory/items/reports/excel/spares-issue-excel.service.js +17 -7
- package/dist/inventory/items/reports/excel/stock-excel.service.js +17 -7
- package/dist/purchases/payment-made/reports/excel/payments-made-excel.service.js +17 -7
- package/dist/purchases/payment-made/reports/excel/ven-balance-excel.service.js +17 -7
- package/dist/services/reports/excel/insurance-expire-excel.service.js +17 -7
- package/dist/services/reports/excel/next-service-date-excel.service.js +17 -7
- package/dist/services/reports/excel/repair-orders-excel.service.js +17 -7
- package/dist/shared/table-section/pdf-table.header.d.ts +1 -1
- package/dist/shared/table-section/pdf-table.header.js +14 -2
- package/dist/shared/table-section/pdf-table.section.js +6 -13
- package/dist/{accounting/invoice/invoice-pdf.service.js → shared/transactions-pdf.service.js} +15 -15
- package/package.json +1 -1
- package/src/accounting/counter-sales/auto-sales-receipt-pdf.service.ts +569 -0
- package/src/accounting/counter-sales/pos-receipt-pdf.ts +577 -0
- package/src/accounting/counter-sales/sales-receipt-pdf.service.ts +628 -0
- package/src/accounting/counter-sales/sales-receipt-print.service.ts +506 -0
- package/src/accounting/credit-note/cn-print.service.ts +264 -0
- package/src/accounting/credit-note/credit-note-pdf.service.ts +602 -0
- package/src/accounting/credit-note/credit-note-totals.service.ts +424 -0
- package/src/accounting/debit-note/debit-note-pdf.service.ts +681 -0
- package/src/accounting/debit-note/debit-note-print.service.ts +276 -0
- package/src/accounting/debit-note/debit-note-totals.service.ts +361 -0
- package/src/accounting/invoice/hc-inv-pdf.service.ts +880 -0
- package/src/accounting/invoice/inv-pdf.service.ts +812 -0
- package/src/accounting/invoice/inv-print.service.ts +532 -0
- package/src/accounting/invoice/invoice-landscape-pdf.service.ts +947 -0
- package/src/accounting/invoice/invoice-letterhead-pdf.service.ts +813 -0
- package/src/accounting/invoice/invoice-pdf/invoice-pdf.service.ts +359 -0
- package/src/accounting/invoice/invoice-portrait-pdf.ts +972 -0
- package/src/accounting/invoice/invoice-print.service.ts +2906 -0
- package/src/accounting/invoice/invoice-total.service.ts +834 -0
- package/src/accounting/invoice/reports/excel/analysis-excel.service.ts +291 -0
- package/src/accounting/invoice/reports/excel/category-wise-item-excel.service.ts +267 -0
- package/src/accounting/invoice/reports/excel/cust-wise-sales-details.ts +321 -0
- package/src/accounting/invoice/reports/excel/cust-wise-sales-summary-excel.service.ts +300 -0
- package/src/accounting/invoice/reports/excel/invoice-wise-excel.service.ts +859 -0
- package/src/accounting/invoice/reports/excel/item-wise-doctor-sale-excel.service.ts +255 -0
- package/src/accounting/invoice/reports/excel/items-wise-sales-excel.service.ts +312 -0
- package/src/accounting/invoice/reports/excel/manf-wise-sales-excel.service.ts +273 -0
- package/src/accounting/invoice/reports/excel/operator-wise-details.ts +258 -0
- package/src/accounting/invoice/reports/excel/operator-wise-summary.ts +259 -0
- package/src/accounting/invoice/reports/excel/sa-wise-labor-sales-excel.service.ts +230 -0
- package/src/accounting/invoice/reports/excel/sa-wise-part-sales-excel.service.ts +231 -0
- package/src/accounting/invoice/reports/excel/sale-summary-excel.service.ts +326 -0
- package/src/accounting/invoice/reports/excel/sales-by-service-details-excel.service.ts +0 -0
- package/src/accounting/invoice/reports/excel/sales-by-service-summary-excel.service.ts +432 -0
- package/src/accounting/invoice/reports/excel/scheduled-drug-summary-excel.service.ts +373 -0
- package/src/accounting/invoice/reports/excel/scheduled-drugs-excel.service.ts +372 -0
- package/src/accounting/invoice/reports/pdf/analysis-pdf.service.ts +113 -0
- package/src/accounting/invoice/reports/pdf/category-wise-item-pdf.service.ts +107 -0
- package/src/accounting/invoice/reports/pdf/cust-wise-sales-details-pdf.service.ts +125 -0
- package/src/accounting/invoice/reports/pdf/cust-wise-sales-summary-pdf.service.ts +119 -0
- package/src/accounting/invoice/reports/pdf/item-wise-doctor-sale-pdf.service.ts +180 -0
- package/src/accounting/invoice/reports/pdf/item-wise-sales-pdf.service.ts +193 -0
- package/src/accounting/invoice/reports/pdf/manf-wise-sales-pdf.service.ts +188 -0
- package/src/accounting/invoice/reports/pdf/operator-wise-details-pdf.service.ts +118 -0
- package/src/accounting/invoice/reports/pdf/operator-wise-summary-pdf.ts +116 -0
- package/src/accounting/invoice/reports/pdf/sales-by-service-pdf.service.ts +132 -0
- package/src/accounting/invoice/reports/pdf/scheduled-drug-pdf.service.ts +191 -0
- package/src/accounting/invoice/reports/pdf/scheduled-drug-summary-pdf.service.ts +202 -0
- package/src/accounting/invoice/shared-inv-pdf.service.ts +787 -0
- package/src/accounting/invoice/unified-invoice-pdf.service.ts +937 -0
- package/src/accounting/payment-receive/payment-pdf.service.ts +410 -0
- package/src/accounting/payment-receive/payment-receipt-pdf/receipt-pdf.service.ts +470 -0
- package/src/accounting/payment-receive/receipt-print.service.ts +71 -0
- package/src/accounting/payment-receive/reports/excel/cust-balance-excel.service.ts +298 -0
- package/src/accounting/payment-receive/reports/excel/payment-receive-excel.service.ts +221 -0
- package/src/accounting/payment-receive/reports/pdf/customer-balances-pdf.service.ts +182 -0
- package/src/accounting/payment-receive/reports/pdf/payment-report-pdf.service.ts +116 -0
- package/src/aggregation/aggregation.ts +58 -0
- package/src/appointments/appointments/appointment-total.service.ts +298 -0
- package/src/appointments/consultations/consultation-fee-receipt.service.ts +407 -0
- package/src/appointments/consultations/consultation-full-pdf.service.ts +238 -0
- package/src/appointments/consultations/consultation-letterhead-pdf.service.ts +430 -0
- package/src/appointments/consultations/consultation-pdf.service.ts +417 -0
- package/src/common/reports/excel/product-without-owner-excel.service.ts +308 -0
- package/src/common/reports/pdf/product-without-owner-pdf.service.ts +146 -0
- package/src/enums/cache-enums.ts +33 -0
- package/src/enums/code-enums.ts +291 -0
- package/src/enums/country-enums.ts +9 -0
- package/src/enums/enums.ts +364 -0
- package/src/enums/industry-enums.ts +26 -0
- package/src/enums/treatment-enums.ts +9 -0
- package/src/gst/excel/GSTR-RO-excel.service.ts +926 -0
- package/src/gst/excel/GSTR1-excel.service.ts +313 -0
- package/src/gst/excel/GSTR2-excel.service.ts +314 -0
- package/src/gst/excel/hsn-summary.ts +314 -0
- package/src/gst/excel/tally-sales-import.service.ts +767 -0
- package/src/gst/pdf/hsn-summary-pdf.ts +176 -0
- package/src/index.ts +194 -0
- package/src/inventory/items/adjustment-pdf.service.ts +177 -0
- package/src/inventory/items/issue-parts-pdf.service.ts +795 -0
- package/src/inventory/items/item-bar-code-label-pdf.ts +194 -0
- package/src/inventory/items/item-detais-pdf.ts +141 -0
- package/src/inventory/items/item-price-for-pricelist.ts +368 -0
- package/src/inventory/items/reports/excel/expiring-drugs-excel.service.ts +290 -0
- package/src/inventory/items/reports/excel/item-wise-mout-details.ts +284 -0
- package/src/inventory/items/reports/excel/item-wise-mout-summary.ts +279 -0
- package/src/inventory/items/reports/excel/spares-issue-excel.service.ts +494 -0
- package/src/inventory/items/reports/excel/stock-excel.service.ts +319 -0
- package/src/inventory/items/reports/pdf/expiring-drugs-pdf.service.ts +172 -0
- package/src/inventory/items/reports/pdf/item-wise-mout-details-pdf.ts +122 -0
- package/src/inventory/items/reports/pdf/item-wise-mout-summary-pdf.ts +115 -0
- package/src/inventory/items/reports/pdf/reorder-point-pdf.service.ts +163 -0
- package/src/inventory/material-out/mout-pdf.service.ts +545 -0
- package/src/inventory/transfer-order/transfer-order-pdf.service.ts +154 -0
- package/src/purchases/bills/bill-pdf/bill-pdf.service.ts +211 -0
- package/src/purchases/bills/bill-pdf.service.ts +21 -0
- package/src/purchases/payment-made/reports/excel/payments-made-excel.service.ts +313 -0
- package/src/purchases/payment-made/reports/excel/ven-balance-excel.service.ts +307 -0
- package/src/purchases/payment-made/reports/pdf/vendor-balances-pdf.service.ts +114 -0
- package/src/purchases/purchase-order/po-totals.service.ts +343 -0
- package/src/purchases/purchase-order/purchase-order-pdf.service.ts +1016 -0
- package/src/purchases/purchase-order/purchase-order-print.service.ts +279 -0
- package/src/purchases/purchase-order/purchase-order-totals.service.ts +637 -0
- package/src/purchases/vendor-credit-note/vendor-credit-note-pdf.service.ts +1055 -0
- package/src/purchases/vendor-credit-note/vendor-credit-note-print.service.ts +145 -0
- package/src/purchases/vendor-credit-note/vendor-credit-note-totals.service.ts +399 -0
- package/src/purchases/vendor-debit-note/vendor-debit-note-pdf.service.ts +582 -0
- package/src/purchases/vendor-debit-note/vendor-debit-note-print.service.ts +295 -0
- package/src/purchases/vendor-debit-note/vendor-debit-note-totals.service.ts +377 -0
- package/src/sales/delivery-challan/dc-landscape-pdf.service.ts +922 -0
- package/src/sales/delivery-challan/dc-landscape-without-price-pdf.service.ts +869 -0
- package/src/sales/delivery-challan/dc-without-price-pdf.service.ts +505 -0
- package/src/sales/delivery-challan/delivery-challan-pdf.service.ts +461 -0
- package/src/sales/delivery-challan/delivery-challan-print.service.ts +229 -0
- package/src/sales/delivery-challan/delivery-challan-totals.ts +466 -0
- package/src/sales/sales/equipment-design-pdf.service.ts +153 -0
- package/src/sales/sales/pack-ship-pdf.service.ts +128 -0
- package/src/sales/sales/pack-ship-print.service.ts +198 -0
- package/src/sales/sales/sales-pdf.service.ts +658 -0
- package/src/sales/sales/sales-print.service.ts +376 -0
- package/src/sales/sales/sales-totals.service.ts +500 -0
- package/src/sales-receive/sales-receive-pdf.service.ts +602 -0
- package/src/sales-receive/sales-receive-print.service.ts +242 -0
- package/src/sales-receive/sales-receive-totals.service.ts +651 -0
- package/src/services/checklist-pdf.ts +151 -0
- package/src/services/checklists-pdf.ts +133 -0
- package/src/services/est.print-service.ts +1155 -0
- package/src/services/reports/excel/insurance-expire-excel.service.ts +292 -0
- package/src/services/reports/excel/next-service-date-excel.service.ts +317 -0
- package/src/services/reports/excel/repair-orders-excel.service.ts +249 -0
- package/src/services/reports/pdf/insurance-expire-pdf.service.ts +115 -0
- package/src/services/reports/pdf/next-service-date-pdf.service.ts +198 -0
- package/src/services/reports/pdf/repair-orders-pdf.service.ts +184 -0
- package/src/services/ro-pdf.service.ts +1917 -0
- package/src/services/ro-print-service.ts +881 -0
- package/src/services/ro-totals.service.ts +1314 -0
- package/src/services/separate-wo-print.service.ts +396 -0
- package/src/services/service-history-pdf.service.ts +145 -0
- package/src/services/service-price-for-pricelist.ts +649 -0
- package/src/services/technician-pdf.service.ts +234 -0
- package/src/services/technician-print.service.ts +95 -0
- package/src/shared/header-footer-section/pdf-header-footer.section.ts +519 -0
- package/src/shared/header-footer-section/pdf-shared.utils.ts +46 -0
- package/src/shared/math-operations.ts +208 -0
- package/src/shared/party-details-section/pdf-party-details.section.ts +602 -0
- package/src/shared/shared-pdf.service.ts +3042 -0
- package/src/shared/shared-print.service.ts +879 -0
- package/src/shared/table-section/pdf-table.config.ts +8 -0
- package/src/shared/table-section/pdf-table.header.ts +396 -0
- package/src/shared/table-section/pdf-table.row.ts +248 -0
- package/src/shared/table-section/pdf-table.section.ts +447 -0
- package/src/shared/totals-section/pdf-totals.section.ts +921 -0
- package/src/shared/transactions-pdf.service.ts +191 -0
- package/src/shared/util.ts +101 -0
- package/src/tasks/meetings/meeting-pdf.ts +410 -0
- package/src/tasks/tasks/task-pdf.service.ts +238 -0
- package/src/tasks/tasks/task-reports-pdf.service.ts +313 -0
- package/src/tax/index.ts +86 -0
- package/src/tax/tax-calculator.ts +1025 -0
- package/src/tax/tax.types.ts +535 -0
- package/src/transaction-calculations/discounts-distribution.ts +343 -0
- package/src/transaction-calculations/index.ts +3 -0
- package/src/transaction-calculations/total-calculation.ts +443 -0
- package/src/transaction-calculations/transaction-calculation-engine.ts +903 -0
- package/src/utils/my-date.ts +111 -0
- package/src/utils/tr-utils.ts +104 -0
- package/tsconfig.json +2 -2
- /package/dist/{accounting/invoice/invoice-pdf.service.d.ts → shared/transactions-pdf.service.d.ts} +0 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { Add, Divide, Multiply, Subtract } from "../../shared/math-operations";
|
|
2
|
+
import { TrUtils } from "../../utils/tr-utils";
|
|
3
|
+
|
|
4
|
+
export class POTotalsService {
|
|
5
|
+
|
|
6
|
+
static GetTotalsValue(ItemsList: any, IsIndependentTax: boolean, DetailedInfo: boolean,
|
|
7
|
+
Disc: any, Perc: any, TaxCodes: any, WithItems: boolean, EntitySettings: any) {
|
|
8
|
+
|
|
9
|
+
ItemsList = this.CalculateItemValues(ItemsList);
|
|
10
|
+
|
|
11
|
+
let finalTotalsData: any = this.GetFinalPODataForSave(ItemsList, IsIndependentTax,
|
|
12
|
+
Disc, Perc, DetailedInfo, EntitySettings.DecimalsNumber);
|
|
13
|
+
|
|
14
|
+
if (DetailedInfo) {
|
|
15
|
+
finalTotalsData = this.GetDetailedTotalsData(finalTotalsData, IsIndependentTax, ItemsList, TaxCodes, EntitySettings.DecimalsNumber);
|
|
16
|
+
}
|
|
17
|
+
if (WithItems) {
|
|
18
|
+
finalTotalsData.Items = ItemsList;
|
|
19
|
+
}
|
|
20
|
+
return finalTotalsData;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static CalculateItemValues(ItemsList: any) {
|
|
24
|
+
ItemsList = this.ResetItemValues(ItemsList);
|
|
25
|
+
|
|
26
|
+
// ItemsList = this.GetItemsDiscountPrice(ItemsList);
|
|
27
|
+
|
|
28
|
+
// ItemsList = this.GetItemsAfterDiscount(ItemsList);
|
|
29
|
+
|
|
30
|
+
return ItemsList;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static ResetItemValues(ItemsList: any) {
|
|
34
|
+
ItemsList.forEach((Item: any) => {
|
|
35
|
+
Item = this.ResetItemValueIfInvalid(Item);
|
|
36
|
+
Item.DiscountedPrice = this.GetItemDiscountedPrice(Item.UnPr, Item.Qty,
|
|
37
|
+
Item.Disc, Item.Perc);
|
|
38
|
+
Item.AfterItemDisc = this.GetItemTotalAfterDiscount(Item.UnPr, Item.Qty,
|
|
39
|
+
Item.Disc, Item.Perc);
|
|
40
|
+
});
|
|
41
|
+
return ItemsList;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static ResetItemValueIfInvalid(Item: any) {
|
|
45
|
+
Item.UnPr = TrUtils.SetValueToZeroIfNull(Item.UnPr);
|
|
46
|
+
Item.Disc = TrUtils.SetValueToZeroIfNull(Item.Disc);
|
|
47
|
+
Item.CCGST = TrUtils.SetValueToZeroIfNull(Item.CCGST);
|
|
48
|
+
Item.CSGST = TrUtils.SetValueToZeroIfNull(Item.CSGST);
|
|
49
|
+
Item.CIGST = TrUtils.SetValueToZeroIfNull(Item.CIGST);
|
|
50
|
+
return Item;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static GetItemDiscountedPrice(Price: any, Qty: any, Disc: any, DiscInPerc: boolean) {
|
|
54
|
+
if (DiscInPerc) {
|
|
55
|
+
return ((Price * Qty) * Disc) / 100;
|
|
56
|
+
} else {
|
|
57
|
+
return Disc;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static GetItemTotalAfterDiscount(Price: any, Qty: any, Disc: any, DiscInPerc: boolean) {
|
|
62
|
+
return ((Price * Qty) - this.GetItemDiscountedPrice(Price, Qty, Disc, DiscInPerc))
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static GetFinalPODataForSave(ItemsList: any, IsIndependentTax: boolean,
|
|
66
|
+
Disc: any, Perc: any, DetailedInfo: boolean, DecimalsNumber: number) {
|
|
67
|
+
|
|
68
|
+
let finalTotalsData: any = {};
|
|
69
|
+
|
|
70
|
+
finalTotalsData = this.ResetRecordDiscountsIfInvalid(Disc, Perc, finalTotalsData, DetailedInfo);
|
|
71
|
+
|
|
72
|
+
finalTotalsData = this.GetFinalTotalsData(finalTotalsData, ItemsList,
|
|
73
|
+
IsIndependentTax, Disc, Perc, DetailedInfo, DecimalsNumber);
|
|
74
|
+
|
|
75
|
+
return finalTotalsData;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static ResetRecordDiscountsIfInvalid(Disc: any, Perc: boolean, finalTotalsData: any, DetailedInfo: boolean) {
|
|
79
|
+
|
|
80
|
+
Perc = TrUtils.SetPercToTrueIfNull(Perc);
|
|
81
|
+
Disc = TrUtils.SetValueToZeroIfNull(Disc);
|
|
82
|
+
|
|
83
|
+
finalTotalsData.Disc = Disc;
|
|
84
|
+
finalTotalsData.Perc = Perc;
|
|
85
|
+
|
|
86
|
+
if (DetailedInfo) {
|
|
87
|
+
finalTotalsData.FixedDisc = Disc;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return finalTotalsData;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static GetFinalTotalsData(finalTotalsData: any, ItemsList: any, IsIndependentTax: boolean,
|
|
94
|
+
Disc: any, Perc: boolean, DetailedInfo: boolean, DecimalsNumber: number) {
|
|
95
|
+
let AfterDiscTotals: number = this.GetSubTotal(ItemsList);
|
|
96
|
+
|
|
97
|
+
let ItemTaxTotal = this.GetItemsTaxTotal(ItemsList, IsIndependentTax);
|
|
98
|
+
|
|
99
|
+
finalTotalsData.SubTotal = TrUtils.FixedTo(AfterDiscTotals, DecimalsNumber);
|
|
100
|
+
|
|
101
|
+
let Total: any = this.GetTotalBasedOnTaxType(ItemTaxTotal, ItemsList,
|
|
102
|
+
IsIndependentTax, Disc, Perc);
|
|
103
|
+
|
|
104
|
+
finalTotalsData.Total = TrUtils.FixedTo(Total, DecimalsNumber);
|
|
105
|
+
|
|
106
|
+
finalTotalsData.ITax = IsIndependentTax;
|
|
107
|
+
|
|
108
|
+
if (DetailedInfo) {
|
|
109
|
+
finalTotalsData.FixedSubTotal = TrUtils.FixedTo(AfterDiscTotals, DecimalsNumber);
|
|
110
|
+
finalTotalsData.FixedTotal = TrUtils.FixedTo(Total, DecimalsNumber);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return finalTotalsData;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static GetSubTotal(ItemsList: any) {
|
|
117
|
+
let ItemsTotalAfterDisc: any = this.GetItemsTotalAfterDiscount(ItemsList);
|
|
118
|
+
return ItemsTotalAfterDisc;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static GetDetailedTotalsData(finalTotalsData: any, IsIndependentTax: boolean, ItemsList: any,
|
|
122
|
+
TaxCodes: any, DecimalsNumber: number) {
|
|
123
|
+
|
|
124
|
+
finalTotalsData.ItemsDiscTotal = this.GetItemDiscountedTotal(ItemsList);
|
|
125
|
+
|
|
126
|
+
finalTotalsData.ItemsTotalAfterDisc = this.GetItemsTotalAfterDiscount(ItemsList);
|
|
127
|
+
|
|
128
|
+
finalTotalsData.ItemsTotalBeforeDisc = TrUtils.FixedTo(Add(finalTotalsData.ItemsTotalAfterDisc
|
|
129
|
+
, finalTotalsData.ItemsDiscTotal), DecimalsNumber);
|
|
130
|
+
|
|
131
|
+
finalTotalsData.ItemITax = this.GetItemsTaxTotal(ItemsList, IsIndependentTax);
|
|
132
|
+
// finalTotalsData.ItemCGST = this.GetItemCGSTTaxTotal(ItemsList, IsIndependentTax);
|
|
133
|
+
// finalTotalsData.ItemIGST = this.GetItemIGSTTaxTotal(ItemsList, IsIndependentTax);
|
|
134
|
+
// finalTotalsData.ItemSGST = this.GetItemSGSTTaxTotal(ItemsList, IsIndependentTax);
|
|
135
|
+
let TaxAmt: any = this.GetItemGSTTaxTotal(ItemsList);
|
|
136
|
+
|
|
137
|
+
finalTotalsData.ItemCGST = TrUtils.SetValueToZeroIfNull(TaxAmt[0]);
|
|
138
|
+
finalTotalsData.ItemSGST = TrUtils.SetValueToZeroIfNull(TaxAmt[1]);
|
|
139
|
+
finalTotalsData.ItemIGST = TrUtils.SetValueToZeroIfNull(TaxAmt[2]);
|
|
140
|
+
|
|
141
|
+
finalTotalsData.ItemAfterTax = TrUtils.FixedTo(Add(finalTotalsData.ItemITax , finalTotalsData.ItemsTotalAfterDisc), DecimalsNumber);
|
|
142
|
+
|
|
143
|
+
finalTotalsData.OverAllRecordDiscount = (finalTotalsData.Perc) ? Divide(Multiply(finalTotalsData.SubTotal , finalTotalsData.Disc), 100) : finalTotalsData.Disc;
|
|
144
|
+
|
|
145
|
+
finalTotalsData.TaxGroupData = this.GetItemsTaxGrouping(ItemsList, TaxCodes, DecimalsNumber);
|
|
146
|
+
|
|
147
|
+
finalTotalsData.TotalRoundedBy = TrUtils.FixedTo(Subtract(Math.round(finalTotalsData.Total), finalTotalsData.Total), DecimalsNumber);
|
|
148
|
+
|
|
149
|
+
finalTotalsData.RoundedTotal = Math.round(finalTotalsData.Total);
|
|
150
|
+
for (var key in finalTotalsData) {
|
|
151
|
+
if (key !== 'Total' && key !== 'SubTotal' &&
|
|
152
|
+
key !== 'Disc' && key !== 'Perc' && key !== 'ITax'
|
|
153
|
+
&& typeof finalTotalsData[key] === 'number') {
|
|
154
|
+
finalTotalsData[key] = TrUtils.FixPriceValue(finalTotalsData[key], DecimalsNumber);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return finalTotalsData;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static GetItemGSTTaxTotal(ItemsList: Array<any>) {
|
|
162
|
+
let CGSTAmt: number = 0;
|
|
163
|
+
let SGSTAmt: number = 0;
|
|
164
|
+
let IGSTAmt: number = 0;
|
|
165
|
+
ItemsList.forEach((Item: any) => {
|
|
166
|
+
CGSTAmt = Add(CGSTAmt, Item.CGST);
|
|
167
|
+
SGSTAmt = Add(SGSTAmt, Item.SGST);
|
|
168
|
+
IGSTAmt = Add(IGSTAmt, Item.IGST);
|
|
169
|
+
});
|
|
170
|
+
return [CGSTAmt, SGSTAmt, IGSTAmt];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
static GetItemDiscountedTotal(ItemsList: any) {
|
|
174
|
+
let ItemsDiscountedTotal: any = 0;
|
|
175
|
+
ItemsList.forEach((Item: any) => {
|
|
176
|
+
ItemsDiscountedTotal += Item.DiscountedPrice;
|
|
177
|
+
});
|
|
178
|
+
return ItemsDiscountedTotal;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
static GetItemsTotalAfterDiscount(ItemsList: any) {
|
|
182
|
+
let ItemsTotalAfterDisc: any = 0;
|
|
183
|
+
ItemsList.forEach((Item: any) => {
|
|
184
|
+
ItemsTotalAfterDisc += Item.AfterItemDisc;
|
|
185
|
+
});
|
|
186
|
+
return ItemsTotalAfterDisc;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
static GetItemsTaxTotal(ItemsList: any, IsIndependentTax: boolean) {
|
|
190
|
+
let TotalTaxAmt: any = 0;
|
|
191
|
+
if (IsIndependentTax) {
|
|
192
|
+
ItemsList.forEach((Item: any) => {
|
|
193
|
+
TotalTaxAmt = TotalTaxAmt + Item.CCGST + Item.CSGST + Item.CIGST;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return TotalTaxAmt;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
static GetTotalBasedOnTaxType(ItemsTaxAmount: number, ItemsList: any,
|
|
200
|
+
IsIndependentTax: boolean, Discount: number, DiscInPerc: boolean) {
|
|
201
|
+
|
|
202
|
+
let SubTotalWithTax: any = 0;
|
|
203
|
+
|
|
204
|
+
let ItemsAfterDisc: any = this.GetItemsTotalAfterDiscount(ItemsList);
|
|
205
|
+
|
|
206
|
+
if (IsIndependentTax) {
|
|
207
|
+
SubTotalWithTax = ItemsAfterDisc + ItemsTaxAmount;
|
|
208
|
+
} else {
|
|
209
|
+
SubTotalWithTax = ItemsAfterDisc;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
let Total = 0;
|
|
213
|
+
if (!TrUtils.IsZero(SubTotalWithTax)) {
|
|
214
|
+
if (DiscInPerc === true) {
|
|
215
|
+
Total = (SubTotalWithTax - (SubTotalWithTax * Discount) / 100);
|
|
216
|
+
} else {
|
|
217
|
+
Total = SubTotalWithTax - Discount;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return Total;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
static GetItemsTaxGrouping(ItemsList: any, TaxCodes: any, DecimalsNumber: number) {
|
|
225
|
+
return this.GetTaxGroupingItemsByHSN(ItemsList, TaxCodes, DecimalsNumber);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
static GetTaxGroupingItemsByHSN(Items: any, TaxCodes: any, DecimalsNumber: number) {
|
|
229
|
+
Items = this.GetCombinedTaxPercentage(Items, TaxCodes);
|
|
230
|
+
// Items = this.ResetItemsHSNIfInvalid(Items);
|
|
231
|
+
|
|
232
|
+
let FinalMatchedItems: any[] = this.CompareItemsByHSN(Items, TaxCodes);
|
|
233
|
+
|
|
234
|
+
return this.GetTaxGroupingInfoByHSN(FinalMatchedItems, TaxCodes, DecimalsNumber);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
static GetCombinedTaxPercentage(Items: any, TaxCodes: any) {
|
|
238
|
+
Items.forEach((Item: any) => {
|
|
239
|
+
if (TrUtils.IsNull(Item.HSN)) {
|
|
240
|
+
Item.HSN = '';
|
|
241
|
+
}
|
|
242
|
+
let TaxInfo = this.GetGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
243
|
+
Item.CGSTAmt = TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
|
|
244
|
+
Item.SGSTAmt = TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
|
|
245
|
+
Item.IGSTAmt = TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
|
|
246
|
+
Item.CombinedTaxPercentage = Add(Item.CGSTAmt, Item.SGSTAmt, Item.IGSTAmt);
|
|
247
|
+
});
|
|
248
|
+
return Items;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
static CompareItemsByHSN(Items: any, TaxCodes: any) {
|
|
252
|
+
let FinalMatchedItems: any[] = [];
|
|
253
|
+
Items.forEach((Item: any) => {
|
|
254
|
+
let MatchedItemsBasedOnHSN = Items.filter((argItem: any) => {
|
|
255
|
+
let ItemFound: boolean = false;
|
|
256
|
+
FinalMatchedItems.forEach((FinalArgItems: any) => {
|
|
257
|
+
let ItemIndex: any = FinalArgItems.findIndex((FinalArgItem: any) => {
|
|
258
|
+
return FinalArgItem._id === argItem._id;
|
|
259
|
+
});
|
|
260
|
+
if (ItemIndex !== -1) {
|
|
261
|
+
ItemFound = true;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
// let argCGST = this.GetCGSTValueBasedOnTaxCode(argItem.TCode, TaxCodes);
|
|
265
|
+
// let argSGST = this.GetSGSTValueBasedOnTaxCode(argItem.TCode, TaxCodes);
|
|
266
|
+
// let argIGST = this.GetIGSTValueBasedOnTaxCode(argItem.TCode, TaxCodes);
|
|
267
|
+
// let ItemCGST = this.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
268
|
+
// let ItemSGST = this.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
269
|
+
// let ItemIGST = this.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
270
|
+
return (argItem.HSN === Item.HSN) && (!ItemFound) &&
|
|
271
|
+
(argItem.CGSTAmt === Item.CGSTAmt) && (argItem.IGSTAmt === Item.IGSTAmt) &&
|
|
272
|
+
(argItem.SGSTAmt === Item.SGSTAmt);
|
|
273
|
+
});
|
|
274
|
+
if (MatchedItemsBasedOnHSN.length !== 0) {
|
|
275
|
+
FinalMatchedItems.push(MatchedItemsBasedOnHSN);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
return FinalMatchedItems;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
static GetTaxGroupingInfoByHSN(FinalMatchedItems: any, TaxCodes: any, DecimalsNumber: number) {
|
|
282
|
+
let HSNTaxInfo: any[] = [];
|
|
283
|
+
FinalMatchedItems.forEach((MatchedItem: any) => {
|
|
284
|
+
let TaxInfo: any = {};
|
|
285
|
+
let TaxOnAmount: any = 0;
|
|
286
|
+
let TaxAmount: any = 0;
|
|
287
|
+
let HSN: any = MatchedItem[0].HSN;
|
|
288
|
+
TaxInfo.CombinedTaxPercentage = MatchedItem[0].CombinedTaxPercentage;
|
|
289
|
+
MatchedItem.forEach((argMatchedGSTItem: any) => {
|
|
290
|
+
// TaxOnAmount += TrUtils.FixedTo(argMatchedGSTItem.AfterItemDisc);
|
|
291
|
+
// TaxAmount += TrUtils.FixedTo(argMatchedGSTItem.CCGST);
|
|
292
|
+
// TaxAmount += TrUtils.FixedTo(argMatchedGSTItem.CIGST);
|
|
293
|
+
// TaxAmount += TrUtils.FixedTo(argMatchedGSTItem.CSGST);
|
|
294
|
+
TaxOnAmount = Add(TaxOnAmount, argMatchedGSTItem.AfterItemDisc);
|
|
295
|
+
TaxAmount = Add(TaxAmount, argMatchedGSTItem.CGST);
|
|
296
|
+
TaxAmount = Add(TaxAmount, argMatchedGSTItem.IGST);
|
|
297
|
+
TaxAmount = Add(TaxAmount, argMatchedGSTItem.SGST);
|
|
298
|
+
});
|
|
299
|
+
TaxInfo.HSN = HSN;
|
|
300
|
+
TaxInfo.TotalTaxableAmount = TrUtils.FixPriceValue(TaxOnAmount, DecimalsNumber);
|
|
301
|
+
TaxInfo.TotalTaxAmount = TrUtils.FixPriceValue(TaxAmount, DecimalsNumber);
|
|
302
|
+
TaxInfo.ItemsCount = MatchedItem.length;
|
|
303
|
+
// let CGST = this.GetCGSTValueBasedOnTaxCode(MatchedItem[0].TCode, TaxCodes);
|
|
304
|
+
// let SGST = this.GetSGSTValueBasedOnTaxCode(MatchedItem[0].TCode, TaxCodes);
|
|
305
|
+
// let IGST = this.GetIGSTValueBasedOnTaxCode(MatchedItem[0].TCode, TaxCodes);
|
|
306
|
+
// TaxInfo.CGST = CGST;
|
|
307
|
+
// TaxInfo.IGST = IGST;
|
|
308
|
+
// TaxInfo.SGST = SGST;
|
|
309
|
+
TaxInfo.CGST = MatchedItem[0].CGSTAmt;
|
|
310
|
+
TaxInfo.IGST = MatchedItem[0].IGSTAmt;
|
|
311
|
+
TaxInfo.SGST = MatchedItem[0].SGSTAmt;
|
|
312
|
+
if (TaxOnAmount !== 0) {
|
|
313
|
+
HSNTaxInfo.push(TaxInfo);
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
return HSNTaxInfo;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
static GetGSTValueBasedOnTaxCode(TCode: any, argTaxCodes: any) {
|
|
320
|
+
if (TrUtils.IsNull(TCode)) {
|
|
321
|
+
return [0, 0, 0];
|
|
322
|
+
}
|
|
323
|
+
let TaxCodes: any = TrUtils.Stringify(argTaxCodes);
|
|
324
|
+
let TCodeIndex: any = TaxCodes.findIndex((TaxCode: any) => {
|
|
325
|
+
return TaxCode._id === Number(TCode);
|
|
326
|
+
});
|
|
327
|
+
if (TCodeIndex !== -1) {
|
|
328
|
+
// // if (TrUtils.IsNull(TaxCodes[TCodeIndex].CGST)) {
|
|
329
|
+
// // return 0;
|
|
330
|
+
// // } else {
|
|
331
|
+
// return [TaxCodes[TCodeIndex].CGST, TaxCodes[TCodeIndex].SGST, TaxCodes[TCodeIndex].IGST];
|
|
332
|
+
// // }
|
|
333
|
+
if (TaxCodes[TCodeIndex].Type === 'Intra') {
|
|
334
|
+
return [TaxCodes[TCodeIndex].CGST, TaxCodes[TCodeIndex].SGST, 0];
|
|
335
|
+
} else {
|
|
336
|
+
return [0, 0, TaxCodes[TCodeIndex].IGST];
|
|
337
|
+
}
|
|
338
|
+
} else {
|
|
339
|
+
return [0, 0, 0];
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
}
|