tango-app-api-payment-subscription 3.0.8 → 3.0.9-dev
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
|
@@ -69,8 +69,8 @@ export const clientBillingSubscriptionInfo = async ( req, res, next ) => {
|
|
|
69
69
|
return res.sendError( 'no data found', 204 );
|
|
70
70
|
}
|
|
71
71
|
let storeCount = await storeService.count( { clientId: clientInfo[0].clientId } );
|
|
72
|
-
|
|
73
|
-
let
|
|
72
|
+
let tangoProducts = [ 'tangoTraffic', 'tangoZone', 'tangoSOP', 'prioritySupport' ];
|
|
73
|
+
let activeProducts = clientInfo[0].planDetails.product;
|
|
74
74
|
let liveProducts = [];
|
|
75
75
|
let trialProducts = [];
|
|
76
76
|
let expiredProducts = [];
|
|
@@ -87,19 +87,50 @@ export const clientBillingSubscriptionInfo = async ( req, res, next ) => {
|
|
|
87
87
|
return Math.floor( differencems / ( 1000 * 60 * 60 * 24 ) );
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
let singleActiveProducts = [];
|
|
91
|
+
for ( let i = 0; i < activeProducts.length; i++ ) {
|
|
92
|
+
singleActiveProducts.push( activeProducts[i].productName );
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
for ( let i = 0; i < tangoProducts.length; i++ ) {
|
|
96
|
+
if ( !singleActiveProducts.includes( tangoProducts[i] ) ) {
|
|
97
|
+
activeProducts.push( { productName: tangoProducts[i], active: false } );
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
activeProducts.forEach( ( element ) => {
|
|
102
|
+
switch ( element.productName ) {
|
|
103
|
+
case 'tangoTraffic':
|
|
104
|
+
element.aliseProductName = 'Tango Traffic';
|
|
105
|
+
break;
|
|
106
|
+
case 'tangoZone':
|
|
107
|
+
element.aliseProductName = 'Tango Zone';
|
|
108
|
+
break;
|
|
109
|
+
case 'tangoSOP':
|
|
110
|
+
element.aliseProductName = 'Tango SOP';
|
|
111
|
+
break;
|
|
112
|
+
case 'prioritySupport':
|
|
113
|
+
element.aliseProductName = 'Priority Support';
|
|
114
|
+
break;
|
|
115
|
+
default:
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
|
|
91
119
|
if ( element.status == 'live' ) {
|
|
92
|
-
liveProducts.push( { 'productName': element.productName } );
|
|
120
|
+
liveProducts.push( { 'productName': element.productName, 'aliseProductName': element.aliseProductName } );
|
|
93
121
|
element.toolTip = 'Subscribed';
|
|
122
|
+
element.active = true;
|
|
94
123
|
}
|
|
95
124
|
if ( element.status == 'trial' && ( element.trialEndDate >= currentDate ) ) {
|
|
96
125
|
let differenceInDays = dateDifference( element.trialEndDate, currentDate );
|
|
97
|
-
trialProducts.push( { 'productName': element.productName, 'toolTip': differenceInDays +' days trial left' } );
|
|
126
|
+
trialProducts.push( { 'productName': element.productName, 'aliseProductName': element.aliseProductName, 'toolTip': differenceInDays +' days trial left' } );
|
|
98
127
|
element.toolTip = 'On Trial';
|
|
128
|
+
element.active = true;
|
|
99
129
|
}
|
|
100
130
|
if ( element.status == 'trial' && ( element.trialEndDate < currentDate ) ) {
|
|
101
|
-
expiredProducts.push( { 'productName': element.productName, 'toolTip': 'Trial Expired' } );
|
|
131
|
+
expiredProducts.push( { 'productName': element.productName, 'aliseProductName': element.aliseProductName, 'toolTip': 'Trial Expired' } );
|
|
102
132
|
element.toolTip = 'Trial Expired';
|
|
133
|
+
element.active = true;
|
|
103
134
|
}
|
|
104
135
|
} );
|
|
105
136
|
|
|
@@ -111,6 +142,15 @@ export const clientBillingSubscriptionInfo = async ( req, res, next ) => {
|
|
|
111
142
|
}
|
|
112
143
|
|
|
113
144
|
// Check Due Limit from invoice //
|
|
145
|
+
let getPendingInvoice = await invoiceService.find( { clientId: clientInfo[0].clientId, status: 'pending' } );
|
|
146
|
+
let getPI = false;
|
|
147
|
+
if ( getPendingInvoice.length > 0 ) {
|
|
148
|
+
if ( getPendingInvoice[0].billingDate >= currentDate ) {
|
|
149
|
+
getPI= false;
|
|
150
|
+
} else {
|
|
151
|
+
getPI = true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
114
154
|
|
|
115
155
|
// Check Client Request from client request//
|
|
116
156
|
let getClientRequest = await clientRequestService.find( { clientId: clientInfo[0].clientId, status: 'pending' } );
|
|
@@ -121,7 +161,7 @@ export const clientBillingSubscriptionInfo = async ( req, res, next ) => {
|
|
|
121
161
|
|
|
122
162
|
let currentPlanInfo = {};
|
|
123
163
|
currentPlanInfo.paymentStatus = clientInfo[0].planDetails.paymentStatus || '--';
|
|
124
|
-
currentPlanInfo.dueLimitReached =
|
|
164
|
+
currentPlanInfo.dueLimitReached = getPI;
|
|
125
165
|
currentPlanInfo.price = clientInfo[0].price || '--';
|
|
126
166
|
currentPlanInfo.priceType = priceType || '--';
|
|
127
167
|
currentPlanInfo.subscriptionType = clientInfo[0].planDetails.subscriptionType || '--';
|
|
@@ -133,12 +173,13 @@ export const clientBillingSubscriptionInfo = async ( req, res, next ) => {
|
|
|
133
173
|
currentPlanInfo.liveProducts = liveProducts || '--';
|
|
134
174
|
currentPlanInfo.trialProducts = trialProducts || '--';
|
|
135
175
|
currentPlanInfo.expiredProducts = expiredProducts || '--';
|
|
136
|
-
currentPlanInfo.product =
|
|
176
|
+
currentPlanInfo.product = activeProducts || '--';
|
|
137
177
|
currentPlanInfo.pendingClientRequest = getPCR;
|
|
138
178
|
|
|
139
179
|
let data = {
|
|
140
180
|
_id: clientInfo[0]._id,
|
|
141
181
|
clientId: clientInfo[0].clientId,
|
|
182
|
+
clientName: clientInfo[0].clientName,
|
|
142
183
|
currentPlanInfo: currentPlanInfo,
|
|
143
184
|
billingDetails: { ...clientInfo[0].billingDetails, nextBillingDate: '--' },
|
|
144
185
|
bankDetails: clientInfo[0].virtualAccount,
|
|
@@ -152,36 +193,6 @@ export const clientBillingSubscriptionInfo = async ( req, res, next ) => {
|
|
|
152
193
|
}
|
|
153
194
|
};
|
|
154
195
|
|
|
155
|
-
export const getStoreList = async ( req, res ) => {
|
|
156
|
-
try {
|
|
157
|
-
let storeList = await storeService.find( { clientId: req.query.clientId, status: 'active' }, { _id: 1, storeId: 1, storeName: 1 } );
|
|
158
|
-
|
|
159
|
-
if ( !storeList.length ) {
|
|
160
|
-
return res.sendError( 'no data found', 204 );
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return res.sendSuccess( storeList );
|
|
164
|
-
} catch ( e ) {
|
|
165
|
-
logger.error( { error: e, function: 'getStoreList' } );
|
|
166
|
-
return res.sendError( e, 500 );
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
export const getClientList = async ( req, res ) => {
|
|
171
|
-
try {
|
|
172
|
-
let storeList = await paymentService.find( { status: 'active' }, { clientId: 1, _id: 1, clientName: 1 } );
|
|
173
|
-
|
|
174
|
-
if ( !storeList.length ) {
|
|
175
|
-
return res.sendError( 'no data found', 204 );
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return res.sendSuccess( storeList );
|
|
179
|
-
} catch ( e ) {
|
|
180
|
-
logger.error( { error: e, function: 'getClientList' } );
|
|
181
|
-
return res.sendError( e, 500 );
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
|
|
185
196
|
export const pricingInfo = async ( req, res ) => {
|
|
186
197
|
try {
|
|
187
198
|
let query = [
|