tango-app-api-payment-subscription 3.4.3 → 3.4.4
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-payment-subscription",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.4",
|
|
4
4
|
"description": "paymentSubscription",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"mongodb": "^6.4.0",
|
|
26
26
|
"nodemon": "^3.1.0",
|
|
27
27
|
"swagger-ui-express": "^5.0.0",
|
|
28
|
-
"tango-api-schema": "^2.5.
|
|
28
|
+
"tango-api-schema": "^2.5.77",
|
|
29
29
|
"tango-app-api-middleware": "^3.6.18",
|
|
30
30
|
"winston": "^3.12.0",
|
|
31
31
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -443,7 +443,8 @@ export async function latestDailyPricing( req, res ) {
|
|
|
443
443
|
'Store Name': store.storeName,
|
|
444
444
|
'Store ID': store.storeId,
|
|
445
445
|
'Product': product.productName,
|
|
446
|
-
'Camera Count': store.
|
|
446
|
+
'Traffic Camera Count': store.trafficCameraCount || 0,
|
|
447
|
+
'Zone Camera Count': store.zoneCameraCount || 0,
|
|
447
448
|
'Zone Count': store.zoneCount || 0,
|
|
448
449
|
'Working Days': product.workingdays || 0,
|
|
449
450
|
'Status': store.status || '',
|
|
@@ -454,7 +455,8 @@ export async function latestDailyPricing( req, res ) {
|
|
|
454
455
|
'Store Name': store.storeName,
|
|
455
456
|
'Store ID': store.storeId,
|
|
456
457
|
'Product': '',
|
|
457
|
-
'Camera Count': store.
|
|
458
|
+
'Traffic Camera Count': store.trafficCameraCount || 0,
|
|
459
|
+
'Zone Camera Count': store.zoneCameraCount || 0,
|
|
458
460
|
'Zone Count': store.zoneCount || 0,
|
|
459
461
|
'Working Days': 0,
|
|
460
462
|
'Status': store.status || '',
|
|
@@ -632,7 +634,7 @@ export async function updateDailyPricingStoreField( req, res ) {
|
|
|
632
634
|
try {
|
|
633
635
|
const { clientId, dateString, storeId, fieldName, value } = req.body;
|
|
634
636
|
|
|
635
|
-
const allowedFields = [ '
|
|
637
|
+
const allowedFields = [ 'trafficCameraCount', 'zoneCameraCount', 'zoneCount' ];
|
|
636
638
|
if ( !clientId || !dateString || !storeId || !fieldName || value === undefined || !allowedFields.includes( fieldName ) ) {
|
|
637
639
|
return res.sendError( 'Missing or invalid required fields', 400 );
|
|
638
640
|
}
|
|
@@ -607,7 +607,8 @@ async function standardPrice( group, getClient, baseDate ) {
|
|
|
607
607
|
},
|
|
608
608
|
storeCount: { $sum: 1 },
|
|
609
609
|
totalZoneCount: { $sum: '$zoneCount' },
|
|
610
|
-
|
|
610
|
+
totalTrafficCameraCount: { $sum: '$trafficCameraCount' },
|
|
611
|
+
totalZoneCameraCount: { $sum: '$zoneCameraCount' },
|
|
611
612
|
},
|
|
612
613
|
},
|
|
613
614
|
{
|
|
@@ -617,7 +618,8 @@ async function standardPrice( group, getClient, baseDate ) {
|
|
|
617
618
|
workingdays: '$_id.workingdays',
|
|
618
619
|
storeCount: '$storeCount',
|
|
619
620
|
totalZoneCount: '$totalZoneCount',
|
|
620
|
-
|
|
621
|
+
totalTrafficCameraCount: '$totalTrafficCameraCount',
|
|
622
|
+
totalZoneCameraCount: '$totalZoneCameraCount',
|
|
621
623
|
},
|
|
622
624
|
},
|
|
623
625
|
{
|
|
@@ -651,7 +653,8 @@ async function standardPrice( group, getClient, baseDate ) {
|
|
|
651
653
|
workingdays: 1,
|
|
652
654
|
storeCount: 1,
|
|
653
655
|
totalZoneCount: 1,
|
|
654
|
-
|
|
656
|
+
totalTrafficCameraCount: 1,
|
|
657
|
+
totalZoneCameraCount: 1,
|
|
655
658
|
standard: {
|
|
656
659
|
$filter: {
|
|
657
660
|
input: '$basepricing.standard',
|
|
@@ -678,7 +681,8 @@ async function standardPrice( group, getClient, baseDate ) {
|
|
|
678
681
|
},
|
|
679
682
|
storeCount: 1,
|
|
680
683
|
totalZoneCount: 1,
|
|
681
|
-
|
|
684
|
+
totalTrafficCameraCount: 1,
|
|
685
|
+
totalZoneCameraCount: 1,
|
|
682
686
|
standardPrice: '$standard.negotiatePrice',
|
|
683
687
|
runningCost: {
|
|
684
688
|
$round: [
|
|
@@ -725,7 +729,8 @@ async function standardPrice( group, getClient, baseDate ) {
|
|
|
725
729
|
},
|
|
726
730
|
storeCount: { $sum: '$storeCount' },
|
|
727
731
|
totalZoneCount: { $sum: '$totalZoneCount' },
|
|
728
|
-
|
|
732
|
+
totalTrafficCameraCount: { $sum: '$totalTrafficCameraCount' },
|
|
733
|
+
totalZoneCameraCount: { $sum: '$totalZoneCameraCount' },
|
|
729
734
|
amount: { $sum: '$perstorecost' },
|
|
730
735
|
},
|
|
731
736
|
},
|
|
@@ -739,7 +744,8 @@ async function standardPrice( group, getClient, baseDate ) {
|
|
|
739
744
|
},
|
|
740
745
|
storeCount: 1,
|
|
741
746
|
totalZoneCount: 1,
|
|
742
|
-
|
|
747
|
+
totalTrafficCameraCount: 1,
|
|
748
|
+
totalZoneCameraCount: 1,
|
|
743
749
|
amount: 1,
|
|
744
750
|
description: {
|
|
745
751
|
$cond: {
|
|
@@ -843,8 +849,12 @@ async function standardPrice( group, getClient, baseDate ) {
|
|
|
843
849
|
if ( store.productName === 'tangoZone' ) {
|
|
844
850
|
if ( productBillingType === 'perZone' && store.zoneCount > 0 ) {
|
|
845
851
|
storeCount = store.zoneCount;
|
|
846
|
-
} else if ( productBillingType === 'perCamera' && store.
|
|
847
|
-
storeCount = store.
|
|
852
|
+
} else if ( productBillingType === 'perCamera' && store.zoneCameraCount > 0 ) {
|
|
853
|
+
storeCount = store.zoneCameraCount;
|
|
854
|
+
}
|
|
855
|
+
} else if ( store.productName === 'tangoTraffic' ) {
|
|
856
|
+
if ( productBillingType === 'perCamera' && store.trafficCameraCount > 0 ) {
|
|
857
|
+
storeCount = store.trafficCameraCount;
|
|
848
858
|
}
|
|
849
859
|
}
|
|
850
860
|
|
|
@@ -872,20 +882,26 @@ async function standardPrice( group, getClient, baseDate ) {
|
|
|
872
882
|
// Filter out eachStore products from aggregated results
|
|
873
883
|
products = products.filter( ( p ) => !eachStoreProductNames.includes( p.productName ) );
|
|
874
884
|
|
|
875
|
-
// Adjust storeCount based on billingType for tangoZone (overallStore products only)
|
|
885
|
+
// Adjust storeCount based on billingType for tangoZone and tangoTraffic (overallStore products only)
|
|
876
886
|
products = products.map( ( product ) => {
|
|
877
887
|
let productBillingType = billingTypeMap[product.productName] || 'perStore';
|
|
878
888
|
if ( product.productName === 'tangoZone' ) {
|
|
879
889
|
if ( productBillingType === 'perZone' && product.totalZoneCount > 0 ) {
|
|
880
890
|
product.amount = product.price * product.totalZoneCount;
|
|
881
891
|
product.storeCount = product.totalZoneCount;
|
|
882
|
-
} else if ( productBillingType === 'perCamera' && product.
|
|
883
|
-
product.amount = product.price * product.
|
|
884
|
-
product.storeCount = product.
|
|
892
|
+
} else if ( productBillingType === 'perCamera' && product.totalZoneCameraCount > 0 ) {
|
|
893
|
+
product.amount = product.price * product.totalZoneCameraCount;
|
|
894
|
+
product.storeCount = product.totalZoneCameraCount;
|
|
895
|
+
}
|
|
896
|
+
} else if ( product.productName === 'tangoTraffic' ) {
|
|
897
|
+
if ( productBillingType === 'perCamera' && product.totalTrafficCameraCount > 0 ) {
|
|
898
|
+
product.amount = product.price * product.totalTrafficCameraCount;
|
|
899
|
+
product.storeCount = product.totalTrafficCameraCount;
|
|
885
900
|
}
|
|
886
901
|
}
|
|
887
902
|
delete product.totalZoneCount;
|
|
888
|
-
delete product.
|
|
903
|
+
delete product.totalTrafficCameraCount;
|
|
904
|
+
delete product.totalZoneCameraCount;
|
|
889
905
|
return product;
|
|
890
906
|
} );
|
|
891
907
|
|
|
@@ -991,7 +1007,8 @@ async function stepPrice( group, getClient ) {
|
|
|
991
1007
|
},
|
|
992
1008
|
storeCount: { $sum: 1 },
|
|
993
1009
|
totalZoneCount: { $sum: '$zoneCount' },
|
|
994
|
-
|
|
1010
|
+
totalTrafficCameraCount: { $sum: '$trafficCameraCount' },
|
|
1011
|
+
totalZoneCameraCount: { $sum: '$zoneCameraCount' },
|
|
995
1012
|
},
|
|
996
1013
|
},
|
|
997
1014
|
{
|
|
@@ -1001,7 +1018,8 @@ async function stepPrice( group, getClient ) {
|
|
|
1001
1018
|
workingdays: '$_id.workingdays',
|
|
1002
1019
|
storeCount: '$storeCount',
|
|
1003
1020
|
totalZoneCount: '$totalZoneCount',
|
|
1004
|
-
|
|
1021
|
+
totalTrafficCameraCount: '$totalTrafficCameraCount',
|
|
1022
|
+
totalZoneCameraCount: '$totalZoneCameraCount',
|
|
1005
1023
|
},
|
|
1006
1024
|
},
|
|
1007
1025
|
{
|
|
@@ -1083,8 +1101,12 @@ async function stepPrice( group, getClient ) {
|
|
|
1083
1101
|
if ( store.productName === 'tangoZone' ) {
|
|
1084
1102
|
if ( productBillingType === 'perZone' && store.zoneCount > 0 ) {
|
|
1085
1103
|
storeCount = store.zoneCount;
|
|
1086
|
-
} else if ( productBillingType === 'perCamera' && store.
|
|
1087
|
-
storeCount = store.
|
|
1104
|
+
} else if ( productBillingType === 'perCamera' && store.zoneCameraCount > 0 ) {
|
|
1105
|
+
storeCount = store.zoneCameraCount;
|
|
1106
|
+
}
|
|
1107
|
+
} else if ( store.productName === 'tangoTraffic' ) {
|
|
1108
|
+
if ( productBillingType === 'perCamera' && store.trafficCameraCount > 0 ) {
|
|
1109
|
+
storeCount = store.trafficCameraCount;
|
|
1088
1110
|
}
|
|
1089
1111
|
}
|
|
1090
1112
|
|
|
@@ -1114,18 +1136,23 @@ async function stepPrice( group, getClient ) {
|
|
|
1114
1136
|
// Filter out eachStore products from aggregated results
|
|
1115
1137
|
products = products.filter( ( p ) => !eachStoreProductNames.includes( p.productName ) );
|
|
1116
1138
|
|
|
1117
|
-
// Adjust storeCount based on billingType for tangoZone (overallStore only)
|
|
1139
|
+
// Adjust storeCount based on billingType for tangoZone and tangoTraffic (overallStore only)
|
|
1118
1140
|
products = products.map( ( product ) => {
|
|
1119
1141
|
let productBillingType = billingTypeMap[product.productName] || 'perStore';
|
|
1120
1142
|
if ( product.productName === 'tangoZone' ) {
|
|
1121
1143
|
if ( productBillingType === 'perZone' && product.totalZoneCount > 0 ) {
|
|
1122
1144
|
product.storeCount = product.totalZoneCount;
|
|
1123
|
-
} else if ( productBillingType === 'perCamera' && product.
|
|
1124
|
-
product.storeCount = product.
|
|
1145
|
+
} else if ( productBillingType === 'perCamera' && product.totalZoneCameraCount > 0 ) {
|
|
1146
|
+
product.storeCount = product.totalZoneCameraCount;
|
|
1147
|
+
}
|
|
1148
|
+
} else if ( product.productName === 'tangoTraffic' ) {
|
|
1149
|
+
if ( productBillingType === 'perCamera' && product.totalTrafficCameraCount > 0 ) {
|
|
1150
|
+
product.storeCount = product.totalTrafficCameraCount;
|
|
1125
1151
|
}
|
|
1126
1152
|
}
|
|
1127
1153
|
delete product.totalZoneCount;
|
|
1128
|
-
delete product.
|
|
1154
|
+
delete product.totalTrafficCameraCount;
|
|
1155
|
+
delete product.totalZoneCameraCount;
|
|
1129
1156
|
return product;
|
|
1130
1157
|
} );
|
|
1131
1158
|
|
|
@@ -1773,3 +1800,24 @@ export async function getClientBasePricing( req, res ) {
|
|
|
1773
1800
|
}
|
|
1774
1801
|
}
|
|
1775
1802
|
|
|
1803
|
+
export async function deleteInvoice( req, res ) {
|
|
1804
|
+
try {
|
|
1805
|
+
const { invoiceId } = req.params;
|
|
1806
|
+
if ( !invoiceId ) {
|
|
1807
|
+
return res.sendError( 'Invoice ID is required', 400 );
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
const invoice = await invoiceService.findOne( { _id: invoiceId } );
|
|
1811
|
+
if ( !invoice ) {
|
|
1812
|
+
return res.sendError( 'Invoice not found', 404 );
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
await invoiceService.deleteRecord( { _id: invoiceId } );
|
|
1816
|
+
|
|
1817
|
+
res.sendSuccess( { message: 'Invoice deleted successfully' } );
|
|
1818
|
+
} catch ( error ) {
|
|
1819
|
+
logger.error( { error: error, function: 'deleteInvoice' } );
|
|
1820
|
+
return res.sendError( error, 500 );
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
|
|
@@ -3318,15 +3318,23 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3318
3318
|
];
|
|
3319
3319
|
let dailyData = await dailyPriceService.aggregate( query );
|
|
3320
3320
|
let cameraDetails = await cameraService.find( { storeId: getStore[storeIndex].storeId, clientId: requestClient[clientIndex], isActivated: true, isUp: true }, { streamName: 1, productModule: 1 } );
|
|
3321
|
+
console.log( '🚀 ~ dailyPricingInsert ~ cameraDetails:', cameraDetails );
|
|
3321
3322
|
|
|
3322
|
-
let
|
|
3323
|
+
let trafficCameraCount = cameraDetails.filter( ( cam ) =>
|
|
3323
3324
|
( cam.productModule || [] ).some( ( mod ) =>
|
|
3324
|
-
( mod.
|
|
3325
|
+
( mod.productName === 'tangoTraffic' || mod.productName === 'tangoTracking' ) && mod.checked === true,
|
|
3325
3326
|
),
|
|
3326
3327
|
).length;
|
|
3328
|
+
|
|
3329
|
+
let zoneCameraCount = cameraDetails.filter( ( cam ) =>
|
|
3330
|
+
( cam.productModule || [] ).some( ( mod ) =>
|
|
3331
|
+
mod.productName === 'tangoZone' && mod.checked === true,
|
|
3332
|
+
),
|
|
3333
|
+
).length;
|
|
3334
|
+
|
|
3327
3335
|
let zoneCameraStreamNames = cameraDetails.filter( ( cam ) =>
|
|
3328
3336
|
( cam.productModule || [] ).some( ( mod ) =>
|
|
3329
|
-
mod.
|
|
3337
|
+
mod.productName === 'tangoZone' && mod.checked === true,
|
|
3330
3338
|
),
|
|
3331
3339
|
).map( ( cam ) => cam.streamName );
|
|
3332
3340
|
let taggingDetails = await taggingService.find( { storeId: getStore[storeIndex].storeId, clientId: requestClient[clientIndex], productName: 'tangoZone', coordinates: { $ne: [] }, streamName: { $in: zoneCameraStreamNames } }, { tagName: 1 } );
|
|
@@ -3336,7 +3344,7 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3336
3344
|
let workingdays;
|
|
3337
3345
|
let workingdaystrax;
|
|
3338
3346
|
const givenDate = dayjs( requestData.date );
|
|
3339
|
-
|
|
3347
|
+
console.log( '🚀 ~ dailyPricingInsert ~ cameraCount:', trafficCameraCount, zoneCameraCount, zoneCount );
|
|
3340
3348
|
const isFirstDayOfMonth = givenDate.isSame( dayjs().startOf( 'month' ), 'day' );
|
|
3341
3349
|
if ( getStore[storeIndex]?.edge.firstFile ) {
|
|
3342
3350
|
if ( firstDate < requestData.date && getStore[storeIndex]?.status == 'active' &&
|
|
@@ -3413,7 +3421,8 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3413
3421
|
daysDifferenceTrax: workingdaystrax,
|
|
3414
3422
|
products: productList,
|
|
3415
3423
|
camera: cameraDetails.map( ( item ) => item.streamName ),
|
|
3416
|
-
|
|
3424
|
+
trafficCameraCount: trafficCameraCount,
|
|
3425
|
+
zoneCameraCount: zoneCameraCount,
|
|
3417
3426
|
zoneCount: zoneCount,
|
|
3418
3427
|
zoneName: zoneName,
|
|
3419
3428
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
-
import { createInvoice, invoiceDownload, clientInvoiceList, creditTransactionlist, pendingInvoices, applyDiscount, migrateInvoice, PaymentStatusChange, checkPaymentStatus, getInvoice, updateInvoice, getClientBasePricing } from '../controllers/invoice.controller.js';
|
|
2
|
+
import { createInvoice, invoiceDownload, clientInvoiceList, creditTransactionlist, pendingInvoices, applyDiscount, migrateInvoice, PaymentStatusChange, checkPaymentStatus, getInvoice, updateInvoice, getClientBasePricing, deleteInvoice } from '../controllers/invoice.controller.js';
|
|
3
3
|
import { isAllowedSessionHandler, accessVerification } from 'tango-app-api-middleware';
|
|
4
4
|
export const invoiceRouter = express.Router();
|
|
5
5
|
|
|
@@ -17,5 +17,6 @@ invoiceRouter.post( '/checkPaymentStatus', checkPaymentStatus );
|
|
|
17
17
|
invoiceRouter.get( '/getInvoice/:invoiceId', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ], access: [ { featureName: 'TangoAdmin', name: 'invoiceApproval', permissions: [] } ] } ), getInvoice );
|
|
18
18
|
invoiceRouter.put( '/updateInvoice', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ], access: [ { featureName: 'TangoAdmin', name: 'invoiceApproval', permissions: [ 'isEdit' ] } ] } ), updateInvoice );
|
|
19
19
|
invoiceRouter.get( '/getClientBasePricing/:clientId', isAllowedSessionHandler, getClientBasePricing );
|
|
20
|
+
invoiceRouter.delete( '/deleteInvoice/:invoiceId', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ], access: [ { featureName: 'TangoAdmin', name: 'invoiceApproval', permissions: [ 'isEdit' ] } ] } ), deleteInvoice );
|
|
20
21
|
|
|
21
22
|
|