tango-app-api-infra 3.0.93-dev → 3.0.94-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
|
@@ -204,7 +204,7 @@ export async function installationCard( req, res ) {
|
|
|
204
204
|
{ 'status': { $ne: 'closed' } },
|
|
205
205
|
{ 'ticketDetails.issueStatus': 'notidentified' },
|
|
206
206
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
207
|
-
{ createdAt: { $lte:
|
|
207
|
+
{ createdAt: { $lte: date.end } },
|
|
208
208
|
],
|
|
209
209
|
},
|
|
210
210
|
},
|
|
@@ -216,7 +216,7 @@ export async function installationCard( req, res ) {
|
|
|
216
216
|
{ 'status': { $ne: 'closed' } },
|
|
217
217
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
218
218
|
{ 'ticketDetails.issueStatus': 'identified' },
|
|
219
|
-
{ createdAt: { $lte:
|
|
219
|
+
{ createdAt: { $lte: date.end } },
|
|
220
220
|
],
|
|
221
221
|
},
|
|
222
222
|
},
|
|
@@ -549,7 +549,7 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
549
549
|
{ 'status': { $ne: 'closed' } },
|
|
550
550
|
|
|
551
551
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
552
|
-
{ createdAt: { $lte:
|
|
552
|
+
{ createdAt: { $lte: date.end } },
|
|
553
553
|
],
|
|
554
554
|
},
|
|
555
555
|
} );
|
|
@@ -8,7 +8,7 @@ export async function createTicket( req, res ) {
|
|
|
8
8
|
let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'issueDate': ( new Date( req.body.Date ) ), 'basicDetails.storeId': req.body.storeId } );
|
|
9
9
|
|
|
10
10
|
if ( ticketExist ) {
|
|
11
|
-
return res.sendSuccess( '
|
|
11
|
+
return res.sendSuccess( 'Ticket Already Exists for the store' );
|
|
12
12
|
}
|
|
13
13
|
let actionBy = '';
|
|
14
14
|
if ( req.user.userType == 'tango' ) {
|
|
@@ -21,6 +21,7 @@ export async function createTicket( req, res ) {
|
|
|
21
21
|
actualCount: req.body.actualCount,
|
|
22
22
|
expectedCount: req.body.expectedCount,
|
|
23
23
|
contactEmail: req.body.contactEmail,
|
|
24
|
+
showToClient: req.body.showToClient,
|
|
24
25
|
};
|
|
25
26
|
req.body.issueDate = new Date( req.body.Date );
|
|
26
27
|
req.body.ticketId = 'TE_DM_' + new Date().valueOf();
|
|
@@ -106,17 +107,31 @@ export async function updateMat( req, res ) {
|
|
|
106
107
|
export async function activityList( req, res ) {
|
|
107
108
|
try {
|
|
108
109
|
let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
|
|
109
|
-
let query = [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
let query = [ ];
|
|
111
|
+
if ( req.body.fromDate == req.body.toDate ) {
|
|
112
|
+
query.push( {
|
|
113
|
+
$match: {
|
|
114
|
+
$and: [
|
|
115
|
+
{ 'basicDetails.storeId': req.body.storeId },
|
|
116
|
+
{ issueType: { $in: [ 'lowcount', 'highcount' ] } },
|
|
117
|
+
{ createdAt: { $lte: date.end } },
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
} );
|
|
121
|
+
} else {
|
|
122
|
+
query.push( {
|
|
123
|
+
$match: {
|
|
124
|
+
$and: [
|
|
125
|
+
{ 'basicDetails.storeId': req.body.storeId },
|
|
126
|
+
{ issueType: { $in: [ 'lowcount', 'highcount' ] } },
|
|
127
|
+
{ createdAt: { $gte: date.start } },
|
|
128
|
+
{ createdAt: { $lte: date.end } },
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
} );
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
query.push( {
|
|
120
135
|
$project: {
|
|
121
136
|
storeId: '$basicDetails.storeId',
|
|
122
137
|
status: 1,
|
|
@@ -153,7 +168,7 @@ export async function activityList( req, res ) {
|
|
|
153
168
|
issueDate: -1,
|
|
154
169
|
},
|
|
155
170
|
},
|
|
156
|
-
|
|
171
|
+
);
|
|
157
172
|
|
|
158
173
|
if ( req.body.filter && req.body.filter !== '' ) {
|
|
159
174
|
query.push( {
|
|
@@ -1746,3 +1746,261 @@ export async function storeFilter( req, res ) {
|
|
|
1746
1746
|
}
|
|
1747
1747
|
}
|
|
1748
1748
|
|
|
1749
|
+
export async function dataMismatchTable( req, res ) {
|
|
1750
|
+
try {
|
|
1751
|
+
const inputData = req.body;
|
|
1752
|
+
const defaultValue = [
|
|
1753
|
+
{ name: 'Low Count', count: 0 },
|
|
1754
|
+
{ name: 'High Count', count: 0 },
|
|
1755
|
+
{ name: 'Total', count: 0 },
|
|
1756
|
+
|
|
1757
|
+
];
|
|
1758
|
+
|
|
1759
|
+
let countFilter = [
|
|
1760
|
+
{ issueDate: { $gte: new Date( inputData.fromDate ) } },
|
|
1761
|
+
{ issueDate: { $lte: new Date( inputData.toDate ) } },
|
|
1762
|
+
{
|
|
1763
|
+
issueType: { $in: [ 'highcount', 'lowcount' ] },
|
|
1764
|
+
},
|
|
1765
|
+
|
|
1766
|
+
];
|
|
1767
|
+
if ( inputData.clientId && inputData?.clientId?.length > 0 ) {
|
|
1768
|
+
countFilter.push( {
|
|
1769
|
+
'basicDetails.clientId': { $in: inputData.clientId },
|
|
1770
|
+
} );
|
|
1771
|
+
}
|
|
1772
|
+
const countQuery = [
|
|
1773
|
+
{
|
|
1774
|
+
$match: {
|
|
1775
|
+
$and: countFilter,
|
|
1776
|
+
},
|
|
1777
|
+
|
|
1778
|
+
},
|
|
1779
|
+
{
|
|
1780
|
+
$project: {
|
|
1781
|
+
high: {
|
|
1782
|
+
$cond: [
|
|
1783
|
+
{
|
|
1784
|
+
$eq: [ '$issueType', 'highcount' ],
|
|
1785
|
+
}, 1, 0,
|
|
1786
|
+
],
|
|
1787
|
+
},
|
|
1788
|
+
low: {
|
|
1789
|
+
$cond: [
|
|
1790
|
+
{ $eq: [ '$issueType', 'lowcount' ] }, 1, 0,
|
|
1791
|
+
],
|
|
1792
|
+
},
|
|
1793
|
+
},
|
|
1794
|
+
},
|
|
1795
|
+
{
|
|
1796
|
+
$group: {
|
|
1797
|
+
_id: null,
|
|
1798
|
+
highCount: { $sum: '$high' },
|
|
1799
|
+
LowCount: { $sum: '$low' },
|
|
1800
|
+
total: { $sum: 1 },
|
|
1801
|
+
|
|
1802
|
+
},
|
|
1803
|
+
},
|
|
1804
|
+
{
|
|
1805
|
+
$project: {
|
|
1806
|
+
_id: 0,
|
|
1807
|
+
response: [
|
|
1808
|
+
{ name: 'Low Count', count: '$LowCount' },
|
|
1809
|
+
{ name: 'High Count', count: '$highCount' },
|
|
1810
|
+
{ name: 'Total', count: '$total' },
|
|
1811
|
+
],
|
|
1812
|
+
},
|
|
1813
|
+
},
|
|
1814
|
+
|
|
1815
|
+
];
|
|
1816
|
+
|
|
1817
|
+
const response = await aggregateTangoTicket( countQuery );
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
const limit = inputData.limit || 10;
|
|
1821
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
1822
|
+
let filter = [
|
|
1823
|
+
{ issueDate: { $gte: new Date( inputData.fromDate ) } },
|
|
1824
|
+
{ issueDate: { $lte: new Date( inputData.toDate ) } },
|
|
1825
|
+
{ 'basicDetails.clientId': { $in: inputData.clientId } },
|
|
1826
|
+
{ issueType: { $in: [ 'highcount', 'lowcount' ] } },
|
|
1827
|
+
];
|
|
1828
|
+
const query = [
|
|
1829
|
+
{
|
|
1830
|
+
$match: {
|
|
1831
|
+
$and: filter,
|
|
1832
|
+
},
|
|
1833
|
+
},
|
|
1834
|
+
{
|
|
1835
|
+
$project: {
|
|
1836
|
+
createdAt: { $dateToString: { format: '%d-%m-%Y', date: '$createdAt' } },
|
|
1837
|
+
issueDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
|
|
1838
|
+
ticketId: 1,
|
|
1839
|
+
clientName: '$basicDetails.clientName',
|
|
1840
|
+
clientId: '$basicDetails.clientId',
|
|
1841
|
+
storeName: '$basicDetails.storeName',
|
|
1842
|
+
storeId: '$basicDetails.storeId',
|
|
1843
|
+
userId: { $ifNull: [ '$ticketDetails.addressingUser', '$$REMOVE' ] },
|
|
1844
|
+
issueType: 1,
|
|
1845
|
+
status: 1,
|
|
1846
|
+
|
|
1847
|
+
},
|
|
1848
|
+
},
|
|
1849
|
+
{
|
|
1850
|
+
$lookup: {
|
|
1851
|
+
from: 'users',
|
|
1852
|
+
let: { userId: '$userId' },
|
|
1853
|
+
pipeline: [
|
|
1854
|
+
{
|
|
1855
|
+
$match: {
|
|
1856
|
+
$expr: {
|
|
1857
|
+
$eq: [ '$_id', '$$userId' ],
|
|
1858
|
+
},
|
|
1859
|
+
},
|
|
1860
|
+
},
|
|
1861
|
+
{
|
|
1862
|
+
$project: {
|
|
1863
|
+
userName: 1,
|
|
1864
|
+
userType: 1,
|
|
1865
|
+
email: 1,
|
|
1866
|
+
},
|
|
1867
|
+
},
|
|
1868
|
+
], as: 'userInfo',
|
|
1869
|
+
},
|
|
1870
|
+
},
|
|
1871
|
+
|
|
1872
|
+
{
|
|
1873
|
+
$unwind: {
|
|
1874
|
+
path: '$userInfo',
|
|
1875
|
+
preserveNullAndEmptyArrays: true,
|
|
1876
|
+
},
|
|
1877
|
+
},
|
|
1878
|
+
{
|
|
1879
|
+
$project: {
|
|
1880
|
+
createdAt: 1,
|
|
1881
|
+
issueDate: 1,
|
|
1882
|
+
ticketId: 1,
|
|
1883
|
+
clientName: 1,
|
|
1884
|
+
clientId: 1,
|
|
1885
|
+
storeName: 1,
|
|
1886
|
+
storeId: 1,
|
|
1887
|
+
userName: { $ifNull: [ '$userInfo.userName', '' ] },
|
|
1888
|
+
email: { $ifNull: [ '$userInfo.email', '' ] },
|
|
1889
|
+
type: { $ifNull: [ { $cond: [ { $eq: [ '$userInfo.userType', 'client' ] }, 'external', { $cond: [ { $eq: [ '$userInfo.userType', 'tango' ] }, 'internal', '' ] } ] }, '' ] },
|
|
1890
|
+
issueType: 1,
|
|
1891
|
+
status: 1,
|
|
1892
|
+
},
|
|
1893
|
+
},
|
|
1894
|
+
|
|
1895
|
+
];
|
|
1896
|
+
|
|
1897
|
+
if ( inputData?.filterIssue && inputData?.filterIssue != '' ) {
|
|
1898
|
+
const issueType = inputData.filterIssue == 'total' ? [ 'highcount', 'lowcount' ] : [ inputData.filterIssue ];
|
|
1899
|
+
filter.push( {
|
|
1900
|
+
issueType: { $in: issueType },
|
|
1901
|
+
} );
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
if ( inputData?.filterByStores && inputData?.filterByStores?.length > 0 ) {
|
|
1905
|
+
filter.push( {
|
|
1906
|
+
'basicDetails.storeId': { $in: inputData.filterByStores },
|
|
1907
|
+
} );
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
if ( inputData?.filterByStatus && inputData?.filterByStatus?.length > 0 ) {
|
|
1911
|
+
filter.push( {
|
|
1912
|
+
status: { $in: inputData.filterByStatus },
|
|
1913
|
+
} );
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
if ( inputData?.filterByQueryType && inputData?.filterByQueryType?.length > 0 ) {
|
|
1917
|
+
query.push( {
|
|
1918
|
+
$match: {
|
|
1919
|
+
type: { $in: inputData.filterByQueryType },
|
|
1920
|
+
},
|
|
1921
|
+
} );
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
if ( inputData.searchValue && inputData.searchValue !== '' ) {
|
|
1925
|
+
filter.push( {
|
|
1926
|
+
|
|
1927
|
+
$or: [
|
|
1928
|
+
{ 'basicDetails.clientName': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1929
|
+
{ 'basicDetails.storeId': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1930
|
+
{ 'basicDetails.storeName': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1931
|
+
{ 'status': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1932
|
+
{ 'ticketId': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1933
|
+
{ 'issueType': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1934
|
+
],
|
|
1935
|
+
|
|
1936
|
+
} );
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
if ( inputData.sortColumName ) {
|
|
1940
|
+
const sortBy = inputData.sortBy || -1;
|
|
1941
|
+
query.push( {
|
|
1942
|
+
$sort: {
|
|
1943
|
+
[inputData.sortColumName == 'storeId' ? 'basicDetails.storeId' :
|
|
1944
|
+
inputData.sortColumName == 'clientName' ? 'basicDetails.clientName' :
|
|
1945
|
+
inputData.sortColumName == 'storeName' ? 'basicDetails.storeName' : inputData.sortColumName]: sortBy,
|
|
1946
|
+
},
|
|
1947
|
+
} );
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
const count = await aggregateTangoTicket( query );
|
|
1951
|
+
|
|
1952
|
+
|
|
1953
|
+
query.push(
|
|
1954
|
+
{ $skip: offset },
|
|
1955
|
+
{ $limit: limit },
|
|
1956
|
+
);
|
|
1957
|
+
const result = await aggregateTangoTicket( query );
|
|
1958
|
+
|
|
1959
|
+
|
|
1960
|
+
if ( inputData.export ) {
|
|
1961
|
+
const resultChunk = await chunkArray( count, 10 );
|
|
1962
|
+
const promises = resultChunk.map( async ( chunk ) => {
|
|
1963
|
+
const list = [];
|
|
1964
|
+
for ( let i = 0; i < chunk.length; i++ ) {
|
|
1965
|
+
req.user.userType == 'tango' ?
|
|
1966
|
+
|
|
1967
|
+
list.push( {
|
|
1968
|
+
'Created Date': chunk[i]?.createdAt,
|
|
1969
|
+
'Issue Date': chunk[i]?.issueDate,
|
|
1970
|
+
'Ticket ID': chunk[i]?.ticketId,
|
|
1971
|
+
'Brand ID': chunk[i]?.clientId,
|
|
1972
|
+
'Brand Name': chunk[i]?.clientName,
|
|
1973
|
+
'Store ID': chunk[i]?.storeId,
|
|
1974
|
+
'Store Name': chunk[i]?.storeName,
|
|
1975
|
+
'User Name': chunk[i]?.userName,
|
|
1976
|
+
'User Email': chunk[i]?.email,
|
|
1977
|
+
'Issue Type': chunk[i]?.issueType,
|
|
1978
|
+
'Type': chunk[i]?.type,
|
|
1979
|
+
'Status': chunk[i]?.status,
|
|
1980
|
+
|
|
1981
|
+
} ) :
|
|
1982
|
+
list.push( {
|
|
1983
|
+
'Created Date': chunk[i]?.createdAt,
|
|
1984
|
+
'Issue Date': chunk[i]?.issueDate,
|
|
1985
|
+
'Ticket ID': chunk[i]?.clientName,
|
|
1986
|
+
'Store ID': chunk[i]?.storeId,
|
|
1987
|
+
'Store Name': chunk[i]?.storeName,
|
|
1988
|
+
'Issue Type': chunk[i]?.issueType,
|
|
1989
|
+
'Type': chunk[i]?.type,
|
|
1990
|
+
'Status': chunk[i]?.status,
|
|
1991
|
+
} );
|
|
1992
|
+
}
|
|
1993
|
+
return list;
|
|
1994
|
+
} );
|
|
1995
|
+
const temp = await Promise.all( promises );
|
|
1996
|
+
const exportResult = temp.flat();
|
|
1997
|
+
await download( exportResult, res );
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
return res.sendSuccess( { response: response[0]?.response || defaultValue, result: result, count: count.length } );
|
|
2002
|
+
} catch ( error ) {
|
|
2003
|
+
logger.error( { error: error, function: 'dataMismatchTable' } );
|
|
2004
|
+
res.sendError( 'Internal Server Error', 500 );
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
@@ -157,6 +157,7 @@ export async function userTicketList( req, res ) {
|
|
|
157
157
|
$project: {
|
|
158
158
|
storeId: '$basicDetails.storeId',
|
|
159
159
|
storeName: '$basicDetails.storeName',
|
|
160
|
+
clientId: '$basicDetails.clientId',
|
|
160
161
|
Date: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
|
|
161
162
|
updatedAt: 1,
|
|
162
163
|
ticketId: 1,
|
|
@@ -190,6 +191,7 @@ export async function userTicketList( req, res ) {
|
|
|
190
191
|
storeId: 1,
|
|
191
192
|
storeName: 1,
|
|
192
193
|
updatedAt: 1,
|
|
194
|
+
clientId: 1,
|
|
193
195
|
Date: 1,
|
|
194
196
|
ticketId: 1,
|
|
195
197
|
issueStatus: 1,
|
|
@@ -206,6 +208,7 @@ export async function userTicketList( req, res ) {
|
|
|
206
208
|
_id: '$ticketId',
|
|
207
209
|
storeId: { $first: '$storeId' },
|
|
208
210
|
storeName: { $first: '$storeName' },
|
|
211
|
+
clientId: { $first: '$clientId' },
|
|
209
212
|
updatedAt: { $first: '$updatedAt' },
|
|
210
213
|
Date: { $first: '$Date' },
|
|
211
214
|
ticketId: { $first: '$ticketId' },
|
|
@@ -4,7 +4,7 @@ import { isAllowedSessionHandler, authorize, validate } from 'tango-app-api-midd
|
|
|
4
4
|
import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, validateTicketstatus, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
|
|
5
5
|
import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons, matTable, removeAttachment,
|
|
6
6
|
secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments, getInfraIssues,
|
|
7
|
-
updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, allCounts, infraTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
|
|
7
|
+
updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, allCounts, infraTable, dataMismatchTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
|
|
8
8
|
import { getInfraIssueValid } from '../dtos/infra.dtos.js';
|
|
9
9
|
|
|
10
10
|
|
|
@@ -76,6 +76,10 @@ infraRouter.post( '/matTable', isAllowedSessionHandler, authorize( {
|
|
|
76
76
|
userType: [ 'client', 'tango' ], access: [
|
|
77
77
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
78
78
|
} ), matTable );
|
|
79
|
+
infraRouter.post( '/dataMismatchTable', isAllowedSessionHandler, authorize( {
|
|
80
|
+
userType: [ 'client', 'tango' ], access: [
|
|
81
|
+
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
82
|
+
} ), dataMismatchTable );
|
|
79
83
|
infraRouter.post( '/assignTicket', isAllowedSessionHandler, authorize( {
|
|
80
84
|
userType: [ 'client', 'tango' ], access: [
|
|
81
85
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isEdit', 'isView' ] } ],
|