7806_devToTest_2332 #2801
|
@ -22,6 +22,7 @@
|
|||
- feat: refs #7438 Added volume to item_valuateInventory by:guillermo
|
||||
- feat: refs #7438 Requested changes and little changes by:guillermo
|
||||
- refs #6281 feat:buyFk in itemShelving by:sergiodt
|
||||
- feat: refs #6449 item ID is displayed in the sale line by:jorgep
|
||||
|
||||
### Changed 📦
|
||||
|
||||
|
|
|
@ -4,15 +4,7 @@ describe('collection getSales()', () => {
|
|||
const collectionOrTicketFk = 999999;
|
||||
const print = true;
|
||||
const source = 'CHECKER';
|
||||
|
||||
beforeAll(() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'},
|
||||
}
|
||||
};
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should return a collection with tickets, placements and barcodes settled correctly', async() => {
|
||||
const tx = await models.Collection.beginTransaction({});
|
||||
|
|
|
@ -1,15 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('collection getTickets()', () => {
|
||||
let ctx;
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
};
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should get tickets, sales and barcodes from collection', async() => {
|
||||
const tx = await models.Collection.beginTransaction({});
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('setSaleQuantity()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should change quantity sale', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
|
|
@ -1,22 +1,7 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('getStarredModules()', () => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
const ctx = {req: activeCtx};
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it(`should return the starred modules for a given user`, async() => {
|
||||
const newStarred = await models.StarredModule.create({workerFk: 9, moduleFk: 'customer', position: 1});
|
||||
|
|
|
@ -1,24 +1,8 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('setPosition()', () => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
const ctx = {
|
||||
req: activeCtx
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should increase the orders module position by replacing it with clients and vice versa', async() => {
|
||||
const tx = await models.StarredModule.beginTransaction({});
|
||||
|
|
|
@ -1,24 +1,7 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('toggleStarredModule()', () => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
const ctx = {
|
||||
req: activeCtx
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
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');
|
||||
|
@ -26,7 +9,7 @@ describe('toggleStarredModule()', () => {
|
|||
|
||||
expect(starredModules.length).toEqual(1);
|
||||
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);
|
||||
|
||||
await models.StarredModule.toggleStarredModule(ctx, 'order');
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('userConfig getUserConfig()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it(`should return the configuration data of a given user`, async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const result = await models.UserConfig.getUserConfig(ctx, options);
|
||||
|
||||
expect(result.warehouseFk).toEqual(1);
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('loopback model MailAliasAccount', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should add a mail Alias', async() => {
|
||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
||||
let error;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 9}};
|
||||
const options = {transaction: tx, ctx};
|
||||
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
|
||||
|
||||
await tx.rollback();
|
||||
|
@ -23,7 +24,7 @@ describe('loopback model MailAliasAccount', () => {
|
|||
let error;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 9}};
|
||||
const options = {transaction: tx, ctx};
|
||||
await models.MailAliasAccount.create({mailAlias: 3, account: 5}, options);
|
||||
|
||||
await tx.rollback();
|
||||
|
|
|
@ -9,24 +9,24 @@
|
|||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
"type": "string"
|
||||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
"type": "string"
|
||||
},
|
||||
"isInventory": {
|
||||
"type": "number"
|
||||
"type": "number"
|
||||
},
|
||||
"isManaged":{
|
||||
"type": "boolean"
|
||||
"isManaged": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"countryFk": {
|
||||
"type": "number"
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -34,6 +34,11 @@
|
|||
"type": "belongsTo",
|
||||
"model": "Country",
|
||||
"foreignKey": "countryFk"
|
||||
},
|
||||
"address": {
|
||||
"type": "belongsTo",
|
||||
"model": "Address",
|
||||
"foreignKey": "addressFk"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
|
@ -44,5 +49,11 @@
|
|||
"permission": "ALLOW"
|
||||
}
|
||||
],
|
||||
"scope" : {"where": {"isForTicket": {"neq": 0}}}
|
||||
"scope": {
|
||||
"where": {
|
||||
"isForTicket": {
|
||||
"neq": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ async function init() {
|
|||
host: process.env.DB_HOST,
|
||||
port: process.env.DB_PORT
|
||||
});
|
||||
|
||||
const bootOptions = {dataSources};
|
||||
await new Promise((resolve, reject) => {
|
||||
app.boot(bootOptions,
|
||||
|
@ -33,3 +32,4 @@ module.exports = {
|
|||
|
||||
if (require.main === module)
|
||||
init();
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ async function test() {
|
|||
'loopback/**/*[sS]pec.js',
|
||||
'modules/*/back/**/*.[sS]pec.js'
|
||||
],
|
||||
helpers: []
|
||||
helpers: [`back/vn-jasmine.js`],
|
||||
};
|
||||
|
||||
if (PARALLEL) {
|
||||
|
@ -114,7 +114,6 @@ async function test() {
|
|||
if (opts.ci)
|
||||
runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = SPEC_TIMEOUT;
|
||||
|
||||
// runner.loadConfigFile('back/jasmine.json');
|
||||
runner.loadConfig(config);
|
||||
process.env.SPEC_IS_RUNNING = true;
|
||||
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,
|
||||
isInventory = TRUE,
|
||||
life = 10,
|
||||
density = 250,
|
||||
itemPackingTypeFk = NULL,
|
||||
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,
|
||||
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);
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ BEGIN
|
|||
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||
JOIN vn.component c ON c.id = sc.componentFk
|
||||
JOIN vn.componentType ct ON ct.id = c.typeFk
|
||||
WHERE ct.code = 'FREIGHT'
|
||||
WHERE ct.code = 'freight'
|
||||
AND r.created BETWEEN vDatedFrom AND vDatedTo
|
||||
GROUP BY r.id
|
||||
) sub ON sub.routeFk = r.Id_Ruta
|
||||
|
|
|
@ -2,7 +2,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|||
SQL SECURITY DEFINER
|
||||
VIEW `bi`.`tarifa_componentes_series`
|
||||
AS SELECT `ct`.`id` AS `tarifa_componentes_series_id`,
|
||||
`ct`.`type` AS `Serie`,
|
||||
`ct`.`name` AS `Serie`,
|
||||
`ct`.`isBase` AS `base`,
|
||||
`ct`.`isMargin` AS `margen`
|
||||
FROM `vn`.`componentType` `ct`
|
||||
|
|
|
@ -7,7 +7,6 @@ BEGIN
|
|||
*/
|
||||
DECLARE vRewriteKop INT DEFAULT NULL;
|
||||
DECLARE vTruncatePutOrder INT DEFAULT NULL;
|
||||
DECLARE vBarcode CHAR(15) DEFAULT NULL;
|
||||
DECLARE vKop INT;
|
||||
DECLARE vPutOrderFk BIGINT;
|
||||
|
||||
|
@ -16,17 +15,6 @@ BEGIN
|
|||
FROM ekt
|
||||
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
|
||||
|
||||
IF vKop IS NULL THEN
|
||||
|
@ -46,10 +34,9 @@ BEGIN
|
|||
|
||||
-- Refresh EKT
|
||||
|
||||
UPDATE ekt SET
|
||||
barcode = vBarcode
|
||||
,kop = vKop
|
||||
,putOrderFk = vTruncatePutOrder
|
||||
UPDATE ekt
|
||||
SET kop = vKop,
|
||||
putOrderFk = vTruncatePutOrder
|
||||
WHERE id = vSelf;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -2,7 +2,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|||
SQL SECURITY DEFINER
|
||||
VIEW `edi`.`ektRecent`
|
||||
AS SELECT `e`.`id` AS `id`,
|
||||
`e`.`barcode` AS `barcode`,
|
||||
`e`.`entryYear` AS `entryYear`,
|
||||
`e`.`batchNumber` AS `batchNumber`,
|
||||
`e`.`deliveryNumber` AS `deliveryNumber`,
|
||||
|
|
|
@ -6,19 +6,6 @@ BEGIN
|
|||
* identificando y notificando los asientos descuadrados
|
||||
* 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
|
||||
JOIN (
|
||||
|
|
|
@ -47,9 +47,9 @@ BEGIN
|
|||
INTO vHasTooMuchCollections,
|
||||
vLockName
|
||||
FROM productionConfig pc
|
||||
LEFT JOIN tCollection ON TRUE;
|
||||
LEFT JOIN tmp.collection ON TRUE;
|
||||
|
||||
DROP TEMPORARY TABLE tCollection;
|
||||
DROP TEMPORARY TABLE tmp.collection;
|
||||
|
||||
IF vHasTooMuchCollections THEN
|
||||
CALL util.throw('Hay colecciones pendientes');
|
||||
|
|
|
@ -7,27 +7,32 @@ BEGIN
|
|||
* @param vWorkerFk id del worker.
|
||||
* @table Devuelve tabla temporal con las colecciones pendientes
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tCollection;
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
CREATE TEMPORARY TABLE tCollection
|
||||
SELECT c.id collectionFk,
|
||||
date(c.created) created,
|
||||
COUNT(DISTINCT tc.ticketFk) ticketTotalCount
|
||||
FROM collection c
|
||||
JOIN ticketCollection tc ON tc.collectionFk = c.id
|
||||
JOIN sale s ON s.ticketFk = tc.ticketFk
|
||||
JOIN ticketState ts ON ts.ticketFk = tc.ticketFk
|
||||
JOIN state s2 ON s2.id = ts.stateFk
|
||||
JOIN productionConfig pc
|
||||
JOIN vn.state ss on ss.code = 'PREPARED'
|
||||
LEFT JOIN vn.saleTracking st on st.saleFk = s.id AND st.stateFk = ss.id
|
||||
WHERE c.workerFk = vWorkerFk
|
||||
AND TIMESTAMPDIFF(HOUR, c.created , util.VN_NOW()) < pc.pendingCollectionsAge
|
||||
AND s.quantity != 0
|
||||
AND s2.order < pc.pendingCollectionsOrder
|
||||
GROUP BY c.id
|
||||
HAVING COUNT(*) > COUNT(DISTINCT st.id);
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.collection
|
||||
ENGINE = MEMORY
|
||||
SELECT c.id collectionFk,
|
||||
DATE(c.created) created,
|
||||
COUNT(DISTINCT tc.ticketFk) ticketTotalCount
|
||||
FROM collection c
|
||||
JOIN ticketCollection tc ON tc.collectionFk = c.id
|
||||
JOIN sale s ON s.ticketFk = tc.ticketFk
|
||||
JOIN ticketState ts ON ts.ticketFk = tc.ticketFk
|
||||
JOIN state s2 ON s2.id = ts.stateFk
|
||||
JOIN productionConfig pc
|
||||
JOIN vn.state ss ON ss.code = 'PREPARED'
|
||||
LEFT JOIN vn.saleTracking st ON st.saleFk = s.id
|
||||
AND st.stateFk = ss.id
|
||||
WHERE c.workerFk = vWorkerFk
|
||||
AND TIMESTAMPDIFF(HOUR, c.created , util.VN_NOW()) < pc.pendingCollectionsAge
|
||||
AND s.quantity
|
||||
AND s2.order < pc.pendingCollectionsOrder
|
||||
GROUP BY c.id
|
||||
HAVING COUNT(*) > COUNT(DISTINCT st.id);
|
||||
|
||||
SELECT * FROM tCollection;
|
||||
SELECT * FROM tmp.collection;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -15,6 +15,11 @@ proc: BEGIN
|
|||
DECLARE vEndingDate DATETIME;
|
||||
DECLARE vIsTodayRelative BOOLEAN;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY
|
||||
INTO vEndingDate
|
||||
FROM productionConfig;
|
||||
|
@ -31,7 +36,8 @@ proc: BEGIN
|
|||
CALL prepareClientList();
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems
|
||||
(INDEX (ticketFk)) ENGINE = MEMORY
|
||||
(INDEX (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped
|
||||
FROM tmp.productionTicket tt
|
||||
JOIN ticket t ON t.id = tt.ticketFk;
|
||||
|
|
|
@ -8,7 +8,7 @@ BEGIN
|
|||
JOIN vn.component c ON c.id = sc.componentFk
|
||||
JOIN vn.componentType ct ON ct.id = c.typeFk
|
||||
WHERE s.ticketFk = vTicketFk
|
||||
AND ct.`type` = 'otros';
|
||||
AND ct.code = 'other';
|
||||
|
||||
UPDATE vn.sale s
|
||||
JOIN (
|
||||
|
|
|
@ -278,12 +278,11 @@ BEGIN
|
|||
-- Redondeo: Cantidad pedida incorrecta en al grouping de la última compra
|
||||
CALL buyUltimate(vWarehouseFk, vDate);
|
||||
INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk)
|
||||
SELECT ticketFk, problem, saleFk
|
||||
SELECT ticketFk, problem ,saleFk
|
||||
FROM (
|
||||
SELECT tl.ticketFk,
|
||||
s.id saleFk ,
|
||||
LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,''), ' '), 250) problem,
|
||||
MOD(s.quantity, b.`grouping`) hasRounding
|
||||
s.id saleFk,
|
||||
LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem
|
||||
FROM tmp.ticket_list tl
|
||||
JOIN ticket t ON t.id = tl.ticketFk
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
|
@ -291,9 +290,9 @@ BEGIN
|
|||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
||||
JOIN buy b ON b.id = bu.buyFk
|
||||
WHERE MOD(s.quantity, b.`grouping`)
|
||||
GROUP BY tl.ticketFk
|
||||
HAVING hasRounding
|
||||
) sub
|
||||
)sub
|
||||
ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk;
|
||||
END LOOP;
|
||||
CLOSE vCursor;
|
||||
|
|
|
@ -9,6 +9,11 @@ BEGIN
|
|||
*/
|
||||
DECLARE vStateFk INT;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
INSERT INTO ticket (
|
||||
clientFk,
|
||||
shipped,
|
||||
|
|
|
@ -20,7 +20,8 @@ BEGIN
|
|||
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||
JOIN saleComponent sc ON sc.saleFk = s.id
|
||||
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
|
||||
AND ic.merchandise;
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ BEGIN
|
|||
JOIN vn.componentType ct ON ct.id = c.typeFk
|
||||
JOIN vn.sale s ON s.id = sc.saleFk
|
||||
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
|
||||
SET tf.freight = sb.freight;
|
||||
|
||||
|
@ -88,7 +88,7 @@ BEGIN
|
|||
|
||||
-- Margin
|
||||
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,
|
||||
t.ticketFk
|
||||
FROM vn.saleComponent sc
|
||||
|
|
|
@ -19,4 +19,4 @@ FROM (
|
|||
)
|
||||
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(
|
||||
`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`.`life` AS `life`,
|
||||
`it`.`isPackaging` AS `isPackaging`,
|
||||
`it`.`density` AS `density`,
|
||||
`it`.`isInventory` AS `inventory`,
|
||||
`it`.`created` AS `odbc_date`,
|
||||
`it`.`making` AS `confeccion`,
|
||||
`it`.`temperatureFk` AS `Temperatura`,
|
||||
`it`.`promo` AS `promo`,
|
||||
`it`.`maneuver` AS `maneuver`,
|
||||
`it`.`target` AS `target`,
|
||||
`it`.`topMargin` AS `top_margin`,
|
||||
`it`.`profit` AS `profit`
|
||||
`it`.`promo` AS `promo`
|
||||
FROM `vn`.`itemType` `it`
|
||||
|
|
|
@ -2,7 +2,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`buy_edi`
|
||||
AS SELECT `t`.`id` AS `id`,
|
||||
`t`.`barcode` AS `barcode`,
|
||||
`t`.`entryYear` AS `entry_year`,
|
||||
`t`.`deliveryNumber` AS `delivery_number`,
|
||||
`t`.`fec` AS `fec`,
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
ALTER TABLE vn.claimLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.clientLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.deviceProductionLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.entryLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.invoiceInLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.itemLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.packingSiteDeviceLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.parkingLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.rateLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.routeLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.shelvingLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.supplierLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.ticketLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.travelLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.userLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.workerLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE vn.zoneLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
|
||||
ALTER TABLE account.userLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE account.signInLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE account.roleLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
||||
ALTER TABLE account.accountLog ADD COLUMN IF NOT EXISTS summaryId varchar(30);
|
|
@ -0,0 +1,8 @@
|
|||
-- Place your SQL code here
|
||||
|
||||
USE vn;
|
||||
|
||||
ALTER TABLE vn.roadmap ADD kmStart mediumint(9) DEFAULT NULL NULL;
|
||||
ALTER TABLE vn.roadmap ADD kmEnd mediumint(9) DEFAULT NULL NULL;
|
||||
ALTER TABLE vn.roadmap ADD started DATETIME NULL;
|
||||
ALTER TABLE vn.roadmap ADD finished DATETIME NULL;
|
|
@ -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';
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE vn.calendar ADD created timestamp DEFAULT current_timestamp() NOT NULL AFTER dated;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE vn.greuge CHANGE Id id int(10) unsigned auto_increment NOT NULL;
|
|
@ -2,18 +2,9 @@ const models = require('vn-loopback/server/server').models;
|
|||
|
||||
describe('Application execute()/executeProc()/executeFunc()', () => {
|
||||
const userWithoutPrivileges = 1;
|
||||
const userWithPrivileges = 9;
|
||||
const userWithInheritedPrivileges = 120;
|
||||
let tx;
|
||||
|
||||
function getCtx(userId) {
|
||||
return {
|
||||
req: {
|
||||
accessToken: {userId},
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
};
|
||||
}
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
beforeEach(async() => {
|
||||
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() => {
|
||||
const ctx = getCtx(userWithoutPrivileges);
|
||||
const ctx = {req: {accessToken: {userId: userWithoutPrivileges}}};
|
||||
|
||||
let error;
|
||||
try {
|
||||
|
@ -66,7 +57,6 @@ describe('Application execute()/executeProc()/executeFunc()', () => {
|
|||
});
|
||||
|
||||
it('should execute procedure and get data', async() => {
|
||||
const ctx = getCtx(userWithPrivileges);
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
|
@ -90,7 +80,6 @@ describe('Application execute()/executeProc()/executeFunc()', () => {
|
|||
|
||||
describe('Application executeProc()', () => {
|
||||
it('should execute procedure and get data (executeProc)', async() => {
|
||||
const ctx = getCtx(userWithPrivileges);
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
|
@ -115,7 +104,6 @@ describe('Application execute()/executeProc()/executeFunc()', () => {
|
|||
|
||||
describe('Application executeFunc()', () => {
|
||||
it('should execute function and get data', async() => {
|
||||
const ctx = getCtx(userWithPrivileges);
|
||||
try {
|
||||
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() => {
|
||||
const ctx = getCtx(userWithInheritedPrivileges);
|
||||
const ctx = {req: {accessToken: {userId: userWithInheritedPrivileges}}};
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ module.exports = Self => {
|
|||
const locale = modelLocale && modelLocale.get(lang);
|
||||
|
||||
json[modelName] = {
|
||||
http: model.sharedClass.http.path,
|
||||
properties: model.definition.rawProperties,
|
||||
validations: jsonValidations,
|
||||
locale
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Model crud()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
let insertId;
|
||||
const barcodeModel = app.models.ItemBarcode;
|
||||
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Model rewriteDbError()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should extend rewriteDbError properties to any model passed', () => {
|
||||
const exampleModel = models.ItemTag;
|
||||
|
|
|
@ -2,15 +2,7 @@ const app = require('vn-loopback/server/server');
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('claim filter()', () => {
|
||||
let ctx;
|
||||
beforeEach(() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
};
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should return 1 result filtering by id', async() => {
|
||||
const tx = await app.models.Claim.beginTransaction({});
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('claim regularizeClaim()', () => {
|
||||
const userId = 18;
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: userId},
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
};
|
||||
const ctx = beforeAll.mockLoopBackContext(userId);
|
||||
ctx.req.__ = (value, params) => {
|
||||
return params.nickname;
|
||||
};
|
||||
|
||||
const chatModel = models.Chat;
|
||||
const claimId = 1;
|
||||
const ticketId = 1;
|
||||
|
@ -40,20 +33,6 @@ describe('claim regularizeClaim()', () => {
|
|||
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() => {
|
||||
const tx = await models.Claim.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,22 +1,10 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
const i18n = require('i18n');
|
||||
describe('Update Claim', () => {
|
||||
let url;
|
||||
let claimStatesMap = {};
|
||||
beforeAll.mockLoopBackContext();
|
||||
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();
|
||||
claimStatesMap = claimStates.reduce((acc, state) => ({...acc, [state.code]: state.id}), {});
|
||||
});
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Update Claim', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
const newDate = Date.vnNew();
|
||||
const original = {
|
||||
ticketFk: 3,
|
||||
|
|
|
@ -1,23 +1,10 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Client addressesPropagateRe', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
|
||||
it('should propagate the isEqualizated on both addresses of Mr Wayne 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({});
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Address createAddress', () => {
|
||||
const clientFk = 1101;
|
||||
|
@ -7,20 +6,7 @@ describe('Address createAddress', () => {
|
|||
const incotermsFk = 'FAS';
|
||||
const customAgentOneId = 1;
|
||||
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should throw a non uee member error if no incoterms is defined', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Client Create', () => {
|
||||
const newAccount = {
|
||||
userName: 'deadpool',
|
||||
|
@ -16,20 +14,7 @@ describe('Client Create', () => {
|
|||
const newAccountWithoutEmail = JSON.parse(JSON.stringify(newAccount));
|
||||
delete newAccountWithoutEmail.email;
|
||||
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it(`should not find deadpool as he's not created yet`, async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Client getCard()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should receive a formated card of Bruce Wayne', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const options = {transaction: tx};
|
||||
|
||||
const id = 1101;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('client getDebt()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should return the client debt', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('client sendSms()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should now send a message and log it', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const id = 1101;
|
||||
const destination = 222222222;
|
||||
const message = 'this is the message created in a test';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('client summary()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should return a summary object containing data', async() => {
|
||||
const clientId = 1101;
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Address updateAddress', () => {
|
||||
const clientId = 1101;
|
||||
const addressId = 1;
|
||||
|
@ -14,20 +12,7 @@ describe('Address updateAddress', () => {
|
|||
}
|
||||
};
|
||||
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should throw the non uee member error if no incoterms is defined', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
|
|
@ -1,24 +1,10 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('loopback model address', () => {
|
||||
let createdAddressId;
|
||||
const clientId = 1101;
|
||||
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
beforeAll(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
afterAll(async() => {
|
||||
const client = await models.Client.findById(clientId);
|
||||
|
|
|
@ -29,7 +29,8 @@ module.exports = Self => {
|
|||
http: {
|
||||
path: '/:id/buy-label',
|
||||
verb: 'GET'
|
||||
}
|
||||
},
|
||||
accessScopes: ['DEFAULT', 'read:multimedia']
|
||||
});
|
||||
|
||||
Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label');
|
||||
|
|
|
@ -112,7 +112,6 @@ module.exports = Self => {
|
|||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const conn = Self.dataSource.connector;
|
||||
const where = buildFilter(ctx.args, (param, value) => {
|
||||
switch (param) {
|
||||
|
@ -146,7 +145,12 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
filter = mergeFilters(ctx.args.filter, {where});
|
||||
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const isSupplier = await Self.app.models.Supplier.findById(userId, myOptions);
|
||||
if (isSupplier) {
|
||||
if (!filter.where) filter.where = {};
|
||||
filter.where[`e.supplierFk`] = ctx.req.accessToken.userId;
|
||||
}
|
||||
const stmts = [];
|
||||
let stmt;
|
||||
stmt = new ParameterizedSQL(
|
||||
|
@ -158,7 +162,7 @@ module.exports = Self => {
|
|||
e.invoiceNumber,
|
||||
e.isBooked,
|
||||
e.isExcludedFromAvailable,
|
||||
e.evaNotes AS observation,
|
||||
e.evaNotes observation,
|
||||
e.isConfirmed,
|
||||
e.isOrdered,
|
||||
e.isRaid,
|
||||
|
@ -170,13 +174,19 @@ module.exports = Self => {
|
|||
e.gestDocFk,
|
||||
e.invoiceInFk,
|
||||
t.landed,
|
||||
s.name AS supplierName,
|
||||
s.nickname AS supplierAlias,
|
||||
co.code AS companyCode,
|
||||
cu.code AS currencyCode
|
||||
s.name supplierName,
|
||||
s.nickname supplierAlias,
|
||||
co.code companyCode,
|
||||
cu.code currencyCode,
|
||||
t.shipped,
|
||||
t.landed,
|
||||
t.ref AS travelRef,
|
||||
t.warehouseInFk,
|
||||
w.name warehouseInName
|
||||
FROM vn.entry e
|
||||
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||
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.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;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getBuys', {
|
||||
Self.remoteMethodCtx('getBuys', {
|
||||
description: 'Returns buys for one entry',
|
||||
accessType: 'READ',
|
||||
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 myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
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 = {
|
||||
where: {entryFk: id},
|
||||
fields: [
|
||||
|
@ -49,9 +57,23 @@ module.exports = Self => {
|
|||
'buyingValue',
|
||||
'price2',
|
||||
'price3',
|
||||
'printedStickers'
|
||||
'printedStickers',
|
||||
'entryFk'
|
||||
],
|
||||
include: {
|
||||
include: [{
|
||||
relation: 'entry',
|
||||
scope: {
|
||||
fields: [
|
||||
'id', 'supplierFk'
|
||||
],
|
||||
include: {
|
||||
relation: 'supplier', scope: {
|
||||
fields: ['id']
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'item',
|
||||
scope: {
|
||||
fields: [
|
||||
|
@ -82,9 +104,8 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
defaultFilter = mergeFilters(defaultFilter, filter);
|
||||
|
||||
return models.Buy.find(defaultFilter, myOptions);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('entry addFromPackaging()', () => {
|
||||
const supplier = 442;
|
||||
|
@ -7,22 +6,10 @@ describe('entry addFromPackaging()', () => {
|
|||
const yesterday = new Date(today);
|
||||
yesterday.setDate(today.getDate() - 1);
|
||||
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 49},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'},
|
||||
},
|
||||
},
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx,
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
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 options = {transaction: tx};
|
||||
|
||||
|
|
|
@ -1,21 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Buy editLatestsBuys()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should change the value of a given column for the selected buys', async() => {
|
||||
const tx = await models.Buy.beginTransaction({});
|
||||
|
|
|
@ -9,7 +9,8 @@ describe('Entry filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
search: 1
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 9}}
|
||||
};
|
||||
|
||||
const result = await models.Entry.filter(ctx, options);
|
||||
|
@ -32,7 +33,8 @@ describe('Entry filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
currencyFk: 1
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 9}}
|
||||
};
|
||||
|
||||
const result = await models.Entry.filter(ctx, options);
|
||||
|
@ -46,26 +48,73 @@ describe('Entry filter()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should return the entry matching the supplier', async() => {
|
||||
const tx = await models.Entry.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
describe('should return the entry matching the supplier', () => {
|
||||
it('when userId is supplier ', async() => {
|
||||
const tx = await models.Entry.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
args: {
|
||||
supplierFk: 2
|
||||
}
|
||||
};
|
||||
try {
|
||||
const ctx = {
|
||||
args: {},
|
||||
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();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
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() => {
|
||||
|
@ -76,7 +125,8 @@ describe('Entry filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
companyFk: 442
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 9}}
|
||||
};
|
||||
|
||||
const result = await models.Entry.filter(ctx, options);
|
||||
|
@ -98,7 +148,8 @@ describe('Entry filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
isBooked: true,
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 9}}
|
||||
};
|
||||
|
||||
const result = await models.Entry.filter(ctx, options);
|
||||
|
@ -121,7 +172,8 @@ describe('Entry filter()', () => {
|
|||
args: {
|
||||
reference: 'movement',
|
||||
travelFk: '2'
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 9}}
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
describe('entry getBuys()', () => {
|
||||
const entryId = 4;
|
||||
it('should get the buys and items of an entry', async() => {
|
||||
const tx = await models.Entry.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
describe('should get the buys and items of an entry ', () => {
|
||||
it('when is supplier and entry owner', async() => {
|
||||
const tx = await models.Entry.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const result = await models.Entry.getBuys(entryId, options);
|
||||
try {
|
||||
const ctx = {
|
||||
args: {
|
||||
search: 1
|
||||
},
|
||||
req: {accessToken: {userId: 2}}
|
||||
};
|
||||
|
||||
const length = result.length;
|
||||
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
||||
const result = await models.Entry.getBuys(ctx, entryId, options);
|
||||
|
||||
expect(result.length).toEqual(4);
|
||||
expect(anyResult.item).toBeDefined();
|
||||
const length = result.length;
|
||||
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
expect(result.length).toEqual(4);
|
||||
expect(anyResult.item).toBeDefined();
|
||||
|
||||
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 LoopBackContext = require('loopback-context');
|
||||
const activeCtx = {accessToken: {userId: 9}};
|
||||
|
||||
describe('entry importBuysPreview()', () => {
|
||||
const entryId = 1;
|
||||
beforeAll(async() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should return the buys with the calculated packagingFk', async() => {
|
||||
const tx = await models.Entry.beginTransaction({});
|
||||
|
|
|
@ -1,15 +1,7 @@
|
|||
const LoopBackContext = require('loopback-context');
|
||||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('invoiceInDueDay new()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should correctly create a new due day', async() => {
|
||||
const userId = 9;
|
||||
|
|
|
@ -1,24 +1,11 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('invoiceIn clone()', () => {
|
||||
let ctx;
|
||||
const ctx = beforeAll.getCtx();
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 1},
|
||||
headers: {origin: 'http://localhost'}
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: ctx.req
|
||||
});
|
||||
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
|
@ -28,7 +15,8 @@ describe('invoiceIn clone()', () => {
|
|||
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);
|
||||
|
||||
expect(clone.supplierRef).toEqual('1234(2)');
|
||||
|
@ -51,7 +39,8 @@ describe('invoiceIn clone()', () => {
|
|||
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);
|
||||
|
||||
expect(clone.supplierRef).toEqual('1234(2)');
|
||||
|
|
|
@ -1,24 +1,11 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('invoiceIn corrective()', () => {
|
||||
let ctx;
|
||||
const ctx = beforeAll.getCtx();
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'}
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: ctx.req
|
||||
});
|
||||
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('invoiceOut book()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const ctx = beforeAll.getCtx();
|
||||
const invoiceOutId = 5;
|
||||
|
||||
it('should update the booked property', async() => {
|
||||
|
|
|
@ -1,24 +1,13 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('upsertFixedPrice()', () => {
|
||||
const now = Date.vnNew();
|
||||
const fixedPriceId = 1;
|
||||
let originalFixedPrice;
|
||||
|
||||
beforeAll.mockLoopBackContext();
|
||||
beforeAll(async() => {
|
||||
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() => {
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('itemShelving getAlternative()', () => {
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'},
|
||||
}
|
||||
};
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should return a list of items without alternatives', async() => {
|
||||
const shelvingFk = 'HEJ';
|
||||
|
|
|
@ -1,25 +1,13 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('ItemShelving upsertItem()', () => {
|
||||
const warehouseFk = 1;
|
||||
let ctx;
|
||||
|
||||
const ctx = beforeAll.getCtx();
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'}
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: ctx.req
|
||||
});
|
||||
|
||||
options = {transaction: tx};
|
||||
tx = await models.ItemShelving.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
|
|
|
@ -1,21 +1,8 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('item clone()', () => {
|
||||
let nextItemId;
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
beforeEach(async() => {
|
||||
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');
|
||||
|
||||
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() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
active: ctx
|
||||
});
|
||||
const losesClientId = 1111;
|
||||
const ticket = await models.Ticket.findById(7, null, options);
|
||||
|
|
|
@ -1,21 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('item new()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should create a new item, adding the name as a tag', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
|
|
|
@ -1,27 +1,13 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('regularize()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 18},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.mockLoopBackContext(18);
|
||||
|
||||
it('should create a new ticket and add a line', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {req: {accessToken: {userId: 18}}};
|
||||
const itemId = 1;
|
||||
const warehouseId = 1;
|
||||
const quantity = 11;
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('item updateTaxes()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should throw an error if the taxClassFk is blank', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('tag onSubmit()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should delete a tag', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('order addToOrder()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const ctx = beforeAll.getCtx();
|
||||
const orderId = 8;
|
||||
it('should add a row to a given order', async() => {
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('order filter()', () => {
|
||||
const ctx = {
|
||||
req: {accessToken: {userId: 9}},
|
||||
args: {},
|
||||
params: {}
|
||||
};
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should call the filter method with a basic search', async() => {
|
||||
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');
|
||||
|
||||
describe('order new()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should throw an error if the client isnt active', async() => {
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('order newFromTicket()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should create a new order from an existing ticket', async() => {
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,21 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('AgencyTerm createInvoiceIn()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
const rows = [
|
||||
{
|
||||
routeFk: 2,
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getPalletMatchState', {
|
||||
description: 'Get list of pallet from truckFk with true or false if state is matched',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'truckFk',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The truckFk id'
|
||||
},
|
||||
{
|
||||
arg: 'state',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'State code'
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getPalletMatchState`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getPalletMatchState = async(truckFk, state, options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const result = await Self.rawSql(`
|
||||
WITH tPallet AS(
|
||||
SELECT ep.id pallet, e.id expedition, e.stateTypeFk
|
||||
FROM vn.expeditionPallet ep
|
||||
JOIN vn.expeditionScan es ON es.palletFk = ep.id
|
||||
JOIN expedition e ON e.id = es.expeditionFk
|
||||
WHERE ep.truckFk = ?
|
||||
),totalPalletExpedition AS(
|
||||
SELECT t.*, COUNT(expedition) totalPalletExpedition
|
||||
FROM tPallet t
|
||||
GROUP BY expedition
|
||||
),totalPalletExpeditionCode AS(
|
||||
SELECT t.*, COUNT(expedition) totalPalletExpeditionCode
|
||||
FROM tPallet t
|
||||
JOIN vn.expeditionStateType est ON est.id = t.stateTypeFk
|
||||
WHERE code = ?
|
||||
GROUP BY expedition
|
||||
)
|
||||
SELECT t.pallet,
|
||||
tpe.totalPalletExpedition = tpec.totalPalletExpeditionCode hasMatchStateCode
|
||||
FROM tPallet t
|
||||
LEFT JOIN totalPalletExpedition tpe ON tpe.expedition = t.expedition
|
||||
LEFT JOIN totalPalletExpeditionCode tpec ON tpec.expedition = t.expedition
|
||||
GROUP BY t.pallet;`,
|
||||
[truckFk, state],
|
||||
myOptions);
|
||||
|
||||
return result;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('roadMapStop getPalletMatchState()', () => {
|
||||
it('should return list of pallet with true or false if state is matched', async() => {
|
||||
const truckFk = 1;
|
||||
const state = 'ON DELIVERY';
|
||||
const result = await models.RoadmapStop.getPalletMatchState(truckFk, state);
|
||||
|
||||
expect(result[0].hasMatchStateCode).toBe(1);
|
||||
});
|
||||
});
|
|
@ -1,21 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('route clone()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
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() => {
|
||||
|
|
|
@ -1,20 +1,9 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('route guessPriority()', () => {
|
||||
const targetRouteId = 7;
|
||||
let routeTicketsToRestore;
|
||||
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
__: () => {}
|
||||
};
|
||||
|
||||
beforeAll(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
afterAll(async() => {
|
||||
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() => {
|
||||
const ctx = {
|
||||
req: activeCtx
|
||||
};
|
||||
routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}});
|
||||
|
||||
await app.models.Route.guessPriority(ctx, targetRouteId);
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('route updateWorkCenter()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
const routeId = 1;
|
||||
|
||||
it('should set the commission work center if the worker has workCenter', async() => {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "roadmap"
|
||||
"table": "roadmap"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
|
@ -41,10 +41,22 @@
|
|||
},
|
||||
"driverName": {
|
||||
"type": "string"
|
||||
},
|
||||
"kmStart": {
|
||||
"type": "number"
|
||||
},
|
||||
"kmEnd": {
|
||||
"type": "number"
|
||||
},
|
||||
"started": {
|
||||
"type": "date"
|
||||
},
|
||||
"finished": {
|
||||
"type": "date"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"worker": {
|
||||
"relations": {
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "id"
|
||||
|
@ -59,5 +71,5 @@
|
|||
"model": "RoadmapStop",
|
||||
"foreignKey": "roadmapFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/roadmapStop/getPalletMatchState')(Self);
|
||||
};
|
|
@ -3,7 +3,7 @@
|
|||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "roadmapStop"
|
||||
"table": "roadmapStop"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
|
@ -28,16 +28,16 @@
|
|||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"roadmap": {
|
||||
"relations": {
|
||||
"roadmap": {
|
||||
"type": "belongsTo",
|
||||
"model": "Roadmap",
|
||||
"foreignKey": "roadmapFk"
|
||||
},
|
||||
"address": {
|
||||
"type": "belongsTo",
|
||||
"model": "Address",
|
||||
"model": "RoadmapAddress",
|
||||
"foreignKey": "addressFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('supplier consumption() filter', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should return a list of entries from the supplier 2', async() => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {}};
|
||||
const filter = {
|
||||
where: {
|
||||
supplierFk: 2
|
||||
|
|
|
@ -3,7 +3,6 @@ const LoopBackContext = require('loopback-context');
|
|||
|
||||
describe('Supplier updateFiscalData()', () => {
|
||||
const supplierId = 1;
|
||||
const administrativeId = 5;
|
||||
const buyerId = 35;
|
||||
|
||||
const name = 'NEW PLANTS';
|
||||
|
|
|
@ -1,25 +1,13 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('loopback model Supplier', () => {
|
||||
let supplierOne;
|
||||
let supplierTwo;
|
||||
|
||||
beforeAll.mockLoopBackContext();
|
||||
beforeAll(async() => {
|
||||
supplierOne = await models.Supplier.findById(1);
|
||||
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', () => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('expeditionState addExpeditionState()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should update the expedition states', async() => {
|
||||
const tx = await models.ExpeditionState.beginTransaction({});
|
||||
try {
|
||||
|
|
|
@ -1,19 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('ticket deleteExpeditions()', () => {
|
||||
let ctx;
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
accessToken: {userId: 9},
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: ctx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should delete the selected expeditions', async() => {
|
||||
const tx = await models.Expedition.beginTransaction({});
|
||||
|
|
|
@ -1,29 +1,11 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('ticket moveExpeditions()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should move the selected expeditions to new ticket', async() => {
|
||||
const tx = await models.Expedition.beginTransaction({});
|
||||
const ctx = {
|
||||
req: {accessToken: {userId: 9}},
|
||||
args: {},
|
||||
params: {}
|
||||
};
|
||||
const myCtx = Object.assign({}, ctx);
|
||||
const myCtx = ctx;
|
||||
|
||||
try {
|
||||
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;
|
||||
|
||||
|
|
|
@ -1,21 +1,8 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('sale canEdit()', () => {
|
||||
const employeeId = 1;
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
describe('sale not exists', () => {
|
||||
it('should return error if sale not exists', async() => {
|
||||
|
|
|
@ -1,24 +1,11 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Ticket cloning - clone function', () => {
|
||||
let ctx;
|
||||
const ctx = beforeAll.getCtx();
|
||||
beforeAll.mockLoopBackContext();
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'}
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: ctx.req
|
||||
});
|
||||
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
|
|
|
@ -1,20 +1,8 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('sale deleteSales()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should throw an error if the ticket of the given sales is not editable', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
@ -23,14 +11,6 @@ describe('sale deleteSales()', () => {
|
|||
try {
|
||||
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 ticketId = 2;
|
||||
|
||||
|
@ -51,13 +31,6 @@ describe('sale deleteSales()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'localhost:5000'},
|
||||
__: () => {}
|
||||
}
|
||||
};
|
||||
const sale = await models.Sale.findOne({where: {id: 9}}, options);
|
||||
sale.id = null;
|
||||
const newSale = await models.Sale.create(sale, options);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('sale recalculatePrice()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should update the sale price', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
const sales = [
|
||||
|
@ -10,7 +11,6 @@ describe('sale recalculatePrice()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const response = await models.Sale.recalculatePrice(ctx, sales, options);
|
||||
|
||||
expect(response[0].affectedRows).toBeDefined();
|
||||
|
@ -30,7 +30,6 @@ describe('sale recalculatePrice()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const immutableSale = [{id: 1, ticketFk: 1}];
|
||||
await models.Sale.recalculatePrice(ctx, immutableSale, options);
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('sale reserve()', () => {
|
||||
const ctx = {
|
||||
|
@ -10,19 +9,7 @@ describe('sale reserve()', () => {
|
|||
}
|
||||
};
|
||||
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should throw an error if the ticket can not be modified', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue