6745-2404_testToMaster #1950

Merged
alexm merged 191 commits from 6745-2404_testToMaster into master 2024-01-25 07:39:13 +00:00
30 changed files with 219 additions and 154 deletions
Showing only changes of commit 1cd9b85ddf - Show all commits

View File

@ -1 +0,0 @@
DELETE FROM `account`.`signInLog` where owner <> FALSE

View File

@ -0,0 +1,2 @@
DELETE FROM `account`.`signInLog` where owner <> FALSE;

View File

View File

@ -0,0 +1,14 @@
DELETE FROM salix.ACL
WHERE model = 'WorkerTimeControl'
AND property IN ('*','addTime');
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
VALUES
('WorkerTimeControl', 'addTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('WorkerTimeControl', 'deleteTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('WorkerTimeControl', 'updateTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('WorkerTimeControl', 'sendMail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('WorkerTimeControl', 'updateWorkerTimeControlMail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('WorkerTimeControl', 'weeklyHourRecordEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('WorkerTimeControl', 'getMailStates', 'READ', 'ALLOW', 'ROLE', 'employee'),
('WorkerTimeControl', 'resendWeeklyHourEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee');

View File

@ -0,0 +1 @@
ALTER TABLE `vn`.`item` DROP COLUMN stars;

View File

@ -929,25 +929,25 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`)
('VT', 'Sales'); ('VT', 'Sales');
INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`, INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`,
`comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`, `weightByPiece`) `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`, `weightByPiece`)
VALUES VALUES
(1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'EMB', 0, NULL, 'V', 0, 15,3), (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 15,3),
(2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0, 10,2), (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 10,2),
(3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, 5,5), (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5,5),
(4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL), (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
(5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL), (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
(6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL), (6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
(7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL), (7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
(8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, NULL,NULL), (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
(9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL,NULL), (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL,NULL),
(10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL), (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
(11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL), (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
(12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL), (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
(13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1, NULL,NULL), (13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL,NULL),
(14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL,NULL), (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL,NULL),
(15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL), (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
(16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL), (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
(71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL); (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL);
-- Update the taxClass after insert of the items -- Update the taxClass after insert of the items
UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2 UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2

View File

@ -735,7 +735,7 @@ export default {
}, },
createStateView: { createStateView: {
state: 'vn-autocomplete[ng-model="$ctrl.stateFk"]', state: 'vn-autocomplete[ng-model="$ctrl.stateFk"]',
worker: 'vn-worker-autocomplete[ng-model="$ctrl.workerFk"]', worker: 'vn-worker-autocomplete[ng-model="$ctrl.userFk"]',
saveStateButton: `button[type=submit]` saveStateButton: `button[type=submit]`
}, },
claimsIndex: { claimsIndex: {

View File

@ -202,5 +202,6 @@
"keepPrice": "keepPrice", "keepPrice": "keepPrice",
"Cannot past travels with entries": "Cannot past travels with entries", "Cannot past travels with entries": "Cannot past travels with entries",
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}", "It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}",
"Incorrect pin": "Incorrect pin." "Incorrect pin": "Incorrect pin.",
} "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified"
}

View File

@ -50,7 +50,7 @@ module.exports = Self => {
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.item'); stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.item');
stmt = new ParameterizedSQL( stmt = new ParameterizedSQL(
`CREATE TEMPORARY TABLE tmp.item `CREATE TEMPORARY TABLE tmp.item
(PRIMARY KEY (itemFk)) ENGINE = MEMORY (PRIMARY KEY (itemFk)) ENGINE = MEMORY
SELECT DISTINCT SELECT DISTINCT
i.id AS itemFk, i.id AS itemFk,
@ -112,7 +112,6 @@ module.exports = Self => {
i.value7, i.value7,
i.tag8, i.tag8,
i.value8, i.value8,
i.stars,
tci.price, tci.price,
tci.available, tci.available,
w.lastName, w.lastName,
@ -131,7 +130,7 @@ module.exports = Self => {
if (orderBy.isTag) { if (orderBy.isTag) {
stmt.merge({ stmt.merge({
sql: ` sql: `
LEFT JOIN vn.itemTag itg LEFT JOIN vn.itemTag itg
LEFT JOIN vn.tag t ON t.id = itg.tagFk LEFT JOIN vn.tag t ON t.id = itg.tagFk
ON itg.itemFk = tci.itemFk AND itg.tagFk = ?`, ON itg.itemFk = tci.itemFk AND itg.tagFk = ?`,
params: [orderBy.field], params: [orderBy.field],
@ -140,7 +139,7 @@ module.exports = Self => {
const way = orderBy.way == 'DESC' ? 'DESC' : 'ASC'; const way = orderBy.way == 'DESC' ? 'DESC' : 'ASC';
const tag = await Self.app.models.Tag.findById(orderBy.field, null, myOptions); const tag = await Self.app.models.Tag.findById(orderBy.field, null, myOptions);
const orderSql = ` const orderSql = `
ORDER BY ORDER BY
itg.value IS NULL, itg.value IS NULL,
${tag.isQuantitative ? 'CAST(itg.value AS SIGNED)' : 'itg.value'} ${tag.isQuantitative ? 'CAST(itg.value AS SIGNED)' : 'itg.value'}
${way}`; ${way}`;
@ -158,7 +157,7 @@ module.exports = Self => {
// Apply item prices // Apply item prices
const pricesIndex = stmts.push( const pricesIndex = stmts.push(
`SELECT `SELECT
tcp.itemFk, tcp.itemFk,
tcp.grouping, tcp.grouping,
tcp.price, tcp.price,

View File

@ -37,11 +37,6 @@
value="{{::item.value7}}"> value="{{::item.value7}}">
</vn-label-value> </vn-label-value>
</div> </div>
<vn-horizontal>
<vn-one>
<vn-rating ng-if="::item.stars"
ng-model="::item.stars"/>
</vn-one>
<vn-horizontal <vn-horizontal
class="text-right text-caption alert vn-mr-xs" class="text-right text-caption alert vn-mr-xs"
ng-if="::item.minQuantity"> ng-if="::item.minQuantity">
@ -54,7 +49,6 @@
</vn-one> </vn-one>
{{::item.minQuantity}} {{::item.minQuantity}}
</vn-horizontal> </vn-horizontal>
</vn-horizontal>
<div class="footer"> <div class="footer">
<div class="price"> <div class="price">
<vn-one> <vn-one>

View File

@ -16,19 +16,4 @@ columns:
vehicleFk: vehicle vehicleFk: vehicle
agencyModeFk: agency agencyModeFk: agency
routeFk: route routeFk: route
zoneFk: zone zoneFk: zone
name: name
beachFk: beach
ticketPacked: tickets packed
ticketFree: tickets free
ticketProduction: tickets production
packages: packages
note: note
dated: dated
dockFk: dock
priority: priority
etd: etd
expeditionTruckFk: truck
m3boxes: m3 boxes
bufferFk: buffer
isPickingAllowed: is picking allowed

View File

@ -16,19 +16,4 @@ columns:
vehicleFk: vehículo vehicleFk: vehículo
agencyModeFk: agencia agencyModeFk: agencia
routeFk: ruta routeFk: ruta
zoneFk: zona zoneFk: zona
name: nombre
beachFk: playa
ticketPacked: tickets encajados
ticketFree: tickets libres
ticketProduction: tickets producción
packages: paquetes
note: nota
dated: fecha
dockFk: muelle
priority: prioridad
etd: etd
expeditionTruckFk: camión
m3boxes: m3 cajas
bufferFk: buffer
isPickingAllowed: está permitido recoger

View File

@ -0,0 +1,19 @@
name: routesMonitor
columns:
routeFk: route
name: name
beachFk: beach
ticketPacked: tickets packed
ticketFree: tickets free
ticketProduction: tickets production
packages: packages
note: note
dated: dated
dockFk: dock
m3: m3
priority: priority
etd: etd
expeditionTruckFk: truck
m3boxes: m3 boxes
bufferFk: buffer
isPickingAllowed: is picking allowed

View File

@ -0,0 +1,19 @@
name: monitorRutas
columns:
routeFk: ruta
name: nombre
beachFk: playa
ticketPacked: tickets encajados
ticketFree: tickets libres
ticketProduction: tickets producción
packages: paquetes
note: nota
dated: fecha
dockFk: muelle
m3: m3
priority: prioridad
etd: etd
expeditionTruckFk: camión
m3boxes: m3 cajas
bufferFk: buffer
isPickingAllowed: está permitido recoger

View File

@ -22,5 +22,8 @@
}, },
"Vehicle": { "Vehicle": {
"dataSource": "vn" "dataSource": "vn"
},
"RoutesMonitor": {
"dataSource": "vn"
} }
} }

View File

@ -0,0 +1,61 @@
{
"name": "RoutesMonitor",
"base": "Loggable",
"options": {
"mysql": {
"table": "routesMonitor"
}
},
"properties": {
"routeFk": {
"type": "number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string"
},
"beachFk": {
"type": "number"
},
"ticketPacked": {
"type": "number"
},
"ticketFree": {
"type": "number"
},
"ticketProduction": {
"type": "number"
},
"packages": {
"type": "number"
},
"note": {
"type": "string"
},
"dated": {
"type": "date"
},
"dockFk": {
"type": "number"
},
"m3": {
"type": "number"
},
"priority": {
"type": "number"
},
"expeditionTruckFk": {
"type": "number"
},
"m3boxes": {
"type": "number"
},
"bufferFk": {
"type": "number"
},
"isPickingAllowed": {
"type": "boolean"
}
}
}

View File

@ -21,7 +21,7 @@
</vn-autocomplete> </vn-autocomplete>
<vn-worker-autocomplete <vn-worker-autocomplete
vn-one vn-one
ng-model="$ctrl.workerFk"> ng-model="$ctrl.userFk">
</vn-worker-autocomplete> </vn-worker-autocomplete>
</vn-horizontal> </vn-horizontal>
</vn-card> </vn-card>

View File

@ -17,19 +17,19 @@ class Controller extends Section {
set stateFk(value) { set stateFk(value) {
this.params.stateFk = value; this.params.stateFk = value;
this.isPickerDesignedState = this.getIsPickerDesignedState(value); this.isPickerDesignedState = this.getIsPickerDesignedState(value);
this.workerFk = window.localStorage.currentUserWorkerId; this.userFk = window.localStorage.currentUserWorkerId;
} }
get stateFk() { get stateFk() {
return this.params.stateFk; return this.params.stateFk;
} }
set workerFk(value) { set userFk(value) {
this.params.workerFk = value; this.params.userFk = value;
} }
get workerFk() { get userFk() {
return this.params.workerFk; return this.params.userFk;
} }
getPickerDesignedState() { getPickerDesignedState() {

View File

@ -29,11 +29,11 @@ describe('Ticket', () => {
}); });
}); });
describe('workerFk setter', () => { describe('userFk setter', () => {
it('should set params.workerFk', () => { it('should set params.userFk', () => {
controller.workerFk = 1; controller.userFk = 1;
expect(controller.params.workerFk).toEqual(1); expect(controller.params.userFk).toEqual(1);
}); });
}); });

View File

@ -3,7 +3,7 @@ const UserError = require('vn-loopback/util/user-error');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('deleteTimeEntry', { Self.remoteMethodCtx('deleteTimeEntry', {
description: 'Deletes a manual time entry for a worker if the user role is above the worker', description: 'Deletes a manual time entry for a worker if the user role is above the worker',
accessType: 'READ', accessType: 'WRITE',
accepts: [{ accepts: [{
arg: 'id', arg: 'id',
type: 'number', type: 'number',

View File

@ -7,7 +7,7 @@ module.exports = {
this.invoice = await this.findOneFromDef('invoice', [this.reference]); this.invoice = await this.findOneFromDef('invoice', [this.reference]);
this.checkMainEntity(this.invoice); this.checkMainEntity(this.invoice);
this.client = await this.findOneFromDef('client', [this.reference]); this.client = await this.findOneFromDef('client', [this.reference]);
this.incoterms = await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference]); this.incoterms = await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference, this.reference]);
}, },
props: { props: {
reference: { reference: {

View File

@ -1,13 +1,12 @@
SELECT SELECT c.id,
c.id, c.socialName,
c.socialName, c.street postalAddress,
c.street AS postalAddress, IF (ios.taxAreaFk IS NOT NULL, CONCAT(cty.code, c.fi), c.fi) fi,
IF (ios.taxAreaFk IS NOT NULL, CONCAT(cty.code, c.fi), c.fi) fi, CONCAT(c.postcode, ' - ', c.city) postcodeCity
CONCAT(c.postcode, ' - ', c.city) postcodeCity FROM vn.invoiceOut io
FROM vn.invoiceOut io JOIN vn.client c ON c.id = io.clientFk
JOIN vn.client c ON c.id = io.clientFk JOIN vn.country cty ON cty.id = c.countryFk
JOIN vn.country cty ON cty.id = c.countryFk LEFT JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
LEFT JOIN vn.invoiceOutSerial ios ON ios.code = io.serial AND ios.taxAreaFk = 'CEE'
AND ios.taxAreaFk = 'CEE' LEFT JOIN ticket t ON t.refFk = io.ref
LEFT JOIN ticket t ON t.refFk = io.ref WHERE t.refFk = ?
WHERE t.refFk = ?

View File

@ -1,38 +1,14 @@
SELECT io.issued, SELECT pack.packages,
c.socialName,
c.street postalAddress,
c.fi,
io.clientFk,
c.postcode,
c.city,
io.companyFk,
io.ref,
tc.code,
s.concept,
s.quantity,
s.price,
s.discount,
s.ticketFk,
t.shipped,
t.refFk,
a.nickname,
s.itemFk,
s.id saleFk,
pm.name AS pmname,
sa.iban,
c.phone,
MAX(t.packages) packages,
a.incotermsFk, a.incotermsFk,
ic.name incotermsName , ic.name incotermsName,
t.weight, t.weight,
t.observations,
ca.fiscalName customsAgentName, ca.fiscalName customsAgentName,
ca.street customsAgentStreet, ca.street customsAgentStreet,
ca.nif customsAgentNif, ca.nif customsAgentNif,
ca.phone customsAgentPhone, ca.phone customsAgentPhone,
ca.email customsAgentEmail, ca.email customsAgentEmail,
CAST(sub2.volume AS DECIMAL (10,2)) volume, CAST(vol.volume AS DECIMAL (10,2)) volume,
sub3.intrastat intr.intrastat
FROM vn.invoiceOut io FROM vn.invoiceOut io
JOIN vn.supplier su ON su.id = io.companyFk JOIN vn.supplier su ON su.id = io.companyFk
JOIN vn.client c ON c.id = io.clientFk JOIN vn.client c ON c.id = io.clientFk
@ -42,26 +18,35 @@ SELECT io.issued,
LEFT JOIN vn.incoterms ic ON ic.code = a.incotermsFk LEFT JOIN vn.incoterms ic ON ic.code = a.incotermsFk
LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk
JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.sale s ON s.ticketFk = t.id
JOIN (SELECT SUM(volume) volume JOIN (
FROM vn.invoiceOut io SELECT SUM(volume) volume, COUNT(*) packages
JOIN vn.ticket t ON t.refFk = io.ref FROM vn.invoiceOut io
JOIN vn.saleVolume sv ON sv.ticketFk = t.id JOIN vn.ticket t ON t.refFk = io.ref
WHERE t.refFk = ? JOIN vn.saleVolume sv ON sv.ticketFk = t.id
) sub2 ON TRUE WHERE t.refFk = ?
JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk AND itc.itemFk = s.itemFk ) vol
JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk
AND itc.itemFk = s.itemFk
JOIN vn.taxClass tc ON tc.id = itc.taxClassFk JOIN vn.taxClass tc ON tc.id = itc.taxClassFk
JOIN vn.invoiceOutSerial ios ON ios.code = io.serial AND ios.taxAreaFk = 'WORLD' JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
AND ios.taxAreaFk = 'WORLD'
JOIN vn.country cty ON cty.id = c.countryFk JOIN vn.country cty ON cty.id = c.countryFk
JOIN vn.payMethod pm ON pm.id = c .payMethodFk JOIN vn.payMethod pm ON pm.id = c .payMethodFk
JOIN vn.company co ON co.id=io.companyFk JOIN vn.company co ON co.id=io.companyFk
JOIN vn.supplierAccount sa ON sa.id=co.supplierAccountFk JOIN vn.supplierAccount sa ON sa.id=co.supplierAccountFk
LEFT JOIN (SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR '. ' ) as intrastat JOIN (
FROM vn.ticket t SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR '. ' ) intrastat
JOIN vn.invoiceOut io ON io.ref = t.refFk FROM vn.ticket t
JOIN vn.sale s ON t.id = s.ticketFk JOIN vn.invoiceOut io ON io.ref = t.refFk
JOIN vn.item i ON i.id = s.itemFk JOIN vn.sale s ON t.id = s.ticketFk
JOIN vn.intrastat ir ON ir.id = i.intrastatFk JOIN vn.item i ON i.id = s.itemFk
WHERE t.refFk = ? JOIN vn.intrastat ir ON ir.id = i.intrastatFk
)sub3 ON TRUE WHERE t.refFk = ?
WHERE t.refFk = ? ) intr
JOIN (
SELECT SUM(packages) packages
FROM ticket
WHERE refFk = ?
) pack
WHERE t.refFk = ?
LIMIT 1

View File

@ -1,18 +1,17 @@
SELECT SELECT io.id,
io.id, io.issued,
io.issued, io.clientFk,
io.clientFk, io.companyFk,
io.companyFk, io.ref,
io.ref, pm.code payMethodCode,
pm.code AS payMethodCode, cny.code companyCode,
cny.code companyCode, sa.iban,
sa.iban, ios.footNotes
ios.footNotes FROM invoiceOut io
FROM invoiceOut io JOIN client c ON c.id = io.clientFk
JOIN client c ON c.id = io.clientFk JOIN payMethod pm ON pm.id = c.payMethodFk
JOIN payMethod pm ON pm.id = c.payMethodFk JOIN company cny ON cny.id = io.companyFk
JOIN company cny ON cny.id = io.companyFk JOIN supplierAccount sa ON sa.id = cny.supplierAccountFk
JOIN supplierAccount sa ON sa.id = cny.supplierAccountFk LEFT JOIN invoiceOutSerial ios ON ios.code = io.serial
LEFT JOIN invoiceOutSerial ios ON ios.code = io.serial LEFT JOIN ticket t ON t.refFk = io.ref
LEFT JOIN ticket t ON t.refFk = io.ref WHERE t.refFk = ?
WHERE t.refFk = ?