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,466 @@
|
|
|
1
|
+
import { Add, Divide, Multiply, Subtract } from "../../shared/math-operations";
|
|
2
|
+
import { TrUtils } from "../../utils/tr-utils";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export class DeliveryChallanTotalsService {
|
|
6
|
+
|
|
7
|
+
static GetTotalsValue(PartsList: any, IsIndependentTax: boolean, DetailedInfo: boolean, Disc: any, Perc: string,
|
|
8
|
+
TaxCodes: any, WithItems: boolean, Settings: any, isRoundable: boolean, EntitySettings: any) {
|
|
9
|
+
|
|
10
|
+
// LPerc = TrUtils.SetPercToStringIfNull(LPerc);
|
|
11
|
+
Perc = TrUtils.SetPercToStringIfNull(Perc);
|
|
12
|
+
// LDisc = TrUtils.SetValueToZeroIfNull(LDisc);
|
|
13
|
+
Disc = TrUtils.SetValueToZeroIfNull(Disc);
|
|
14
|
+
PartsList = this.CalculateLaborPartValues(PartsList, IsIndependentTax);
|
|
15
|
+
let finalTotalsData: any = this.GetFinalChallanDataForSave(PartsList, IsIndependentTax, Disc, Perc, DetailedInfo, Settings, isRoundable, EntitySettings.DecimalsNumber);
|
|
16
|
+
if (DetailedInfo) {
|
|
17
|
+
finalTotalsData = this.GetDetailedTotalsData(finalTotalsData,
|
|
18
|
+
IsIndependentTax, PartsList, TaxCodes, EntitySettings.DecimalsNumber);
|
|
19
|
+
}
|
|
20
|
+
if (WithItems) {
|
|
21
|
+
finalTotalsData.Items = PartsList;
|
|
22
|
+
}
|
|
23
|
+
return finalTotalsData;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static CalculateLaborPartValues(PartsList: any, IsIndependentTax: boolean) {
|
|
27
|
+
PartsList = this.ResetLaborPartValues(PartsList, IsIndependentTax);
|
|
28
|
+
|
|
29
|
+
// PartsList = this.GetLaborPartsDiscountPrice(PartsList);
|
|
30
|
+
|
|
31
|
+
// PartsList = this.GetLaborPartsAfterDiscount(PartsList);
|
|
32
|
+
|
|
33
|
+
// PartsList = this.GetPartsAfterTax(PartsList, IsIndependentTax);
|
|
34
|
+
|
|
35
|
+
return PartsList;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static ResetLaborPartValues(PartsList: any, IsIndependentTax: boolean) {
|
|
39
|
+
PartsList.forEach((Part: any) => {
|
|
40
|
+
Part = this.ResetLaborPartValueIfInvalid(Part);
|
|
41
|
+
Part.DiscountedPrice = Add(Part.Disc, TrUtils.SetValueToZeroIfNull(Part.RecDisc));
|
|
42
|
+
let NetAmt: number = Subtract(Part.UnAmt, Part.Disc, Part.RecDisc);
|
|
43
|
+
Part.AfterPartDisc = NetAmt;
|
|
44
|
+
if (IsIndependentTax) {
|
|
45
|
+
Part.AfterPartTax = Add(Part.AfterPartDisc, Part.CGST, Part.SGST, Part.IGST);
|
|
46
|
+
} else {
|
|
47
|
+
Part.AfterPartTax = Part.AfterPartDisc;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return PartsList;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static ResetLaborPartValueIfInvalid(Part: any) {
|
|
54
|
+
Part.UnPr = TrUtils.SetValueToZeroIfNull(Part.UnPr);
|
|
55
|
+
Part.Disc = TrUtils.SetValueToZeroIfNull(Part.Disc);
|
|
56
|
+
Part.RecDisc = TrUtils.SetValueToZeroIfNull(Part.RecDisc);
|
|
57
|
+
Part.CGST = this.GetTaxAmountFromTaxes(Part, 'CGST');
|
|
58
|
+
Part.SGST = this.GetTaxAmountFromTaxes(Part, 'SGST');
|
|
59
|
+
Part.IGST = this.GetTaxAmountFromTaxes(Part, 'IGST');
|
|
60
|
+
Part.TCode = this.GetTCodeFromTaxes(Part);
|
|
61
|
+
return Part;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static GetFinalChallanDataForSave(PartsList: any, IsIndependentTax: boolean,
|
|
65
|
+
Disc: any, Perc: string,
|
|
66
|
+
DetailedInfo: boolean, Settings: any, isRoundable: boolean, DecimalsNumber: number) {
|
|
67
|
+
let finalTotalsData: any = {};
|
|
68
|
+
finalTotalsData = this.SetMainDiscountValues(Disc, Perc, finalTotalsData, DetailedInfo);
|
|
69
|
+
finalTotalsData.Settings = Settings;
|
|
70
|
+
finalTotalsData = this.GetFinalCustomerTotalsData(finalTotalsData, PartsList,
|
|
71
|
+
IsIndependentTax, DetailedInfo, isRoundable, DecimalsNumber);
|
|
72
|
+
return finalTotalsData;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static SetMainDiscountValues(Disc: any, Perc: string, finalTotalsData: any, DetailedInfo: boolean) {
|
|
76
|
+
|
|
77
|
+
finalTotalsData.Disc = Disc;
|
|
78
|
+
finalTotalsData.Perc = Perc;
|
|
79
|
+
|
|
80
|
+
if (DetailedInfo) {
|
|
81
|
+
finalTotalsData.FixedDisc = Disc;
|
|
82
|
+
}
|
|
83
|
+
return finalTotalsData;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static GetFinalCustomerTotalsData(finalTotalsData: any, PartsList: any, IsIndependentTax: boolean,
|
|
87
|
+
DetailedInfo: boolean, isRoundable: boolean, DecimalsNumber: number) {
|
|
88
|
+
let CustomerAfterDiscTotals: number = this.GetSubTotalFor(PartsList);
|
|
89
|
+
// let CustLaborTaxTotal = this.GetLaborTaxTotalFor(IsIndependentTax);
|
|
90
|
+
let CustPartTaxTotal = this.GetPartsTaxTotalFor(PartsList, IsIndependentTax);
|
|
91
|
+
// console.log('CustPartTaxTotal', CustPartTaxTotal);
|
|
92
|
+
let CustItemsDiscTotal = this.GetPartDiscountedTotal(PartsList);
|
|
93
|
+
|
|
94
|
+
finalTotalsData.SubTotal = Add(CustomerAfterDiscTotals, CustItemsDiscTotal);
|
|
95
|
+
let CustTotal: any = this.GetCustomerTotalBasedOnTaxType(CustPartTaxTotal, PartsList, IsIndependentTax);
|
|
96
|
+
// console.log('CustTotal', CustTotal);
|
|
97
|
+
if (isRoundable) {
|
|
98
|
+
finalTotalsData.Round = TrUtils.FixedTo(Subtract(Math.round(CustTotal), CustTotal), DecimalsNumber);
|
|
99
|
+
finalTotalsData.Total = Math.round(CustTotal);
|
|
100
|
+
} else {
|
|
101
|
+
finalTotalsData.Total = TrUtils.FixedTo(CustTotal, DecimalsNumber);
|
|
102
|
+
}
|
|
103
|
+
if (DetailedInfo) {
|
|
104
|
+
finalTotalsData.FixedSubTotal = TrUtils.FixedTo(CustomerAfterDiscTotals, DecimalsNumber);
|
|
105
|
+
finalTotalsData.FixedTotal = TrUtils.FixedTo(CustTotal, DecimalsNumber);
|
|
106
|
+
}
|
|
107
|
+
return finalTotalsData;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static GetSubTotalFor(PartsList: any) {
|
|
111
|
+
// let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
|
|
112
|
+
let PartsTotalAfterDisc: any = this.GetPartsTotalAfterDiscount(PartsList);
|
|
113
|
+
return PartsTotalAfterDisc;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static GetPartsTotalAfterDiscount(PartsList: any) {
|
|
117
|
+
let PartsTotalAfterDisc: any = 0;
|
|
118
|
+
// console.log('PartsList', PartsList);
|
|
119
|
+
PartsList.forEach((Part: any) => {
|
|
120
|
+
PartsTotalAfterDisc = Add(PartsTotalAfterDisc, Part.AfterPartDisc);
|
|
121
|
+
});
|
|
122
|
+
return PartsTotalAfterDisc;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static GetDetailedTotalsData(finalTotalsData: any, IsIndependentTax: boolean, PartsList: any, TaxCodes: any, DecimalsNumber: number) {
|
|
126
|
+
// finalTotalsData.CustLaborDiscTotal = this.GetLaborDiscountedTotal(opCodesList);
|
|
127
|
+
finalTotalsData.CustPartsDiscTotal = this.GetPartDiscountedTotal(PartsList);
|
|
128
|
+
// finalTotalsData.CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(opCodesList);
|
|
129
|
+
finalTotalsData.CustPartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
|
|
130
|
+
finalTotalsData.CustLaborTotalBeforeDisc = Add(finalTotalsData.CustLaborTotalAfterDisc
|
|
131
|
+
, finalTotalsData.CustLaborDiscTotal);
|
|
132
|
+
finalTotalsData.CustPartsTotalBeforeDisc = Add(finalTotalsData.CustPartsTotalAfterDisc
|
|
133
|
+
, finalTotalsData.CustPartsDiscTotal);
|
|
134
|
+
// finalTotalsData.CustLaborITax = this.GetLaborTaxTotalFor(opCodesList, IsIndependentTax);
|
|
135
|
+
// finalTotalsData.CustLaborSGST = this.GetLaborSGSTTaxTotal(opCodesList, IsIndependentTax);
|
|
136
|
+
// finalTotalsData.CustLaborCGST = this.GetLaborCGSTTaxTotal(opCodesList, IsIndependentTax);
|
|
137
|
+
// finalTotalsData.CustLaborIGST = this.GetLaborIGSTTaxTotal(opCodesList, IsIndependentTax);
|
|
138
|
+
// finalTotalsData.CustPartITax = this.GetPartsTaxTotalFor(PartsList, IsIndependentTax);
|
|
139
|
+
// finalTotalsData.CustPartCGST = this.GetPartCGSTTaxTotal(PartsList, IsIndependentTax);
|
|
140
|
+
// finalTotalsData.CustPartIGST = this.GetPartIGSTTaxTotal(PartsList, IsIndependentTax);
|
|
141
|
+
// finalTotalsData.CustPartSGST = this.GetPartSGSTTaxTotal(PartsList, IsIndependentTax);
|
|
142
|
+
let TaxInfo: any = this.GetPartGSTTaxTotal(PartsList, IsIndependentTax);
|
|
143
|
+
finalTotalsData.CustPartITax = TrUtils.SetValueToZeroIfNull(TaxInfo[3]);
|
|
144
|
+
finalTotalsData.CustPartCGST = TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
|
|
145
|
+
finalTotalsData.CustPartIGST = TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
|
|
146
|
+
finalTotalsData.CustPartSGST = TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
|
|
147
|
+
// finalTotalsData.CustLaborAfterTax = TrUtils.FixedTo(finalTotalsData.CustLaborITax + finalTotalsData.CustLaborTotalAfterDisc);
|
|
148
|
+
finalTotalsData.CustPartAfterTax = Add(finalTotalsData.CustPartITax, finalTotalsData.CustPartsTotalAfterDisc);
|
|
149
|
+
finalTotalsData.CustTaxGroupData = this.GetTaxGroupingForPartsByHSN(PartsList, TaxCodes, DecimalsNumber);
|
|
150
|
+
finalTotalsData.CustTaxGroupDataByPerc = this.GetTaxGroupingForPartsByPerc(PartsList, TaxCodes, DecimalsNumber);
|
|
151
|
+
finalTotalsData.CustTotalRoundedBy = TrUtils.FixedTo(finalTotalsData.Round, DecimalsNumber);
|
|
152
|
+
finalTotalsData.CustRoundedTotal = TrUtils.FixedTo(finalTotalsData.Total, DecimalsNumber);
|
|
153
|
+
for (var key in finalTotalsData) {
|
|
154
|
+
if (key !== 'Total' && key !== 'SubTotal' &&
|
|
155
|
+
key !== 'LDisc' && key !== 'LPerc' && key !== 'PDisc' &&
|
|
156
|
+
key !== 'PPerc' && key !== 'Disc' && key !== 'Perc' && key !== 'Tax'
|
|
157
|
+
&& typeof finalTotalsData[key] === 'number') {
|
|
158
|
+
finalTotalsData[key] = TrUtils.FixPriceValue(finalTotalsData[key], DecimalsNumber);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return finalTotalsData;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
static GetTaxGroupingForPartsByPerc(Parts: any, TaxCodes: any, DecimalsNumber: any) {
|
|
166
|
+
Parts = this.GetCombinedTaxPercentage(TrUtils.Stringify(Parts), TaxCodes);
|
|
167
|
+
// Parts = this.ResetPartsHSNIfInvalid(Parts);
|
|
168
|
+
|
|
169
|
+
let FinalMatchedParts: any[] = this.ComparePartsByPerc(Parts, TaxCodes);
|
|
170
|
+
|
|
171
|
+
return this.GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, DecimalsNumber);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static ComparePartsByPerc(Parts: any, TaxCodes: any) {
|
|
175
|
+
let FinalMatchedParts: any[] = [];
|
|
176
|
+
Parts?.forEach((Part: any) => {
|
|
177
|
+
let MatchedPartsBasedOnHSN = Parts.filter((argPart: any) => {
|
|
178
|
+
let PartFound: boolean = false;
|
|
179
|
+
FinalMatchedParts.forEach((FinalArgParts: any) => {
|
|
180
|
+
let PartIndex: any = FinalArgParts.findIndex((FinalArgPart: any) => {
|
|
181
|
+
return FinalArgPart._id === argPart._id;
|
|
182
|
+
});
|
|
183
|
+
if (PartIndex !== -1) {
|
|
184
|
+
PartFound = true;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argPart.TCode, TaxCodes);
|
|
189
|
+
// let argCGST = argGSTValues[0];
|
|
190
|
+
// let argSGST = argGSTValues[1];
|
|
191
|
+
// let argIGST = argGSTValues[2];
|
|
192
|
+
|
|
193
|
+
// let partGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
194
|
+
// let partCGST = partGSTValues[0];
|
|
195
|
+
// let partSGST = partGSTValues[1];
|
|
196
|
+
// let partIGST = partGSTValues[2];
|
|
197
|
+
|
|
198
|
+
return (!PartFound) &&
|
|
199
|
+
(argPart.CGSTAmt === Part.CGSTAmt) && (argPart.IGSTAmt === Part.IGSTAmt) &&
|
|
200
|
+
(argPart.SGSTAmt === Part.SGSTAmt);
|
|
201
|
+
});
|
|
202
|
+
if (MatchedPartsBasedOnHSN.length !== 0) {
|
|
203
|
+
FinalMatchedParts.push(MatchedPartsBasedOnHSN);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
return FinalMatchedParts;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
static GetLaborDiscountedTotal(LaborList: any) {
|
|
210
|
+
let LaborDiscountedTotal: any = 0;
|
|
211
|
+
LaborList.forEach((Labor: any) => {
|
|
212
|
+
LaborDiscountedTotal = Add(LaborDiscountedTotal, Labor.DiscountedPrice);
|
|
213
|
+
});
|
|
214
|
+
return LaborDiscountedTotal;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
static GetPartDiscountedTotal(PartsList: any) {
|
|
218
|
+
let PartsDiscountedTotal: any = 0;
|
|
219
|
+
PartsList.forEach((Part: any) => {
|
|
220
|
+
PartsDiscountedTotal = Add(PartsDiscountedTotal, Part.DiscountedPrice);
|
|
221
|
+
});
|
|
222
|
+
return PartsDiscountedTotal;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
static GetPartsTaxTotalFor(PartsList: any, IsIndependentTax: boolean) {
|
|
226
|
+
let TotalTaxAmt: any = 0;
|
|
227
|
+
if (IsIndependentTax) {
|
|
228
|
+
PartsList.forEach((Part: any) => {
|
|
229
|
+
TotalTaxAmt = Add(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return TotalTaxAmt;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
static GetCustomerTotalBasedOnTaxType(PartsTaxAmount: number, PartsList: any, IsIndependentTax: boolean) {
|
|
236
|
+
// let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
|
|
237
|
+
let PartsTotalAfterDisc: any = this.GetPartsTotalAfterDiscount(PartsList);
|
|
238
|
+
if (IsIndependentTax) {
|
|
239
|
+
return Add(PartsTotalAfterDisc, PartsTaxAmount);
|
|
240
|
+
} else {
|
|
241
|
+
return PartsTotalAfterDisc;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
static LaborTotalAfterDiscount(LaborTotalAfterDisc: number, LaborTaxAmount: number, MainLDisc: number, LDiscInPerc: string) {
|
|
246
|
+
let LaborTotal: number = Add(LaborTotalAfterDisc, LaborTaxAmount);
|
|
247
|
+
if (!TrUtils.IsZero(MainLDisc)) {
|
|
248
|
+
if (!TrUtils.IsEmpty(LDiscInPerc)) {
|
|
249
|
+
LaborTotal = Subtract(LaborTotal, Divide(Multiply(LaborTotal, Number(LDiscInPerc)), 100));
|
|
250
|
+
} else {
|
|
251
|
+
LaborTotal = Subtract(LaborTotal, MainLDisc);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return LaborTotal;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
static ItemsTotalAfterDiscount(PartsTotalAfterDisc: number, PartsTaxAmount: number, MainPDisc: number, PDiscInPerc: string) {
|
|
258
|
+
let ItemsTotal: number = Add(PartsTotalAfterDisc, PartsTaxAmount);
|
|
259
|
+
if (!TrUtils.IsZero(MainPDisc)) {
|
|
260
|
+
if (!TrUtils.IsEmpty(PDiscInPerc)) {
|
|
261
|
+
ItemsTotal = Subtract(ItemsTotal, Divide(Multiply(ItemsTotal, Number(PDiscInPerc)), 100));
|
|
262
|
+
} else {
|
|
263
|
+
ItemsTotal = Subtract(ItemsTotal, MainPDisc);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return ItemsTotal;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
static GetLaborCGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean) {
|
|
270
|
+
let TotalTaxAmt: any = 0;
|
|
271
|
+
if (IsIndependentTax) {
|
|
272
|
+
opCodesList.forEach((Labor: any) => {
|
|
273
|
+
TotalTaxAmt = Add(TotalTaxAmt, Labor.CGST);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return TotalTaxAmt;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
static GetLaborIGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean) {
|
|
280
|
+
let TotalTaxAmt: any = 0;
|
|
281
|
+
if (IsIndependentTax) {
|
|
282
|
+
opCodesList.forEach((Labor: any) => {
|
|
283
|
+
TotalTaxAmt = Add(TotalTaxAmt, Labor.IGST);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
return TotalTaxAmt;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
static GetLaborSGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean) {
|
|
290
|
+
let TotalTaxAmt: any = 0;
|
|
291
|
+
if (IsIndependentTax) {
|
|
292
|
+
opCodesList.forEach((Labor: any) => {
|
|
293
|
+
TotalTaxAmt = Add(TotalTaxAmt, Labor.SGST);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
return TotalTaxAmt;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
static GetPartGSTTaxTotal(PartsList: any, IsIndependentTax: boolean) {
|
|
300
|
+
let TotalCGSTAmt: number = 0;
|
|
301
|
+
let TotalSGSTAmt: number = 0;
|
|
302
|
+
let TotalIGSTAmt: number = 0;
|
|
303
|
+
let TotalTaxAmt: number = 0;
|
|
304
|
+
if (IsIndependentTax) {
|
|
305
|
+
PartsList.forEach((Part: any) => {
|
|
306
|
+
TotalCGSTAmt = Add(TotalCGSTAmt, Part.CGST);
|
|
307
|
+
TotalSGSTAmt = Add(TotalSGSTAmt, Part.SGST);
|
|
308
|
+
TotalIGSTAmt = Add(TotalIGSTAmt, Part.IGST);
|
|
309
|
+
TotalTaxAmt = Add(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
return [TotalCGSTAmt, TotalSGSTAmt, TotalIGSTAmt, TotalTaxAmt];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
static GetTaxGroupingForPartsByHSN(Parts: any, TaxCodes: any, DecimalsNumber: number) {
|
|
316
|
+
Parts = this.GetCombinedTaxPercentage(Parts, TaxCodes);
|
|
317
|
+
// Parts = this.ResetPartsHSNIfInvalid(Parts);
|
|
318
|
+
|
|
319
|
+
let FinalMatchedParts: any[] = this.ComparePartsByHSN(Parts, TaxCodes);
|
|
320
|
+
|
|
321
|
+
return this.GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, DecimalsNumber);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
static GetCombinedTaxPercentage(Parts: any, TaxCodes: any) {
|
|
325
|
+
Parts.forEach((Part: any) => {
|
|
326
|
+
if (TrUtils.IsNull(Part.HSN)) {
|
|
327
|
+
Part.HSN = '';
|
|
328
|
+
}
|
|
329
|
+
Part.CGSTAmt = this.GetTaxRateFromTaxes(Part, 'CGST');
|
|
330
|
+
Part.SGSTAmt = this.GetTaxRateFromTaxes(Part, 'SGST');
|
|
331
|
+
Part.IGSTAmt = this.GetTaxRateFromTaxes(Part, 'IGST');
|
|
332
|
+
|
|
333
|
+
Part.CombinedTaxPercentage = Add(Part.CGSTAmt, Part.SGSTAmt, Part.IGSTAmt);
|
|
334
|
+
});
|
|
335
|
+
return Parts;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
static ComparePartsByHSN(Parts: any, TaxCodes: any) {
|
|
339
|
+
let FinalMatchedParts: any[] = [];
|
|
340
|
+
Parts.forEach((Part: any) => {
|
|
341
|
+
let MatchedPartsBasedOnHSN = Parts.filter((argPart: any) => {
|
|
342
|
+
let PartFound: boolean = false;
|
|
343
|
+
FinalMatchedParts.forEach((FinalArgParts: any) => {
|
|
344
|
+
let PartIndex: any = FinalArgParts.findIndex((FinalArgPart: any) => {
|
|
345
|
+
return FinalArgPart._id === argPart._id;
|
|
346
|
+
});
|
|
347
|
+
if (PartIndex !== -1) {
|
|
348
|
+
PartFound = true;
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argPart.TCode, TaxCodes);
|
|
353
|
+
// let argCGST = argGSTValues[0];
|
|
354
|
+
// let argSGST = argGSTValues[1];
|
|
355
|
+
// let argIGST = argGSTValues[2];
|
|
356
|
+
|
|
357
|
+
// let partGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
358
|
+
// let partCGST = partGSTValues[0];
|
|
359
|
+
// let partSGST = partGSTValues[1];
|
|
360
|
+
// let partIGST = partGSTValues[2];
|
|
361
|
+
|
|
362
|
+
return (argPart.HSN === Part.HSN) && (!PartFound) &&
|
|
363
|
+
(argPart.CGSTAmt === Part.CGSTAmt) && (argPart.IGSTAmt === Part.IGSTAmt) &&
|
|
364
|
+
(argPart.SGSTAmt === Part.SGSTAmt);
|
|
365
|
+
});
|
|
366
|
+
if (MatchedPartsBasedOnHSN.length !== 0) {
|
|
367
|
+
FinalMatchedParts.push(MatchedPartsBasedOnHSN);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
return FinalMatchedParts;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
static GetTaxGroupingInfoByHSN(FinalMatchedParts: any, TaxCodes: any, DecimalsNumber: any) {
|
|
374
|
+
let HSNTaxInfo: any[] = [];
|
|
375
|
+
FinalMatchedParts.forEach((MatchedPart: any) => {
|
|
376
|
+
let TaxInfo: any = {};
|
|
377
|
+
let TaxOnAmount: any = 0;
|
|
378
|
+
let TaxAmount: any = 0;
|
|
379
|
+
|
|
380
|
+
let CGSTAmt: any = 0;
|
|
381
|
+
let SGSTAmt: any = 0;
|
|
382
|
+
let IGSTAmt: any = 0;
|
|
383
|
+
|
|
384
|
+
let HSN: any = MatchedPart[0].HSN;
|
|
385
|
+
TaxInfo.CombinedTaxPercentage = MatchedPart[0].CombinedTaxPercentage;
|
|
386
|
+
MatchedPart.forEach((argMatchedGSTPart: any) => {
|
|
387
|
+
TaxOnAmount = Add(TaxOnAmount, TrUtils.FixedTo(argMatchedGSTPart.AfterPartDisc, DecimalsNumber));
|
|
388
|
+
TaxAmount = Add(TaxAmount, TrUtils.FixedTo(argMatchedGSTPart.CGST, DecimalsNumber));
|
|
389
|
+
TaxAmount = Add(TaxAmount, TrUtils.FixedTo(argMatchedGSTPart.IGST, DecimalsNumber));
|
|
390
|
+
TaxAmount = Add(TaxAmount, TrUtils.FixedTo(argMatchedGSTPart.SGST, DecimalsNumber));
|
|
391
|
+
CGSTAmt = Add(CGSTAmt, TrUtils.FixedTo(argMatchedGSTPart.CGST, DecimalsNumber));
|
|
392
|
+
SGSTAmt = Add(SGSTAmt, TrUtils.FixedTo(argMatchedGSTPart.SGST, DecimalsNumber));
|
|
393
|
+
IGSTAmt = Add(IGSTAmt, TrUtils.FixedTo(argMatchedGSTPart.IGST, DecimalsNumber));
|
|
394
|
+
});
|
|
395
|
+
TaxInfo.HSN = HSN;
|
|
396
|
+
|
|
397
|
+
TaxInfo.CGSTAmt = CGSTAmt;
|
|
398
|
+
TaxInfo.SGSTAmt = SGSTAmt;
|
|
399
|
+
TaxInfo.IGSTAmt = IGSTAmt;
|
|
400
|
+
|
|
401
|
+
TaxInfo.TotalTaxableAmount = TrUtils.FixPriceValue(TaxOnAmount, DecimalsNumber);
|
|
402
|
+
TaxInfo.TotalTaxAmount = TrUtils.FixPriceValue(TaxAmount, DecimalsNumber);
|
|
403
|
+
TaxInfo.ItemsCount = MatchedPart.length;
|
|
404
|
+
// let GSTValues: any[] = this.GetGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
|
|
405
|
+
// TaxInfo.CGST = GSTValues[0];
|
|
406
|
+
// TaxInfo.SGST = GSTValues[1];
|
|
407
|
+
// TaxInfo.IGST = GSTValues[2];
|
|
408
|
+
TaxInfo.CGST = MatchedPart[0].CGSTAmt;
|
|
409
|
+
TaxInfo.IGST = MatchedPart[0].IGSTAmt;
|
|
410
|
+
TaxInfo.SGST = MatchedPart[0].SGSTAmt;
|
|
411
|
+
if (TaxOnAmount !== 0) {
|
|
412
|
+
HSNTaxInfo.push(TaxInfo);
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
return HSNTaxInfo;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
static GetTaxAmountFromTaxes(item: any, taxCode: string, fallbackAmount: any = 0) {
|
|
419
|
+
const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
|
|
420
|
+
const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
|
|
421
|
+
if (matchedTaxes.length !== 0) {
|
|
422
|
+
return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Amt), 0);
|
|
423
|
+
}
|
|
424
|
+
return TrUtils.SetValueToZeroIfNull(fallbackAmount);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
static GetTaxRateFromTaxes(item: any, taxCode: string, fallbackRate: any = 0) {
|
|
428
|
+
const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
|
|
429
|
+
const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
|
|
430
|
+
if (matchedTaxes.length !== 0) {
|
|
431
|
+
return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Rate), 0);
|
|
432
|
+
}
|
|
433
|
+
return TrUtils.SetValueToZeroIfNull(fallbackRate);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
static GetTCodeFromTaxes(item: any) {
|
|
437
|
+
const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
|
|
438
|
+
const matchedTax = taxes.find((tax: any) => !TrUtils.IsNull(tax?.TaxCodeId));
|
|
439
|
+
if (!TrUtils.IsNull(matchedTax?.TaxCodeId)) {
|
|
440
|
+
return matchedTax.TaxCodeId;
|
|
441
|
+
}
|
|
442
|
+
return item?.TCode;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
static GetGSTValueBasedOnTaxCode(TCode: any, TaxCodes: any) {
|
|
446
|
+
let CGST: number = 0;
|
|
447
|
+
let SGST: number = 0;
|
|
448
|
+
let IGST: number = 0;
|
|
449
|
+
if (TrUtils.IsNull(TCode)) {
|
|
450
|
+
return [CGST, SGST, IGST];
|
|
451
|
+
}
|
|
452
|
+
let TCodeIndex: any = TaxCodes.findIndex((TaxCode: any) => {
|
|
453
|
+
return TaxCode._id === Number(TCode);
|
|
454
|
+
});
|
|
455
|
+
if (TCodeIndex !== -1) {
|
|
456
|
+
if (TaxCodes[TCodeIndex].Type === 'Intra') {
|
|
457
|
+
return [TaxCodes[TCodeIndex].CGST, TaxCodes[TCodeIndex].SGST, 0];
|
|
458
|
+
} else {
|
|
459
|
+
return [0, 0, TaxCodes[TCodeIndex].IGST];
|
|
460
|
+
}
|
|
461
|
+
} else {
|
|
462
|
+
return [CGST, SGST, IGST];
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
|
|
2
|
+
import { SharedPDFService } from '../../shared/shared-pdf.service';
|
|
3
|
+
import { PrintSharedService } from '../../shared/shared-print.service';
|
|
4
|
+
import { TrUtils } from '../../utils/tr-utils';
|
|
5
|
+
|
|
6
|
+
export class EquipmentDesignPdf {
|
|
7
|
+
|
|
8
|
+
static GetEquipmentPdf(Entity: any, Image: any, Sites: any, Items: any) {
|
|
9
|
+
|
|
10
|
+
var dd = {
|
|
11
|
+
info: {
|
|
12
|
+
title: 'Equipment Design',
|
|
13
|
+
},
|
|
14
|
+
background: function (currentPage: any, pageSize: any) {
|
|
15
|
+
return SharedPDFService.GetWatermarkImage(Image, pageSize, Entity.Wmark);
|
|
16
|
+
},
|
|
17
|
+
header: function (currentPage: any, pageCount: any) {
|
|
18
|
+
return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 7, fontSize: 8, marginTop: 2 };
|
|
19
|
+
},
|
|
20
|
+
pageMargins: [10, 15, 10, 15],
|
|
21
|
+
content: this.GetContentData(Entity, Sites, Items, Image),
|
|
22
|
+
// styles: SharedPDFService.GetStyles()
|
|
23
|
+
};
|
|
24
|
+
return dd;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static GetContentData(Entity: any, Sites: any, Items: any, Image: any) {
|
|
28
|
+
let EntityData: any = PrintSharedService.GetFormattedEntityDataForPrint(TrUtils.Stringify(Entity), '', null);
|
|
29
|
+
Entity = PrintSharedService.GetEntityHeaderStyles(Entity, Entity, Image);
|
|
30
|
+
EntityData.HColor = Entity.HColor;
|
|
31
|
+
return [
|
|
32
|
+
// SharedPDFService.MainHeading(EntityData.CName, EntityData.Header, Image, EntityData.HColor, null),
|
|
33
|
+
{ text: EntityData.CName, fontSize: 26, bold: true, color: EntityData.HColor, alignment: 'center' },
|
|
34
|
+
{ text: 'EQUIPMENT DESIGN', bold: true, alignment: 'center', marginBottom: 20, marginTop: 20, decoration: 'underline' },
|
|
35
|
+
{
|
|
36
|
+
style: 'tableExample',
|
|
37
|
+
color: '#444',
|
|
38
|
+
table: {
|
|
39
|
+
widths: ['auto', '*', '*', '*', '*'],
|
|
40
|
+
headerRows: 1,
|
|
41
|
+
body: this.getsites(Sites, Items)
|
|
42
|
+
},
|
|
43
|
+
layout: PrintSharedService.LayOutStyle()
|
|
44
|
+
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static getsites(Sites: any, Items: any) {
|
|
51
|
+
let mainsites = [];
|
|
52
|
+
mainsites = Sites.filter((site:any) => {
|
|
53
|
+
return TrUtils.IsNull(site.Parent);
|
|
54
|
+
});
|
|
55
|
+
mainsites.forEach((site:any, pindex:any) => {
|
|
56
|
+
site.Index = pindex + 1;
|
|
57
|
+
site.children = this.GetChildren(Sites, site.Id, site.Index);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
var body = [[{ text: 'SNO', bold: true }, { text: 'Location', bold: true }, { text: 'Quantity', bold: true }, { text: 'Tonnage(TR)', bold: true }, { text: 'Model', bold: true }]]
|
|
61
|
+
var SNO = 0
|
|
62
|
+
mainsites.forEach((item:any) => {
|
|
63
|
+
var lo:any = []
|
|
64
|
+
// lo.push({ text: item.Name, colSpan: item.children.length });
|
|
65
|
+
// lo.push({});
|
|
66
|
+
let Itemdata: any = this.GetItem(item.ItemId, Items);
|
|
67
|
+
if (TrUtils.IsNull(Itemdata.TR)) {
|
|
68
|
+
Itemdata.TR = '';
|
|
69
|
+
}
|
|
70
|
+
if (TrUtils.IsNull(Itemdata.Model)) {
|
|
71
|
+
Itemdata.Model = '';
|
|
72
|
+
}
|
|
73
|
+
if (TrUtils.IsNull(item.Qty)) {
|
|
74
|
+
item.Qty = '';
|
|
75
|
+
}
|
|
76
|
+
if (TrUtils.IsNull(item.children) || item.children.length === 0) {
|
|
77
|
+
lo.push({ text: item.Index });
|
|
78
|
+
lo.push({ text: item.Name });
|
|
79
|
+
lo.push({ text: item.Qty });
|
|
80
|
+
lo.push({ text: Itemdata.TR });
|
|
81
|
+
lo.push({ text: Itemdata.Model });
|
|
82
|
+
} else {
|
|
83
|
+
lo.push({ text: item.Index });
|
|
84
|
+
lo.push({ text: item.Name, colSpan: 4 });
|
|
85
|
+
lo.push({});
|
|
86
|
+
lo.push({});
|
|
87
|
+
lo.push({});
|
|
88
|
+
}
|
|
89
|
+
body.push(lo);
|
|
90
|
+
body = this.tablechilderan(Sites, item.Id, body, Items)
|
|
91
|
+
});
|
|
92
|
+
return body;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static GetChildren(Sites: any, siteid: any, pindex: any) {
|
|
96
|
+
let children = Sites.filter((site: any) => {
|
|
97
|
+
return site.Parent === siteid;
|
|
98
|
+
});
|
|
99
|
+
children.forEach((child:any, cindex:any) => {
|
|
100
|
+
child.Index = pindex + '.' + (cindex + 1);
|
|
101
|
+
child.children = this.GetChildren(Sites, child.Id, child.Index);
|
|
102
|
+
});
|
|
103
|
+
return children;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static tablechilderan(Sites: any, siteid: any, body: any, Items: any) {
|
|
107
|
+
let children = Sites.filter((site: any) => {
|
|
108
|
+
return site.Parent === siteid;
|
|
109
|
+
});
|
|
110
|
+
children.forEach((child: any, cindex: any) => {
|
|
111
|
+
var sm = [];
|
|
112
|
+
|
|
113
|
+
// sm.push({ text: child.Name, colSpan: child.children.length })
|
|
114
|
+
// sm.push({ text: 'High wall' });
|
|
115
|
+
let Itemdata: any = this.GetItem(child.ItemId, Items);
|
|
116
|
+
if (TrUtils.IsNull(Itemdata.TR)) {
|
|
117
|
+
Itemdata.TR = '';
|
|
118
|
+
}
|
|
119
|
+
if (TrUtils.IsNull(Itemdata.Model)) {
|
|
120
|
+
Itemdata.Model = '';
|
|
121
|
+
}
|
|
122
|
+
if (TrUtils.IsNull(child.Qty)) {
|
|
123
|
+
child.Qty = '';
|
|
124
|
+
}
|
|
125
|
+
if (child.children.length === 0) {
|
|
126
|
+
sm.push({ text: child.Index });
|
|
127
|
+
sm.push({ text: child.Name });
|
|
128
|
+
sm.push({ text: child.Qty });
|
|
129
|
+
sm.push({ text: Itemdata.TR });
|
|
130
|
+
sm.push({ text: Itemdata.Model });
|
|
131
|
+
} else {
|
|
132
|
+
// sm.splice(1, 0, { text: child.Name, colSpan: 4 });
|
|
133
|
+
sm.push({ text: child.Index });
|
|
134
|
+
sm.push({ text: child.Name, colSpan: 4 });
|
|
135
|
+
sm.push({});
|
|
136
|
+
sm.push({});
|
|
137
|
+
sm.push({});
|
|
138
|
+
}
|
|
139
|
+
body.push(sm);
|
|
140
|
+
this.tablechilderan(Sites, child.Id, body, Items);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
return body
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static GetItem(ItemId: any, Items: any) {
|
|
147
|
+
let Index: any = Items.findIndex((item: any) => {
|
|
148
|
+
return item._id === ItemId;
|
|
149
|
+
});
|
|
150
|
+
return (Index !== -1) ? Items[Index] : {};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
}
|