tango-app-api-payment-subscription 3.0.16-dev → 3.0.17-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 +1 -1
- package/src/controllers/paymentSubscription.controllers.js +36 -36
- package/src/dtos/validation.dtos.js +1 -1
- package/src/routes/paymentSubscription.routes.js +1 -1
- /package/src/hbs/{trailCreditNoteEmail.hbs → trialCreditNoteEmail.hbs} +0 -0
- /package/src/hbs/{trailExpiredEmail.hbs → trialExpiredEmail.hbs} +0 -0
- /package/src/hbs/{trailExtentionEmail.hbs → trialExtentionEmail.hbs} +0 -0
- /package/src/hbs/{trailReminderEmail.hbs → trialReminderEmail.hbs} +0 -0
- /package/src/hbs/{trailUnsubscribeEmail.hbs → trialUnsubscribeEmail.hbs} +0 -0
package/package.json
CHANGED
|
@@ -128,15 +128,16 @@ export const clientBillingSubscriptionInfo = async ( req, res, next ) => {
|
|
|
128
128
|
let differenceInDays = 14;
|
|
129
129
|
if ( element?.trialEndDate ) {
|
|
130
130
|
differenceInDays = dateDifference( element?.trialEndDate, currentDate );
|
|
131
|
+
if ( element.trialEndDate < currentDate ) {
|
|
132
|
+
expiredProducts.push( { 'productName': element.productName, 'aliseProductName': element.aliseProductName, 'toolTip': 'Trial Expired' } );
|
|
133
|
+
element.toolTip = 'Trial Expired';
|
|
134
|
+
element.active = true;
|
|
135
|
+
} else {
|
|
136
|
+
trialProducts.push( { 'productName': element.productName, 'aliseProductName': element.aliseProductName, 'toolTip': differenceInDays +' days trial left' } );
|
|
137
|
+
element.toolTip = 'On Trial';
|
|
138
|
+
element.active = true;
|
|
139
|
+
}
|
|
131
140
|
}
|
|
132
|
-
trialProducts.push( { 'productName': element.productName, 'aliseProductName': element.aliseProductName, 'toolTip': differenceInDays +' days trial left' } );
|
|
133
|
-
element.toolTip = 'On Trial';
|
|
134
|
-
element.active = true;
|
|
135
|
-
}
|
|
136
|
-
if ( element.status == 'trial' && ( element.trialEndDate < currentDate ) ) {
|
|
137
|
-
expiredProducts.push( { 'productName': element.productName, 'aliseProductName': element.aliseProductName, 'toolTip': 'Trial Expired' } );
|
|
138
|
-
element.toolTip = 'Trial Expired';
|
|
139
|
-
element.active = true;
|
|
140
141
|
}
|
|
141
142
|
} );
|
|
142
143
|
}
|
|
@@ -202,7 +203,6 @@ export const clientBillingSubscriptionInfo = async ( req, res, next ) => {
|
|
|
202
203
|
export const pricingInfo = async ( req, res ) => {
|
|
203
204
|
try {
|
|
204
205
|
let pricingDetails = await calculatePricing( req, res );
|
|
205
|
-
console.log( await calculatePricing( req, res ), 'details' );
|
|
206
206
|
return res.sendSuccess( pricingDetails );
|
|
207
207
|
} catch ( e ) {
|
|
208
208
|
logger.error( { error: e, function: 'pricingInfo' } );
|
|
@@ -213,7 +213,6 @@ export const pricingInfo = async ( req, res ) => {
|
|
|
213
213
|
async function calculatePricing( req, res ) {
|
|
214
214
|
try {
|
|
215
215
|
let input = req.body;
|
|
216
|
-
console.log( input, 'input' );
|
|
217
216
|
let finalPrice = 0;
|
|
218
217
|
let dummy = [];
|
|
219
218
|
let camaraArray = [];
|
|
@@ -309,7 +308,7 @@ async function calculatePricing( req, res ) {
|
|
|
309
308
|
} );
|
|
310
309
|
return ( { OriginalPrice: Math.round( OriginalPrice ), price: Math.round( finalPrice ), camaraCount: camaraCount } );
|
|
311
310
|
} catch ( e ) {
|
|
312
|
-
|
|
311
|
+
logger.error( { error: e, function: 'calculatePricing' } );
|
|
313
312
|
return false;
|
|
314
313
|
}
|
|
315
314
|
}
|
|
@@ -627,22 +626,24 @@ export const notificationList = async ( req, res ) => {
|
|
|
627
626
|
let getClientInfo = await paymentService.aggregate( query );
|
|
628
627
|
if ( getClientInfo.length ) {
|
|
629
628
|
getClientInfo.forEach( ( item ) => {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
629
|
+
if ( item.product?.trialStartDate && item.product?.trialEndDate ) {
|
|
630
|
+
let [ firstWord, secondWord ] = item.product.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
631
|
+
firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
|
|
632
|
+
let startDate = dayjs( item.product.trialStartDate );
|
|
633
|
+
let endDate = dayjs( item.product.trialEndDate ).startOf( 'day' );
|
|
634
|
+
let date = dayjs().startOf( 'day' );
|
|
635
|
+
let days = date.diff( startDate, 'day' );
|
|
636
|
+
let totalDays = endDate.diff( startDate, 'day' );
|
|
637
|
+
let percentage = Math.round( ( days / totalDays )* 100 );
|
|
638
|
+
let leftDays = endDate.diff( date, 'day' ) + 1;
|
|
639
|
+
notificationList.push( {
|
|
640
|
+
product: item.product.productName,
|
|
641
|
+
name: `${firstWord} ${secondWord}`,
|
|
642
|
+
day: leftDays < 0 ? 0 : leftDays,
|
|
643
|
+
percentage: percentage > 100 ? 100 : percentage,
|
|
644
|
+
category: 'trial product',
|
|
645
|
+
} );
|
|
646
|
+
}
|
|
646
647
|
} );
|
|
647
648
|
}
|
|
648
649
|
|
|
@@ -1455,7 +1456,6 @@ export const pricingListUpdate = async ( req, res ) => {
|
|
|
1455
1456
|
return res.sendSuccess( 'Pricig Updated Successfully' );
|
|
1456
1457
|
} );
|
|
1457
1458
|
} catch ( e ) {
|
|
1458
|
-
console.log( e );
|
|
1459
1459
|
logger.error( { error: e, function: 'addPricingList' } );
|
|
1460
1460
|
return res.sendError( e, 500 );
|
|
1461
1461
|
}
|
|
@@ -1555,7 +1555,7 @@ export const getRemindClients = async ( req, res ) => {
|
|
|
1555
1555
|
username: userDetails.userName,
|
|
1556
1556
|
product: firstWord + ' ' + secondWord,
|
|
1557
1557
|
};
|
|
1558
|
-
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/
|
|
1558
|
+
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialReminderEmail.hbs', 'utf8' );
|
|
1559
1559
|
const template = Handlebars.compile( templateHtml );
|
|
1560
1560
|
const html = template( { data: data } );
|
|
1561
1561
|
let params = {
|
|
@@ -1618,7 +1618,7 @@ export const getExpiredClients = async ( req, res ) => {
|
|
|
1618
1618
|
username: userDetails.userName,
|
|
1619
1619
|
product: firstWord +' '+secondWord,
|
|
1620
1620
|
};
|
|
1621
|
-
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/
|
|
1621
|
+
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialExpiredEmail.hbs', 'utf8' );
|
|
1622
1622
|
const template = Handlebars.compile( templateHtml );
|
|
1623
1623
|
const html = template( { data: data } );
|
|
1624
1624
|
let params = {
|
|
@@ -1641,12 +1641,12 @@ export const getExpiredClients = async ( req, res ) => {
|
|
|
1641
1641
|
|
|
1642
1642
|
export const invoiceDownload = async ( req, res ) => {
|
|
1643
1643
|
try {
|
|
1644
|
-
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/invoicePdf.hbs', 'utf8' );
|
|
1645
|
-
const template = Handlebars.compile( templateHtml );
|
|
1646
|
-
const html = template( { data: '' } );
|
|
1647
|
-
console.log( html );
|
|
1644
|
+
// const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/invoicePdf.hbs', 'utf8' );
|
|
1645
|
+
// const template = Handlebars.compile( templateHtml );
|
|
1646
|
+
// const html = template( { data: '' } );
|
|
1647
|
+
// console.log( html );
|
|
1648
1648
|
} catch ( e ) {
|
|
1649
|
-
console.log( e );
|
|
1649
|
+
// console.log( e );
|
|
1650
1650
|
logger.error( { error: e, function: 'invoiceDownload' } );
|
|
1651
1651
|
return res.sendError( e, 500 );
|
|
1652
1652
|
}
|
|
@@ -1707,7 +1707,7 @@ export const invoiceCreate = async ( req, res ) => {
|
|
|
1707
1707
|
}
|
|
1708
1708
|
return res.sendSuccess( 'Invoice Created Successfully' );
|
|
1709
1709
|
} catch ( e ) {
|
|
1710
|
-
console.log( e );
|
|
1710
|
+
// console.log( e );
|
|
1711
1711
|
logger.error( { error: e, function: 'invoiceDownload' } );
|
|
1712
1712
|
return res.sendError( e, 500 );
|
|
1713
1713
|
}
|
|
@@ -33,7 +33,7 @@ export const validateProducts = {
|
|
|
33
33
|
export const validateunsubscribeParams = {
|
|
34
34
|
body: joi.object( {
|
|
35
35
|
reason: joi.string().required(),
|
|
36
|
-
description: joi.string().
|
|
36
|
+
description: joi.string().optional().empty( '' ),
|
|
37
37
|
clientId: joi.string().required(),
|
|
38
38
|
} ),
|
|
39
39
|
};
|
|
@@ -8,7 +8,7 @@ export const paymentSubscriptionRouter = express.Router();
|
|
|
8
8
|
|
|
9
9
|
paymentSubscriptionRouter.post( '/addBilling', isAllowedSessionHandler, authorize( {
|
|
10
10
|
userType: [ 'tango', 'client' ], access: [
|
|
11
|
-
{ featureName: 'settings', name: '
|
|
11
|
+
{ featureName: 'settings', name: 'paymentSubscriptions', permissions: [ 'isEdit' ] },
|
|
12
12
|
],
|
|
13
13
|
} ), validate( validationDtos.validateBillingParams ), validateClient, paymentController.addBilling );
|
|
14
14
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|