tango-app-api-payment-subscription 3.0.17-dev → 3.0.18-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
|
@@ -600,6 +600,7 @@ export const notificationList = async ( req, res ) => {
|
|
|
600
600
|
query.status = 'pending';
|
|
601
601
|
if ( req?.query?.clientId ) {
|
|
602
602
|
query.clientId = req?.query?.clientId;
|
|
603
|
+
query.category = { $ne: 'TrialExtend' };
|
|
603
604
|
}
|
|
604
605
|
let notificationList = await clientRequestService.find( query, { createdAt: 0, updatedAt: 0 } );
|
|
605
606
|
query = [
|
|
@@ -1222,6 +1223,21 @@ export const invoiceList = async ( req, res ) => {
|
|
|
1222
1223
|
} );
|
|
1223
1224
|
}
|
|
1224
1225
|
|
|
1226
|
+
query.push( {
|
|
1227
|
+
$project: {
|
|
1228
|
+
_id: 1,
|
|
1229
|
+
invoice: 1,
|
|
1230
|
+
stores: 1,
|
|
1231
|
+
billingDate: 1,
|
|
1232
|
+
status: 1,
|
|
1233
|
+
paymentMethod: 1,
|
|
1234
|
+
amount: 1,
|
|
1235
|
+
discount: 1,
|
|
1236
|
+
revisedAmount: 1,
|
|
1237
|
+
products: 1,
|
|
1238
|
+
},
|
|
1239
|
+
} );
|
|
1240
|
+
|
|
1225
1241
|
query.push(
|
|
1226
1242
|
{
|
|
1227
1243
|
$facet: {
|
|
@@ -1241,6 +1257,16 @@ export const invoiceList = async ( req, res ) => {
|
|
|
1241
1257
|
if ( !invoiceDetails[0]?.data.length ) {
|
|
1242
1258
|
return res.sendError( 'no data found', 204 );
|
|
1243
1259
|
}
|
|
1260
|
+
invoiceDetails[0].data.forEach( ( item ) => {
|
|
1261
|
+
item.billingDate = dayjs( item.billingDate ).format( 'DD MMM, YYYY' );
|
|
1262
|
+
} );
|
|
1263
|
+
if ( req.user.userType == 'client' ) {
|
|
1264
|
+
invoiceDetails[0].data.forEach( ( item ) => {
|
|
1265
|
+
delete item.discount;
|
|
1266
|
+
delete item.revisedAmount;
|
|
1267
|
+
delete item.products;
|
|
1268
|
+
} );
|
|
1269
|
+
}
|
|
1244
1270
|
let data = {
|
|
1245
1271
|
data: invoiceDetails[0].data,
|
|
1246
1272
|
count: invoiceDetails[0].count[0].count,
|
|
@@ -1248,6 +1274,16 @@ export const invoiceList = async ( req, res ) => {
|
|
|
1248
1274
|
if ( !req.body.export ) {
|
|
1249
1275
|
return res.sendSuccess( data );
|
|
1250
1276
|
} else {
|
|
1277
|
+
invoiceDetails[0].data.forEach( ( item ) => {
|
|
1278
|
+
if ( item.status == 'trial' ) {
|
|
1279
|
+
item.amount = 'Trial';
|
|
1280
|
+
}
|
|
1281
|
+
if ( item.status == 'free' ) {
|
|
1282
|
+
item.amount = 'Free';
|
|
1283
|
+
}
|
|
1284
|
+
delete item._id;
|
|
1285
|
+
delete item.paymentMethod;
|
|
1286
|
+
} );
|
|
1251
1287
|
download( invoiceDetails[0].data, res );
|
|
1252
1288
|
}
|
|
1253
1289
|
} catch ( e ) {
|
|
@@ -1378,7 +1414,7 @@ export const pricingListUpdate = async ( req, res ) => {
|
|
|
1378
1414
|
productName: product,
|
|
1379
1415
|
discountPercentage: baseDetails.discoutPercentage,
|
|
1380
1416
|
basePrice: baseDetails.basePrice,
|
|
1381
|
-
negotiatePrice:
|
|
1417
|
+
negotiatePrice: discountPrice,
|
|
1382
1418
|
},
|
|
1383
1419
|
);
|
|
1384
1420
|
stepList.push(
|
|
@@ -1386,7 +1422,7 @@ export const pricingListUpdate = async ( req, res ) => {
|
|
|
1386
1422
|
productName: product,
|
|
1387
1423
|
discountPercentage: baseDetails.discoutPercentage,
|
|
1388
1424
|
basePrice: baseDetails.basePrice,
|
|
1389
|
-
negotiatePrice:
|
|
1425
|
+
negotiatePrice: discountPrice,
|
|
1390
1426
|
storeRange: '1-100',
|
|
1391
1427
|
},
|
|
1392
1428
|
);
|
|
@@ -1661,7 +1697,7 @@ export const updateInvoiceStatus = async ( req, res ) => {
|
|
|
1661
1697
|
if ( !invoiceDetails ) {
|
|
1662
1698
|
return res.sendError( 'no data found', 204 );
|
|
1663
1699
|
}
|
|
1664
|
-
invoiceDetails.status = req.body?.status || '
|
|
1700
|
+
invoiceDetails.status = req.body?.status || 'Payment Received';
|
|
1665
1701
|
invoiceDetails.save().then( async () => {
|
|
1666
1702
|
let clientInfo = await paymentService.findOne( { clientId: invoiceDetails.clientId } );
|
|
1667
1703
|
if ( clientInfo ) {
|
|
@@ -1682,12 +1718,13 @@ export const invoiceCreate = async ( req, res ) => {
|
|
|
1682
1718
|
let products = req.body.client.planDetails.product.map( ( item ) => item.productName );
|
|
1683
1719
|
let storeDetails = await storeService.count( { clientId: req.body.clientId, status: 'active' } );
|
|
1684
1720
|
let data;
|
|
1721
|
+
let clientId = req.body.clientId;
|
|
1685
1722
|
data = {
|
|
1686
1723
|
invoice: `invoice #0${req.body.client.clientId} - ${Math.floor( Math.random() * 100 ) + 1}`,
|
|
1687
1724
|
billingDate: new Date(),
|
|
1688
1725
|
products: products,
|
|
1689
1726
|
stores: storeDetails,
|
|
1690
|
-
status: '',
|
|
1727
|
+
status: 'pending',
|
|
1691
1728
|
clientId: req.body.clientId,
|
|
1692
1729
|
};
|
|
1693
1730
|
req.body = {
|
|
@@ -1700,7 +1737,7 @@ export const invoiceCreate = async ( req, res ) => {
|
|
|
1700
1737
|
let pricingDetails = await calculatePricing( req, res );
|
|
1701
1738
|
data.amount = pricingDetails.price;
|
|
1702
1739
|
await invoiceService.create( data );
|
|
1703
|
-
let clientInfo = await paymentService.findOne( { clientId:
|
|
1740
|
+
let clientInfo = await paymentService.findOne( { clientId: clientId } );
|
|
1704
1741
|
if ( clientInfo ) {
|
|
1705
1742
|
clientInfo.planDetails.paymentStatus = 'due';
|
|
1706
1743
|
clientInfo.save();
|
|
@@ -97,7 +97,7 @@ export const validateInvoiceParams = {
|
|
|
97
97
|
body: joi.object( {
|
|
98
98
|
limit: joi.number().required(),
|
|
99
99
|
offset: joi.number().required(),
|
|
100
|
-
searchValue: joi.string().optional(),
|
|
100
|
+
searchValue: joi.string().optional().empty( '' ),
|
|
101
101
|
filter: joi.string().optional(),
|
|
102
102
|
sortColumn: joi.string().optional(),
|
|
103
103
|
sortBy: joi.number().optional(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import model from 'tango-api-schema';
|
|
2
2
|
|
|
3
3
|
export const aggregate = async ( query ={} ) => {
|
|
4
|
-
return await model.invoiceModel.aggregate( query );
|
|
4
|
+
return await model.invoiceModel.aggregate( query, { collation: { locale: 'en_US', numericOrdering: true } } );
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
export const findOne = async ( query ={}, record={} ) => {
|