tango-app-api-client 3.1.18 → 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.18",
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.144",
29
- "tango-app-api-middleware": "^3.1.26",
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 ) } } );
@@ -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
+ };
@@ -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
+ };