tango-app-api-payment-subscription 3.4.0-alpha.7 → 3.4.0-alpha.8
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
|
/* eslint-disable new-cap */
|
|
3
|
-
import { logger, download, sendEmailWithSES, insertOpenSearchData, getOpenSearchData, updateOpenSearchData, getOpenSearchById } from 'tango-app-api-middleware';
|
|
3
|
+
import { logger, download, sendEmailWithSES, insertOpenSearchData, getOpenSearchData, updateOpenSearchData, getOpenSearchById, sendTeamsNotification } from 'tango-app-api-middleware';
|
|
4
4
|
import * as paymentService from '../services/clientPayment.services.js';
|
|
5
5
|
import * as basePriceService from '../services/basePrice.service.js';
|
|
6
6
|
import * as storeService from '../services/store.service.js';
|
|
@@ -3244,7 +3244,7 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3244
3244
|
let getClient = await paymentService.findOne( { clientId: requestClient[clientIndex] } );
|
|
3245
3245
|
if ( getClient ) {
|
|
3246
3246
|
let getBaseprice = await basePriceService.findOne( { clientId: requestClient[clientIndex] } );
|
|
3247
|
-
let getStore = await storeService.find( { 'clientId': requestClient[clientIndex]
|
|
3247
|
+
let getStore = await storeService.find( { 'clientId': requestClient[clientIndex] } );
|
|
3248
3248
|
console.log( '==========>', getStore.length );
|
|
3249
3249
|
if ( getStore.length ) {
|
|
3250
3250
|
let storeList = [];
|
|
@@ -3268,6 +3268,7 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3268
3268
|
{
|
|
3269
3269
|
$project: {
|
|
3270
3270
|
'stores.daysDifference': 1,
|
|
3271
|
+
'stores.daysDifferenceTrax': 1,
|
|
3271
3272
|
'dateString': 1,
|
|
3272
3273
|
},
|
|
3273
3274
|
},
|
|
@@ -3282,24 +3283,47 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3282
3283
|
let cameraDetails = await cameraService.find( { storeId: getStore[storeIndex].storeId, clientId: requestClient[clientIndex], isActivated: true, isUp: true }, { streamName: 1 } );
|
|
3283
3284
|
let firstDate = dayjs( getStore[storeIndex]?.edge?.firstFileDate ).format( 'YYYY-MM-DD' );
|
|
3284
3285
|
let workingdays;
|
|
3286
|
+
let workingdaystrax;
|
|
3285
3287
|
const givenDate = dayjs( requestData.date );
|
|
3286
3288
|
|
|
3287
3289
|
const isFirstDayOfMonth = givenDate.isSame( dayjs().startOf( 'month' ), 'day' );
|
|
3288
|
-
if (
|
|
3290
|
+
if ( getStore[storeIndex]?.edge.firstFile ) {
|
|
3291
|
+
if ( firstDate < requestData.date && getStore[storeIndex]?.status == 'active' &&
|
|
3292
|
+
dailyData[0]?.dateString != dayjs( requestData.date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) ) {
|
|
3293
|
+
if ( dailyData.length && dailyData[0]?.stores?.daysDifference&&!isFirstDayOfMonth ) {
|
|
3294
|
+
workingdays = dailyData[0]?.stores?.daysDifference + 1;
|
|
3295
|
+
} else {
|
|
3296
|
+
workingdays = 1;
|
|
3297
|
+
}
|
|
3298
|
+
} else {
|
|
3299
|
+
if ( dailyData[0]?.stores?.daysDifference&&!isFirstDayOfMonth ) {
|
|
3300
|
+
workingdays = dailyData[0]?.stores?.daysDifference;
|
|
3301
|
+
} else {
|
|
3302
|
+
workingdays = 0;
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
console.log( dailyData[0]?.stores );
|
|
3307
|
+
if ( getStore[storeIndex]?.status == 'active' &&
|
|
3289
3308
|
dailyData[0]?.dateString != dayjs( requestData.date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) ) {
|
|
3290
|
-
if ( dailyData.length && dailyData[0]?.stores?.
|
|
3291
|
-
|
|
3309
|
+
if ( dailyData.length && dailyData[0]?.stores?.daysDifferenceTrax&&!isFirstDayOfMonth ) {
|
|
3310
|
+
workingdaystrax = dailyData[0]?.stores?.daysDifferenceTrax + 1;
|
|
3292
3311
|
} else {
|
|
3293
|
-
|
|
3312
|
+
workingdaystrax = 1;
|
|
3294
3313
|
}
|
|
3295
3314
|
} else {
|
|
3296
|
-
if ( dailyData[0]?.stores?.
|
|
3297
|
-
|
|
3315
|
+
if ( dailyData[0]?.stores?.daysDifferenceTrax&&!isFirstDayOfMonth ) {
|
|
3316
|
+
workingdaystrax = dailyData[0]?.stores?.daysDifferenceTrax;
|
|
3298
3317
|
} else {
|
|
3299
|
-
|
|
3318
|
+
workingdaystrax = 0;
|
|
3300
3319
|
}
|
|
3301
3320
|
}
|
|
3302
3321
|
let priceDetails = getClient.priceType == 'standard' ? getBaseprice.standard : getBaseprice.step;
|
|
3322
|
+
priceDetails = priceDetails.filter( ( item1 ) =>
|
|
3323
|
+
getClient.planDetails.product.some( ( item2 ) =>
|
|
3324
|
+
item2.productName === item1.productName && item2.status === 'live',
|
|
3325
|
+
),
|
|
3326
|
+
);
|
|
3303
3327
|
for ( let storeProductIndex = 0; storeProductIndex < getStore[storeIndex].product.length; storeProductIndex++ ) {
|
|
3304
3328
|
let productDetails;
|
|
3305
3329
|
if ( getClient.priceType == 'standard' ) {
|
|
@@ -3316,11 +3340,11 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3316
3340
|
productDetails = stepProductDetails[stepProductDetails.length - 1];
|
|
3317
3341
|
}
|
|
3318
3342
|
}
|
|
3319
|
-
|
|
3320
3343
|
if ( productDetails ) {
|
|
3344
|
+
console.log( '-------', workingdays, workingdaystrax, productDetails.productName );
|
|
3321
3345
|
let newObject = {
|
|
3322
3346
|
productName: productDetails.productName,
|
|
3323
|
-
workingdays: workingdays,
|
|
3347
|
+
workingdays: productDetails.productName==='tangoTrax'?workingdaystrax:workingdays,
|
|
3324
3348
|
};
|
|
3325
3349
|
productList.push( newObject );
|
|
3326
3350
|
}
|
|
@@ -3335,6 +3359,7 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3335
3359
|
edgefirstFileDate: getStore[storeIndex]?.edge?.firstFileDate || null,
|
|
3336
3360
|
date: new Date( requestData.date ),
|
|
3337
3361
|
daysDifference: workingdays,
|
|
3362
|
+
daysDifferenceTrax: workingdaystrax,
|
|
3338
3363
|
products: productList,
|
|
3339
3364
|
camera: cameraDetails.map( ( item ) => item.streamName ),
|
|
3340
3365
|
cameraCount: cameraDetails.length,
|
|
@@ -3343,6 +3368,7 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3343
3368
|
console.log( storeIndex, getStore.length - 1 );
|
|
3344
3369
|
if ( storeIndex == getStore.length - 1 ) {
|
|
3345
3370
|
let activestores = storeList.filter( ( store ) => store.status=='active' );
|
|
3371
|
+
console.log( '------', activestores.length );
|
|
3346
3372
|
let params = {
|
|
3347
3373
|
clientId: requestClient[clientIndex],
|
|
3348
3374
|
stores: storeList,
|
|
@@ -3369,6 +3395,13 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3369
3395
|
}
|
|
3370
3396
|
// console.log( clientIndex, requestClient.length-1 );
|
|
3371
3397
|
if ( clientIndex == requestClient.length - 1 ) {
|
|
3398
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
3399
|
+
let totalcount = await dailyPriceService.find( { dateString: dayjs( requestData.date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) } );
|
|
3400
|
+
let teamsMsg = `${totalcount.length} clients data is inserted on ${dayjs( requestData.date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' )}`;
|
|
3401
|
+
console.log( teamsMsg );
|
|
3402
|
+
if ( teamsAlertUrls.invoiceAlert ) {
|
|
3403
|
+
sendTeamsNotification( teamsAlertUrls.invoiceAlert, teamsMsg );
|
|
3404
|
+
}
|
|
3372
3405
|
return res.sendSuccess( 'Price Details Inserted Successfully' );
|
|
3373
3406
|
}
|
|
3374
3407
|
}
|