tango-app-api-payment-subscription 3.1.20 → 3.1.21-beta.1
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
|
@@ -120,7 +120,7 @@ export async function createInvoice( req, res ) {
|
|
|
120
120
|
let data = {
|
|
121
121
|
groupName: group.groupName,
|
|
122
122
|
groupId: group._id,
|
|
123
|
-
invoice:
|
|
123
|
+
invoice: req.body.invoiceId?req.body.invoiceId:`INV-${Finacialyear}-${invoiceNo}`,
|
|
124
124
|
products: products,
|
|
125
125
|
status: 'pending',
|
|
126
126
|
amount: Math.round( amount ),
|
|
@@ -140,7 +140,9 @@ export async function createInvoice( req, res ) {
|
|
|
140
140
|
if ( req.body.invoiceId ) {
|
|
141
141
|
await invoiceService.deleteRecord( { invoice: req.body.invoiceId } );
|
|
142
142
|
}
|
|
143
|
-
|
|
143
|
+
if ( Number( totalAmount ) > 0 ) {
|
|
144
|
+
await invoiceService.create( data );
|
|
145
|
+
}
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
res.sendSuccess( 'Invoice Created SuccessFully' );
|
|
@@ -178,7 +180,6 @@ export async function invoiceDownload( req, res ) {
|
|
|
178
180
|
} );
|
|
179
181
|
|
|
180
182
|
|
|
181
|
-
|
|
182
183
|
let invoiceDate = dayjs( invoiceInfo.createdAt ).format( 'DD/MM/YYYY' );
|
|
183
184
|
let days = clientDetails?.paymentInvoice?.extendPaymentPeriodDays || 10;
|
|
184
185
|
let dueDate = invoiceInfo?.dueDate ? dayjs( invoiceInfo?.dueDate ).format( 'DD/MM/YYYY' ) : dayjs().add( days, 'days' ).format( 'DD/MM/YYYY' );
|
|
@@ -210,9 +211,7 @@ export async function invoiceDownload( req, res ) {
|
|
|
210
211
|
discountAmount: invoiceInfo.discountAmount ? invoiceInfo.discountAmount : 0,
|
|
211
212
|
logo: `${JSON.parse( process.env.URL ).apiDomain}/logo.png`,
|
|
212
213
|
uidomain: `${JSON.parse( process.env.URL ).domain}`,
|
|
213
|
-
attachAnnexure: getgroup
|
|
214
|
-
virtualaccountNumber: virtualAccount.accountNumber,
|
|
215
|
-
virtualifsc: virtualAccount.ifsc,
|
|
214
|
+
attachAnnexure: getgroup?.attachAnnexure,
|
|
216
215
|
billingAddressLineOne: getgroup?.addressLineOne,
|
|
217
216
|
billingAddressLineTwo: getgroup?.addressLineTwo,
|
|
218
217
|
billingCountry: getgroup?.country,
|
|
@@ -220,8 +219,8 @@ export async function invoiceDownload( req, res ) {
|
|
|
220
219
|
billingCity: getgroup?.city,
|
|
221
220
|
billingPinCode: getgroup?.pinCode,
|
|
222
221
|
billingCurrency: virtualAccount?.currency,
|
|
223
|
-
virtualaccountNumber: virtualAccount?virtualAccount?.accountNumber:'',
|
|
224
|
-
virtualifsc: virtualAccount?virtualAccount?.ifsc:'',
|
|
222
|
+
virtualaccountNumber: virtualAccount ? virtualAccount?.accountNumber : '',
|
|
223
|
+
virtualifsc: virtualAccount ? virtualAccount?.ifsc : '',
|
|
225
224
|
};
|
|
226
225
|
|
|
227
226
|
if ( invoiceData?.tax?.length ) {
|
|
@@ -939,14 +938,14 @@ export async function clientInvoiceList( req, res ) {
|
|
|
939
938
|
},
|
|
940
939
|
} );
|
|
941
940
|
}
|
|
942
|
-
if ( req.body.paymentStatus && req.body.paymentStatus.length>0 ) {
|
|
941
|
+
if ( req.body.paymentStatus && req.body.paymentStatus.length > 0 ) {
|
|
943
942
|
query.push( {
|
|
944
943
|
$match: {
|
|
945
944
|
paymentStatus: { $in: req.body.paymentStatus },
|
|
946
945
|
},
|
|
947
946
|
} );
|
|
948
947
|
}
|
|
949
|
-
if ( req.body.status && req.body.status.length>0 ) {
|
|
948
|
+
if ( req.body.status && req.body.status.length > 0 ) {
|
|
950
949
|
query.push( {
|
|
951
950
|
$match: {
|
|
952
951
|
status: { $in: req.body.status },
|
|
@@ -1074,7 +1073,7 @@ export async function creditTransactionlist( req, res ) {
|
|
|
1074
1073
|
} );
|
|
1075
1074
|
}
|
|
1076
1075
|
let count = await paymentAccountService.aggregate( query );
|
|
1077
|
-
if ( count.length===0 ) {
|
|
1076
|
+
if ( count.length === 0 ) {
|
|
1078
1077
|
return res.sendError( 'No data', 204 );
|
|
1079
1078
|
}
|
|
1080
1079
|
if ( req.body.export ) {
|
|
@@ -1150,3 +1149,38 @@ export async function applyDiscount( req, res ) {
|
|
|
1150
1149
|
return res.sendError( error, 500 );
|
|
1151
1150
|
}
|
|
1152
1151
|
}
|
|
1152
|
+
|
|
1153
|
+
export async function migrateInvoice( req, res ) {
|
|
1154
|
+
try {
|
|
1155
|
+
let OldinvoiceList = await invoiceService.find( { groupId: { $exists: false } } );
|
|
1156
|
+
for ( let Oldinvoice of OldinvoiceList ) {
|
|
1157
|
+
let updateproduct = [];
|
|
1158
|
+
for ( let product of Oldinvoice.products ) {
|
|
1159
|
+
let obj = {
|
|
1160
|
+
productName: product.product.product,
|
|
1161
|
+
storeCount: product.count,
|
|
1162
|
+
amount: product.price,
|
|
1163
|
+
price: product.basePrice,
|
|
1164
|
+
HsnNumber: product.HSNnumber,
|
|
1165
|
+
month: product.Month,
|
|
1166
|
+
description: product.description,
|
|
1167
|
+
};
|
|
1168
|
+
updateproduct.push( obj );
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
let findgroup = await billingService.findOne( { clientId: Oldinvoice.clientId, groupName: 'Default Group' } );
|
|
1172
|
+
let updateInvoice = await invoiceService.updateOne( { invoice: Oldinvoice.invoice },
|
|
1173
|
+
{
|
|
1174
|
+
products: updateproduct,
|
|
1175
|
+
paymentStatus: 'unpaid',
|
|
1176
|
+
groupName: findgroup&&findgroup.groupName ? findgroup.groupName : 'Default Group',
|
|
1177
|
+
groupId: findgroup&&findgroup._id ? findgroup._id : '',
|
|
1178
|
+
currency: findgroup&&findgroup.currency? findgroup.currency : 'inr',
|
|
1179
|
+
},
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
} catch ( error ) {
|
|
1183
|
+
logger.error( { error: error, function: 'migrateInvoice' } );
|
|
1184
|
+
return res.sendError( error, 500 );
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
-
import { createInvoice, invoiceDownload, clientInvoiceList, creditTransactionlist, pendingInvoices, applyDiscount } from '../controllers/invoice.controller.js';
|
|
2
|
+
import { createInvoice, invoiceDownload, clientInvoiceList, creditTransactionlist, pendingInvoices, applyDiscount, migrateInvoice } from '../controllers/invoice.controller.js';
|
|
3
3
|
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
4
4
|
export const invoiceRouter = express.Router();
|
|
5
5
|
|
|
@@ -10,5 +10,6 @@ invoiceRouter.post( '/clientInvoiceList', isAllowedSessionHandler, clientInvoice
|
|
|
10
10
|
invoiceRouter.post( '/creditTransactionlist', isAllowedSessionHandler, creditTransactionlist );
|
|
11
11
|
invoiceRouter.post( '/pendingInvoices', isAllowedSessionHandler, pendingInvoices );
|
|
12
12
|
invoiceRouter.post( '/applyDiscount', isAllowedSessionHandler, applyDiscount );
|
|
13
|
+
invoiceRouter.post( '/migrateInvoice', migrateInvoice );
|
|
13
14
|
|
|
14
15
|
|
|
@@ -7,25 +7,25 @@ import { getInvoiceSchema, getVirtualAccountSchema, valletPayValid, verifyPaymen
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
paymentRouter.get( '/get-virtual-account', isAllowedSessionHandler, authorize( {
|
|
10
|
-
userType: [ 'tango' ], access: [
|
|
10
|
+
userType: [ 'tango', 'client' ], access: [
|
|
11
11
|
{ featureName: 'settings', name: 'paymentSubscriptions', permissions: [ 'isView' ] },
|
|
12
12
|
],
|
|
13
13
|
} ), validate( getVirtualAccountSchema ), getVirtualAccount );
|
|
14
14
|
|
|
15
15
|
paymentRouter.get( '/wallet-pay/:invoice', isAllowedSessionHandler, authorize( {
|
|
16
|
-
userType: [ 'tango' ], access: [
|
|
16
|
+
userType: [ 'tango', 'client' ], access: [
|
|
17
17
|
{ featureName: 'settings', name: 'paymentSubscriptions', permissions: [ 'isEdit' ] },
|
|
18
18
|
],
|
|
19
19
|
} ), validate( valletPayValid ), payUsingVallet );
|
|
20
20
|
|
|
21
21
|
paymentRouter.get( '/generate-order/:invoice', isAllowedSessionHandler, authorize( {
|
|
22
|
-
userType: [ 'tango' ], access: [
|
|
22
|
+
userType: [ 'tango', 'client' ], access: [
|
|
23
23
|
{ featureName: 'settings', name: 'paymentSubscriptions', permissions: [ 'isEdit' ] },
|
|
24
24
|
],
|
|
25
25
|
} ), validate( valletPayValid ), generateOrder );
|
|
26
26
|
|
|
27
27
|
paymentRouter.post( '/verify-payment/:invoice', isAllowedSessionHandler, authorize( {
|
|
28
|
-
userType: [ 'tango' ], access: [
|
|
28
|
+
userType: [ 'tango', 'client' ], access: [
|
|
29
29
|
{ featureName: 'settings', name: 'paymentSubscriptions', permissions: [ 'isEdit' ] },
|
|
30
30
|
],
|
|
31
31
|
} ), validate( verifyPaymentValid ), verifyPayment );
|