tango-app-api-client 3.1.17 → 3.1.19-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-client",
3
- "version": "3.1.17",
3
+ "version": "3.1.19-alpha.1",
4
4
  "description": "client",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -25,8 +25,8 @@
25
25
  "mongodb": "^6.3.0",
26
26
  "nodemon": "^3.0.3",
27
27
  "swagger-ui-express": "^5.0.0",
28
- "tango-api-schema": "^2.0.113",
29
- "tango-app-api-middleware": "^3.1.19",
28
+ "tango-api-schema": "^2.0.148",
29
+ "tango-app-api-middleware": "^3.1.30",
30
30
  "winston": "^3.11.0",
31
31
  "winston-daily-rotate-file": "^5.0.0"
32
32
  },
@@ -1,5 +1,5 @@
1
1
  import { billingDetailsUpdate, brandInfoUpdate, domainDetailsConfigurationUpdate, featureConfigurationUpdate, getClientData, signatoryDetailsUpdate, ticketConfigurationUpdate, documentsUpdate, getUserData, auditConfigurationUpdate, auditConfigurationGet, CsmUsersGet, OpsUsersGet, userConfigurationUpdate, findClient, aggregateClient, createAuditQueue, findOne, insert, update, findOneClient, updateOneClient } from '../service/client.service.js';
2
- import { checkFileExist, fileUpload, signedUrl, chunkArray, download, logger, getOpenSearchData, insertOpenSearchData, sendEmailWithSES } from 'tango-app-api-middleware';
2
+ import { checkFileExist, fileUpload, signedUrl, chunkArray, download, logger, getOpenSearchData, insertOpenSearchData, sendEmailWithSES, createCustomer, createVirtualAccount } from 'tango-app-api-middleware';
3
3
  import { countDocumentsUser, findOneAndUpdateUser, findOneUser, getUserNameEmailById, updateManyUser } from '../service/user.service.js';
4
4
  import { aggregateStore, countDocumentsStore, findStore, findOneStore, updateManyStore } from '../service/store.service.js';
5
5
  import { aggregateCamera, countDocumentsCamera } from '../service/camera.service.js';
@@ -11,7 +11,9 @@ import { join } from 'path';
11
11
  import { readFileSync } from 'fs';
12
12
  import handlebars from 'handlebars';
13
13
  import { countDocumentsGroup, createGroupModel, findOneGroup } from '../service/group.service.js';
14
- import { deleteOneAuthentication } from '../service/authentication.service.js';
14
+ // import { deleteOneAuthentication } from '../service/authentication.service.js';
15
+ import { createBilling } from '../service/billing.service.js';
16
+ import { createPaymentAccount } from '../service/paymentAccount.service.js';
15
17
 
16
18
 
17
19
  export async function create( req, res ) {
@@ -75,6 +77,32 @@ export async function create( req, res ) {
75
77
 
76
78
  const insertedClientRecord = await findOneClient( { clientId: record.clientId }, {} );
77
79
 
80
+ const customer = await createCustomer( { name: user.userName, email: user.email, clientId: insertedClientRecord.clientId } );
81
+
82
+ const virtualAccount = await createVirtualAccount( { receiverTypes: [ 'bank_account' ], description: `Virtual Account for ${insertedClientRecord.clientId}`,
83
+ customerId: customer.id, notes: { createdAt: new Date(), createdBy: req.user?.email } } );
84
+
85
+ const paymentAccount = {
86
+ clientId: insertedClientRecord.clientId,
87
+ virtualAccId: virtualAccount?.id,
88
+ bankAccId: virtualAccount?.receivers[0]?.id,
89
+ accountNumber: virtualAccount?.receivers[0]?.account_number,
90
+ ifsc: virtualAccount?.receivers[0]?.ifsc,
91
+ customerId: virtualAccount?.customer_id,
92
+ status: virtualAccount?.status,
93
+ paymentType: virtualAccount?.entity,
94
+ branch: 'RS Puram, Coimbatore',
95
+ currency: 'dollar',
96
+ };
97
+
98
+ if ( leadRecord.countryCode === '91' ) {
99
+ paymentAccount.currency = 'inr';
100
+ }
101
+
102
+
103
+ await createPaymentAccount( paymentAccount );
104
+
105
+
78
106
  const defaultGroup = {
79
107
  'groupName': 'All stores',
80
108
  'description': 'Contains all the onboarded stores',
@@ -85,6 +113,13 @@ export async function create( req, res ) {
85
113
 
86
114
  await createGroupModel( defaultGroup );
87
115
 
116
+ const primaryBillingGroup = {
117
+ clientId: insertedClientRecord.clientId,
118
+ isPrimary: true,
119
+ };
120
+
121
+ await createBilling( primaryBillingGroup );
122
+
88
123
  const createdGroup = await findOneGroup( { clientId: insertedClientRecord.clientId, isDefault: true }, {} );
89
124
 
90
125
  let oldGroup = {
@@ -251,7 +286,7 @@ export async function create( req, res ) {
251
286
  permission: getPermission?.permission,
252
287
  clientId: String( tangoId ),
253
288
  };
254
- await deleteOneAuthentication( { user: user?._id, type: 'retail' } );
289
+ // await deleteOneAuthentication( { user: user?._id, type: 'retail' } );
255
290
  await findOneAndUpdateUser( userQuery, userRecord );
256
291
  await createAuditQueue( generatedName );
257
292
  return res.sendSuccess( { result: { clientId: String( tangoId ) } } );
@@ -813,7 +848,7 @@ export async function updateFeatureConfiguration( req, res ) {
813
848
  close: req.body?.close, conversionCalculation: req.body?.conversionCalculation, conversionCondition: req.body?.conversionCondition,
814
849
  conversionValue: req.body?.conversionValue, infraAlertCondition: req.body?.infraAlertCondition, infraAlertValue: req.body?.infraAlertValue, isFootfallDirectory: req.body?.isFootfallDirectory,
815
850
  isNormalized: req.body?.isNormalized, isPasserByData: req.body?.isPasserByData, missedOpportunityCalculation: req.body?.missedOpportunityCalculation, open: req.body?.open,
816
- isExcludedArea: req.body?.isExcludedArea,
851
+ isExcludedArea: req.body?.isExcludedArea, isCameraDisabled: req.body?.isCameraDisabled, isbillingDisabled: req.body?.isbillingDisabled,
817
852
  } );
818
853
 
819
854
  let updateKeys = [];
@@ -10,14 +10,6 @@ export const clientDocs = {
10
10
  tags: [ 'Client' ],
11
11
  description: 'lead appoved and create a new client',
12
12
  operationId: 'create',
13
- parameters: [ {
14
- in: 'path',
15
- name: 'id',
16
- required: true,
17
- schema: {
18
- type: 'string',
19
- },
20
- } ],
21
13
  requestBody: {
22
14
  content: {
23
15
  'application/json': {
@@ -109,6 +109,8 @@ export const featureConfigurationSchemaBody = joi.object(
109
109
  isPasserByData: joi.boolean().optional(),
110
110
  isFootfallDirectory: joi.boolean().optional(),
111
111
  isExcludedArea: joi.boolean().optional(),
112
+ isCameraDisabled: joi.boolean().optional(),
113
+ isbillingDisabled: joi.boolean().optional(),
112
114
  },
113
115
  );
114
116
 
@@ -0,0 +1,6 @@
1
+ import billingModel from 'tango-api-schema/schema/billing.model.js';
2
+
3
+
4
+ export async function createBilling( field = {} ) {
5
+ return await billingModel.create( field );
6
+ };
@@ -133,6 +133,7 @@ export function featureConfigurationUpdate( {
133
133
  close, conversionCalculation, conversionCondition,
134
134
  conversionValue, infraAlertCondition, infraAlertValue, isFootfallDirectory,
135
135
  isNormalized, isPasserByData, missedOpportunityCalculation, open, isExcludedArea,
136
+ isCameraDisabled, isbillingDisabled,
136
137
  } ) {
137
138
  return clientModel.updateOne( { clientId: clientId },
138
139
  {
@@ -153,6 +154,8 @@ export function featureConfigurationUpdate( {
153
154
  'featureConfigs.isFootfallDirectory': isFootfallDirectory,
154
155
  'featureConfigs.isExcludedArea': isExcludedArea,
155
156
  'featureConfigs.updateFeatureConfig': false,
157
+ 'featureConfigs.isCameraDisabled': isCameraDisabled,
158
+ 'featureConfigs.isbillingDisabled': isbillingDisabled,
156
159
  },
157
160
  } );
158
161
  }
@@ -0,0 +1,6 @@
1
+ import paymentAccount from 'tango-api-schema/schema/paymentAccount.model.js';
2
+
3
+
4
+ export async function createPaymentAccount( field ) {
5
+ return await paymentAccount.create( field );
6
+ };