tango-app-api-payment-subscription 3.0.19-dev → 3.0.21-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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-payment-subscription",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.21-dev",
|
|
4
4
|
"description": "paymentSubscription",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
"tango-api-schema": "^2.0.62",
|
|
24
24
|
"tango-app-api-middleware": "^1.0.49-dev",
|
|
25
25
|
"winston": "^3.12.0",
|
|
26
|
-
"winston-daily-rotate-file": "^5.0.0"
|
|
26
|
+
"winston-daily-rotate-file": "^5.0.0",
|
|
27
|
+
"html-to-pdfmake": "^2.5.6",
|
|
28
|
+
"jsdom": "^24.0.0",
|
|
29
|
+
"pdfmake": "^0.2.10"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
32
|
"eslint": "^8.57.0",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
/* eslint-disable new-cap */
|
|
2
3
|
import { logger, download, sendEmailWithSES, appConfig } from 'tango-app-api-middleware';
|
|
3
4
|
import * as paymentService from '../services/clientPayment.services.js';
|
|
@@ -31,6 +32,16 @@ export const addBilling = async ( req, res ) => {
|
|
|
31
32
|
billingDetails.nextBillingDate = '--';
|
|
32
33
|
resultData.billingDetails = billingDetails;
|
|
33
34
|
logger.info( 'Billing Details Added Successfully' );
|
|
35
|
+
// const logObj = {
|
|
36
|
+
// clientId: req.body.clientId,
|
|
37
|
+
// userName: req.user?.userName,
|
|
38
|
+
// email: req.user?.email,
|
|
39
|
+
// date: new Date(),
|
|
40
|
+
// logType: 'billing',
|
|
41
|
+
// logSubType: 'billingInfo',
|
|
42
|
+
// changes: [ 'billingAddress', 'gstNumber', 'nextBillingDate' ],
|
|
43
|
+
// eventType: 'update',
|
|
44
|
+
// };
|
|
34
45
|
return res.sendSuccess( { message: 'Billing Details Added Successfully', data: resultData } );
|
|
35
46
|
} else {
|
|
36
47
|
logger.error( 'Error Occurs WHile updating billing Detaisls' );
|
|
@@ -130,7 +141,7 @@ export const clientBillingSubscriptionInfo = async ( req, res, next ) => {
|
|
|
130
141
|
if ( element.status == 'trial' ) {
|
|
131
142
|
let differenceInDays = 14;
|
|
132
143
|
if ( element?.trialEndDate ) {
|
|
133
|
-
differenceInDays = dateDifference( element?.trialEndDate, currentDate );
|
|
144
|
+
differenceInDays = dateDifference( new Date( dayjs( element?.trialEndDate ).add( 1, 'days' ).startOf( 'day' ) ), new Date( dayjs( currentDate ).startOf( 'day' ) ) );
|
|
134
145
|
if ( element.trialEndDate < currentDate ) {
|
|
135
146
|
expiredProducts.push( { 'productName': element.productName, 'aliseProductName': element.aliseProductName, 'toolTip': 'Trial Expired' } );
|
|
136
147
|
element.toolTip = 'Trial Expired';
|
|
@@ -386,7 +397,10 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
386
397
|
category: 'Trial',
|
|
387
398
|
status: 'pending',
|
|
388
399
|
};
|
|
389
|
-
await clientRequestService.
|
|
400
|
+
let productExists = await clientRequestService.findOne( { clientId: requestBody.clientId, name: item.name, category: 'Trial', status: 'pending' } );
|
|
401
|
+
if ( !productExists ) {
|
|
402
|
+
await clientRequestService.insert( params );
|
|
403
|
+
}
|
|
390
404
|
}
|
|
391
405
|
if ( item.type == 'subscription' ) {
|
|
392
406
|
if ( existsIndex == -1 ) {
|
|
@@ -405,7 +419,6 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
405
419
|
let details = {
|
|
406
420
|
subscriptionType: requestBody.subscriptionType,
|
|
407
421
|
subscriptionPeriod: requestBody.subscriptionPeriod,
|
|
408
|
-
storeCount: requestBody.storeCount,
|
|
409
422
|
totalCamera: requestBody.totalCamera,
|
|
410
423
|
totalStores: requestBody.totalStores,
|
|
411
424
|
storeSize: requestBody.storeSize,
|
|
@@ -471,7 +484,7 @@ export const trialProductList = async ( req, res ) => {
|
|
|
471
484
|
} );
|
|
472
485
|
return res.sendSuccess( products );
|
|
473
486
|
} catch ( e ) {
|
|
474
|
-
logger.error( { error: e, function: '
|
|
487
|
+
logger.error( { error: e, function: 'trialProductList' } );
|
|
475
488
|
return res.sendError( e, 500 );
|
|
476
489
|
}
|
|
477
490
|
};
|
|
@@ -541,7 +554,7 @@ export const trialRequest = async ( req, res ) => {
|
|
|
541
554
|
|
|
542
555
|
return res.sendSuccess( 'Request Send Successfully' );
|
|
543
556
|
} catch ( e ) {
|
|
544
|
-
logger.error( { error: e, function: '
|
|
557
|
+
logger.error( { error: e, function: 'trialRequest' } );
|
|
545
558
|
return res.sendError( e, 500 );
|
|
546
559
|
}
|
|
547
560
|
};
|
|
@@ -588,7 +601,7 @@ export const updateInvoiceDetails = async ( req, res ) => {
|
|
|
588
601
|
clientInvoiceDetails.save().then( () => {
|
|
589
602
|
return res.sendSuccess( 'Invoice Updated Successfully' );
|
|
590
603
|
} ).catch( ( e ) => {
|
|
591
|
-
return res.sendError( e );
|
|
604
|
+
return res.sendError( e, 500 );
|
|
592
605
|
} );
|
|
593
606
|
} catch ( e ) {
|
|
594
607
|
logger.error( { error: e, function: 'invoiceDetails' } );
|
|
@@ -759,7 +772,7 @@ export const trialExtendRequestApproval = async ( req, res ) => {
|
|
|
759
772
|
userName: userDetails.userName,
|
|
760
773
|
product: firstWord +' '+secondWord,
|
|
761
774
|
days: req.body.days,
|
|
762
|
-
date: trialDate,
|
|
775
|
+
date: dayjs( trialDate ).format( 'YYYY-MM-DD' ),
|
|
763
776
|
};
|
|
764
777
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialExtentionEmail.hbs', 'utf8' );
|
|
765
778
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -1379,11 +1392,11 @@ export const priceList = async ( req, res ) => {
|
|
|
1379
1392
|
item.storeCount = item.storeCount - diff;
|
|
1380
1393
|
}
|
|
1381
1394
|
}
|
|
1382
|
-
let discountPrice = product.basePrice * ( product.discountPercentage / 100 );
|
|
1383
|
-
let price = product.basePrice - discountPrice;
|
|
1395
|
+
// let discountPrice = product.basePrice * ( product.discountPercentage / 100 );
|
|
1396
|
+
// let price = product.basePrice - discountPrice;
|
|
1384
1397
|
totalProductPrice = totalProductPrice + product.basePrice;
|
|
1385
1398
|
totalnegotiatePrice = totalnegotiatePrice + product.negotiatePrice;
|
|
1386
|
-
product.price =
|
|
1399
|
+
product.price = product.negotiatePrice * product.storeCount;
|
|
1387
1400
|
temp.push( product );
|
|
1388
1401
|
let originalPrice = product.basePrice * product.storeCount;
|
|
1389
1402
|
product.originalPrice = originalPrice;
|
|
@@ -1392,9 +1405,10 @@ export const priceList = async ( req, res ) => {
|
|
|
1392
1405
|
} );
|
|
1393
1406
|
} );
|
|
1394
1407
|
data = temp;
|
|
1395
|
-
let discountPrice =
|
|
1396
|
-
let discountPercentage = (
|
|
1397
|
-
let
|
|
1408
|
+
let discountPrice = totalProductPrice - totalnegotiatePrice;
|
|
1409
|
+
let discountPercentage = totalnegotiatePrice > 0 ? ( totalnegotiatePrice / totalProductPrice ) * 100 : 0;
|
|
1410
|
+
let gstAmount = discountTotalPrice * ( 18 / 100 );
|
|
1411
|
+
let finalValue = parseFloat( discountTotalPrice ) + gstAmount;
|
|
1398
1412
|
let result = {
|
|
1399
1413
|
product: data,
|
|
1400
1414
|
totalActualPrice: originalTotalPrice,
|
|
@@ -1402,7 +1416,7 @@ export const priceList = async ( req, res ) => {
|
|
|
1402
1416
|
actualPrice: totalProductPrice,
|
|
1403
1417
|
negotiatePrice: totalnegotiatePrice,
|
|
1404
1418
|
discountPrice: discountPrice,
|
|
1405
|
-
discountPercentage: discountPercentage.toFixed(),
|
|
1419
|
+
discountPercentage: discountPercentage.toFixed( 2 ),
|
|
1406
1420
|
finalValue: finalValue.toFixed( 2 ),
|
|
1407
1421
|
};
|
|
1408
1422
|
return res.sendSuccess( result );
|
|
@@ -1432,7 +1446,7 @@ export const pricingListUpdate = async ( req, res ) => {
|
|
|
1432
1446
|
productName: product,
|
|
1433
1447
|
discountPercentage: baseDetails.discoutPercentage,
|
|
1434
1448
|
basePrice: baseDetails.basePrice,
|
|
1435
|
-
negotiatePrice: discountPrice,
|
|
1449
|
+
negotiatePrice: baseDetails.basePrice - discountPrice,
|
|
1436
1450
|
},
|
|
1437
1451
|
);
|
|
1438
1452
|
stepList.push(
|
|
@@ -1440,7 +1454,7 @@ export const pricingListUpdate = async ( req, res ) => {
|
|
|
1440
1454
|
productName: product,
|
|
1441
1455
|
discountPercentage: baseDetails.discoutPercentage,
|
|
1442
1456
|
basePrice: baseDetails.basePrice,
|
|
1443
|
-
negotiatePrice: discountPrice,
|
|
1457
|
+
negotiatePrice: baseDetails.basePrice - discountPrice,
|
|
1444
1458
|
storeRange: '1-100',
|
|
1445
1459
|
},
|
|
1446
1460
|
);
|
|
@@ -1506,7 +1520,22 @@ export const pricingListUpdate = async ( req, res ) => {
|
|
|
1506
1520
|
} else {
|
|
1507
1521
|
getPriceInfo.step = req.body.products;
|
|
1508
1522
|
}
|
|
1509
|
-
getPriceInfo.save().then( () => {
|
|
1523
|
+
getPriceInfo.save().then( async () => {
|
|
1524
|
+
let userDetails= await userService.findOne( { clientId: invoiceDetails.clientId, role: 'superadmin' } );
|
|
1525
|
+
if ( userDetails ) {
|
|
1526
|
+
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/revisedPriceEmail.hbs', 'utf8' );
|
|
1527
|
+
const template = Handlebars.compile( templateHtml );
|
|
1528
|
+
const html = template( { data: '' } );
|
|
1529
|
+
let params = {
|
|
1530
|
+
toEmail: userDetails.email,
|
|
1531
|
+
mailSubject: 'test',
|
|
1532
|
+
htmlBody: html,
|
|
1533
|
+
attachment: '',
|
|
1534
|
+
sourceEmail: appConfig.cloud.aws.ses.adminEmail,
|
|
1535
|
+
};
|
|
1536
|
+
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1510
1539
|
return res.sendSuccess( 'Pricig Updated Successfully' );
|
|
1511
1540
|
} );
|
|
1512
1541
|
} catch ( e ) {
|
|
@@ -1531,7 +1560,7 @@ export const updatedRevisedPrice = async ( req, res ) => {
|
|
|
1531
1560
|
const template = Handlebars.compile( templateHtml );
|
|
1532
1561
|
const html = template( { data: '' } );
|
|
1533
1562
|
let params = {
|
|
1534
|
-
toEmail:
|
|
1563
|
+
toEmail: userDetails.email,
|
|
1535
1564
|
mailSubject: 'test',
|
|
1536
1565
|
htmlBody: html,
|
|
1537
1566
|
attachment: '',
|
|
@@ -152,7 +152,6 @@ export const validateUpdateSubscriptionSchema = {
|
|
|
152
152
|
priceType: joi.string().required(),
|
|
153
153
|
subscriptionType: joi.string().required(),
|
|
154
154
|
subscriptionPeriod: joi.string().required(),
|
|
155
|
-
storeCount: joi.number().required(),
|
|
156
155
|
totalCamera: joi.number().required(),
|
|
157
156
|
totalStores: joi.string().required(),
|
|
158
157
|
storeSize: joi.string().required(),
|