mobioffice-cli 1.0.0 → 1.0.2
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
package/src/services/customer.ts
DELETED
@@ -1,382 +0,0 @@
|
|
1
|
-
import * as admin from "firebase-admin";
|
2
|
-
import { Company } from "../models/company.model";
|
3
|
-
import { CustomCollection } from "../models/customCollection.model";
|
4
|
-
import { Customer, CustomerContact } from "../models/customer/customer.model";
|
5
|
-
import { Offline } from "../models/offline.model";
|
6
|
-
import { HttpResponseAndErrorHandling } from "../models/response.model";
|
7
|
-
import { User } from "../models/user.model";
|
8
|
-
import { Connection } from '@planetscale/database'
|
9
|
-
import { readFileSync } from "fs";
|
10
|
-
import { Pool } from 'mysql2';
|
11
|
-
import CurdService from "../models/crud/crud";
|
12
|
-
|
13
|
-
class CustomerServices {
|
14
|
-
static async createCustomer(firestore: admin.firestore.Firestore,
|
15
|
-
connection: Pool,
|
16
|
-
arrayUnion: any,
|
17
|
-
customerNUserInfo: any) {
|
18
|
-
const curdService = new CurdService(connection);
|
19
|
-
try {
|
20
|
-
const companyId = customerNUserInfo.companyId;
|
21
|
-
const userId = customerNUserInfo.userId;
|
22
|
-
const customerObj = await this.createObjForAddingCustomer(customerNUserInfo.extra.extraData);
|
23
|
-
const objectToSave = JSON.parse(JSON.stringify(customerObj));
|
24
|
-
objectToSave.id = customerNUserInfo.id;
|
25
|
-
let qryStr = `INSERT INTO Customers
|
26
|
-
(companyId, GSTNo, address,
|
27
|
-
city, contactName, contactNo,
|
28
|
-
customerName, state, zipcode)
|
29
|
-
VALUES
|
30
|
-
("${companyId}", "${objectToSave.GSTNo}",
|
31
|
-
"${objectToSave.address}", "${objectToSave.city}",
|
32
|
-
"${objectToSave.contactName}", "${objectToSave.contactNo}",
|
33
|
-
"${objectToSave.customerName}", "${objectToSave.state}",
|
34
|
-
"${objectToSave.zipcode}")`;
|
35
|
-
const insertRes: any = await curdService.query(qryStr)
|
36
|
-
const customerId = insertRes.insertId;
|
37
|
-
const contactInfo = {
|
38
|
-
customerId: customerId,
|
39
|
-
contactName: objectToSave.contactName,
|
40
|
-
contactNo: objectToSave.contactNo,
|
41
|
-
designation: null,
|
42
|
-
alternateContactNo: null
|
43
|
-
}
|
44
|
-
const infoToSave = JSON.parse(JSON.stringify(contactInfo));
|
45
|
-
await this.saveContactInfoToDB(connection, infoToSave);
|
46
|
-
console.log(objectToSave.customerName)
|
47
|
-
let isWorkAreaDocPresent = false;
|
48
|
-
const workAreaDoc = await firestore.collection("CustomCollections")
|
49
|
-
.doc(companyId)
|
50
|
-
.collection("Users")
|
51
|
-
.doc(userId)
|
52
|
-
.get();
|
53
|
-
if (workAreaDoc.exists) {
|
54
|
-
isWorkAreaDocPresent = true;
|
55
|
-
}
|
56
|
-
if (isWorkAreaDocPresent) {
|
57
|
-
await firestore.collection("CustomCollections")
|
58
|
-
.doc(companyId)
|
59
|
-
.collection("Users")
|
60
|
-
.doc(userId)
|
61
|
-
.update({ workAreas: arrayUnion(objectToSave.city) })
|
62
|
-
} else {
|
63
|
-
await firestore.collection("CustomCollections")
|
64
|
-
.doc(companyId)
|
65
|
-
.collection("Users")
|
66
|
-
.doc(userId)
|
67
|
-
.set({
|
68
|
-
id: userId,
|
69
|
-
workAreas: [objectToSave.city]
|
70
|
-
})
|
71
|
-
}
|
72
|
-
const userInfo = await User.getUserInfoById(firestore, userId,
|
73
|
-
companyId);
|
74
|
-
const customerCardObj = await this.createCustomerCard(customerNUserInfo, userInfo);
|
75
|
-
const userRef = Offline.createRefForUser(firestore, companyId, userId);
|
76
|
-
customerCardObj.id = userRef.id
|
77
|
-
await userRef.set(customerCardObj);
|
78
|
-
await Offline.sendFeedToManagers(firestore, companyId, userId, customerCardObj);
|
79
|
-
await Offline.deleteInfoFromIncoming(firestore, customerNUserInfo.id);
|
80
|
-
console.log("Doc deleted from incoming collection");
|
81
|
-
return new HttpResponseAndErrorHandling(200, "Created", null, null).getSuccessResponse();
|
82
|
-
} catch (error) {
|
83
|
-
console.log(error);
|
84
|
-
return new HttpResponseAndErrorHandling(400, "Failed", null, 400);
|
85
|
-
}
|
86
|
-
}
|
87
|
-
|
88
|
-
static async createCustomerCard(customerInfo: any, userInfo: any) {
|
89
|
-
const incomingExtraData = customerInfo.extra.extraData;
|
90
|
-
const customerName = incomingExtraData.customerName;
|
91
|
-
const userName = userInfo.name;
|
92
|
-
const description = `${customerName} added by ${userName}`;
|
93
|
-
const customerCard: any = { ...customerInfo };
|
94
|
-
const time = customerInfo.createdAt;
|
95
|
-
const address = incomingExtraData.address;
|
96
|
-
const city = incomingExtraData.city;
|
97
|
-
const zipcode = incomingExtraData.zipcode;
|
98
|
-
const contactNo = incomingExtraData.contactNo;
|
99
|
-
const state = incomingExtraData.state;
|
100
|
-
const gstNo = incomingExtraData.gstNo;
|
101
|
-
const contactName = incomingExtraData.contactName;
|
102
|
-
const extraData = {
|
103
|
-
"customerName": customerName,
|
104
|
-
"userName": userName,
|
105
|
-
"time": time,
|
106
|
-
"date": new Date(time).toLocaleDateString(),
|
107
|
-
"address": address,
|
108
|
-
"city": city,
|
109
|
-
"zipcode": zipcode,
|
110
|
-
"contactNo": contactNo,
|
111
|
-
"state": state,
|
112
|
-
"gstNo": gstNo,
|
113
|
-
"contactName": contactName
|
114
|
-
}
|
115
|
-
delete customerCard.extra;
|
116
|
-
customerCard.extraData = extraData;
|
117
|
-
customerCard.description = description;
|
118
|
-
customerCard.actionType = "worklog";
|
119
|
-
return customerCard;
|
120
|
-
}
|
121
|
-
|
122
|
-
static async createObjForAddingCustomer(extraData: any) {
|
123
|
-
const customer = new Customer(extraData.customerName,
|
124
|
-
extraData.address,
|
125
|
-
extraData.zipcode,
|
126
|
-
extraData.city.toUpperCase(),
|
127
|
-
extraData.state.toUpperCase(),
|
128
|
-
extraData.gstNo,
|
129
|
-
extraData.contactName,
|
130
|
-
extraData.contactNo);
|
131
|
-
return customer;
|
132
|
-
}
|
133
|
-
|
134
|
-
static async addCustomerContact(firestore: admin.firestore.Firestore,
|
135
|
-
connection: Pool,
|
136
|
-
customerContactNUserInfo: any) {
|
137
|
-
try {
|
138
|
-
const companyId = customerContactNUserInfo.companyId;
|
139
|
-
const userId = customerContactNUserInfo.userId;
|
140
|
-
const customerId = customerContactNUserInfo.extra.extraData.customerNameId;
|
141
|
-
console.log(companyId, customerId);
|
142
|
-
let contactObj: any = await this.createObjForContact(customerContactNUserInfo.extra.extraData);
|
143
|
-
const contactObjToSave = JSON.parse(JSON.stringify(contactObj));
|
144
|
-
await this.saveContactInfoToDB(connection, contactObjToSave);
|
145
|
-
const userInfo = await User.getUserInfoById(firestore, userId,
|
146
|
-
companyId);
|
147
|
-
const contactCard = await this.createContactCard(customerContactNUserInfo, userInfo);
|
148
|
-
const userRef = Offline.createRefForUser(firestore, companyId, userId);
|
149
|
-
contactCard.id = userRef.id
|
150
|
-
await userRef.set(contactCard);
|
151
|
-
await Offline.sendFeedToManagers(firestore, companyId, userId, contactCard);
|
152
|
-
await Offline.deleteInfoFromIncoming(firestore, customerContactNUserInfo.id);
|
153
|
-
console.log("Doc deleted from incoming collection");
|
154
|
-
return new HttpResponseAndErrorHandling(200, "Success", null, null);
|
155
|
-
} catch (error: any) {
|
156
|
-
return new HttpResponseAndErrorHandling(400, error, null, null);
|
157
|
-
}
|
158
|
-
}
|
159
|
-
|
160
|
-
static async saveContactInfoToDB(connection: Pool, contactInfo: any) {
|
161
|
-
const curdService = new CurdService(connection);
|
162
|
-
|
163
|
-
try {
|
164
|
-
let qryStr = `INSERT INTO Contacts
|
165
|
-
(customerId, alternateContactNo,
|
166
|
-
contactName, contactNo,
|
167
|
-
designation)
|
168
|
-
VALUES ("${contactInfo.customerId}",
|
169
|
-
"${contactInfo.alternateContactNo}",
|
170
|
-
"${contactInfo.contactName}",
|
171
|
-
"${contactInfo.contactNo}",
|
172
|
-
"${contactInfo.designation}")`
|
173
|
-
const result = await curdService.query(qryStr);
|
174
|
-
console.log(result);
|
175
|
-
} catch (error) {
|
176
|
-
console.error(error);
|
177
|
-
}
|
178
|
-
}
|
179
|
-
|
180
|
-
static async createContactCard(contactInfo: any, userInfo: any) {
|
181
|
-
const incomingExtraData = contactInfo.extra.extraData;
|
182
|
-
const customerName = incomingExtraData.customerName;
|
183
|
-
const contactName = incomingExtraData.contactName;
|
184
|
-
const contactNo = incomingExtraData.contactNo;
|
185
|
-
const designation = incomingExtraData.designation;
|
186
|
-
const userName = userInfo.name;
|
187
|
-
const description = `${contactName} of ${customerName} added by ${userName}`;
|
188
|
-
const contactCard: any = { ...contactInfo };
|
189
|
-
const time = contactInfo.createdAt;
|
190
|
-
const extraData = {
|
191
|
-
"customerName": customerName,
|
192
|
-
"userName": userName,
|
193
|
-
"time": time,
|
194
|
-
"contactName": contactName,
|
195
|
-
"contactNo": contactNo,
|
196
|
-
"designation": designation,
|
197
|
-
"date": new Date(time).toLocaleDateString(),
|
198
|
-
"alternateContactNo": incomingExtraData.alternateContactNo
|
199
|
-
}
|
200
|
-
delete contactCard.extra;
|
201
|
-
contactCard.extraData = extraData;
|
202
|
-
contactCard.description = description;
|
203
|
-
contactCard.actionType = "worklog";
|
204
|
-
return contactCard;
|
205
|
-
}
|
206
|
-
|
207
|
-
static async createObjForContact(contactInfo: any) {
|
208
|
-
const customerContact = new CustomerContact(
|
209
|
-
contactInfo.customerNameId,
|
210
|
-
contactInfo.contactName,
|
211
|
-
contactInfo.contactNo,
|
212
|
-
contactInfo.alternateContactNo,
|
213
|
-
contactInfo.designation
|
214
|
-
)
|
215
|
-
return customerContact;
|
216
|
-
}
|
217
|
-
|
218
|
-
static async addCustomers(firestore: admin.firestore.Firestore, nickName: string, customerInfo: any) {
|
219
|
-
let companyId = await Company.getCompanyIdByNickName(firestore, nickName)
|
220
|
-
const filteredCustomerInfo: any = {
|
221
|
-
GSTNo: customerInfo.gstNo,
|
222
|
-
address: customerInfo.address,
|
223
|
-
city: customerInfo.city,
|
224
|
-
contactName: null,
|
225
|
-
contactNo: null,
|
226
|
-
customerName: customerInfo.customerName,
|
227
|
-
state: customerInfo.state,
|
228
|
-
zipcode: customerInfo.zipcode
|
229
|
-
}
|
230
|
-
let isCustomerPresent = await firestore.collection("CustomCollections").doc(companyId).collection("Customers").where("customerName", "==", filteredCustomerInfo.customerName).get();
|
231
|
-
isCustomerPresent.forEach(doc => console.log(doc.data()))
|
232
|
-
console.log(isCustomerPresent.empty);
|
233
|
-
if (isCustomerPresent.empty) {
|
234
|
-
let customerSnapshot = await firestore.collection("CustomCollections").doc(companyId).collection("Customers").doc()
|
235
|
-
let id = customerSnapshot.id
|
236
|
-
filteredCustomerInfo.id = id
|
237
|
-
customerSnapshot.set(filteredCustomerInfo)
|
238
|
-
return `${id} added successfully`
|
239
|
-
}
|
240
|
-
}
|
241
|
-
|
242
|
-
static async addCustomerContactViaCsv(firestore: admin.firestore.Firestore, nickName: string, customerContactInfo: any) {
|
243
|
-
let companyId = await Company.getCompanyIdByNickName(firestore, nickName)
|
244
|
-
let customerSnapshot = await firestore.collection("CustomCollections").doc(companyId).collection("Customers").where("customerId", "==", customerContactInfo.companyId).get()
|
245
|
-
let customerInfoId = customerSnapshot.docs[0].data().id
|
246
|
-
let customerContactSnapshot = await firestore.collection("CustomCollections").doc(companyId).collection("Customers").doc(customerInfoId).collection("Contacts").doc()
|
247
|
-
customerContactInfo.id = customerContactSnapshot.id
|
248
|
-
customerContactInfo.customerName = customerSnapshot.docs[0].data().customerName
|
249
|
-
customerContactSnapshot.set(customerContactInfo)
|
250
|
-
return "Success"
|
251
|
-
}
|
252
|
-
|
253
|
-
static async addCustomerContactsViaJSON(firestore: admin.firestore.Firestore, nickName: string, customerContactInfo: any) {
|
254
|
-
let companyId = await Company.getCompanyIdByNickName(firestore, nickName);
|
255
|
-
let customerSnapshot = await firestore.collection("CustomCollections").doc(companyId).collection("Customers").where("customerName", "==", customerContactInfo.customerName).get();
|
256
|
-
let customerInfoId = customerSnapshot.docs[0].data().id;
|
257
|
-
let contactSnapshot = await firestore.collection("CustomCollections").doc(companyId).collection("Customers").doc(customerInfoId).collection("Contacts").doc();
|
258
|
-
contactSnapshot.set(customerContactInfo.contactInfoToSave);
|
259
|
-
return `${contactSnapshot.id} in ${customerContactInfo.customerName}`;
|
260
|
-
}
|
261
|
-
|
262
|
-
static async deleteCustomerContact(firestore: admin.firestore.Firestore, nickName: string, customerContactInfo: any) {
|
263
|
-
let companyId = await Company.getCompanyIdByNickName(firestore, nickName)
|
264
|
-
let customerSnapshot = await firestore.collection("CustomCollections").doc(companyId).collection("Customers").where("customerId", "==", customerContactInfo.companyId).get()
|
265
|
-
let customerInfoId = customerSnapshot.docs[0].data().id
|
266
|
-
let customerContactSnapshot = await firestore.collection("CustomCollections").doc(companyId).collection("Customers").doc(customerInfoId).collection("Contacts").get()
|
267
|
-
customerContactSnapshot.forEach((doc) => {
|
268
|
-
doc.ref.delete()
|
269
|
-
})
|
270
|
-
return "deleted"
|
271
|
-
}
|
272
|
-
|
273
|
-
static async getCustomer(firestore: admin.firestore.Firestore, connection: Pool, companyId: string, phone: string) {
|
274
|
-
const curdService = new CurdService(connection)
|
275
|
-
let userWorkAreaDoc: any = await CustomCollection.getUserWorkAreaList(firestore, companyId, phone)
|
276
|
-
let userWorkAreaList = JSON.stringify(userWorkAreaDoc.workAreas).replace("[", "").replace("]", "")
|
277
|
-
let formattedCustomerList = []
|
278
|
-
if (userWorkAreaList.length) {
|
279
|
-
try {
|
280
|
-
let qryStr = `select c.id , c.customerName , c.city from Customers as c where city in (${userWorkAreaList}) or state in (${userWorkAreaList})`
|
281
|
-
let result: any = await curdService.query(qryStr)
|
282
|
-
for (let customer of result) {
|
283
|
-
formattedCustomerList.push({
|
284
|
-
id: customer.id,
|
285
|
-
label: customer.customerName + ` (${customer.city})`
|
286
|
-
})
|
287
|
-
}
|
288
|
-
} catch (error) {
|
289
|
-
console.log(error)
|
290
|
-
}
|
291
|
-
}
|
292
|
-
return formattedCustomerList
|
293
|
-
|
294
|
-
}
|
295
|
-
|
296
|
-
static async getCustomerContact(firestore: admin.firestore.Firestore, connection: Pool, companyId: string, customerId: string) {
|
297
|
-
const curdService = new CurdService(connection);
|
298
|
-
try {
|
299
|
-
let qryStr = `SELECT con.id , con.contactName FROM Contacts as con where customerId = ${customerId};`
|
300
|
-
let result: any = await curdService.query(qryStr)
|
301
|
-
let formattedCustomerList = []
|
302
|
-
for (let contact of result) {
|
303
|
-
formattedCustomerList.push({
|
304
|
-
id: contact.id,
|
305
|
-
label: contact.contactName
|
306
|
-
})
|
307
|
-
}
|
308
|
-
return formattedCustomerList
|
309
|
-
} catch (error) {
|
310
|
-
console.log(error)
|
311
|
-
return error
|
312
|
-
}
|
313
|
-
}
|
314
|
-
|
315
|
-
static async insertCustomerDetails(connection: Pool) {
|
316
|
-
const curdService = new CurdService(connection);
|
317
|
-
try {
|
318
|
-
let path = "/home/atishae/atishae/mobiOffice_web/mobioffice-cli/scripts/benaraScripts/customerList.json"
|
319
|
-
const customerInfo = readFileSync(path, "utf-8");
|
320
|
-
const customerList = await JSON.parse(customerInfo);
|
321
|
-
console.log(customerList.length)
|
322
|
-
let count = 0
|
323
|
-
for (let customer of customerList) {
|
324
|
-
let qryStr = `INSERT INTO Customers (companyId, GSTNo, address, city, contactName, contactNo, customerName, state, zipcode) VALUES ("GC5BOfo2Ibma9CJ4NRpM", "${customer.GSTNo}", "${customer.address}", "${customer.city}", "${customer.contactName}", "${customer.contactNo}", "${customer.customerName}", "${customer.state}", "${customer.zipcode}")`
|
325
|
-
await curdService.query(qryStr)
|
326
|
-
count++
|
327
|
-
console.log(count)
|
328
|
-
}
|
329
|
-
return customerList.length
|
330
|
-
} catch (error) {
|
331
|
-
console.log(error)
|
332
|
-
}
|
333
|
-
}
|
334
|
-
|
335
|
-
static async insertCustomerContact(connection: Pool) {
|
336
|
-
const curdService = new CurdService(connection)
|
337
|
-
try {
|
338
|
-
let path = "/home/atishae/atishae/mobiOffice_web/json/benara/data/customerContacts.json"
|
339
|
-
const contactInfo = readFileSync(path, "utf-8");
|
340
|
-
const contactList = await JSON.parse(contactInfo);
|
341
|
-
// console.log(contactList[2452])
|
342
|
-
let count = 0
|
343
|
-
for (let contact of contactList) {
|
344
|
-
count++
|
345
|
-
console.log(count)
|
346
|
-
let customerQry = `SELECT c.id FROM Customers as c where c.customerName = "${contact.customerName}"`
|
347
|
-
let customerIdResult: any = await curdService.query(customerQry)
|
348
|
-
let qryStr = `INSERT INTO Contacts (customerId, alternateContactNo, contactName, contactNo, designation) VALUES ("${customerIdResult[0].id}", "${contact.contactInfoToSave.alternateContactNo}", "${contact.contactInfoToSave.contactName}", "${contact.contactInfoToSave.contactNo}", ${null})`
|
349
|
-
await curdService.query(qryStr)
|
350
|
-
}
|
351
|
-
return contactList.length
|
352
|
-
} catch (error) {
|
353
|
-
console.log(error)
|
354
|
-
}
|
355
|
-
}
|
356
|
-
|
357
|
-
static async inertUserWorkArea(connection: Pool) {
|
358
|
-
try {
|
359
|
-
let path = "/home/atishae/atishae/mobiOffice_web/json/benara/data/userworkarea.json"
|
360
|
-
const workAreaInfo = readFileSync(path, "utf-8");
|
361
|
-
const workAreaList = await JSON.parse(workAreaInfo);
|
362
|
-
let count = 0
|
363
|
-
for (let userArea of workAreaList) {
|
364
|
-
if (userArea.id == "47RfcTj4d2PBailEJvVpbgQ9EAf1") {
|
365
|
-
let workArea = JSON.stringify(userArea.workAreas).replace("[", "").replace("]", "")
|
366
|
-
console.log(workArea)
|
367
|
-
break
|
368
|
-
}
|
369
|
-
count++
|
370
|
-
console.log(count)
|
371
|
-
|
372
|
-
// let qryStr = `INSERT INTO WorkArea (companyId, userId, workArea) VALUES ("GC5BOfo2Ibma9CJ4NRpM", "${userArea.id}", "${userArea.workAreas}",)`
|
373
|
-
// await connection.execute(qryStr)
|
374
|
-
}
|
375
|
-
return workAreaList.length
|
376
|
-
} catch (error) {
|
377
|
-
console.log(error)
|
378
|
-
}
|
379
|
-
}
|
380
|
-
}
|
381
|
-
|
382
|
-
export { CustomerServices };
|
package/src/services/meeting.ts
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
import * as admin from "firebase-admin";
|
2
|
-
import { Action } from "../models/action.model";
|
3
|
-
import { Company } from "../models/company.model";
|
4
|
-
import { Feeds } from "../models/feed.models";
|
5
|
-
import { MeetingSummary } from "../models/meeting.model";
|
6
|
-
import { Offline } from "../models/offline.model";
|
7
|
-
import { HttpResponseAndErrorHandling } from "../models/response.model";
|
8
|
-
import { User } from "../models/user.model";
|
9
|
-
import { Pool } from 'mysql2';
|
10
|
-
|
11
|
-
class MeetingServices {
|
12
|
-
static async addMeetingInfo(firestore: admin.firestore.Firestore,
|
13
|
-
meetingsDBConnection:Pool,
|
14
|
-
storageRef: any,
|
15
|
-
meetingInfo: any) {
|
16
|
-
try {
|
17
|
-
let incomingDocId = meetingInfo.id
|
18
|
-
const companyId = meetingInfo.companyId;
|
19
|
-
const createdAt = meetingInfo.createdAt;
|
20
|
-
const userId = meetingInfo.userId;
|
21
|
-
const meetingSummary = await this.createMeetingSummary(storageRef, meetingInfo);
|
22
|
-
const meetingDoc = {...meetingInfo};
|
23
|
-
const contactName = meetingInfo.extra.extraData.contactName;
|
24
|
-
const customerName = meetingInfo.extra.extraData.customerName;
|
25
|
-
meetingDoc.extraData = meetingSummary;
|
26
|
-
delete meetingDoc.extra;
|
27
|
-
const description = `met with ${contactName} of ${customerName}`;
|
28
|
-
const meetingDocToSave = JSON.parse(JSON.stringify(meetingDoc));
|
29
|
-
meetingDocToSave.actionType = meetingInfo.extra.actionType
|
30
|
-
meetingDocToSave.description = description;
|
31
|
-
meetingDocToSave.extraData.date = createdAt
|
32
|
-
meetingDocToSave.extraData["Start Time"] = createdAt
|
33
|
-
meetingDocToSave.extraData["End Time"] = null
|
34
|
-
console.log(meetingDocToSave);
|
35
|
-
const actionId = meetingInfo.extra.actionId;
|
36
|
-
const meetingDocRef = firestore.collection("Companies")
|
37
|
-
.doc(companyId)
|
38
|
-
.collection("Actions")
|
39
|
-
.doc(actionId)
|
40
|
-
.collection("meetings")
|
41
|
-
.doc();
|
42
|
-
meetingDocToSave.eventId = meetingDocRef.id
|
43
|
-
meetingDocToSave.id = meetingDocRef.id
|
44
|
-
meetingDocRef.set(meetingDocToSave);
|
45
|
-
let userDetails = await User.getUserInfoById(firestore,userId,companyId)
|
46
|
-
let userName = userDetails?.name
|
47
|
-
await MeetingSummary.syncReportDBFirebaseUserEntries(meetingsDBConnection,meetingDocToSave,userName)
|
48
|
-
const userRef = await Offline.createRefForUser(firestore, companyId, userId);
|
49
|
-
meetingDocToSave.id = userRef.id
|
50
|
-
await userRef.set(meetingDocToSave);
|
51
|
-
console.log("Sent feed to user");
|
52
|
-
await Offline.sendFeedToManagers(firestore, companyId, userId, meetingDocToSave);
|
53
|
-
console.log("Sent feeds to managers");
|
54
|
-
await Offline.deleteInfoFromIncoming(firestore, incomingDocId);
|
55
|
-
console.log("Document deleted from incoming");
|
56
|
-
return new HttpResponseAndErrorHandling(200, "Created", null, null).getSuccessResponse();
|
57
|
-
} catch (error) {
|
58
|
-
console.log(error)
|
59
|
-
return new HttpResponseAndErrorHandling(400, "Failed", null, 400).getErrorResponse();
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
static async createMeetingSummary(storageRef: any,
|
64
|
-
meetingInfo: any) {
|
65
|
-
try {
|
66
|
-
const actionName = meetingInfo.actionName;
|
67
|
-
const incomingExtraData = meetingInfo.extra.extraData;
|
68
|
-
const contactName = incomingExtraData.contactName;
|
69
|
-
const customerName = incomingExtraData.customerName;
|
70
|
-
const base64Img = incomingExtraData.meetingImage;
|
71
|
-
const createdAt = meetingInfo.createdAt;
|
72
|
-
const meetingImageUrl = await Offline.uploadImg(storageRef,
|
73
|
-
base64Img,
|
74
|
-
actionName,
|
75
|
-
createdAt);
|
76
|
-
const meetingSummary = new MeetingSummary(customerName,
|
77
|
-
contactName,
|
78
|
-
meetingImageUrl);
|
79
|
-
return meetingSummary;
|
80
|
-
} catch (error: any) {
|
81
|
-
console.log(error);
|
82
|
-
throw new Error(error);
|
83
|
-
}
|
84
|
-
}
|
85
|
-
|
86
|
-
static async getOngoingMeetingsList(firestore:admin.firestore.Firestore,nickName:string,phone:string){
|
87
|
-
let companyId = await Company.getCompanyIdByNickName(firestore,nickName)
|
88
|
-
let actionId = await Action.getActionId(firestore,companyId,"meeting")
|
89
|
-
let userId = await User.getUserIdByPhone(firestore,phone)
|
90
|
-
const meetingDocList = await MeetingServices.getMeetingsListByUserId(firestore,companyId,actionId,userId)
|
91
|
-
return meetingDocList
|
92
|
-
}
|
93
|
-
|
94
|
-
static async getMeetingsListByUserId(firestore:admin.firestore.Firestore,companyId:string,actionId:string,userId:string){
|
95
|
-
const meetingDocRef = await firestore.collection("Companies")
|
96
|
-
.doc(companyId)
|
97
|
-
.collection("Actions")
|
98
|
-
.doc(actionId)
|
99
|
-
.collection("meetings")
|
100
|
-
.where("userId","==",userId)
|
101
|
-
.get()
|
102
|
-
return meetingDocRef.docs.map((doc)=>{
|
103
|
-
return doc.data()
|
104
|
-
})
|
105
|
-
|
106
|
-
}
|
107
|
-
|
108
|
-
static async updateFeedForEndMeeting(firestore:admin.firestore.Firestore,meetingsDBConnection:Pool,companyId:string,userId:string,eventId:string,incomingDocId:string){
|
109
|
-
let time = new Date().getTime()
|
110
|
-
await Action.updateMeetingStatus(firestore,companyId,userId,eventId,time)
|
111
|
-
await MeetingSummary.updateEndTimeToReportDB(meetingsDBConnection,eventId,time)
|
112
|
-
let managersList = await Offline.getUserManagersList(firestore, companyId, userId);
|
113
|
-
for(let manager of managersList){
|
114
|
-
await Feeds.updateEndMeetingsTimeInFeeds(firestore,manager,companyId,eventId,time)
|
115
|
-
}
|
116
|
-
await Feeds.updateEndMeetingsTimeInFeeds(firestore,userId,companyId,eventId,time)
|
117
|
-
await Offline.deleteInfoFromIncoming(firestore,incomingDocId);
|
118
|
-
return "success"
|
119
|
-
}
|
120
|
-
|
121
|
-
}
|
122
|
-
|
123
|
-
export { MeetingServices }
|
package/test/1.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
/* import { Company } from "./models/company.model.js";
|
2
|
-
import { User } from "./models/user.model.js";
|
3
|
-
|
4
|
-
|
5
|
-
await mj.getUserLocation();
|
6
|
-
*/
|
7
|
-
// import admin from "./db.js";
|
8
|
-
// import {License} from "../src/models/license.model";
|
9
|
-
// let t = admin.firestore.Timestamp.now();
|
10
|
-
// let company="";
|
11
|
-
// let user=""
|
12
|
-
// let user_status = await License.validateUserLicense(admin.firestore(),t,company,user)
|
13
|
-
// console.log(user_status);
|
package/test/db.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import admin from "firebase-admin";
|
2
|
-
import { fireConfig } from "./firebaseConfig";
|
3
|
-
|
4
|
-
try {
|
5
|
-
admin.initializeApp({
|
6
|
-
credential: admin.credential.cert(fireConfig),
|
7
|
-
});
|
8
|
-
console.log("Initialized.");
|
9
|
-
} catch (error) {
|
10
|
-
/*
|
11
|
-
* We skip the "already exists" message which is
|
12
|
-
* not an actual error when we're hot-reloading.
|
13
|
-
*/
|
14
|
-
if (!/already exists/u.test(error.message)) {
|
15
|
-
console.error("Firebase admin initialization error", error.stack);
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
export default admin;
|
package/test/firebaseConfig.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export const fireConfig = {};
|
package/tsconfig.json
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "ESNext",
|
4
|
-
"module": "CommonJS",
|
5
|
-
"moduleResolution": "Node",
|
6
|
-
"strict": true,
|
7
|
-
"rootDir": "src",
|
8
|
-
"esModuleInterop": true,
|
9
|
-
"resolveJsonModule": true,
|
10
|
-
"skipLibCheck": true,
|
11
|
-
"outDir": "./lib",
|
12
|
-
"declaration": true
|
13
|
-
},
|
14
|
-
"include": ["src/**/*.ts"],
|
15
|
-
"exclude": ["node_modules", "lib", ".vscode"]
|
16
|
-
}
|