mobioffice-cli 0.2.1 → 1.0.1
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/{src/index.ts → lib/index.d.ts} +1 -45
- package/lib/models/Feed-Details-Screen.model.d.ts +6 -0
- package/lib/models/Feed-Details-Screen.model.js +27 -0
- package/lib/models/action.model.d.ts +58 -0
- package/lib/models/action.model.js +315 -0
- package/lib/models/actions/doffing.d.ts +6 -0
- package/lib/models/actions/doffing.js +64 -0
- package/lib/models/actions/folding.d.ts +7 -0
- package/lib/models/actions/folding.js +37 -0
- package/lib/models/attendance.model.d.ts +44 -0
- package/lib/models/attendance.model.js +446 -0
- package/lib/models/cicoPost.model.d.ts +9 -0
- package/lib/models/cicoPost.model.js +19 -0
- package/lib/models/company.model.d.ts +67 -0
- package/lib/models/company.model.js +725 -0
- package/lib/models/contact-us/resquest.model.d.ts +30 -0
- package/lib/models/contact-us/resquest.model.js +73 -0
- package/lib/models/crud/crud.d.ts +7 -0
- package/lib/models/crud/crud.js +27 -0
- package/lib/models/customCollection.model.d.ts +9 -0
- package/lib/models/customCollection.model.js +40 -0
- package/lib/models/customer/customer.model.d.ts +32 -0
- package/lib/models/customer/customer.model.js +62 -0
- package/lib/models/deviceChangeReq.d.ts +10 -0
- package/lib/models/deviceChangeReq.js +138 -0
- package/lib/models/dispatch.model.d.ts +14 -0
- package/lib/models/dispatch.model.js +93 -0
- package/lib/models/feed.models.d.ts +8 -0
- package/lib/models/feed.models.js +97 -0
- package/lib/models/geofence.model.d.ts +7 -0
- package/lib/models/geofence.model.js +61 -0
- package/lib/models/leaveApplicationPost.model.d.ts +12 -0
- package/lib/models/leaveApplicationPost.model.js +72 -0
- package/lib/models/license.model.d.ts +25 -0
- package/lib/models/license.model.js +198 -0
- package/lib/models/log.model.d.ts +6 -0
- package/{src/models/log.model.ts → lib/models/log.model.js} +11 -11
- package/lib/models/meeting.model.d.ts +11 -0
- package/lib/models/meeting.model.js +79 -0
- package/lib/models/meter.model.d.ts +18 -0
- package/lib/models/meter.model.js +54 -0
- package/lib/models/missingPunchPost.model.d.ts +15 -0
- package/lib/models/missingPunchPost.model.js +69 -0
- package/lib/models/offline.model.d.ts +70 -0
- package/lib/models/offline.model.js +831 -0
- package/lib/models/post.model.d.ts +38 -0
- package/lib/models/post.model.js +94 -0
- package/lib/models/printDetailsScreen.model.d.ts +6 -0
- package/lib/models/printDetailsScreen.model.js +27 -0
- package/lib/models/pushNotifications/pushNotification.model.d.ts +4 -0
- package/lib/models/pushNotifications/pushNotification.model.js +17 -0
- package/lib/models/report-actions.model.d.ts +26 -0
- package/lib/models/report-actions.model.js +56 -0
- package/lib/models/report-definition-details.model.d.ts +13 -0
- package/lib/models/report-definition-details.model.js +85 -0
- package/lib/models/report-definition.model.d.ts +23 -0
- package/lib/models/report-definition.model.js +26 -0
- package/lib/models/report-definitions-summary.model.d.ts +8 -0
- package/lib/models/report-definitions-summary.model.js +59 -0
- package/lib/models/report-detail-data.model.d.ts +46 -0
- package/lib/models/report-detail-data.model.js +49 -0
- package/lib/models/report-visibility.model.d.ts +7 -0
- package/lib/models/report-visibility.model.js +42 -0
- package/lib/models/report.model.d.ts +19 -0
- package/lib/models/report.model.js +138 -0
- package/lib/models/reportGenerator.model.d.ts +164 -0
- package/lib/models/reportGenerator.model.js +642 -0
- package/lib/models/response.model.d.ts +18 -0
- package/lib/models/response.model.js +30 -0
- package/lib/models/steps.factory.model.d.ts +172 -0
- package/lib/models/steps.factory.model.js +187 -0
- package/lib/models/storeGupShupLog.model.d.ts +6 -0
- package/lib/models/storeGupShupLog.model.js +51 -0
- package/lib/models/summary.model.d.ts +10 -0
- package/{src/models/summary.model.ts → lib/models/summary.model.js} +28 -27
- package/lib/models/tasks/sub-task-group.model.d.ts +42 -0
- package/lib/models/tasks/sub-task-group.model.js +154 -0
- package/lib/models/tasks/tags.model.d.ts +29 -0
- package/lib/models/tasks/tags.model.js +70 -0
- package/lib/models/tasks/task-group.model.d.ts +53 -0
- package/lib/models/tasks/task-group.model.js +156 -0
- package/lib/models/tasks/task.model.d.ts +163 -0
- package/lib/models/tasks/task.model.js +603 -0
- package/lib/models/tempCollection.model.d.ts +40 -0
- package/{src/models/tempCollection.model.ts → lib/models/tempCollection.model.js} +114 -130
- package/lib/models/user.model.d.ts +42 -0
- package/lib/models/user.model.js +272 -0
- package/lib/models/utility.model.d.ts +13 -0
- package/lib/models/utility.model.js +93 -0
- package/lib/models/visitorManagement/acknowledgement.model.d.ts +9 -0
- package/lib/models/visitorManagement/acknowledgement.model.js +55 -0
- package/lib/models/visitorManagement/invite.model.d.ts +32 -0
- package/lib/models/visitorManagement/invite.model.js +326 -0
- package/lib/models/visitorManagement/newIn.model.d.ts +19 -0
- package/lib/models/visitorManagement/newIn.model.js +67 -0
- package/lib/models/visitorManagement/selfServe.model.d.ts +13 -0
- package/lib/models/visitorManagement/selfServe.model.js +46 -0
- package/lib/models/worklogPost.model.d.ts +6 -0
- package/lib/models/worklogPost.model.js +9 -0
- package/lib/services/customer.d.ts +30 -0
- package/lib/services/customer.js +354 -0
- package/lib/services/meeting.d.ts +19 -0
- package/lib/services/meeting.js +109 -0
- package/package.json +4 -1
- package/.prettierrc +0 -4
- package/a.js +0 -3
- package/scripts/1.ts +0 -1300
- package/scripts/GCloudPubSub/pub-sub-config.json +0 -12
- package/scripts/GCloudPubSub/visitorAutoRejection.ts +0 -86
- package/scripts/actions/assignUsersFromOneActionToOther.ts +0 -64
- package/scripts/actions/assignUsersListToAction.ts +0 -81
- package/scripts/actions/getActionsListOfUser.ts +0 -42
- package/scripts/actions/getCompanyUserDetails.ts +0 -49
- package/scripts/actions/giveActionToUser.ts +0 -41
- package/scripts/actions/giveUsersToActivitySelector.ts +0 -56
- package/scripts/actions/groupActionsInActivitySelector.ts +0 -101
- package/scripts/actions/modifySummaryReportDB.ts +0 -42
- package/scripts/actions/setUrlToActionStep.ts +0 -18
- package/scripts/actions/syncMySqlAttendanceDBWithFirebase.ts +0 -93
- package/scripts/actions/syncMySqlMeetingsDBWithFirebase.ts +0 -103
- package/scripts/actions/test.ts +0 -29
- package/scripts/actions/transferFeedsOldIdToNew.ts +0 -40
- package/scripts/actions/transformUserIntoManager.ts +0 -89
- package/scripts/argvConfig.js +0 -9
- package/scripts/backUpData/testCode.ts +0 -131
- package/scripts/benaraScripts/addWorkAreaMap.ts +0 -46
- package/scripts/benaraScripts/add_customers.ts +0 -26
- package/scripts/benaraScripts/add_customers_contact.ts +0 -27
- package/scripts/benaraScripts/add_empty_work_area.ts +0 -17
- package/scripts/benaraScripts/assignManagers.ts +0 -35
- package/scripts/benaraScripts/changeCheckInFlag.ts +0 -45
- package/scripts/benaraScripts/createCustomerContactsList.ts +0 -170
- package/scripts/benaraScripts/createUserByDeletingOldUser.ts +0 -70
- package/scripts/benaraScripts/createUsersAreaMapCollection.ts +0 -23
- package/scripts/benaraScripts/createWorkAreaMap.ts +0 -24
- package/scripts/benaraScripts/mapWorkAreasToUsers.ts +0 -112
- package/scripts/companies_data.json +0 -2496
- package/scripts/create_or_update_users.ts +0 -31
- package/scripts/csvToJson/csvToJson.ts +0 -90
- package/scripts/csvToJson/users.json +0 -3896
- package/scripts/db.js +0 -27
- package/scripts/db.json +0 -13
- package/scripts/dbMySql.ts +0 -63
- package/scripts/delete_action_steps.ts +0 -11
- package/scripts/delete_user.ts +0 -71
- package/scripts/dev_companies_data.json +0 -613
- package/scripts/enroll.xlsx +0 -0
- package/scripts/export_users.ts +0 -72
- package/scripts/files/visitorManagementFiles/displayScreen.json +0 -70
- package/scripts/files/visitorManagementFiles/init_report_visibility.ts +0 -79
- package/scripts/firebaseConfig.js +0 -12
- package/scripts/firebaseDocs/deleteIncommingCollection.ts +0 -47
- package/scripts/firebaseDocs/updateDoc.ts +0 -43
- package/scripts/getActionDataIntoJSON/getActionData.ts +0 -68
- package/scripts/get_attendance_by_any_date.ts +0 -14
- package/scripts/get_attendance_by_month.ts +0 -12
- package/scripts/get_attendance_monthly_by_team.ts +0 -11
- package/scripts/get_daily_report.ts +0 -10
- package/scripts/get_mangers.ts +0 -13
- package/scripts/grant_user_license.ts +0 -18
- package/scripts/init_CustomCollection.ts +0 -16
- package/scripts/init_action_steps.ts +0 -28
- package/scripts/init_actions.ts +0 -31
- package/scripts/init_company.ts +0 -18
- package/scripts/init_customer_mysql.ts +0 -12
- package/scripts/init_feed.ts +0 -4
- package/scripts/init_feed_details_screen.ts +0 -14
- package/scripts/init_geofence.ts +0 -26
- package/scripts/init_print_details_screen.ts +0 -14
- package/scripts/init_report_actions.ts +0 -24
- package/scripts/init_report_definition_detail.ts +0 -26
- package/scripts/init_report_definition_summary.ts +0 -16
- package/scripts/init_report_visibility.ts +0 -46
- package/scripts/init_user_customcollection.ts +0 -16
- package/scripts/json/action.json +0 -21
- package/scripts/json/company.json +0 -24
- package/scripts/json/report-action.json +0 -13
- package/scripts/json/report-def-deet.json +0 -43
- package/scripts/json/resp.json +0 -784
- package/scripts/json/steps.json +0 -24
- package/scripts/json/test.ts +0 -49
- package/scripts/mysqlConfig.ts +0 -9
- package/scripts/revoke_or_extend_license.ts +0 -14
- package/scripts/stream.js +0 -4
- package/scripts/testing1.ts +0 -35
- package/scripts/update/doc.json +0 -20
- package/scripts/update/getDocByPath.ts +0 -34
- package/scripts/update/updateDocByPath.ts +0 -47
- package/scripts/update/updateUsersOfCompanies.ts +0 -58
- package/scripts/update_actions.ts +0 -19
- package/scripts/update_actions_steps.ts +0 -19
- package/scripts/update_company.ts +0 -19
- package/scripts/update_geofence.ts +0 -20
- package/scripts/update_managers.ts +0 -16
- package/scripts/visitorMgmt/createArea.ts +0 -68
- package/scripts/visitorMgmt/createArea.txt +0 -3
- package/scripts/visitorMgmt/createVisitorPathInstructionDocs.ts +0 -130
- package/scripts/visitorMgmt/createVisitorPathInstructionDocs.txt +0 -18
- package/scripts/visitorMgmt/encryptDateString.ts +0 -71
- package/scripts/visitorMgmt/makeHostsManagersOfEachOther.ts +0 -117
- package/scripts/whatsapp_gupshup/sendMessage.ts +0 -97
- package/src/models/Feed-Details-Screen.model.ts +0 -29
- package/src/models/action.model.ts +0 -355
- package/src/models/actions/doffing.ts +0 -71
- package/src/models/actions/folding.ts +0 -39
- package/src/models/attendance.model.ts +0 -615
- package/src/models/cicoPost.model.ts +0 -20
- package/src/models/company.model.ts +0 -975
- package/src/models/contact-us/resquest.model.ts +0 -87
- package/src/models/crud/crud.ts +0 -30
- package/src/models/customCollection.model.ts +0 -47
- package/src/models/customer/customer.model.ts +0 -85
- package/src/models/deviceChangeReq.ts +0 -150
- package/src/models/dispatch.model.ts +0 -99
- package/src/models/feed.models.ts +0 -104
- package/src/models/geofence.model.ts +0 -61
- package/src/models/leaveApplicationPost.model.ts +0 -79
- package/src/models/license.model.ts +0 -215
- package/src/models/meeting.model.ts +0 -80
- package/src/models/meter.model.ts +0 -62
- package/src/models/missingPunchPost.model.ts +0 -84
- package/src/models/offline.model.ts +0 -1133
- package/src/models/post.model.ts +0 -105
- package/src/models/printDetailsScreen.model.ts +0 -30
- package/src/models/pushNotifications/pushNotification.model.ts +0 -17
- package/src/models/report-actions.model.ts +0 -57
- package/src/models/report-definition-details.model.ts +0 -89
- package/src/models/report-definition.model.ts +0 -26
- package/src/models/report-definitions-summary.model.ts +0 -59
- package/src/models/report-detail-data.model.ts +0 -49
- package/src/models/report-visibility.model.ts +0 -44
- package/src/models/report.model.ts +0 -179
- package/src/models/reportGenerator.model.ts +0 -883
- package/src/models/response.model.ts +0 -31
- package/src/models/steps.factory.model.ts +0 -195
- package/src/models/storeGupShupLog.model.ts +0 -49
- package/src/models/tasks/sub-task-group.model.ts +0 -173
- package/src/models/tasks/tags.model.ts +0 -113
- package/src/models/tasks/task-group.model.ts +0 -172
- package/src/models/tasks/task.model.ts +0 -681
- package/src/models/user.model.ts +0 -319
- package/src/models/utility.model.ts +0 -100
- package/src/models/visitorManagement/acknowledgement.model.ts +0 -71
- package/src/models/visitorManagement/invite.model.ts +0 -406
- package/src/models/visitorManagement/newIn.model.ts +0 -82
- package/src/models/visitorManagement/selfServe.model.ts +0 -58
- package/src/models/worklogPost.model.ts +0 -8
- package/src/services/customer.ts +0 -382
- package/src/services/meeting.ts +0 -123
- package/test/1.ts +0 -13
- package/test/db.js +0 -19
- package/test/firebaseConfig.js +0 -1
- package/tsconfig.json +0 -16
@@ -1,12 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.TempCollection = void 0;
|
4
|
+
const response_model_1 = require("./response.model");
|
4
5
|
class TempCollection {
|
5
|
-
static async createTempCollection(firestore
|
6
|
-
await firestore.collection("TempCollection").doc(uniqueId).set(data)
|
7
|
-
return "stock added"
|
6
|
+
static async createTempCollection(firestore, uniqueId, data) {
|
7
|
+
await firestore.collection("TempCollection").doc(uniqueId).set(data);
|
8
|
+
return "stock added";
|
8
9
|
}
|
9
|
-
|
10
10
|
// static async verifyTakaList(firestore:admin.firestore.Firestore,uniqueId:string,takaId:string,arrayInstance:any,scanType:string){
|
11
11
|
// let itemDetailsList_snapshot = await firestore.collection("TempCollection").doc(uniqueId).get()
|
12
12
|
// let itemDetailsdoc = JSON.parse(JSON.stringify(itemDetailsList_snapshot.data()))
|
@@ -96,33 +96,34 @@ class TempCollection {
|
|
96
96
|
// return new HttpResponseAndErrorHandling(400, "Not available", null, 400).getErrorResponse();
|
97
97
|
// }
|
98
98
|
// }
|
99
|
-
|
100
|
-
|
101
|
-
let
|
102
|
-
let
|
103
|
-
|
104
|
-
if(keys.length) {
|
99
|
+
static async verifyTakaList(firestore, uniqueId, takaId, arrayInstance, scanType) {
|
100
|
+
let itemDetailsList_snapshot = await firestore.collection("TempCollection").doc(uniqueId).get();
|
101
|
+
let itemDetailsDoc = JSON.parse(JSON.stringify(itemDetailsList_snapshot.data()));
|
102
|
+
let keys = Object.keys(itemDetailsDoc);
|
103
|
+
if (keys.length) {
|
105
104
|
const matchResult = await this.matchTakaInTakaList(takaId, itemDetailsDoc.takaList, scanType);
|
106
105
|
const summary = JSON.parse(itemDetailsDoc.summary);
|
107
106
|
let serialNo = summary.length;
|
108
107
|
if (matchResult.status === "not found") {
|
109
108
|
let message = "Please verify the taka no. with system";
|
110
|
-
const isAlreadyScanned = await this.checkIfAlreadyScanned(itemDetailsDoc,takaId,scanType);
|
109
|
+
const isAlreadyScanned = await this.checkIfAlreadyScanned(itemDetailsDoc, takaId, scanType);
|
111
110
|
if (isAlreadyScanned) {
|
112
111
|
message = "This taka has been scanned already";
|
113
112
|
}
|
114
113
|
const verificationFailedResponse = await this.createResponseToSend(summary, serialNo, message);
|
115
114
|
return verificationFailedResponse;
|
116
|
-
}
|
115
|
+
}
|
116
|
+
else if (matchResult.status === "duplicate found") {
|
117
117
|
const message = "Duplicate taka exists, please select full scan";
|
118
118
|
const duplicateFoundResponse = await this.createResponseToSend(summary, serialNo, message);
|
119
119
|
return duplicateFoundResponse;
|
120
|
-
}
|
120
|
+
}
|
121
|
+
else {
|
121
122
|
const fullTakaId = matchResult.id;
|
122
123
|
const resObj = await this.createResponseObj(itemDetailsDoc, fullTakaId, serialNo + 1);
|
123
124
|
if (resObj.status) {
|
124
125
|
summary.unshift(resObj.info);
|
125
|
-
serialNo = summary.length
|
126
|
+
serialNo = summary.length;
|
126
127
|
const summaryToSave = JSON.stringify(summary);
|
127
128
|
await this.updateInfoInDB(itemDetailsList_snapshot, fullTakaId, summaryToSave, arrayInstance);
|
128
129
|
const isTakaAdded = await this.checkIfTakaIsAdded(firestore, fullTakaId, uniqueId);
|
@@ -130,73 +131,72 @@ class TempCollection {
|
|
130
131
|
const message = "Scan successfully";
|
131
132
|
const successResponse = await this.createResponseToSend(summary, serialNo, message);
|
132
133
|
return successResponse;
|
133
|
-
}
|
134
|
+
}
|
135
|
+
else {
|
134
136
|
await this.resetReferenceDoc(arrayInstance, itemDetailsList_snapshot, fullTakaId);
|
135
137
|
const message = "Taka Scan failed, please scan again";
|
136
|
-
const responseToSend = await this.createResponseToSend(summary, serialNo, message)
|
137
|
-
return responseToSend
|
138
|
+
const responseToSend = await this.createResponseToSend(summary, serialNo, message);
|
139
|
+
return responseToSend;
|
138
140
|
}
|
139
|
-
}
|
141
|
+
}
|
142
|
+
else {
|
140
143
|
const message = "Please verify taka with the system";
|
141
|
-
const responseToSend = await this.createResponseToSend(summary, serialNo, message)
|
142
|
-
return responseToSend
|
144
|
+
const responseToSend = await this.createResponseToSend(summary, serialNo, message);
|
145
|
+
return responseToSend;
|
143
146
|
}
|
144
147
|
}
|
145
|
-
}
|
146
|
-
|
148
|
+
}
|
149
|
+
else {
|
150
|
+
return new response_model_1.HttpResponseAndErrorHandling(400, "Not available", null, 400).getErrorResponse();
|
147
151
|
}
|
148
152
|
}
|
149
|
-
|
150
|
-
|
151
|
-
let alreadyScannedTakkaList
|
152
|
-
|
153
|
-
if(scanType == "partial"){
|
153
|
+
static async checkIfAlreadyScanned(itemDetailsDoc, takaId, scanType) {
|
154
|
+
let alreadyScannedTakkaList = itemDetailsDoc.alreadyScannedTakaId;
|
155
|
+
for (let compareStr of alreadyScannedTakkaList) {
|
156
|
+
if (scanType == "partial") {
|
154
157
|
compareStr = compareStr.split("-")[2];
|
155
158
|
}
|
156
|
-
if(compareStr == takaId){
|
157
|
-
return true
|
159
|
+
if (compareStr == takaId) {
|
160
|
+
return true;
|
158
161
|
}
|
159
162
|
}
|
160
|
-
return false
|
163
|
+
return false;
|
161
164
|
}
|
162
|
-
|
163
|
-
|
164
|
-
let
|
165
|
-
for(let scannedTakka of summary){
|
165
|
+
static async createCountRow(summary, serialNo) {
|
166
|
+
let totalQuantity = 0;
|
167
|
+
for (let scannedTakka of summary) {
|
166
168
|
totalQuantity += Number(Number(scannedTakka["Quantity"]).toFixed(3));
|
167
169
|
}
|
168
|
-
let totalQuantityDoc
|
169
|
-
totalQuantityDoc["Sr No"] = "Total"
|
170
|
-
totalQuantityDoc["Sales Order"] = "-"
|
171
|
-
totalQuantityDoc["Roll No"] = serialNo
|
172
|
-
totalQuantityDoc["Quantity"] = totalQuantity
|
173
|
-
totalQuantityDoc["Design"] = "-"
|
174
|
-
totalQuantityDoc["Color"] = "-"
|
175
|
-
totalQuantityDoc["Grade"] = "-"
|
170
|
+
let totalQuantityDoc = {};
|
171
|
+
totalQuantityDoc["Sr No"] = "Total";
|
172
|
+
totalQuantityDoc["Sales Order"] = "-";
|
173
|
+
totalQuantityDoc["Roll No"] = serialNo;
|
174
|
+
totalQuantityDoc["Quantity"] = totalQuantity;
|
175
|
+
totalQuantityDoc["Design"] = "-";
|
176
|
+
totalQuantityDoc["Color"] = "-";
|
177
|
+
totalQuantityDoc["Grade"] = "-";
|
176
178
|
return totalQuantityDoc;
|
177
179
|
}
|
178
|
-
|
179
|
-
static async updateInfoInDB(docFromDB: any, takaId: string, summaryToSave: string, arrayInstance: any) {
|
180
|
+
static async updateInfoInDB(docFromDB, takaId, summaryToSave, arrayInstance) {
|
180
181
|
await docFromDB.ref.update({
|
181
182
|
takaList: arrayInstance.arrayRemove(takaId),
|
182
|
-
alreadyScannedTakaId
|
183
|
+
alreadyScannedTakaId: arrayInstance.arrayUnion(takaId),
|
183
184
|
summary: summaryToSave
|
184
|
-
})
|
185
|
+
});
|
185
186
|
}
|
186
|
-
|
187
|
-
static async checkIfTakaIsAdded(firestore: admin.firestore.Firestore, fullTakaId: string, uniqueId: string) {
|
187
|
+
static async checkIfTakaIsAdded(firestore, fullTakaId, uniqueId) {
|
188
188
|
let itemDetailsList_snapshot = await firestore.collection("TempCollection").doc(uniqueId).get();
|
189
|
-
let itemDetailsDoc
|
189
|
+
let itemDetailsDoc = itemDetailsList_snapshot.data();
|
190
190
|
const summary = JSON.parse(itemDetailsDoc.summary);
|
191
191
|
const compareStr = summary[0]["Roll No"];
|
192
192
|
if (compareStr === fullTakaId) {
|
193
|
-
return true;
|
194
|
-
}
|
193
|
+
return true;
|
194
|
+
}
|
195
|
+
else {
|
195
196
|
return false;
|
196
197
|
}
|
197
198
|
}
|
198
|
-
|
199
|
-
static async createResponseToSend(summary: any, serialNo: number, message: string) {
|
199
|
+
static async createResponseToSend(summary, serialNo, message) {
|
200
200
|
if (summary.length) {
|
201
201
|
const countRow = await this.createCountRow(summary, serialNo);
|
202
202
|
summary.push(countRow);
|
@@ -204,24 +204,22 @@ class TempCollection {
|
|
204
204
|
const result = {
|
205
205
|
data: JSON.stringify(summary),
|
206
206
|
message: message
|
207
|
-
}
|
207
|
+
};
|
208
208
|
return result;
|
209
209
|
}
|
210
|
-
|
211
|
-
static async resetReferenceDoc(arrayInstance: any, docFromDB: any, fullTakaId: string) {
|
210
|
+
static async resetReferenceDoc(arrayInstance, docFromDB, fullTakaId) {
|
212
211
|
await docFromDB.ref.update({
|
213
212
|
takaList: arrayInstance.arrayUnion(fullTakaId),
|
214
213
|
alreadyScannedTakaId: arrayInstance.arrayRemove(fullTakaId),
|
215
|
-
})
|
214
|
+
});
|
216
215
|
}
|
217
|
-
|
218
|
-
static async matchTakaInTakaList(takaId: string, takaList: string[], scanType: string) {
|
216
|
+
static async matchTakaInTakaList(takaId, takaList, scanType) {
|
219
217
|
let count = 0;
|
220
218
|
const result = {
|
221
219
|
status: "",
|
222
|
-
id
|
223
|
-
}
|
224
|
-
let idToSave
|
220
|
+
id: ""
|
221
|
+
};
|
222
|
+
let idToSave = "";
|
225
223
|
for (let fullId of takaList) {
|
226
224
|
let compareStr = fullId;
|
227
225
|
if (scanType === "partial") {
|
@@ -232,58 +230,56 @@ class TempCollection {
|
|
232
230
|
count++;
|
233
231
|
}
|
234
232
|
}
|
235
|
-
if(count === 0) {
|
233
|
+
if (count === 0) {
|
236
234
|
result.status = "not found";
|
237
|
-
}
|
235
|
+
}
|
236
|
+
else if (count === 1) {
|
238
237
|
result.status = "Success";
|
239
238
|
result.id = idToSave;
|
240
|
-
}
|
239
|
+
}
|
240
|
+
else {
|
241
241
|
result.status = "duplicate found";
|
242
242
|
}
|
243
243
|
return result;
|
244
244
|
}
|
245
|
-
|
246
|
-
static async verifyTakaNUpdate(firestore: admin.firestore.Firestore, takaNo: string, uniqueId: string,
|
247
|
-
arrayInstance: any, payLoadInfo: any, gradeInfoList: any) {
|
245
|
+
static async verifyTakaNUpdate(firestore, takaNo, uniqueId, arrayInstance, payLoadInfo, gradeInfoList) {
|
248
246
|
takaNo = takaNo.toUpperCase();
|
249
247
|
const infoDoc = await firestore.collection("TempCollection").doc(uniqueId).get();
|
250
|
-
const soDetails
|
248
|
+
const soDetails = infoDoc.data();
|
251
249
|
let summary = soDetails.summary;
|
252
250
|
for (let i = 0; i < soDetails.takaList.length; i++) {
|
253
|
-
if(takaNo === soDetails.takaList[i]) {
|
251
|
+
if (takaNo === soDetails.takaList[i]) {
|
254
252
|
const infoToStore = {
|
255
253
|
taka_no: `${takaNo}@@${payLoadInfo.parcelNo}`,
|
256
254
|
selectedSODesign: payLoadInfo.selectedSODesign,
|
257
255
|
selectedSORowId: payLoadInfo.selectedSORowId
|
258
|
-
}
|
259
|
-
const newScanRow = await this.getNewScanRow(soDetails.takaDetails,
|
260
|
-
soDetails.takaList[i],
|
261
|
-
summary,
|
262
|
-
gradeInfoList)
|
256
|
+
};
|
257
|
+
const newScanRow = await this.getNewScanRow(soDetails.takaDetails, soDetails.takaList[i], summary, gradeInfoList);
|
263
258
|
if (newScanRow) {
|
264
259
|
summary.unshift(newScanRow);
|
265
260
|
}
|
266
261
|
summary = JSON.parse(JSON.stringify(summary));
|
267
262
|
try {
|
268
263
|
await firestore.collection("TempCollection")
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
}
|
264
|
+
.doc(uniqueId)
|
265
|
+
.update({
|
266
|
+
scannedTakas: arrayInstance.arrayUnion(infoToStore),
|
267
|
+
takaList: arrayInstance.arrayRemove(takaNo),
|
268
|
+
summary: summary
|
269
|
+
});
|
270
|
+
}
|
271
|
+
catch (error) {
|
276
272
|
console.log(error);
|
277
273
|
return {
|
278
274
|
data: null,
|
279
275
|
message: "Something went wrong"
|
280
|
-
}
|
276
|
+
};
|
281
277
|
}
|
282
278
|
if (summary.length) {
|
283
279
|
const totalRow = await this.createTotalRow(summary);
|
284
280
|
summary.push(totalRow);
|
285
281
|
}
|
286
|
-
summary = JSON.stringify(summary)
|
282
|
+
summary = JSON.stringify(summary);
|
287
283
|
return {
|
288
284
|
data: summary,
|
289
285
|
message: "Scan successfully"
|
@@ -298,34 +294,30 @@ class TempCollection {
|
|
298
294
|
return {
|
299
295
|
data: summary,
|
300
296
|
message: "Please verify the taka number with the system"
|
301
|
-
}
|
297
|
+
};
|
302
298
|
}
|
303
|
-
|
304
|
-
static async getGradeFromId(id: string, gradeInfoList: any) {
|
299
|
+
static async getGradeFromId(id, gradeInfoList) {
|
305
300
|
for (let gradeInfo of gradeInfoList) {
|
306
301
|
if (id === gradeInfo.id) {
|
307
302
|
return gradeInfo.label;
|
308
303
|
}
|
309
304
|
}
|
310
305
|
}
|
311
|
-
|
312
|
-
|
313
|
-
oldSummary: any, gradeInfoList: any) {
|
314
|
-
for(let j = 0; j < takaDetails.length; j++) {
|
306
|
+
static async getNewScanRow(takaDetails, currTaka, oldSummary, gradeInfoList) {
|
307
|
+
for (let j = 0; j < takaDetails.length; j++) {
|
315
308
|
let obj = takaDetails[j];
|
316
309
|
if (obj.taka_no === currTaka) {
|
317
|
-
|
310
|
+
return {
|
318
311
|
serialNo: oldSummary.length + 1,
|
319
312
|
...obj,
|
320
313
|
grade: await this.getGradeFromId(obj.grade, gradeInfoList),
|
321
|
-
|
314
|
+
};
|
322
315
|
}
|
323
316
|
}
|
324
317
|
return null;
|
325
318
|
}
|
326
|
-
|
327
|
-
|
328
|
-
const totalRow: any = {};
|
319
|
+
static async createTotalRow(summary) {
|
320
|
+
const totalRow = {};
|
329
321
|
let totalMeter = 0;
|
330
322
|
for (let row of summary) {
|
331
323
|
totalMeter += Number(Number(row.meter).toFixed(3));
|
@@ -336,9 +328,8 @@ class TempCollection {
|
|
336
328
|
totalRow.grade = "-";
|
337
329
|
return totalRow;
|
338
330
|
}
|
339
|
-
|
340
|
-
|
341
|
-
let resObj: any = {
|
331
|
+
static async createResponseObj(responseInfo, takaId, serialNo) {
|
332
|
+
let resObj = {
|
342
333
|
status: false,
|
343
334
|
info: {}
|
344
335
|
};
|
@@ -347,10 +338,11 @@ class TempCollection {
|
|
347
338
|
if (takaId === takaDetailsObj.taka_no) {
|
348
339
|
if (itemDetails.P2 === takaDetailsObj.grade) {
|
349
340
|
resObj.status = true;
|
350
|
-
}
|
341
|
+
}
|
342
|
+
else {
|
351
343
|
return resObj;
|
352
344
|
}
|
353
|
-
resObj.info["Sr No"] = serialNo
|
345
|
+
resObj.info["Sr No"] = serialNo;
|
354
346
|
resObj.info["Sales Order"] = itemDetails.SOBookNameWithSrNo;
|
355
347
|
resObj.info["Roll No"] = takaId;
|
356
348
|
resObj.info["Quantity"] = Number(Number(takaDetailsObj.meter).toFixed(3));
|
@@ -360,39 +352,31 @@ class TempCollection {
|
|
360
352
|
}
|
361
353
|
}
|
362
354
|
}
|
363
|
-
return resObj
|
355
|
+
return resObj;
|
364
356
|
}
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
return stockListSnapshot.data()
|
357
|
+
static async getStockListbyUserId(firestore, userId) {
|
358
|
+
let stockListSnapshot = await firestore.collection("TempCollection").doc(userId).get();
|
359
|
+
return stockListSnapshot.data();
|
369
360
|
}
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
return "Success"
|
361
|
+
static async createTempCollectionOnlyWithSerialNo(firestore, uniqueId, doc) {
|
362
|
+
await firestore.collection("TempCollection").doc(uniqueId).set(doc);
|
363
|
+
return "Success";
|
374
364
|
}
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
return "Deleted"
|
365
|
+
static async deleteTempCollection(firestore, uniqueId) {
|
366
|
+
await firestore.collection("TempCollection").doc(uniqueId).delete();
|
367
|
+
return "Deleted";
|
379
368
|
}
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
return docSnapshot.exists
|
369
|
+
static async isDocPresent(firestore, uniqueId) {
|
370
|
+
let docSnapshot = await firestore.collection("TempCollection").doc(uniqueId).get();
|
371
|
+
return docSnapshot.exists;
|
384
372
|
}
|
385
|
-
|
386
|
-
static async getDocInfo(firestore: admin.firestore.Firestore, uniqueId: string) {
|
373
|
+
static async getDocInfo(firestore, uniqueId) {
|
387
374
|
let docSnap = await firestore.collection("TempCollection").doc(uniqueId).get();
|
388
375
|
return docSnap.data();
|
389
376
|
}
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
return "Success"
|
377
|
+
static async storeResponseInTemp(firestore, data) {
|
378
|
+
await firestore.collection("TempCollection").doc(data.uniqueId).set(data);
|
379
|
+
return "Success";
|
394
380
|
}
|
395
|
-
|
396
381
|
}
|
397
|
-
|
398
|
-
export { TempCollection }
|
382
|
+
exports.TempCollection = TempCollection;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import * as admin from "firebase-admin";
|
2
|
+
declare class User {
|
3
|
+
reportingTo: string | null;
|
4
|
+
managers: string[];
|
5
|
+
bio: string | null;
|
6
|
+
fcmToken: string | null;
|
7
|
+
email: string | null;
|
8
|
+
avatarUrl: string | null;
|
9
|
+
satOff: string | null;
|
10
|
+
id: string;
|
11
|
+
designation: string | null;
|
12
|
+
roles: string;
|
13
|
+
roamId: string | null;
|
14
|
+
birthDate: number;
|
15
|
+
name: string;
|
16
|
+
hasCheckedIn: boolean;
|
17
|
+
department: string | null;
|
18
|
+
empCode: string | null;
|
19
|
+
phone: string;
|
20
|
+
constructor(reportingTo: any, managers: string[], bio: string, fcmToken: string, email: string, avatarUrl: string, satOff: string, id: string, designation: string, roles: string, roamId: string, birthdate: number, name: string, hasCheckedIn: boolean, department: string, empCode: string, phone: string);
|
21
|
+
static initUsers(firestore: admin.firestore.Firestore): Promise<string>;
|
22
|
+
static getUsersListByManger(firestore: admin.firestore.Firestore, nickName: string): Promise<Map<any, any>>;
|
23
|
+
static getUserPhonebyUserId(firestore: admin.firestore.Firestore, userId: string): Promise<any>;
|
24
|
+
static getUserIdByPhone(firestore: admin.firestore.Firestore, phone: string): Promise<string>;
|
25
|
+
static getUserInfoById(firestore: admin.firestore.Firestore, userId: string, companyId: string): Promise<admin.firestore.DocumentData | undefined>;
|
26
|
+
static getUsersListByCompanyNickName(firestore: admin.firestore.Firestore, nickName: string): Promise<any[]>;
|
27
|
+
static deleteUser(firebase: admin.firestore.Firestore, auth: any, arrayRemove: any, nickName: string, phone: string): Promise<string>;
|
28
|
+
static getApps(firestore: admin.firestore.Firestore, phone: string, nickName: string): Promise<{
|
29
|
+
id: any;
|
30
|
+
name: any;
|
31
|
+
displayName: any;
|
32
|
+
icon: any;
|
33
|
+
}[]>;
|
34
|
+
static getActionsByUserApp(firestore: admin.firestore.Firestore, phone: string, nickName: string, actionId: string): Promise<{
|
35
|
+
name: any;
|
36
|
+
displayName: any;
|
37
|
+
icon: any;
|
38
|
+
id: any;
|
39
|
+
}[]>;
|
40
|
+
static getHostsPhoneList(firestore: admin.firestore.Firestore, companyId: string): Promise<any[]>;
|
41
|
+
}
|
42
|
+
export { User };
|