@@ -112,18 +110,32 @@
-
-
+
+ {{price.rate2 | currency: 'EUR':2}}
+
+
+
+
+
|
-
-
+
+ {{price.rate3 | currency: 'EUR':2}}
+
+
+
+
+
|
{
+ const rate2 = res.data.rate2;
+ if (rate2) {
+ price.rate2 = rate2;
+ this.upsertPrice(price);
+ }
+ });
+ }
}
ngModule.vnComponent('vnFixedPrice', {
diff --git a/modules/item/front/fixed-price/index.spec.js b/modules/item/front/fixed-price/index.spec.js
index 94621e352..db9579444 100644
--- a/modules/item/front/fixed-price/index.spec.js
+++ b/modules/item/front/fixed-price/index.spec.js
@@ -85,5 +85,25 @@ describe('fixed price', () => {
expect(controller.$.model.remove).toHaveBeenCalled();
});
});
+
+ describe('recalculateRate2()', () => {
+ it(`should rate2 recalculate`, () => {
+ jest.spyOn(controller.vnApp, 'showSuccess');
+ const price = {
+ id: 1,
+ itemFk: 1,
+ rate2: 2,
+ rate3: 2
+ };
+ const response = {rate2: 1};
+ controller.recalculateRate2(price);
+
+ const query = `FixedPrices/getRate2?fixedPriceId=${price.id}&rate3=${price.rate3}`;
+ $httpBackend.expectGET(query).respond(response);
+ $httpBackend.flush();
+
+ expect(price.rate2).toEqual(response.rate2);
+ });
+ });
});
});
diff --git a/modules/item/front/fixed-price/locale/es.yml b/modules/item/front/fixed-price/locale/es.yml
index 3f400336d..6bdfcb678 100644
--- a/modules/item/front/fixed-price/locale/es.yml
+++ b/modules/item/front/fixed-price/locale/es.yml
@@ -3,5 +3,3 @@ Search prices by item ID or code: Buscar por ID de artículo o código
Search fixed prices: Buscar precios fijados
Add fixed price: Añadir precio fijado
This row will be removed: Esta linea se eliminará
-Price By Unit: Precio Por Unidad
-Price By Package: Precio Por Paquete
\ No newline at end of file
diff --git a/modules/item/front/locale/es.yml b/modules/item/front/locale/es.yml
index 88ab031e1..0fc014742 100644
--- a/modules/item/front/locale/es.yml
+++ b/modules/item/front/locale/es.yml
@@ -44,6 +44,7 @@ Weight/Piece: Peso/tallo
Search items by id, name or barcode: Buscar articulos por identificador, nombre o codigo de barras
SalesPerson: Comercial
Concept: Concepto
+Units/Box: Unidades/Caja
# Sections
Items: Artículos
@@ -61,4 +62,4 @@ Item diary: Registro de compra-venta
Last entries: Últimas entradas
Tags: Etiquetas
Waste breakdown: Desglose de mermas
-Waste breakdown by item: Desglose de mermas por artículo
\ No newline at end of file
+Waste breakdown by item: Desglose de mermas por artículo
diff --git a/modules/mdb/back/methods/mdbVersion/last.js b/modules/mdb/back/methods/mdbVersion/last.js
new file mode 100644
index 000000000..5f89f10fb
--- /dev/null
+++ b/modules/mdb/back/methods/mdbVersion/last.js
@@ -0,0 +1,46 @@
+const UserError = require('vn-loopback/util/user-error');
+
+module.exports = Self => {
+ Self.remoteMethodCtx('last', {
+ description: 'Gets the latest version of a access file',
+ accepts: [
+ {
+ arg: 'appName',
+ type: 'string',
+ required: true,
+ description: 'The app name'
+ }
+ ],
+ returns: {
+ type: 'number',
+ root: true
+ },
+ http: {
+ path: `/:appName/last`,
+ verb: 'GET'
+ }
+ });
+
+ Self.last = async(ctx, appName) => {
+ const models = Self.app.models;
+ const versions = await models.MdbVersion.find({
+ where: {app: appName},
+ fields: ['version']
+ });
+
+ if (!versions.length)
+ throw new UserError('App name does not exist');
+
+ let maxNumber = 0;
+ for (let mdb of versions) {
+ if (mdb.version > maxNumber)
+ maxNumber = mdb.version;
+ }
+
+ let response = {
+ version: maxNumber
+ };
+
+ return response;
+ };
+};
diff --git a/modules/mdb/back/methods/mdbVersion/upload.js b/modules/mdb/back/methods/mdbVersion/upload.js
index 5dfe5d3ef..1df4365a9 100644
--- a/modules/mdb/back/methods/mdbVersion/upload.js
+++ b/modules/mdb/back/methods/mdbVersion/upload.js
@@ -11,20 +11,22 @@ module.exports = Self => {
type: 'string',
required: true,
description: 'The app name'
- },
- {
- arg: 'newVersion',
+ }, {
+ arg: 'toVersion',
type: 'number',
required: true,
description: `The new version number`
- },
- {
+ }, {
arg: 'branch',
type: 'string',
required: true,
description: `The branch name`
- },
- {
+ }, {
+ arg: 'fromVersion',
+ type: 'string',
+ required: true,
+ description: `The old version number`
+ }, {
arg: 'unlock',
type: 'boolean',
required: false,
@@ -41,16 +43,13 @@ module.exports = Self => {
}
});
- Self.upload = async(ctx, appName, newVersion, branch, unlock, options) => {
+ Self.upload = async(ctx, appName, toVersion, branch, fromVersion, unlock, options) => {
const models = Self.app.models;
- const userId = ctx.req.accessToken.userId;
const myOptions = {};
const $t = ctx.req.__; // $translate
-
const TempContainer = models.TempContainer;
const AccessContainer = models.AccessContainer;
const fileOptions = {};
-
let tx;
if (typeof options == 'object')
@@ -63,14 +62,28 @@ module.exports = Self => {
let srcFile;
try {
+ const userId = ctx.req.accessToken.userId;
const mdbApp = await models.MdbApp.findById(appName, null, myOptions);
- if (mdbApp.locked && mdbApp.userFk != userId) {
+ if (mdbApp && mdbApp.locked && mdbApp.userFk != userId) {
throw new UserError($t('App locked', {
userId: mdbApp.userFk
}));
}
+ const existBranch = await models.MdbBranch.findOne({
+ where: {name: branch}
+ }, myOptions);
+
+ if (!existBranch)
+ throw new UserError('Not exist this branch');
+
+ let lastMethod = await Self.last(ctx, appName, myOptions);
+ lastMethod.version++;
+
+ if (lastMethod.version != toVersion)
+ throw new UserError('Try again');
+
const tempContainer = await TempContainer.container('access');
const uploaded = await TempContainer.upload(tempContainer.name, ctx.req, ctx.result, fileOptions);
const files = Object.values(uploaded.files).map(file => {
@@ -83,7 +96,7 @@ module.exports = Self => {
const accessContainer = await AccessContainer.container('.archive');
const destinationFile = path.join(
- accessContainer.client.root, accessContainer.name, appName, `${newVersion}.7z`);
+ accessContainer.client.root, accessContainer.name, appName, `${toVersion}.7z`);
if (process.env.NODE_ENV == 'test')
await fs.unlink(srcFile);
@@ -104,7 +117,7 @@ module.exports = Self => {
await fs.mkdir(branchPath, {recursive: true});
const destinationBranch = path.join(branchPath, `${appName}.7z`);
- const destinationRelative = `../../.archive/${appName}/${newVersion}.7z`;
+ const destinationRelative = `../../.archive/${appName}/${toVersion}.7z`;
try {
await fs.unlink(destinationBranch);
} catch (e) {}
@@ -112,7 +125,7 @@ module.exports = Self => {
if (branch == 'master') {
const destinationRoot = path.join(accessContainer.client.root, `${appName}.7z`);
- const rootRelative = `./.archive/${appName}/${newVersion}.7z`;
+ const rootRelative = `./.archive/${appName}/${toVersion}.7z`;
try {
await fs.unlink(destinationRoot);
} catch (e) {}
@@ -120,10 +133,18 @@ module.exports = Self => {
}
}
+ await models.MdbVersionTree.create({
+ app: appName,
+ version: toVersion,
+ branchFk: branch,
+ fromVersion,
+ userFk: userId
+ }, myOptions);
+
await models.MdbVersion.upsert({
app: appName,
branchFk: branch,
- version: newVersion
+ version: toVersion
}, myOptions);
if (unlock) await models.MdbApp.unlock(ctx, appName, myOptions);
@@ -133,7 +154,7 @@ module.exports = Self => {
if (tx) await tx.rollback();
if (fs.existsSync(srcFile))
- await fs.unlink(srcFile);
+ fs.unlink(srcFile);
throw e;
}
diff --git a/modules/mdb/back/model-config.json b/modules/mdb/back/model-config.json
index 6107f8790..8010afca2 100644
--- a/modules/mdb/back/model-config.json
+++ b/modules/mdb/back/model-config.json
@@ -8,6 +8,9 @@
"MdbVersion": {
"dataSource": "vn"
},
+ "MdbVersionTree": {
+ "dataSource": "vn"
+ },
"AccessContainer": {
"dataSource": "accessStorage"
}
diff --git a/modules/mdb/back/models/mdbVersion.js b/modules/mdb/back/models/mdbVersion.js
index b36ee2a60..3a7a0c6f3 100644
--- a/modules/mdb/back/models/mdbVersion.js
+++ b/modules/mdb/back/models/mdbVersion.js
@@ -1,3 +1,4 @@
module.exports = Self => {
require('../methods/mdbVersion/upload')(Self);
+ require('../methods/mdbVersion/last')(Self);
};
diff --git a/modules/mdb/back/models/mdbVersionTree.json b/modules/mdb/back/models/mdbVersionTree.json
new file mode 100644
index 000000000..8c0260e54
--- /dev/null
+++ b/modules/mdb/back/models/mdbVersionTree.json
@@ -0,0 +1,35 @@
+{
+ "name": "MdbVersionTree",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "mdbVersionTree"
+ }
+ },
+ "properties": {
+ "app": {
+ "type": "string",
+ "description": "The app name",
+ "id": true
+ },
+ "version": {
+ "type": "number"
+ },
+ "branchFk": {
+ "type": "string"
+ },
+ "fromVersion": {
+ "type": "number"
+ },
+ "userFk": {
+ "type": "number"
+ }
+ },
+ "relations": {
+ "branch": {
+ "type": "belongsTo",
+ "model": "MdbBranch",
+ "foreignKey": "branchFk"
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html
index 2f7c34e2d..b8559154e 100644
--- a/modules/monitor/front/index/tickets/index.html
+++ b/modules/monitor/front/index/tickets/index.html
@@ -79,51 +79,51 @@
@@ -133,64 +133,64 @@
- {{::ticket.id}}
+ {{ticket.id}}
|
- {{::ticket.nickname}}
+ {{ticket.nickname}}
|
- {{::ticket.userName | dashIfEmpty}}
+ {{ticket.userName | dashIfEmpty}}
|
-
- {{::ticket.shippedDate | date: 'dd/MM/yyyy'}}
+
+ {{ticket.shippedDate | date: 'dd/MM/yyyy'}}
|
- {{::ticket.zoneLanding | date: 'HH:mm'}} |
- {{::ticket.practicalHour | date: 'HH:mm'}} |
- {{::ticket.shipped | date: 'HH:mm'}} |
- {{::ticket.province}} |
+ {{ticket.zoneLanding | date: 'HH:mm'}} |
+ {{ticket.practicalHour | date: 'HH:mm'}} |
+ {{ticket.shipped | date: 'HH:mm'}} |
+ {{ticket.province}} |
- {{::ticket.refFk}}
+ {{ticket.refFk}}
- {{::ticket.state}}
+ ng-show="!ticket.refFk"
+ class="chip {{ticket.classColor}}">
+ {{ticket.state}}
|
- {{::ticket.zoneName | dashIfEmpty}}
+ {{ticket.zoneName | dashIfEmpty}}
|
-
- {{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}}
+
+ {{(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}}
|
{
- this.vnApp.showMessage(this.$t('SMS sent!'));
+ this.vnApp.showMessage(this.$t('SMS sent'));
if (res.data) this.emit('send', {response: res.data});
});
diff --git a/modules/route/front/sms/index.spec.js b/modules/route/front/sms/index.spec.js
index 42bf30931..8bf35e673 100644
--- a/modules/route/front/sms/index.spec.js
+++ b/modules/route/front/sms/index.spec.js
@@ -30,7 +30,7 @@ describe('Route', () => {
controller.onResponse();
$httpBackend.flush();
- expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
+ expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent');
});
it('should call onResponse without the destination and show an error snackbar', () => {
diff --git a/modules/ticket/back/methods/sale/salePreparingList.js b/modules/ticket/back/methods/sale/salePreparingList.js
new file mode 100644
index 000000000..e6e7d5164
--- /dev/null
+++ b/modules/ticket/back/methods/sale/salePreparingList.js
@@ -0,0 +1,33 @@
+module.exports = Self => {
+ Self.remoteMethodCtx('salePreparingList', {
+ description: 'Returns a list with the lines of a ticket and its different states of preparation',
+ accessType: 'READ',
+ accepts: [{
+ arg: 'id',
+ type: 'number',
+ required: true,
+ description: 'The ticket id',
+ http: {source: 'path'}
+ }],
+ returns: {
+ type: ['object'],
+ root: true
+ },
+ http: {
+ path: `/:id/salePreparingList`,
+ verb: 'GET'
+ }
+ });
+
+ Self.salePreparingList = async(ctx, id, options) => {
+ const myOptions = {};
+
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ query = `CALL vn.salePreparingList(?)`;
+ const [sales] = await Self.rawSql(query, [id], myOptions);
+
+ return sales;
+ };
+};
diff --git a/modules/ticket/back/methods/sale/usesMana.js b/modules/ticket/back/methods/sale/usesMana.js
index 093057dca..3f55293bf 100644
--- a/modules/ticket/back/methods/sale/usesMana.js
+++ b/modules/ticket/back/methods/sale/usesMana.js
@@ -24,6 +24,8 @@ module.exports = Self => {
const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions);
const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions);
const workerDepartment = await models.WorkerDepartment.findById(userId, null, myOptions);
+ if (!workerDepartment) return false;
+
const usesMana = departments.find(department => department.id == workerDepartment.departmentFk);
return usesMana ? true : false;
diff --git a/modules/ticket/back/methods/ticket/getTicketsFuture.js b/modules/ticket/back/methods/ticket/getTicketsFuture.js
index 6798df513..901e546f7 100644
--- a/modules/ticket/back/methods/ticket/getTicketsFuture.js
+++ b/modules/ticket/back/methods/ticket/getTicketsFuture.js
@@ -108,16 +108,26 @@ module.exports = Self => {
switch (param) {
case 'id':
return {'f.id': value};
- case 'lines':
+ case 'linesMax':
return {'f.lines': {lte: value}};
- case 'liters':
+ case 'litersMax':
return {'f.liters': {lte: value}};
case 'futureId':
return {'f.futureId': value};
case 'ipt':
- return {'f.ipt': value};
+ return {or:
+ [
+ {'f.ipt': {like: `%${value}%`}},
+ {'f.ipt': null}
+ ]
+ };
case 'futureIpt':
- return {'f.futureIpt': value};
+ return {or:
+ [
+ {'f.futureIpt': {like: `%${value}%`}},
+ {'f.futureIpt': null}
+ ]
+ };
case 'state':
return {'f.stateCode': {like: `%${value}%`}};
case 'futureState':
@@ -203,7 +213,6 @@ module.exports = Self => {
tmp.ticket_problems`);
const sql = ParameterizedSQL.join(stmts, ';');
-
const result = await conn.executeStmt(sql, myOptions);
return result[ticketsIndex];
diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js
index c05ba764d..51639e304 100644
--- a/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js
@@ -19,7 +19,7 @@ describe('ticket getTicketsFuture()', () => {
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsFuture(ctx, options);
- expect(result.length).toEqual(4);
+ expect(result.length).toBeGreaterThan(0);
await tx.rollback();
} catch (e) {
await tx.rollback();
@@ -43,7 +43,7 @@ describe('ticket getTicketsFuture()', () => {
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsFuture(ctx, options);
- expect(result.length).toEqual(4);
+ expect(result.length).toBeGreaterThan(0);
await tx.rollback();
} catch (e) {
@@ -93,7 +93,7 @@ describe('ticket getTicketsFuture()', () => {
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsFuture(ctx, options);
- expect(result.length).toEqual(4);
+ expect(result.length).toBeGreaterThan(0);
await tx.rollback();
} catch (e) {
@@ -118,7 +118,7 @@ describe('ticket getTicketsFuture()', () => {
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsFuture(ctx, options);
- expect(result.length).toEqual(1);
+ expect(result.length).toBeGreaterThan(0);
await tx.rollback();
} catch (e) {
@@ -143,7 +143,7 @@ describe('ticket getTicketsFuture()', () => {
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsFuture(ctx, options);
- expect(result.length).toEqual(4);
+ expect(result.length).toBeGreaterThan(0);
await tx.rollback();
} catch (e) {
@@ -168,7 +168,7 @@ describe('ticket getTicketsFuture()', () => {
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsFuture(ctx, options);
- expect(result.length).toEqual(4);
+ expect(result.length).toBeGreaterThan(0);
await tx.rollback();
} catch (e) {
@@ -187,13 +187,13 @@ describe('ticket getTicketsFuture()', () => {
originDated: today,
futureDated: today,
warehouseFk: 1,
- ipt: 0
+ ipt: 'H'
};
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsFuture(ctx, options);
- expect(result.length).toEqual(0);
+ expect(result.length).toBeGreaterThan(0);
await tx.rollback();
} catch (e) {
@@ -218,7 +218,7 @@ describe('ticket getTicketsFuture()', () => {
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsFuture(ctx, options);
- expect(result.length).toEqual(4);
+ expect(result.length).toBeGreaterThan(0);
await tx.rollback();
} catch (e) {
@@ -237,13 +237,13 @@ describe('ticket getTicketsFuture()', () => {
originDated: today,
futureDated: today,
warehouseFk: 1,
- futureIpt: 0
+ futureIpt: 'H'
};
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsFuture(ctx, options);
- expect(result.length).toEqual(0);
+ expect(result.length).toBeGreaterThan(0);
await tx.rollback();
} catch (e) {
@@ -268,7 +268,7 @@ describe('ticket getTicketsFuture()', () => {
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsFuture(ctx, options);
- expect(result.length).toEqual(1);
+ expect(result.length).toBeGreaterThan(0);
await tx.rollback();
} catch (e) {
@@ -293,7 +293,7 @@ describe('ticket getTicketsFuture()', () => {
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsFuture(ctx, options);
- expect(result.length).toEqual(4);
+ expect(result.length).toBeGreaterThan(0);
await tx.rollback();
} catch (e) {
diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json
index 50cfbd08a..62e763c8f 100644
--- a/modules/ticket/back/model-config.json
+++ b/modules/ticket/back/model-config.json
@@ -26,6 +26,9 @@
"PackingSiteConfig": {
"dataSource": "vn"
},
+ "ExpeditionMistake": {
+ "dataSource": "vn"
+ },
"PrintServerQueue": {
"dataSource": "vn"
},
diff --git a/modules/ticket/back/models/expeditionMistake.json b/modules/ticket/back/models/expeditionMistake.json
new file mode 100644
index 000000000..43033194a
--- /dev/null
+++ b/modules/ticket/back/models/expeditionMistake.json
@@ -0,0 +1,33 @@
+{
+ "name": "ExpeditionMistake",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "expeditionMistake"
+ }
+ },
+ "properties": {
+ "created": {
+ "type": "date"
+ }
+ },
+ "relations": {
+ "expedition": {
+ "type": "belongsTo",
+ "model": "Expedition",
+ "foreignKey": "expeditionFk"
+ },
+ "worker": {
+ "type": "belongsTo",
+ "model": "Worker",
+ "foreignKey": "workerFk"
+ },
+ "type": {
+ "type": "belongsTo",
+ "model": "MistakeType",
+ "foreignKey": "typeFk"
+ }
+ }
+
+ }
+
\ No newline at end of file
diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js
index ae247fc24..bab201fdd 100644
--- a/modules/ticket/back/models/sale.js
+++ b/modules/ticket/back/models/sale.js
@@ -1,5 +1,6 @@
module.exports = Self => {
require('../methods/sale/getClaimableFromTicket')(Self);
+ require('../methods/sale/salePreparingList')(Self);
require('../methods/sale/reserve')(Self);
require('../methods/sale/deleteSales')(Self);
require('../methods/sale/updatePrice')(Self);
diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html
index 805e0b391..c2ebc3e3a 100644
--- a/modules/ticket/front/descriptor-menu/index.html
+++ b/modules/ticket/front/descriptor-menu/index.html
@@ -21,30 +21,28 @@
Add turn
Show Delivery Note...
as PDF
-
- as PDF
-
as PDF without prices
+
+ as PDF signed
+
@@ -54,7 +52,7 @@
Send Delivery Note...
@@ -64,6 +62,11 @@
translate>
Send PDF
+
+ Send PDF to tablet
+
@@ -323,3 +326,18 @@
question="Are you sure you want to refund all?"
message="Refund all">
+
+
+
+
+
+
+
+
diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js
index 168002d07..f6001c6b8 100644
--- a/modules/ticket/front/descriptor-menu/index.js
+++ b/modules/ticket/front/descriptor-menu/index.js
@@ -85,7 +85,6 @@ class Controller extends Section {
.then(res => this.ticket = res.data)
.then(() => {
this.isTicketEditable();
- this.hasDocuware();
});
}
@@ -134,15 +133,6 @@ class Controller extends Section {
});
}
- hasDocuware() {
- const params = {
- fileCabinet: 'deliveryClient',
- dialog: 'findTicket'
- };
- this.$http.post(`Docuwares/${this.id}/checkFile`, params)
- .then(res => this.hasDocuwareFile = res.data);
- }
-
showPdfDeliveryNote(type) {
this.vnReport.show(`tickets/${this.id}/delivery-note-pdf`, {
recipientId: this.ticket.client.id,
@@ -151,7 +141,10 @@ class Controller extends Section {
}
sendPdfDeliveryNote($data) {
- return this.vnEmail.send(`tickets/${this.id}/delivery-note-email`, {
+ let query = `tickets/${this.id}/delivery-note-email`;
+ if (this.hasDocuwareFile) query = `docuwares/${this.id}/delivery-note-email`;
+
+ return this.vnEmail.send(query, {
recipientId: this.ticket.client.id,
recipient: $data.email
});
@@ -267,8 +260,15 @@ class Controller extends Section {
if (client.hasElectronicInvoice) {
this.$http.post(`NotificationQueues`, {
- notificationFk: 'invoiceElectronic',
+ notificationFk: 'invoice-electronic',
authorFk: client.id,
+ params: JSON.stringify(
+ {
+ 'name': client.name,
+ 'email': client.email,
+ 'ticketId': this.id,
+ 'url': window.location.href
+ })
}).then(() => {
this.vnApp.showSuccess(this.$t('Invoice sent'));
});
@@ -312,6 +312,24 @@ class Controller extends Section {
return this.$http.post(`Tickets/${this.id}/sendSms`, sms)
.then(() => this.vnApp.showSuccess(this.$t('SMS sent')));
}
+
+ hasDocuware() {
+ this.$http.post(`Docuwares/${this.id}/checkFile`, {fileCabinet: 'deliveryNote', signed: true})
+ .then(res => {
+ this.hasDocuwareFile = res.data;
+ });
+ }
+
+ uploadDocuware(force) {
+ if (!force)
+ return this.$.pdfToTablet.show();
+
+ return this.$http.post(`Docuwares/${this.id}/upload`, {fileCabinet: 'deliveryNote'})
+ .then(() => {
+ this.vnApp.showSuccess(this.$t('PDF sent!'));
+ this.$.balanceCreate.show();
+ });
+ }
}
Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];
diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js
index 48b64f4a0..67dc0affa 100644
--- a/modules/ticket/front/descriptor-menu/index.spec.js
+++ b/modules/ticket/front/descriptor-menu/index.spec.js
@@ -286,9 +286,34 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
describe('hasDocuware()', () => {
it('should call hasDocuware method', () => {
- $httpBackend.whenPOST(`Docuwares/${ticket.id}/checkFile`).respond();
+ $httpBackend.whenPOST(`Docuwares/${ticket.id}/checkFile`).respond(true);
controller.hasDocuware();
$httpBackend.flush();
+
+ expect(controller.hasDocuwareFile).toBe(true);
+ });
+ });
+
+ describe('uploadDocuware()', () => {
+ it('should open dialog if not force', () => {
+ controller.$.pdfToTablet = {show: () => {}};
+ jest.spyOn(controller.$.pdfToTablet, 'show');
+ controller.uploadDocuware(false);
+
+ expect(controller.$.pdfToTablet.show).toHaveBeenCalled();
+ });
+
+ it('should make a query and show balance create', () => {
+ controller.$.balanceCreate = {show: () => {}};
+ jest.spyOn(controller.$.balanceCreate, 'show');
+ jest.spyOn(controller.vnApp, 'showSuccess');
+
+ $httpBackend.whenPOST(`Docuwares/${ticket.id}/upload`).respond(true);
+ controller.uploadDocuware(true);
+ $httpBackend.flush();
+
+ expect(controller.vnApp.showSuccess).toHaveBeenCalled();
+ expect(controller.$.balanceCreate.show).toHaveBeenCalled();
});
});
diff --git a/modules/ticket/front/descriptor-menu/locale/es.yml b/modules/ticket/front/descriptor-menu/locale/es.yml
index a2725f485..b51637524 100644
--- a/modules/ticket/front/descriptor-menu/locale/es.yml
+++ b/modules/ticket/front/descriptor-menu/locale/es.yml
@@ -1,9 +1,11 @@
Show Delivery Note...: Ver albarán...
Send Delivery Note...: Enviar albarán...
as PDF: como PDF
+as PDF signed: como PDF firmado
as CSV: como CSV
as PDF without prices: como PDF sin precios
Send PDF: Enviar PDF
+Send PDF to tablet: Enviar PDF a tablet
Send CSV: Enviar CSV
Send CSV Delivery Note: Enviar albarán en CSV
Send PDF Delivery Note: Enviar albarán en PDF
@@ -13,3 +15,6 @@ Invoice sent: Factura enviada
The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}"
Transfer client: Transferir cliente
SMS Notify changes: SMS Notificar cambios
+PDF sent!: ¡PDF enviado!
+Already exist signed delivery note: Ya existe albarán de entrega firmado
+Are you sure you want to replace this delivery note?: ¿Seguro que quieres reemplazar este albarán de entrega?
diff --git a/modules/ticket/front/future/index.html b/modules/ticket/front/future/index.html
index 1af1fb9ba..68b0aa4fd 100644
--- a/modules/ticket/front/future/index.html
+++ b/modules/ticket/front/future/index.html
@@ -129,9 +129,9 @@
class="link">
{{::ticket.id}}
|
-
+ |
- {{::ticket.shipped | date: 'dd/MM/yyyy'}}
+ {{::ticket.shipped | date: 'dd/MM/yyyy HH:mm'}}
|
{{::ticket.ipt}} |
@@ -150,9 +150,9 @@
{{::ticket.futureId}}
-
+ |
- {{::ticket.futureShipped | date: 'dd/MM/yyyy'}}
+ {{::ticket.futureShipped | date: 'dd/MM/yyyy HH:mm'}}
|
{{::ticket.futureIpt}} |
diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html
index fc585650a..851817551 100644
--- a/modules/ticket/front/sale-tracking/index.html
+++ b/modules/ticket/front/sale-tracking/index.html
@@ -1,10 +1,11 @@
@@ -12,31 +13,27 @@
-
+ Is checked
Item
- Description
+ Description
Quantity
- Original
- Worker
- State
- Created
+
-
-
-
-
+
+
+
+
+
+
+
- {{sale.itemFk | zeroFill:6}}
+ {{::sale.itemFk | zeroFill:6}}
@@ -53,16 +50,18 @@
{{::sale.quantity}}
- {{::sale.originalQuantity}}
-
-
- {{::sale.userNickname | dashIfEmpty}}
-
+
+
+
+
+
- {{::sale.state}}
- {{::sale.created | date: 'dd/MM/yyyy HH:mm'}}
@@ -70,8 +69,99 @@
+ warehouse-fk="$ctrl.ticket.warehouseFk"
+ ticket-fk="$ctrl.ticket.id">
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+ Quantity
+ Original
+ Worker
+ State
+ Created
+
+
+
+
+ {{::sale.quantity}}
+ {{::sale.originalQuantity}}
+
+
+ {{::sale.userNickname | dashIfEmpty}}
+
+
+ {{::sale.state}}
+ {{::sale.created | date: 'dd/MM/yyyy HH:mm'}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Quantity
+ Worker
+ Shelving
+ Parking
+ Created
+
+
+
+
+ {{::itemShelvingSale.quantity}}
+
+
+ {{::itemShelvingSale.name | dashIfEmpty}}
+
+
+ {{::itemShelvingSale.shelvingFk}}
+ {{::itemShelvingSale.code}}
+ {{::itemShelvingSale.created | date: 'dd/MM/yyyy HH:mm'}}
+
+
+
+
+
+
+
+
diff --git a/modules/ticket/front/sale-tracking/index.js b/modules/ticket/front/sale-tracking/index.js
index 394ef4f1e..60e42a461 100644
--- a/modules/ticket/front/sale-tracking/index.js
+++ b/modules/ticket/front/sale-tracking/index.js
@@ -1,12 +1,100 @@
import ngModule from '../module';
import Section from 'salix/components/section';
+import './style.scss';
-class Controller extends Section {}
+class Controller extends Section {
+ constructor($element, $) {
+ super($element, $);
+ this.filter = {
+ include: [
+ {
+ relation: 'item'
+ }, {
+ relation: 'saleTracking',
+ scope: {
+ fields: ['isChecked']
+ }
+ }
+ ]
+ };
+ }
+
+ get sales() {
+ return this._sales;
+ }
+
+ set sales(value) {
+ this._sales = value;
+ if (value) {
+ const query = `Sales/${this.$params.id}/salePreparingList`;
+ this.$http.get(query)
+ .then(res => {
+ this.salePreparingList = res.data;
+ for (const salePreparing of this.salePreparingList) {
+ for (const sale of this.sales) {
+ if (salePreparing.saleFk == sale.id)
+ sale.preparingList = salePreparing;
+ }
+ }
+ });
+ }
+ }
+
+ showItemDescriptor(event, sale) {
+ this.quicklinks = {
+ btnThree: {
+ icon: 'icon-transaction',
+ state: `item.card.diary({
+ id: ${sale.itemFk},
+ warehouseFk: ${this.ticket.warehouseFk},
+ lineFk: ${sale.id}
+ })`,
+ tooltip: 'Item diary'
+ }
+ };
+ this.$.itemDescriptor.show(event.target, sale.itemFk);
+ }
+
+ chipHasSaleGroupDetail(hasSaleGroupDetail) {
+ if (hasSaleGroupDetail) return 'pink';
+ else return 'message';
+ }
+
+ chipIsPreviousSelected(isPreviousSelected) {
+ if (isPreviousSelected) return 'notice';
+ else return 'message';
+ }
+
+ chipIsPrevious(isPrevious) {
+ if (isPrevious) return 'dark-notice';
+ else return 'message';
+ }
+
+ chipIsPrepared(isPrepared) {
+ if (isPrepared) return 'warning';
+ else return 'message';
+ }
+
+ chipIsControled(isControled) {
+ if (isControled) return 'yellow';
+ else return 'message';
+ }
+
+ showSaleTracking(sale) {
+ this.saleId = sale.id;
+ this.$.saleTracking.show();
+ }
+
+ showItemShelvingSale(sale) {
+ this.saleId = sale.id;
+ this.$.itemShelvingSale.show();
+ }
+}
ngModule.vnComponent('vnTicketSaleTracking', {
template: require('./index.html'),
controller: Controller,
bindings: {
- ticket: '<',
- },
+ ticket: '<'
+ }
});
diff --git a/modules/ticket/front/sale-tracking/locale/es.yml b/modules/ticket/front/sale-tracking/locale/es.yml
new file mode 100644
index 000000000..eabc0a04d
--- /dev/null
+++ b/modules/ticket/front/sale-tracking/locale/es.yml
@@ -0,0 +1,6 @@
+ItemShelvings sale: Carros línea
+has saleGroupDetail: tiene detalle grupo lineas
+is previousSelected: es previa seleccionada
+is previous: es previa
+is prepared: esta preparado
+is controled: esta controlado
diff --git a/modules/ticket/front/sale-tracking/style.scss b/modules/ticket/front/sale-tracking/style.scss
new file mode 100644
index 000000000..6d8b3db69
--- /dev/null
+++ b/modules/ticket/front/sale-tracking/style.scss
@@ -0,0 +1,7 @@
+@import "variables";
+
+.chip {
+ display: inline-block;
+ min-width: 15px;
+ min-height: 25px;
+}
diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html
index c624b1a95..97f6a2a81 100644
--- a/modules/ticket/front/sale/index.html
+++ b/modules/ticket/front/sale/index.html
@@ -30,7 +30,7 @@
ng-click="moreOptions.show($event)"
ng-show="$ctrl.hasSelectedSales()">
-
-
@@ -68,6 +68,7 @@
Disc
Amount
Packaging
+
@@ -84,13 +85,13 @@
vn-tooltip="{{::$ctrl.$t('Claim')}}: {{::sale.claim.claimFk}}">
-
-
@@ -108,21 +109,21 @@
-
-
{{::sale.visible}}
-
{{::sale.available}}
@@ -195,7 +196,7 @@
translate-attr="{title: !$ctrl.isLocked ? 'Edit discount' : ''}"
ng-click="$ctrl.showEditDiscountPopover($event, sale)"
ng-if="sale.id">
- {{(sale.discount / 100) | percentage}}
+ {{(sale.discount / 100) | percentage}}
@@ -204,6 +205,22 @@
{{::sale.item.itemPackingTypeFk | dashIfEmpty}}
+
+
+
+
+
+
+
@@ -383,8 +400,8 @@
-
{{::ticket.id}} |
@@ -392,22 +409,22 @@
{{::ticket.agencyName}} |
{{::ticket.address}}
- {{::ticket.nickname}}
- {{::ticket.name}}
- {{::ticket.street}}
- {{::ticket.postalCode}}
+ {{::ticket.nickname}}
+ {{::ticket.name}}
+ {{::ticket.street}}
+ {{::ticket.postalCode}}
{{::ticket.city}}
|
@@ -441,10 +458,11 @@
-
-
+ sms="$ctrl.newSMS"
+ on-send="$ctrl.onSmsSend($sms)">
+
Refund
-
\ No newline at end of file
+
diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js
index f64d0b61b..618d4727d 100644
--- a/modules/ticket/front/sale/index.js
+++ b/modules/ticket/front/sale/index.js
@@ -389,6 +389,11 @@ class Controller extends Section {
this.$.sms.open();
}
+ onSmsSend(sms) {
+ return this.$http.post(`Tickets/${this.ticket.id}/sendSms`, sms)
+ .then(() => this.vnApp.showSuccess(this.$t('SMS sent')));
+ }
+
/**
* Inserts a new instance
*/
diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml
index 072e57534..2668b7811 100644
--- a/modules/ticket/front/sale/locale/es.yml
+++ b/modules/ticket/front/sale/locale/es.yml
@@ -13,9 +13,9 @@ New ticket: Nuevo ticket
Edit price: Editar precio
You are going to delete lines of the ticket: Vas a eliminar lineas del ticket
This ticket will be removed from current route! Continue anyway?: ¡Se eliminará el ticket de la ruta actual! ¿Continuar de todas formas?
-You have to allow pop-ups in your web browser to use this functionality:
+You have to allow pop-ups in your web browser to use this functionality:
Debes permitir los pop-pups en tu navegador para que esta herramienta funcione correctamente
-Disc: Dto
+Disc: Dto
Available: Disponible
What is the day of receipt of the ticket?: ¿Cual es el día de preparación del pedido?
Add claim: Crear reclamación
@@ -39,3 +39,4 @@ Packaging: Encajado
Refund: Abono
Promotion mana: Maná promoción
Claim mana: Maná reclamación
+History: Historial
diff --git a/modules/travel/front/extra-community/index.html b/modules/travel/front/extra-community/index.html
index 5174f8da2..ee8dcdf98 100644
--- a/modules/travel/front/extra-community/index.html
+++ b/modules/travel/front/extra-community/index.html
@@ -27,7 +27,7 @@
diff --git a/modules/travel/front/extra-community/index.js b/modules/travel/front/extra-community/index.js
index a4ac487e6..2389570b9 100644
--- a/modules/travel/front/extra-community/index.js
+++ b/modules/travel/front/extra-community/index.js
@@ -43,16 +43,6 @@ class Controller extends Section {
this.smartTableOptions = {};
}
- get hasDateRange() {
- const userParams = this.$.model.userParams;
- const hasLanded = userParams.landedTo;
- const hasShipped = userParams.shippedFrom;
- const hasContinent = userParams.continent;
- const hasWarehouseOut = userParams.warehouseOutFk;
-
- return hasLanded || hasShipped || hasContinent || hasWarehouseOut;
- }
-
onDragInterval() {
if (this.dragClientY > 0 && this.dragClientY < 75)
this.$window.scrollTo(0, this.$window.scrollY - 10);
diff --git a/modules/travel/front/extra-community/index.spec.js b/modules/travel/front/extra-community/index.spec.js
index ae48b9ca1..18ddee665 100644
--- a/modules/travel/front/extra-community/index.spec.js
+++ b/modules/travel/front/extra-community/index.spec.js
@@ -14,17 +14,6 @@ describe('Travel Component vnTravelExtraCommunity', () => {
controller.$.model.refresh = jest.fn();
}));
- describe('hasDateRange()', () => {
- it('should return truthy when shippedFrom or landedTo are set as userParams', () => {
- const now = new Date();
- controller.$.model.userParams = {shippedFrom: now, landedTo: now};
-
- const result = controller.hasDateRange;
-
- expect(result).toBeTruthy();
- });
- });
-
describe('findDraggable()', () => {
it('should find the draggable element', () => {
const draggable = document.createElement('tr');
diff --git a/package-lock.json b/package-lock.json
index 550a1ec76..31820196f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,7 @@
"version": "9.0.0",
"license": "GPL-3.0",
"dependencies": {
- "axios": "^0.25.0",
+ "axios": "^1.2.2",
"bcrypt": "^5.0.1",
"bmp-js": "^0.1.0",
"compression": "^1.7.3",
@@ -3893,10 +3893,13 @@
"license": "MIT"
},
"node_modules/axios": {
- "version": "0.25.0",
- "license": "MIT",
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.2.tgz",
+ "integrity": "sha512-bz/J4gS2S3I7mpN/YZfGFTqhXTYzRho8Ay38w2otuuDR322KzFIWm/4W2K6gIwvWaws5n+mnb7D1lN9uD+QH6Q==",
"dependencies": {
- "follow-redirects": "^1.14.7"
+ "follow-redirects": "^1.15.0",
+ "form-data": "^4.0.0",
+ "proxy-from-env": "^1.1.0"
}
},
"node_modules/babel-jest": {
@@ -8401,14 +8404,15 @@
}
},
"node_modules/follow-redirects": {
- "version": "1.14.9",
+ "version": "1.15.2",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
+ "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
- "license": "MIT",
"engines": {
"node": ">=4.0"
},
@@ -28842,9 +28846,13 @@
"version": "1.11.0"
},
"axios": {
- "version": "0.25.0",
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.2.tgz",
+ "integrity": "sha512-bz/J4gS2S3I7mpN/YZfGFTqhXTYzRho8Ay38w2otuuDR322KzFIWm/4W2K6gIwvWaws5n+mnb7D1lN9uD+QH6Q==",
"requires": {
- "follow-redirects": "^1.14.7"
+ "follow-redirects": "^1.15.0",
+ "form-data": "^4.0.0",
+ "proxy-from-env": "^1.1.0"
}
},
"babel-jest": {
@@ -31964,7 +31972,9 @@
}
},
"follow-redirects": {
- "version": "1.14.9"
+ "version": "1.15.2",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
+ "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA=="
},
"for-in": {
"version": "1.0.2",
diff --git a/package.json b/package.json
index 8cc33526d..9633751a0 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"node": ">=14"
},
"dependencies": {
- "axios": "^0.25.0",
+ "axios": "^1.2.2",
"bcrypt": "^5.0.1",
"bmp-js": "^0.1.0",
"compression": "^1.7.3",
diff --git a/print/templates/email/invoice-electronic/invoice-electronic.html b/print/templates/email/invoice-electronic/invoice-electronic.html
new file mode 100644
index 000000000..fc96e0970
--- /dev/null
+++ b/print/templates/email/invoice-electronic/invoice-electronic.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+ {{ $t('subject') }}
+
+
+ {{ $t('title') }} {{name}}
+ {{ $t('clientMail') }} {{email}}
+ {{ $t('ticketId') }} {{ticketId}}
+
+
diff --git a/print/templates/email/invoice-electronic/invoice-electronic.js b/print/templates/email/invoice-electronic/invoice-electronic.js
new file mode 100644
index 000000000..2e1e739ac
--- /dev/null
+++ b/print/templates/email/invoice-electronic/invoice-electronic.js
@@ -0,0 +1,21 @@
+module.exports = {
+ name: 'invoice-electronic',
+ props: {
+ name: {
+ type: [String],
+ required: true
+ },
+ email: {
+ type: [String],
+ required: true
+ },
+ ticketId: {
+ type: [Number],
+ required: true
+ },
+ url: {
+ type: [String],
+ required: true
+ }
+ },
+};
diff --git a/print/templates/email/invoice-electronic/locale/en.yml b/print/templates/email/invoice-electronic/locale/en.yml
new file mode 100644
index 000000000..5523a2fa3
--- /dev/null
+++ b/print/templates/email/invoice-electronic/locale/en.yml
@@ -0,0 +1,4 @@
+subject: A electronic invoice has been created
+title: A new electronic invoice has been created for the client
+clientMail: The client's email is
+ticketId: The invoice's ticket is
\ No newline at end of file
diff --git a/print/templates/email/invoice-electronic/locale/es.yml b/print/templates/email/invoice-electronic/locale/es.yml
new file mode 100644
index 000000000..2cbcfbb36
--- /dev/null
+++ b/print/templates/email/invoice-electronic/locale/es.yml
@@ -0,0 +1,4 @@
+subject: Se ha creado una factura electrónica
+title: Se ha creado una nueva factura electrónica para el cliente
+clientMail: El correo del cliente es
+ticketId: El ticket de la factura es
\ No newline at end of file
diff --git a/print/templates/reports/invoice/invoice.js b/print/templates/reports/invoice/invoice.js
index 48848c079..f7011ad81 100755
--- a/print/templates/reports/invoice/invoice.js
+++ b/print/templates/reports/invoice/invoice.js
@@ -82,7 +82,7 @@ module.exports = {
return this.rawSqlFromDef(`taxes`, [reference]);
},
fetchIntrastat(reference) {
- return this.rawSqlFromDef(`intrastat`, [reference, reference, reference, reference, reference]);
+ return this.rawSqlFromDef(`intrastat`, [reference, reference, reference]);
},
fetchRectified(reference) {
return this.rawSqlFromDef(`rectified`, [reference]);
diff --git a/print/templates/reports/invoice/sql/intrastat.sql b/print/templates/reports/invoice/sql/intrastat.sql
index 7f5fbdf39..f986a9564 100644
--- a/print/templates/reports/invoice/sql/intrastat.sql
+++ b/print/templates/reports/invoice/sql/intrastat.sql
@@ -1,39 +1,26 @@
SELECT *
FROM invoiceOut io
JOIN invoiceOutSerial ios ON io.serial = ios.code
- JOIN
- (SELECT
- t.refFk,
- ir.id code,
- ir.description description,
- CAST(SUM(IFNULL(i.stems, 1) * s.quantity) AS DECIMAL(10,2)) stems,
- CAST(SUM(CAST(IFNULL(i.stems, 1) * s.quantity * IF(ic.grams, ic.grams, i.density * ic.cm3delivery / 1000) / 1000 AS DECIMAL(10,2)) *
- IF(sub.weight, sub.weight / vn.invoiceOut_getWeight(?), 1)) AS DECIMAL(10,2)) netKg,
- CAST(SUM((s.quantity * s.price * (100 - s.discount) / 100 )) AS DECIMAL(10,2)) subtotal
- FROM vn.ticket t
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk
- JOIN vn.intrastat ir ON ir.id = i.intrastatFk
- LEFT JOIN (
- SELECT t2.weight
- FROM vn.ticket t2
- WHERE refFk = ? AND weight
- LIMIT 1
- ) sub ON TRUE
- WHERE t.refFk = ?
- AND i.intrastatFk
- GROUP BY i.intrastatFk
- UNION ALL
- SELECT
- NULL AS refFk,
- NULL AS code,
- NULL AS description,
- 0 AS stems,
- 0 AS netKg,
- IF(CAST(SUM((ts.quantity * ts.price)) AS DECIMAL(10,2)), CAST(SUM((ts.quantity * ts.price)) AS DECIMAL(10,2)), 0) AS subtotal
- FROM vn.ticketService ts
- JOIN vn.ticket t ON ts.ticketFk = t.id
- WHERE t.refFk = ?) sub
- WHERE io.`ref` = ? AND ios.isCEE
- ORDER BY sub.code;
+ JOIN(
+ SELECT ir.id code,
+ ir.description,
+ iii.stems,
+ iii.net netKg,
+ iii.amount subtotal
+ FROM vn.invoiceInIntrastat iii
+ LEFT JOIN vn.invoiceIn ii ON ii.id = iii.invoiceInFk
+ LEFT JOIN vn.invoiceOut io ON io.ref = ii.supplierRef
+ LEFT JOIN vn.intrastat ir ON ir.id = iii.intrastatFk
+ WHERE io.`ref` = ?
+ UNION ALL
+ SELECT NULL code,
+ 'Servicios' description,
+ 0 stems,
+ 0 netKg,
+ IF(CAST(SUM((ts.quantity * ts.price)) AS DECIMAL(10,2)), CAST(SUM((ts.quantity * ts.price)) AS DECIMAL(10,2)), 0) subtotal
+ FROM vn.ticketService ts
+ JOIN vn.ticket t ON ts.ticketFk = t.id
+ WHERE t.refFk = ?
+ ) sub
+ WHERE io.ref = ? AND ios.isCEE
+ ORDER BY sub.code;
| |