8144-devToTest_2448 #3216
|
@ -32,8 +32,7 @@ RUN apt-get update \
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
samba-common-bin samba-dsdb-modules\
|
samba-common-bin samba-dsdb-modules\
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
&& npm -g install pm2
|
|
||||||
|
|
||||||
# Salix
|
# Salix
|
||||||
|
|
||||||
|
@ -55,7 +54,4 @@ COPY \
|
||||||
README.md \
|
README.md \
|
||||||
./
|
./
|
||||||
|
|
||||||
CMD ["pm2-runtime", "./back/process.yml"]
|
CMD ["node", "--tls-min-v1.0", "--openssl-legacy-provider", "./loopback/server/server.js"]
|
||||||
|
|
||||||
HEALTHCHECK --interval=15s --timeout=10s \
|
|
||||||
CMD curl -f http://localhost:3000/api/Applications/status || exit 1
|
|
|
@ -62,7 +62,8 @@ module.exports = Self => {
|
||||||
p.code parkingCodePrevia,
|
p.code parkingCodePrevia,
|
||||||
p.pickingOrder pickingOrderPrevia,
|
p.pickingOrder pickingOrderPrevia,
|
||||||
iss.id itemShelvingSaleFk,
|
iss.id itemShelvingSaleFk,
|
||||||
iss.isPicked
|
iss.isPicked,
|
||||||
|
iss.itemShelvingFk
|
||||||
FROM ticketCollection tc
|
FROM ticketCollection tc
|
||||||
LEFT JOIN collection c ON c.id = tc.collectionFk
|
LEFT JOIN collection c ON c.id = tc.collectionFk
|
||||||
JOIN sale s ON s.ticketFk = tc.ticketFk
|
JOIN sale s ON s.ticketFk = tc.ticketFk
|
||||||
|
@ -102,7 +103,8 @@ module.exports = Self => {
|
||||||
p.code,
|
p.code,
|
||||||
p.pickingOrder,
|
p.pickingOrder,
|
||||||
iss.id itemShelvingSaleFk,
|
iss.id itemShelvingSaleFk,
|
||||||
iss.isPicked
|
iss.isPicked,
|
||||||
|
iss.itemShelvingFk
|
||||||
FROM sectorCollection sc
|
FROM sectorCollection sc
|
||||||
JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
|
JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
|
||||||
JOIN saleGroup sg ON sg.id = ss.saleGroupFk
|
JOIN saleGroup sg ON sg.id = ss.saleGroupFk
|
||||||
|
|
|
@ -4,21 +4,45 @@ module.exports = Self => {
|
||||||
/**
|
/**
|
||||||
* Returns basic headers
|
* Returns basic headers
|
||||||
*
|
*
|
||||||
* @param {string} cookie - The docuware cookie
|
|
||||||
* @return {object} - The headers
|
* @return {object} - The headers
|
||||||
*/
|
*/
|
||||||
Self.getOptions = async() => {
|
Self.getOptions = async() => {
|
||||||
const docuwareConfig = await Self.app.models.DocuwareConfig.findOne();
|
const docuwareConfig = await Self.app.models.DocuwareConfig.findOne();
|
||||||
|
const now = Date.vnNow();
|
||||||
|
let {url, username, password, token, expired} = docuwareConfig;
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV && (!expired || expired < now + 60)) {
|
||||||
|
const {data: {IdentityServiceUrl}} = await axios.get(`${url}/Home/IdentityServiceInfo`);
|
||||||
|
const {data: {token_endpoint}} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`);
|
||||||
|
const {data} = await axios.post(token_endpoint, {
|
||||||
|
grant_type: 'password',
|
||||||
|
scope: 'docuware.platform',
|
||||||
|
client_id: 'docuware.platform.net.client',
|
||||||
|
username,
|
||||||
|
password
|
||||||
|
}, {headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}});
|
||||||
|
|
||||||
|
const newToken = data.access_token;
|
||||||
|
token = data.token_type + ' ' + newToken;
|
||||||
|
await docuwareConfig.updateAttributes({
|
||||||
|
token,
|
||||||
|
expired: now + data.expires_in
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Cookie': docuwareConfig.cookie
|
'Authorization': token
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: docuwareConfig.url,
|
url,
|
||||||
headers
|
headers
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,87 +2,54 @@ const axios = require('axios');
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('Docuware core', () => {
|
describe('Docuware core', () => {
|
||||||
beforeAll(() => {
|
const fileCabinetCode = 'deliveryNote';
|
||||||
|
beforeAll(async() => {
|
||||||
process.env.NODE_ENV = 'testing';
|
process.env.NODE_ENV = 'testing';
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(() => {
|
const docuwareInfo = await models.Docuware.findOne({
|
||||||
delete process.env.NODE_ENV;
|
where: {
|
||||||
});
|
code: fileCabinetCode
|
||||||
|
}
|
||||||
describe('getOptions()', () => {
|
|
||||||
it('should return url and headers', async() => {
|
|
||||||
const result = await models.Docuware.getOptions();
|
|
||||||
|
|
||||||
expect(result.url).toBeDefined();
|
|
||||||
expect(result.headers).toBeDefined();
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe('getDialog()', () => {
|
spyOn(axios, 'get').and.callFake(url => {
|
||||||
it('should return dialogId', async() => {
|
if (url.includes('IdentityServiceInfo')) return {data: {IdentityServiceUrl: 'IdentityServiceUrl'}};
|
||||||
const dialogs = {
|
if (url.includes('IdentityServiceUrl')) return {data: {token_endpoint: 'token_endpoint'}};
|
||||||
data: {
|
if (url.includes('dialogs')) {
|
||||||
Dialog: [
|
return {
|
||||||
{
|
data: {
|
||||||
DisplayName: 'find',
|
Dialog: [
|
||||||
Id: 'getDialogTest'
|
{
|
||||||
}
|
DisplayName: 'find',
|
||||||
]
|
Id: 'getDialogTest'
|
||||||
}
|
}
|
||||||
};
|
]
|
||||||
spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(dialogs)));
|
}
|
||||||
const result = await models.Docuware.getDialog('deliveryNote', 'find', 'randomFileCabinetId');
|
};
|
||||||
|
}
|
||||||
|
|
||||||
expect(result).toEqual('getDialogTest');
|
if (url.includes('FileCabinets')) {
|
||||||
});
|
return {data: {
|
||||||
});
|
|
||||||
|
|
||||||
describe('getFileCabinet()', () => {
|
|
||||||
it('should return fileCabinetId', async() => {
|
|
||||||
const code = 'deliveryNote';
|
|
||||||
const docuwareInfo = await models.Docuware.findOne({
|
|
||||||
where: {
|
|
||||||
code
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const dialogs = {
|
|
||||||
data: {
|
|
||||||
FileCabinet: [
|
FileCabinet: [
|
||||||
{
|
{
|
||||||
Name: docuwareInfo.fileCabinetName,
|
Name: docuwareInfo.fileCabinetName,
|
||||||
Id: 'getFileCabinetTest'
|
Id: 'getFileCabinetTest'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}};
|
||||||
};
|
}
|
||||||
spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(dialogs)));
|
|
||||||
const result = await models.Docuware.getFileCabinet(code);
|
|
||||||
|
|
||||||
expect(result).toEqual('getFileCabinetTest');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('get()', () => {
|
|
||||||
it('should return data without parse', async() => {
|
|
||||||
spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random()))));
|
|
||||||
spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random()))));
|
|
||||||
const data = {
|
|
||||||
data: {
|
|
||||||
id: 1
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data)));
|
|
||||||
const result = await models.Docuware.get('deliveryNote');
|
|
||||||
|
|
||||||
expect(result.id).toEqual(1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return data with parse', async() => {
|
spyOn(axios, 'post').and.callFake(url => {
|
||||||
spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random()))));
|
if (url.includes('token_endpoint')) {
|
||||||
spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random()))));
|
return {data: {
|
||||||
const data = {
|
access_token: 'access_token',
|
||||||
data: {
|
token_type: 'bearer',
|
||||||
|
expires_in: 10000
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
if (url.includes('DialogExpression')) {
|
||||||
|
return {data: {
|
||||||
Items: [{
|
Items: [{
|
||||||
Fields: [
|
Fields: [
|
||||||
{
|
{
|
||||||
|
@ -103,12 +70,52 @@ describe('Docuware core', () => {
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
delete process.env.NODE_ENV;
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getOptions()', () => {
|
||||||
|
it('should return url and headers', async() => {
|
||||||
|
const result = await models.Docuware.getOptions();
|
||||||
|
|
||||||
|
expect(result.url).toBeDefined();
|
||||||
|
expect(result.headers).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Dialog()', () => {
|
||||||
|
it('should return dialogId', async() => {
|
||||||
|
const result = await models.Docuware.getDialog('deliveryNote', 'find', 'randomFileCabinetId');
|
||||||
|
|
||||||
|
expect(result).toEqual('getDialogTest');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getFileCabinet()', () => {
|
||||||
|
it('should return fileCabinetId', async() => {
|
||||||
|
const result = await models.Docuware.getFileCabinet(fileCabinetCode);
|
||||||
|
|
||||||
|
expect(result).toEqual('getFileCabinetTest');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('get()', () => {
|
||||||
|
it('should return data without parse', async() => {
|
||||||
|
const [result] = await models.Docuware.get('deliveryNote');
|
||||||
|
|
||||||
|
expect(result.firstRequiredField).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return data with parse', async() => {
|
||||||
const parse = {
|
const parse = {
|
||||||
'firstRequiredField': 'id',
|
'firstRequiredField': 'id',
|
||||||
'secondRequiredField': 'name',
|
'secondRequiredField': 'name',
|
||||||
};
|
};
|
||||||
spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data)));
|
|
||||||
const [result] = await models.Docuware.get('deliveryNote', null, parse);
|
const [result] = await models.Docuware.get('deliveryNote', null, parse);
|
||||||
|
|
||||||
expect(result.id).toEqual(1);
|
expect(result.id).toEqual(1);
|
||||||
|
@ -119,17 +126,14 @@ describe('Docuware core', () => {
|
||||||
|
|
||||||
describe('getById()', () => {
|
describe('getById()', () => {
|
||||||
it('should return data', async() => {
|
it('should return data', async() => {
|
||||||
spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random()))));
|
spyOn(models.Docuware, 'get');
|
||||||
spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random()))));
|
await models.Docuware.getById('deliveryNote', 1);
|
||||||
const data = {
|
|
||||||
data: {
|
|
||||||
id: 1
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data)));
|
|
||||||
const result = await models.Docuware.getById('deliveryNote', 1);
|
|
||||||
|
|
||||||
expect(result.id).toEqual(1);
|
expect(models.Docuware.get).toHaveBeenCalledWith(
|
||||||
|
'deliveryNote',
|
||||||
|
{condition: [Object({DBName: 'N__ALBAR_N', Value: [1]})]},
|
||||||
|
undefined
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -143,7 +143,7 @@ module.exports = Self => {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
'X-File-ModifiedDate': Date.vnNew(),
|
'X-File-ModifiedDate': Date.vnNew(),
|
||||||
'Cookie': docuwareOptions.headers.headers.Cookie,
|
'Authorization': docuwareOptions.headers.headers.Authorization,
|
||||||
...data.getHeaders()
|
...data.getHeaders()
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,17 +16,17 @@
|
||||||
"url": {
|
"url": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"cookie": {
|
"token": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"username": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"expired":{
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"acls": [
|
|
||||||
{
|
|
||||||
"property": "*",
|
|
||||||
"accessType": "*",
|
|
||||||
"principalType": "ROLE",
|
|
||||||
"principalId": "$everyone",
|
|
||||||
"permission": "ALLOW"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
apps:
|
|
||||||
- script: ./loopback/server/server.js
|
|
||||||
name: salix-back
|
|
||||||
instances: 1
|
|
||||||
max_restarts: 0
|
|
||||||
autorestart: false
|
|
||||||
node_args: --tls-min-v1.0 --openssl-legacy-provider
|
|
|
@ -388,23 +388,23 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`)
|
||||||
(4, 'GCN Channel'),
|
(4, 'GCN Channel'),
|
||||||
(5, 'The Newspaper');
|
(5, 'The Newspaper');
|
||||||
|
|
||||||
INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`businessTypeFk`,`typeFk`)
|
INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`businessTypeFk`,`typeFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'),
|
(1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'),
|
||||||
(1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'),
|
(1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'),
|
||||||
(1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'),
|
(1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'),
|
||||||
(1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'),
|
(1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'),
|
||||||
(1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 18, 0, 'florist','normal'),
|
(1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 18, 0, 'florist','normal'),
|
||||||
(1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 19, 0, 'florist','normal'),
|
(1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 19, 0, 'florist','normal'),
|
||||||
(1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 19, 0, 'florist','normal'),
|
(1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 19, 0, 'florist','normal'),
|
||||||
(1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 'florist','normal'),
|
(1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 'florist','normal'),
|
||||||
(1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, 0, 'florist','normal'),
|
(1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, 0, 'florist','normal'),
|
||||||
(1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, NULL, 1, 'florist','normal'),
|
(1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, NULL, 1, 'florist','normal'),
|
||||||
(1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'),
|
(1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'),
|
||||||
(1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses');
|
(1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses');
|
||||||
|
|
||||||
INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
|
INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
|
||||||
SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1
|
SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1
|
||||||
FROM `account`.`role` `r`
|
FROM `account`.`role` `r`
|
||||||
WHERE `r`.`hasLogin` = 1;
|
WHERE `r`.`hasLogin` = 1;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_sectorCollectionAddPrevOK`(
|
||||||
|
vSectorCollectionFk INT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Inserta los registros de sectorCollection con el estado PREVIA OK si la reserva está picked
|
||||||
|
*
|
||||||
|
* @param vSectorCollectionFk Identificador de vn.sectorCollection
|
||||||
|
*/
|
||||||
|
REPLACE saleTracking(saleFk, isChecked, workerFk, stateFk)
|
||||||
|
SELECT sgd.saleFk, TRUE, sc.userFk, s.id
|
||||||
|
FROM sectorCollection sc
|
||||||
|
JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id
|
||||||
|
JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk
|
||||||
|
JOIN state s ON s.code = 'OK PREVIOUS'
|
||||||
|
JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk
|
||||||
|
WHERE sc.id = vSectorCollectionFk AND iss.isPicked;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,5 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getTax`(IN vTaxArea VARCHAR(25))
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getTax`(
|
||||||
|
vTaxArea VARCHAR(25)
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Calcula la base imponible, el IVA y el recargo de equivalencia para
|
* Calcula la base imponible, el IVA y el recargo de equivalencia para
|
||||||
|
@ -33,30 +35,39 @@ BEGIN
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketTax
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketTax
|
||||||
(PRIMARY KEY (ticketFk, code, rate))
|
(PRIMARY KEY (ticketFk, code, rate))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT * FROM (
|
WITH sales AS (
|
||||||
SELECT tmpTicket.ticketFk,
|
SELECT s.ticketFk,
|
||||||
bp.pgcFk,
|
s.itemFk,
|
||||||
SUM(s.quantity * s.price * (100 - s.discount) / 100 ) taxableBase,
|
s.quantity * s.price * (100 - s.discount) / 100 total,
|
||||||
pgc.rate,
|
t.companyFk,
|
||||||
tc.code,
|
t.addressFk,
|
||||||
bp.priority
|
su.countryFk,
|
||||||
FROM tmp.ticket tmpTicket
|
ata.areaFk,
|
||||||
JOIN sale s ON s.ticketFk = tmpTicket.ticketFk
|
itc.taxClassFk
|
||||||
JOIN item i ON i.id = s.itemFk
|
FROM vn.sale s
|
||||||
JOIN ticket t ON t.id = tmpTicket.ticketFk
|
JOIN tmp.ticket tmp ON tmp.ticketFk = s.ticketFk
|
||||||
JOIN supplier su ON su.id = t.companyFk
|
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||||
|
JOIN vn.supplier su ON su.id = t.companyFk
|
||||||
JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk
|
JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk
|
||||||
AND ata.companyFk = t.companyFk
|
AND ata.companyFk = t.companyFk
|
||||||
JOIN itemTaxCountry itc ON itc.itemFk = i.id
|
JOIN vn.itemTaxCountry itc ON itc.itemFk = s.itemFk
|
||||||
AND itc.countryFk = su.countryFk
|
AND itc.countryFk = su.countryFk
|
||||||
JOIN bookingPlanner bp ON bp.countryFk = su.countryFk
|
HAVING total
|
||||||
AND bp.taxAreaFk = ata.areaFk
|
)
|
||||||
AND bp.taxClassFk = itc.taxClassFk
|
SELECT s.ticketFk,
|
||||||
JOIN pgc ON pgc.code = bp.pgcFk
|
bp.pgcFk,
|
||||||
JOIN taxClass tc ON tc.id = bp.taxClassFk
|
SUM(s.total) taxableBase,
|
||||||
GROUP BY tmpTicket.ticketFk, pgc.code, pgc.rate
|
pgc.rate,
|
||||||
HAVING taxableBase
|
tc.code,
|
||||||
) t3
|
bp.priority
|
||||||
|
FROM sales s
|
||||||
|
JOIN vn.bookingPlanner bp ON bp.countryFk = s.countryFk
|
||||||
|
AND bp.taxAreaFk = s.areaFk
|
||||||
|
AND bp.taxClassFk = s.taxClassFk
|
||||||
|
JOIN vn.pgc ON pgc.code = bp.pgcFk
|
||||||
|
JOIN vn.taxClass tc ON tc.id = bp.taxClassFk
|
||||||
|
GROUP BY s.ticketFk, pgc.code, pgc.rate
|
||||||
|
HAVING taxableBase
|
||||||
ORDER BY priority;
|
ORDER BY priority;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax
|
||||||
|
|
|
@ -3,10 +3,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterI
|
||||||
AFTER INSERT ON `itemShelvingSale`
|
AFTER INSERT ON `itemShelvingSale`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
UPDATE sale s
|
UPDATE sale s
|
||||||
JOIN operator o ON o.workerFk = account.myUser_getId()
|
JOIN operator o ON o.workerFk = account.myUser_getId()
|
||||||
SET s.isPicked = IF(o.isOnReservationMode, s.isPicked, TRUE)
|
JOIN sector se ON se.id = o.sectorFk
|
||||||
WHERE id = NEW.saleFk;
|
SET s.isPicked = IF(IFNULL(se.isOnReservationMode, o.isOnReservationMode), s.isPicked, TRUE)
|
||||||
|
WHERE s.id = NEW.saleFk;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -22,7 +22,6 @@ AS SELECT `c`.`id` AS `id_cliente`,
|
||||||
`c`.`credit` AS `credito`,
|
`c`.`credit` AS `credito`,
|
||||||
`c`.`countryFk` AS `Id_Pais`,
|
`c`.`countryFk` AS `Id_Pais`,
|
||||||
`c`.`isActive` AS `activo`,
|
`c`.`isActive` AS `activo`,
|
||||||
`c`.`gestdocFk` AS `gestdoc_id`,
|
|
||||||
`c`.`quality` AS `calidad`,
|
`c`.`quality` AS `calidad`,
|
||||||
`c`.`payMethodFk` AS `pay_met_id`,
|
`c`.`payMethodFk` AS `pay_met_id`,
|
||||||
`c`.`created` AS `created`,
|
`c`.`created` AS `created`,
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
ALTER TABLE `vn`.`operator`
|
||||||
|
ADD COLUMN `machineFk` int(11) DEFAULT NULL,
|
||||||
|
ADD CONSTRAINT `operator_machine_FK` FOREIGN KEY (`machineFk`) REFERENCES `vn`.`machine` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('Machine','*','*','ALLOW','ROLE','productionBoss');
|
|
@ -0,0 +1,4 @@
|
||||||
|
ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS username varchar(100) NULL;
|
||||||
|
ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS password varchar(100) NULL;
|
||||||
|
ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS token text NULL;
|
||||||
|
ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS expired int(11) NULL;
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE vn.client CHANGE gestdocFk gestdocFk__ int(11) DEFAULT NULL NULL COMMENT '@deprecated 2024-10-17';
|
|
@ -240,5 +240,6 @@
|
||||||
"There is already a tray with the same height": "There is already a tray with the same height",
|
"There is already a tray with the same height": "There is already a tray with the same height",
|
||||||
"The height must be greater than 50cm": "The height must be greater than 50cm",
|
"The height must be greater than 50cm": "The height must be greater than 50cm",
|
||||||
"The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm",
|
"The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm",
|
||||||
"The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line"
|
"The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line",
|
||||||
|
"There are tickets for this area, delete them first": "There are tickets for this area, delete them first"
|
||||||
}
|
}
|
||||||
|
|
|
@ -382,5 +382,6 @@
|
||||||
"This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha",
|
"This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha",
|
||||||
"No valid travel thermograph found": "No se encontró un termógrafo válido",
|
"No valid travel thermograph found": "No se encontró un termógrafo válido",
|
||||||
"The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea",
|
"The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea",
|
||||||
"type cannot be blank": "Se debe rellenar el tipo"
|
"type cannot be blank": "Se debe rellenar el tipo",
|
||||||
|
"There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero"
|
||||||
}
|
}
|
|
@ -48,13 +48,13 @@ module.exports = Self => {
|
||||||
let stmt;
|
let stmt;
|
||||||
stmts.push(new ParameterizedSQL(
|
stmts.push(new ParameterizedSQL(
|
||||||
`CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
`CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||||
(KEY (ticketFk))
|
(INDEX (ticketFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT id ticketFk
|
SELECT id ticketFk
|
||||||
FROM ticket t
|
FROM ticket
|
||||||
WHERE shipped BETWEEN ? AND util.dayEnd(?)
|
WHERE shipped BETWEEN ? AND util.dayEnd(?)
|
||||||
AND refFk IS NULL`, [args.from, args.to]));
|
AND refFk IS NULL`, [args.from, args.to]));
|
||||||
stmts.push(`CALL vn.ticket_getTax(NULL)`);
|
stmts.push(`CALL ticket_getTax(NULL)`);
|
||||||
stmts.push(new ParameterizedSQL(
|
stmts.push(new ParameterizedSQL(
|
||||||
`CREATE OR REPLACE TEMPORARY TABLE tmp.filter
|
`CREATE OR REPLACE TEMPORARY TABLE tmp.filter
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
|
@ -71,12 +71,12 @@ module.exports = Self => {
|
||||||
c.isTaxDataChecked,
|
c.isTaxDataChecked,
|
||||||
w.id comercialId,
|
w.id comercialId,
|
||||||
u.name workerName
|
u.name workerName
|
||||||
FROM vn.ticket t
|
FROM ticket t
|
||||||
JOIN vn.company co ON co.id = t.companyFk
|
JOIN company co ON co.id = t.companyFk
|
||||||
JOIN vn.sale s ON s.ticketFk = t.id
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
JOIN vn.client c ON c.id = t.clientFk
|
JOIN client c ON c.id = t.clientFk
|
||||||
JOIN vn.country cou ON cou.id = c.countryFk
|
JOIN country cou ON cou.id = c.countryFk
|
||||||
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
LEFT JOIN worker w ON w.id = c.salesPersonFk
|
||||||
JOIN account.user u ON u.id = w.id
|
JOIN account.user u ON u.id = w.id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT ticketFk, taxableBase
|
SELECT ticketFk, taxableBase
|
||||||
|
|
|
@ -228,52 +228,57 @@ module.exports = Self => {
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.filter
|
CREATE OR REPLACE TEMPORARY TABLE tmp.filter
|
||||||
(INDEX (id))
|
(INDEX (id))
|
||||||
ENGINE = MEMORY
|
ENGINE = InnoDB
|
||||||
SELECT t.id,
|
SELECT t.id,
|
||||||
t.shipped,
|
t.shipped,
|
||||||
CAST(DATE(t.shipped) AS CHAR) shippedDate,
|
CAST(DATE(t.shipped) AS CHAR) shippedDate,
|
||||||
HOUR(t.shipped) shippedHour,
|
HOUR(t.shipped) shippedHour,
|
||||||
t.nickname,
|
t.nickname,
|
||||||
t.refFk,
|
t.refFk,
|
||||||
t.routeFk,
|
t.routeFk,
|
||||||
t.warehouseFk,
|
t.warehouseFk,
|
||||||
t.clientFk,
|
t.clientFk,
|
||||||
t.totalWithoutVat,
|
t.totalWithoutVat,
|
||||||
t.totalWithVat,
|
t.totalWithVat,
|
||||||
io.id invoiceOutId,
|
io.id invoiceOutId,
|
||||||
a.provinceFk,
|
a.provinceFk,
|
||||||
p.name province,
|
p.name province,
|
||||||
w.name warehouse,
|
w.name warehouse,
|
||||||
am.name agencyMode,
|
am.name agencyMode,
|
||||||
am.id agencyModeFk,
|
am.id agencyModeFk,
|
||||||
st.name state,
|
st.name state,
|
||||||
st.classColor,
|
st.classColor,
|
||||||
wk.lastName salesPerson,
|
wk.lastName salesPerson,
|
||||||
ts.stateFk stateFk,
|
ts.stateFk stateFk,
|
||||||
ts.alertLevel alertLevel,
|
ts.alertLevel alertLevel,
|
||||||
ts.code alertLevelCode,
|
ts.code alertLevelCode,
|
||||||
u.name userName,
|
u.name userName,
|
||||||
c.salesPersonFk,
|
c.salesPersonFk,
|
||||||
z.hour zoneLanding,
|
z.hour zoneLanding,
|
||||||
HOUR(z.hour) zoneHour,
|
HOUR(z.hour) zoneHour,
|
||||||
MINUTE(z.hour) zoneMinute,
|
MINUTE(z.hour) zoneMinute,
|
||||||
z.name zoneName,
|
z.name zoneName,
|
||||||
z.id zoneFk,
|
z.id zoneFk,
|
||||||
CAST(z.hour AS CHAR) hour,
|
CAST(z.hour AS CHAR) hour,
|
||||||
a.nickname addressNickname
|
a.nickname addressNickname,
|
||||||
FROM ticket t
|
(SELECT GROUP_CONCAT(DISTINCT i2.itemPackingTypeFk ORDER BY i2.itemPackingTypeFk SEPARATOR ',')
|
||||||
LEFT JOIN invoiceOut io ON t.refFk = io.ref
|
FROM sale s2
|
||||||
LEFT JOIN zone z ON z.id = t.zoneFk
|
JOIN item i2 ON i2.id = s2.itemFk
|
||||||
LEFT JOIN address a ON a.id = t.addressFk
|
WHERE s2.ticketFk = t.id
|
||||||
LEFT JOIN province p ON p.id = a.provinceFk
|
) AS packing
|
||||||
LEFT JOIN warehouse w ON w.id = t.warehouseFk
|
FROM ticket t
|
||||||
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
|
LEFT JOIN invoiceOut io ON t.refFk = io.ref
|
||||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
LEFT JOIN zone z ON z.id = t.zoneFk
|
||||||
LEFT JOIN state st ON st.id = ts.stateFk
|
LEFT JOIN address a ON a.id = t.addressFk
|
||||||
LEFT JOIN client c ON c.id = t.clientFk
|
LEFT JOIN province p ON p.id = a.provinceFk
|
||||||
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
|
LEFT JOIN warehouse w ON w.id = t.warehouseFk
|
||||||
LEFT JOIN account.user u ON u.id = wk.id
|
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||||
LEFT JOIN route r ON r.id = t.routeFk
|
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||||
|
LEFT JOIN state st ON st.id = ts.stateFk
|
||||||
|
LEFT JOIN client c ON c.id = t.clientFk
|
||||||
|
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
|
||||||
|
LEFT JOIN account.user u ON u.id = wk.id
|
||||||
|
LEFT JOIN route r ON r.id = t.routeFk
|
||||||
`);
|
`);
|
||||||
|
|
||||||
if (args.orderFk) {
|
if (args.orderFk) {
|
||||||
|
@ -292,6 +297,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt.merge(conn.makeWhere(filter.where));
|
stmt.merge(conn.makeWhere(filter.where));
|
||||||
|
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`
|
||||||
|
|
|
@ -24,13 +24,28 @@
|
||||||
"warehouseFk": {
|
"warehouseFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"sectorFk": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
"labelerFk": {
|
"labelerFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"isOnReservationMode": {
|
"isOnReservationMode": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"required": true
|
"required": true
|
||||||
}
|
},
|
||||||
|
"machineFk": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"linesLimit": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"volumeLimit": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"sizeLimit": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"sector": {
|
"sector": {
|
||||||
|
@ -53,6 +68,11 @@
|
||||||
"model": "ItemPackingType",
|
"model": "ItemPackingType",
|
||||||
"foreignKey": "itemPackingTypeFk",
|
"foreignKey": "itemPackingTypeFk",
|
||||||
"primaryKey": "code"
|
"primaryKey": "code"
|
||||||
}
|
},
|
||||||
|
"machine": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Machine",
|
||||||
|
"foreignKey": "machineFk"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('deleteZone', {
|
Self.remoteMethodCtx('deleteZone', {
|
||||||
description: 'Delete a zone',
|
description: 'Delete a zone',
|
||||||
|
@ -49,26 +50,12 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const promises = [];
|
|
||||||
|
|
||||||
const ticketList = await models.Ticket.find(filter, myOptions);
|
const ticketList = await models.Ticket.find(filter, myOptions);
|
||||||
const fixingState = await models.State.findOne({where: {code: 'FIXING'}}, myOptions);
|
|
||||||
const worker = await models.Worker.findOne({
|
|
||||||
where: {id: userId}
|
|
||||||
}, myOptions);
|
|
||||||
|
|
||||||
await models.Ticket.rawSql('UPDATE ticket SET zoneFk = NULL WHERE zoneFk = ?', [id], myOptions);
|
if (ticketList.length > 0)
|
||||||
|
throw new UserError('There are tickets for this area, delete them first');
|
||||||
|
|
||||||
for (ticket of ticketList) {
|
|
||||||
if (ticket.ticketState().alertLevel == 0) {
|
|
||||||
promises.push(models.Ticket.state(ctx, {
|
|
||||||
ticketFk: ticket.id,
|
|
||||||
stateFk: fixingState.id,
|
|
||||||
userFk: worker.id
|
|
||||||
}, myOptions));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await Promise.all(promises);
|
|
||||||
await models.Zone.destroyById(id, myOptions);
|
await models.Zone.destroyById(id, myOptions);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
|
@ -8,9 +8,9 @@ describe('zone deletezone()', () => {
|
||||||
__: value => value
|
__: value => value
|
||||||
};
|
};
|
||||||
const ctx = {req: activeCtx};
|
const ctx = {req: activeCtx};
|
||||||
const zoneId = 9;
|
const zoneId = 4;
|
||||||
|
const zoneId2 = 3;
|
||||||
let ticketIDs;
|
let ticketIDs;
|
||||||
let originalTicketStates;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
@ -35,18 +35,8 @@ describe('zone deletezone()', () => {
|
||||||
await models.Zone.deleteZone(ctx, zoneId, options);
|
await models.Zone.deleteZone(ctx, zoneId, options);
|
||||||
|
|
||||||
const updatedZone = await models.Zone.findById(zoneId, null, options);
|
const updatedZone = await models.Zone.findById(zoneId, null, options);
|
||||||
const anUpdatedTicket = await models.Ticket.findById(ticketIDs[0], null, options);
|
|
||||||
|
|
||||||
const updatedTicketStates = await models.TicketState.find({
|
|
||||||
where: {
|
|
||||||
ticketFk: {inq: ticketIDs},
|
|
||||||
code: 'FIXING'
|
|
||||||
}
|
|
||||||
}, options);
|
|
||||||
|
|
||||||
expect(updatedZone).toBeNull();
|
expect(updatedZone).toBeNull();
|
||||||
expect(anUpdatedTicket.zoneFk).toBeNull();
|
|
||||||
expect(updatedTicketStates.length).toBeGreaterThan(originalTicketStates.length);
|
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -54,4 +44,20 @@ describe('zone deletezone()', () => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not delete the zone if it has tickets', async() => {
|
||||||
|
const tx = await models.Zone.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
await models.Zone.deleteZone(ctx, zoneId2, options);
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e.message;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error).toEqual('There are tickets for this area, delete them first');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
<th width="5%">{{$t('reference')}}</th>
|
<th width="5%">{{$t('reference')}}</th>
|
||||||
<th class="number">{{$t('quantity')}}</th>
|
<th class="number">{{$t('quantity')}}</th>
|
||||||
<th width="50%">{{$t('concept')}}</th>
|
<th width="50%">{{$t('concept')}}</th>
|
||||||
|
<th width="50%">{{$t('producer')}}</th>
|
||||||
<th class="number" v-if="showPrices">{{$t('price')}}</th>
|
<th class="number" v-if="showPrices">{{$t('price')}}</th>
|
||||||
<th class="centered" width="5%" v-if="showPrices">{{$t('discount')}}</th>
|
<th class="centered" width="5%" v-if="showPrices">{{$t('discount')}}</th>
|
||||||
<th class="centered" v-if="showPrices">{{$t('vat')}}</th>
|
<th class="centered" v-if="showPrices">{{$t('vat')}}</th>
|
||||||
|
@ -69,6 +70,7 @@
|
||||||
<td width="5%">{{sale.itemFk}}</td>
|
<td width="5%">{{sale.itemFk}}</td>
|
||||||
<td class="number">{{sale.quantity}}</td>
|
<td class="number">{{sale.quantity}}</td>
|
||||||
<td width="50%">{{sale.concept}}</td>
|
<td width="50%">{{sale.concept}}</td>
|
||||||
|
<td width="5%" class="font light-gray" v-if="sale.subName">{{sale.subName}}</td>
|
||||||
<td class="number" v-if="showPrices">{{sale.price | currency('EUR', $i18n.locale)}}</td>
|
<td class="number" v-if="showPrices">{{sale.price | currency('EUR', $i18n.locale)}}</td>
|
||||||
<td class="centered" width="5%" v-if="showPrices">{{(sale.discount / 100) | percentage}}</td>
|
<td class="centered" width="5%" v-if="showPrices">{{(sale.discount / 100) | percentage}}</td>
|
||||||
<td class="centered" v-if="showPrices">{{sale.vatType}}</td>
|
<td class="centered" v-if="showPrices">{{sale.vatType}}</td>
|
||||||
|
@ -81,7 +83,6 @@
|
||||||
<span v-if="sale.value5"> <strong>{{sale.tag5}}</strong> {{sale.value5}} </span>
|
<span v-if="sale.value5"> <strong>{{sale.tag5}}</strong> {{sale.value5}} </span>
|
||||||
<span v-if="sale.value6"> <strong>{{sale.tag6}}</strong> {{sale.value6}} </span>
|
<span v-if="sale.value6"> <strong>{{sale.tag6}}</strong> {{sale.value6}} </span>
|
||||||
<span v-if="sale.value7"> <strong>{{sale.tag7}}</strong> {{sale.value7}} </span>
|
<span v-if="sale.value7"> <strong>{{sale.tag7}}</strong> {{sale.value7}} </span>
|
||||||
<span v-if="sale.subName"> <strong>{{$t('producer')}}</strong> {{ sale.subName }}</span>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in New Issue