diff --git a/back/methods/dms/deleteTrashFiles.js b/back/methods/dms/deleteTrashFiles.js
index 828f9658c6..63d7021c5f 100644
--- a/back/methods/dms/deleteTrashFiles.js
+++ b/back/methods/dms/deleteTrashFiles.js
@@ -47,20 +47,22 @@ module.exports = Self => {
for (let dms of dmsToDelete) {
const pathHash = DmsContainer.getHash(dms.id);
const dmsContainer = await DmsContainer.container(pathHash);
- const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file);
try {
+ const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file);
await fs.unlink(dstFile);
} catch (err) {
- continue;
+ if (err.code != 'ENOENT')
+ throw err;
}
+
+ await dms.destroy(myOptions);
+
const dstFolder = path.join(dmsContainer.client.root, pathHash);
try {
await fs.rmdir(dstFolder);
} catch (err) {
continue;
}
-
- await dms.destroy(myOptions);
}
};
};
diff --git a/db/changes/10501-november/00-deletePickupContact.sql b/db/changes/10502-november/00-deletePickupContact.sql
similarity index 100%
rename from db/changes/10501-november/00-deletePickupContact.sql
rename to db/changes/10502-november/00-deletePickupContact.sql
diff --git a/db/changes/10501-november/00-itemShelvingACL.sql b/db/changes/10502-november/00-itemShelvingACL.sql
similarity index 100%
rename from db/changes/10501-november/00-itemShelvingACL.sql
rename to db/changes/10502-november/00-itemShelvingACL.sql
diff --git a/db/changes/10501-november/00-itemShelvingPlacementSupplyStockACL.sql b/db/changes/10502-november/00-itemShelvingPlacementSupplyStockACL.sql
similarity index 100%
rename from db/changes/10501-november/00-itemShelvingPlacementSupplyStockACL.sql
rename to db/changes/10502-november/00-itemShelvingPlacementSupplyStockACL.sql
diff --git a/db/changes/10501-november/00-zone_getPostalCode.sql b/db/changes/10502-november/00-zone_getPostalCode.sql
similarity index 100%
rename from db/changes/10501-november/00-zone_getPostalCode.sql
rename to db/changes/10502-november/00-zone_getPostalCode.sql
diff --git a/db/docker.js b/db/docker.js
index 3eb262a822..05217d659a 100644
--- a/db/docker.js
+++ b/db/docker.js
@@ -47,12 +47,8 @@ module.exports = class Docker {
if (ci) network = `--network="${networkName}"`;
log('Starting container...');
- const container = await this.execP(`
- docker run \
- ${network} \
- --env RUN_CHOWN=${runChown} \
- -d ${dockerArgs} salix-db
- `);
+ const container = await this.execP(
+ `docker run ${network} --env RUN_CHOWN=${runChown} -d ${dockerArgs} salix-db`);
this.id = container.stdout.trim();
try {
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index 5db3bba63a..619f5125d8 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -918,7 +918,7 @@ INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`)
(3, 'Perdida', 'LOST');
-INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`, `hostFk`)
+INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `freightItemFk`, `created`, `itemFk`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`)
VALUES
(1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1, 'pc1'),
(2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1, NULL),
diff --git a/db/dump/structure.sql b/db/dump/structure.sql
index 402c8e695b..9f2370832b 100644
--- a/db/dump/structure.sql
+++ b/db/dump/structure.sql
@@ -27518,7 +27518,7 @@ CREATE TABLE `expedition` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`agencyModeFk` int(11) NOT NULL,
`ticketFk` int(10) NOT NULL,
- `isBox` int(11) DEFAULT 1 COMMENT 'Este campo realmente en un campo itemFk, haciendo referencia al artículo que nos va a facturar el proveedor de transporte.\nSe debería llamar freightItemFk',
+ `freightItemFk` int(11) DEFAULT 1 COMMENT 'Este campo realmente en un campo itemFk, haciendo referencia al artículo que nos va a facturar el proveedor de transporte.\nSe debería llamar freightItemFk',
`created` timestamp NULL DEFAULT current_timestamp(),
`isRefund__` bit(1) DEFAULT b'0' COMMENT 'Deprecado 01/06/2022',
`isPickUp__` bit(1) DEFAULT b'0' COMMENT 'Deprecado 01/06/2022',
@@ -27534,7 +27534,7 @@ CREATE TABLE `expedition` (
`hasNewRoute` bit(1) NOT NULL DEFAULT b'0',
PRIMARY KEY (`id`),
KEY `index1` (`agencyModeFk`),
- KEY `index2` (`isBox`),
+ KEY `index2` (`freightItemFk`),
KEY `index3` (`created`),
KEY `index4` (`ticketFk`),
KEY `expedition_fk3_idx` (`packagingFk`),
@@ -27567,7 +27567,7 @@ BEGIN
DECLARE vShipFk INT;
- IF NEW.isBox > 0 THEN
+ IF NEW.freightItemFk > 0 THEN
UPDATE ticket SET packages = nz(packages) + 1 WHERE id = NEW.ticketFk;
@@ -27638,7 +27638,7 @@ DELIMITER ;;
BEGIN
UPDATE ticket t
SET packages = (SELECT COUNT(counter)-1
- FROM expedition e WHERE e.ticketFk = OLD.ticketFk and e.isBox)
+ FROM expedition e WHERE e.ticketFk = OLD.ticketFk and e.freightItemFk)
WHERE t.id = OLD.ticketFk;
END */;;
@@ -36287,7 +36287,7 @@ CREATE TABLE `sorter` (
`created` datetime NOT NULL,
`routeFk` int(10) unsigned NOT NULL,
`ticketFk` int(10) NOT NULL,
- `isBox` int(11) DEFAULT 1,
+ `freightItemFk` int(11) DEFAULT 1,
`itemFk` int(11) DEFAULT NULL,
`width` decimal(10,2) DEFAULT 0.00,
`depth` decimal(10,2) DEFAULT 0.00,
@@ -44956,7 +44956,7 @@ BEGIN
SELECT SUM((t.zonePrice - t.zoneBonus) * ebv.ratio) INTO deliveryPrice
FROM vn.ticket t
LEFT JOIN expedition e ON e.ticketFk = t.id
- JOIN expeditionBoxVol ebv ON ebv.boxFk = e.isBox
+ JOIN expeditionBoxVol ebv ON ebv.boxFk = e.freightItemFk
WHERE t.id = vTicketFk;
END IF;
@@ -46492,7 +46492,7 @@ BEGIN
LEFT JOIN item i ON i.id = b.itemFk
LEFT JOIN itemType it ON it.id = i.typeFk
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
- LEFT JOIN packaging p ON p.id = b.packageFk AND NOT p.isBox
+ LEFT JOIN packaging p ON p.id = b.packageFk AND NOT p.freightItemFk
JOIN volumeConfig vc ON TRUE
WHERE b.id = vSelf;
@@ -53229,7 +53229,7 @@ BEGIN
INNER JOIN vn.ticketState ts ON ts.ticketFk = exp.ticketFk
LEFT JOIN vn.address a ON t.addressFk = a.id
LEFT JOIN vn.warehouse w ON t.warehouseFk = w.id
- WHERE t.routeFk = vRouteFk AND exp.isBox > 0;
+ WHERE t.routeFk = vRouteFk AND exp.freightItemFk > 0;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -53760,7 +53760,7 @@ BEGIN
GROUP BY sub.ticketFk
) sub2 ON sub2.ticketFk = t.id
LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk
- WHERE t.routeFk = vRouteFk AND e.isBox <> FALSE
+ WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE
ORDER BY r.created, t.priority DESC;
END ;;
DELIMITER ;
diff --git a/front/core/components/input-file/index.html b/front/core/components/input-file/index.html
index 5ec7e1da49..14d138cfe6 100644
--- a/front/core/components/input-file/index.html
+++ b/front/core/components/input-file/index.html
@@ -3,7 +3,7 @@
ng-transclude="prepend"
class="prepend">
-
+
diff --git a/front/core/components/input-file/style.scss b/front/core/components/input-file/style.scss
index 44d11f7744..72470c4fe3 100644
--- a/front/core/components/input-file/style.scss
+++ b/front/core/components/input-file/style.scss
@@ -4,4 +4,13 @@
.value {
cursor: pointer;
}
+ .control {
+ & > input[type=file] {
+ opacity: 0;
+ }
+ & > section {
+ position: absolute;
+ bottom: 0;
+ }
+ }
}
\ No newline at end of file
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 8c6f2cac83..36595c51bb 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -239,5 +239,6 @@
"This route does not exists": "Esta ruta no existe",
"Claim pickup order sent": "Reclamación Orden de recogida enviada [({{claimId}})]({{{claimUrl}}}) al cliente *{{clientName}}*",
"You don't have grant privilege": "No tienes privilegios para dar privilegios",
- "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario"
+ "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario",
+ "Empty data source": "Origen de datos vacio"
}
diff --git a/modules/client/back/methods/receipt/balanceCompensationEmail.js b/modules/client/back/methods/receipt/balanceCompensationEmail.js
new file mode 100644
index 0000000000..e9ded147de
--- /dev/null
+++ b/modules/client/back/methods/receipt/balanceCompensationEmail.js
@@ -0,0 +1,40 @@
+const {Email} = require('vn-print');
+
+module.exports = Self => {
+ Self.remoteMethodCtx('balanceCompensationEmail', {
+ description: 'Sends the debit balances compensation email with an attached PDF',
+ accessType: 'WRITE',
+ accepts: [
+ {
+ arg: 'id',
+ type: 'Number',
+ required: true,
+ description: 'The receipt id',
+ http: { source: 'path' }
+ }
+ ],
+ returns: {
+ type: ['object'],
+ root: true
+ },
+ http: {
+ path: '/:id/balance-compensation-email',
+ verb: 'POST'
+ }
+ });
+
+ Self.balanceCompensationEmail = async (ctx, id) => {
+
+ const models = Self.app.models;
+ const receipt = await models.Receipt.findById(id, {fields: ['clientFk']});
+ const client = await models.Client.findById(receipt.clientFk, {fields:['email']});
+
+ const email = new Email('balance-compensation', {
+ lang: ctx.req.getLocale(),
+ recipient: client.email+',administracion@verdnatura.es',
+ id
+ });
+
+ return email.send();
+ };
+};
diff --git a/modules/client/back/methods/receipt/balanceCompensationPdf.js b/modules/client/back/methods/receipt/balanceCompensationPdf.js
new file mode 100644
index 0000000000..ff8713253f
--- /dev/null
+++ b/modules/client/back/methods/receipt/balanceCompensationPdf.js
@@ -0,0 +1,50 @@
+const { Report } = require('vn-print');
+
+module.exports = Self => {
+ Self.remoteMethodCtx('balanceCompensationPdf', {
+ description: 'Returns the the debit balances compensation pdf',
+ accessType: 'READ',
+ accepts: [
+ {
+ arg: 'id',
+ type: 'number',
+ required: true,
+ description: 'The receipt id',
+ http: { source: 'path' }
+ }
+ ],
+ returns: [
+ {
+ arg: 'body',
+ type: 'file',
+ root: true
+ }, {
+ arg: 'Content-Type',
+ type: 'String',
+ http: {target: 'header'}
+ }, {
+ arg: 'Content-Disposition',
+ type: 'String',
+ http: {target: 'header'}
+ }
+ ],
+ http: {
+ path: '/:id/balance-compensation-pdf',
+ verb: 'GET'
+ }
+ });
+
+ Self.balanceCompensationPdf = async(ctx, id) => {
+ const args = Object.assign({}, ctx.args);
+ const params = {lang: ctx.req.getLocale()};
+
+ delete args.ctx;
+ for (const param in args)
+ params[param] = args[param];
+
+ const report = new Report('balance-compensation', params);
+ const stream = await report.toPdfStream();
+
+ return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
+ };
+};
diff --git a/modules/client/back/models/receipt.js b/modules/client/back/models/receipt.js
index b79102e6b8..3118cc2390 100644
--- a/modules/client/back/models/receipt.js
+++ b/modules/client/back/models/receipt.js
@@ -2,6 +2,8 @@ const LoopBackContext = require('loopback-context');
module.exports = function(Self) {
require('../methods/receipt/filter')(Self);
+ require('../methods/receipt/balanceCompensationEmail')(Self);
+ require('../methods/receipt/balanceCompensationPdf')(Self);
require('../methods/receipt/receiptPdf')(Self);
Self.validateBinded('amountPaid', isNotZero, {
diff --git a/modules/client/front/balance/index/index.html b/modules/client/front/balance/index/index.html
index 3c61d8543d..1e07161128 100644
--- a/modules/client/front/balance/index/index.html
+++ b/modules/client/front/balance/index/index.html
@@ -121,9 +121,22 @@
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/modules/client/front/balance/index/index.js b/modules/client/front/balance/index/index.js
index 7e09e018cd..b2529924f9 100644
--- a/modules/client/front/balance/index/index.js
+++ b/modules/client/front/balance/index/index.js
@@ -2,8 +2,9 @@ import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller extends Section {
- constructor($element, $) {
+ constructor($element, $, vnEmail) {
super($element, $);
+ this.vnEmail = vnEmail;
this.filter = {
include: {
relation: 'company',
@@ -54,45 +55,49 @@ class Controller extends Section {
}
})).then(() => this.getBalances());
}
-
+
getCurrentBalance() {
const clientRisks = this.$.riskModel.data;
const selectedCompany = this.companyId;
const currentBalance = clientRisks.find(balance => {
return balance.companyFk === selectedCompany;
});
-
+
return currentBalance && currentBalance.amount;
}
-
+
getBalances() {
const balances = this.$.model.data;
balances.forEach((balance, index) => {
if (index === 0)
- balance.balance = this.getCurrentBalance();
+ balance.balance = this.getCurrentBalance();
if (index > 0) {
let previousBalance = balances[index - 1];
balance.balance = previousBalance.balance - (previousBalance.debit - previousBalance.credit);
}
});
}
-
+
showInvoiceOutDescriptor(event, balance) {
if (!balance.isInvoice) return;
if (event.defaultPrevented) return;
-
+
this.$.invoiceOutDescriptor.show(event.target, balance.id);
}
-
+
changeDescription(balance) {
const params = {description: balance.description};
const endpoint = `Receipts/${balance.id}`;
this.$http.patch(endpoint, params)
- .then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
+ .then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
+ }
+
+ sendEmail(balance) {
+ return this.vnEmail.send(`Receipts/${balance.id}/balance-compensation-email`);
}
}
-Controller.$inject = ['$element', '$scope'];
+Controller.$inject = ['$element', '$scope', 'vnEmail'];
ngModule.vnComponent('vnClientBalanceIndex', {
template: require('./index.html'),
diff --git a/modules/client/front/balance/index/locale/es.yml b/modules/client/front/balance/index/locale/es.yml
index 05ef7070af..de710869e7 100644
--- a/modules/client/front/balance/index/locale/es.yml
+++ b/modules/client/front/balance/index/locale/es.yml
@@ -8,4 +8,6 @@ Havings: Haber
Balance: Balance
Total by company: Total por empresa
Download PDF: Descargar PDF
-BILL: N/FRA {{ref}}
\ No newline at end of file
+Send compensation: Enviar compensación
+BILL: N/FRA {{ref}}
+Notify compensation: ¿Desea informar de la compensación al cliente por correo?
\ No newline at end of file
diff --git a/modules/entry/front/buy/index/index.html b/modules/entry/front/buy/index/index.html
index eaa37c92e7..ae67e208b2 100644
--- a/modules/entry/front/buy/index/index.html
+++ b/modules/entry/front/buy/index/index.html
@@ -91,7 +91,7 @@
url="Packagings"
show-field="id"
value-field="id"
- where="{isBox: true}"
+ where="{freightItemFk: true}"
ng-model="buy.packageFk"
on-change="$ctrl.saveBuy(buy)">
diff --git a/modules/ticket/back/methods/expedition/filter.js b/modules/ticket/back/methods/expedition/filter.js
index 723d7c8443..65f840d80f 100644
--- a/modules/ticket/back/methods/expedition/filter.js
+++ b/modules/ticket/back/methods/expedition/filter.js
@@ -32,7 +32,7 @@ module.exports = Self => {
`SELECT
e.id,
e.ticketFk,
- e.isBox,
+ e.freightItemFk,
e.workerFk,
i1.name packageItemName,
e.counter,
@@ -51,7 +51,7 @@ module.exports = Self => {
FROM vn.expedition e
LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
LEFT JOIN vn.item i2 ON i2.id = e.itemFk
- INNER JOIN vn.item i1 ON i1.id = e.isBox
+ INNER JOIN vn.item i1 ON i1.id = e.freightItemFk
LEFT JOIN vn.packaging p ON p.id = e.packagingFk
LEFT JOIN vn.item i3 ON i3.id = p.itemFk
LEFT JOIN account.user u ON u.id = e.workerFk
diff --git a/modules/ticket/back/methods/ticket/collectionLabel.js b/modules/ticket/back/methods/ticket/collectionLabel.js
new file mode 100644
index 0000000000..064ca0210b
--- /dev/null
+++ b/modules/ticket/back/methods/ticket/collectionLabel.js
@@ -0,0 +1,50 @@
+const {Report} = require('vn-print');
+
+module.exports = Self => {
+ Self.remoteMethodCtx('collectionLabel', {
+ description: 'Returns the collection label',
+ accessType: 'READ',
+ accepts: [
+ {
+ arg: 'id',
+ type: 'number',
+ required: true,
+ description: 'The ticket id',
+ http: {source: 'path'}
+ },
+ ],
+ returns: [
+ {
+ arg: 'body',
+ type: 'file',
+ root: true
+ }, {
+ arg: 'Content-Type',
+ type: 'String',
+ http: {target: 'header'}
+ }, {
+ arg: 'Content-Disposition',
+ type: 'String',
+ http: {target: 'header'}
+ }
+ ],
+ http: {
+ path: '/:id/collection-label',
+ verb: 'GET'
+ }
+ });
+
+ Self.collectionLabel = async(ctx, id) => {
+ const args = Object.assign({}, ctx.args);
+ const params = {lang: ctx.req.getLocale()};
+
+ delete args.ctx;
+ for (const param in args)
+ params[param] = args[param];
+
+ const report = new Report('collection-label', params);
+ const stream = await report.toPdfStream();
+
+ return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
+ };
+};
diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js
index 9e9fdb664a..4dd3461615 100644
--- a/modules/ticket/back/methods/ticket/updateDiscount.js
+++ b/modules/ticket/back/methods/ticket/updateDiscount.js
@@ -188,7 +188,7 @@ module.exports = Self => {
async function createSaleComponent(saleId, value, componentId, myOptions) {
const models = Self.app.models;
- return models.SaleComponent.create({
+ return models.SaleComponent.upsert({
saleFk: saleId,
value: value,
componentFk: componentId
diff --git a/modules/ticket/back/models/expedition.json b/modules/ticket/back/models/expedition.json
index fc94f185df..324ad46092 100644
--- a/modules/ticket/back/models/expedition.json
+++ b/modules/ticket/back/models/expedition.json
@@ -16,7 +16,7 @@
"type": "number",
"description": "Identifier"
},
- "isBox": {
+ "freightItemFk": {
"type": "number"
},
"created": {
@@ -55,7 +55,7 @@
"freightItem": {
"type": "belongsTo",
"model": "Item",
- "foreignKey": "isBox"
+ "foreignKey": "freightItemFk"
},
"packaging": {
"type": "belongsTo",
diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js
index 8ab1845d96..3ac03e1de8 100644
--- a/modules/ticket/back/models/ticket-methods.js
+++ b/modules/ticket/back/models/ticket-methods.js
@@ -34,4 +34,5 @@ module.exports = function(Self) {
require('../methods/ticket/closeByAgency')(Self);
require('../methods/ticket/closeByRoute')(Self);
require('../methods/ticket/isRoleAdvanced')(Self);
+ require('../methods/ticket/collectionLabel')(Self);
};
diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html
index ea84743bcd..0c04b42fb9 100644
--- a/modules/ticket/front/descriptor-menu/index.html
+++ b/modules/ticket/front/descriptor-menu/index.html
@@ -5,6 +5,13 @@
+
+ Transfer client
+
+
+
+
+
+
+
+ #{{id}} - {{::name}}
+
+
+
+
+
+
+
+
{
+ const ticket = this.ticket;
+
+ const params =
+ {
+ clientFk: client.data.id,
+ addressFk: client.data.defaultAddressFk,
+ };
+
+ this.$http.patch(`Tickets/${ticket.id}`, params).then(() => {
+ this.vnApp.showSuccess(this.$t('Data saved!'));
+ this.reload();
+ });
+ });
+ }
+
isTicketEditable() {
if (!this.ticket) return;
diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js
index 091b9a2cfd..1716e36f6f 100644
--- a/modules/ticket/front/descriptor-menu/index.spec.js
+++ b/modules/ticket/front/descriptor-menu/index.spec.js
@@ -281,4 +281,17 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
$httpBackend.flush();
});
});
+
+ describe('transferClient()', () => {
+ it(`should perform two queries, a get to obtain the clientData and a patch to update the ticket`, () => {
+ const client =
+ {
+ clientFk: 1101,
+ addressFk: 1,
+ };
+ $httpBackend.expect('GET', `Clients/${ticket.client.id}`).respond(client);
+ $httpBackend.expect('PATCH', `Tickets/${ticket.id}`).respond();
+ controller.transferClient();
+ });
+ });
});
diff --git a/modules/ticket/front/descriptor-menu/locale/es.yml b/modules/ticket/front/descriptor-menu/locale/es.yml
index b65159a3c5..968c61f841 100644
--- a/modules/ticket/front/descriptor-menu/locale/es.yml
+++ b/modules/ticket/front/descriptor-menu/locale/es.yml
@@ -9,4 +9,5 @@ Send CSV Delivery Note: Enviar albarán en CSV
Send PDF Delivery Note: Enviar albarán en PDF
Show Proforma: Ver proforma
Refund all: Abonar todo
-The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}"
\ No newline at end of file
+The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}"
+Transfer client: Transferir cliente
\ No newline at end of file
diff --git a/modules/ticket/front/descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml
index 8ab88ce09e..bce9e62d7c 100644
--- a/modules/ticket/front/descriptor/locale/es.yml
+++ b/modules/ticket/front/descriptor/locale/es.yml
@@ -22,4 +22,4 @@ SMS Pending payment: 'SMS Pago pendiente'
Restore ticket: Restaurar ticket
You are going to restore this ticket: Vas a restaurar este ticket
Are you sure you want to restore this ticket?: ¿Seguro que quieres restaurar el ticket?
-Are you sure you want to refund all?: ¿Seguro que quieres abonar todo?
\ No newline at end of file
+Are you sure you want to refund all?: ¿Seguro que quieres abonar todo?
diff --git a/print/templates/email/balance-compensation/assets/css/import.js b/print/templates/email/balance-compensation/assets/css/import.js
new file mode 100644
index 0000000000..4b4bb70869
--- /dev/null
+++ b/print/templates/email/balance-compensation/assets/css/import.js
@@ -0,0 +1,11 @@
+const Stylesheet = require(`vn-print/core/stylesheet`);
+
+const path = require('path');
+const vnPrintPath = path.resolve('print');
+
+module.exports = new Stylesheet([
+ `${vnPrintPath}/common/css/spacing.css`,
+ `${vnPrintPath}/common/css/misc.css`,
+ `${vnPrintPath}/common/css/layout.css`,
+ `${vnPrintPath}/common/css/email.css`])
+ .mergeStyles();
diff --git a/print/templates/email/balance-compensation/attachments.json b/print/templates/email/balance-compensation/attachments.json
new file mode 100644
index 0000000000..d2bf461c5f
--- /dev/null
+++ b/print/templates/email/balance-compensation/attachments.json
@@ -0,0 +1,6 @@
+[
+ {
+ "filename": "balance-compensation.pdf",
+ "component": "balance-compensation"
+ }
+]
\ No newline at end of file
diff --git a/print/templates/email/balance-compensation/balance-compensation.html b/print/templates/email/balance-compensation/balance-compensation.html
new file mode 100644
index 0000000000..c7388a7a3a
--- /dev/null
+++ b/print/templates/email/balance-compensation/balance-compensation.html
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{$t('description.instructions')}} {{client.name}}
+ {{$t('description.attached')}}
+ {{$t('description.response')}}
+ {{$t('description.regards')}}
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
\ No newline at end of file
diff --git a/print/templates/email/balance-compensation/balance-compensation.js b/print/templates/email/balance-compensation/balance-compensation.js
new file mode 100755
index 0000000000..362e1b1785
--- /dev/null
+++ b/print/templates/email/balance-compensation/balance-compensation.js
@@ -0,0 +1,39 @@
+const Component = require(`vn-print/core/component`);
+const emailHeader = new Component('email-header');
+const emailFooter = new Component('email-footer');
+const attachment = new Component('attachment');
+
+
+module.exports = {
+ name: 'balance-compensation',
+ async serverPrefetch() {
+ this.client = await this.fetchClient(this.id);
+ },
+ methods: {
+ fetchClient(id) {
+ return this.findOneFromDef('client', [id]);
+ },
+ },
+ components: {
+ 'email-header': emailHeader.build(),
+ 'email-footer': emailFooter.build(),
+ 'attachment': attachment.build()
+ },
+ data() {
+ return {
+ attachments: [
+ {
+ filename: 'balance-compensation.pdf',
+ type: 'pdf',
+ path: `Receipts/${this.id}/balance-compensation-pdf`
+ }
+ ]
+ };
+ },
+ props: {
+ id: {
+ type: Number,
+ required: true
+ }
+ }
+};
diff --git a/print/templates/email/balance-compensation/locale/es.yml b/print/templates/email/balance-compensation/locale/es.yml
new file mode 100644
index 0000000000..44253bee2f
--- /dev/null
+++ b/print/templates/email/balance-compensation/locale/es.yml
@@ -0,0 +1,6 @@
+subject: Compensación VerdNatura SL
+description:
+ instructions: Buenos días,
+ attached: Adjuntamos escrito para su confirmación
+ response: Rogamos su respuesta a la mayor brevedad
+ regards: Un saludo
\ No newline at end of file
diff --git a/print/templates/email/balance-compensation/sql/client.sql b/print/templates/email/balance-compensation/sql/client.sql
new file mode 100644
index 0000000000..1e842d69d2
--- /dev/null
+++ b/print/templates/email/balance-compensation/sql/client.sql
@@ -0,0 +1,5 @@
+SELECT
+ c.name
+FROM client c
+ JOIN receipt r ON r.clientFk = c.id
+WHERE r.id = ?;
\ No newline at end of file
diff --git a/print/templates/reports/balance-compensation/balance-compensation.html b/print/templates/reports/balance-compensation/balance-compensation.html
new file mode 100644
index 0000000000..3291d66f4f
--- /dev/null
+++ b/print/templates/reports/balance-compensation/balance-compensation.html
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{$t('Place')}} {{currentDate()}}
+ {{$t('Compensation') | uppercase}}
+ {{$t('In one hand')}}:
+ {{company.name}} {{$t('CIF')}} {{company.nif}} {{$t('Home')}} {{company.street}}, {{company.city}}.
+ {{$t('In other hand')}}:
+ {{$t('Sr')}} {{client.name}} {{$t('NIF')}} {{client.fi}} {{$t('Home')}} {{client.street}}, {{client.city}}.
+ {{$t('Agree') | uppercase}}
+ {{$t('Date')}} {{client.payed | date('%d-%m-%Y')}} {{$t('Compensate')}} {{client.amountPaid}} € {{$t('From client')}} {{client.name}} {{$t('To client')}} {{company.name}}.
+ {{$t('Reception')}} administracion@verdnatura.es
+ {{$t('Greetings')}}
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
\ No newline at end of file
diff --git a/print/templates/reports/balance-compensation/balance-compensation.js b/print/templates/reports/balance-compensation/balance-compensation.js
new file mode 100644
index 0000000000..6227412a9c
--- /dev/null
+++ b/print/templates/reports/balance-compensation/balance-compensation.js
@@ -0,0 +1,36 @@
+const Component = require(`vn-print/core/component`);
+const reportHeader = new Component('report-header');
+const reportFooter = new Component('report-footer');
+
+module.exports = {
+ name: 'balance-compensation',
+ async serverPrefetch() {
+ this.client = await this.fetchClient(this.id);
+ this.company = await this.fetchCompany(this.id);
+ },
+ methods: {
+ fetchClient(id) {
+ return this.findOneFromDef('client', [id]);
+ },
+ fetchCompany(id) {
+ return this.findOneFromDef('company', [id]);
+ },
+
+ currentDate() {
+ const current = new Date();
+ const date = `${current.getDate()}/${current.getMonth()+1}/${current.getFullYear()}`;
+ return date;
+ }
+ },
+ components: {
+ 'report-header': reportHeader.build(),
+ 'report-footer': reportFooter.build()
+ },
+ props: {
+ id: {
+ type: Number,
+ required: true,
+ description: 'The receipt id'
+ }
+ }
+};
diff --git a/print/templates/reports/balance-compensation/css/import.js b/print/templates/reports/balance-compensation/css/import.js
new file mode 100644
index 0000000000..37a98dfddb
--- /dev/null
+++ b/print/templates/reports/balance-compensation/css/import.js
@@ -0,0 +1,12 @@
+const Stylesheet = require(`vn-print/core/stylesheet`);
+
+const path = require('path');
+const vnPrintPath = path.resolve('print');
+
+module.exports = new Stylesheet([
+ `${vnPrintPath}/common/css/spacing.css`,
+ `${vnPrintPath}/common/css/misc.css`,
+ `${vnPrintPath}/common/css/layout.css`,
+ `${vnPrintPath}/common/css/report.css`,
+ `${__dirname}/style.css`])
+ .mergeStyles();
diff --git a/print/templates/reports/balance-compensation/locale/es.yml b/print/templates/reports/balance-compensation/locale/es.yml
new file mode 100644
index 0000000000..546e55f060
--- /dev/null
+++ b/print/templates/reports/balance-compensation/locale/es.yml
@@ -0,0 +1,16 @@
+reportName: compensacion-saldo
+Place: Algemesí, a
+Compensation: Compensación de saldos deudores y acreedores
+In one hand: De una parte
+CIF: con CIF
+NIF: con NIF
+Home: y domicilio sito en
+In other hand: De la otra
+Sr: Don/Doña
+Agree: Acuerdan
+Date: En fecha de
+Compensate: se ha compensado el saldo de
+From client: del cliente/proveedor
+To client: con el cliente/proveedor
+Reception: Por favor, rogamos confirmen la recepción de esta compensación al email
+Greetings: Saludos cordiales,
\ No newline at end of file
diff --git a/print/templates/reports/balance-compensation/sql/client.sql b/print/templates/reports/balance-compensation/sql/client.sql
new file mode 100644
index 0000000000..92e6f6cabe
--- /dev/null
+++ b/print/templates/reports/balance-compensation/sql/client.sql
@@ -0,0 +1,12 @@
+SELECT
+ c.name,
+ c.socialName,
+ c.street,
+ c.fi,
+ c.city,
+ r.amountPaid,
+ r.payed
+ FROM client c
+ JOIN receipt r ON r.clientFk = c.id
+ JOIN supplier s ON c.fi = s.nif
+ WHERE r.id = ?
\ No newline at end of file
diff --git a/print/templates/reports/balance-compensation/sql/company.sql b/print/templates/reports/balance-compensation/sql/company.sql
new file mode 100644
index 0000000000..e61228a105
--- /dev/null
+++ b/print/templates/reports/balance-compensation/sql/company.sql
@@ -0,0 +1,8 @@
+SELECT
+ s.name,
+ s.nif,
+ s.street,
+ s.city
+ FROM supplier s
+ JOIN receipt r ON r.companyFk = s.id
+ WHERE r.id = ?;
\ No newline at end of file
diff --git a/print/templates/reports/collection-label/assets/css/import.js b/print/templates/reports/collection-label/assets/css/import.js
new file mode 100644
index 0000000000..37a98dfddb
--- /dev/null
+++ b/print/templates/reports/collection-label/assets/css/import.js
@@ -0,0 +1,12 @@
+const Stylesheet = require(`vn-print/core/stylesheet`);
+
+const path = require('path');
+const vnPrintPath = path.resolve('print');
+
+module.exports = new Stylesheet([
+ `${vnPrintPath}/common/css/spacing.css`,
+ `${vnPrintPath}/common/css/misc.css`,
+ `${vnPrintPath}/common/css/layout.css`,
+ `${vnPrintPath}/common/css/report.css`,
+ `${__dirname}/style.css`])
+ .mergeStyles();
diff --git a/print/templates/reports/collection-label/assets/css/style.css b/print/templates/reports/collection-label/assets/css/style.css
new file mode 100644
index 0000000000..fe1975445d
--- /dev/null
+++ b/print/templates/reports/collection-label/assets/css/style.css
@@ -0,0 +1,37 @@
+html {
+ font-family: "Roboto";
+ margin-top: -7px;
+}
+* {
+ box-sizing: border-box;
+ text-align: center;
+ font-size: 26px;
+}
+#vertical {
+ writing-mode: vertical-rl;
+ height: 226px;
+ margin-left: -13px;
+}
+.outline {
+ border: 1px solid black;
+ padding: 5px;
+}
+#nickname {
+ font-size: 22px;
+}
+#agencyDescripton {
+ font-size: 32px;
+ font-weight: bold;
+}
+#bold {
+ font-weight: bold;
+}
+#barcode{
+ width: 390px;
+}
+#shipped {
+ font-weight: bold;
+}
+#ticketFk, #vertical {
+ font-size: 34px;
+}
\ No newline at end of file
diff --git a/print/templates/reports/collection-label/collection-label.html b/print/templates/reports/collection-label/collection-label.html
new file mode 100644
index 0000000000..5ae375786a
--- /dev/null
+++ b/print/templates/reports/collection-label/collection-label.html
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+ {{labelData.levelV}} |
+ {{labelData.ticketFk}} ⬸ {{labelData.clientFk}} |
+ {{labelData.shipped}} |
+
+
+ |
+ {{labelData.workerCode}} |
+
+
+ {{labelData.labelCount}} |
+
+
+ {{labelData.size}} |
+
+
+ {{labelData.agencyDescription}} |
+ {{labelData.lineCount}} |
+
+
+ {{labelData.nickName}} |
+ {{labelData.agencyHour}} |
+
+
+
+
+
\ No newline at end of file
diff --git a/print/templates/reports/collection-label/collection-label.js b/print/templates/reports/collection-label/collection-label.js
new file mode 100644
index 0000000000..1ae986c987
--- /dev/null
+++ b/print/templates/reports/collection-label/collection-label.js
@@ -0,0 +1,46 @@
+const jsBarcode = require('jsbarcode');
+const {DOMImplementation, XMLSerializer} = require('xmldom');
+const UserError = require('vn-loopback/util/user-error');
+
+module.exports = {
+ name: 'collection-label',
+ props: {
+ id: {
+ type: Number,
+ required: true,
+ description: 'The ticket or collection id'
+ }
+ },
+ async serverPrefetch() {
+ let ticketIds;
+ const res = await this.rawSqlFromDef('tickets', [this.id]);
+
+ if (res.length) {
+ ticketIds = [];
+ for (const row of res)
+ ticketIds.push(row.ticketFk);
+ } else
+ ticketIds = [this.id];
+
+ this.labelsData = await this.rawSqlFromDef('labelsData', [ticketIds]);
+
+ if (!this.labelsData.length)
+ throw new UserError('Empty data source');
+ },
+ methods: {
+ getBarcode(id) {
+ const xmlSerializer = new XMLSerializer();
+ const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null);
+ const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+
+ jsBarcode(svgNode, id, {
+ xmlDocument: document,
+ format: 'code128',
+ displayValue: false,
+ width: 3.8,
+ height: 110,
+ });
+ return xmlSerializer.serializeToString(svgNode);
+ },
+ }
+};
diff --git a/print/templates/reports/collection-label/locale/es.yml b/print/templates/reports/collection-label/locale/es.yml
new file mode 100644
index 0000000000..a54d3bad8b
--- /dev/null
+++ b/print/templates/reports/collection-label/locale/es.yml
@@ -0,0 +1 @@
+reportName: labelCollection
\ No newline at end of file
diff --git a/print/templates/reports/collection-label/options.json b/print/templates/reports/collection-label/options.json
new file mode 100644
index 0000000000..175b3c1db8
--- /dev/null
+++ b/print/templates/reports/collection-label/options.json
@@ -0,0 +1,11 @@
+{
+ "width": "10.4cm",
+ "height": "4.8cm",
+ "margin": {
+ "top": "0cm",
+ "right": "0.5cm",
+ "bottom": "0cm",
+ "left": "0cm"
+ },
+ "printBackground": true
+}
\ No newline at end of file
diff --git a/print/templates/reports/collection-label/sql/labelsData.sql b/print/templates/reports/collection-label/sql/labelsData.sql
new file mode 100644
index 0000000000..6f5b47a54d
--- /dev/null
+++ b/print/templates/reports/collection-label/sql/labelsData.sql
@@ -0,0 +1,35 @@
+SELECT c.itemPackingTypeFk,
+ CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color,
+ CONCAT(tc.collectionFk, ' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-', tc.`level`) levelV,
+ tc.ticketFk,
+ LEFT(COALESCE(et.description, zo.name, am.name),12) agencyDescription,
+ am.name,
+ t.clientFk,
+ CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), 'm³') m3 ,
+ CAST(IF(ic.code = 'plant', CONCAT(MAX(i.`size`),' cm'), COUNT(*)) AS CHAR) size,
+ w.code workerCode,
+ tt.labelCount,
+ IF(HOUR(t.shipped), TIME_FORMAT(t.shipped, '%H:%i'), TIME_FORMAT(zo.`hour`, '%H:%i')) agencyHour,
+ DATE_FORMAT(t.shipped, '%d/%m/%y') shipped,
+ COUNT(*) lineCount,
+ t.nickName
+ FROM vn.ticket t
+ JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
+ JOIN vn.collection c ON c.id = tc.collectionFk
+ LEFT JOIN vn.collectionColors cc ON cc.shelve = tc.`level`
+ AND cc.wagon = tc.wagon
+ AND cc.trainFk = c.trainFk
+ JOIN vn.sale s ON s.ticketFk = t.id
+ LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.worker w ON w.id = c.workerFk
+ JOIN vn.agencyMode am ON am.id = t.agencyModeFk
+ LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id
+ LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id
+ LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
+ LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
+ WHERE tc.ticketFk IN (?)
+ GROUP BY t.id
+ ORDER BY cc.`code`;
\ No newline at end of file
diff --git a/print/templates/reports/collection-label/sql/tickets.sql b/print/templates/reports/collection-label/sql/tickets.sql
new file mode 100644
index 0000000000..05deeba83a
--- /dev/null
+++ b/print/templates/reports/collection-label/sql/tickets.sql
@@ -0,0 +1,3 @@
+SELECT ticketFk
+ FROM ticketCollection
+ WHERE collectionFk = ?
\ No newline at end of file
diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html
index 96fb6e957f..e310539e03 100644
--- a/print/templates/reports/driver-route/driver-route.html
+++ b/print/templates/reports/driver-route/driver-route.html
@@ -81,7 +81,7 @@
-