shareneus 1.0.5
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/dist/aggregation/aggregation.js +60 -0
- package/dist/enums/cache-enums.js +37 -0
- package/dist/enums/code-enums.js +288 -0
- package/dist/enums/enums.js +362 -0
- package/dist/enums/industry-enums.js +24 -0
- package/dist/excel-files/GSTR-RO-excel.service.js +935 -0
- package/dist/excel-files/GSTR1-excel.service.js +295 -0
- package/dist/excel-files/GSTR2-excel.service.js +295 -0
- package/dist/excel-files/analysis-excel.service.js +297 -0
- package/dist/excel-files/category-wise-item-excel.service.js +274 -0
- package/dist/excel-files/cust-balance-excel.service.js +287 -0
- package/dist/excel-files/cust-wise-sales-details.js +320 -0
- package/dist/excel-files/cust-wise-sales-summary-excel.service.js +302 -0
- package/dist/excel-files/expiring-drugs-excel.service.js +292 -0
- package/dist/excel-files/insurance-expire-excel.service.js +301 -0
- package/dist/excel-files/invoice-wise-excel.service.js +857 -0
- package/dist/excel-files/item-wise-doctor-sale-excel.service.js +258 -0
- package/dist/excel-files/item-wise-mout-details.js +292 -0
- package/dist/excel-files/item-wise-mout-summary.js +286 -0
- package/dist/excel-files/items-wise-sales-excel.service.js +314 -0
- package/dist/excel-files/manf-wise-sales-excel.service.js +276 -0
- package/dist/excel-files/operator-wise-details.js +265 -0
- package/dist/excel-files/operator-wise-summary.js +266 -0
- package/dist/excel-files/payment-receive-excel.service.js +225 -0
- package/dist/excel-files/payments-made-excel.service.js +302 -0
- package/dist/excel-files/repair-orders-excel.service.js +255 -0
- package/dist/excel-files/sa-wise-labor-sales-excel.service.js +232 -0
- package/dist/excel-files/sa-wise-part-sales-excel.service.js +232 -0
- package/dist/excel-files/sale-summary-excel.service.js +326 -0
- package/dist/excel-files/sales-by-service-details-excel.service.js +1 -0
- package/dist/excel-files/sales-by-service-summary-excel.service.js +422 -0
- package/dist/excel-files/scheduled-drug-summary-excel.service.js +367 -0
- package/dist/excel-files/scheduled-drugs-excel.service.js +366 -0
- package/dist/excel-files/spares-issue-excel.service.js +492 -0
- package/dist/excel-files/stock-excel.service.js +283 -0
- package/dist/excel-files/tally-sales-import.service.js +765 -0
- package/dist/excel-files/ven-balance-excel.service.js +293 -0
- package/dist/index.js +237 -0
- package/dist/services/analysis-pdf.service.js +105 -0
- package/dist/services/appointment-total.service.js +253 -0
- package/dist/services/auto-sales-receipt-pdf.service.js +539 -0
- package/dist/services/category-wise-item-pdf.service.js +98 -0
- package/dist/services/checklist-pdf.js +140 -0
- package/dist/services/checklists-pdf.js +124 -0
- package/dist/services/cn-print.service.js +211 -0
- package/dist/services/consultation-fee-receipt.service.js +378 -0
- package/dist/services/consultation-full-pdf.service.js +220 -0
- package/dist/services/consultation-pdf.service.js +360 -0
- package/dist/services/credit-note-pdf.service.js +578 -0
- package/dist/services/credit-note-totals.service.js +328 -0
- package/dist/services/cust-wise-sales-details-pdf.service.js +118 -0
- package/dist/services/cust-wise-sales-summary-pdf.service.js +111 -0
- package/dist/services/customer-balances-pdf.service.js +169 -0
- package/dist/services/dc-landscape-pdf.service.js +903 -0
- package/dist/services/dc-landscape-without-price-pdf.service.js +853 -0
- package/dist/services/dc-without-price-pdf.service.js +489 -0
- package/dist/services/debit-note-pdf.service.js +673 -0
- package/dist/services/debit-note-print.service.js +234 -0
- package/dist/services/debit-note-totals.service.js +293 -0
- package/dist/services/delivery-challan-pdf.service.js +434 -0
- package/dist/services/delivery-challan-print.service.js +177 -0
- package/dist/services/delivery-challan-totals.js +339 -0
- package/dist/services/equipment-design-pdf.service.js +144 -0
- package/dist/services/est.print-service.js +1053 -0
- package/dist/services/expiring-drugs-pdf.service.js +156 -0
- package/dist/services/hc-inv-pdf.service.js +837 -0
- package/dist/services/insurance-expire-pdf.service.js +99 -0
- package/dist/services/inv-pdf.service.js +785 -0
- package/dist/services/inv-print.service.js +415 -0
- package/dist/services/invoice-landscape-pdf.service.js +909 -0
- package/dist/services/invoice-total.service.js +659 -0
- package/dist/services/issue-parts-pdf.service.js +763 -0
- package/dist/services/item-detais-pdf.js +136 -0
- package/dist/services/item-wise-doctor-sale-pdf.service.js +164 -0
- package/dist/services/item-wise-mout-details-pdf.js +107 -0
- package/dist/services/item-wise-mout-summary-pdf.js +99 -0
- package/dist/services/item-wise-sales-pdf.service.js +178 -0
- package/dist/services/manf-wise-sales-pdf.service.js +173 -0
- package/dist/services/meeting-pdf.js +369 -0
- package/dist/services/mout-pdf.service.js +503 -0
- package/dist/services/operator-wise-details-pdf.service.js +103 -0
- package/dist/services/operator-wise-summary-pdf.js +101 -0
- package/dist/services/pack-ship-pdf.service.js +105 -0
- package/dist/services/pack-ship-print.service.js +167 -0
- package/dist/services/payment-pdf.service.js +373 -0
- package/dist/services/payment-report-pdf.service.js +106 -0
- package/dist/services/po-totals.service.js +279 -0
- package/dist/services/pos-receipt-pdf.js +438 -0
- package/dist/services/purchase-order-pdf.service.js +924 -0
- package/dist/services/purchase-order-print.service.js +150 -0
- package/dist/services/purchase-order-totals.service.js +280 -0
- package/dist/services/receipt-print.service.js +50 -0
- package/dist/services/reorder-point-pdf.service.js +151 -0
- package/dist/services/repair-orders-pdf.service.js +172 -0
- package/dist/services/ro-pdf.service.js +1764 -0
- package/dist/services/ro-print-service.js +737 -0
- package/dist/services/ro-totals.service.js +1241 -0
- package/dist/services/sales-by-service-pdf.service.js +116 -0
- package/dist/services/sales-pdf.service.js +630 -0
- package/dist/services/sales-print.service.js +305 -0
- package/dist/services/sales-receipt-pdf.service.js +611 -0
- package/dist/services/sales-receipt-print.service.js +425 -0
- package/dist/services/sales-totals.service.js +339 -0
- package/dist/services/scheduled-drug-pdf.service.js +176 -0
- package/dist/services/scheduled-drug-summary-pdf.service.js +188 -0
- package/dist/services/separate-wo-print.service.js +351 -0
- package/dist/services/shared-inv-pdf.service.js +763 -0
- package/dist/services/shared-pdf.service.js +2569 -0
- package/dist/services/shared-print.service.js +885 -0
- package/dist/services/task-pdf.service.js +220 -0
- package/dist/services/task-reports-pdf.service.js +296 -0
- package/dist/services/technician-pdf.service.js +238 -0
- package/dist/services/technician-print.service.js +87 -0
- package/dist/services/transfer-order-pdf.service.js +139 -0
- package/dist/services/vendor-balances-pdf.service.js +101 -0
- package/dist/services/vendor-credit-note-pdf.service.js +1007 -0
- package/dist/services/vendor-credit-note-print.service.js +104 -0
- package/dist/services/vendor-credit-note-totals.service.js +327 -0
- package/dist/services/vendor-debit-note-pdf.service.js +561 -0
- package/dist/services/vendor-debit-note-print.service.js +245 -0
- package/dist/services/vendor-debit-note-totals.service.js +305 -0
- package/dist/utils/my-date.js +652 -0
- package/dist/utils/tr-utils.js +354 -0
- package/package.json +24 -0
- package/tsconfig.json +109 -0
|
@@ -0,0 +1,1053 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EstPrintService = void 0;
|
|
4
|
+
const aggregation_1 = require("../aggregation/aggregation");
|
|
5
|
+
const code_enums_1 = require("../enums/code-enums");
|
|
6
|
+
const enums_1 = require("../enums/enums");
|
|
7
|
+
const my_date_1 = require("../utils/my-date");
|
|
8
|
+
const tr_utils_1 = require("../utils/tr-utils");
|
|
9
|
+
const ro_totals_service_1 = require("./ro-totals.service");
|
|
10
|
+
const shared_print_service_1 = require("./shared-print.service");
|
|
11
|
+
class EstPrintService {
|
|
12
|
+
static GetEstimatePrintInfo(OriginalROData, OriginalCustomerData, OriginalVehicleData, OriginalEntityData, image, Payee, InsCompanyName, AsCustomerOnly, AsInsuranceOnly, AsCustomerAndInsurance, AsInsuranceOrCustomer, TaxCodes, OverallEst, SuppEstIndex, AsEstimated, isInitial, isReverse, Consolidate) {
|
|
13
|
+
let ROPrintData = {};
|
|
14
|
+
let argROData = tr_utils_1.TrUtils.Stringify(OriginalROData);
|
|
15
|
+
argROData.Comps = tr_utils_1.TrUtils.IsNull(argROData.Comps) ? [] : argROData.Comps;
|
|
16
|
+
argROData.Ops = tr_utils_1.TrUtils.IsNull(argROData.Ops) ? [] : argROData.Ops;
|
|
17
|
+
argROData.Parts = tr_utils_1.TrUtils.IsNull(argROData.Parts) ? [] : argROData.Parts;
|
|
18
|
+
argROData.Colli = tr_utils_1.TrUtils.IsNull(argROData.Colli) ? [] : argROData.Colli;
|
|
19
|
+
let IncludeGST = tr_utils_1.TrUtils.isTaxable(argROData.Settings.Tax);
|
|
20
|
+
ROPrintData = this.GetROBasicDetailsForPrint(ROPrintData, argROData, OriginalVehicleData, OverallEst, isInitial);
|
|
21
|
+
let SType;
|
|
22
|
+
if (!tr_utils_1.TrUtils.IsNull(OriginalROData.Settings) && !tr_utils_1.TrUtils.IsNull(OriginalROData.Settings.PoS)) {
|
|
23
|
+
SType = OriginalROData.Settings.PoS.SType;
|
|
24
|
+
}
|
|
25
|
+
ROPrintData = this.GetPrintConditionsBasedOnInput(ROPrintData, IncludeGST, Payee, AsCustomerOnly, AsInsuranceOnly, AsCustomerAndInsurance, AsInsuranceOrCustomer, SType, Consolidate);
|
|
26
|
+
ROPrintData.Entity = shared_print_service_1.PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Estimate", OriginalROData);
|
|
27
|
+
ROPrintData = shared_print_service_1.PrintSharedService.GetEntityHeaderStyles(ROPrintData, OriginalEntityData, image);
|
|
28
|
+
if (Payee === enums_1.PayTypeEnum.Insurance) {
|
|
29
|
+
ROPrintData = this.GetInsDetailsForPrint(ROPrintData, InsCompanyName, argROData, AsEstimated);
|
|
30
|
+
}
|
|
31
|
+
argROData = this.IfInitialEstimateChangeStatus(argROData, AsEstimated);
|
|
32
|
+
argROData = this.CheckStatusAndChangeDeclinedItemsToNew(argROData);
|
|
33
|
+
argROData = this.GetValidItemsForTotals(argROData);
|
|
34
|
+
if (!OverallEst) {
|
|
35
|
+
argROData = this.GetItemsBySuppEstIndex(argROData, SuppEstIndex);
|
|
36
|
+
if (!tr_utils_1.TrUtils.IsNull(SuppEstIndex)) {
|
|
37
|
+
let Index = argROData.SuppEst.findIndex((supp) => {
|
|
38
|
+
return supp.Id === SuppEstIndex;
|
|
39
|
+
});
|
|
40
|
+
if (Index !== -1 && !tr_utils_1.TrUtils.IsNull(argROData.SuppEst[Index].Date)) {
|
|
41
|
+
ROPrintData.CrDate = my_date_1.MyDate.ConvertUTCDateToReadable(argROData.SuppEst[Index].Date);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
argROData.Ops = this.SeparateROLaborByPType(argROData.Ops, Payee, AsCustomerOnly, AsInsuranceOnly, AsEstimated);
|
|
46
|
+
argROData.Parts = this.SeparateROPartsByPType(argROData.Parts, Payee, AsCustomerOnly, AsInsuranceOnly, AsEstimated);
|
|
47
|
+
argROData.Colli = this.SeparateROCollisionsByItems(argROData.Colli, argROData.Ops, argROData.Parts);
|
|
48
|
+
// argROData = this.ResetDescForPrint(argROData);
|
|
49
|
+
argROData.Parts = this.ResetQtyAndUoM(argROData.Parts);
|
|
50
|
+
if (AsInsuranceOnly || AsCustomerAndInsurance || AsInsuranceOrCustomer) {
|
|
51
|
+
ROPrintData.ShowAccParts = true;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
ROPrintData.ShowAccParts = this.CheckAndShowItemsAsAR(argROData);
|
|
55
|
+
}
|
|
56
|
+
argROData = this.ReverseItemsForROPrint(argROData, isReverse);
|
|
57
|
+
let finalTotalsData = ro_totals_service_1.ROTotalsService.GetTotalsValue(argROData, TaxCodes, false, true, true, ROPrintData.Entity.Round);
|
|
58
|
+
finalTotalsData = this.CheckAndGetCombinedTotals(AsCustomerAndInsurance, AsInsuranceOrCustomer, finalTotalsData);
|
|
59
|
+
finalTotalsData.Settings = tr_utils_1.TrUtils.Stringify(argROData.Settings);
|
|
60
|
+
if (AsCustomerOnly) {
|
|
61
|
+
if (ROPrintData.ShowAccParts) {
|
|
62
|
+
finalTotalsData = this.GetLaborAndPartItemsAfterDisc(finalTotalsData);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
finalTotalsData = this.GetDetailedInfoForItems(finalTotalsData);
|
|
66
|
+
finalTotalsData = this.GetCustTaxInfo(finalTotalsData, IncludeGST, TaxCodes);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (AsCustomerAndInsurance) {
|
|
70
|
+
finalTotalsData = this.GetCombinedInfoForItems(finalTotalsData);
|
|
71
|
+
}
|
|
72
|
+
if (AsInsuranceOrCustomer) {
|
|
73
|
+
finalTotalsData.Parts = this.GetSplitInfoForParts(finalTotalsData.Parts);
|
|
74
|
+
}
|
|
75
|
+
if (IncludeGST) {
|
|
76
|
+
finalTotalsData.ShowDetailedLaborTaxInfo = this.CheckLaborTaxItemIndex(finalTotalsData.Ops) !== -1;
|
|
77
|
+
finalTotalsData.ShowDetailedPartTaxInfo = this.CheckPartTaxItemIndex(finalTotalsData.Parts) !== -1;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
finalTotalsData.ShowDetailedLaborTaxInfo = false;
|
|
81
|
+
finalTotalsData.ShowDetailedPartTaxInfo = false;
|
|
82
|
+
}
|
|
83
|
+
ROPrintData = tr_utils_1.TrUtils.ConcatObjects(ROPrintData, finalTotalsData);
|
|
84
|
+
if (ROPrintData.ShowAccParts) {
|
|
85
|
+
ROPrintData = this.ConvertItemsAsAR(ROPrintData, Consolidate);
|
|
86
|
+
}
|
|
87
|
+
ROPrintData.Colli = this.EmptyInvalidCollisionRepairItems(ROPrintData.Colli);
|
|
88
|
+
ROPrintData = this.GetLineTotals(ROPrintData, IncludeGST, AsCustomerOnly, AsInsuranceOnly, Consolidate);
|
|
89
|
+
ROPrintData.PrintInfo = this.PrepareFormatForEstPrint(ROPrintData, SuppEstIndex, OverallEst, code_enums_1.ROTypeEnum.Estimate, AsEstimated);
|
|
90
|
+
ROPrintData = this.CheckAndCombineDescMPNForAR(ROPrintData.Entity.MPN, ROPrintData);
|
|
91
|
+
ROPrintData.Vehicle = shared_print_service_1.PrintSharedService.GetVehicleFromServiceAndFormatData(OriginalVehicleData);
|
|
92
|
+
ROPrintData.Customer = shared_print_service_1.PrintSharedService.GetCustomerFromServiceAndFormatData(OriginalCustomerData);
|
|
93
|
+
if ((Payee === enums_1.PayTypeEnum.Customer || AsCustomerOnly) && !ROPrintData.ConsolidateGST) {
|
|
94
|
+
// if (PrintSharedService.CheckItemIndexWithDisc(ROPrintData) !== -1) {
|
|
95
|
+
ROPrintData.ShowDiscountColumn = (ROPrintData.Settings.DiscLvl === 'ITM' || ROPrintData.Settings.DiscLvl === 'RECITM') ? true : false;
|
|
96
|
+
// }
|
|
97
|
+
}
|
|
98
|
+
return ROPrintData;
|
|
99
|
+
}
|
|
100
|
+
static GetROBasicDetailsForPrint(ROPrintData, argROData, Product, OverallEst, isInitial) {
|
|
101
|
+
ROPrintData.CrDate = my_date_1.MyDate.ConvertUTCDateToReadable(argROData.CrDate);
|
|
102
|
+
if (!isInitial) {
|
|
103
|
+
ROPrintData.PrDate = my_date_1.MyDate.ConvertUTCDateToReadable(argROData.PrDate);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
delete ROPrintData.PrDate;
|
|
107
|
+
}
|
|
108
|
+
ROPrintData.MIn = Product.MIn;
|
|
109
|
+
ROPrintData._id = argROData.Code;
|
|
110
|
+
if (isInitial || tr_utils_1.TrUtils.IsNull(argROData.SuppEst) || argROData.SuppEst.length === 0 || OverallEst) {
|
|
111
|
+
ROPrintData.Type = 'Estimate';
|
|
112
|
+
ROPrintData.HeaderName = 'Estimate';
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
ROPrintData.Type = 'Supplementary Estimate';
|
|
116
|
+
ROPrintData.HeaderName = 'Supplementary Estimate';
|
|
117
|
+
}
|
|
118
|
+
ROPrintData.SuppEst = argROData.SuppEst;
|
|
119
|
+
return ROPrintData;
|
|
120
|
+
}
|
|
121
|
+
static GetPrintConditionsBasedOnInput(ROPrintData, IncludeGST, Payee, AsCustomerOnly, AsInsuranceOnly, AsCustomerAndInsurance, AsInsuranceOrCustomer, SType, Consolidate) {
|
|
122
|
+
ROPrintData.Payee = Payee;
|
|
123
|
+
ROPrintData.AsCustomerOnly = AsCustomerOnly;
|
|
124
|
+
ROPrintData.AsInsuranceOnly = AsInsuranceOnly;
|
|
125
|
+
ROPrintData.AsCustomerAndInsurance = AsCustomerAndInsurance;
|
|
126
|
+
ROPrintData.AsInsuranceOrCustomer = AsInsuranceOrCustomer;
|
|
127
|
+
ROPrintData.IncludeGST = IncludeGST;
|
|
128
|
+
ROPrintData.ConsolidateGST = Consolidate;
|
|
129
|
+
ROPrintData.Consolidate = Consolidate;
|
|
130
|
+
ROPrintData.ShowIGST = (tr_utils_1.TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
|
|
131
|
+
ROPrintData.ShowTaxColumn = (IncludeGST && !Consolidate) ? true : false;
|
|
132
|
+
// ROPrintData.ShowDiscountColumn = (Payee === PayTypeEnum.Customer || AsCustomerOnly) ? true : false;
|
|
133
|
+
return ROPrintData;
|
|
134
|
+
}
|
|
135
|
+
static GetInsDetailsForPrint(ROPrintData, InsCompanyName, argROData, AsEstimated) {
|
|
136
|
+
if (tr_utils_1.TrUtils.IsNull(argROData.Ins)) {
|
|
137
|
+
argROData.Ins = this.GetDefualtInsData();
|
|
138
|
+
}
|
|
139
|
+
ROPrintData.InsComp = InsCompanyName;
|
|
140
|
+
if (!AsEstimated) {
|
|
141
|
+
ROPrintData.SurName = argROData.Ins.SName;
|
|
142
|
+
ROPrintData.SurEmail = argROData.Ins.SEmail;
|
|
143
|
+
ROPrintData.SurPhone = argROData.Ins.SPhone;
|
|
144
|
+
}
|
|
145
|
+
ROPrintData.PolType = argROData.Ins.Type;
|
|
146
|
+
ROPrintData.PolNo = argROData.Ins.PolNo;
|
|
147
|
+
return ROPrintData;
|
|
148
|
+
}
|
|
149
|
+
static GetDefualtInsData() {
|
|
150
|
+
let ROInsData = {
|
|
151
|
+
SName: '',
|
|
152
|
+
SEmail: '',
|
|
153
|
+
SPhone: '',
|
|
154
|
+
PolNo: ''
|
|
155
|
+
};
|
|
156
|
+
return ROInsData;
|
|
157
|
+
}
|
|
158
|
+
static IfInitialEstimateChangeStatus(argROData, AsEstimated) {
|
|
159
|
+
if (AsEstimated) {
|
|
160
|
+
argROData.Sts = enums_1.ROStatusEnum.New;
|
|
161
|
+
argROData.Ops = this.ChangeLaborStatusToNew(argROData.Ops);
|
|
162
|
+
argROData.Parts = this.ChangePartStatusToNew(argROData.Parts);
|
|
163
|
+
argROData.Colli = this.ChangeColliStatusToNew(argROData.Colli);
|
|
164
|
+
}
|
|
165
|
+
return argROData;
|
|
166
|
+
}
|
|
167
|
+
static ChangeLaborStatusToNew(Operations) {
|
|
168
|
+
Operations.forEach((Labor) => {
|
|
169
|
+
Labor.Sts = enums_1.LaborStatusEnum.New;
|
|
170
|
+
});
|
|
171
|
+
return Operations;
|
|
172
|
+
}
|
|
173
|
+
static ChangePartStatusToNew(Parts) {
|
|
174
|
+
Parts.forEach((Part) => {
|
|
175
|
+
if (!tr_utils_1.TrUtils.IsNull(Part.CollId)) {
|
|
176
|
+
Part.Sts = enums_1.LaborStatusEnum.New;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return Parts;
|
|
180
|
+
}
|
|
181
|
+
static ChangeColliStatusToNew(Collisions) {
|
|
182
|
+
Collisions.forEach((Collision) => {
|
|
183
|
+
Collision.Sts = enums_1.LaborStatusEnum.New;
|
|
184
|
+
});
|
|
185
|
+
return Collisions;
|
|
186
|
+
}
|
|
187
|
+
static CheckStatusAndChangeDeclinedItemsToNew(argROData) {
|
|
188
|
+
if (argROData.Sts === enums_1.ROStatusEnum.New || argROData.Sts === enums_1.ROStatusEnum.WtngForAppr) {
|
|
189
|
+
argROData = this.ChangeDeclinedStatusToNew(argROData);
|
|
190
|
+
}
|
|
191
|
+
return argROData;
|
|
192
|
+
}
|
|
193
|
+
static ChangeDeclinedStatusToNew(argROData) {
|
|
194
|
+
argROData.Ops = this.ChangeDeclinedLaborStatusToNew(argROData.Ops);
|
|
195
|
+
argROData.Parts = this.ChangeDeclinedPartStatusToNew(argROData.Parts);
|
|
196
|
+
argROData.Colli = this.ChangeDeclinedColliStatusToNew(argROData.Colli);
|
|
197
|
+
return argROData;
|
|
198
|
+
}
|
|
199
|
+
static ChangeDeclinedLaborStatusToNew(Operations) {
|
|
200
|
+
Operations.forEach((Labor) => {
|
|
201
|
+
if (Labor.Sts === enums_1.LaborStatusEnum.Declined) {
|
|
202
|
+
Labor.Sts = enums_1.LaborStatusEnum.New;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
return Operations;
|
|
206
|
+
}
|
|
207
|
+
static ChangeDeclinedPartStatusToNew(Parts) {
|
|
208
|
+
Parts.forEach((Part) => {
|
|
209
|
+
if (!tr_utils_1.TrUtils.IsNull(Part.CollId) && Part.Sts === enums_1.LaborStatusEnum.Declined) {
|
|
210
|
+
Part.Sts = enums_1.LaborStatusEnum.New;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return Parts;
|
|
214
|
+
}
|
|
215
|
+
static ChangeDeclinedColliStatusToNew(Collisions) {
|
|
216
|
+
Collisions.forEach((Collision) => {
|
|
217
|
+
if (Collision.Sts === enums_1.LaborStatusEnum.Declined) {
|
|
218
|
+
Collision.Sts = enums_1.LaborStatusEnum.New;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
return Collisions;
|
|
222
|
+
}
|
|
223
|
+
static GetValidItemsForTotals(RecordData) {
|
|
224
|
+
let RecordStatus = RecordData.Sts;
|
|
225
|
+
RecordData.Ops = this.GetLaborByRecordAndLaborStatus(RecordStatus, RecordData.Ops);
|
|
226
|
+
RecordData.Parts = this.GetPartsByRecordAndPartStatus(RecordStatus, RecordData.Parts);
|
|
227
|
+
RecordData.Colli = this.GetCollisionByRecordAndColliStatus(RecordStatus, RecordData.Colli);
|
|
228
|
+
return RecordData;
|
|
229
|
+
}
|
|
230
|
+
static GetLaborByRecordAndLaborStatus(RecordStatus, Operations) {
|
|
231
|
+
if (RecordStatus === enums_1.ROStatusEnum.Cancelled || RecordStatus === enums_1.ROStatusEnum.Declined) {
|
|
232
|
+
return Operations;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
return this.GetValidROLaborListByStatus(Operations);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
static GetValidROLaborListByStatus(Operations) {
|
|
239
|
+
let opCodesList = Operations.filter((Operation) => {
|
|
240
|
+
if (this.CheckOperationHasActiveStatus(Operation.Sts)) {
|
|
241
|
+
return Operation;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
return opCodesList;
|
|
245
|
+
}
|
|
246
|
+
static CheckOperationHasActiveStatus(Status) {
|
|
247
|
+
return (Status !== enums_1.LaborStatusEnum.Cancelled && Status !== enums_1.LaborStatusEnum.Declined) ? true : false;
|
|
248
|
+
}
|
|
249
|
+
static GetPartsByRecordAndPartStatus(RecordStatus, Parts) {
|
|
250
|
+
if (RecordStatus === enums_1.ROStatusEnum.Cancelled || RecordStatus === enums_1.ROStatusEnum.Declined) {
|
|
251
|
+
return Parts;
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
return this.GetValidROPartsListByStatus(Parts);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
static GetValidROPartsListByStatus(Parts) {
|
|
258
|
+
let PartsList = Parts.filter((Part) => {
|
|
259
|
+
if (tr_utils_1.TrUtils.IsNull(Part.CollId)) {
|
|
260
|
+
return Part;
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
if (this.CheckOperationHasActiveStatus(Part.Sts)) {
|
|
264
|
+
return Part;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
return PartsList;
|
|
269
|
+
}
|
|
270
|
+
static GetCollisionByRecordAndColliStatus(RecordStatus, Collisions) {
|
|
271
|
+
if (RecordStatus === enums_1.ROStatusEnum.Cancelled || RecordStatus === enums_1.ROStatusEnum.Declined) {
|
|
272
|
+
return Collisions;
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
return this.GetValidROCollisionListByStatus(Collisions);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
static GetValidROCollisionListByStatus(Collisions) {
|
|
279
|
+
let collList = Collisions.filter((Collision) => {
|
|
280
|
+
if (this.CheckOperationHasActiveStatus(Collision.Sts)) {
|
|
281
|
+
return Collision;
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
return collList;
|
|
285
|
+
}
|
|
286
|
+
static GetItemsBySuppEstIndex(argROData, SuppEstIndex) {
|
|
287
|
+
if (tr_utils_1.TrUtils.IsNull(SuppEstIndex)) {
|
|
288
|
+
SuppEstIndex = null;
|
|
289
|
+
}
|
|
290
|
+
argROData.Ops = argROData.Ops.filter((Labor) => {
|
|
291
|
+
if (tr_utils_1.TrUtils.IsNull(Labor.SuppEst)) {
|
|
292
|
+
Labor.SuppEst = null;
|
|
293
|
+
}
|
|
294
|
+
return Labor.SuppEst === SuppEstIndex;
|
|
295
|
+
});
|
|
296
|
+
argROData.Parts = argROData.Parts.filter((Part) => {
|
|
297
|
+
if (tr_utils_1.TrUtils.IsNull(Part.SuppEst)) {
|
|
298
|
+
Part.SuppEst = null;
|
|
299
|
+
}
|
|
300
|
+
return Part.SuppEst === SuppEstIndex;
|
|
301
|
+
});
|
|
302
|
+
argROData.Colli = argROData.Colli.filter((Collision) => {
|
|
303
|
+
if (tr_utils_1.TrUtils.IsNull(Collision.SuppEst)) {
|
|
304
|
+
Collision.SuppEst = null;
|
|
305
|
+
}
|
|
306
|
+
return Collision.SuppEst === SuppEstIndex;
|
|
307
|
+
});
|
|
308
|
+
return argROData;
|
|
309
|
+
}
|
|
310
|
+
static SeparateROLaborByPType(Labors, PType, CustomerOnly, InsuranceOnly, AsEstimated) {
|
|
311
|
+
let LaborList = [];
|
|
312
|
+
LaborList = Labors.filter((Labor) => {
|
|
313
|
+
if (AsEstimated) {
|
|
314
|
+
if (PType === enums_1.PayTypeEnum.Customer) {
|
|
315
|
+
return Labor.PBy === enums_1.PayTypeEnum.Customer;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
return (Labor.PBy === enums_1.PayTypeEnum.Insurance || Labor.PBy === enums_1.PayTypeEnum.Shared);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
if (PType === enums_1.PayTypeEnum.Customer) {
|
|
323
|
+
return Labor.PBy === PType;
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
if (CustomerOnly) {
|
|
327
|
+
return (Labor.PBy === enums_1.PayTypeEnum.Shared) && !tr_utils_1.TrUtils.IsZero(Labor.Pr);
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
if (InsuranceOnly) {
|
|
331
|
+
return (Labor.PBy === enums_1.PayTypeEnum.Insurance || Labor.PBy === enums_1.PayTypeEnum.Shared) && !tr_utils_1.TrUtils.IsZero(Labor.AssPr);
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
return (Labor.PBy === enums_1.PayTypeEnum.Insurance || Labor.PBy === enums_1.PayTypeEnum.Shared);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
return LaborList;
|
|
341
|
+
}
|
|
342
|
+
static SeparateROPartsByPType(Parts, PType, CustomerOnly, InsuranceOnly, AsEstimated) {
|
|
343
|
+
let PartsList = [];
|
|
344
|
+
PartsList = Parts.filter((Part) => {
|
|
345
|
+
if (AsEstimated) {
|
|
346
|
+
if (PType === enums_1.PayTypeEnum.Customer) {
|
|
347
|
+
return Part.PBy === PType;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
return (Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
if (PType === enums_1.PayTypeEnum.Customer) {
|
|
355
|
+
return Part.PBy === PType;
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
if (CustomerOnly) {
|
|
359
|
+
return (Part.PBy === enums_1.PayTypeEnum.Shared) && !tr_utils_1.TrUtils.IsZero(Part.UnPr);
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
if (InsuranceOnly) {
|
|
363
|
+
return (Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared) && !tr_utils_1.TrUtils.IsZero(Part.AssPr);
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
return (Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
return PartsList;
|
|
373
|
+
}
|
|
374
|
+
static SeparateROCollisionsByItems(Collisions, Ops, Parts) {
|
|
375
|
+
let CollisionList = Collisions.filter((Collision) => {
|
|
376
|
+
let LaborIndex = Ops.findIndex((Labor) => {
|
|
377
|
+
return Labor.CollId === Collision._id;
|
|
378
|
+
});
|
|
379
|
+
let PartIndex = Parts.findIndex((Part) => {
|
|
380
|
+
return Part.CollId === Collision._id;
|
|
381
|
+
});
|
|
382
|
+
if (LaborIndex !== -1 || PartIndex !== -1) {
|
|
383
|
+
return Collision;
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
return CollisionList;
|
|
387
|
+
}
|
|
388
|
+
static ResetQtyAndUoM(Parts) {
|
|
389
|
+
Parts.forEach((Item) => {
|
|
390
|
+
if (!tr_utils_1.TrUtils.IsZero(Item.Qty) && !tr_utils_1.TrUtils.CheckInvalidSelect(Item.UoM)) {
|
|
391
|
+
Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
return Parts;
|
|
395
|
+
}
|
|
396
|
+
static CheckAndShowItemsAsAR(argROData) {
|
|
397
|
+
let AccPartsIndex = argROData.Parts.findIndex((Part) => {
|
|
398
|
+
return !tr_utils_1.TrUtils.IsNull((Part.CollId));
|
|
399
|
+
});
|
|
400
|
+
let InsLaborIndex = argROData.Ops.findIndex((Labor) => {
|
|
401
|
+
return !tr_utils_1.TrUtils.IsNull((Labor.CollId));
|
|
402
|
+
});
|
|
403
|
+
if (AccPartsIndex !== -1 || InsLaborIndex !== -1) {
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
static ConvertItemsAsAR(ROPrintData, Consolidate) {
|
|
411
|
+
ROPrintData.Colli.forEach((Collision) => {
|
|
412
|
+
Collision = this.ResetItemsDataById(Collision, ROPrintData.Ops, ROPrintData.Parts);
|
|
413
|
+
});
|
|
414
|
+
ROPrintData.Ops.forEach((Labor) => {
|
|
415
|
+
// console.log('Labor', Labor);
|
|
416
|
+
Labor.NetAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.NetAmt);
|
|
417
|
+
Labor.CCGST = tr_utils_1.TrUtils.FixPriceValue(Labor.CCGST);
|
|
418
|
+
Labor.CSGST = tr_utils_1.TrUtils.FixPriceValue(Labor.CSGST);
|
|
419
|
+
Labor.CIGST = tr_utils_1.TrUtils.FixPriceValue(Labor.CIGST);
|
|
420
|
+
Labor.Disc = tr_utils_1.TrUtils.FixPriceValue(Labor.Disc);
|
|
421
|
+
Labor.AssPr = tr_utils_1.TrUtils.FixPriceValue(Labor.AssPr);
|
|
422
|
+
Labor.ACGST = tr_utils_1.TrUtils.FixPriceValue(Labor.ACGST);
|
|
423
|
+
Labor.ASGST = tr_utils_1.TrUtils.FixPriceValue(Labor.ASGST);
|
|
424
|
+
Labor.AIGST = tr_utils_1.TrUtils.FixPriceValue(Labor.AIGST);
|
|
425
|
+
if (Consolidate) {
|
|
426
|
+
if (Labor.PBy === enums_1.PayTypeEnum.Customer) {
|
|
427
|
+
Labor.EstPr = tr_utils_1.TrUtils.FixPriceValue(Labor.CustAfterTax);
|
|
428
|
+
Labor.Pr = tr_utils_1.TrUtils.FixPriceValue(Labor.CustAfterTax);
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
Labor.EstPr = tr_utils_1.TrUtils.FixPriceValue(Labor.InsAfterTax);
|
|
432
|
+
Labor.Pr = tr_utils_1.TrUtils.FixPriceValue(Labor.InsAfterTax);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
Labor.EstPr = tr_utils_1.TrUtils.FixPriceValue(Labor.EstPr);
|
|
437
|
+
Labor.Pr = tr_utils_1.TrUtils.FixPriceValue(Labor.Pr);
|
|
438
|
+
}
|
|
439
|
+
Labor.ECGST = tr_utils_1.TrUtils.FixPriceValue(Labor.ECGST);
|
|
440
|
+
Labor.ESGST = tr_utils_1.TrUtils.FixPriceValue(Labor.ESGST);
|
|
441
|
+
Labor.EIGST = tr_utils_1.TrUtils.FixPriceValue(Labor.EIGST);
|
|
442
|
+
if (tr_utils_1.TrUtils.IsNull(Labor.CollId)) {
|
|
443
|
+
let LaborColli = {
|
|
444
|
+
_id: Labor._id,
|
|
445
|
+
Desc: Labor.Desc,
|
|
446
|
+
PBy: Labor.PBy,
|
|
447
|
+
Op_Id: Labor.Op_Id,
|
|
448
|
+
Qty: 0,
|
|
449
|
+
Sts: Labor.Sts
|
|
450
|
+
};
|
|
451
|
+
LaborColli.RRFData = Labor;
|
|
452
|
+
LaborColli.SuppEst = Labor.SuppEst;
|
|
453
|
+
ROPrintData.Colli.push(LaborColli);
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
ROPrintData.Parts.forEach((Part) => {
|
|
457
|
+
// console.log('Part', Part);
|
|
458
|
+
Part.NetAmt = tr_utils_1.TrUtils.FixPriceValue(Part.NetAmt);
|
|
459
|
+
Part.UnAmt = tr_utils_1.TrUtils.FixPriceValue(Part.UnAmt);
|
|
460
|
+
Part.CCGST = tr_utils_1.TrUtils.FixPriceValue(Part.CCGST);
|
|
461
|
+
Part.CSGST = tr_utils_1.TrUtils.FixPriceValue(Part.CSGST);
|
|
462
|
+
Part.CIGST = tr_utils_1.TrUtils.FixPriceValue(Part.CIGST);
|
|
463
|
+
Part.Disc = tr_utils_1.TrUtils.FixPriceValue(Part.Disc);
|
|
464
|
+
Part.AssPr = tr_utils_1.TrUtils.FixPriceValue(Part.AssPr);
|
|
465
|
+
Part.AssAmt = tr_utils_1.TrUtils.FixPriceValue(Part.AssAmt);
|
|
466
|
+
Part.ACGST = tr_utils_1.TrUtils.FixPriceValue(Part.ACGST);
|
|
467
|
+
Part.ASGST = tr_utils_1.TrUtils.FixPriceValue(Part.ASGST);
|
|
468
|
+
Part.AIGST = tr_utils_1.TrUtils.FixPriceValue(Part.AIGST);
|
|
469
|
+
Part.EstPr = tr_utils_1.TrUtils.FixPriceValue(Part.EstPr);
|
|
470
|
+
if (Consolidate) {
|
|
471
|
+
if (Part.PBy === enums_1.PayTypeEnum.Customer) {
|
|
472
|
+
Part.EstPr = tr_utils_1.TrUtils.FixPriceValue(Part.CustAfterTax / Part.Qty);
|
|
473
|
+
Part.UnPr = tr_utils_1.TrUtils.FixPriceValue(Part.CustAfterTax / Part.Qty);
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
Part.EstPr = tr_utils_1.TrUtils.FixPriceValue(Part.InsAfterTax / Part.Qty);
|
|
477
|
+
Part.UnPr = tr_utils_1.TrUtils.FixPriceValue(Part.InsAfterTax / Part.Qty);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
Part.EstPr = tr_utils_1.TrUtils.FixPriceValue(Part.EstPr);
|
|
482
|
+
Part.UnPr = tr_utils_1.TrUtils.FixPriceValue(Part.UnPr);
|
|
483
|
+
}
|
|
484
|
+
Part.EstAmt = tr_utils_1.TrUtils.FixPriceValue(Part.EstAmt);
|
|
485
|
+
Part.ECGST = tr_utils_1.TrUtils.FixPriceValue(Part.ECGST);
|
|
486
|
+
Part.ESGST = tr_utils_1.TrUtils.FixPriceValue(Part.ESGST);
|
|
487
|
+
Part.EIGST = tr_utils_1.TrUtils.FixPriceValue(Part.EIGST);
|
|
488
|
+
if (tr_utils_1.TrUtils.IsNull(Part.CollId)) {
|
|
489
|
+
let LaborIndex = ROPrintData.Ops.findIndex((Labor) => {
|
|
490
|
+
return Labor._id === Part.OpId;
|
|
491
|
+
});
|
|
492
|
+
let OpsStatus = ROPrintData.Ops[LaborIndex].Sts;
|
|
493
|
+
let PartColli = {
|
|
494
|
+
_id: Part._id,
|
|
495
|
+
Desc: Part.Desc,
|
|
496
|
+
PBy: Part.PBy,
|
|
497
|
+
Sts: OpsStatus
|
|
498
|
+
};
|
|
499
|
+
PartColli.PartData = Part;
|
|
500
|
+
PartColli.SuppEst = Part.SuppEst;
|
|
501
|
+
ROPrintData.Colli.push(PartColli);
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
ROPrintData.Ops = [];
|
|
505
|
+
ROPrintData.Parts = [];
|
|
506
|
+
return ROPrintData;
|
|
507
|
+
}
|
|
508
|
+
static ResetItemsDataById(Collision, AddedOperations, AddedParts) {
|
|
509
|
+
Collision.PartData = tr_utils_1.TrUtils.IsNull(Collision.PartId)
|
|
510
|
+
? null : this.GetPartDataById(Collision.PartId, AddedParts);
|
|
511
|
+
Collision.RRFData = tr_utils_1.TrUtils.IsNull(Collision.RRFId)
|
|
512
|
+
? null : this.GetLaborDataById(Collision.RRFId, AddedOperations);
|
|
513
|
+
Collision.PtngData = tr_utils_1.TrUtils.IsNull(Collision.PainId)
|
|
514
|
+
? null : this.GetLaborDataById(Collision.PainId, AddedOperations);
|
|
515
|
+
Collision.DtngData = tr_utils_1.TrUtils.IsNull(Collision.RepId)
|
|
516
|
+
? null : this.GetLaborDataById(Collision.RepId, AddedOperations);
|
|
517
|
+
return Collision;
|
|
518
|
+
}
|
|
519
|
+
static GetPartDataById(PartId, AddedParts) {
|
|
520
|
+
let partIndex = AddedParts.findIndex((Part) => {
|
|
521
|
+
return Part._id === PartId;
|
|
522
|
+
});
|
|
523
|
+
return (partIndex !== -1) ? AddedParts[partIndex] : null;
|
|
524
|
+
}
|
|
525
|
+
static GetLaborDataById(LaborId, AddedOperations) {
|
|
526
|
+
let laborIndex = AddedOperations.findIndex((Labor) => {
|
|
527
|
+
return Labor._id === LaborId;
|
|
528
|
+
});
|
|
529
|
+
return (laborIndex !== -1) ? AddedOperations[laborIndex] : null;
|
|
530
|
+
}
|
|
531
|
+
static EmptyInvalidCollisionRepairItems(Colli) {
|
|
532
|
+
Colli.forEach((CollisionItem) => {
|
|
533
|
+
if (!tr_utils_1.TrUtils.IsNull(CollisionItem.PartData) && !this.CheckOperationHasActiveStatus(CollisionItem.PartData.Sts)) {
|
|
534
|
+
CollisionItem.PartData.EstPr = null;
|
|
535
|
+
CollisionItem.PartData.AssPr = null;
|
|
536
|
+
CollisionItem.PartData.UnPr = null;
|
|
537
|
+
CollisionItem.PartData.Disc = 0;
|
|
538
|
+
CollisionItem.PartData.RecDisc = 0;
|
|
539
|
+
}
|
|
540
|
+
if (!tr_utils_1.TrUtils.IsNull(CollisionItem.RRFData) && !this.CheckOperationHasActiveStatus(CollisionItem.RRFData.Sts)) {
|
|
541
|
+
CollisionItem.RRFData.EstPr = null;
|
|
542
|
+
CollisionItem.RRFData.AssPr = null;
|
|
543
|
+
CollisionItem.RRFData.Pr = null;
|
|
544
|
+
CollisionItem.RRFData.Disc = 0;
|
|
545
|
+
CollisionItem.RRFData.RecDisc = 0;
|
|
546
|
+
}
|
|
547
|
+
if (!tr_utils_1.TrUtils.IsNull(CollisionItem.DtngData) && !this.CheckOperationHasActiveStatus(CollisionItem.DtngData.Sts)) {
|
|
548
|
+
CollisionItem.DtngData.EstPr = null;
|
|
549
|
+
CollisionItem.DtngData.AssPr = null;
|
|
550
|
+
CollisionItem.DtngData.Pr = null;
|
|
551
|
+
CollisionItem.DtngData.Disc = 0;
|
|
552
|
+
CollisionItem.DtngData.RecDisc = 0;
|
|
553
|
+
}
|
|
554
|
+
if (!tr_utils_1.TrUtils.IsNull(CollisionItem.PtngData) && !this.CheckOperationHasActiveStatus(CollisionItem.PtngData.Sts)) {
|
|
555
|
+
CollisionItem.PtngData.EstPr = null;
|
|
556
|
+
CollisionItem.PtngData.AssPr = null;
|
|
557
|
+
CollisionItem.PtngData.Pr = null;
|
|
558
|
+
CollisionItem.PtngData.Disc = 0;
|
|
559
|
+
CollisionItem.PtngData.RecDisc = 0;
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
return Colli;
|
|
563
|
+
}
|
|
564
|
+
static GetLineTotals(ROPrintData, IncludeGST, AsCustomerOnly, AsInsuranceOnly, Consolidate) {
|
|
565
|
+
ROPrintData.Ops.forEach((Labor) => {
|
|
566
|
+
Labor.LineTotal = this.GetLaborLineTotal(Labor, IncludeGST, AsCustomerOnly, AsInsuranceOnly, Consolidate);
|
|
567
|
+
});
|
|
568
|
+
ROPrintData.Parts.forEach((Part) => {
|
|
569
|
+
Part.LineTotal = this.GetPartLineTotal(Part, IncludeGST, AsCustomerOnly, AsInsuranceOnly, Consolidate);
|
|
570
|
+
});
|
|
571
|
+
ROPrintData.Colli.forEach((Collision) => {
|
|
572
|
+
let LineTotal = 0;
|
|
573
|
+
if (!tr_utils_1.TrUtils.IsNull(Collision.PartData)) {
|
|
574
|
+
LineTotal += this.GetCollisionPartLineTotal(Collision.PartData, AsCustomerOnly, AsInsuranceOnly, Consolidate);
|
|
575
|
+
}
|
|
576
|
+
if (!tr_utils_1.TrUtils.IsNull(Collision.RRFData)) {
|
|
577
|
+
LineTotal += this.GetCollisionLaborLineTotal(Collision.RRFData, AsCustomerOnly, AsInsuranceOnly, Consolidate);
|
|
578
|
+
}
|
|
579
|
+
if (!tr_utils_1.TrUtils.IsNull(Collision.PtngData)) {
|
|
580
|
+
LineTotal += this.GetCollisionLaborLineTotal(Collision.PtngData, AsCustomerOnly, AsInsuranceOnly, Consolidate);
|
|
581
|
+
}
|
|
582
|
+
if (!tr_utils_1.TrUtils.IsNull(Collision.DtngData)) {
|
|
583
|
+
LineTotal += this.GetCollisionLaborLineTotal(Collision.DtngData, AsCustomerOnly, AsInsuranceOnly, Consolidate);
|
|
584
|
+
}
|
|
585
|
+
Collision.LineTotal = tr_utils_1.TrUtils.FixPriceValue(LineTotal);
|
|
586
|
+
});
|
|
587
|
+
return ROPrintData;
|
|
588
|
+
}
|
|
589
|
+
static GetCollisionPartLineTotal(PartData, AsCustomerOnly, AsInsuranceOnly, Consolidate) {
|
|
590
|
+
let LineTotal = 0;
|
|
591
|
+
if (AsCustomerOnly) {
|
|
592
|
+
if (Consolidate) {
|
|
593
|
+
LineTotal = PartData.CustAfterTax;
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
LineTotal = PartData.CustAfterPartDisc;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
else if (AsInsuranceOnly) {
|
|
600
|
+
if (Consolidate) {
|
|
601
|
+
LineTotal = PartData.InsAfterTax;
|
|
602
|
+
}
|
|
603
|
+
else {
|
|
604
|
+
LineTotal = PartData.InsAfterPartDisc;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
if (Consolidate) {
|
|
609
|
+
LineTotal = PartData.InsAfterTax + PartData.CustAfterTax;
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
LineTotal = PartData.InsAfterPartDisc + PartData.CustAfterPartDisc;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return LineTotal;
|
|
616
|
+
}
|
|
617
|
+
static GetCollisionLaborLineTotal(LaborData, AsCustomerOnly, AsInsuranceOnly, Consolidate) {
|
|
618
|
+
let LineTotal = 0;
|
|
619
|
+
if (AsCustomerOnly) {
|
|
620
|
+
if (Consolidate) {
|
|
621
|
+
LineTotal = LaborData.CustAfterTax;
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
LineTotal = LaborData.CustAfterLaborDisc;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
else if (AsInsuranceOnly) {
|
|
628
|
+
if (Consolidate) {
|
|
629
|
+
LineTotal = LaborData.InsAfterTax;
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
LineTotal = LaborData.InsAfterLaborDisc;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
if (Consolidate) {
|
|
637
|
+
LineTotal = LaborData.InsAfterTax + LaborData.CustAfterTax;
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
LineTotal = LaborData.InsAfterLaborDisc + LaborData.CustAfterLaborDisc;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return LineTotal;
|
|
644
|
+
}
|
|
645
|
+
static GetLaborLineTotal(LaborData, IncludeGST, AsCustomerOnly, AsInsuranceOnly, Consolidate) {
|
|
646
|
+
let LineTotal = 0;
|
|
647
|
+
if (AsCustomerOnly) {
|
|
648
|
+
if (IncludeGST || Consolidate) {
|
|
649
|
+
LineTotal = LaborData.CustAfterTax;
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
LineTotal = LaborData.CustAfterLaborDisc;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
else if (AsInsuranceOnly) {
|
|
656
|
+
if (IncludeGST || Consolidate) {
|
|
657
|
+
LineTotal = LaborData.InsAfterTax;
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
LineTotal = LaborData.InsAfterLaborDisc;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
else {
|
|
664
|
+
if (IncludeGST || Consolidate) {
|
|
665
|
+
LineTotal = LaborData.CustAfterTax + LaborData.InsAfterTax;
|
|
666
|
+
}
|
|
667
|
+
else {
|
|
668
|
+
LineTotal = LaborData.InsAfterLaborDisc + LaborData.CustAfterLaborDisc;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return tr_utils_1.TrUtils.FixedTo(LineTotal);
|
|
672
|
+
}
|
|
673
|
+
static GetPartLineTotal(PartData, IncludeGST, AsCustomerOnly, AsInsuranceOnly, Consolidate) {
|
|
674
|
+
let LineTotal = 0;
|
|
675
|
+
if (AsCustomerOnly) {
|
|
676
|
+
if (IncludeGST || Consolidate) {
|
|
677
|
+
LineTotal = PartData.CustAfterTax;
|
|
678
|
+
}
|
|
679
|
+
else {
|
|
680
|
+
LineTotal = PartData.CustAfterPartDisc;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
else if (AsInsuranceOnly) {
|
|
684
|
+
if (IncludeGST || Consolidate) {
|
|
685
|
+
LineTotal = PartData.InsAfterTax;
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
LineTotal = PartData.InsAfterPartDisc;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
if (IncludeGST || Consolidate) {
|
|
693
|
+
LineTotal = PartData.InsAfterTax + PartData.CustAfterTax;
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
LineTotal = PartData.InsAfterPartDisc + PartData.CustAfterPartDisc;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
return tr_utils_1.TrUtils.FixedTo(LineTotal);
|
|
700
|
+
}
|
|
701
|
+
static ReverseItemsForROPrint(argROData, isReverse) {
|
|
702
|
+
if (isReverse) {
|
|
703
|
+
argROData.Comps = tr_utils_1.TrUtils.IsNull(argROData.Comps) ? [] : argROData.Comps.reverse();
|
|
704
|
+
argROData.Ops = tr_utils_1.TrUtils.IsNull(argROData.Ops) ? [] : argROData.Ops.reverse();
|
|
705
|
+
argROData.Parts = tr_utils_1.TrUtils.IsNull(argROData.Parts) ? [] : argROData.Parts.reverse();
|
|
706
|
+
argROData.Colli = tr_utils_1.TrUtils.IsNull(argROData.Colli) ? [] : argROData.Colli.reverse();
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
argROData.Comps = tr_utils_1.TrUtils.IsNull(argROData.Comps) ? [] : argROData.Comps;
|
|
710
|
+
argROData.Ops = tr_utils_1.TrUtils.IsNull(argROData.Ops) ? [] : argROData.Ops;
|
|
711
|
+
argROData.Parts = tr_utils_1.TrUtils.IsNull(argROData.Parts) ? [] : argROData.Parts;
|
|
712
|
+
argROData.Colli = tr_utils_1.TrUtils.IsNull(argROData.Colli) ? [] : argROData.Colli;
|
|
713
|
+
}
|
|
714
|
+
let ReversedLabors = [];
|
|
715
|
+
argROData.Comps.forEach((Complaint) => {
|
|
716
|
+
argROData.Ops.forEach((Labor) => {
|
|
717
|
+
if (Labor.CompId === Complaint._id) {
|
|
718
|
+
ReversedLabors.push(Labor);
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
});
|
|
722
|
+
argROData.Ops.forEach((Labor) => {
|
|
723
|
+
if (tr_utils_1.TrUtils.IsNull(Labor.CompId)) {
|
|
724
|
+
ReversedLabors.push(Labor);
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
argROData.Ops = ReversedLabors;
|
|
728
|
+
let ReversedParts = [];
|
|
729
|
+
argROData.Ops.forEach((Labor) => {
|
|
730
|
+
argROData.Parts.forEach((Part) => {
|
|
731
|
+
if (tr_utils_1.TrUtils.IsNull(Part.CollId) && (Part.OpId === Labor._id)) {
|
|
732
|
+
ReversedParts.push(Part);
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
argROData.Parts.forEach((Part) => {
|
|
737
|
+
if (!tr_utils_1.TrUtils.IsNull(Part.CollId)) {
|
|
738
|
+
ReversedParts.push(Part);
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
argROData.Parts = ReversedParts;
|
|
742
|
+
return argROData;
|
|
743
|
+
}
|
|
744
|
+
static CheckAndGetCombinedTotals(AsCustomerAndInsurance, AsInsuranceOrCustomer, finalTotalsData) {
|
|
745
|
+
if (AsCustomerAndInsurance || AsInsuranceOrCustomer) {
|
|
746
|
+
finalTotalsData.InsLaborTotalBeforeDisc = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.CustLaborTotalBeforeDisc) +
|
|
747
|
+
Number(finalTotalsData.InsLaborTotalBeforeDisc));
|
|
748
|
+
finalTotalsData.InsLaborDiscTotal = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.CustLaborDiscTotal) +
|
|
749
|
+
Number(finalTotalsData.InsLaborDiscTotal));
|
|
750
|
+
finalTotalsData.InsLaborCGST = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.CustLaborCGST) +
|
|
751
|
+
Number(finalTotalsData.InsLaborCGST));
|
|
752
|
+
finalTotalsData.InsLaborSGST = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.CustLaborSGST) +
|
|
753
|
+
Number(finalTotalsData.InsLaborSGST));
|
|
754
|
+
finalTotalsData.InsLaborIGST = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.CustLaborIGST) +
|
|
755
|
+
Number(finalTotalsData.InsLaborIGST));
|
|
756
|
+
finalTotalsData.InsPartIGST = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.CustPartIGST) +
|
|
757
|
+
Number(finalTotalsData.InsPartIGST));
|
|
758
|
+
finalTotalsData.InsPartsTotalBeforeDisc = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.CustPartsTotalBeforeDisc) +
|
|
759
|
+
Number(finalTotalsData.InsPartsTotalBeforeDisc));
|
|
760
|
+
finalTotalsData.InsPartsDiscTotal = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.CustPartsDiscTotal) +
|
|
761
|
+
Number(finalTotalsData.InsPartsDiscTotal));
|
|
762
|
+
finalTotalsData.InsPartCGST = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.CustPartCGST) +
|
|
763
|
+
Number(finalTotalsData.InsPartCGST));
|
|
764
|
+
finalTotalsData.InsPartSGST = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.CustPartSGST) +
|
|
765
|
+
Number(finalTotalsData.InsPartSGST));
|
|
766
|
+
finalTotalsData.InsLaborTotalAfterTax = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.CustLaborAfterTax) +
|
|
767
|
+
Number(finalTotalsData.InsLaborTotalAfterTax));
|
|
768
|
+
finalTotalsData.InsPartsTotalAfterTax = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.CustPartAfterTax) +
|
|
769
|
+
Number(finalTotalsData.InsPartsTotalAfterTax));
|
|
770
|
+
finalTotalsData.FixedInsTotal = tr_utils_1.TrUtils.FixPriceValue(Number(finalTotalsData.FixedTotal) +
|
|
771
|
+
Number(finalTotalsData.FixedInsTotal));
|
|
772
|
+
finalTotalsData.InsTotalRoundedBy = tr_utils_1.TrUtils.FixPriceValue(Math.round(Number(finalTotalsData.FixedInsTotal)) - Number(finalTotalsData.FixedInsTotal));
|
|
773
|
+
finalTotalsData.InsRoundedTotal = tr_utils_1.TrUtils.FixPriceValue(Math.round(Number(finalTotalsData.FixedInsTotal)));
|
|
774
|
+
let InsTaxGroupData = [];
|
|
775
|
+
finalTotalsData.InsTaxGroupData.forEach((InsTaxGroup) => {
|
|
776
|
+
let index = finalTotalsData.CustTaxGroupData.findIndex((CustTaxGroup) => {
|
|
777
|
+
return CustTaxGroup.HSN === InsTaxGroup.HSN;
|
|
778
|
+
});
|
|
779
|
+
if (index !== -1) {
|
|
780
|
+
InsTaxGroup.TotalTaxAmount = tr_utils_1.TrUtils.FixPriceValue(Number(InsTaxGroup.TotalTaxAmount) + Number(finalTotalsData.CustTaxGroupData[index].TotalTaxAmount));
|
|
781
|
+
InsTaxGroup.TotalTaxableAmount = tr_utils_1.TrUtils.FixPriceValue(Number(InsTaxGroup.TotalTaxableAmount) + Number(finalTotalsData.CustTaxGroupData[index].TotalTaxableAmount));
|
|
782
|
+
}
|
|
783
|
+
InsTaxGroupData.push(InsTaxGroup);
|
|
784
|
+
});
|
|
785
|
+
finalTotalsData.InsTaxGroupData = InsTaxGroupData;
|
|
786
|
+
}
|
|
787
|
+
return finalTotalsData;
|
|
788
|
+
}
|
|
789
|
+
static GetDetailedInfoForItems(ROTotalsData) {
|
|
790
|
+
ROTotalsData.Ops = this.GetCustLaborPrintInfo(ROTotalsData.Ops);
|
|
791
|
+
ROTotalsData.Parts = this.GetCustItemsPrintInfo(ROTotalsData.Parts, ROTotalsData.Ops);
|
|
792
|
+
return ROTotalsData;
|
|
793
|
+
}
|
|
794
|
+
static GetCustLaborPrintInfo(LaborList) {
|
|
795
|
+
LaborList.forEach((Labor) => {
|
|
796
|
+
Labor.HSN = Labor.SAC;
|
|
797
|
+
if (Labor.Sts === enums_1.LaborStatusEnum.New || Labor.Sts === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
798
|
+
Labor.UnPr = tr_utils_1.TrUtils.FixPriceValue(Labor.EstPr);
|
|
799
|
+
Labor.Disc = 0;
|
|
800
|
+
Labor.Perc = '';
|
|
801
|
+
}
|
|
802
|
+
else {
|
|
803
|
+
Labor.UnPr = tr_utils_1.TrUtils.FixPriceValue(Labor.Pr);
|
|
804
|
+
}
|
|
805
|
+
});
|
|
806
|
+
return LaborList;
|
|
807
|
+
}
|
|
808
|
+
static GetCustItemsPrintInfo(Items, LaborList) {
|
|
809
|
+
Items.forEach((Item) => {
|
|
810
|
+
let LaborStatus = tr_utils_1.TrUtils.IsNull(Item.CollId) ? this.GetPartParentStatus(Item.OpId, LaborList) : Item.Sts;
|
|
811
|
+
if (LaborStatus === enums_1.LaborStatusEnum.New || LaborStatus === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
812
|
+
Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.EstPr);
|
|
813
|
+
Item.Disc = 0;
|
|
814
|
+
Item.Perc = '';
|
|
815
|
+
}
|
|
816
|
+
else {
|
|
817
|
+
Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.UnPr);
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
return Items;
|
|
821
|
+
}
|
|
822
|
+
static GetCustTaxInfo(ROTotalsData, IncludeGST, TaxCodes) {
|
|
823
|
+
ROTotalsData.Ops = this.GetCustLaborTaxInfo(ROTotalsData.Ops, IncludeGST, TaxCodes);
|
|
824
|
+
ROTotalsData.Parts = this.GetCustPartTaxInfo(ROTotalsData.Parts, ROTotalsData.Ops, IncludeGST, TaxCodes);
|
|
825
|
+
return ROTotalsData;
|
|
826
|
+
}
|
|
827
|
+
static GetCustLaborTaxInfo(LaborList, IncludeGST, TaxCodes) {
|
|
828
|
+
LaborList.forEach((Labor) => {
|
|
829
|
+
if (Labor.Sts === enums_1.LaborStatusEnum.New || Labor.Sts === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
830
|
+
if (IncludeGST) {
|
|
831
|
+
Labor.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.ECGST);
|
|
832
|
+
Labor.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.ESGST);
|
|
833
|
+
Labor.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.EIGST);
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
Labor.CGSTAmt = 0;
|
|
837
|
+
Labor.SGSTAmt = 0;
|
|
838
|
+
Labor.IGSTAmt = 0;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
if (IncludeGST) {
|
|
843
|
+
Labor.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.CCGST);
|
|
844
|
+
Labor.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.CSGST);
|
|
845
|
+
Labor.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.CIGST);
|
|
846
|
+
}
|
|
847
|
+
else {
|
|
848
|
+
Labor.CGSTAmt = 0;
|
|
849
|
+
Labor.SGSTAmt = 0;
|
|
850
|
+
Labor.IGSTAmt = 0;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
Labor.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
|
|
854
|
+
Labor.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
|
|
855
|
+
Labor.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
|
|
856
|
+
});
|
|
857
|
+
return LaborList;
|
|
858
|
+
}
|
|
859
|
+
static GetCustPartTaxInfo(Items, LaborList, IncludeGST, TaxCodes) {
|
|
860
|
+
Items.forEach((Item) => {
|
|
861
|
+
let LaborStatus = tr_utils_1.TrUtils.IsNull(Item.CollId) ? this.GetPartParentStatus(Item.OpId, LaborList) : Item.Sts;
|
|
862
|
+
if (LaborStatus === enums_1.LaborStatusEnum.New || LaborStatus === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
863
|
+
if (IncludeGST) {
|
|
864
|
+
Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.ECGST);
|
|
865
|
+
Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.ESGST);
|
|
866
|
+
Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.EIGST);
|
|
867
|
+
}
|
|
868
|
+
else {
|
|
869
|
+
Item.CGSTAmt = 0;
|
|
870
|
+
Item.SGSTAmt = 0;
|
|
871
|
+
Item.IGSTAmt = 0;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
if (IncludeGST) {
|
|
876
|
+
Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.CCGST);
|
|
877
|
+
Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.CSGST);
|
|
878
|
+
Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.CIGST);
|
|
879
|
+
}
|
|
880
|
+
else {
|
|
881
|
+
Item.CGSTAmt = 0;
|
|
882
|
+
Item.SGSTAmt = 0;
|
|
883
|
+
Item.IGSTAmt = 0;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
Item.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
887
|
+
Item.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
888
|
+
Item.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
889
|
+
});
|
|
890
|
+
return Items;
|
|
891
|
+
}
|
|
892
|
+
static GetLaborAndPartItemsAfterDisc(ROTotalsData) {
|
|
893
|
+
ROTotalsData.Ops = this.GetCustLaborAfterDiscPrintInfo(ROTotalsData.Ops);
|
|
894
|
+
ROTotalsData.Parts = this.GetCustItemsAfterDiscPrintInfo(ROTotalsData.Parts, ROTotalsData.Ops);
|
|
895
|
+
return ROTotalsData;
|
|
896
|
+
}
|
|
897
|
+
static GetCustLaborAfterDiscPrintInfo(LaborList) {
|
|
898
|
+
LaborList.forEach((Labor) => {
|
|
899
|
+
Labor.HSN = Labor.SAC;
|
|
900
|
+
if (Labor.Sts === enums_1.LaborStatusEnum.New || Labor.Sts === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
901
|
+
Labor.UnPr = tr_utils_1.TrUtils.FixPriceValue(Labor.EstPr);
|
|
902
|
+
}
|
|
903
|
+
else {
|
|
904
|
+
Labor.UnPr = tr_utils_1.TrUtils.FixPriceValue(Labor.NetAmt);
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
return LaborList;
|
|
908
|
+
}
|
|
909
|
+
static GetCustItemsAfterDiscPrintInfo(Items, LaborList) {
|
|
910
|
+
Items.forEach((Item) => {
|
|
911
|
+
let LaborStatus = tr_utils_1.TrUtils.IsNull(Item.CollId) ? this.GetPartParentStatus(Item.OpId, LaborList) : Item.Sts;
|
|
912
|
+
if (LaborStatus === enums_1.LaborStatusEnum.New || LaborStatus === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
913
|
+
Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.EstPr);
|
|
914
|
+
}
|
|
915
|
+
else {
|
|
916
|
+
Item.UnPr = tr_utils_1.TrUtils.FixedTo((0, aggregation_1.division)(Item.NetAmt, Item.Qty));
|
|
917
|
+
}
|
|
918
|
+
});
|
|
919
|
+
return Items;
|
|
920
|
+
}
|
|
921
|
+
static GetPartParentStatus(PartOpId, LaborList) {
|
|
922
|
+
let index = LaborList.findIndex((Labor) => {
|
|
923
|
+
return Labor._id === PartOpId;
|
|
924
|
+
});
|
|
925
|
+
return LaborList[index].Sts;
|
|
926
|
+
}
|
|
927
|
+
static GetCombinedInfoForItems(ROTotalsData) {
|
|
928
|
+
ROTotalsData.Ops = this.GetLaborCombinedPrintInfo(ROTotalsData.Ops);
|
|
929
|
+
ROTotalsData.Parts = this.GetItemsCombinedPrintInfo(ROTotalsData.Parts);
|
|
930
|
+
return ROTotalsData;
|
|
931
|
+
}
|
|
932
|
+
static GetLaborCombinedPrintInfo(LaborList) {
|
|
933
|
+
LaborList.forEach((Labor) => {
|
|
934
|
+
Labor.AssPr = tr_utils_1.TrUtils.FixedTo((0, aggregation_1.addition)(Labor.AssPr, Labor.NetAmt));
|
|
935
|
+
});
|
|
936
|
+
return LaborList;
|
|
937
|
+
}
|
|
938
|
+
static GetItemsCombinedPrintInfo(Items) {
|
|
939
|
+
Items.forEach((Item) => {
|
|
940
|
+
Item.AssPr = tr_utils_1.TrUtils.FixedTo((0, aggregation_1.division)((0, aggregation_1.addition)(Item.AssAmt, Item.NetAmt), Item.Qty));
|
|
941
|
+
});
|
|
942
|
+
return Items;
|
|
943
|
+
}
|
|
944
|
+
static GetSplitInfoForParts(Items) {
|
|
945
|
+
Items.forEach((Item) => {
|
|
946
|
+
Item.UnPr = tr_utils_1.TrUtils.FixedTo((0, aggregation_1.division)(Item.NetAmt, Item.Qty));
|
|
947
|
+
});
|
|
948
|
+
return Items;
|
|
949
|
+
}
|
|
950
|
+
static CheckLaborTaxItemIndex(LaborList) {
|
|
951
|
+
let TaxIndex = LaborList.findIndex((Labor) => {
|
|
952
|
+
if (!tr_utils_1.TrUtils.CheckInvalidSelect(Labor.TCode)) {
|
|
953
|
+
return Labor;
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
return TaxIndex;
|
|
957
|
+
}
|
|
958
|
+
static CheckPartTaxItemIndex(PartsList) {
|
|
959
|
+
let TaxIndex = PartsList.findIndex((Part) => {
|
|
960
|
+
if (!tr_utils_1.TrUtils.CheckInvalidSelect(Part.TCode)) {
|
|
961
|
+
return Part;
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
return TaxIndex;
|
|
965
|
+
}
|
|
966
|
+
static PrepareFormatForEstPrint(ROPrintData, SuppEstCodeValue, OverAllEst, argROType, AsEstimated) {
|
|
967
|
+
let PrintInfo = [];
|
|
968
|
+
if (OverAllEst === true) {
|
|
969
|
+
let ROLaborParts = this.GetFormatForEstPrint(null, null, ROPrintData, argROType, AsEstimated);
|
|
970
|
+
PrintInfo.push(ROLaborParts);
|
|
971
|
+
ROPrintData.SuppEst.forEach((SuppEstCode, index) => {
|
|
972
|
+
let ROPrintInfo = this.GetFormatForEstPrint(SuppEstCode.Id, index, ROPrintData, argROType, AsEstimated);
|
|
973
|
+
PrintInfo.push(ROPrintInfo);
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
else {
|
|
977
|
+
let SuppEstIndex;
|
|
978
|
+
if (!tr_utils_1.TrUtils.IsNull(SuppEstCodeValue)) {
|
|
979
|
+
SuppEstIndex = ROPrintData.SuppEst.findIndex((SuppEst) => {
|
|
980
|
+
return SuppEst.Id === SuppEstCodeValue;
|
|
981
|
+
});
|
|
982
|
+
if (SuppEstIndex === -1) {
|
|
983
|
+
SuppEstIndex = null;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
let ROLaborParts = this.GetFormatForEstPrint(SuppEstCodeValue, SuppEstIndex, ROPrintData, argROType, AsEstimated);
|
|
987
|
+
PrintInfo.push(ROLaborParts);
|
|
988
|
+
}
|
|
989
|
+
return PrintInfo;
|
|
990
|
+
}
|
|
991
|
+
static GetFormatForEstPrint(SuppEstCodeValue, SuppEstIndex, ROPrintData, argROType, AsEstimated) {
|
|
992
|
+
let ROLaborParts = {};
|
|
993
|
+
if (!tr_utils_1.TrUtils.IsNull(SuppEstIndex)) {
|
|
994
|
+
ROLaborParts.Text = 'Supp.Est -' + (SuppEstIndex + 1);
|
|
995
|
+
}
|
|
996
|
+
ROLaborParts.Ops = this.SeparateLaborListByPTypeAndSuppIndex(ROPrintData.Ops, SuppEstCodeValue);
|
|
997
|
+
ROLaborParts.Parts = this.SeparateOnlyPartsByPTypeAndSuppIndex(ROPrintData.Parts, SuppEstCodeValue);
|
|
998
|
+
ROLaborParts.Colli = this.SeparateCollisionBySuppIndex(ROPrintData.Colli, SuppEstCodeValue);
|
|
999
|
+
if (AsEstimated) {
|
|
1000
|
+
ROLaborParts.Sts = enums_1.EstimateStatusEnum.New;
|
|
1001
|
+
}
|
|
1002
|
+
else {
|
|
1003
|
+
ROLaborParts.Sts = enums_1.EstimateStatusEnum.Approved;
|
|
1004
|
+
}
|
|
1005
|
+
ROLaborParts.Type = argROType;
|
|
1006
|
+
return ROLaborParts;
|
|
1007
|
+
}
|
|
1008
|
+
static SeparateLaborListByPTypeAndSuppIndex(Operations, SuppEstCodeValue) {
|
|
1009
|
+
let Ops = [];
|
|
1010
|
+
Ops = Operations.filter((Operation) => {
|
|
1011
|
+
if (tr_utils_1.TrUtils.IsNull(Operation.SuppEst)) {
|
|
1012
|
+
Operation.SuppEst = null;
|
|
1013
|
+
}
|
|
1014
|
+
return Operation.SuppEst === SuppEstCodeValue;
|
|
1015
|
+
});
|
|
1016
|
+
return Ops;
|
|
1017
|
+
}
|
|
1018
|
+
static SeparateOnlyPartsByPTypeAndSuppIndex(Parts, SuppEstCodeValue) {
|
|
1019
|
+
let SParts = [];
|
|
1020
|
+
SParts = Parts.filter((Part) => {
|
|
1021
|
+
if (tr_utils_1.TrUtils.IsNull(Part.SuppEst)) {
|
|
1022
|
+
Part.SuppEst = null;
|
|
1023
|
+
}
|
|
1024
|
+
return Part.SuppEst === SuppEstCodeValue;
|
|
1025
|
+
});
|
|
1026
|
+
return SParts;
|
|
1027
|
+
}
|
|
1028
|
+
static SeparateCollisionBySuppIndex(Collisions, SuppEstCodeValue) {
|
|
1029
|
+
let FilteredCollisions = [];
|
|
1030
|
+
FilteredCollisions = Collisions.filter((Collision) => {
|
|
1031
|
+
if (tr_utils_1.TrUtils.IsNull(Collision.SuppEst)) {
|
|
1032
|
+
Collision.SuppEst = null;
|
|
1033
|
+
}
|
|
1034
|
+
if (Collision.SuppEst === SuppEstCodeValue) {
|
|
1035
|
+
return Collision;
|
|
1036
|
+
}
|
|
1037
|
+
});
|
|
1038
|
+
return FilteredCollisions;
|
|
1039
|
+
}
|
|
1040
|
+
static CheckAndCombineDescMPNForAR(PrintPartNo, ROPrintData) {
|
|
1041
|
+
if (PrintPartNo) {
|
|
1042
|
+
ROPrintData.PrintInfo.forEach((PrintData) => {
|
|
1043
|
+
PrintData.Colli.forEach((Collision) => {
|
|
1044
|
+
if (!tr_utils_1.TrUtils.IsNull(Collision.PartData) && !tr_utils_1.TrUtils.IsEmpty(Collision.PartData.MPN)) {
|
|
1045
|
+
Collision.Desc = Collision.Desc + '/' + Collision.PartData.MPN;
|
|
1046
|
+
}
|
|
1047
|
+
});
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
return ROPrintData;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
exports.EstPrintService = EstPrintService;
|