Merge branch 'dev' into 3080-osticket_report
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
21c34b90ec
|
@ -3,7 +3,7 @@ module.exports = Self => {
|
||||||
description: 'Get pending collections from a worker',
|
description: 'Get pending collections from a worker',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
returns: {
|
returns: {
|
||||||
type: 'Object',
|
type: 'object',
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('getCollection()', () => {
|
describe('ticket getCollection()', () => {
|
||||||
it('return list of collection', async() => {
|
it('should return a list of collections', async() => {
|
||||||
let ctx = {req: {accessToken: {userId: 1106}}};
|
let ctx = {req: {accessToken: {userId: 1106}}};
|
||||||
let response = await app.models.Collection.getCollection(ctx);
|
let response = await models.Collection.getCollection(ctx);
|
||||||
|
|
||||||
expect(response.length).toBeGreaterThan(0);
|
expect(response.length).toBeGreaterThan(0);
|
||||||
expect(response[0].collectionFk).toEqual(1);
|
expect(response[0].collectionFk).toEqual(1);
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
alter table `vn`.`travelThermograph` modify `temperature` enum('COOL', 'WARM') null;
|
|
@ -1067,10 +1067,10 @@ INSERT INTO `vn`.`itemPlacement`(`id`, `itemFk`, `warehouseFk`, `code`)
|
||||||
(4, 2, 1, 'A44');
|
(4, 2, 1, 'A44');
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`)
|
INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1106, 5),
|
(1, 1106, 5, DATE_ADD(CURDATE(),INTERVAL +1 DAY)),
|
||||||
(2, 1106, 14);
|
(2, 1106, 14, CURDATE());
|
||||||
|
|
||||||
INSERT INTO `vn`.`ticketCollection`(`id`, `ticketFk`, `collectionFk`)
|
INSERT INTO `vn`.`ticketCollection`(`id`, `ticketFk`, `collectionFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2224,6 +2224,11 @@ INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `week
|
||||||
|
|
||||||
INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11');
|
INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11');
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`temperature`(`code`, `name`, `description`)
|
||||||
|
VALUES
|
||||||
|
('WARM', 'Warm', 'Warm'),
|
||||||
|
('COOL', 'Cool', 'Cool');
|
||||||
|
|
||||||
INSERT INTO `vn`.`thermograph`(`id`, `model`)
|
INSERT INTO `vn`.`thermograph`(`id`, `model`)
|
||||||
VALUES
|
VALUES
|
||||||
('TMM190901395', 'TEMPMATE'),
|
('TMM190901395', 'TEMPMATE'),
|
||||||
|
@ -2231,7 +2236,8 @@ INSERT INTO `vn`.`thermograph`(`id`, `model`)
|
||||||
('TZ1905012010', 'DISPOSABLE'),
|
('TZ1905012010', 'DISPOSABLE'),
|
||||||
('138350-0', 'DISPOSABLE');
|
('138350-0', 'DISPOSABLE');
|
||||||
|
|
||||||
INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperature`, `result`, `dmsFk`)
|
|
||||||
|
INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperatureFk`, `result`, `dmsFk`)
|
||||||
VALUES
|
VALUES
|
||||||
('TMM190901395', CURDATE(), 1, 1, 'WARM', 'Ok', NULL),
|
('TMM190901395', CURDATE(), 1, 1, 'WARM', 'Ok', NULL),
|
||||||
('TL.BBA85422', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL),
|
('TL.BBA85422', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL),
|
||||||
|
|
|
@ -1005,7 +1005,7 @@ export default {
|
||||||
newThermographId: 'vn-textfield[ng-model="$ctrl.newThermograph.thermographId"]',
|
newThermographId: 'vn-textfield[ng-model="$ctrl.newThermograph.thermographId"]',
|
||||||
newThermographModel: 'vn-autocomplete[ng-model="$ctrl.newThermograph.model"]',
|
newThermographModel: 'vn-autocomplete[ng-model="$ctrl.newThermograph.model"]',
|
||||||
newThermographWarehouse: 'vn-autocomplete[ng-model="$ctrl.newThermograph.warehouseId"]',
|
newThermographWarehouse: 'vn-autocomplete[ng-model="$ctrl.newThermograph.warehouseId"]',
|
||||||
newThermographTemperature: 'vn-autocomplete[ng-model="$ctrl.newThermograph.temperature"]',
|
newThermographTemperature: 'vn-autocomplete[ng-model="$ctrl.newThermograph.temperatureFk"]',
|
||||||
createThermographButton: 'form button[response="accept"]',
|
createThermographButton: 'form button[response="accept"]',
|
||||||
uploadIcon: 'vn-travel-thermograph-create vn-icon[icon="icon-attach"]',
|
uploadIcon: 'vn-travel-thermograph-create vn-icon[icon="icon-attach"]',
|
||||||
createdThermograph: 'vn-travel-thermograph-index vn-tbody > vn-tr',
|
createdThermograph: 'vn-travel-thermograph-index vn-tbody > vn-tr',
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
import selectors from '../../helpers/selectors.js';
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
import getBrowser from '../../helpers/puppeteer';
|
||||||
|
|
||||||
// #3082 clone is broken due to a strange trigger from production
|
describe('InvoiceIn descriptor path', () => {
|
||||||
xdescribe('InvoiceIn descriptor path', () => {
|
|
||||||
let browser;
|
let browser;
|
||||||
let page;
|
let page;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe('Travel thermograph path', () => {
|
||||||
await page.write(selectors.travelThermograph.newThermographId, thermographName);
|
await page.write(selectors.travelThermograph.newThermographId, thermographName);
|
||||||
await page.autocompleteSearch(selectors.travelThermograph.newThermographModel, 'TEMPMATE');
|
await page.autocompleteSearch(selectors.travelThermograph.newThermographModel, 'TEMPMATE');
|
||||||
await page.autocompleteSearch(selectors.travelThermograph.newThermographWarehouse, 'Warehouse Two');
|
await page.autocompleteSearch(selectors.travelThermograph.newThermographWarehouse, 'Warehouse Two');
|
||||||
await page.autocompleteSearch(selectors.travelThermograph.newThermographTemperature, 'WARM');
|
await page.autocompleteSearch(selectors.travelThermograph.newThermographTemperature, 'Warm');
|
||||||
await page.waitToClick(selectors.travelThermograph.createThermographButton);
|
await page.waitToClick(selectors.travelThermograph.createThermographButton);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,11 @@ module.exports = Self => {
|
||||||
|
|
||||||
const issued = new Date(sourceInvoiceIn.issued);
|
const issued = new Date(sourceInvoiceIn.issued);
|
||||||
issued.setMonth(issued.getMonth() + 1);
|
issued.setMonth(issued.getMonth() + 1);
|
||||||
|
const clonedRef = sourceInvoiceIn.supplierRef + '(2)';
|
||||||
|
|
||||||
const clone = await models.InvoiceIn.create({
|
const clone = await models.InvoiceIn.create({
|
||||||
serial: sourceInvoiceIn.serial,
|
serial: sourceInvoiceIn.serial,
|
||||||
supplierRef: sourceInvoiceIn.supplierRef,
|
supplierRef: clonedRef,
|
||||||
supplierFk: sourceInvoiceIn.supplierFk,
|
supplierFk: sourceInvoiceIn.supplierFk,
|
||||||
issued: issued,
|
issued: issued,
|
||||||
currencyFk: sourceInvoiceIn.currencyFk,
|
currencyFk: sourceInvoiceIn.currencyFk,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
// #3082 clone is broken due to a strange trigger from production
|
describe('invoiceIn clone()', () => {
|
||||||
xdescribe('invoiceIn clone()', () => {
|
|
||||||
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 userId = 1;
|
const userId = 1;
|
||||||
const ctx = {
|
const ctx = {
|
||||||
|
@ -18,7 +17,7 @@ xdescribe('invoiceIn clone()', () => {
|
||||||
try {
|
try {
|
||||||
const clone = await models.InvoiceIn.clone(ctx, 1, options);
|
const clone = await models.InvoiceIn.clone(ctx, 1, options);
|
||||||
|
|
||||||
expect(clone.supplierRef).toEqual('1234');
|
expect(clone.supplierRef).toEqual('1234(2)');
|
||||||
|
|
||||||
const invoiceInTaxes = await models.InvoiceInTax.find({where: {invoiceInFk: clone.id}}, options);
|
const invoiceInTaxes = await models.InvoiceInTax.find({where: {invoiceInFk: clone.id}}, options);
|
||||||
|
|
||||||
|
|
|
@ -4,27 +4,30 @@ module.exports = Self => {
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
arg: 'thermographId',
|
arg: 'thermographId',
|
||||||
type: 'String',
|
type: 'string',
|
||||||
description: 'The thermograph id',
|
description: 'The thermograph id',
|
||||||
required: true
|
required: true
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
arg: 'model',
|
arg: 'model',
|
||||||
type: 'String',
|
type: 'string',
|
||||||
description: 'The thermograph model',
|
description: 'The thermograph model',
|
||||||
required: true
|
required: true
|
||||||
}, {
|
},
|
||||||
arg: 'temperature',
|
{
|
||||||
type: 'String',
|
arg: 'temperatureFk',
|
||||||
|
type: 'string',
|
||||||
description: 'The thermograph temperature',
|
description: 'The thermograph temperature',
|
||||||
required: true
|
required: true
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
arg: 'warehouseId',
|
arg: 'warehouseId',
|
||||||
type: 'Number',
|
type: 'number',
|
||||||
description: 'The warehouse id',
|
description: 'The warehouse id',
|
||||||
required: true
|
required: true
|
||||||
}],
|
}],
|
||||||
returns: {
|
returns: {
|
||||||
type: 'Object',
|
type: 'object',
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
|
@ -33,27 +36,35 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.createThermograph = async(thermographId, model, temperature, warehouseId) => {
|
Self.createThermograph = async(thermographId, model, temperatureFk, warehouseId, options) => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const tx = await Self.beginTransaction({});
|
let tx;
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
|
||||||
const thermograph = await models.Thermograph.create({
|
const thermograph = await models.Thermograph.create({
|
||||||
id: thermographId,
|
id: thermographId,
|
||||||
model: model
|
model: model
|
||||||
}, options);
|
}, myOptions);
|
||||||
|
|
||||||
await Self.rawSql(`
|
await Self.rawSql(`
|
||||||
INSERT INTO travelThermograph(thermographFk, warehouseFk, temperature, created)
|
INSERT INTO travelThermograph(thermographFk, warehouseFk, temperatureFk, created)
|
||||||
VALUES (?, ?,?, NOW())
|
VALUES (?, ?, ?, NOW())
|
||||||
`, [thermograph.id, warehouseId, temperature], options);
|
`, [thermograph.id, warehouseId, temperatureFk], myOptions);
|
||||||
|
|
||||||
await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
return thermograph;
|
return thermograph;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,47 +1,51 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('Termograph createThermograph()', () => {
|
describe('Termograph createThermograph()', () => {
|
||||||
const models = app.models;
|
|
||||||
const thermographId = '99999-1';
|
const thermographId = '99999-1';
|
||||||
const model = 'DISPOSABLE';
|
const model = 'DISPOSABLE';
|
||||||
const temperature = 'COOL';
|
const temperatureFk = 'COOL';
|
||||||
const warehouseId = 1;
|
const warehouseId = 1;
|
||||||
let createdThermograph;
|
|
||||||
|
|
||||||
afterAll(async done => {
|
it(`should create a thermograph which is saved in both thermograph and travelThermograph`, async() => {
|
||||||
let travelThermograpToDelete = await models.TravelThermograph.findOne({where: {thermographFk: createdThermograph.id}});
|
const tx = await models.Thermograph.beginTransaction({});
|
||||||
let thermograpToDelete = await models.Thermograph.findById(createdThermograph.id);
|
|
||||||
|
|
||||||
await travelThermograpToDelete.destroy();
|
try {
|
||||||
await thermograpToDelete.destroy();
|
const options = {transaction: tx};
|
||||||
|
|
||||||
done();
|
const createdThermograph = await models.Thermograph.createThermograph(thermographId, model, temperatureFk, warehouseId, options);
|
||||||
|
|
||||||
|
expect(createdThermograph.id).toEqual(thermographId);
|
||||||
|
expect(createdThermograph.model).toEqual(model);
|
||||||
|
|
||||||
|
const createdTravelThermograpth = await models.TravelThermograph.findOne({where: {thermographFk: thermographId}}, options);
|
||||||
|
|
||||||
|
expect(createdTravelThermograpth.warehouseFk).toEqual(warehouseId);
|
||||||
|
expect(createdTravelThermograpth.temperatureFk).toEqual(temperatureFk);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should be able to create just once a thermograph which is saved in both thermograph and travelThermograph`, async() => {
|
it(`should throw an error when trying to created repeated thermograph`, async() => {
|
||||||
let createdTravelThermograpth = await models.TravelThermograph.findOne({where: {thermographFk: thermographId}});
|
const tx = await models.Thermograph.beginTransaction({});
|
||||||
|
|
||||||
expect(createdTravelThermograpth).toBeNull();
|
|
||||||
|
|
||||||
createdThermograph = await models.Thermograph.createThermograph(thermographId, model, temperature, warehouseId);
|
|
||||||
|
|
||||||
expect(createdThermograph.id).toEqual(thermographId);
|
|
||||||
expect(createdThermograph.model).toEqual(model);
|
|
||||||
|
|
||||||
createdTravelThermograpth = await models.TravelThermograph.findOne({where: {thermographFk: thermographId}});
|
|
||||||
|
|
||||||
expect(createdTravelThermograpth.warehouseFk).toEqual(warehouseId);
|
|
||||||
expect(createdTravelThermograpth.temperature).toEqual(temperature);
|
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await models.Thermograph.createThermograph(thermographId, model, temperature, warehouseId);
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
await models.Thermograph.createThermograph(thermographId, model, temperatureFk, warehouseId, options);
|
||||||
|
await models.Thermograph.createThermograph(thermographId, model, temperatureFk, warehouseId, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error).toBeDefined();
|
|
||||||
expect(error.message).toBe('This thermograph id already exists');
|
expect(error.message).toBe('This thermograph id already exists');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
module.exports = Self => {
|
|
||||||
Self.remoteMethod('getThermographTemperatures', {
|
|
||||||
description: 'Gets the thermograph temperatures',
|
|
||||||
accessType: 'READ',
|
|
||||||
returns: {
|
|
||||||
type: ['String'],
|
|
||||||
root: true
|
|
||||||
},
|
|
||||||
http: {
|
|
||||||
path: `/getThermographTemperatures`,
|
|
||||||
verb: 'GET'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.getThermographTemperatures = async() => {
|
|
||||||
return Self.getEnumValues('temperature');
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -6,44 +6,51 @@ module.exports = Self => {
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
arg: 'id',
|
arg: 'id',
|
||||||
type: 'Number',
|
type: 'number',
|
||||||
description: 'The travel id',
|
description: 'The travel id',
|
||||||
http: {source: 'path'}
|
http: {source: 'path'}
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
arg: 'thermographId',
|
arg: 'thermographId',
|
||||||
type: 'String',
|
type: 'string',
|
||||||
description: 'The thermograph id',
|
description: 'The thermograph id',
|
||||||
required: true
|
required: true
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
arg: 'state',
|
arg: 'state',
|
||||||
type: 'String',
|
type: 'string',
|
||||||
required: true
|
required: true
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
arg: 'warehouseId',
|
arg: 'warehouseId',
|
||||||
type: 'Number',
|
type: 'number',
|
||||||
description: 'The warehouse id',
|
description: 'The warehouse id',
|
||||||
required: true
|
required: true
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
arg: 'companyId',
|
arg: 'companyId',
|
||||||
type: 'Number',
|
type: 'number',
|
||||||
description: 'The company id',
|
description: 'The company id',
|
||||||
required: true
|
required: true
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
arg: 'dmsTypeId',
|
arg: 'dmsTypeId',
|
||||||
type: 'Number',
|
type: 'number',
|
||||||
description: 'The dms type id',
|
description: 'The dms type id',
|
||||||
required: true
|
required: true
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
arg: 'reference',
|
arg: 'reference',
|
||||||
type: 'String',
|
type: 'string',
|
||||||
required: true
|
required: true
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
arg: 'description',
|
arg: 'description',
|
||||||
type: 'String',
|
type: 'string',
|
||||||
required: true
|
required: true
|
||||||
}],
|
}],
|
||||||
returns: {
|
returns: {
|
||||||
type: 'Object',
|
type: 'object',
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
|
@ -52,36 +59,44 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.createThermograph = async(ctx, id, thermographId, state) => {
|
Self.createThermograph = async(ctx, id, thermographId, state, options) => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const tx = await Self.beginTransaction({});
|
let tx;
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
|
||||||
const travelThermograph = await models.TravelThermograph.findOne({
|
const travelThermograph = await models.TravelThermograph.findOne({
|
||||||
where: {
|
where: {
|
||||||
thermographFk: thermographId,
|
thermographFk: thermographId,
|
||||||
travelFk: null
|
travelFk: null
|
||||||
}
|
}
|
||||||
}, options);
|
}, myOptions);
|
||||||
|
|
||||||
if (!travelThermograph)
|
if (!travelThermograph)
|
||||||
throw new UserError('No valid travel thermograph found');
|
throw new UserError('No valid travel thermograph found');
|
||||||
|
|
||||||
const uploadedFiles = await models.Dms.uploadFile(ctx, options);
|
const uploadedFiles = await models.Dms.uploadFile(ctx, myOptions);
|
||||||
const firstDms = uploadedFiles[0];
|
const firstDms = uploadedFiles[0];
|
||||||
|
|
||||||
await travelThermograph.updateAttributes({
|
await travelThermograph.updateAttributes({
|
||||||
dmsFk: firstDms.id,
|
dmsFk: firstDms.id,
|
||||||
travelFk: id,
|
travelFk: id,
|
||||||
result: state
|
result: state
|
||||||
}, options);
|
}, myOptions);
|
||||||
|
|
||||||
await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
return travelThermograph;
|
return travelThermograph;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('Travel createThermograph()', () => {
|
describe('Travel createThermograph()', () => {
|
||||||
const models = app.models;
|
|
||||||
const travelId = 3;
|
const travelId = 3;
|
||||||
const currentUserId = 1102;
|
const currentUserId = 1102;
|
||||||
const thermographId = '138350-0';
|
const thermographId = '138350-0';
|
||||||
const ctx = {req: {accessToken: {userId: currentUserId}}, args: {dmsTypeId: 1}};
|
const ctx = {req: {accessToken: {userId: currentUserId}}, args: {dmsTypeId: 1}};
|
||||||
let travelThermographBefore;
|
|
||||||
|
|
||||||
afterAll(async done => {
|
|
||||||
await app.models.TravelThermograph.rawSql(`
|
|
||||||
UPDATE travelThermograph
|
|
||||||
SET travelFk = NULL, dmsFk = NULL
|
|
||||||
WHERE id = ?`, [travelThermographBefore.id]);
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should set the travelFk and dmsFk properties to the travel thermograph`, async() => {
|
it(`should set the travelFk and dmsFk properties to the travel thermograph`, async() => {
|
||||||
spyOn(app.models.Dms, 'uploadFile').and.returnValue([{id: 5}]);
|
const tx = await models.Travel.beginTransaction({});
|
||||||
|
|
||||||
travelThermographBefore = await models.TravelThermograph.findOne({
|
try {
|
||||||
where: {
|
const options = {transaction: tx};
|
||||||
thermographFk: thermographId,
|
|
||||||
travelFk: null
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
await models.Travel.createThermograph(ctx, travelId, thermographId);
|
spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 5}]);
|
||||||
|
|
||||||
const travelThermographAfter = await models.TravelThermograph.findOne({
|
travelThermographBefore = await models.TravelThermograph.findOne({
|
||||||
where: {
|
where: {
|
||||||
thermographFk: thermographId,
|
thermographFk: thermographId,
|
||||||
travelFk: travelId
|
travelFk: null
|
||||||
}
|
}
|
||||||
});
|
}, options);
|
||||||
|
|
||||||
expect(app.models.Dms.uploadFile).toHaveBeenCalledWith(ctx, jasmine.any(Object));
|
await models.Travel.createThermograph(ctx, travelId, thermographId, options);
|
||||||
|
|
||||||
expect(travelThermographBefore).toBeDefined();
|
const travelThermographAfter = await models.TravelThermograph.findOne({
|
||||||
expect(travelThermographBefore.thermographFk).toEqual(thermographId);
|
where: {
|
||||||
expect(travelThermographBefore.travelFk).toBeNull();
|
thermographFk: thermographId,
|
||||||
expect(travelThermographAfter).toBeDefined();
|
travelFk: travelId
|
||||||
|
}
|
||||||
|
}, options);
|
||||||
|
|
||||||
expect(travelThermographAfter.thermographFk).toEqual(thermographId);
|
expect(models.Dms.uploadFile).toHaveBeenCalledWith(ctx, jasmine.any(Object));
|
||||||
expect(travelThermographAfter.travelFk).toEqual(travelId);
|
|
||||||
expect(travelThermographAfter.dmsFk).toEqual(5);
|
expect(travelThermographBefore).toBeDefined();
|
||||||
|
expect(travelThermographBefore.thermographFk).toEqual(thermographId);
|
||||||
|
expect(travelThermographBefore.travelFk).toBeNull();
|
||||||
|
expect(travelThermographAfter).toBeDefined();
|
||||||
|
|
||||||
|
expect(travelThermographAfter.thermographFk).toEqual(thermographId);
|
||||||
|
expect(travelThermographAfter.travelFk).toEqual(travelId);
|
||||||
|
expect(travelThermographAfter.dmsFk).toEqual(5);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,5 +13,8 @@
|
||||||
},
|
},
|
||||||
"TravelThermograph": {
|
"TravelThermograph": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"Temperature": {
|
||||||
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "Temperature",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "temperature"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"code": {
|
||||||
|
"type": "string",
|
||||||
|
"id": true,
|
||||||
|
"description": "Identifier",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"acls": [{
|
||||||
|
"accessType": "READ",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}]
|
||||||
|
}
|
|
@ -1,4 +0,0 @@
|
||||||
module.exports = Self => {
|
|
||||||
require('../methods/travel-thermograph/getThermographTemperatures')(Self);
|
|
||||||
};
|
|
||||||
|
|
|
@ -13,22 +13,25 @@
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "Number",
|
"type": "number",
|
||||||
"description": "Identifier",
|
"description": "Identifier",
|
||||||
"id": true
|
"id": true
|
||||||
},
|
},
|
||||||
"created": {
|
"created": {
|
||||||
"type": "Date"
|
"type": "date"
|
||||||
},
|
},
|
||||||
"temperature": {
|
"temperature": {
|
||||||
"type": "String",
|
"type": "string"
|
||||||
|
},
|
||||||
|
"temperatureFk": {
|
||||||
|
"type": "string",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"type": "String"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"warehouseFk": {
|
"warehouseFk": {
|
||||||
"type": "Number",
|
"type": "number",
|
||||||
"required": true
|
"required": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -122,8 +122,9 @@
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="temperaturesModel"
|
vn-id="temperaturesModel"
|
||||||
url="TravelThermographs/getThermographTemperatures"
|
url="Temperatures"
|
||||||
data="thermographTemperatures">
|
data="Temperatures"
|
||||||
|
auto-load="true">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-dialog class="edit"
|
<vn-dialog class="edit"
|
||||||
vn-id="newThermographDialog"
|
vn-id="newThermographDialog"
|
||||||
|
@ -162,10 +163,10 @@
|
||||||
vn-one
|
vn-one
|
||||||
required="true"
|
required="true"
|
||||||
label="Temperature"
|
label="Temperature"
|
||||||
ng-model="$ctrl.newThermograph.temperature"
|
ng-model="$ctrl.newThermograph.temperatureFk"
|
||||||
data="thermographTemperatures"
|
data='Temperatures'
|
||||||
show-field="value"
|
show-field="name"
|
||||||
value-field="value">
|
value-field="code">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</tpl-body>
|
</tpl-body>
|
||||||
|
|
|
@ -63,12 +63,11 @@ class Controller extends Section {
|
||||||
this.newThermograph = {
|
this.newThermograph = {
|
||||||
thermographId: this.thermographId,
|
thermographId: this.thermographId,
|
||||||
warehouseId: this.warehouseId,
|
warehouseId: this.warehouseId,
|
||||||
temperature: defaultTemperature,
|
temperatureFk: defaultTemperature,
|
||||||
model: defaultModel
|
model: defaultModel
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$.modelsModel.refresh();
|
this.$.modelsModel.refresh();
|
||||||
this.$.temperaturesModel.refresh();
|
|
||||||
this.$.newThermographDialog.show();
|
this.$.newThermographDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue