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,500 @@
|
|
|
1
|
+
import { Add, Divide, Multiply, Subtract } from "../../shared/math-operations";
|
|
2
|
+
import { TrUtils } from "../../utils/tr-utils";
|
|
3
|
+
|
|
4
|
+
export class SalesTotalsService {
|
|
5
|
+
|
|
6
|
+
static GetTotalsValue(ItemsList: any, IsIndependentTax: boolean, DetailedInfo: boolean,
|
|
7
|
+
PDisc: any, PPerc: string, Disc: any, Perc: string,
|
|
8
|
+
TaxCodes: any, WithItems: boolean, Settings: any, isRoundable: boolean, EntitySettings: any) {
|
|
9
|
+
|
|
10
|
+
// LPerc = TrUtils.SetPercToStringIfNull(LPerc);
|
|
11
|
+
PPerc = TrUtils.SetPercToStringIfNull(PPerc);
|
|
12
|
+
Perc = TrUtils.SetPercToStringIfNull(Perc);
|
|
13
|
+
// LDisc = TrUtils.SetValueToZeroIfNull(LDisc);
|
|
14
|
+
PDisc = TrUtils.SetValueToZeroIfNull(PDisc);
|
|
15
|
+
Disc = TrUtils.SetValueToZeroIfNull(Disc);
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// opCodesList = this.CalculateLaborValues(opCodesList, IsIndependentTax);
|
|
19
|
+
|
|
20
|
+
ItemsList = this.CalculateLaborItemValues(ItemsList, IsIndependentTax);
|
|
21
|
+
|
|
22
|
+
let finalTotalsData: any = this.GetFinalRODataForSave(ItemsList, IsIndependentTax,
|
|
23
|
+
PDisc, PPerc, Disc, Perc, DetailedInfo, Settings, isRoundable, EntitySettings);
|
|
24
|
+
|
|
25
|
+
if (DetailedInfo) {
|
|
26
|
+
finalTotalsData = this.GetDetailedTotalsData(finalTotalsData,
|
|
27
|
+
IsIndependentTax, ItemsList, TaxCodes, EntitySettings);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (WithItems) {
|
|
31
|
+
finalTotalsData.Items = ItemsList;
|
|
32
|
+
}
|
|
33
|
+
return finalTotalsData;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static CalculateLaborItemValues(ItemsList: any, IsIndependentTax: boolean) {
|
|
37
|
+
ItemsList = this.ResetLaborItemValues(ItemsList, IsIndependentTax);
|
|
38
|
+
|
|
39
|
+
// ItemsList = this.GetLaborItemsDiscountPrice(ItemsList);
|
|
40
|
+
|
|
41
|
+
// ItemsList = this.GetLaborItemsAfterDiscount(ItemsList);
|
|
42
|
+
|
|
43
|
+
// ItemsList = this.GetItemsAfterTax(ItemsList, IsIndependentTax);
|
|
44
|
+
|
|
45
|
+
return ItemsList;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static ResetLaborItemValues(ItemsList: any, IsIndependentTax: boolean) {
|
|
49
|
+
ItemsList.forEach((Item: any) => {
|
|
50
|
+
Item = this.ResetLaborItemValueIfInvalid(Item);
|
|
51
|
+
Item.DiscountedPrice = Add(Item.Disc, Item.RecDisc);
|
|
52
|
+
let NetAmt: number = Subtract(Item.UnAmt, Item.Disc, Item.RecDisc);
|
|
53
|
+
Item.AfterItemDisc = TrUtils.SetValueToZeroIfNull(NetAmt);
|
|
54
|
+
if (IsIndependentTax) {
|
|
55
|
+
Item.AfterItemTax = Add(Item.AfterItemDisc, Item.CGST, Item.SGST, Item.IGST);
|
|
56
|
+
} else {
|
|
57
|
+
Item.AfterItemTax = Item.AfterItemDisc;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return ItemsList;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static ResetLaborItemValueIfInvalid(Item: any) {
|
|
64
|
+
Item.UnPr = TrUtils.SetValueToZeroIfNull(Item.UnPr);
|
|
65
|
+
Item.Disc = TrUtils.SetValueToZeroIfNull(Item.Disc);
|
|
66
|
+
Item.RecDisc = TrUtils.SetValueToZeroIfNull(Item.RecDisc);
|
|
67
|
+
Item.CGST = this.GetTaxAmountFromTaxes(Item, 'CGST');
|
|
68
|
+
Item.SGST = this.GetTaxAmountFromTaxes(Item, 'SGST');
|
|
69
|
+
Item.IGST = this.GetTaxAmountFromTaxes(Item, 'IGST');
|
|
70
|
+
Item.TCode = this.GetTCodeFromTaxes(Item);
|
|
71
|
+
|
|
72
|
+
return Item;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static GetTCodeFromTaxes(item: any) {
|
|
76
|
+
const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
|
|
77
|
+
const matchedTax = taxes.find((tax: any) => !TrUtils.IsNull(tax?.TaxCodeId));
|
|
78
|
+
if (!TrUtils.IsNull(matchedTax?.TaxCodeId)) {
|
|
79
|
+
return matchedTax.TaxCodeId;
|
|
80
|
+
}
|
|
81
|
+
return item?.TCode;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static GetFinalRODataForSave(ItemsList: any, IsIndependentTax: boolean,
|
|
85
|
+
PDisc: string, PPerc: string, Disc: any, Perc: string,
|
|
86
|
+
DetailedInfo: boolean, Settings: any, isRoundable: boolean, DecimalsNumber: number) {
|
|
87
|
+
|
|
88
|
+
let finalTotalsData: any = {};
|
|
89
|
+
|
|
90
|
+
finalTotalsData = this.SetMainDiscountValues(PPerc, PDisc, Disc, Perc, finalTotalsData, DetailedInfo);
|
|
91
|
+
|
|
92
|
+
finalTotalsData.Settings = Settings;
|
|
93
|
+
|
|
94
|
+
finalTotalsData = this.GetFinalCustomerTotalsData(finalTotalsData, ItemsList,
|
|
95
|
+
IsIndependentTax, DetailedInfo, isRoundable, DecimalsNumber);
|
|
96
|
+
|
|
97
|
+
return finalTotalsData;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static SetMainDiscountValues(PPerc: string,
|
|
101
|
+
PDisc: any, Disc: any, Perc: string, finalTotalsData: any, DetailedInfo: boolean) {
|
|
102
|
+
finalTotalsData.PDisc = PDisc;
|
|
103
|
+
finalTotalsData.PPerc = PPerc;
|
|
104
|
+
|
|
105
|
+
finalTotalsData.Disc = Disc;
|
|
106
|
+
finalTotalsData.Perc = Perc;
|
|
107
|
+
|
|
108
|
+
if (DetailedInfo) {
|
|
109
|
+
finalTotalsData.FixedPDisc = PDisc;
|
|
110
|
+
finalTotalsData.FixedDisc = Disc;
|
|
111
|
+
}
|
|
112
|
+
return finalTotalsData;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static GetFinalCustomerTotalsData(finalTotalsData: any, ItemsList: any, IsIndependentTax: boolean,
|
|
116
|
+
DetailedInfo: boolean, isRoundable: boolean, DecimalsNumber: number) {
|
|
117
|
+
let CustomerAfterDiscTotals: number = this.GetSubTotalFor(ItemsList);
|
|
118
|
+
|
|
119
|
+
// let CustLaborTaxTotal = this.GetLaborTaxTotalFor(IsIndependentTax);
|
|
120
|
+
|
|
121
|
+
let CustItemTaxTotal = this.GetItemsTaxTotalFor(ItemsList, IsIndependentTax);
|
|
122
|
+
let CustItemsDiscTotal = this.GetItemDiscountedTotal(ItemsList);
|
|
123
|
+
|
|
124
|
+
finalTotalsData.SubTotal = Add(CustomerAfterDiscTotals, CustItemsDiscTotal);
|
|
125
|
+
|
|
126
|
+
let CustTotal: any = this.GetCustomerTotalBasedOnTaxType(CustItemTaxTotal, ItemsList, IsIndependentTax);
|
|
127
|
+
|
|
128
|
+
if (isRoundable) {
|
|
129
|
+
finalTotalsData.Round = Subtract(Math.round(CustTotal), CustTotal);
|
|
130
|
+
finalTotalsData.Total = Math.round(CustTotal);
|
|
131
|
+
} else {
|
|
132
|
+
finalTotalsData.Total = TrUtils.FixedTo(CustTotal, DecimalsNumber);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
if (DetailedInfo) {
|
|
138
|
+
finalTotalsData.FixedSubTotal = TrUtils.FixedTo(CustomerAfterDiscTotals, DecimalsNumber);
|
|
139
|
+
finalTotalsData.FixedTotal = TrUtils.FixedTo(CustTotal, DecimalsNumber);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
return finalTotalsData;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static GetSubTotalFor(ItemsList: any) {
|
|
147
|
+
// let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
|
|
148
|
+
let ItemsTotalAfterDisc: any = this.GetItemsTotalAfterDiscount(ItemsList);
|
|
149
|
+
return ItemsTotalAfterDisc;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static GetItemsTotalAfterDiscount(ItemsList: any) {
|
|
153
|
+
let ItemsTotalAfterDisc: any = 0;
|
|
154
|
+
ItemsList.forEach((Item: any) => {
|
|
155
|
+
ItemsTotalAfterDisc = Add(ItemsTotalAfterDisc, Item.AfterItemDisc);
|
|
156
|
+
});
|
|
157
|
+
return ItemsTotalAfterDisc;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
static GetDetailedTotalsData(finalTotalsData: any, IsIndependentTax: boolean, ItemsList: any, TaxCodes: any, DecimalsNumber: any) {
|
|
161
|
+
// finalTotalsData.CustLaborDiscTotal = this.GetLaborDiscountedTotal(opCodesList);
|
|
162
|
+
|
|
163
|
+
finalTotalsData.CustItemsDiscTotal = this.GetItemDiscountedTotal(ItemsList);
|
|
164
|
+
|
|
165
|
+
// finalTotalsData.CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(opCodesList);
|
|
166
|
+
finalTotalsData.CustItemsTotalAfterDisc = this.GetItemsTotalAfterDiscount(ItemsList);
|
|
167
|
+
|
|
168
|
+
finalTotalsData.CustLaborTotalBeforeDisc = Add(finalTotalsData.CustLaborTotalAfterDisc
|
|
169
|
+
, finalTotalsData.CustLaborDiscTotal);
|
|
170
|
+
finalTotalsData.CustItemsTotalBeforeDisc = Add(finalTotalsData.CustItemsTotalAfterDisc
|
|
171
|
+
, finalTotalsData.CustItemsDiscTotal);
|
|
172
|
+
|
|
173
|
+
// finalTotalsData.CustLaborITax = this.GetLaborTaxTotalFor(opCodesList, IsIndependentTax);
|
|
174
|
+
// finalTotalsData.CustLaborSGST = this.GetLaborSGSTTaxTotal(opCodesList, IsIndependentTax);
|
|
175
|
+
// finalTotalsData.CustLaborCGST = this.GetLaborCGSTTaxTotal(opCodesList, IsIndependentTax);
|
|
176
|
+
// finalTotalsData.CustLaborIGST = this.GetLaborIGSTTaxTotal(opCodesList, IsIndependentTax);
|
|
177
|
+
|
|
178
|
+
let TaxInfo: any = this.GetItemGSTTaxTotal(ItemsList, IsIndependentTax);
|
|
179
|
+
finalTotalsData.CustItemITax = TrUtils.SetValueToZeroIfNull(TaxInfo[3]);
|
|
180
|
+
finalTotalsData.CustItemCGST = TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
|
|
181
|
+
finalTotalsData.CustItemIGST = TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
|
|
182
|
+
finalTotalsData.CustItemSGST = TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
|
|
183
|
+
|
|
184
|
+
// finalTotalsData.CustLaborAfterTax = TrUtils.FixedTo(finalTotalsData.CustLaborITax + finalTotalsData.CustLaborTotalAfterDisc);
|
|
185
|
+
finalTotalsData.CustItemAfterTax = Add(finalTotalsData.CustItemITax, finalTotalsData.CustItemsTotalAfterDisc);
|
|
186
|
+
|
|
187
|
+
finalTotalsData.CustTaxGroupData = this.GetTaxGroupingForItemsByHSN(ItemsList, TaxCodes, DecimalsNumber);
|
|
188
|
+
finalTotalsData.CustTaxGroupDataByPerc = this.GetTaxGroupingForPartsByPerc(ItemsList, TaxCodes, DecimalsNumber);
|
|
189
|
+
|
|
190
|
+
finalTotalsData.CustTotalRoundedBy = TrUtils.FixedTo(finalTotalsData.Round, DecimalsNumber);
|
|
191
|
+
|
|
192
|
+
finalTotalsData.CustRoundedTotal = TrUtils.FixedTo(finalTotalsData.Total, DecimalsNumber);
|
|
193
|
+
|
|
194
|
+
for (var key in finalTotalsData) {
|
|
195
|
+
if (key !== 'Total' && key !== 'SubTotal' &&
|
|
196
|
+
key !== 'LDisc' && key !== 'LPerc' && key !== 'PDisc' &&
|
|
197
|
+
key !== 'PPerc' && key !== 'Disc' && key !== 'Perc' && key !== 'Tax'
|
|
198
|
+
&& typeof finalTotalsData[key] === 'number') {
|
|
199
|
+
finalTotalsData[key] = TrUtils.FixPriceValue(finalTotalsData[key], DecimalsNumber);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return finalTotalsData;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
static GetTaxGroupingForPartsByPerc(Parts: any, TaxCodes: any, DecimalsNumber: any) {
|
|
207
|
+
Parts = this.GetCombinedTaxPercentage(TrUtils.Stringify(Parts), TaxCodes);
|
|
208
|
+
// Parts = this.ResetPartsHSNIfInvalid(Parts);
|
|
209
|
+
|
|
210
|
+
let FinalMatchedParts: any[] = this.ComparePartsByPerc(Parts, TaxCodes);
|
|
211
|
+
|
|
212
|
+
return this.GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, DecimalsNumber);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
static ComparePartsByPerc(Parts: any, TaxCodes: any) {
|
|
216
|
+
let FinalMatchedParts: any[] = [];
|
|
217
|
+
Parts?.forEach((Part: any) => {
|
|
218
|
+
let MatchedPartsBasedOnHSN = Parts.filter((argPart: any) => {
|
|
219
|
+
let PartFound: boolean = false;
|
|
220
|
+
FinalMatchedParts.forEach((FinalArgParts: any) => {
|
|
221
|
+
let PartIndex: any = FinalArgParts.findIndex((FinalArgPart: any) => {
|
|
222
|
+
return FinalArgPart._id === argPart._id;
|
|
223
|
+
});
|
|
224
|
+
if (PartIndex !== -1) {
|
|
225
|
+
PartFound = true;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argPart.TCode, TaxCodes);
|
|
230
|
+
// let argCGST = argGSTValues[0];
|
|
231
|
+
// let argSGST = argGSTValues[1];
|
|
232
|
+
// let argIGST = argGSTValues[2];
|
|
233
|
+
|
|
234
|
+
// let partGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
235
|
+
// let partCGST = partGSTValues[0];
|
|
236
|
+
// let partSGST = partGSTValues[1];
|
|
237
|
+
// let partIGST = partGSTValues[2];
|
|
238
|
+
|
|
239
|
+
return (!PartFound) &&
|
|
240
|
+
(argPart.CGSTAmt === Part.CGSTAmt) && (argPart.IGSTAmt === Part.IGSTAmt) &&
|
|
241
|
+
(argPart.SGSTAmt === Part.SGSTAmt);
|
|
242
|
+
});
|
|
243
|
+
if (MatchedPartsBasedOnHSN.length !== 0) {
|
|
244
|
+
FinalMatchedParts.push(MatchedPartsBasedOnHSN);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
return FinalMatchedParts;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
static GetLaborDiscountedTotal(LaborList: any) {
|
|
252
|
+
let LaborDiscountedTotal: any = 0;
|
|
253
|
+
LaborList.forEach((Labor: any) => {
|
|
254
|
+
LaborDiscountedTotal = Add(LaborDiscountedTotal, Labor.DiscountedPrice);
|
|
255
|
+
});
|
|
256
|
+
return LaborDiscountedTotal;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
static GetItemDiscountedTotal(ItemsList: any) {
|
|
260
|
+
let ItemsDiscountedTotal: any = 0;
|
|
261
|
+
ItemsList.forEach((Item: any) => {
|
|
262
|
+
ItemsDiscountedTotal = Add(ItemsDiscountedTotal, Item.DiscountedPrice);
|
|
263
|
+
});
|
|
264
|
+
return ItemsDiscountedTotal;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
static GetItemsTaxTotalFor(ItemsList: any, IsIndependentTax: boolean) {
|
|
268
|
+
let TotalTaxAmt: any = 0;
|
|
269
|
+
if (IsIndependentTax) {
|
|
270
|
+
ItemsList.forEach((Item: any) => {
|
|
271
|
+
TotalTaxAmt = Add(TotalTaxAmt, Item.CGST, Item.SGST, Item.IGST);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
return TotalTaxAmt;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
static GetCustomerTotalBasedOnTaxType(ItemsTaxAmount: number, ItemsList: any, IsIndependentTax: boolean) {
|
|
278
|
+
// let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
|
|
279
|
+
let ItemsTotalAfterDisc: any = this.GetItemsTotalAfterDiscount(ItemsList);
|
|
280
|
+
if (IsIndependentTax) {
|
|
281
|
+
return Add(ItemsTotalAfterDisc, ItemsTaxAmount);
|
|
282
|
+
} else {
|
|
283
|
+
return ItemsTotalAfterDisc;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
static LaborTotalAfterDiscount(LaborTotalAfterDisc: number, LaborTaxAmount: number, MainLDisc: number, LDiscInPerc: string) {
|
|
288
|
+
let LaborTotal: number = Add(LaborTotalAfterDisc, LaborTaxAmount);
|
|
289
|
+
if (!TrUtils.IsZero(MainLDisc)) {
|
|
290
|
+
if (!TrUtils.IsEmpty(LDiscInPerc)) {
|
|
291
|
+
LaborTotal = Subtract(LaborTotal, Divide(Multiply(LaborTotal, Number(LDiscInPerc)), 100));
|
|
292
|
+
} else {
|
|
293
|
+
LaborTotal = Subtract(LaborTotal, MainLDisc);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return LaborTotal;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
static ItemsTotalAfterDiscount(ItemsTotalAfterDisc: number, ItemsTaxAmount: number, MainPDisc: number, PDiscInPerc: string) {
|
|
300
|
+
let ItemsTotal: number = Add(ItemsTotalAfterDisc, ItemsTaxAmount);
|
|
301
|
+
if (!TrUtils.IsZero(MainPDisc)) {
|
|
302
|
+
if (!TrUtils.IsEmpty(PDiscInPerc)) {
|
|
303
|
+
ItemsTotal = Subtract(ItemsTotal, Divide(Multiply(ItemsTotal, Number(PDiscInPerc)), 100));
|
|
304
|
+
} else {
|
|
305
|
+
ItemsTotal = Subtract(ItemsTotal, MainPDisc);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return ItemsTotal;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
static GetLaborCGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean) {
|
|
312
|
+
let TotalTaxAmt: any = 0;
|
|
313
|
+
if (IsIndependentTax) {
|
|
314
|
+
opCodesList.forEach((Labor: any) => {
|
|
315
|
+
TotalTaxAmt = Add(TotalTaxAmt, Labor.CGST);
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return TotalTaxAmt;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
static GetLaborIGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean) {
|
|
322
|
+
let TotalTaxAmt: any = 0;
|
|
323
|
+
if (IsIndependentTax) {
|
|
324
|
+
opCodesList.forEach((Labor: any) => {
|
|
325
|
+
TotalTaxAmt = Add(TotalTaxAmt, Labor.IGST);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return TotalTaxAmt;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
static GetLaborSGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean) {
|
|
332
|
+
let TotalTaxAmt: any = 0;
|
|
333
|
+
if (IsIndependentTax) {
|
|
334
|
+
opCodesList.forEach((Labor: any) => {
|
|
335
|
+
TotalTaxAmt = Add(TotalTaxAmt, Labor.SGST);
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
return TotalTaxAmt;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
static GetItemGSTTaxTotal(ItemsList: any, IsIndependentTax: boolean) {
|
|
342
|
+
let TotalCGSTAmt: number = 0;
|
|
343
|
+
let TotalSGSTAmt: number = 0;
|
|
344
|
+
let TotalIGSTAmt: number = 0;
|
|
345
|
+
let TotalTaxAmt: number = 0;
|
|
346
|
+
if (IsIndependentTax) {
|
|
347
|
+
ItemsList.forEach((Item: any) => {
|
|
348
|
+
TotalCGSTAmt = Add(TotalCGSTAmt, Item.CGST);
|
|
349
|
+
TotalSGSTAmt = Add(TotalSGSTAmt, Item.SGST);
|
|
350
|
+
TotalIGSTAmt = Add(TotalIGSTAmt, Item.IGST);
|
|
351
|
+
TotalTaxAmt = Add(TotalTaxAmt, Item.CGST, Item.SGST, Item.IGST);
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
return [TotalCGSTAmt, TotalSGSTAmt, TotalIGSTAmt, TotalTaxAmt];
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
static GetTaxGroupingForItemsByHSN(Items: any, TaxCodes: any, DecimalsNumber: number) {
|
|
358
|
+
Items = this.GetCombinedTaxPercentage(Items, TaxCodes);
|
|
359
|
+
// Items = this.ResetItemsHSNIfInvalid(Items);
|
|
360
|
+
|
|
361
|
+
let FinalMatchedItems: any[] = this.CompareItemsByHSN(Items, TaxCodes);
|
|
362
|
+
|
|
363
|
+
return this.GetTaxGroupingInfoByHSN(FinalMatchedItems, TaxCodes, DecimalsNumber);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
static GetCombinedTaxPercentage(Items: any, TaxCodes: any) {
|
|
367
|
+
Items.forEach((Item: any) => {
|
|
368
|
+
if (TrUtils.IsNull(Item.HSN)) {
|
|
369
|
+
Item.HSN = '';
|
|
370
|
+
}
|
|
371
|
+
let TaxInfo = this.GetGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
372
|
+
Item.CGSTAmt = this.GetTaxRateFromTaxes(Item, 'CGST');
|
|
373
|
+
Item.SGSTAmt = this.GetTaxRateFromTaxes(Item, 'SGST');
|
|
374
|
+
Item.IGSTAmt = this.GetTaxRateFromTaxes(Item, 'IGST');
|
|
375
|
+
|
|
376
|
+
Item.CombinedTaxPercentage = Add(Item.CGSTAmt, Item.SGSTAmt, Item.IGSTAmt);
|
|
377
|
+
});
|
|
378
|
+
return Items;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
static CompareItemsByHSN(Items: any, TaxCodes: any) {
|
|
382
|
+
let FinalMatchedItems: any[] = [];
|
|
383
|
+
Items.forEach((Item: any) => {
|
|
384
|
+
let MatchedItemsBasedOnHSN = Items.filter((argItem: any) => {
|
|
385
|
+
let ItemFound: boolean = false;
|
|
386
|
+
FinalMatchedItems.forEach((FinalArgItems: any) => {
|
|
387
|
+
let ItemIndex: any = FinalArgItems.findIndex((FinalArgItem: any) => {
|
|
388
|
+
return FinalArgItem._id === argItem._id;
|
|
389
|
+
});
|
|
390
|
+
if (ItemIndex !== -1) {
|
|
391
|
+
ItemFound = true;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
// let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argItem.TCode, TaxCodes);
|
|
396
|
+
// let argCGST = argGSTValues[0];
|
|
397
|
+
// let argSGST = argGSTValues[1];
|
|
398
|
+
// let argIGST = argGSTValues[2];
|
|
399
|
+
|
|
400
|
+
// let ItemGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
401
|
+
// let ItemCGST = ItemGSTValues[0];
|
|
402
|
+
// let ItemSGST = ItemGSTValues[1];
|
|
403
|
+
// let ItemIGST = ItemGSTValues[2];
|
|
404
|
+
|
|
405
|
+
return (argItem.HSN === Item.HSN) && (!ItemFound) &&
|
|
406
|
+
(argItem.CGSTAmt === Item.CGSTAmt) && (argItem.IGSTAmt === Item.IGSTAmt) &&
|
|
407
|
+
(argItem.SGSTAmt === Item.SGSTAmt);
|
|
408
|
+
});
|
|
409
|
+
if (MatchedItemsBasedOnHSN.length !== 0) {
|
|
410
|
+
FinalMatchedItems.push(MatchedItemsBasedOnHSN);
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
return FinalMatchedItems;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
static GetTaxGroupingInfoByHSN(FinalMatchedParts: any, TaxCodes: any, DecimalsNumber: any) {
|
|
417
|
+
let HSNTaxInfo: any[] = [];
|
|
418
|
+
FinalMatchedParts.forEach((MatchedPart: any) => {
|
|
419
|
+
let TaxInfo: any = {};
|
|
420
|
+
let TaxOnAmount: any = 0;
|
|
421
|
+
let TaxAmount: any = 0;
|
|
422
|
+
|
|
423
|
+
let CGSTAmt: any = 0;
|
|
424
|
+
let SGSTAmt: any = 0;
|
|
425
|
+
let IGSTAmt: any = 0;
|
|
426
|
+
|
|
427
|
+
let HSN: any = MatchedPart[0].HSN;
|
|
428
|
+
TaxInfo.CombinedTaxPercentage = MatchedPart[0].CombinedTaxPercentage;
|
|
429
|
+
MatchedPart.forEach((argMatchedGSTPart: any) => {
|
|
430
|
+
TaxOnAmount = Add(TaxOnAmount, TrUtils.FixedTo(argMatchedGSTPart.AfterPartDisc, DecimalsNumber));
|
|
431
|
+
TaxAmount = Add(TaxAmount, TrUtils.FixedTo(argMatchedGSTPart.CGST, DecimalsNumber));
|
|
432
|
+
TaxAmount = Add(TaxAmount, TrUtils.FixedTo(argMatchedGSTPart.IGST, DecimalsNumber));
|
|
433
|
+
TaxAmount = Add(TaxAmount, TrUtils.FixedTo(argMatchedGSTPart.SGST, DecimalsNumber));
|
|
434
|
+
CGSTAmt = Add(CGSTAmt, TrUtils.FixedTo(argMatchedGSTPart.CGST, DecimalsNumber));
|
|
435
|
+
SGSTAmt = Add(SGSTAmt, TrUtils.FixedTo(argMatchedGSTPart.SGST, DecimalsNumber));
|
|
436
|
+
IGSTAmt = Add(IGSTAmt, TrUtils.FixedTo(argMatchedGSTPart.IGST, DecimalsNumber));
|
|
437
|
+
});
|
|
438
|
+
TaxInfo.HSN = HSN;
|
|
439
|
+
|
|
440
|
+
TaxInfo.CGSTAmt = CGSTAmt;
|
|
441
|
+
TaxInfo.SGSTAmt = SGSTAmt;
|
|
442
|
+
TaxInfo.IGSTAmt = IGSTAmt;
|
|
443
|
+
|
|
444
|
+
TaxInfo.TotalTaxableAmount = TrUtils.FixPriceValue(TaxOnAmount, DecimalsNumber);
|
|
445
|
+
TaxInfo.TotalTaxAmount = TrUtils.FixPriceValue(TaxAmount, DecimalsNumber);
|
|
446
|
+
TaxInfo.ItemsCount = MatchedPart.length;
|
|
447
|
+
// let GSTValues: any[] = this.GetGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
|
|
448
|
+
// TaxInfo.CGST = GSTValues[0];
|
|
449
|
+
// TaxInfo.SGST = GSTValues[1];
|
|
450
|
+
// TaxInfo.IGST = GSTValues[2];
|
|
451
|
+
TaxInfo.CGST = MatchedPart[0].CGSTAmt;
|
|
452
|
+
TaxInfo.IGST = MatchedPart[0].IGSTAmt;
|
|
453
|
+
TaxInfo.SGST = MatchedPart[0].SGSTAmt;
|
|
454
|
+
if (TaxOnAmount !== 0) {
|
|
455
|
+
HSNTaxInfo.push(TaxInfo);
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
return HSNTaxInfo;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
static GetTaxAmountFromTaxes(item: any, taxCode: string, fallbackAmount: any = 0) {
|
|
462
|
+
const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
|
|
463
|
+
const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
|
|
464
|
+
if (matchedTaxes.length !== 0) {
|
|
465
|
+
return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Amt), 0);
|
|
466
|
+
}
|
|
467
|
+
return TrUtils.SetValueToZeroIfNull(fallbackAmount);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
static GetTaxRateFromTaxes(item: any, taxCode: string, fallbackRate: any = 0) {
|
|
471
|
+
const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
|
|
472
|
+
const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
|
|
473
|
+
if (matchedTaxes.length !== 0) {
|
|
474
|
+
return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Rate), 0);
|
|
475
|
+
}
|
|
476
|
+
return TrUtils.SetValueToZeroIfNull(fallbackRate);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
static GetGSTValueBasedOnTaxCode(TCode: any, TaxCodes: any) {
|
|
480
|
+
let CGST: number = 0;
|
|
481
|
+
let SGST: number = 0;
|
|
482
|
+
let IGST: number = 0;
|
|
483
|
+
if (TrUtils.IsNull(TCode)) {
|
|
484
|
+
return [CGST, SGST, IGST];
|
|
485
|
+
}
|
|
486
|
+
let TCodeIndex: any = TaxCodes.findIndex((TaxCode: any) => {
|
|
487
|
+
return TaxCode._id === Number(TCode);
|
|
488
|
+
});
|
|
489
|
+
if (TCodeIndex !== -1) {
|
|
490
|
+
if (TaxCodes[TCodeIndex].Type === 'Intra') {
|
|
491
|
+
return [TaxCodes[TCodeIndex].CGST, TaxCodes[TCodeIndex].SGST, 0];
|
|
492
|
+
} else {
|
|
493
|
+
return [0, 0, TaxCodes[TCodeIndex].IGST];
|
|
494
|
+
}
|
|
495
|
+
} else {
|
|
496
|
+
return [CGST, SGST, IGST];
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
}
|