my-typescript-library-rahul52us 2.4.5 → 2.4.6
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/dist/routes/org.route.js +1 -0
- package/dist/routes/org.route.js.map +1 -1
- package/dist/services/organisation/organisation.service.js +68 -1
- package/dist/services/organisation/organisation.service.js.map +1 -1
- package/dist/types/services/organisation/organisation.service.d.ts +1 -0
- package/package.json +1 -1
- package/src/routes/org.route.ts +2 -1
- package/src/services/organisation/organisation.service.ts +68 -0
package/dist/routes/org.route.js
CHANGED
|
@@ -8,6 +8,7 @@ const auth_controller_1 = require("../controllers/auth.controller");
|
|
|
8
8
|
const organisation_service_1 = require("../services/organisation/organisation.service");
|
|
9
9
|
const Organisation = express_1.default.Router();
|
|
10
10
|
Organisation.post('/create', auth_controller_1.authenticateJWT, organisation_service_1.createOrganizationService);
|
|
11
|
+
Organisation.post('/getVendorAddress', auth_controller_1.authenticateJWT, organisation_service_1.getVendorAddressDetails);
|
|
11
12
|
Organisation.get('/get', auth_controller_1.authenticateJWT, organisation_service_1.getOrgDetailsService);
|
|
12
13
|
Organisation.get('/getall', auth_controller_1.authenticateJWT, organisation_service_1.getOrganisationService);
|
|
13
14
|
Organisation.get('/getcount', auth_controller_1.authenticateJWT, organisation_service_1.getComplainceCountService);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"org.route.js","sourceRoot":"","sources":["../../src/routes/org.route.ts"],"names":[],"mappings":";;;;;AAAA,sDAA2E;AAC3E,oEAAiE;AACjE,
|
|
1
|
+
{"version":3,"file":"org.route.js","sourceRoot":"","sources":["../../src/routes/org.route.ts"],"names":[],"mappings":";;;;;AAAA,sDAA2E;AAC3E,oEAAiE;AACjE,wFAAuN;AAGvN,MAAM,YAAY,GAAG,iBAAO,CAAC,MAAM,EAAE,CAAC;AAEtC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,iCAAe,EAAE,gDAAyB,CAAC,CAAA;AACxE,YAAY,CAAC,IAAI,CAAC,mBAAmB,EAAC,iCAAe,EAAC,8CAAuB,CAAC,CAAA;AAC9E,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,iCAAe,EAAE,2CAAoB,CAAC,CAAA;AAC/D,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,iCAAe,EAAE,6CAAsB,CAAC,CAAA;AACpE,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,iCAAe,EAAE,gDAAyB,CAAC,CAAA;AACzE,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,iCAAe,EAAE,gDAAyB,CAAC,CAAA;AAEvE,kBAAe,YAAY,CAAC"}
|
|
@@ -8,10 +8,77 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getComplainceCountService = exports.getOrganisationService = exports.updateOrganisationHandler = exports.findOrgDetailsService = exports.getOrgDetailsService = exports.createOrganizationService = void 0;
|
|
15
|
+
exports.getComplainceCountService = exports.getOrganisationService = exports.updateOrganisationHandler = exports.findOrgDetailsService = exports.getOrgDetailsService = exports.createOrganizationService = exports.getVendorAddressDetails = void 0;
|
|
13
16
|
const organisation_repository_1 = require("../../repository/organisation.repository");
|
|
14
17
|
const filesystem_repository_1 = require("../../repository/filesystem.repository");
|
|
18
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
19
|
+
function getVendorAddressDetails(req, res) {
|
|
20
|
+
var _a, _b, _c;
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
try {
|
|
23
|
+
let datas = {};
|
|
24
|
+
if (process.env.domain === "indoco") {
|
|
25
|
+
const Organisation = mongoose_1.default.models["Organisation"];
|
|
26
|
+
const orgBase = yield Organisation.findOne({
|
|
27
|
+
onboardingId: (_a = req === null || req === void 0 ? void 0 : req.body) === null || _a === void 0 ? void 0 : _a.documentId
|
|
28
|
+
});
|
|
29
|
+
if (orgBase) {
|
|
30
|
+
let addresses = [];
|
|
31
|
+
let pan = null;
|
|
32
|
+
const orgs = yield Organisation.find({
|
|
33
|
+
vendorName: {
|
|
34
|
+
$regex: `^${(_b = orgBase.vendorName) === null || _b === void 0 ? void 0 : _b.trim()}$`,
|
|
35
|
+
$options: "i",
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
if (Array.isArray(orgs) && orgs.length > 0) {
|
|
39
|
+
const approvedOrgs = orgs.filter((org) => org.status === "approved");
|
|
40
|
+
const validOrgs = orgs.filter((org) => org.status !== "rejected");
|
|
41
|
+
if (validOrgs.length > 0) {
|
|
42
|
+
pan = approvedOrgs.length > 0 ? approvedOrgs[0].gstin : (_c = validOrgs[0]) === null || _c === void 0 ? void 0 : _c.gstin;
|
|
43
|
+
const seenAddresses = new Set();
|
|
44
|
+
addresses = validOrgs
|
|
45
|
+
.map((org) => {
|
|
46
|
+
var _a;
|
|
47
|
+
const address = (_a = org === null || org === void 0 ? void 0 : org.values) === null || _a === void 0 ? void 0 : _a.billingAddress;
|
|
48
|
+
const vendorCode = org === null || org === void 0 ? void 0 : org.vendorCode;
|
|
49
|
+
return address ? { address, vendorCode } : null;
|
|
50
|
+
})
|
|
51
|
+
.filter((item) => {
|
|
52
|
+
if (!item || seenAddresses.has(item.address))
|
|
53
|
+
return false;
|
|
54
|
+
seenAddresses.add(item.address);
|
|
55
|
+
return true;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
datas = { addresses, pan, vendorName: orgBase.vendorName };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return res.status(200).send({
|
|
62
|
+
status: 'success',
|
|
63
|
+
message: 'Retrive Vendor Address details',
|
|
64
|
+
data: datas
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
res.status(200).send({
|
|
68
|
+
status: 'success',
|
|
69
|
+
message: 'Retrive Vendor Address details',
|
|
70
|
+
data: datas
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
res.status(500).send({
|
|
75
|
+
message: err === null || err === void 0 ? void 0 : err.message,
|
|
76
|
+
data: err === null || err === void 0 ? void 0 : err.message
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
exports.getVendorAddressDetails = getVendorAddressDetails;
|
|
15
82
|
function createOrganizationService(req, res) {
|
|
16
83
|
var _a, _b;
|
|
17
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation.service.js","sourceRoot":"","sources":["../../../src/services/organisation/organisation.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"organisation.service.js","sourceRoot":"","sources":["../../../src/services/organisation/organisation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sFAA6J;AAE7J,kFAAoE;AACpE,wDAAgC;AAShC,SAAsB,uBAAuB,CAAC,GAAS,EAAE,GAAS;;;QAC9D,IACA;YACI,IAAI,KAAK,GAAS,EAAE,CAAA;YACpB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,QAAQ,EAAE;gBACjC,MAAM,YAAY,GAAG,kBAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;gBAErD,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC;oBACzC,YAAY,EAAE,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,0CAAE,UAAU;iBACpC,CAAC,CAAC;gBAEH,IAAI,OAAO,EAAE;oBACX,IAAI,SAAS,GAA8C,EAAE,CAAC;oBAC9D,IAAI,GAAG,GAAkB,IAAI,CAAC;oBAE9B,MAAM,IAA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AC,KAAK,CAAC,GAAa,IAAI,IAAI,CAAC;YAC1C,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAa,IAAI,IAAI,CAAC;YAC5C,MAAM,KAAK,GAAG,MAAM,IAAA,+CAAqB,EAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;YACjF,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACtC;QACD,OAAO,KAAK,EAAE;YACV,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;SACpE;IACL,CAAC;CAAA;AAbD,8DAaC;AAAA,CAAC"}
|
|
@@ -5,6 +5,7 @@ interface UserRequest extends Request {
|
|
|
5
5
|
_id?: string;
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
+
export declare function getVendorAddressDetails(req: any, res: any): Promise<any>;
|
|
8
9
|
export declare function createOrganizationService(req: any, res: Response): Promise<any>;
|
|
9
10
|
export declare function getOrgDetailsService(req: UserRequest, res: Response): Promise<any>;
|
|
10
11
|
export declare function findOrgDetailsService(req: UserRequest, res: Response): Promise<any>;
|
package/package.json
CHANGED
package/src/routes/org.route.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import express, { Request, Response, NextFunction, Router } from 'express';
|
|
2
2
|
import { authenticateJWT } from '../controllers/auth.controller';
|
|
3
|
-
import { createOrganizationService, getComplainceCountService, getOrgDetailsService, getOrganisationService, updateOrganisationHandler } from '../services/organisation/organisation.service';
|
|
3
|
+
import { createOrganizationService, getComplainceCountService, getOrgDetailsService, getOrganisationService, getVendorAddressDetails, updateOrganisationHandler } from '../services/organisation/organisation.service';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const Organisation = express.Router();
|
|
7
7
|
|
|
8
8
|
Organisation.post('/create', authenticateJWT, createOrganizationService)
|
|
9
|
+
Organisation.post('/getVendorAddress',authenticateJWT,getVendorAddressDetails)
|
|
9
10
|
Organisation.get('/get', authenticateJWT, getOrgDetailsService)
|
|
10
11
|
Organisation.get('/getall', authenticateJWT, getOrganisationService)
|
|
11
12
|
Organisation.get('/getcount', authenticateJWT, getComplainceCountService)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createOrg, findOrgById, updateorganisation, getOrgDetails, getCompliancesDetails, findOrgDetails } from '../../repository/organisation.repository';
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { uploadFile } from '../../repository/filesystem.repository';
|
|
4
|
+
import mongoose from 'mongoose';
|
|
4
5
|
|
|
5
6
|
interface UserRequest extends Request {
|
|
6
7
|
user?: {
|
|
@@ -9,6 +10,73 @@ interface UserRequest extends Request {
|
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
export async function getVendorAddressDetails(req : any, res : any){
|
|
14
|
+
try
|
|
15
|
+
{
|
|
16
|
+
let datas : any = {}
|
|
17
|
+
if (process.env.domain === "indoco") {
|
|
18
|
+
const Organisation = mongoose.models["Organisation"];
|
|
19
|
+
|
|
20
|
+
const orgBase = await Organisation.findOne({
|
|
21
|
+
onboardingId: req?.body?.documentId
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (orgBase) {
|
|
25
|
+
let addresses: { address: string; vendorCode: string }[] = [];
|
|
26
|
+
let pan: string | null = null;
|
|
27
|
+
|
|
28
|
+
const orgs = await Organisation.find({
|
|
29
|
+
vendorName: {
|
|
30
|
+
$regex: `^${orgBase.vendorName?.trim()}$`,
|
|
31
|
+
$options: "i",
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (Array.isArray(orgs) && orgs.length > 0) {
|
|
36
|
+
const approvedOrgs = orgs.filter((org: any) => org.status === "approved");
|
|
37
|
+
const validOrgs = orgs.filter((org: any) => org.status !== "rejected");
|
|
38
|
+
|
|
39
|
+
if (validOrgs.length > 0) {
|
|
40
|
+
pan = approvedOrgs.length > 0 ? approvedOrgs[0].gstin : validOrgs[0]?.gstin;
|
|
41
|
+
|
|
42
|
+
const seenAddresses = new Set<string>();
|
|
43
|
+
addresses = validOrgs
|
|
44
|
+
.map((org: any) => {
|
|
45
|
+
const address = org?.values?.billingAddress;
|
|
46
|
+
const vendorCode = org?.vendorCode;
|
|
47
|
+
return address ? { address, vendorCode } : null;
|
|
48
|
+
})
|
|
49
|
+
.filter((item): item is { address: string; vendorCode: string } => {
|
|
50
|
+
if (!item || seenAddresses.has(item.address)) return false;
|
|
51
|
+
seenAddresses.add(item.address);
|
|
52
|
+
return true;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
datas = { addresses, pan, vendorName : orgBase.vendorName };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return res.status(200).send({
|
|
60
|
+
status : 'success',
|
|
61
|
+
message : 'Retrive Vendor Address details',
|
|
62
|
+
data : datas
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
res.status(200).send({
|
|
67
|
+
status : 'success',
|
|
68
|
+
message : 'Retrive Vendor Address details',
|
|
69
|
+
data : datas
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
catch(err : any)
|
|
73
|
+
{
|
|
74
|
+
res.status(500).send({
|
|
75
|
+
message : err?.message,
|
|
76
|
+
data : err?.message
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
}
|
|
12
80
|
|
|
13
81
|
export async function createOrganizationService(req: any, res: Response
|
|
14
82
|
): Promise<any> {
|