Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
4535795515
|
@ -4,15 +4,7 @@ describe('collection getSales()', () => {
|
||||||
const collectionOrTicketFk = 999999;
|
const collectionOrTicketFk = 999999;
|
||||||
const print = true;
|
const print = true;
|
||||||
const source = 'CHECKER';
|
const source = 'CHECKER';
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
beforeAll(() => {
|
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return a collection with tickets, placements and barcodes settled correctly', async() => {
|
it('should return a collection with tickets, placements and barcodes settled correctly', async() => {
|
||||||
const tx = await models.Collection.beginTransaction({});
|
const tx = await models.Collection.beginTransaction({});
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('collection getTickets()', () => {
|
describe('collection getTickets()', () => {
|
||||||
let ctx;
|
const ctx = beforeAll.getCtx();
|
||||||
beforeAll(async() => {
|
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should get tickets, sales and barcodes from collection', async() => {
|
it('should get tickets, sales and barcodes from collection', async() => {
|
||||||
const tx = await models.Collection.beginTransaction({});
|
const tx = await models.Collection.beginTransaction({});
|
||||||
|
|
|
@ -1,20 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('setSaleQuantity()', () => {
|
describe('setSaleQuantity()', () => {
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should change quantity sale', async() => {
|
it('should change quantity sale', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
|
@ -1,22 +1,7 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('getStarredModules()', () => {
|
describe('getStarredModules()', () => {
|
||||||
const activeCtx = {
|
const ctx = beforeAll.getCtx();
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const ctx = {req: activeCtx};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should return the starred modules for a given user`, async() => {
|
it(`should return the starred modules for a given user`, async() => {
|
||||||
const newStarred = await models.StarredModule.create({workerFk: 9, moduleFk: 'customer', position: 1});
|
const newStarred = await models.StarredModule.create({workerFk: 9, moduleFk: 'customer', position: 1});
|
||||||
|
|
|
@ -1,24 +1,8 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('setPosition()', () => {
|
describe('setPosition()', () => {
|
||||||
const activeCtx = {
|
const ctx = beforeAll.getCtx();
|
||||||
accessToken: {userId: 9},
|
beforeAll.mockLoopBackContext();
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const ctx = {
|
|
||||||
req: activeCtx
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should increase the orders module position by replacing it with clients and vice versa', async() => {
|
it('should increase the orders module position by replacing it with clients and vice versa', async() => {
|
||||||
const tx = await models.StarredModule.beginTransaction({});
|
const tx = await models.StarredModule.beginTransaction({});
|
||||||
|
|
|
@ -1,24 +1,7 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('toggleStarredModule()', () => {
|
describe('toggleStarredModule()', () => {
|
||||||
const activeCtx = {
|
const ctx = beforeAll.getCtx();
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const ctx = {
|
|
||||||
req: activeCtx
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create a new starred module and then remove it by calling the method again with same args', async() => {
|
it('should create a new starred module and then remove it by calling the method again with same args', async() => {
|
||||||
const starredModule = await models.StarredModule.toggleStarredModule(ctx, 'order');
|
const starredModule = await models.StarredModule.toggleStarredModule(ctx, 'order');
|
||||||
|
@ -26,7 +9,7 @@ describe('toggleStarredModule()', () => {
|
||||||
|
|
||||||
expect(starredModules.length).toEqual(1);
|
expect(starredModules.length).toEqual(1);
|
||||||
expect(starredModule.moduleFk).toEqual('order');
|
expect(starredModule.moduleFk).toEqual('order');
|
||||||
expect(starredModule.workerFk).toEqual(activeCtx.accessToken.userId);
|
expect(starredModule.workerFk).toEqual(ctx.req.accessToken.userId);
|
||||||
expect(starredModule.position).toEqual(starredModules.length);
|
expect(starredModule.position).toEqual(starredModules.length);
|
||||||
|
|
||||||
await models.StarredModule.toggleStarredModule(ctx, 'order');
|
await models.StarredModule.toggleStarredModule(ctx, 'order');
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('userConfig getUserConfig()', () => {
|
describe('userConfig getUserConfig()', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
it(`should return the configuration data of a given user`, async() => {
|
it(`should return the configuration data of a given user`, async() => {
|
||||||
const tx = await models.Item.beginTransaction({});
|
const tx = await models.Item.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const result = await models.UserConfig.getUserConfig(ctx, options);
|
const result = await models.UserConfig.getUserConfig(ctx, options);
|
||||||
|
|
||||||
expect(result.warehouseFk).toEqual(1);
|
expect(result.warehouseFk).toEqual(1);
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('loopback model MailAliasAccount', () => {
|
describe('loopback model MailAliasAccount', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
it('should add a mail Alias', async() => {
|
it('should add a mail Alias', async() => {
|
||||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
const tx = await models.MailAliasAccount.beginTransaction({});
|
||||||
let error;
|
let error;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx, accessToken: {userId: 9}};
|
const options = {transaction: tx, ctx};
|
||||||
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
|
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -23,7 +24,7 @@ describe('loopback model MailAliasAccount', () => {
|
||||||
let error;
|
let error;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx, accessToken: {userId: 9}};
|
const options = {transaction: tx, ctx};
|
||||||
await models.MailAliasAccount.create({mailAlias: 3, account: 5}, options);
|
await models.MailAliasAccount.create({mailAlias: 3, account: 5}, options);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
|
@ -10,7 +10,6 @@ async function init() {
|
||||||
host: process.env.DB_HOST,
|
host: process.env.DB_HOST,
|
||||||
port: process.env.DB_PORT
|
port: process.env.DB_PORT
|
||||||
});
|
});
|
||||||
|
|
||||||
const bootOptions = {dataSources};
|
const bootOptions = {dataSources};
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
app.boot(bootOptions,
|
app.boot(bootOptions,
|
||||||
|
@ -33,3 +32,4 @@ module.exports = {
|
||||||
|
|
||||||
if (require.main === module)
|
if (require.main === module)
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ async function test() {
|
||||||
'loopback/**/*[sS]pec.js',
|
'loopback/**/*[sS]pec.js',
|
||||||
'modules/*/back/**/*.[sS]pec.js'
|
'modules/*/back/**/*.[sS]pec.js'
|
||||||
],
|
],
|
||||||
helpers: []
|
helpers: [`back/vn-jasmine.js`],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (PARALLEL) {
|
if (PARALLEL) {
|
||||||
|
@ -114,7 +114,6 @@ async function test() {
|
||||||
if (opts.ci)
|
if (opts.ci)
|
||||||
runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = SPEC_TIMEOUT;
|
runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = SPEC_TIMEOUT;
|
||||||
|
|
||||||
// runner.loadConfigFile('back/jasmine.json');
|
|
||||||
runner.loadConfig(config);
|
runner.loadConfig(config);
|
||||||
process.env.SPEC_IS_RUNNING = true;
|
process.env.SPEC_IS_RUNNING = true;
|
||||||
await runner.execute();
|
await runner.execute();
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
const getAccessToken = (userId = 9) => {
|
||||||
|
return {accessToken: {userId}};
|
||||||
|
};
|
||||||
|
const DEFAULT_HEADERS = {headers: {origin: 'http://localhost'}};
|
||||||
|
const default_before_all = userId => {
|
||||||
|
return {
|
||||||
|
req: {
|
||||||
|
...getAccessToken(userId),
|
||||||
|
...DEFAULT_HEADERS,
|
||||||
|
...{__: value => value}
|
||||||
|
|
||||||
|
},
|
||||||
|
args: {}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const default_loopback_ctx = userId => {
|
||||||
|
return {
|
||||||
|
...getAccessToken(userId),
|
||||||
|
...default_before_all(userId),
|
||||||
|
http: {
|
||||||
|
...default_before_all(userId)
|
||||||
|
},
|
||||||
|
args: {}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
function vnBeforeAll() {
|
||||||
|
Object.assign(beforeAll, {getCtx: default_before_all, mockLoopBackContext});
|
||||||
|
}
|
||||||
|
|
||||||
|
const mockLoopBackContext = userId => {
|
||||||
|
const activeCtx = default_loopback_ctx(userId);
|
||||||
|
beforeAll(() => {
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
active: activeCtx
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return activeCtx;
|
||||||
|
};
|
||||||
|
module.exports = {
|
||||||
|
mockLoopBackContext
|
||||||
|
};
|
||||||
|
|
||||||
|
(function init() {
|
||||||
|
vnBeforeAll();
|
||||||
|
})();
|
|
@ -3232,7 +3232,6 @@ INSERT IGNORE INTO vn.itemType
|
||||||
workerFk = 103,
|
workerFk = 103,
|
||||||
isInventory = TRUE,
|
isInventory = TRUE,
|
||||||
life = 10,
|
life = 10,
|
||||||
density = 250,
|
|
||||||
itemPackingTypeFk = NULL,
|
itemPackingTypeFk = NULL,
|
||||||
temperatureFk = 'warm';
|
temperatureFk = 'warm';
|
||||||
|
|
||||||
|
@ -3912,4 +3911,3 @@ VALUES(1, '');
|
||||||
INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode,
|
INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode,
|
||||||
truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments)
|
truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments)
|
||||||
VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL);
|
VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL);
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ BEGIN
|
||||||
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||||
JOIN vn.component c ON c.id = sc.componentFk
|
JOIN vn.component c ON c.id = sc.componentFk
|
||||||
JOIN vn.componentType ct ON ct.id = c.typeFk
|
JOIN vn.componentType ct ON ct.id = c.typeFk
|
||||||
WHERE ct.code = 'FREIGHT'
|
WHERE ct.code = 'freight'
|
||||||
AND r.created BETWEEN vDatedFrom AND vDatedTo
|
AND r.created BETWEEN vDatedFrom AND vDatedTo
|
||||||
GROUP BY r.id
|
GROUP BY r.id
|
||||||
) sub ON sub.routeFk = r.Id_Ruta
|
) sub ON sub.routeFk = r.Id_Ruta
|
||||||
|
|
|
@ -2,7 +2,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
SQL SECURITY DEFINER
|
SQL SECURITY DEFINER
|
||||||
VIEW `bi`.`tarifa_componentes_series`
|
VIEW `bi`.`tarifa_componentes_series`
|
||||||
AS SELECT `ct`.`id` AS `tarifa_componentes_series_id`,
|
AS SELECT `ct`.`id` AS `tarifa_componentes_series_id`,
|
||||||
`ct`.`type` AS `Serie`,
|
`ct`.`name` AS `Serie`,
|
||||||
`ct`.`isBase` AS `base`,
|
`ct`.`isBase` AS `base`,
|
||||||
`ct`.`isMargin` AS `margen`
|
`ct`.`isMargin` AS `margen`
|
||||||
FROM `vn`.`componentType` `ct`
|
FROM `vn`.`componentType` `ct`
|
||||||
|
|
|
@ -7,7 +7,6 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vRewriteKop INT DEFAULT NULL;
|
DECLARE vRewriteKop INT DEFAULT NULL;
|
||||||
DECLARE vTruncatePutOrder INT DEFAULT NULL;
|
DECLARE vTruncatePutOrder INT DEFAULT NULL;
|
||||||
DECLARE vBarcode CHAR(15) DEFAULT NULL;
|
|
||||||
DECLARE vKop INT;
|
DECLARE vKop INT;
|
||||||
DECLARE vPutOrderFk BIGINT;
|
DECLARE vPutOrderFk BIGINT;
|
||||||
|
|
||||||
|
@ -16,17 +15,6 @@ BEGIN
|
||||||
FROM ekt
|
FROM ekt
|
||||||
WHERE id = vSelf;
|
WHERE id = vSelf;
|
||||||
|
|
||||||
-- Generates the barcode
|
|
||||||
|
|
||||||
SELECT CONCAT(
|
|
||||||
LPAD(IFNULL(auction,0), 3, 0),
|
|
||||||
LPAD(IFNULL(klo, 99), 2, 0),
|
|
||||||
LPAD(DAYOFYEAR(fec), 3, 0),
|
|
||||||
COALESCE(agj, RIGHT(batchNumber,7), id))
|
|
||||||
INTO vBarcode
|
|
||||||
FROM ekt
|
|
||||||
WHERE id = vSelf;
|
|
||||||
|
|
||||||
-- Rewrites the kop parameter
|
-- Rewrites the kop parameter
|
||||||
|
|
||||||
IF vKop IS NULL THEN
|
IF vKop IS NULL THEN
|
||||||
|
@ -46,10 +34,9 @@ BEGIN
|
||||||
|
|
||||||
-- Refresh EKT
|
-- Refresh EKT
|
||||||
|
|
||||||
UPDATE ekt SET
|
UPDATE ekt
|
||||||
barcode = vBarcode
|
SET kop = vKop,
|
||||||
,kop = vKop
|
putOrderFk = vTruncatePutOrder
|
||||||
,putOrderFk = vTruncatePutOrder
|
|
||||||
WHERE id = vSelf;
|
WHERE id = vSelf;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -2,7 +2,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
SQL SECURITY DEFINER
|
SQL SECURITY DEFINER
|
||||||
VIEW `edi`.`ektRecent`
|
VIEW `edi`.`ektRecent`
|
||||||
AS SELECT `e`.`id` AS `id`,
|
AS SELECT `e`.`id` AS `id`,
|
||||||
`e`.`barcode` AS `barcode`,
|
|
||||||
`e`.`entryYear` AS `entryYear`,
|
`e`.`entryYear` AS `entryYear`,
|
||||||
`e`.`batchNumber` AS `batchNumber`,
|
`e`.`batchNumber` AS `batchNumber`,
|
||||||
`e`.`deliveryNumber` AS `deliveryNumber`,
|
`e`.`deliveryNumber` AS `deliveryNumber`,
|
||||||
|
|
|
@ -6,19 +6,6 @@ BEGIN
|
||||||
* identificando y notificando los asientos descuadrados
|
* identificando y notificando los asientos descuadrados
|
||||||
* y ajustando los saldos en caso necesario.
|
* y ajustando los saldos en caso necesario.
|
||||||
*/
|
*/
|
||||||
INSERT INTO mail (receiver, subject, body)
|
|
||||||
SELECT 'cau@verdnatura.es',
|
|
||||||
'Asientos descuadrados',
|
|
||||||
GROUP_CONCAT(CONCAT(' Asiento: ', ASIEN, ' - Importe:', recon) SEPARATOR ' | \n')
|
|
||||||
FROM (
|
|
||||||
SELECT ASIEN,
|
|
||||||
SUM(IFNULL(ROUND(Eurodebe, 2), 0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) recon
|
|
||||||
FROM XDiario
|
|
||||||
WHERE NOT enlazado
|
|
||||||
GROUP BY ASIEN
|
|
||||||
HAVING ABS(SUM(IFNULL(ROUND(Eurodebe, 2), 0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0))) > 0.01
|
|
||||||
) sub
|
|
||||||
HAVING COUNT(*);
|
|
||||||
|
|
||||||
UPDATE XDiario xd
|
UPDATE XDiario xd
|
||||||
JOIN (
|
JOIN (
|
||||||
|
|
|
@ -8,7 +8,7 @@ BEGIN
|
||||||
JOIN vn.component c ON c.id = sc.componentFk
|
JOIN vn.component c ON c.id = sc.componentFk
|
||||||
JOIN vn.componentType ct ON ct.id = c.typeFk
|
JOIN vn.componentType ct ON ct.id = c.typeFk
|
||||||
WHERE s.ticketFk = vTicketFk
|
WHERE s.ticketFk = vTicketFk
|
||||||
AND ct.`type` = 'otros';
|
AND ct.code = 'other';
|
||||||
|
|
||||||
UPDATE vn.sale s
|
UPDATE vn.sale s
|
||||||
JOIN (
|
JOIN (
|
||||||
|
|
|
@ -20,7 +20,8 @@ BEGIN
|
||||||
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||||
JOIN saleComponent sc ON sc.saleFk = s.id
|
JOIN saleComponent sc ON sc.saleFk = s.id
|
||||||
JOIN component c ON c.id = sc.componentFk
|
JOIN component c ON c.id = sc.componentFk
|
||||||
JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 1
|
JOIN componentType ct ON ct.id = c.typeFk
|
||||||
|
AND ct.code = 'cost'
|
||||||
WHERE t.shipped BETWEEN vShippedFrom AND vShippedTo
|
WHERE t.shipped BETWEEN vShippedFrom AND vShippedTo
|
||||||
AND ic.merchandise;
|
AND ic.merchandise;
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ BEGIN
|
||||||
JOIN vn.componentType ct ON ct.id = c.typeFk
|
JOIN vn.componentType ct ON ct.id = c.typeFk
|
||||||
JOIN vn.sale s ON s.id = sc.saleFk
|
JOIN vn.sale s ON s.id = sc.saleFk
|
||||||
JOIN tmp.ticket t ON t.ticketFk = s.ticketFk
|
JOIN tmp.ticket t ON t.ticketFk = s.ticketFk
|
||||||
WHERE ct.code = 'FREIGHT'
|
WHERE ct.code = 'freight'
|
||||||
GROUP BY t.ticketFk) sb ON sb.ticketFk = tf.ticketFk
|
GROUP BY t.ticketFk) sb ON sb.ticketFk = tf.ticketFk
|
||||||
SET tf.freight = sb.freight;
|
SET tf.freight = sb.freight;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ BEGIN
|
||||||
|
|
||||||
-- Margin
|
-- Margin
|
||||||
UPDATE tmp.ticketFloramondo tf
|
UPDATE tmp.ticketFloramondo tf
|
||||||
JOIN (SELECT SUM(IF(ct.code = 'COST',sc.value, 0)) cost,
|
JOIN (SELECT SUM(IF(ct.code = 'cost',sc.value, 0)) cost,
|
||||||
SUM(IF(ct.isMargin, sc.value, 0)) margin,
|
SUM(IF(ct.isMargin, sc.value, 0)) margin,
|
||||||
t.ticketFk
|
t.ticketFk
|
||||||
FROM vn.saleComponent sc
|
FROM vn.saleComponent sc
|
||||||
|
|
|
@ -19,4 +19,4 @@ FROM (
|
||||||
)
|
)
|
||||||
JOIN `vn`.`componentType` `ct` ON(`ct`.`id` = `c`.`typeFk`)
|
JOIN `vn`.`componentType` `ct` ON(`ct`.`id` = `c`.`typeFk`)
|
||||||
)
|
)
|
||||||
WHERE `ct`.`type` = 'coste'
|
WHERE `ct`.`code` = 'cost'
|
||||||
|
|
|
@ -16,6 +16,6 @@ FROM (
|
||||||
)
|
)
|
||||||
JOIN `vn`.`componentType` `ct` ON(
|
JOIN `vn`.`componentType` `ct` ON(
|
||||||
`ct`.`id` = `c`.`typeFk`
|
`ct`.`id` = `c`.`typeFk`
|
||||||
AND `ct`.`type` = 'agencia'
|
AND `ct`.`code` = 'freight'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,14 +9,9 @@ AS SELECT `it`.`id` AS `tipo_id`,
|
||||||
`it`.`workerFk` AS `Id_Trabajador`,
|
`it`.`workerFk` AS `Id_Trabajador`,
|
||||||
`it`.`life` AS `life`,
|
`it`.`life` AS `life`,
|
||||||
`it`.`isPackaging` AS `isPackaging`,
|
`it`.`isPackaging` AS `isPackaging`,
|
||||||
`it`.`density` AS `density`,
|
|
||||||
`it`.`isInventory` AS `inventory`,
|
`it`.`isInventory` AS `inventory`,
|
||||||
`it`.`created` AS `odbc_date`,
|
`it`.`created` AS `odbc_date`,
|
||||||
`it`.`making` AS `confeccion`,
|
`it`.`making` AS `confeccion`,
|
||||||
`it`.`temperatureFk` AS `Temperatura`,
|
`it`.`temperatureFk` AS `Temperatura`,
|
||||||
`it`.`promo` AS `promo`,
|
`it`.`promo` AS `promo`
|
||||||
`it`.`maneuver` AS `maneuver`,
|
|
||||||
`it`.`target` AS `target`,
|
|
||||||
`it`.`topMargin` AS `top_margin`,
|
|
||||||
`it`.`profit` AS `profit`
|
|
||||||
FROM `vn`.`itemType` `it`
|
FROM `vn`.`itemType` `it`
|
||||||
|
|
|
@ -2,7 +2,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
SQL SECURITY DEFINER
|
SQL SECURITY DEFINER
|
||||||
VIEW `vn2008`.`buy_edi`
|
VIEW `vn2008`.`buy_edi`
|
||||||
AS SELECT `t`.`id` AS `id`,
|
AS SELECT `t`.`id` AS `id`,
|
||||||
`t`.`barcode` AS `barcode`,
|
|
||||||
`t`.`entryYear` AS `entry_year`,
|
`t`.`entryYear` AS `entry_year`,
|
||||||
`t`.`deliveryNumber` AS `delivery_number`,
|
`t`.`deliveryNumber` AS `delivery_number`,
|
||||||
`t`.`fec` AS `fec`,
|
`t`.`fec` AS `fec`,
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
INSERT IGNORE INTO salix.ACL (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`)
|
||||||
|
VALUES ('Entry','filter','READ','ALLOW','ROLE','supplier');
|
||||||
|
|
||||||
|
INSERT IGNORE INTO salix.ACL (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`)
|
||||||
|
VALUES ('Entry','getBuys','READ','ALLOW','ROLE','supplier');
|
||||||
|
|
||||||
|
INSERT IGNORE INTO salix.ACL (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`)
|
||||||
|
VALUES ('Entry','buyLabel','READ','ALLOW','ROLE','supplier');
|
||||||
|
|
||||||
|
INSERT IGNORE INTO `account`.`role` (`name`,`description`,`hasLogin`,`created`,`modified`)
|
||||||
|
VALUES ('supplier','Proveedores',1,'2017-10-10 14:58:58.000','2017-10-10 14:59:20.000');
|
||||||
|
SET @supplierFk =LAST_INSERT_ID();
|
||||||
|
INSERT IGNORE INTO account.roleInherit (`role`,`inheritsFrom`)
|
||||||
|
VALUES (@supplierFk,2);
|
||||||
|
|
||||||
|
UPDATE salix.ACL
|
||||||
|
SET principalId='$authenticated'
|
||||||
|
WHERE id=264;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
ALTER TABLE vn.componentType
|
||||||
|
CHANGE code code varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL AFTER id;
|
||||||
|
ALTER TABLE vn.componentType
|
||||||
|
CHANGE `type` name varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
|
||||||
|
UPDATE IGNORE vn.componentType
|
||||||
|
SET code = LOWER(code);
|
||||||
|
UPDATE IGNORE vn.componentType
|
||||||
|
SET code = 'other'
|
||||||
|
WHERE id = 12;
|
|
@ -0,0 +1,6 @@
|
||||||
|
ALTER TABLE vn.itemType
|
||||||
|
CHANGE maneuver maneuver__ double DEFAULT 0.21 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418',
|
||||||
|
CHANGE target target__ double DEFAULT 0.15 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418',
|
||||||
|
CHANGE topMargin topMargin__ double DEFAULT 0.3 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418',
|
||||||
|
CHANGE profit profit__ double DEFAULT 0.02 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418',
|
||||||
|
CHANGE density density__ double DEFAULT 167 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418 Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta';
|
|
@ -2,18 +2,9 @@ const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('Application execute()/executeProc()/executeFunc()', () => {
|
describe('Application execute()/executeProc()/executeFunc()', () => {
|
||||||
const userWithoutPrivileges = 1;
|
const userWithoutPrivileges = 1;
|
||||||
const userWithPrivileges = 9;
|
|
||||||
const userWithInheritedPrivileges = 120;
|
const userWithInheritedPrivileges = 120;
|
||||||
let tx;
|
let tx;
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
function getCtx(userId) {
|
|
||||||
return {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
tx = await models.Application.beginTransaction({});
|
tx = await models.Application.beginTransaction({});
|
||||||
|
@ -42,7 +33,7 @@ describe('Application execute()/executeProc()/executeFunc()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error when execute procedure and not have privileges', async() => {
|
it('should throw error when execute procedure and not have privileges', async() => {
|
||||||
const ctx = getCtx(userWithoutPrivileges);
|
const ctx = {req: {accessToken: {userId: userWithoutPrivileges}}};
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
|
@ -66,7 +57,6 @@ describe('Application execute()/executeProc()/executeFunc()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should execute procedure and get data', async() => {
|
it('should execute procedure and get data', async() => {
|
||||||
const ctx = getCtx(userWithPrivileges);
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
@ -90,7 +80,6 @@ describe('Application execute()/executeProc()/executeFunc()', () => {
|
||||||
|
|
||||||
describe('Application executeProc()', () => {
|
describe('Application executeProc()', () => {
|
||||||
it('should execute procedure and get data (executeProc)', async() => {
|
it('should execute procedure and get data (executeProc)', async() => {
|
||||||
const ctx = getCtx(userWithPrivileges);
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
@ -115,7 +104,6 @@ describe('Application execute()/executeProc()/executeFunc()', () => {
|
||||||
|
|
||||||
describe('Application executeFunc()', () => {
|
describe('Application executeFunc()', () => {
|
||||||
it('should execute function and get data', async() => {
|
it('should execute function and get data', async() => {
|
||||||
const ctx = getCtx(userWithPrivileges);
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
@ -137,7 +125,7 @@ describe('Application execute()/executeProc()/executeFunc()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should execute function and get data with user with inherited privileges', async() => {
|
it('should execute function and get data with user with inherited privileges', async() => {
|
||||||
const ctx = getCtx(userWithInheritedPrivileges);
|
const ctx = {req: {accessToken: {userId: userWithInheritedPrivileges}}};
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ module.exports = Self => {
|
||||||
const locale = modelLocale && modelLocale.get(lang);
|
const locale = modelLocale && modelLocale.get(lang);
|
||||||
|
|
||||||
json[modelName] = {
|
json[modelName] = {
|
||||||
|
http: model.sharedClass.http.path,
|
||||||
properties: model.definition.rawProperties,
|
properties: model.definition.rawProperties,
|
||||||
validations: jsonValidations,
|
validations: jsonValidations,
|
||||||
locale
|
locale
|
||||||
|
|
|
@ -1,20 +1,7 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Model crud()', () => {
|
describe('Model crud()', () => {
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
let insertId;
|
let insertId;
|
||||||
const barcodeModel = app.models.ItemBarcode;
|
const barcodeModel = app.models.ItemBarcode;
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Model rewriteDbError()', () => {
|
describe('Model rewriteDbError()', () => {
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should extend rewriteDbError properties to any model passed', () => {
|
it('should extend rewriteDbError properties to any model passed', () => {
|
||||||
const exampleModel = models.ItemTag;
|
const exampleModel = models.ItemTag;
|
||||||
|
|
|
@ -2,15 +2,7 @@ const app = require('vn-loopback/server/server');
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('claim filter()', () => {
|
describe('claim filter()', () => {
|
||||||
let ctx;
|
const ctx = beforeAll.getCtx();
|
||||||
beforeEach(() => {
|
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return 1 result filtering by id', async() => {
|
it('should return 1 result filtering by id', async() => {
|
||||||
const tx = await app.models.Claim.beginTransaction({});
|
const tx = await app.models.Claim.beginTransaction({});
|
||||||
|
|
|
@ -1,18 +1,11 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('claim regularizeClaim()', () => {
|
describe('claim regularizeClaim()', () => {
|
||||||
const userId = 18;
|
const userId = 18;
|
||||||
const ctx = {
|
const ctx = beforeAll.mockLoopBackContext(userId);
|
||||||
req: {
|
|
||||||
accessToken: {userId: userId},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ctx.req.__ = (value, params) => {
|
ctx.req.__ = (value, params) => {
|
||||||
return params.nickname;
|
return params.nickname;
|
||||||
};
|
};
|
||||||
|
|
||||||
const chatModel = models.Chat;
|
const chatModel = models.Chat;
|
||||||
const claimId = 1;
|
const claimId = 1;
|
||||||
const ticketId = 1;
|
const ticketId = 1;
|
||||||
|
@ -40,20 +33,6 @@ describe('claim regularizeClaim()', () => {
|
||||||
return await models.ClaimEnd.create(claimEnds, options);
|
return await models.ClaimEnd.create(claimEnds, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should send a chat message with value "Trash" and then change claim state to resolved', async() => {
|
it('should send a chat message with value "Trash" and then change claim state to resolved', async() => {
|
||||||
const tx = await models.Claim.beginTransaction({});
|
const tx = await models.Claim.beginTransaction({});
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,10 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
const i18n = require('i18n');
|
const i18n = require('i18n');
|
||||||
describe('Update Claim', () => {
|
describe('Update Claim', () => {
|
||||||
let url;
|
let url;
|
||||||
let claimStatesMap = {};
|
let claimStatesMap = {};
|
||||||
|
beforeAll.mockLoopBackContext();
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
url = await app.models.Url.getUrl();
|
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
const claimStates = await app.models.ClaimState.find();
|
const claimStates = await app.models.ClaimState.find();
|
||||||
claimStatesMap = claimStates.reduce((acc, state) => ({...acc, [state.code]: state.id}), {});
|
claimStatesMap = claimStates.reduce((acc, state) => ({...acc, [state.code]: state.id}), {});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,20 +1,7 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Update Claim', () => {
|
describe('Update Claim', () => {
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const newDate = Date.vnNew();
|
const newDate = Date.vnNew();
|
||||||
const original = {
|
const original = {
|
||||||
ticketFk: 3,
|
ticketFk: 3,
|
||||||
|
|
|
@ -1,23 +1,10 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Client addressesPropagateRe', () => {
|
describe('Client addressesPropagateRe', () => {
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
it('should propagate the isEqualizated on both addresses of Mr Wayne' +
|
||||||
active: activeCtx
|
' and set hasToInvoiceByAddress to false', async() => {
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should propagate the isEqualizated on both addresses of Mr Wayne and set hasToInvoiceByAddress to false', async() => {
|
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Address createAddress', () => {
|
describe('Address createAddress', () => {
|
||||||
const clientFk = 1101;
|
const clientFk = 1101;
|
||||||
|
@ -7,20 +6,7 @@ describe('Address createAddress', () => {
|
||||||
const incotermsFk = 'FAS';
|
const incotermsFk = 'FAS';
|
||||||
const customAgentOneId = 1;
|
const customAgentOneId = 1;
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw a non uee member error if no incoterms is defined', async() => {
|
it('should throw a non uee member error if no incoterms is defined', async() => {
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Client Create', () => {
|
describe('Client Create', () => {
|
||||||
const newAccount = {
|
const newAccount = {
|
||||||
userName: 'deadpool',
|
userName: 'deadpool',
|
||||||
|
@ -16,20 +14,7 @@ describe('Client Create', () => {
|
||||||
const newAccountWithoutEmail = JSON.parse(JSON.stringify(newAccount));
|
const newAccountWithoutEmail = JSON.parse(JSON.stringify(newAccount));
|
||||||
delete newAccountWithoutEmail.email;
|
delete newAccountWithoutEmail.email;
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should not find deadpool as he's not created yet`, async() => {
|
it(`should not find deadpool as he's not created yet`, async() => {
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('Client getCard()', () => {
|
describe('Client getCard()', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
it('should receive a formated card of Bruce Wayne', async() => {
|
it('should receive a formated card of Bruce Wayne', async() => {
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const id = 1101;
|
const id = 1101;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('client getDebt()', () => {
|
describe('client getDebt()', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
it('should return the client debt', async() => {
|
it('should return the client debt', async() => {
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('client sendSms()', () => {
|
describe('client sendSms()', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
it('should now send a message and log it', async() => {
|
it('should now send a message and log it', async() => {
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const id = 1101;
|
const id = 1101;
|
||||||
const destination = 222222222;
|
const destination = 222222222;
|
||||||
const message = 'this is the message created in a test';
|
const message = 'this is the message created in a test';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('client summary()', () => {
|
describe('client summary()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const ctx = beforeAll.getCtx();
|
||||||
it('should return a summary object containing data', async() => {
|
it('should return a summary object containing data', async() => {
|
||||||
const clientId = 1101;
|
const clientId = 1101;
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Address updateAddress', () => {
|
describe('Address updateAddress', () => {
|
||||||
const clientId = 1101;
|
const clientId = 1101;
|
||||||
const addressId = 1;
|
const addressId = 1;
|
||||||
|
@ -14,20 +12,7 @@ describe('Address updateAddress', () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw the non uee member error if no incoterms is defined', async() => {
|
it('should throw the non uee member error if no incoterms is defined', async() => {
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
|
@ -1,24 +1,10 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('loopback model address', () => {
|
describe('loopback model address', () => {
|
||||||
let createdAddressId;
|
let createdAddressId;
|
||||||
const clientId = 1101;
|
const clientId = 1101;
|
||||||
|
|
||||||
const activeCtx = {
|
beforeAll.mockLoopBackContext();
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async() => {
|
||||||
const client = await models.Client.findById(clientId);
|
const client = await models.Client.findById(clientId);
|
||||||
|
|
|
@ -29,7 +29,8 @@ module.exports = Self => {
|
||||||
http: {
|
http: {
|
||||||
path: '/:id/buy-label',
|
path: '/:id/buy-label',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
}
|
},
|
||||||
|
accessScopes: ['DEFAULT', 'read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label');
|
Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label');
|
||||||
|
|
|
@ -112,7 +112,6 @@ module.exports = Self => {
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const conn = Self.dataSource.connector;
|
const conn = Self.dataSource.connector;
|
||||||
const where = buildFilter(ctx.args, (param, value) => {
|
const where = buildFilter(ctx.args, (param, value) => {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
|
@ -146,7 +145,12 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
filter = mergeFilters(ctx.args.filter, {where});
|
filter = mergeFilters(ctx.args.filter, {where});
|
||||||
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
const isSupplier = await Self.app.models.Supplier.findById(userId, options);
|
||||||
|
if (isSupplier) {
|
||||||
|
if (!filter.where) filter.where = {};
|
||||||
|
filter.where[`e.supplierFk`] = ctx.req.accessToken.userId;
|
||||||
|
}
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
stmt = new ParameterizedSQL(
|
stmt = new ParameterizedSQL(
|
||||||
|
@ -158,7 +162,7 @@ module.exports = Self => {
|
||||||
e.invoiceNumber,
|
e.invoiceNumber,
|
||||||
e.isBooked,
|
e.isBooked,
|
||||||
e.isExcludedFromAvailable,
|
e.isExcludedFromAvailable,
|
||||||
e.evaNotes AS observation,
|
e.evaNotes observation,
|
||||||
e.isConfirmed,
|
e.isConfirmed,
|
||||||
e.isOrdered,
|
e.isOrdered,
|
||||||
e.isRaid,
|
e.isRaid,
|
||||||
|
@ -170,13 +174,18 @@ module.exports = Self => {
|
||||||
e.gestDocFk,
|
e.gestDocFk,
|
||||||
e.invoiceInFk,
|
e.invoiceInFk,
|
||||||
t.landed,
|
t.landed,
|
||||||
s.name AS supplierName,
|
s.name supplierName,
|
||||||
s.nickname AS supplierAlias,
|
s.nickname supplierAlias,
|
||||||
co.code AS companyCode,
|
co.code companyCode,
|
||||||
cu.code AS currencyCode
|
cu.code currencyCode,
|
||||||
|
t.shipped,
|
||||||
|
t.landed,
|
||||||
|
t.warehouseInFk,
|
||||||
|
w.name warehouseInName
|
||||||
FROM vn.entry e
|
FROM vn.entry e
|
||||||
JOIN vn.supplier s ON s.id = e.supplierFk
|
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||||
JOIN vn.travel t ON t.id = e.travelFk
|
JOIN vn.travel t ON t.id = e.travelFk
|
||||||
|
JOIN vn.warehouse w ON w.id = t.warehouseInFk
|
||||||
JOIN vn.company co ON co.id = e.companyFk
|
JOIN vn.company co ON co.id = e.companyFk
|
||||||
JOIN vn.currency cu ON cu.id = e.currencyFk`
|
JOIN vn.currency cu ON cu.id = e.currencyFk`
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('getBuys', {
|
Self.remoteMethodCtx('getBuys', {
|
||||||
description: 'Returns buys for one entry',
|
description: 'Returns buys for one entry',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
|
@ -27,13 +29,19 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.getBuys = async(id, filter, options) => {
|
Self.getBuys = async(ctx, id, filter, options) => {
|
||||||
|
const userId = ctx.req.accessToken.userId;
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
const isSupplier = await Self.app.models.Supplier.findById(userId, myOptions);
|
||||||
|
if (isSupplier) {
|
||||||
|
const isEntryOwner = (await Self.findById(id)).supplierFk === userId;
|
||||||
|
|
||||||
|
if (!isEntryOwner) throw new UserError('Access Denied');
|
||||||
|
}
|
||||||
let defaultFilter = {
|
let defaultFilter = {
|
||||||
where: {entryFk: id},
|
where: {entryFk: id},
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -49,9 +57,23 @@ module.exports = Self => {
|
||||||
'buyingValue',
|
'buyingValue',
|
||||||
'price2',
|
'price2',
|
||||||
'price3',
|
'price3',
|
||||||
'printedStickers'
|
'printedStickers',
|
||||||
|
'entryFk'
|
||||||
],
|
],
|
||||||
include: {
|
include: [{
|
||||||
|
relation: 'entry',
|
||||||
|
scope: {
|
||||||
|
fields: [
|
||||||
|
'id', 'supplierFk'
|
||||||
|
],
|
||||||
|
include: {
|
||||||
|
relation: 'supplier', scope: {
|
||||||
|
fields: ['id']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
relation: 'item',
|
relation: 'item',
|
||||||
scope: {
|
scope: {
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -82,9 +104,8 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFilter = mergeFilters(defaultFilter, filter);
|
defaultFilter = mergeFilters(defaultFilter, filter);
|
||||||
|
|
||||||
return models.Buy.find(defaultFilter, myOptions);
|
return models.Buy.find(defaultFilter, myOptions);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('entry addFromPackaging()', () => {
|
describe('entry addFromPackaging()', () => {
|
||||||
const supplier = 442;
|
const supplier = 442;
|
||||||
|
@ -7,22 +6,10 @@ describe('entry addFromPackaging()', () => {
|
||||||
const yesterday = new Date(today);
|
const yesterday = new Date(today);
|
||||||
yesterday.setDate(today.getDate() - 1);
|
yesterday.setDate(today.getDate() - 1);
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 49},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create an incoming travel', async() => {
|
it('should create an incoming travel', async() => {
|
||||||
const ctx = {args: {isTravelReception: true, supplier}};
|
const ctx = {accessToken: {userId: 49}, args: {isTravelReception: true, supplier}};
|
||||||
const tx = await models.Entry.beginTransaction({});
|
const tx = await models.Entry.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Buy editLatestsBuys()', () => {
|
describe('Buy editLatestsBuys()', () => {
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should change the value of a given column for the selected buys', async() => {
|
it('should change the value of a given column for the selected buys', async() => {
|
||||||
const tx = await models.Buy.beginTransaction({});
|
const tx = await models.Buy.beginTransaction({});
|
||||||
|
|
|
@ -9,7 +9,8 @@ describe('Entry filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
search: 1
|
search: 1
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 9}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = await models.Entry.filter(ctx, options);
|
const result = await models.Entry.filter(ctx, options);
|
||||||
|
@ -32,7 +33,8 @@ describe('Entry filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
currencyFk: 1
|
currencyFk: 1
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 9}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = await models.Entry.filter(ctx, options);
|
const result = await models.Entry.filter(ctx, options);
|
||||||
|
@ -46,26 +48,73 @@ describe('Entry filter()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the entry matching the supplier', async() => {
|
describe('should return the entry matching the supplier', () => {
|
||||||
const tx = await models.Entry.beginTransaction({});
|
it('when userId is supplier ', async() => {
|
||||||
const options = {transaction: tx};
|
const tx = await models.Entry.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {},
|
||||||
supplierFk: 2
|
req: {accessToken: {userId: 2}}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const result = await models.Entry.filter(ctx, options);
|
const result = await models.Entry.filter(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(6);
|
expect(result.length).toEqual(6);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('when userId is supplier fetching other supplier', async() => {
|
||||||
|
const tx = await models.Entry.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
supplierFk: 1
|
||||||
|
},
|
||||||
|
req: {accessToken: {userId: 2}}
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await models.Entry.filter(ctx, options);
|
||||||
|
|
||||||
|
expect(result.length).toEqual(6);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('when userId is not supplier', async() => {
|
||||||
|
const tx = await models.Entry.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
supplierFk: 2
|
||||||
|
},
|
||||||
|
req: {accessToken: {userId: 9}}
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await models.Entry.filter(ctx, options);
|
||||||
|
|
||||||
|
expect(result.length).toEqual(6);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the entry matching the company', async() => {
|
it('should return the entry matching the company', async() => {
|
||||||
|
@ -76,7 +125,8 @@ describe('Entry filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
companyFk: 442
|
companyFk: 442
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 9}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = await models.Entry.filter(ctx, options);
|
const result = await models.Entry.filter(ctx, options);
|
||||||
|
@ -98,7 +148,8 @@ describe('Entry filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
isBooked: true,
|
isBooked: true,
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 9}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = await models.Entry.filter(ctx, options);
|
const result = await models.Entry.filter(ctx, options);
|
||||||
|
@ -121,7 +172,8 @@ describe('Entry filter()', () => {
|
||||||
args: {
|
args: {
|
||||||
reference: 'movement',
|
reference: 'movement',
|
||||||
travelFk: '2'
|
travelFk: '2'
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 9}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = await models.Entry.filter(ctx, options);
|
const result = await models.Entry.filter(ctx, options);
|
||||||
|
|
|
@ -1,24 +1,82 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('entry getBuys()', () => {
|
describe('entry getBuys()', () => {
|
||||||
const entryId = 4;
|
const entryId = 4;
|
||||||
it('should get the buys and items of an entry', async() => {
|
describe('should get the buys and items of an entry ', () => {
|
||||||
const tx = await models.Entry.beginTransaction({});
|
it('when is supplier and entry owner', async() => {
|
||||||
const options = {transaction: tx};
|
const tx = await models.Entry.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await models.Entry.getBuys(entryId, options);
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
search: 1
|
||||||
|
},
|
||||||
|
req: {accessToken: {userId: 2}}
|
||||||
|
};
|
||||||
|
|
||||||
const length = result.length;
|
const result = await models.Entry.getBuys(ctx, entryId, options);
|
||||||
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
|
||||||
|
|
||||||
expect(result.length).toEqual(4);
|
const length = result.length;
|
||||||
expect(anyResult.item).toBeDefined();
|
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
||||||
|
|
||||||
await tx.rollback();
|
expect(result.length).toEqual(4);
|
||||||
} catch (e) {
|
expect(anyResult.item).toBeDefined();
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
await tx.rollback();
|
||||||
}
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('when is supplier but not entry owner', async() => {
|
||||||
|
const tx = await models.Entry.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const entryId = 1;
|
||||||
|
try {
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
search: 1
|
||||||
|
},
|
||||||
|
req: {accessToken: {userId: 2}}
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await models.Entry.getBuys(ctx, entryId, options);
|
||||||
|
|
||||||
|
expect(result).toBeUndefined();
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).toBeInstanceOf(UserError);
|
||||||
|
expect(error.message).toBe('Access Denied');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('when is not supplier', async() => {
|
||||||
|
const tx = await models.Entry.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
search: 1
|
||||||
|
},
|
||||||
|
req: {accessToken: {userId: 9}}
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await models.Entry.getBuys(ctx, entryId, options);
|
||||||
|
|
||||||
|
const length = result.length;
|
||||||
|
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
||||||
|
|
||||||
|
expect(result.length).toEqual(4);
|
||||||
|
expect(anyResult.item).toBeDefined();
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
const activeCtx = {accessToken: {userId: 9}};
|
|
||||||
|
|
||||||
describe('entry importBuysPreview()', () => {
|
describe('entry importBuysPreview()', () => {
|
||||||
const entryId = 1;
|
const entryId = 1;
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the buys with the calculated packagingFk', async() => {
|
it('should return the buys with the calculated packagingFk', async() => {
|
||||||
const tx = await models.Entry.beginTransaction({});
|
const tx = await models.Entry.beginTransaction({});
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('invoiceInDueDay new()', () => {
|
describe('invoiceInDueDay new()', () => {
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should correctly create a new due day', async() => {
|
it('should correctly create a new due day', async() => {
|
||||||
const userId = 9;
|
const userId = 9;
|
||||||
|
|
|
@ -1,24 +1,11 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('invoiceIn clone()', () => {
|
describe('invoiceIn clone()', () => {
|
||||||
let ctx;
|
const ctx = beforeAll.getCtx();
|
||||||
let options;
|
let options;
|
||||||
let tx;
|
let tx;
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 1},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
},
|
|
||||||
args: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: ctx.req
|
|
||||||
});
|
|
||||||
|
|
||||||
options = {transaction: tx};
|
options = {transaction: tx};
|
||||||
tx = await models.Sale.beginTransaction({});
|
tx = await models.Sale.beginTransaction({});
|
||||||
options.transaction = tx;
|
options.transaction = tx;
|
||||||
|
@ -28,7 +15,8 @@ describe('invoiceIn clone()', () => {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the cloned invoiceIn and also clone invoiceInDueDays and invoiceInTaxes if there are any referencing the invoiceIn', async() => {
|
it('should return the cloned invoiceIn and also clone invoiceInDueDays ' +
|
||||||
|
'and invoiceInTaxes if there are any referencing the invoiceIn', async() => {
|
||||||
const clone = await models.InvoiceIn.clone(ctx, 1, false, options);
|
const clone = await models.InvoiceIn.clone(ctx, 1, false, options);
|
||||||
|
|
||||||
expect(clone.supplierRef).toEqual('1234(2)');
|
expect(clone.supplierRef).toEqual('1234(2)');
|
||||||
|
@ -51,7 +39,8 @@ describe('invoiceIn clone()', () => {
|
||||||
expect(invoiceInDueDay.length).toEqual(2);
|
expect(invoiceInDueDay.length).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the cloned invoiceIn and also clone invoiceInIntrastat and invoiceInTaxes if it is rectificative', async() => {
|
it('should return the cloned invoiceIn and also clone invoiceInIntrastat ' +
|
||||||
|
'and invoiceInTaxes if it is rectificative', async() => {
|
||||||
const clone = await models.InvoiceIn.clone(ctx, 1, true, options);
|
const clone = await models.InvoiceIn.clone(ctx, 1, true, options);
|
||||||
|
|
||||||
expect(clone.supplierRef).toEqual('1234(2)');
|
expect(clone.supplierRef).toEqual('1234(2)');
|
||||||
|
|
|
@ -1,24 +1,11 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('invoiceIn corrective()', () => {
|
describe('invoiceIn corrective()', () => {
|
||||||
let ctx;
|
const ctx = beforeAll.getCtx();
|
||||||
let options;
|
let options;
|
||||||
let tx;
|
let tx;
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
},
|
|
||||||
args: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: ctx.req
|
|
||||||
});
|
|
||||||
|
|
||||||
options = {transaction: tx};
|
options = {transaction: tx};
|
||||||
tx = await models.Sale.beginTransaction({});
|
tx = await models.Sale.beginTransaction({});
|
||||||
options.transaction = tx;
|
options.transaction = tx;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('invoiceOut book()', () => {
|
describe('invoiceOut book()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const ctx = beforeAll.getCtx();
|
||||||
const invoiceOutId = 5;
|
const invoiceOutId = 5;
|
||||||
|
|
||||||
it('should update the booked property', async() => {
|
it('should update the booked property', async() => {
|
||||||
|
|
|
@ -1,24 +1,13 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('upsertFixedPrice()', () => {
|
describe('upsertFixedPrice()', () => {
|
||||||
const now = Date.vnNew();
|
const now = Date.vnNew();
|
||||||
const fixedPriceId = 1;
|
const fixedPriceId = 1;
|
||||||
let originalFixedPrice;
|
let originalFixedPrice;
|
||||||
|
|
||||||
|
beforeAll.mockLoopBackContext();
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
originalFixedPrice = await models.FixedPrice.findById(fixedPriceId);
|
originalFixedPrice = await models.FixedPrice.findById(fixedPriceId);
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should toggle the hasMinPrice boolean if there's a minPrice and update the rest of the data`, async() => {
|
it(`should toggle the hasMinPrice boolean if there's a minPrice and update the rest of the data`, async() => {
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('itemShelving getAlternative()', () => {
|
describe('itemShelving getAlternative()', () => {
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return a list of items without alternatives', async() => {
|
it('should return a list of items without alternatives', async() => {
|
||||||
const shelvingFk = 'HEJ';
|
const shelvingFk = 'HEJ';
|
||||||
|
|
|
@ -1,25 +1,13 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('ItemShelving upsertItem()', () => {
|
describe('ItemShelving upsertItem()', () => {
|
||||||
const warehouseFk = 1;
|
const warehouseFk = 1;
|
||||||
let ctx;
|
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
let options;
|
let options;
|
||||||
let tx;
|
let tx;
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
},
|
|
||||||
args: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: ctx.req
|
|
||||||
});
|
|
||||||
|
|
||||||
options = {transaction: tx};
|
options = {transaction: tx};
|
||||||
tx = await models.ItemShelving.beginTransaction({});
|
tx = await models.ItemShelving.beginTransaction({});
|
||||||
options.transaction = tx;
|
options.transaction = tx;
|
||||||
|
|
|
@ -1,21 +1,8 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('item clone()', () => {
|
describe('item clone()', () => {
|
||||||
let nextItemId;
|
let nextItemId;
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
let query = `SELECT i1.id + 1 as id FROM vn.item i1
|
let query = `SELECT i1.id + 1 as id FROM vn.item i1
|
||||||
|
|
|
@ -2,17 +2,14 @@ const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('item getBalance()', () => {
|
describe('item getBalance()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const ctx = beforeAll.getCtx();
|
||||||
it('should return the balance lines of a client type loses in which one has highlighted true', async() => {
|
it('should return the balance lines of a client type loses in which one has highlighted true', async() => {
|
||||||
const tx = await models.Item.beginTransaction({});
|
const tx = await models.Item.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
active: activeCtx
|
active: ctx
|
||||||
});
|
});
|
||||||
const losesClientId = 1111;
|
const losesClientId = 1111;
|
||||||
const ticket = await models.Ticket.findById(7, null, options);
|
const ticket = await models.Ticket.findById(7, null, options);
|
||||||
|
|
|
@ -1,21 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('item new()', () => {
|
describe('item new()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const ctx = beforeAll.getCtx();
|
||||||
beforeAll(async() => {
|
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create a new item, adding the name as a tag', async() => {
|
it('should create a new item, adding the name as a tag', async() => {
|
||||||
const tx = await models.Item.beginTransaction({});
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
|
|
@ -1,27 +1,13 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('regularize()', () => {
|
describe('regularize()', () => {
|
||||||
beforeAll(async() => {
|
const ctx = beforeAll.mockLoopBackContext(18);
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 18},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create a new ticket and add a line', async() => {
|
it('should create a new ticket and add a line', async() => {
|
||||||
const tx = await models.Item.beginTransaction({});
|
const tx = await models.Item.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {req: {accessToken: {userId: 18}}};
|
|
||||||
const itemId = 1;
|
const itemId = 1;
|
||||||
const warehouseId = 1;
|
const warehouseId = 1;
|
||||||
const quantity = 11;
|
const quantity = 11;
|
||||||
|
|
|
@ -1,20 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('item updateTaxes()', () => {
|
describe('item updateTaxes()', () => {
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error if the taxClassFk is blank', async() => {
|
it('should throw an error if the taxClassFk is blank', async() => {
|
||||||
const tx = await models.Item.beginTransaction({});
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
|
|
@ -1,20 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('tag onSubmit()', () => {
|
describe('tag onSubmit()', () => {
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should delete a tag', async() => {
|
it('should delete a tag', async() => {
|
||||||
const tx = await models.Item.beginTransaction({});
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('order addToOrder()', () => {
|
describe('order addToOrder()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const ctx = beforeAll.getCtx();
|
||||||
const orderId = 8;
|
const orderId = 8;
|
||||||
it('should add a row to a given order', async() => {
|
it('should add a row to a given order', async() => {
|
||||||
const tx = await models.Order.beginTransaction({});
|
const tx = await models.Order.beginTransaction({});
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('order filter()', () => {
|
describe('order filter()', () => {
|
||||||
const ctx = {
|
const ctx = beforeAll.getCtx();
|
||||||
req: {accessToken: {userId: 9}},
|
|
||||||
args: {},
|
|
||||||
params: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should call the filter method with a basic search', async() => {
|
it('should call the filter method with a basic search', async() => {
|
||||||
const myCtx = Object.assign({}, ctx);
|
const myCtx = Object.assign({}, ctx);
|
||||||
|
|
|
@ -2,7 +2,7 @@ const models = require('vn-loopback/server/server').models;
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
describe('order new()', () => {
|
describe('order new()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const ctx = beforeAll.getCtx();
|
||||||
it('should throw an error if the client isnt active', async() => {
|
it('should throw an error if the client isnt active', async() => {
|
||||||
const tx = await models.Order.beginTransaction({});
|
const tx = await models.Order.beginTransaction({});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('order newFromTicket()', () => {
|
describe('order newFromTicket()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const ctx = beforeAll.getCtx();
|
||||||
it('should create a new order from an existing ticket', async() => {
|
it('should create a new order from an existing ticket', async() => {
|
||||||
const tx = await models.Order.beginTransaction({});
|
const tx = await models.Order.beginTransaction({});
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('AgencyTerm createInvoiceIn()', () => {
|
describe('AgencyTerm createInvoiceIn()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const ctx = beforeAll.getCtx();
|
||||||
beforeAll(async() => {
|
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const rows = [
|
const rows = [
|
||||||
{
|
{
|
||||||
routeFk: 2,
|
routeFk: 2,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('roadMapStop getPalletMatchState()', () => {
|
describe('roadMapStop getPalletMatchState()', () => {
|
||||||
|
|
|
@ -1,21 +1,7 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('route clone()', () => {
|
describe('route clone()', () => {
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const createdDate = Date.vnNew();
|
const createdDate = Date.vnNew();
|
||||||
it('should throw an error if the amount of ids pased to the clone function do no match the database', async() => {
|
it('should throw an error if the amount of ids pased to the clone function do no match the database', async() => {
|
||||||
|
|
|
@ -1,20 +1,9 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('route guessPriority()', () => {
|
describe('route guessPriority()', () => {
|
||||||
const targetRouteId = 7;
|
const targetRouteId = 7;
|
||||||
let routeTicketsToRestore;
|
let routeTicketsToRestore;
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
__: () => {}
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async() => {
|
||||||
let restoreFixtures = [];
|
let restoreFixtures = [];
|
||||||
|
@ -25,9 +14,6 @@ describe('route guessPriority()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call guessPriority() then check all tickets in that route have their priorities defined', async() => {
|
it('should call guessPriority() then check all tickets in that route have their priorities defined', async() => {
|
||||||
const ctx = {
|
|
||||||
req: activeCtx
|
|
||||||
};
|
|
||||||
routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}});
|
routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}});
|
||||||
|
|
||||||
await app.models.Route.guessPriority(ctx, targetRouteId);
|
await app.models.Route.guessPriority(ctx, targetRouteId);
|
||||||
|
|
|
@ -1,20 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('route updateWorkCenter()', () => {
|
describe('route updateWorkCenter()', () => {
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const routeId = 1;
|
const routeId = 1;
|
||||||
|
|
||||||
it('should set the commission work center if the worker has workCenter', async() => {
|
it('should set the commission work center if the worker has workCenter', async() => {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('supplier consumption() filter', () => {
|
describe('supplier consumption() filter', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
it('should return a list of entries from the supplier 2', async() => {
|
it('should return a list of entries from the supplier 2', async() => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {}};
|
|
||||||
const filter = {
|
const filter = {
|
||||||
where: {
|
where: {
|
||||||
supplierFk: 2
|
supplierFk: 2
|
||||||
|
|
|
@ -3,7 +3,6 @@ const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('Supplier updateFiscalData()', () => {
|
describe('Supplier updateFiscalData()', () => {
|
||||||
const supplierId = 1;
|
const supplierId = 1;
|
||||||
const administrativeId = 5;
|
|
||||||
const buyerId = 35;
|
const buyerId = 35;
|
||||||
|
|
||||||
const name = 'NEW PLANTS';
|
const name = 'NEW PLANTS';
|
||||||
|
|
|
@ -1,25 +1,13 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('loopback model Supplier', () => {
|
describe('loopback model Supplier', () => {
|
||||||
let supplierOne;
|
let supplierOne;
|
||||||
let supplierTwo;
|
let supplierTwo;
|
||||||
|
|
||||||
|
beforeAll.mockLoopBackContext();
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
supplierOne = await models.Supplier.findById(1);
|
supplierOne = await models.Supplier.findById(1);
|
||||||
supplierTwo = await models.Supplier.findById(442);
|
supplierTwo = await models.Supplier.findById(442);
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('payMethodFk', () => {
|
describe('payMethodFk', () => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('expeditionState addExpeditionState()', () => {
|
describe('expeditionState addExpeditionState()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const ctx = beforeAll.getCtx();
|
||||||
it('should update the expedition states', async() => {
|
it('should update the expedition states', async() => {
|
||||||
const tx = await models.ExpeditionState.beginTransaction({});
|
const tx = await models.ExpeditionState.beginTransaction({});
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('ticket deleteExpeditions()', () => {
|
describe('ticket deleteExpeditions()', () => {
|
||||||
let ctx;
|
const ctx = beforeAll.getCtx();
|
||||||
beforeAll(async() => {
|
|
||||||
ctx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: ctx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should delete the selected expeditions', async() => {
|
it('should delete the selected expeditions', async() => {
|
||||||
const tx = await models.Expedition.beginTransaction({});
|
const tx = await models.Expedition.beginTransaction({});
|
||||||
|
|
|
@ -1,29 +1,11 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('ticket moveExpeditions()', () => {
|
describe('ticket moveExpeditions()', () => {
|
||||||
beforeAll(async() => {
|
const ctx = beforeAll.getCtx();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should move the selected expeditions to new ticket', async() => {
|
it('should move the selected expeditions to new ticket', async() => {
|
||||||
const tx = await models.Expedition.beginTransaction({});
|
const tx = await models.Expedition.beginTransaction({});
|
||||||
const ctx = {
|
const myCtx = ctx;
|
||||||
req: {accessToken: {userId: 9}},
|
|
||||||
args: {},
|
|
||||||
params: {}
|
|
||||||
};
|
|
||||||
const myCtx = Object.assign({}, ctx);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
@ -38,7 +20,7 @@ describe('ticket moveExpeditions()', () => {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const ticket = await models.Expedition.moveExpeditions(myCtx, options);
|
const ticket = await models.Expedition.moveExpeditions(ctx, options);
|
||||||
|
|
||||||
const newestTicketIdInFixtures = 27;
|
const newestTicketIdInFixtures = 27;
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,8 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('sale canEdit()', () => {
|
describe('sale canEdit()', () => {
|
||||||
const employeeId = 1;
|
const employeeId = 1;
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('sale not exists', () => {
|
describe('sale not exists', () => {
|
||||||
it('should return error if sale not exists', async() => {
|
it('should return error if sale not exists', async() => {
|
||||||
|
|
|
@ -1,24 +1,11 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Ticket cloning - clone function', () => {
|
describe('Ticket cloning - clone function', () => {
|
||||||
let ctx;
|
const ctx = beforeAll.getCtx();
|
||||||
|
beforeAll.mockLoopBackContext();
|
||||||
let options;
|
let options;
|
||||||
let tx;
|
let tx;
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
},
|
|
||||||
args: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: ctx.req
|
|
||||||
});
|
|
||||||
|
|
||||||
options = {transaction: tx};
|
options = {transaction: tx};
|
||||||
tx = await models.Sale.beginTransaction({});
|
tx = await models.Sale.beginTransaction({});
|
||||||
options.transaction = tx;
|
options.transaction = tx;
|
||||||
|
|
|
@ -1,20 +1,8 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('sale deleteSales()', () => {
|
describe('sale deleteSales()', () => {
|
||||||
beforeAll(async() => {
|
const ctx = beforeAll.getCtx();
|
||||||
const activeCtx = {
|
beforeAll.mockLoopBackContext();
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error if the ticket of the given sales is not editable', async() => {
|
it('should throw an error if the ticket of the given sales is not editable', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
|
@ -23,14 +11,6 @@ describe('sale deleteSales()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'localhost:5000'},
|
|
||||||
__: () => {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const sales = [{id: 1, instance: 0}, {id: 2, instance: 1}];
|
const sales = [{id: 1, instance: 0}, {id: 2, instance: 1}];
|
||||||
const ticketId = 2;
|
const ticketId = 2;
|
||||||
|
|
||||||
|
@ -51,13 +31,6 @@ describe('sale deleteSales()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'localhost:5000'},
|
|
||||||
__: () => {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const sale = await models.Sale.findOne({where: {id: 9}}, options);
|
const sale = await models.Sale.findOne({where: {id: 9}}, options);
|
||||||
sale.id = null;
|
sale.id = null;
|
||||||
const newSale = await models.Sale.create(sale, options);
|
const newSale = await models.Sale.create(sale, options);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('sale recalculatePrice()', () => {
|
describe('sale recalculatePrice()', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
it('should update the sale price', async() => {
|
it('should update the sale price', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
const sales = [
|
const sales = [
|
||||||
|
@ -10,7 +11,6 @@ describe('sale recalculatePrice()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const response = await models.Sale.recalculatePrice(ctx, sales, options);
|
const response = await models.Sale.recalculatePrice(ctx, sales, options);
|
||||||
|
|
||||||
expect(response[0].affectedRows).toBeDefined();
|
expect(response[0].affectedRows).toBeDefined();
|
||||||
|
@ -30,7 +30,6 @@ describe('sale recalculatePrice()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const immutableSale = [{id: 1, ticketFk: 1}];
|
const immutableSale = [{id: 1, ticketFk: 1}];
|
||||||
await models.Sale.recalculatePrice(ctx, immutableSale, options);
|
await models.Sale.recalculatePrice(ctx, immutableSale, options);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('sale reserve()', () => {
|
describe('sale reserve()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
|
@ -10,19 +9,7 @@ describe('sale reserve()', () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll.mockLoopBackContext();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error if the ticket can not be modified', async() => {
|
it('should throw an error if the ticket can not be modified', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
|
|
|
@ -1,22 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('sale updateConcept()', () => {
|
describe('sale updateConcept()', () => {
|
||||||
beforeAll(async() => {
|
const ctx = beforeAll.getCtx();
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const saleId = 25;
|
const saleId = 25;
|
||||||
|
|
||||||
it('should throw if ID was undefined', async() => {
|
it('should throw if ID was undefined', async() => {
|
||||||
|
|
|
@ -1,29 +1,8 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('ticket-request confirm()', () => {
|
describe('ticket-request confirm()', () => {
|
||||||
beforeAll(async() => {
|
const ctx = beforeAll.getCtx();
|
||||||
const activeCtx = {
|
beforeAll.mockLoopBackContext();
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
let ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ctx.req.__ = value => {
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
|
|
||||||
it(`should throw an error if the item doesn't exist`, async() => {
|
it(`should throw an error if the item doesn't exist`, async() => {
|
||||||
const tx = await models.TicketRequest.beginTransaction({});
|
const tx = await models.TicketRequest.beginTransaction({});
|
||||||
|
|
|
@ -1,39 +1,15 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('ticket-request deny()', () => {
|
describe('ticket-request deny()', () => {
|
||||||
beforeAll(async() => {
|
const ctx = beforeAll.getCtx();
|
||||||
const activeCtx = {
|
beforeAll.mockLoopBackContext();
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the denied ticket request', async() => {
|
it('should return the denied ticket request', async() => {
|
||||||
const tx = await models.TicketRequest.beginTransaction({});
|
const tx = await models.TicketRequest.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
ctx.args = {id: 4, observation: 'my observation'};
|
||||||
const ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
},
|
|
||||||
args: {id: 4, observation: 'my observation'},
|
|
||||||
};
|
|
||||||
|
|
||||||
ctx.req.__ = value => {
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
|
|
||||||
const result = await models.TicketRequest.deny(ctx, options);
|
const result = await models.TicketRequest.deny(ctx, options);
|
||||||
|
|
||||||
expect(result.id).toEqual(4);
|
expect(result.id).toEqual(4);
|
||||||
|
|
|
@ -1,26 +1,13 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Ticket cloning - clone function', () => {
|
describe('Ticket cloning - clone function', () => {
|
||||||
let ctx;
|
const ctx = beforeAll.getCtx();
|
||||||
let options;
|
let options;
|
||||||
let tx;
|
let tx;
|
||||||
const ticketId = 1;
|
const ticketId = 1;
|
||||||
const shipped = Date.vnNew();
|
const shipped = Date.vnNew();
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
},
|
|
||||||
args: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: ctx.req
|
|
||||||
});
|
|
||||||
|
|
||||||
options = {transaction: tx};
|
options = {transaction: tx};
|
||||||
tx = await models.Ticket.beginTransaction({});
|
tx = await models.Ticket.beginTransaction({});
|
||||||
options.transaction = tx;
|
options.transaction = tx;
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('ticket componentUpdate()', () => {
|
describe('ticket componentUpdate()', () => {
|
||||||
const userID = 1101;
|
const ctx = beforeAll.getCtx(1101);
|
||||||
const ticketID = 11;
|
const ticketID = 11;
|
||||||
const today = Date.vnNew();
|
const today = Date.vnNew();
|
||||||
const tomorrow = Date.vnNew();
|
const tomorrow = Date.vnNew();
|
||||||
|
@ -16,18 +15,8 @@ describe('ticket componentUpdate()', () => {
|
||||||
let componentOfSaleEight;
|
let componentOfSaleEight;
|
||||||
let componentValue;
|
let componentValue;
|
||||||
|
|
||||||
|
beforeAll.mockLoopBackContext();
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
const deliveryComponenet = await models.Component.findOne({where: {code: 'delivery'}});
|
const deliveryComponenet = await models.Component.findOne({where: {code: 'delivery'}});
|
||||||
deliveryComponentId = deliveryComponenet.id;
|
deliveryComponentId = deliveryComponenet.id;
|
||||||
componentOfSaleSeven = `SELECT value
|
componentOfSaleSeven = `SELECT value
|
||||||
|
@ -64,16 +53,7 @@ describe('ticket componentUpdate()', () => {
|
||||||
isWithoutNegatives: false
|
isWithoutNegatives: false
|
||||||
};
|
};
|
||||||
|
|
||||||
let ctx = {
|
ctx.args = args;
|
||||||
args: args,
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: userID},
|
|
||||||
headers: {origin: 'http://localhost'},
|
|
||||||
__: value => {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
await models.Ticket.componentUpdate(ctx, options);
|
await models.Ticket.componentUpdate(ctx, options);
|
||||||
|
|
||||||
[componentValue] = await models.SaleComponent.rawSql(componentOfSaleSeven, null, options);
|
[componentValue] = await models.SaleComponent.rawSql(componentOfSaleSeven, null, options);
|
||||||
|
@ -113,16 +93,7 @@ describe('ticket componentUpdate()', () => {
|
||||||
isWithoutNegatives: false
|
isWithoutNegatives: false
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {
|
ctx.args = args;
|
||||||
args: args,
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: userID},
|
|
||||||
headers: {origin: 'http://localhost'},
|
|
||||||
__: value => {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const observationTypeDelivery = await models.ObservationType.findOne({
|
const observationTypeDelivery = await models.ObservationType.findOne({
|
||||||
where: {code: 'delivery'}
|
where: {code: 'delivery'}
|
||||||
}, options);
|
}, options);
|
||||||
|
@ -152,6 +123,7 @@ describe('ticket componentUpdate()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change warehouse and without negatives', async() => {
|
it('should change warehouse and without negatives', async() => {
|
||||||
|
const ctx = beforeAll.getCtx(9);
|
||||||
const tx = await models.SaleComponent.beginTransaction({});
|
const tx = await models.SaleComponent.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -178,17 +150,7 @@ describe('ticket componentUpdate()', () => {
|
||||||
option: 'renewPrices',
|
option: 'renewPrices',
|
||||||
isWithoutNegatives: true
|
isWithoutNegatives: true
|
||||||
};
|
};
|
||||||
|
ctx.args = args;
|
||||||
const ctx = {
|
|
||||||
args: args,
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'},
|
|
||||||
__: value => {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const oldTicket = await models.Ticket.findById(ticketID, null, options);
|
const oldTicket = await models.Ticket.findById(ticketID, null, options);
|
||||||
|
|
||||||
|
@ -210,6 +172,7 @@ describe('ticket componentUpdate()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('componentUpdate() keepPrice', () => {
|
describe('componentUpdate() keepPrice', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
it('should change shipped and keep price', async() => {
|
it('should change shipped and keep price', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
@ -239,16 +202,7 @@ describe('ticket componentUpdate()', () => {
|
||||||
keepPrice: true
|
keepPrice: true
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {
|
ctx.args = args;
|
||||||
args: args,
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'},
|
|
||||||
__: value => {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const beforeSale = await models.Sale.findById(saleId, null, options);
|
const beforeSale = await models.Sale.findById(saleId, null, options);
|
||||||
await models.Ticket.componentUpdate(ctx, options);
|
await models.Ticket.componentUpdate(ctx, options);
|
||||||
|
@ -292,16 +246,7 @@ describe('ticket componentUpdate()', () => {
|
||||||
keepPrice: false
|
keepPrice: false
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {
|
ctx.args = args;
|
||||||
args: args,
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'},
|
|
||||||
__: value => {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const beforeSale = await models.Sale.findById(saleId, null, options);
|
const beforeSale = await models.Sale.findById(saleId, null, options);
|
||||||
await models.Ticket.componentUpdate(ctx, options);
|
await models.Ticket.componentUpdate(ctx, options);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('ticket filter()', () => {
|
describe('ticket filter()', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
it('should return the tickets matching the filter', async() => {
|
it('should return the tickets matching the filter', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
@ -31,11 +32,12 @@ describe('ticket filter()', () => {
|
||||||
const today = Date.vnNew();
|
const today = Date.vnNew();
|
||||||
today.setHours(23, 59, 59, 59);
|
today.setHours(23, 59, 59, 59);
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {
|
const args = {
|
||||||
problems: true,
|
problems: true,
|
||||||
from: yesterday,
|
from: yesterday,
|
||||||
to: today
|
to: today
|
||||||
}};
|
};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
@ -60,11 +62,12 @@ describe('ticket filter()', () => {
|
||||||
const today = Date.vnNew();
|
const today = Date.vnNew();
|
||||||
today.setHours(23, 59, 59, 59);
|
today.setHours(23, 59, 59, 59);
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {
|
const args = {
|
||||||
problems: false,
|
problems: false,
|
||||||
from: yesterday,
|
from: yesterday,
|
||||||
to: today
|
to: today
|
||||||
}};
|
};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
@ -83,7 +86,8 @@ describe('ticket filter()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {problems: null}};
|
const args = {problems: null};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
@ -102,7 +106,8 @@ describe('ticket filter()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {orderFk: 11}};
|
const args = {orderFk: 11};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
const firstRow = result[0];
|
const firstRow = result[0];
|
||||||
|
@ -123,7 +128,8 @@ describe('ticket filter()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {pending: true}};
|
const args = {pending: true};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
@ -146,7 +152,8 @@ describe('ticket filter()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {pending: false}};
|
const args = {pending: false};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
const firstRow = result[0];
|
const firstRow = result[0];
|
||||||
|
@ -167,11 +174,13 @@ describe('ticket filter()', () => {
|
||||||
|
|
||||||
it('should return the tickets from the worker team', async() => {
|
it('should return the tickets from the worker team', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
const ctx = beforeAll.getCtx(18);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 18}}, args: {myTeam: true}};
|
const args = {myTeam: true};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
@ -185,12 +194,14 @@ describe('ticket filter()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets that are not from the worker team', async() => {
|
it('should return the tickets that are not from the worker team', async() => {
|
||||||
|
const ctx = beforeAll.getCtx(18);
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 18}}, args: {myTeam: false}};
|
const args = {myTeam: false};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
@ -204,12 +215,14 @@ describe('ticket filter()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets belonging to the collection id 1', async() => {
|
it('should return the tickets belonging to the collection id 1', async() => {
|
||||||
|
const ctx = beforeAll.getCtx(18);
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 18}}, args: {collectionFk: 1}};
|
const args = {collectionFk: 1};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
@ -228,7 +241,8 @@ describe('ticket filter()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: true}};
|
const args = {hasRoute: true};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
@ -247,7 +261,8 @@ describe('ticket filter()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: false}};
|
const args = {hasRoute: false};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
@ -266,7 +281,8 @@ describe('ticket filter()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: null}};
|
const args = {hasRoute: null};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
@ -285,7 +301,8 @@ describe('ticket filter()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {hasInvoice: true}};
|
const args = {hasInvoice: true};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
@ -304,7 +321,8 @@ describe('ticket filter()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {hasInvoice: null}};
|
const args = {hasInvoice: null};
|
||||||
|
ctx.args = args;
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('TicketFuture getTicketsAdvance()', () => {
|
describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
const today = Date.vnNew();
|
const today = Date.vnNew();
|
||||||
today.setHours(0, 0, 0, 0);
|
today.setHours(0, 0, 0, 0);
|
||||||
let tomorrow = Date.vnNew();
|
let tomorrow = Date.vnNew();
|
||||||
|
@ -18,7 +19,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
@ -42,7 +43,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
isFullMovable: true
|
isFullMovable: true
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
@ -67,7 +68,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
isFullMovable: false
|
isFullMovable: false
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(0);
|
expect(result.length).toEqual(0);
|
||||||
|
@ -92,7 +93,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
ipt: 'V'
|
ipt: 'V'
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(5);
|
expect(result.length).toBeGreaterThan(5);
|
||||||
|
@ -117,7 +118,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
tfIpt: 'V'
|
tfIpt: 'V'
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(5);
|
expect(result.length).toBeGreaterThan(5);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('ticket getTicketsFuture()', () => {
|
describe('ticket getTicketsFuture()', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
const today = Date.vnNew();
|
const today = Date.vnNew();
|
||||||
today.setHours(0, 0, 0, 0);
|
today.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ describe('ticket getTicketsFuture()', () => {
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
@ -40,7 +41,7 @@ describe('ticket getTicketsFuture()', () => {
|
||||||
problems: true
|
problems: true
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
@ -65,7 +66,7 @@ describe('ticket getTicketsFuture()', () => {
|
||||||
problems: false
|
problems: false
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(0);
|
expect(result.length).toEqual(0);
|
||||||
|
@ -90,7 +91,7 @@ describe('ticket getTicketsFuture()', () => {
|
||||||
problems: null
|
problems: null
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
@ -115,7 +116,7 @@ describe('ticket getTicketsFuture()', () => {
|
||||||
state: 'OK'
|
state: 'OK'
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
@ -140,7 +141,7 @@ describe('ticket getTicketsFuture()', () => {
|
||||||
futureState: 'OK'
|
futureState: 'OK'
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
@ -165,7 +166,7 @@ describe('ticket getTicketsFuture()', () => {
|
||||||
ipt: null
|
ipt: null
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
@ -190,7 +191,7 @@ describe('ticket getTicketsFuture()', () => {
|
||||||
ipt: 'H'
|
ipt: 'H'
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
@ -215,7 +216,7 @@ describe('ticket getTicketsFuture()', () => {
|
||||||
futureIpt: null
|
futureIpt: null
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
@ -240,7 +241,7 @@ describe('ticket getTicketsFuture()', () => {
|
||||||
futureIpt: 'H'
|
futureIpt: 'H'
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
@ -265,7 +266,7 @@ describe('ticket getTicketsFuture()', () => {
|
||||||
id: 13
|
id: 13
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
@ -290,7 +291,7 @@ describe('ticket getTicketsFuture()', () => {
|
||||||
futureId: 12
|
futureId: 12
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
ctx.args = args;
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('ticket isEditableOrThrow()', () => {
|
describe('ticket isEditableOrThrow()', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
it('should throw an error as the ticket does not exist', async() => {
|
it('should throw an error as the ticket does not exist', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const ctx = {
|
|
||||||
req: {accessToken: {userId: 9}}
|
|
||||||
};
|
|
||||||
|
|
||||||
await models.Ticket.isEditableOrThrow(ctx, 9999, options);
|
await models.Ticket.isEditableOrThrow(ctx, 9999, options);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('ticket merge()', () => {
|
describe('ticket merge()', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
const tickets = {
|
const tickets = {
|
||||||
originId: 13,
|
originId: 13,
|
||||||
destinationId: 12,
|
destinationId: 12,
|
||||||
|
@ -10,30 +10,6 @@ describe('ticket merge()', () => {
|
||||||
workerFk: 1
|
workerFk: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
http: {
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost:5000'},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ctx.req.__ = value => {
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should merge two tickets', async() => {
|
it('should merge two tickets', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
||||||
|
|
||||||
describe('ticket recalculateComponents()', () => {
|
describe('ticket recalculateComponents()', () => {
|
||||||
const ticketId = 11;
|
const ticketId = 11;
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
|
|
||||||
it('should update the ticket components', async() => {
|
it('should update the ticket components', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
@ -10,7 +11,6 @@ describe('ticket recalculateComponents()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const response = await models.Ticket.recalculateComponents(ctx, ticketId, options);
|
const response = await models.Ticket.recalculateComponents(ctx, ticketId, options);
|
||||||
|
|
||||||
expect(response.affectedRows).toBeDefined();
|
expect(response.affectedRows).toBeDefined();
|
||||||
|
@ -29,7 +29,6 @@ describe('ticket recalculateComponents()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const immutableTicketId = 1;
|
const immutableTicketId = 1;
|
||||||
await models.Ticket.recalculateComponents(ctx, immutableTicketId, options);
|
await models.Ticket.recalculateComponents(ctx, immutableTicketId, options);
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('ticket sendSms()', () => {
|
describe('ticket sendSms()', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
it('should send a message and log it', async() => {
|
it('should send a message and log it', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const id = 11;
|
const id = 11;
|
||||||
const destination = 222222222;
|
const destination = 222222222;
|
||||||
const message = 'this is the message created in a test';
|
const message = 'this is the message created in a test';
|
||||||
|
|
|
@ -1,17 +1,8 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('ticket setDeleted()', () => {
|
describe('ticket setDeleted()', () => {
|
||||||
const userId = 1106;
|
const ctx = beforeAll.getCtx();
|
||||||
const activeCtx = {
|
beforeAll.mockLoopBackContext();
|
||||||
accessToken: {userId: userId},
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error if the given ticket has a claim', async() => {
|
it('should throw an error if the given ticket has a claim', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
@ -20,7 +11,6 @@ describe('ticket setDeleted()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: activeCtx};
|
|
||||||
const ticketId = 16;
|
const ticketId = 16;
|
||||||
|
|
||||||
await models.Ticket.setDeleted(ctx, ticketId, options);
|
await models.Ticket.setDeleted(ctx, ticketId, options);
|
||||||
|
@ -40,15 +30,6 @@ describe('ticket setDeleted()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost:5000'},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ctx.req.__ = value => {
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
const ticketId = 24;
|
const ticketId = 24;
|
||||||
const [sectorCollectionBefore] = await models.Ticket.rawSql(
|
const [sectorCollectionBefore] = await models.Ticket.rawSql(
|
||||||
`SELECT COUNT(*) numberRows
|
`SELECT COUNT(*) numberRows
|
||||||
|
@ -75,15 +56,6 @@ describe('ticket setDeleted()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost:5000'},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ctx.req.__ = value => {
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
const [ticketCollectionOld] = await models.Ticket.rawSql(
|
const [ticketCollectionOld] = await models.Ticket.rawSql(
|
||||||
`SELECT COUNT(*) numberRows
|
`SELECT COUNT(*) numberRows
|
||||||
FROM vn.ticketCollection`, [], options);
|
FROM vn.ticketCollection`, [], options);
|
||||||
|
@ -110,16 +82,6 @@ describe('ticket setDeleted()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost:5000'},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ctx.req.__ = value => {
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
|
|
||||||
const ticketId = 8;
|
const ticketId = 8;
|
||||||
await models.Ticket.setDeleted(ctx, ticketId, options);
|
await models.Ticket.setDeleted(ctx, ticketId, options);
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,10 @@ const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
xdescribe('ticket state()', () => {
|
xdescribe('ticket state()', () => {
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
const salesPersonId = 18;
|
const salesPersonId = 18;
|
||||||
const employeeId = 1;
|
const employeeId = 1;
|
||||||
const productionId = 49;
|
const productionId = 49;
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
__: value => value
|
|
||||||
};
|
|
||||||
const ctx = {req: activeCtx};
|
|
||||||
const now = Date.vnNew();
|
const now = Date.vnNew();
|
||||||
const sampleTicket = {
|
const sampleTicket = {
|
||||||
shipped: now,
|
shipped: now,
|
||||||
|
@ -33,7 +29,7 @@ xdescribe('ticket state()', () => {
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
active: activeCtx
|
active: ctx
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -45,7 +41,7 @@ xdescribe('ticket state()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
activeCtx.accessToken.userId = salesPersonId;
|
ctx.req.accessToken.userId = salesPersonId;
|
||||||
|
|
||||||
await models.Ticket.state(ctx, {ticketFk: 2, stateFk: 3}, options);
|
await models.Ticket.state(ctx, {ticketFk: 2, stateFk: 3}, options);
|
||||||
|
|
||||||
|
@ -66,7 +62,7 @@ xdescribe('ticket state()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
activeCtx.accessToken.userId = employeeId;
|
ctx.req.accessToken.userId = employeeId;
|
||||||
|
|
||||||
await models.Ticket.state(ctx, {ticketFk: 11, stateFk: 13}, options);
|
await models.Ticket.state(ctx, {ticketFk: 11, stateFk: 13}, options);
|
||||||
|
|
||||||
|
@ -88,7 +84,7 @@ xdescribe('ticket state()', () => {
|
||||||
|
|
||||||
const ticket = await models.Ticket.create(sampleTicket, options);
|
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||||
|
|
||||||
activeCtx.accessToken.userId = productionId;
|
ctx.req.accessToken.userId = productionId;
|
||||||
const stateOk = await models.State.findOne({where: {code: 'OK'}}, options);
|
const stateOk = await models.State.findOne({where: {code: 'OK'}}, options);
|
||||||
const params = {ticketFk: ticket.id, stateFk: stateOk.id};
|
const params = {ticketFk: ticket.id, stateFk: stateOk.id};
|
||||||
|
|
||||||
|
@ -115,7 +111,7 @@ xdescribe('ticket state()', () => {
|
||||||
|
|
||||||
spyOn(models.Chat, 'sendCheckingPresence').and.callThrough();
|
spyOn(models.Chat, 'sendCheckingPresence').and.callThrough();
|
||||||
const ticket = await models.Ticket.create(sampleTicket, options);
|
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||||
activeCtx.accessToken.userId = salesPersonId;
|
ctx.req.accessToken.userId = salesPersonId;
|
||||||
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
||||||
const paramsAssigned = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1};
|
const paramsAssigned = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1};
|
||||||
const resAssigned = await models.Ticket.state(ctx, paramsAssigned, options);
|
const resAssigned = await models.Ticket.state(ctx, paramsAssigned, options);
|
||||||
|
@ -127,7 +123,7 @@ xdescribe('ticket state()', () => {
|
||||||
expect(resAssigned.id).toBeDefined();
|
expect(resAssigned.id).toBeDefined();
|
||||||
expect(models.Chat.sendCheckingPresence).not.toHaveBeenCalled();
|
expect(models.Chat.sendCheckingPresence).not.toHaveBeenCalled();
|
||||||
|
|
||||||
activeCtx.accessToken.userId = productionId;
|
ctx.req.accessToken.userId = productionId;
|
||||||
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
||||||
const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId};
|
const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId};
|
||||||
const resPacked = await models.Ticket.state(ctx, paramsPacked, options);
|
const resPacked = await models.Ticket.state(ctx, paramsPacked, options);
|
||||||
|
@ -149,7 +145,7 @@ xdescribe('ticket state()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ticket = await models.Ticket.create(sampleTicket, options);
|
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||||
activeCtx.accessToken.userId = salesPersonId;
|
ctx.req.accessToken.userId = salesPersonId;
|
||||||
|
|
||||||
const sampleSale = {
|
const sampleSale = {
|
||||||
ticketFk: ticket.id,
|
ticketFk: ticket.id,
|
||||||
|
@ -169,7 +165,7 @@ xdescribe('ticket state()', () => {
|
||||||
expect(resAssigned.userFk).toBe(1);
|
expect(resAssigned.userFk).toBe(1);
|
||||||
expect(resAssigned.id).toBeDefined();
|
expect(resAssigned.id).toBeDefined();
|
||||||
|
|
||||||
activeCtx.accessToken.userId = productionId;
|
ctx.req.accessToken.userId = productionId;
|
||||||
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
||||||
const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId};
|
const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId};
|
||||||
const resPacked = await models.Ticket.state(ctx, paramsPacked, options);
|
const resPacked = await models.Ticket.state(ctx, paramsPacked, options);
|
||||||
|
|
|
@ -4,18 +4,11 @@ describe('Ticket transferClient()', () => {
|
||||||
const originalTicketId = 8;
|
const originalTicketId = 8;
|
||||||
const refundTicketId = 24;
|
const refundTicketId = 24;
|
||||||
const clientId = 1;
|
const clientId = 1;
|
||||||
let ctx;
|
|
||||||
|
const ctx = beforeAll.getCtx();
|
||||||
let options;
|
let options;
|
||||||
let tx;
|
let tx;
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
},
|
|
||||||
args: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
options = {transaction: tx};
|
options = {transaction: tx};
|
||||||
tx = await models.Ticket.beginTransaction({});
|
tx = await models.Ticket.beginTransaction({});
|
||||||
options.transaction = tx;
|
options.transaction = tx;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue