#4613 eliminar uso de portfolio #1178
|
@ -2564,10 +2564,10 @@ UPDATE `vn`.`route`
|
||||||
UPDATE `vn`.`route`
|
UPDATE `vn`.`route`
|
||||||
SET `invoiceInFk`=2
|
SET `invoiceInFk`=2
|
||||||
WHERE `id`=2;
|
WHERE `id`=2;
|
||||||
INSERT INTO `bs`.`salesPerson` (`workerFk`, `year`, `month`, `portfolioWeight`)
|
INSERT INTO `bs`.`salesPerson` (`workerFk`, `year`, `month`)
|
||||||
VALUES
|
VALUES
|
||||||
(18, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 807.23),
|
(18, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE())),
|
||||||
(19, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 34.40);
|
(19, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()));
|
||||||
|
|
||||||
INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`)
|
INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -81044,4 +81044,3 @@ USE `vncontrol`;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
-- Dump completed on 2022-09-16 10:44:31
|
-- Dump completed on 2022-09-16 10:44:31
|
||||||
|
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Client updatePortfolio', () => {
|
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'},
|
|
||||||
[`__`]: value => {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should update the portfolioWeight when the salesPerson of a client changes', async() => {
|
|
||||||
const clientId = 1108;
|
|
||||||
const salesPersonId = 18;
|
|
||||||
|
|
||||||
const tx = await models.Client.beginTransaction({});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = {transaction: tx};
|
|
||||||
const expectedResult = 841.63;
|
|
||||||
|
|
||||||
const client = await models.Client.findById(clientId, null, options);
|
|
||||||
await client.updateAttribute('salesPersonFk', salesPersonId, options);
|
|
||||||
|
|
||||||
await models.Client.updatePortfolio(options);
|
|
||||||
|
|
||||||
const portfolioQuery = `SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `;
|
|
||||||
const [salesPerson] = await models.Client.rawSql(portfolioQuery, null, options);
|
|
||||||
|
|
||||||
expect(salesPerson.portfolioWeight).toEqual(expectedResult);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => {
|
|
||||||
const clientId = 1107;
|
|
||||||
const salesPersonId = 19;
|
|
||||||
const tx = await models.Client.beginTransaction({});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = {transaction: tx};
|
|
||||||
const expectedResult = 34.40;
|
|
||||||
|
|
||||||
const client = await models.Client.findById(clientId, null, options);
|
|
||||||
await client.updateAttribute('salesPersonFk', null, options);
|
|
||||||
|
|
||||||
await models.Client.updatePortfolio();
|
|
||||||
|
|
||||||
const portfolioQuery = `SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `;
|
|
||||||
const [salesPerson] = await models.Client.rawSql(portfolioQuery);
|
|
||||||
|
|
||||||
expect(salesPerson.portfolioWeight).toEqual(expectedResult);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,25 +0,0 @@
|
||||||
module.exports = function(Self) {
|
|
||||||
Self.remoteMethodCtx('updatePortfolio', {
|
|
||||||
description: 'Update salesPeson potfolio weight',
|
|
||||||
accessType: 'READ',
|
|
||||||
accepts: [],
|
|
||||||
returns: {
|
|
||||||
type: 'Object',
|
|
||||||
root: true
|
|
||||||
},
|
|
||||||
http: {
|
|
||||||
path: `/updatePortfolio`,
|
|
||||||
verb: 'GET'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.updatePortfolio = async options => {
|
|
||||||
const myOptions = {};
|
|
||||||
|
|
||||||
if (typeof options == 'object')
|
|
||||||
Object.assign(myOptions, options);
|
|
||||||
|
|
||||||
query = `CALL bs.salesPerson_updatePortfolio()`;
|
|
||||||
return Self.rawSql(query, null, myOptions);
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -22,7 +22,6 @@ module.exports = Self => {
|
||||||
require('../methods/client/summary')(Self);
|
require('../methods/client/summary')(Self);
|
||||||
require('../methods/client/updateAddress')(Self);
|
require('../methods/client/updateAddress')(Self);
|
||||||
require('../methods/client/updateFiscalData')(Self);
|
require('../methods/client/updateFiscalData')(Self);
|
||||||
require('../methods/client/updatePortfolio')(Self);
|
|
||||||
require('../methods/client/updateUser')(Self);
|
require('../methods/client/updateUser')(Self);
|
||||||
require('../methods/client/uploadFile')(Self);
|
require('../methods/client/uploadFile')(Self);
|
||||||
require('../methods/client/campaignMetricsPdf')(Self);
|
require('../methods/client/campaignMetricsPdf')(Self);
|
||||||
|
|
|
@ -10,8 +10,6 @@ export default class Controller extends Section {
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
return this.$.watcher.submit().then(() => {
|
return this.$.watcher.submit().then(() => {
|
||||||
const query = `Clients/updatePortfolio`;
|
|
||||||
this.$http.get(query);
|
|
||||||
this.$http.get(`Clients/${this.$params.id}/checkDuplicatedData`);
|
this.$http.get(`Clients/${this.$params.id}/checkDuplicatedData`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
"jsdom": "^16.7.0",
|
"jsdom": "^16.7.0",
|
||||||
"jszip": "^3.10.0",
|
"jszip": "^3.10.0",
|
||||||
"ldapjs": "^2.2.0",
|
"ldapjs": "^2.2.0",
|
||||||
"loopback": "^3.26.0",
|
"loopback": "^3.28.0",
|
||||||
"loopback-boot": "3.3.1",
|
"loopback-boot": "3.3.1",
|
||||||
"loopback-component-explorer": "^6.5.0",
|
"loopback-component-explorer": "^6.5.0",
|
||||||
"loopback-component-storage": "3.6.1",
|
"loopback-component-storage": "3.6.1",
|
||||||
|
@ -4878,13 +4878,20 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/caniuse-lite": {
|
"node_modules/caniuse-lite": {
|
||||||
"version": "1.0.30001299",
|
"version": "1.0.30001434",
|
||||||
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001434.tgz",
|
||||||
|
"integrity": "sha512-aOBHrLmTQw//WFa2rcF1If9fa3ypkC1wzqqiKHgfdrXTWcU8C4gKVZT77eQAPWN1APys3+uQ0Df07rKauXGEYA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "CC-BY-4.0",
|
"funding": [
|
||||||
"funding": {
|
{
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
"url": "https://opencollective.com/browserslist"
|
"url": "https://opencollective.com/browserslist"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"type": "tidelift",
|
||||||
|
"url": "https://tidelift.com/funding/github/npm/caniuse-lite"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"node_modules/canonical-json": {
|
"node_modules/canonical-json": {
|
||||||
"version": "0.0.4",
|
"version": "0.0.4",
|
||||||
|
@ -12881,6 +12888,66 @@
|
||||||
"xmlcreate": "^1.0.1"
|
"xmlcreate": "^1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/jsbarcode": {
|
||||||
|
"version": "3.11.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsbarcode/-/jsbarcode-3.11.5.tgz",
|
||||||
|
"integrity": "sha512-zv3KsH51zD00I/LrFzFSM6dst7rDn0vIMzaiZFL7qusTjPZiPtxg3zxetp0RR7obmjTw4f6NyGgbdkBCgZUIrA==",
|
||||||
|
"bin": {
|
||||||
|
"auto.js": "bin/barcodes/CODE128/auto.js",
|
||||||
|
"Barcode.js": "bin/barcodes/Barcode.js",
|
||||||
|
"barcodes": "bin/barcodes",
|
||||||
|
"canvas.js": "bin/renderers/canvas.js",
|
||||||
|
"checksums.js": "bin/barcodes/MSI/checksums.js",
|
||||||
|
"codabar": "bin/barcodes/codabar",
|
||||||
|
"CODE128": "bin/barcodes/CODE128",
|
||||||
|
"CODE128_AUTO.js": "bin/barcodes/CODE128/CODE128_AUTO.js",
|
||||||
|
"CODE128.js": "bin/barcodes/CODE128/CODE128.js",
|
||||||
|
"CODE128A.js": "bin/barcodes/CODE128/CODE128A.js",
|
||||||
|
"CODE128B.js": "bin/barcodes/CODE128/CODE128B.js",
|
||||||
|
"CODE128C.js": "bin/barcodes/CODE128/CODE128C.js",
|
||||||
|
"CODE39": "bin/barcodes/CODE39",
|
||||||
|
"constants.js": "bin/barcodes/ITF/constants.js",
|
||||||
|
"defaults.js": "bin/options/defaults.js",
|
||||||
|
"EAN_UPC": "bin/barcodes/EAN_UPC",
|
||||||
|
"EAN.js": "bin/barcodes/EAN_UPC/EAN.js",
|
||||||
|
"EAN13.js": "bin/barcodes/EAN_UPC/EAN13.js",
|
||||||
|
"EAN2.js": "bin/barcodes/EAN_UPC/EAN2.js",
|
||||||
|
"EAN5.js": "bin/barcodes/EAN_UPC/EAN5.js",
|
||||||
|
"EAN8.js": "bin/barcodes/EAN_UPC/EAN8.js",
|
||||||
|
"encoder.js": "bin/barcodes/EAN_UPC/encoder.js",
|
||||||
|
"ErrorHandler.js": "bin/exceptions/ErrorHandler.js",
|
||||||
|
"exceptions": "bin/exceptions",
|
||||||
|
"exceptions.js": "bin/exceptions/exceptions.js",
|
||||||
|
"fixOptions.js": "bin/help/fixOptions.js",
|
||||||
|
"GenericBarcode": "bin/barcodes/GenericBarcode",
|
||||||
|
"getOptionsFromElement.js": "bin/help/getOptionsFromElement.js",
|
||||||
|
"getRenderProperties.js": "bin/help/getRenderProperties.js",
|
||||||
|
"help": "bin/help",
|
||||||
|
"index.js": "bin/renderers/index.js",
|
||||||
|
"index.tmp.js": "bin/barcodes/index.tmp.js",
|
||||||
|
"ITF": "bin/barcodes/ITF",
|
||||||
|
"ITF.js": "bin/barcodes/ITF/ITF.js",
|
||||||
|
"ITF14.js": "bin/barcodes/ITF/ITF14.js",
|
||||||
|
"JsBarcode.js": "bin/JsBarcode.js",
|
||||||
|
"linearizeEncodings.js": "bin/help/linearizeEncodings.js",
|
||||||
|
"merge.js": "bin/help/merge.js",
|
||||||
|
"MSI": "bin/barcodes/MSI",
|
||||||
|
"MSI.js": "bin/barcodes/MSI/MSI.js",
|
||||||
|
"MSI10.js": "bin/barcodes/MSI/MSI10.js",
|
||||||
|
"MSI1010.js": "bin/barcodes/MSI/MSI1010.js",
|
||||||
|
"MSI11.js": "bin/barcodes/MSI/MSI11.js",
|
||||||
|
"MSI1110.js": "bin/barcodes/MSI/MSI1110.js",
|
||||||
|
"object.js": "bin/renderers/object.js",
|
||||||
|
"options": "bin/options",
|
||||||
|
"optionsFromStrings.js": "bin/help/optionsFromStrings.js",
|
||||||
|
"pharmacode": "bin/barcodes/pharmacode",
|
||||||
|
"renderers": "bin/renderers",
|
||||||
|
"shared.js": "bin/renderers/shared.js",
|
||||||
|
"svg.js": "bin/renderers/svg.js",
|
||||||
|
"UPC.js": "bin/barcodes/EAN_UPC/UPC.js",
|
||||||
|
"UPCE.js": "bin/barcodes/EAN_UPC/UPCE.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/jsbn": {
|
"node_modules/jsbn": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
|
@ -23759,6 +23826,14 @@
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
},
|
},
|
||||||
|
"node_modules/xmldom": {
|
||||||
|
"version": "0.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.6.0.tgz",
|
||||||
|
"integrity": "sha512-iAcin401y58LckRZ0TkI4k0VSM1Qg0KGSc3i8rU+xrxe19A/BN1zHyVSJY7uoutVlaTSzYyk/v5AmkewAP7jtg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/xtend": {
|
"node_modules/xtend": {
|
||||||
"version": "4.0.2",
|
"version": "4.0.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -23938,6 +24013,7 @@
|
||||||
"fs-extra": "^7.0.1",
|
"fs-extra": "^7.0.1",
|
||||||
"intl": "^1.2.5",
|
"intl": "^1.2.5",
|
||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
|
"jsbarcode": "^3.11.5",
|
||||||
"jsonexport": "^3.2.0",
|
"jsonexport": "^3.2.0",
|
||||||
"juice": "^5.2.0",
|
"juice": "^5.2.0",
|
||||||
"log4js": "^6.7.0",
|
"log4js": "^6.7.0",
|
||||||
|
@ -23948,7 +24024,8 @@
|
||||||
"strftime": "^0.10.0",
|
"strftime": "^0.10.0",
|
||||||
"vue": "^2.6.10",
|
"vue": "^2.6.10",
|
||||||
"vue-i18n": "^8.15.0",
|
"vue-i18n": "^8.15.0",
|
||||||
"vue-server-renderer": "^2.6.10"
|
"vue-server-renderer": "^2.6.10",
|
||||||
|
"xmldom": "^0.6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"print/node_modules/fs-extra": {
|
"print/node_modules/fs-extra": {
|
||||||
|
@ -28107,7 +28184,9 @@
|
||||||
"version": "1.0.0"
|
"version": "1.0.0"
|
||||||
},
|
},
|
||||||
"caniuse-lite": {
|
"caniuse-lite": {
|
||||||
"version": "1.0.30001299",
|
"version": "1.0.30001434",
|
||||||
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001434.tgz",
|
||||||
|
"integrity": "sha512-aOBHrLmTQw//WFa2rcF1If9fa3ypkC1wzqqiKHgfdrXTWcU8C4gKVZT77eQAPWN1APys3+uQ0Df07rKauXGEYA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"canonical-json": {
|
"canonical-json": {
|
||||||
|
@ -39828,6 +39907,11 @@
|
||||||
"xmlcreate": "^1.0.1"
|
"xmlcreate": "^1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"jsbarcode": {
|
||||||
|
"version": "3.11.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsbarcode/-/jsbarcode-3.11.5.tgz",
|
||||||
|
"integrity": "sha512-zv3KsH51zD00I/LrFzFSM6dst7rDn0vIMzaiZFL7qusTjPZiPtxg3zxetp0RR7obmjTw4f6NyGgbdkBCgZUIrA=="
|
||||||
|
},
|
||||||
"jsbn": {
|
"jsbn": {
|
||||||
"version": "0.1.1"
|
"version": "0.1.1"
|
||||||
},
|
},
|
||||||
|
@ -57805,6 +57889,7 @@
|
||||||
"fs-extra": "^7.0.1",
|
"fs-extra": "^7.0.1",
|
||||||
"intl": "^1.2.5",
|
"intl": "^1.2.5",
|
||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
|
"jsbarcode": "^3.11.5",
|
||||||
"jsonexport": "^3.2.0",
|
"jsonexport": "^3.2.0",
|
||||||
"juice": "^5.2.0",
|
"juice": "^5.2.0",
|
||||||
"log4js": "^6.7.0",
|
"log4js": "^6.7.0",
|
||||||
|
@ -57815,7 +57900,8 @@
|
||||||
"strftime": "^0.10.0",
|
"strftime": "^0.10.0",
|
||||||
"vue": "^2.6.10",
|
"vue": "^2.6.10",
|
||||||
"vue-i18n": "^8.15.0",
|
"vue-i18n": "^8.15.0",
|
||||||
"vue-server-renderer": "^2.6.10"
|
"vue-server-renderer": "^2.6.10",
|
||||||
|
"xmldom": "^0.6.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fs-extra": {
|
"fs-extra": {
|
||||||
|
@ -59678,6 +59764,11 @@
|
||||||
"resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-1.0.2.tgz",
|
||||||
"integrity": "sha512-Mbe56Dvj00onbnSo9J0qj/XlY5bfN9KidsOnpd5tRCsR3ekB3hyyNU9fGrTdqNT5ZNvv4BsA2TcQlignsZyVcw=="
|
"integrity": "sha512-Mbe56Dvj00onbnSo9J0qj/XlY5bfN9KidsOnpd5tRCsR3ekB3hyyNU9fGrTdqNT5ZNvv4BsA2TcQlignsZyVcw=="
|
||||||
},
|
},
|
||||||
|
"xmldom": {
|
||||||
|
"version": "0.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.6.0.tgz",
|
||||||
|
"integrity": "sha512-iAcin401y58LckRZ0TkI4k0VSM1Qg0KGSc3i8rU+xrxe19A/BN1zHyVSJY7uoutVlaTSzYyk/v5AmkewAP7jtg=="
|
||||||
|
},
|
||||||
"xtend": {
|
"xtend": {
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
|
|
Loading…
Reference in New Issue