diff --git a/modules/client/front/address/index/index.html b/modules/client/front/address/index/index.html
index ef3da40519..8ef4232137 100644
--- a/modules/client/front/address/index/index.html
+++ b/modules/client/front/address/index/index.html
@@ -50,7 +50,7 @@
{{::address.postalCode}} -
{{::address.city}},
{{::address.province.name}},
- {{::address.province.country.country}}
+ {{::address.province.country.name}}
{{::address.phone}}
,
diff --git a/modules/client/front/consumption/index.html b/modules/client/front/consumption/index.html
index 17e1e8c8b8..06611da5ab 100644
--- a/modules/client/front/consumption/index.html
+++ b/modules/client/front/consumption/index.html
@@ -77,8 +77,7 @@
tabindex="-1">
-
{{::sale.quantity | dashIfEmpty}}
-
+
{{::sale.quantity | dashIfEmpty}}
diff --git a/modules/client/front/create/index.html b/modules/client/front/create/index.html
index b5c23ecfff..abd974cbf8 100644
--- a/modules/client/front/create/index.html
+++ b/modules/client/front/create/index.html
@@ -66,7 +66,7 @@
rule>
{{code}} - {{town.name}} ({{town.province.name}},
- {{town.province.country.country}})
+ {{town.province.country.name}})
{{name}}, {{province.name}}
- ({{province.country.country}})
+ ({{province.country.name}})
@@ -101,14 +101,14 @@
url="Provinces/location"
fields="['id', 'name', 'countryFk']"
rule>
- {{name}} ({{country.country}})
+ {{name}} ({{country.name}})
+ show-field="name">
diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html
index c2bf86f70d..c366c8ca3d 100644
--- a/modules/client/front/fiscal-data/index.html
+++ b/modules/client/front/fiscal-data/index.html
@@ -16,7 +16,7 @@
auto-load="true"
url="Countries"
data="countries"
- order="country">
+ order="name">
{{code}} - {{town.name}} ({{town.province.name}},
- {{town.province.country.country}})
+ {{town.province.country.name}})
{{name}}, {{province.name}}
- ({{province.country.country}})
+ ({{province.country.name}})
@@ -126,14 +126,14 @@
show-field="name"
value-field="id"
rule>
- {{name}} ({{country.country}})
+ {{name}} ({{country.name}})
diff --git a/modules/client/front/summary/index.html b/modules/client/front/summary/index.html
index a42e192d06..3a46a49597 100644
--- a/modules/client/front/summary/index.html
+++ b/modules/client/front/summary/index.html
@@ -104,7 +104,7 @@
value="{{$ctrl.summary.province.name}}">
+ value="{{$ctrl.summary.country.name}}">
diff --git a/modules/entry/back/methods/entry/addFromBuy.js b/modules/entry/back/methods/entry/addFromBuy.js
index 307c04b97e..e5cc427a85 100644
--- a/modules/entry/back/methods/entry/addFromBuy.js
+++ b/modules/entry/back/methods/entry/addFromBuy.js
@@ -76,7 +76,6 @@ module.exports = Self => {
packing: buyUltimate.packing,
grouping: buyUltimate.grouping,
groupingMode: buyUltimate.groupingMode,
- containerFk: buyUltimate.containerFk,
comissionValue: buyUltimate.comissionValue,
packageValue: buyUltimate.packageValue,
location: buyUltimate.location,
diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json
index 7b6e236857..dc7fd86be2 100644
--- a/modules/entry/back/model-config.json
+++ b/modules/entry/back/model-config.json
@@ -22,5 +22,8 @@
},
"EntryObservation": {
"dataSource": "vn"
+ },
+ "EntryType": {
+ "dataSource": "vn"
}
-}
+}
\ No newline at end of file
diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json
index 35861fd81a..14cafde06b 100644
--- a/modules/entry/back/models/buy.json
+++ b/modules/entry/back/models/buy.json
@@ -63,9 +63,6 @@
"isIgnored": {
"type": "boolean"
},
- "containerFk": {
- "type": "number"
- },
"location": {
"type": "number"
},
diff --git a/modules/entry/back/models/entry-type.json b/modules/entry/back/models/entry-type.json
new file mode 100644
index 0000000000..989aa3a8aa
--- /dev/null
+++ b/modules/entry/back/models/entry-type.json
@@ -0,0 +1,25 @@
+{
+ "name": "EntryType",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
+ "options": {
+ "mysql": {
+ "table": "entryType"
+ }
+ },
+ "properties": {
+ "code": {
+ "type": "string",
+ "id": true,
+ "description": "Identifier"
+ },
+ "description": {
+ "type": "string"
+ },
+ "isInformal": {
+ "type": "boolean"
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json
index ab451219eb..833edf14d8 100644
--- a/modules/entry/back/models/entry.json
+++ b/modules/entry/back/models/entry.json
@@ -35,9 +35,9 @@
},
"isVirtual": {
"type": "boolean",
- "mysql": {
- "columnName": "isRaid"
- }
+ "mysql": {
+ "columnName": "isRaid"
+ }
},
"isRaid": {
"type": "boolean"
@@ -53,9 +53,9 @@
},
"observation": {
"type": "string",
- "mysql": {
- "columnName": "evaNotes"
- }
+ "mysql": {
+ "columnName": "evaNotes"
+ }
},
"loadPriority": {
"type": "number"
@@ -101,6 +101,11 @@
"type": "belongsTo",
"model": "Account",
"foreignKey": "observationEditorFk"
+ },
+ "entryType": {
+ "type": "belongsTo",
+ "model": "EntryType",
+ "foreignKey": "typeFk"
}
}
-}
+}
\ No newline at end of file
diff --git a/modules/invoiceIn/back/methods/invoice-in/exchangeRateUpdate.js b/modules/invoiceIn/back/methods/invoice-in/exchangeRateUpdate.js
index 3ad06b242b..989b1d4a24 100644
--- a/modules/invoiceIn/back/methods/invoice-in/exchangeRateUpdate.js
+++ b/modules/invoiceIn/back/methods/invoice-in/exchangeRateUpdate.js
@@ -54,6 +54,20 @@ module.exports = Self => {
value: rate
});
}
+ const monday = 1;
+ if (xmlDateWithoutTime.getDay() === monday) {
+ const saturday = new Date(xmlDateWithoutTime);
+ saturday.setDate(xmlDateWithoutTime.getDate() - 2);
+ const sunday = new Date(xmlDateWithoutTime);
+ sunday.setDate(xmlDateWithoutTime.getDate() - 1);
+
+ for (const date of [saturday, sunday]) {
+ await models.ReferenceRate.upsertWithWhere(
+ {currencyFk: currency.id, dated: date},
+ {currencyFk: currency.id, dated: date, value: rate}
+ );
+ }
+ }
}
}
}
diff --git a/modules/invoiceIn/back/methods/invoice-in/invoiceInPdf.js b/modules/invoiceIn/back/methods/invoice-in/invoiceInPdf.js
index 681a19fc69..1e9da86a47 100644
--- a/modules/invoiceIn/back/methods/invoice-in/invoiceInPdf.js
+++ b/modules/invoiceIn/back/methods/invoice-in/invoiceInPdf.js
@@ -29,7 +29,8 @@ module.exports = Self => {
http: {
path: '/:id/invoice-in-pdf',
verb: 'GET'
- }
+ },
+ accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.invoiceInPdf = (ctx, id) => Self.printReport(ctx, id, 'invoiceIn');
diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/toUnbook.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/toUnbook.spec.js
new file mode 100644
index 0000000000..b7d98e3078
--- /dev/null
+++ b/modules/invoiceIn/back/methods/invoice-in/specs/toUnbook.spec.js
@@ -0,0 +1,32 @@
+const models = require('vn-loopback/server/server').models;
+
+describe('invoiceIn toUnbook()', () => {
+ it('should check that invoiceIn is unbooked', async() => {
+ const userId = 1;
+ const ctx = {
+ req: {
+
+ accessToken: {userId: userId},
+ headers: {origin: 'http://localhost:5000'},
+ }
+ };
+ const invoiceInId = 1;
+ const tx = await models.InvoiceIn.beginTransaction({});
+ const options = {transaction: tx};
+
+ try {
+ await models.InvoiceIn.toBook(ctx, invoiceInId, options);
+ const bookEntry = await models.InvoiceIn.toUnbook(ctx, invoiceInId, options);
+ const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options);
+
+ expect(bookEntry.accountingEntries).toEqual(4);
+ expect(bookEntry.isLinked).toBeFalsy();
+ expect(invoiceIn.isBooked).toEqual(false);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+});
diff --git a/modules/invoiceIn/back/methods/invoice-in/toBook.js b/modules/invoiceIn/back/methods/invoice-in/toBook.js
index 778742911f..c3be5f8fcf 100644
--- a/modules/invoiceIn/back/methods/invoice-in/toBook.js
+++ b/modules/invoiceIn/back/methods/invoice-in/toBook.js
@@ -32,7 +32,7 @@ module.exports = Self => {
}
try {
- await Self.rawSql(`CALL vn.invoiceIn_booking(?)`, [id], myOptions);
+ await Self.rawSql(`CALL vn.invoiceIn_booking(?, NULL)`, [id], myOptions);
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
diff --git a/modules/invoiceIn/back/methods/invoice-in/toUnbook.js b/modules/invoiceIn/back/methods/invoice-in/toUnbook.js
new file mode 100644
index 0000000000..a697e9ddca
--- /dev/null
+++ b/modules/invoiceIn/back/methods/invoice-in/toUnbook.js
@@ -0,0 +1,80 @@
+module.exports = Self => {
+ Self.remoteMethodCtx('toUnbook', {
+ description: 'To unbook the invoiceIn',
+ accessType: 'WRITE',
+ accepts: {
+ arg: 'id',
+ type: 'number',
+ required: true,
+ description: 'The invoiceIn id',
+ http: {source: 'path'}
+ },
+ returns: {
+ type: 'object',
+ root: true
+ },
+ http: {
+ path: '/:id/toUnbook',
+ verb: 'POST'
+ }
+ });
+
+ Self.toUnbook = async(ctx, invoiceInId, options) => {
+ let tx;
+ const models = Self.app.models;
+ const myOptions = {userId: ctx.req.accessToken.userId};
+
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ if (!myOptions.transaction) {
+ tx = await Self.beginTransaction({});
+ myOptions.transaction = tx;
+ }
+
+ try {
+ let isLinked;
+ let accountingEntries;
+
+ let bookEntry = await models.Xdiario.findOne({
+ fields: ['ASIEN'],
+ where: {
+ and: [
+ {key: invoiceInId},
+ {enlazado: false},
+ {enlazadoSage: false}
+ ]
+ }
+ }, myOptions);
+
+ let asien = bookEntry?.ASIEN;
+ if (asien) {
+ accountingEntries = await models.Xdiario.count({ASIEN: asien}, myOptions);
+
+ await models.Xdiario.destroyAll({ASIEN: asien}, myOptions);
+ await Self.updateAll({id: invoiceInId}, {isBooked: false}, myOptions);
+ } else {
+ const linkedBookEntry = await models.Xdiario.findOne({
+ fields: ['ASIEN'],
+ where: {
+ key: invoiceInId,
+ and: [{or: [{enlazado: true, enlazadoSage: true}]}]
+ }
+ }, myOptions);
+
+ asien = linkedBookEntry?.ASIEN;
+ isLinked = true;
+ }
+ if (tx) await tx.commit();
+
+ return {
+ isLinked,
+ bookEntry: asien,
+ accountingEntries
+ };
+ } catch (e) {
+ if (tx) await tx.rollback();
+ throw e;
+ }
+ };
+};
diff --git a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js
new file mode 100644
index 0000000000..92a1ba8ee6
--- /dev/null
+++ b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js
@@ -0,0 +1,104 @@
+module.exports = Self => {
+ Self.remoteMethodCtx('updateInvoiceIn', {
+ description: 'To update the invoiceIn attributes',
+ accessType: 'WRITE',
+ accepts: [{
+ arg: 'id',
+ type: 'number',
+ required: true,
+ description: 'The invoiceIn id',
+ http: {source: 'path'}
+ }, {
+ arg: 'supplierFk',
+ type: 'number',
+ required: true
+ }, {
+ arg: 'supplierRef',
+ type: 'any',
+ }, {
+ arg: 'issued',
+ type: 'any',
+ }, {
+ arg: 'operated',
+ type: 'any',
+ }, {
+ arg: 'deductibleExpenseFk',
+ type: 'any',
+ }, {
+ arg: 'dmsFk',
+ type: 'any',
+ }, {
+ arg: 'bookEntried',
+ type: 'any',
+ }, {
+ arg: 'booked',
+ type: 'any',
+ }, {
+ arg: 'currencyFk',
+ type: 'number',
+ required: true
+ }, {
+ arg: 'companyFk',
+ type: 'any',
+ }, {
+ arg: 'withholdingSageFk',
+ type: 'any',
+ },
+ ],
+ returns: {
+ type: 'object',
+ root: true
+ },
+ http: {
+ path: '/:id/updateInvoiceIn',
+ verb: 'PATCH'
+ }
+ });
+
+ Self.updateInvoiceIn = async(ctx,
+ id,
+ supplierFk,
+ supplierRef,
+ issued,
+ operated,
+ deductibleExpenseFk,
+ dmsFk,
+ bookEntried,
+ booked,
+ currencyFk,
+ companyFk,
+ withholdingSageFk,
+ options
+ ) => {
+ let tx;
+ const myOptions = {userId: ctx.req.accessToken.userId};
+
+ if (typeof options == 'object') Object.assign(myOptions, options);
+
+ if (!myOptions.transaction) {
+ tx = await Self.beginTransaction({});
+ myOptions.transaction = tx;
+ }
+
+ try {
+ const invoiceIn = await Self.findById(id, null, myOptions);
+ invoiceIn.updateAttributes({supplierFk,
+ supplierRef,
+ issued,
+ operated,
+ deductibleExpenseFk,
+ dmsFk,
+ bookEntried,
+ booked,
+ currencyFk,
+ companyFk,
+ withholdingSageFk
+ }, myOptions);
+ if (tx) await tx.commit();
+ return invoiceIn;
+ } catch (e) {
+ if (tx) await tx.rollback();
+ throw e;
+ }
+ };
+};
diff --git a/modules/invoiceIn/back/models/invoice-in-config.json b/modules/invoiceIn/back/models/invoice-in-config.json
index c0236e6544..638a97fa3d 100644
--- a/modules/invoiceIn/back/models/invoice-in-config.json
+++ b/modules/invoiceIn/back/models/invoice-in-config.json
@@ -26,7 +26,7 @@
"sageWithholding": {
"type": "belongsTo",
"model": "SageWithholding",
- "foreignKey": "sageWithholdingFk"
+ "foreignKey": "sageFarmerWithholdingFk"
}
},
"acls": [{
diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js
index 31cdc1abe4..1e69c0ef8d 100644
--- a/modules/invoiceIn/back/models/invoice-in.js
+++ b/modules/invoiceIn/back/models/invoice-in.js
@@ -11,6 +11,8 @@ module.exports = Self => {
require('../methods/invoice-in/getSerial')(Self);
require('../methods/invoice-in/corrective')(Self);
require('../methods/invoice-in/exchangeRateUpdate')(Self);
+ require('../methods/invoice-in/toUnbook')(Self);
+ require('../methods/invoice-in/updateInvoiceIn')(Self);
Self.rewriteDbError(function(err) {
if (err.code === 'ER_ROW_IS_REFERENCED_2' && err.sqlMessage.includes('vehicleInvoiceIn'))
diff --git a/modules/invoiceIn/front/basic-data/index.html b/modules/invoiceIn/front/basic-data/index.html
index a22abbb330..fbb9b05a20 100644
--- a/modules/invoiceIn/front/basic-data/index.html
+++ b/modules/invoiceIn/front/basic-data/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/modules/invoiceIn/front/descriptor/index.js b/modules/invoiceIn/front/descriptor/index.js
index e005211a38..8fe270fa08 100644
--- a/modules/invoiceIn/front/descriptor/index.js
+++ b/modules/invoiceIn/front/descriptor/index.js
@@ -112,7 +112,7 @@ class Controller extends Descriptor {
}
isAgricultural() {
- return this.invoiceIn.supplier.sageWithholdingFk == this.config[0].sageWithholdingFk;
+ return this.invoiceIn.supplier.sageWithholdingFk == this.config[0].sageFarmerWithholdingFk;
}
}
diff --git a/modules/invoiceOut/back/methods/invoiceOut/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js
index 748e2df17b..f8d42072cf 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/download.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/download.js
@@ -1,5 +1,6 @@
const fs = require('fs-extra');
const path = require('path');
+const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
Self.remoteMethodCtx('download', {
@@ -66,7 +67,7 @@ module.exports = Self => {
console.error(err);
});
- if (process.env.NODE_ENV == 'test') {
+ if (!isProduction()) {
try {
await fs.access(file.path);
} catch (error) {
diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceOutPdf.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceOutPdf.js
index 941d31596b..f4bb6baa9b 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/invoiceOutPdf.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceOutPdf.js
@@ -31,7 +31,8 @@ module.exports = Self => {
http: {
path: '/:reference/invoice-out-pdf',
verb: 'GET'
- }
+ },
+ accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.invoiceOutPdf = async(ctx, reference) => {
diff --git a/modules/invoiceOut/back/methods/invoiceOut/makePdfAndNotify.js b/modules/invoiceOut/back/methods/invoiceOut/makePdfAndNotify.js
index 4bba2498f3..e2dc15993f 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/makePdfAndNotify.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/makePdfAndNotify.js
@@ -33,7 +33,6 @@ module.exports = Self => {
try {
await Self.makePdf(id, options);
} catch (err) {
- console.error(err);
throw new UserError('Error while generating PDF', 'pdfError');
}
diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js
index fc88308856..76ef29604a 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js
@@ -59,7 +59,7 @@ module.exports = Self => {
`CREATE OR REPLACE TEMPORARY TABLE tmp.filter
ENGINE = MEMORY
SELECT co.code company,
- cou.country,
+ cou.name country,
c.id clientId,
c.socialName clientSocialName,
u.nickname workerSocialName,
diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js
index 8e234d7ccc..b5eb9bed58 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js
@@ -36,6 +36,11 @@ module.exports = Self => {
type: 'number',
required: true
},
+ {
+ arg: 'checked',
+ type: 'boolean',
+ required: true
+ },
],
returns: {
type: 'boolean',
@@ -51,6 +56,7 @@ module.exports = Self => {
const models = Self.app.models;
const myOptions = {userId: ctx.req.accessToken.userId};
const {id, refFk, newClientFk, cplusRectificationTypeFk, siiTypeInvoiceOutFk, invoiceCorrectionTypeFk} = ctx.args;
+ const checked = ctx.args.checked;
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
@@ -96,9 +102,10 @@ module.exports = Self => {
await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions);
- const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions);
-
- return invoiceId;
+ if (!checked) {
+ const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions);
+ return invoiceId;
+ }
} catch (e) {
if (tx) await tx.rollback();
throw e;
diff --git a/modules/invoiceOut/back/models/invoice-out.js b/modules/invoiceOut/back/models/invoice-out.js
index e4fcc1a69a..b0e05b6262 100644
--- a/modules/invoiceOut/back/models/invoice-out.js
+++ b/modules/invoiceOut/back/models/invoice-out.js
@@ -1,6 +1,7 @@
const print = require('vn-print');
const path = require('path');
const UserError = require('vn-loopback/util/user-error');
+const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
require('../methods/invoiceOut/filter')(Self);
@@ -59,7 +60,7 @@ module.exports = Self => {
hasPdf: true
}, options);
- if (process.env.NODE_ENV !== 'test') {
+ if (isProduction()) {
await print.storage.write(buffer, {
type: 'invoice',
path: pdfFile.path,
diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html
index 1bf34831e4..da04c8e728 100644
--- a/modules/invoiceOut/front/descriptor-menu/index.html
+++ b/modules/invoiceOut/front/descriptor-menu/index.html
@@ -1,15 +1,3 @@
-
-
-
-
- {{::description}}
+ {{ ::description}}
@@ -226,7 +214,7 @@
+
+
+
+
diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js
index 5184c137ed..0d7fb32dd5 100644
--- a/modules/invoiceOut/front/descriptor-menu/index.js
+++ b/modules/invoiceOut/front/descriptor-menu/index.js
@@ -7,6 +7,7 @@ class Controller extends Section {
super($element, $);
this.vnReport = vnReport;
this.vnEmail = vnEmail;
+ this.checked = true;
}
get invoiceOut() {
@@ -23,6 +24,26 @@ class Controller extends Section {
return this.aclService.hasAny(['invoicing']);
}
+ get isChecked() {
+ return this.checked;
+ }
+
+ set isChecked(value) {
+ this.checked = value;
+ }
+
+ $onInit() {
+ this.$http.get(`CplusRectificationTypes`, {filter: {order: 'description'}})
+ .then(res => {
+ this.cplusRectificationTypes = res.data;
+ this.cplusRectificationType = res.data.filter(type => type.description == 'I – Por diferencias')[0].id;
+ });
+ this.$http.get(`SiiTypeInvoiceOuts`, {filter: {where: {code: {like: 'R%'}}}})
+ .then(res => {
+ this.siiTypeInvoiceOuts = res.data;
+ this.siiTypeInvoiceOut = res.data.filter(type => type.code == 'R4')[0].id;
+ });
+ }
loadData() {
const filter = {
include: [
@@ -34,7 +55,7 @@ class Controller extends Section {
}, {
relation: 'client',
scope: {
- fields: ['id', 'name', 'email']
+ fields: ['id', 'name', 'email', 'hasToInvoiceByAddress']
}
}
]
@@ -136,12 +157,24 @@ class Controller extends Section {
newClientFk: this.clientId,
cplusRectificationTypeFk: this.cplusRectificationType,
siiTypeInvoiceOutFk: this.siiTypeInvoiceOut,
- invoiceCorrectionTypeFk: this.invoiceCorrectionType
+ invoiceCorrectionTypeFk: this.invoiceCorrectionType,
+ checked: this.checked
};
- this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => {
- const invoiceId = res.data;
- this.vnApp.showSuccess(this.$t('Transferred invoice'));
- this.$state.go('invoiceOut.card.summary', {id: invoiceId});
+
+ this.$http.get(`Clients/${this.clientId}`).then(response => {
+ const clientData = response.data;
+ const hasToInvoiceByAddress = clientData.hasToInvoiceByAddress;
+
+ if (this.checked && hasToInvoiceByAddress) {
+ if (!window.confirm(this.$t('confirmTransferInvoice')))
+ return;
+ }
+
+ this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => {
+ const invoiceId = res.data;
+ this.vnApp.showSuccess(this.$t('Transferred invoice'));
+ this.$state.go('invoiceOut.card.summary', {id: invoiceId});
+ });
});
}
}
diff --git a/modules/invoiceOut/front/descriptor-menu/locale/en.yml b/modules/invoiceOut/front/descriptor-menu/locale/en.yml
index 8fad5f25e7..32ea03442b 100644
--- a/modules/invoiceOut/front/descriptor-menu/locale/en.yml
+++ b/modules/invoiceOut/front/descriptor-menu/locale/en.yml
@@ -1,3 +1,7 @@
The following refund tickets have been created: "The following refund tickets have been created: {{ticketIds}}"
Transfer invoice to...: Transfer invoice to...
-Cplus Type: Cplus Type
\ No newline at end of file
+Cplus Type: Cplus Type
+transferInvoice: Transfer Invoice
+destinationClient: Bill destination client
+transferInvoiceInfo: New tickets from the destination customer will be generated in the default consignee.
+confirmTransferInvoice: Destination customer has marked to bill by consignee, do you want to continue?
\ No newline at end of file
diff --git a/modules/invoiceOut/front/descriptor-menu/locale/es.yml b/modules/invoiceOut/front/descriptor-menu/locale/es.yml
index 9285fafa7f..92c1098782 100644
--- a/modules/invoiceOut/front/descriptor-menu/locale/es.yml
+++ b/modules/invoiceOut/front/descriptor-menu/locale/es.yml
@@ -24,3 +24,7 @@ Refund...: Abono...
Transfer invoice to...: Transferir factura a...
Rectificative type: Tipo rectificativa
Transferred invoice: Factura transferida
+transferInvoice: Transferir factura
+destinationClient: Facturar cliente destino
+transferInvoiceInfo: Los nuevos tickets del cliente destino serán generados en el consignatario por defecto.
+confirmTransferInvoice: El cliente destino tiene marcado facturar por consignatario, ¿desea continuar?
\ No newline at end of file
diff --git a/modules/invoiceOut/front/index/manual/index.html b/modules/invoiceOut/front/index/manual/index.html
index 5872911e46..3b991618d1 100644
--- a/modules/invoiceOut/front/index/manual/index.html
+++ b/modules/invoiceOut/front/index/manual/index.html
@@ -27,7 +27,7 @@
{
accessType: 'READ',
accepts: [{
arg: 'barcode',
- type: 'number',
+ type: 'string',
required: true,
description: 'barcode'
}],
@@ -18,7 +18,7 @@ module.exports = Self => {
}
});
- Self.toItem = async(barcode, options) => {
+ Self.toItem = async (barcode, options) => {
const myOptions = {};
if (typeof options == 'object')
diff --git a/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js b/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js
index 8615b7b86b..2dd43224cc 100644
--- a/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js
+++ b/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js
@@ -1,18 +1,17 @@
-const { models } = require('vn-loopback/server/server');
+const {models} = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context');
-// #6276
describe('ItemShelving upsertItem()', () => {
const warehouseFk = 1;
let ctx;
let options;
let tx;
- beforeEach(async () => {
+ beforeEach(async() => {
ctx = {
req: {
- accessToken: { userId: 9 },
- headers: { origin: 'http://localhost' }
+ accessToken: {userId: 9},
+ headers: {origin: 'http://localhost'}
},
args: {}
};
@@ -21,35 +20,35 @@ describe('ItemShelving upsertItem()', () => {
active: ctx.req
});
- options = { transaction: tx };
+ options = {transaction: tx};
tx = await models.ItemShelving.beginTransaction({});
options.transaction = tx;
});
- afterEach(async () => {
+ afterEach(async() => {
await tx.rollback();
});
- it('should add two new records', async () => {
- const shelvingFk = 'ZPP';
+ it('should add two new records', async() => {
+ const shelvingFk = 'GVC';
const items = [1, 1, 1, 2];
await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options);
- const itemShelvings = await models.ItemShelving.find({ where: { shelvingFk } }, options);
+ const itemShelvings = await models.ItemShelving.find({where: {shelvingFk}}, options);
expect(itemShelvings.length).toEqual(2);
});
- it('should update the visible items', async () => {
+ it('should update the visible items', async() => {
const shelvingFk = 'GVC';
const items = [2, 2];
- const { visible: visibleItemsBefore } = await models.ItemShelving.findOne({
- where: { shelvingFk, itemFk: items[0] }
+ const {visible: visibleItemsBefore} = await models.ItemShelving.findOne({
+ where: {shelvingFk, itemFk: items[0]}
}, options);
await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options);
- const { visible: visibleItemsAfter } = await models.ItemShelving.findOne({
- where: { shelvingFk, itemFk: items[0] }
+ const {visible: visibleItemsAfter} = await models.ItemShelving.findOne({
+ where: {shelvingFk, itemFk: items[0]}
}, options);
expect(visibleItemsAfter).toEqual(visibleItemsBefore + 2);
diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js
index d4e2d0f74a..207f8020f4 100644
--- a/modules/item/back/methods/item/getBalance.js
+++ b/modules/item/back/methods/item/getBalance.js
@@ -27,8 +27,11 @@ module.exports = Self => {
const where = filter.where;
const query = 'CALL vn.item_getBalance(?, ?, ?)';
+ if (where?.date) {
+ where.date = new Date(where.date);
+ where.date.setHours(0, 0, 0, 0);
+ }
const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, where.date], myOptions);
-
for (const entry of diary)
if (entry.clientType === 'loses') entry.highlighted = true;
diff --git a/modules/item/back/methods/item/labelPdf.js b/modules/item/back/methods/item/labelPdf.js
index c2462353d7..d7a50397e7 100644
--- a/modules/item/back/methods/item/labelPdf.js
+++ b/modules/item/back/methods/item/labelPdf.js
@@ -51,7 +51,8 @@ module.exports = Self => {
http: {
path: '/:id/label-pdf',
verb: 'GET'
- }
+ },
+ accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.labelPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label');
diff --git a/modules/item/back/models/expense.json b/modules/item/back/models/expense.json
index 468063602f..e661cbc666 100644
--- a/modules/item/back/models/expense.json
+++ b/modules/item/back/models/expense.json
@@ -9,7 +9,7 @@
"properties": {
"id": {
"id": true,
- "type": "number",
+ "type": "string",
"description": "Identifier"
},
"name": {
diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json
index 9d48dcbfb1..10cff3e040 100644
--- a/modules/item/back/models/item.json
+++ b/modules/item/back/models/item.json
@@ -155,6 +155,9 @@
"minQuantity": {
"type": "number",
"description": "Min quantity"
+ },
+ "photoMotivation": {
+ "type": "string"
}
},
"relations": {
diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html
index 5fe84591f2..13c671d29b 100644
--- a/modules/item/front/summary/index.html
+++ b/modules/item/front/summary/index.html
@@ -181,7 +181,7 @@
ng-show="!$ctrl.isBuyer && !$ctrl.isAdministrative">
Tax
-
diff --git a/modules/item/front/tax/index.html b/modules/item/front/tax/index.html
index e993f974fb..78858704fb 100644
--- a/modules/item/front/tax/index.html
+++ b/modules/item/front/tax/index.html
@@ -15,7 +15,7 @@
{
Self.remoteMethodCtx('upload', {
@@ -111,7 +112,7 @@ module.exports = Self => {
const destinationFile = path.join(
accessContainer.client.root, accessContainer.name, appName, `${toVersion}.7z`);
- if (process.env.NODE_ENV == 'test')
+ if (!isProduction())
await fs.unlink(srcFile);
else {
await fs.move(srcFile, destinationFile, {
diff --git a/modules/route/back/methods/roadmap/clone.js b/modules/route/back/methods/roadmap/clone.js
index 456ed823d4..b74cf803c7 100644
--- a/modules/route/back/methods/roadmap/clone.js
+++ b/modules/route/back/methods/roadmap/clone.js
@@ -62,12 +62,12 @@ module.exports = Self => {
const clone = await models.Roadmap.create(roadmap, options);
- const expeditionTrucks = roadmap.expeditionTruck();
- expeditionTrucks.map(expeditionTruck => {
- expeditionTruck.roadmapFk = clone.id;
- return expeditionTruck;
+ const roadmapStops = roadmap.roadmapStop();
+ roadmapStops.map(roadmapStop => {
+ roadmapStop.roadmapFk = clone.id;
+ return roadmapStop;
});
- await models.ExpeditionTruck.create(expeditionTrucks, options);
+ await models.RoadmapStop.create(roadmapStops, options);
}
await tx.commit();
diff --git a/modules/route/back/methods/route/getExternalCmrs.js b/modules/route/back/methods/route/getExternalCmrs.js
index b8cd1041a1..89536f50a8 100644
--- a/modules/route/back/methods/route/getExternalCmrs.js
+++ b/modules/route/back/methods/route/getExternalCmrs.js
@@ -103,7 +103,7 @@ module.exports = Self => {
SELECT t.cmrFk,
t.id ticketFk,
t.routeFk,
- co.country,
+ co.name country,
t.clientFk,
IF(sub.id, TRUE, FALSE) hasCmrDms,
DATE(t.shipped) shipped
diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js
index 0e7c9fe207..c0b952b701 100644
--- a/modules/route/back/methods/route/getTickets.js
+++ b/modules/route/back/methods/route/getTickets.js
@@ -87,10 +87,6 @@ module.exports = Self => {
const where = filter.where;
where['r.id'] = filter.id;
- where.and = [{or: [
- {'t.packages': {gt: 0}},
- {and: [{'ot.code': 'delivery'}, {'tob.observationTypeFk': {neq: null}}]}
- ]}];
stmt.merge(conn.makeWhere(filter.where));
stmt.merge(conn.makeGroupBy('t.id'));
diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json
index 6cf8da9868..0cb48852f4 100644
--- a/modules/route/back/model-config.json
+++ b/modules/route/back/model-config.json
@@ -8,7 +8,7 @@
"DeliveryPoint": {
"dataSource": "vn"
},
- "ExpeditionTruck": {
+ "RoadmapStop": {
"dataSource": "vn"
},
"Roadmap": {
@@ -25,5 +25,8 @@
},
"RoutesMonitor": {
"dataSource": "vn"
+ },
+ "ExpeditionTruck": {
+ "dataSource": "vn"
}
}
diff --git a/modules/route/back/models/expedition-truck.json b/modules/route/back/models/expedition-truck.json
index 8edc7347f0..fc9cd90f0c 100644
--- a/modules/route/back/models/expedition-truck.json
+++ b/modules/route/back/models/expedition-truck.json
@@ -1,43 +1,9 @@
{
"name": "ExpeditionTruck",
- "base": "VnModel",
+ "base": "RoadmapStop",
"options": {
"mysql": {
"table": "expeditionTruck"
}
- },
- "properties": {
- "id": {
- "type": "number",
- "id": true,
- "description": "Identifier"
- },
- "roadmapFk": {
- "type": "number"
- },
- "warehouseFk": {
- "type": "number"
- },
- "eta": {
- "type": "date"
- },
- "description": {
- "type": "string"
- },
- "userFk": {
- "type": "number"
- }
- },
- "relations": {
- "roadmap": {
- "type": "belongsTo",
- "model": "Roadmap",
- "foreignKey": "roadmapFk"
- },
- "warehouse": {
- "type": "belongsTo",
- "model": "Warehouse",
- "foreignKey": "warehouseFk"
- }
- }
+ }
}
diff --git a/modules/route/back/models/roadmap.json b/modules/route/back/models/roadmap.json
index 2f6bb8c02c..01572d718b 100644
--- a/modules/route/back/models/roadmap.json
+++ b/modules/route/back/models/roadmap.json
@@ -54,9 +54,9 @@
"model": "Supplier",
"foreignKey": "supplierFk"
},
- "expeditionTruck": {
+ "roadmapStop": {
"type": "hasMany",
- "model": "ExpeditionTruck",
+ "model": "RoadmapStop",
"foreignKey": "roadmapFk"
}
}
diff --git a/modules/route/back/models/roadmapStop.json b/modules/route/back/models/roadmapStop.json
new file mode 100644
index 0000000000..51aa3a6db1
--- /dev/null
+++ b/modules/route/back/models/roadmapStop.json
@@ -0,0 +1,43 @@
+{
+ "name": "RoadmapStop",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "roadmapStop"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "roadmapFk": {
+ "type": "number"
+ },
+ "warehouseFk": {
+ "type": "number"
+ },
+ "eta": {
+ "type": "date"
+ },
+ "description": {
+ "type": "string"
+ },
+ "userFk": {
+ "type": "number"
+ }
+ },
+ "relations": {
+ "roadmap": {
+ "type": "belongsTo",
+ "model": "Roadmap",
+ "foreignKey": "roadmapFk"
+ },
+ "warehouse": {
+ "type": "belongsTo",
+ "model": "Warehouse",
+ "foreignKey": "warehouseFk"
+ }
+ }
+}
diff --git a/modules/route/front/roadmap/stops/index.html b/modules/route/front/roadmap/stops/index.html
index b69492a21a..82f30c3263 100644
--- a/modules/route/front/roadmap/stops/index.html
+++ b/modules/route/front/roadmap/stops/index.html
@@ -1,22 +1,22 @@
@@ -61,9 +61,9 @@
-
- {{expeditionTruck.warehouse.name}}
- {{expeditionTruck.eta | date:'dd/MM/yyyy HH:mm'}}
+
+ {{roadmapStop.warehouse.name}}
+ {{roadmapStop.eta | date:'dd/MM/yyyy HH:mm'}}
@@ -75,14 +75,14 @@
+ ng-model="$ctrl.roadmapStop.eta">
diff --git a/modules/route/front/roadmap/summary/index.js b/modules/route/front/roadmap/summary/index.js
index 041b43ce34..46abe5ca2f 100644
--- a/modules/route/front/roadmap/summary/index.js
+++ b/modules/route/front/roadmap/summary/index.js
@@ -20,7 +20,7 @@ class Controller extends Component {
include: [
{relation: 'supplier'},
{relation: 'worker'},
- {relation: 'expeditionTruck',
+ {relation: 'roadmapStop',
scope: {
include: [
{relation: 'warehouse'}
@@ -36,19 +36,19 @@ class Controller extends Component {
const eta = new Date(this.roadmap.etd);
eta.setDate(eta.getDate() + 1);
- this.expeditionTruck = {eta: eta};
+ this.roadmapStop = {eta: eta};
}
onAddAccept() {
try {
const data = {
roadmapFk: this.roadmap.id,
- warehouseFk: this.expeditionTruck.warehouseFk,
- eta: this.expeditionTruck.eta,
- description: this.expeditionTruck.description
+ warehouseFk: this.roadmapStop.warehouseFk,
+ eta: this.roadmapStop.eta,
+ description: this.roadmapStop.description
};
- this.$http.post(`ExpeditionTrucks`, data)
+ this.$http.post(`RoadmapStops`, data)
.then(() => {
this.loadData();
this.vnApp.showSuccess(this.$t('Data saved!'));
diff --git a/modules/supplier/back/methods/supplier/getItemsPackaging.js b/modules/supplier/back/methods/supplier/getItemsPackaging.js
index c06195a554..8a27c89c4b 100644
--- a/modules/supplier/back/methods/supplier/getItemsPackaging.js
+++ b/modules/supplier/back/methods/supplier/getItemsPackaging.js
@@ -33,7 +33,7 @@ module.exports = Self => {
JOIN vn.item i ON i.id = b.itemFk
WHERE e.id = ? AND e.supplierFk = ?
GROUP BY i.id
- ) SELECT i.id, i.name, et.quantity, SUM(b.quantity) quantityTotal, et.printedStickers
+ ) SELECT i.id, i.name, et.quantity, SUM(b.quantity) quantityTotal, et.printedStickers, ic.url
FROM vn.buy b
JOIN vn.item i ON i.id = b.itemFk
JOIN vn.entry e ON e.id = b.entryFk
@@ -41,6 +41,7 @@ module.exports = Self => {
JOIN vn.buyConfig bc ON bc.monthsAgo
JOIN vn.travel t ON t.id = e.travelFk
LEFT JOIN entryTmp et ON et.id = i.id
+ JOIN hedera.imageConfig ic
WHERE e.supplierFk = ?
AND i.family IN ('EMB', 'CONT')
AND b.created > (util.VN_CURDATE() - INTERVAL bc.monthsAgo MONTH)
diff --git a/modules/supplier/front/address/create/index.html b/modules/supplier/front/address/create/index.html
index e45539445c..e3f8836415 100644
--- a/modules/supplier/front/address/create/index.html
+++ b/modules/supplier/front/address/create/index.html
@@ -43,7 +43,7 @@
rule>
{{code}} - {{town.name}} ({{town.province.name}},
- {{town.province.country.country}})
+ {{town.province.country.name}})
{{name}}, {{province.name}}
- ({{province.country.country}})
+ ({{province.country.name}})
- {{name}} ({{country.country}})
+ {{name}} ({{country.name}})
diff --git a/modules/supplier/front/address/edit/index.html b/modules/supplier/front/address/edit/index.html
index b6f90134bc..b966023dae 100644
--- a/modules/supplier/front/address/edit/index.html
+++ b/modules/supplier/front/address/edit/index.html
@@ -41,7 +41,7 @@
rule>
{{code}} - {{town.name}} ({{town.province.name}},
- {{town.province.country.country}})
+ {{town.province.country.name}})
{{name}}, {{province.name}}
- ({{province.country.country}})
+ ({{province.country.name}})
- {{name}} ({{country.country}})
+ {{name}} ({{country.name}})
diff --git a/modules/supplier/front/fiscal-data/index.html b/modules/supplier/front/fiscal-data/index.html
index 3fe67762fb..6455bf3fdb 100644
--- a/modules/supplier/front/fiscal-data/index.html
+++ b/modules/supplier/front/fiscal-data/index.html
@@ -16,7 +16,7 @@
auto-load="true"
url="Countries"
data="countries"
- order="country">
+ order="name">
{{code}} - {{town.name}} ({{town.province.name}},
- {{town.province.country.country}})
+ {{town.province.country.name}})
{{name}}, {{province.name}}
- ({{province.country.country}})
+ ({{province.country.name}})
- {{name}} ({{country.country}})
+ {{name}} ({{country.name}})
@@ -198,7 +198,7 @@
vn-name="country"
ng-model="$ctrl.supplier.countryFk"
data="countries"
- show-field="country"
+ show-field="name"
value-field="id"
rule>
diff --git a/modules/supplier/front/summary/index.html b/modules/supplier/front/summary/index.html
index d1b3ee20a9..5ba713fcf3 100644
--- a/modules/supplier/front/summary/index.html
+++ b/modules/supplier/front/summary/index.html
@@ -162,7 +162,7 @@
+ value="{{::$ctrl.summary.country.name}}">
diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js
index 00310f33c3..7c17d00106 100644
--- a/modules/ticket/back/methods/ticket-request/confirm.js
+++ b/modules/ticket/back/methods/ticket-request/confirm.js
@@ -19,6 +19,9 @@ module.exports = Self => {
type: 'number',
required: true,
description: 'The requested item quantity',
+ }, {
+ arg: 'attenderFk',
+ type: 'number'
}],
returns: {
type: 'object',
@@ -73,12 +76,14 @@ module.exports = Self => {
ticketFk: request.ticketFk,
itemFk: ctx.args.itemFk,
quantity: ctx.args.quantity,
+ attenderFk: ctx.args.attenderFk,
concept: item.name
}, myOptions);
await request.updateAttributes({
saleFk: sale.id,
itemFk: sale.itemFk,
- isOk: true
+ isOk: true,
+ attenderFk: sale.attenderFk,
}, myOptions);
const query = `CALL vn.sale_calculateComponent(?, NULL)`;
diff --git a/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js b/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js
index 3d37221c4e..3d39ea278d 100644
--- a/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js
+++ b/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js
@@ -2,10 +2,12 @@ const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('ticket setDelivered()', () => {
- const userId = 50;
+ const userId = 49;
const activeCtx = {
accessToken: {userId: userId},
+ __: value => value
};
+ const ctx = {req: activeCtx};
beforeAll(async() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
@@ -19,8 +21,6 @@ describe('ticket setDelivered()', () => {
try {
const options = {transaction: tx};
- const ctx = {req: {accessToken: {userId: 49}}};
-
const originalTicketOne = await models.Ticket.findById(8, null, options);
const originalTicketTwo = await models.Ticket.findById(10, null, options);
diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js
index d35bd1e3ea..35b9b1e379 100644
--- a/modules/ticket/back/methods/ticket/closeAll.js
+++ b/modules/ticket/back/methods/ticket/closeAll.js
@@ -138,12 +138,13 @@ module.exports = Self => {
JOIN alertLevel al ON al.id = ts.alertLevel
JOIN agencyMode am ON am.id = t.agencyModeFk
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
- JOIN zone z ON z.id = t.zoneFk
+ LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id
SET t.routeFk = NULL
WHERE DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?)
- AND al.code NOT IN('DELIVERED','PACKED')
- AND t.routeFk
- AND z.name LIKE '%MADRID%'`, [toDate, toDate], {userId: ctx.req.accessToken.userId});
+ AND al.code NOT IN ('DELIVERED', 'PACKED')
+ AND NOT t.packages
+ AND tob.id IS NULL
+ AND t.routeFk`, [toDate, toDate], {userId: ctx.req.accessToken.userId});
return {
message: 'Success'
diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js
index 8c59dc3b0c..fba39f18fe 100644
--- a/modules/ticket/back/methods/ticket/closure.js
+++ b/modules/ticket/back/methods/ticket/closure.js
@@ -13,8 +13,6 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
const failedtickets = [];
for (const ticket of tickets) {
try {
- await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId});
-
await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'M');
await Self.rawSql(
`CALL vn.ticket_closeByTicket(?)`,
diff --git a/modules/ticket/back/methods/ticket/docuwareDownload.js b/modules/ticket/back/methods/ticket/docuwareDownload.js
index 7084bbdd4b..f895095705 100644
--- a/modules/ticket/back/methods/ticket/docuwareDownload.js
+++ b/modules/ticket/back/methods/ticket/docuwareDownload.js
@@ -28,7 +28,8 @@ module.exports = Self => {
http: {
path: `/:id/docuwareDownload`,
verb: 'GET'
- }
+ },
+ accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.docuwareDownload = async id => {
diff --git a/modules/ticket/back/methods/ticket/specs/state.spec.js b/modules/ticket/back/methods/ticket/specs/state.spec.js
index 947e72b792..d908aa2efc 100644
--- a/modules/ticket/back/methods/ticket/specs/state.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/state.spec.js
@@ -7,6 +7,7 @@ describe('ticket state()', () => {
const productionId = 49;
const activeCtx = {
accessToken: {userId: 9},
+ __: value => value
};
const ctx = {req: activeCtx};
const now = Date.vnNew();
@@ -88,7 +89,8 @@ describe('ticket state()', () => {
const ticket = await models.Ticket.create(sampleTicket, options);
activeCtx.accessToken.userId = productionId;
- const params = {ticketFk: ticket.id, stateFk: 3};
+ const stateOk = await models.State.findOne({where: {code: 'OK'}}, options);
+ const params = {ticketFk: ticket.id, stateFk: stateOk.id};
const ticketTracking = await models.Ticket.state(ctx, params, options);
@@ -112,16 +114,68 @@ describe('ticket state()', () => {
const options = {transaction: tx};
const ticket = await models.Ticket.create(sampleTicket, options);
- const ctx = {req: {accessToken: {userId: 18}}};
+ activeCtx.accessToken.userId = salesPersonId;
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
- const params = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1};
- const res = await models.Ticket.state(ctx, params, options);
+ const paramsAssigned = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1};
+ const resAssigned = await models.Ticket.state(ctx, paramsAssigned, options);
- expect(res.ticketFk).toBe(params.ticketFk);
- expect(res.stateFk).toBe(params.stateFk);
- expect(res.userFk).toBe(params.userFk);
- expect(res.userFk).toBe(1);
- expect(res.id).toBeDefined();
+ expect(resAssigned.ticketFk).toBe(paramsAssigned.ticketFk);
+ expect(resAssigned.stateFk).toBe(paramsAssigned.stateFk);
+ expect(resAssigned.userFk).toBe(paramsAssigned.userFk);
+ expect(resAssigned.userFk).toBe(1);
+ expect(resAssigned.id).toBeDefined();
+
+ activeCtx.accessToken.userId = productionId;
+ const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
+ const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId};
+ const resPacked = await models.Ticket.state(ctx, paramsPacked, options);
+
+ expect(resPacked.stateFk).toBe(paramsPacked.stateFk);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('Should equalize the quantities of quantity and originalQuantity' +
+ ' if they are different', async() => {
+ const tx = await models.TicketTracking.beginTransaction({});
+
+ try {
+ const options = {transaction: tx};
+
+ const ticket = await models.Ticket.create(sampleTicket, options);
+ activeCtx.accessToken.userId = salesPersonId;
+
+ const sampleSale = {
+ ticketFk: ticket.id,
+ itemFk: 1,
+ concept: 'Test',
+ quantity: 10,
+ originalQuantity: 6
+ };
+ await models.Sale.create(sampleSale, options);
+ const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
+ const paramsAssigned = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1};
+ const resAssigned = await models.Ticket.state(ctx, paramsAssigned, options);
+
+ expect(resAssigned.ticketFk).toBe(paramsAssigned.ticketFk);
+ expect(resAssigned.stateFk).toBe(paramsAssigned.stateFk);
+ expect(resAssigned.userFk).toBe(paramsAssigned.userFk);
+ expect(resAssigned.userFk).toBe(1);
+ expect(resAssigned.id).toBeDefined();
+
+ activeCtx.accessToken.userId = productionId;
+ const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
+ const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId};
+ const resPacked = await models.Ticket.state(ctx, paramsPacked, options);
+
+ const sale = await models.Sale.findOne({where: {ticketFk: ticket.id}}, options);
+
+ expect(resPacked.stateFk).toBe(paramsPacked.stateFk);
+ expect(sale.quantity).toBe(sale.originalQuantity);
await tx.rollback();
} catch (e) {
diff --git a/modules/ticket/back/methods/ticket/state.js b/modules/ticket/back/methods/ticket/state.js
index fea9475f8c..9b0b862f24 100644
--- a/modules/ticket/back/methods/ticket/state.js
+++ b/modules/ticket/back/methods/ticket/state.js
@@ -64,7 +64,63 @@ module.exports = Self => {
if ((ticketState && !oldStateAllowed) || !newStateAllowed)
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
- await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [params.ticketFk, params.code], myOptions);
+ const ticket = await models.Ticket.findById(params.ticketFk, {
+ include: [{
+ relation: 'client',
+ scope: {
+ fields: ['salesPersonFk']
+ }
+ }],
+ fields: ['id', 'clientFk']
+ }, myOptions);
+
+ const salesPersonFk = ticket.client().salesPersonFk;
+ if (salesPersonFk) {
+ const sales = await Self.rawSql(`
+ SELECT DISTINCT s.id,
+ s.itemFk,
+ s.concept,
+ s.originalQuantity AS oldQuantity,
+ s.quantity AS newQuantity
+ FROM vn.sale s
+ JOIN vn.saleTracking st ON st.saleFk = s.id
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.client c ON c.id = t.clientFk
+ JOIN vn.ticketState ts ON ts.ticketFk = t.id
+ JOIN vn.state s2 ON s2.id = ts.stateFk
+ WHERE s.ticketFk = ?
+ AND st.isChecked
+ AND s.originalQuantity IS NOT NULL
+ AND s.originalQuantity <> s.quantity
+ AND s2.\`order\` < (SELECT \`order\` FROM vn.state WHERE code = 'CHECKED')
+ ORDER BY st.created DESC
+ `, [params.ticketFk], myOptions);
+
+ let changes = '';
+ const url = await models.Url.getUrl();
+ const $t = ctx.req.__;
+ for (let sale of sales) {
+ changes += `\r\n-` + $t('Changes in sales', {
+ itemId: sale.itemFk,
+ concept: sale.concept,
+ oldQuantity: sale.oldQuantity,
+ newQuantity: sale.newQuantity,
+ itemUrl: `${url}item/${sale.itemFk}/summary`
+ });
+ const currentSale = await models.Sale.findById(sale.id, null, myOptions);
+ await currentSale.updateAttributes({
+ originalQuantity: currentSale.quantity
+ }, myOptions);
+ }
+
+ const message = $t('Changed sale quantity', {
+ ticketId: ticket.id,
+ changes: changes,
+ ticketUrl: `${url}ticket/${ticket.id}/sale`
+ });
+ await models.Chat.sendCheckingPresence(ctx, salesPersonFk, message, myOptions);
+ }
+ await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticket.id, params.code], myOptions);
const ticketTracking = await models.TicketTracking.findOne({
where: {ticketFk: params.ticketFk},
diff --git a/modules/ticket/back/models/expeditionPallet.json b/modules/ticket/back/models/expeditionPallet.json
index cab3af6ecf..64b3092ae7 100644
--- a/modules/ticket/back/models/expeditionPallet.json
+++ b/modules/ticket/back/models/expeditionPallet.json
@@ -23,9 +23,9 @@
}
},
"relations": {
- "expeditionTruck": {
+ "roadmapStop": {
"type": "belongsTo",
- "model": "ExpeditionTruck",
+ "model": "RoadmapStop",
"foreignKey": "truckFk"
}
}
diff --git a/modules/ticket/back/models/ticket-log.json b/modules/ticket/back/models/ticket-log.json
index 32b4afd13b..d75589f115 100644
--- a/modules/ticket/back/models/ticket-log.json
+++ b/modules/ticket/back/models/ticket-log.json
@@ -8,7 +8,8 @@
},
"properties": {
"id": {
- "type": "string"
+ "type": "number",
+ "id": true
},
"originFk": {
"type": "number"
diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js
index 52cac141c2..32f2454543 100644
--- a/modules/ticket/front/descriptor-menu/index.js
+++ b/modules/ticket/front/descriptor-menu/index.js
@@ -37,18 +37,19 @@ class Controller extends Section {
});
const filter = {
- fields: ['originFk', 'creationDate', 'newInstance'],
+ fields: ['id', 'originFk', 'creationDate', 'newInstance'],
where: {
originFk: value,
newInstance: {like: '%"isDeleted":true%'}
},
- order: 'creationDate DESC'
+ order: 'creationDate DESC',
+ limit: 1
};
- this.$http.get(`TicketLogs/findOne`, {filter})
+ this.$http.get(`TicketLogs`, {filter})
.then(res => {
- if (res && res.data) {
+ if (res && res.data && res.data.length) {
const now = Date.vnNew();
- const maxDate = new Date(res.data.creationDate);
+ const maxDate = new Date(res.data[0].creationDate);
maxDate.setHours(maxDate.getHours() + 1);
if (now <= maxDate)
return this.canRestoreTicket = true;
diff --git a/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js b/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js
index 8964584551..8856371189 100644
--- a/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js
+++ b/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js
@@ -1,3 +1,5 @@
+const moment = require('moment');
+
module.exports = Self => {
Self.remoteMethodCtx('resendWeeklyHourEmail', {
description: 'Send the records for the week of the date provided',
@@ -31,7 +33,8 @@ module.exports = Self => {
Object.assign(myOptions, options);
const yearNumber = dated.getFullYear();
- const weekNumber = getWeekNumber(dated);
+ const weekNumber = moment(dated).isoWeek();
+
const workerTimeControlMail = await models.WorkerTimeControlMail.findOne({
where: {
workerFk: workerId,
@@ -54,15 +57,4 @@ module.exports = Self => {
return false;
};
-
- function getWeekNumber(date) {
- const tempDate = new Date(date);
- let dayOfWeek = tempDate.getDay();
- dayOfWeek = (dayOfWeek === 0) ? 7 : dayOfWeek;
- const firstDayOfWeek = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() - (dayOfWeek - 1));
- const firstDayOfYear = new Date(tempDate.getFullYear(), 0, 1);
- const differenceInMilliseconds = firstDayOfWeek.getTime() - firstDayOfYear.getTime();
- const weekNumber = Math.floor(differenceInMilliseconds / (1000 * 60 * 60 * 24 * 7)) + 1;
- return weekNumber;
- }
};
diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js
index d628d0a2b4..2de1d6e4dc 100644
--- a/modules/worker/back/methods/worker/createAbsence.js
+++ b/modules/worker/back/methods/worker/createAbsence.js
@@ -98,6 +98,22 @@ module.exports = Self => {
if (isHalfHoliday && hasHalfHoliday)
throw new UserError(`Cannot add more than one '1/2 day vacation'`);
+ const isFestive = absenceType.isFestiveEligible;
+
+ const workCenter = await models.Business.findOne({
+ where: {id: args.businessFk}
+ },);
+
+ const [holiday] = await models.CalendarHoliday.find({
+ where: {
+ dated: args.dated,
+ workCenterFk: workCenter.workCenterFk
+ }
+ });
+
+ if (holiday && isFestive)
+ throw new UserError(`Cannot add holidays on this day`);
+
const absence = await models.Calendar.create({
businessFk: labour.businessFk,
dayOffTypeFk: args.absenceTypeId,
diff --git a/modules/worker/back/methods/worker/getAvailablePda.js b/modules/worker/back/methods/worker/getAvailablePda.js
new file mode 100644
index 0000000000..65641a9e61
--- /dev/null
+++ b/modules/worker/back/methods/worker/getAvailablePda.js
@@ -0,0 +1,23 @@
+module.exports = Self => {
+ Self.remoteMethod('getAvailablePda', {
+ description: 'returns devices without user',
+ accessType: 'READ',
+ accepts: [],
+ returns: {
+ type: 'array',
+ root: true
+ },
+ http: {
+ path: `/getAvailablePda`,
+ verb: 'GET'
+ }
+ });
+ Self.getAvailablePda = async() => {
+ return Self.app.models.DeviceProduction.rawSql(
+ `SELECT d.*
+ FROM deviceProduction d
+ LEFT JOIN deviceProductionUser du ON du.deviceProductionFk = d.id
+ WHERE du.deviceProductionFk IS NULL`
+ );
+ };
+};
diff --git a/modules/worker/back/methods/worker/specs/createAbsence.spec.js b/modules/worker/back/methods/worker/specs/createAbsence.spec.js
index 346e43c511..aadaca99b4 100644
--- a/modules/worker/back/methods/worker/specs/createAbsence.spec.js
+++ b/modules/worker/back/methods/worker/specs/createAbsence.spec.js
@@ -104,6 +104,35 @@ describe('Worker createAbsence()', () => {
expect(error.message).toEqual(`Cannot add more than one '1/2 day vacation'`);
});
+ it(`should throw an error when adding a "Holiday" absence if there's a festivity`, async() => {
+ const ctx = {
+ req: {accessToken: {userId: 9}},
+ args: {
+ id: 3,
+ businessFk: 3,
+ absenceTypeId: 1,
+ dated: '2001-12-08T23:00:00.000Z'
+ }
+ };
+ const workerId = 1;
+
+ const tx = await app.models.Calendar.beginTransaction({});
+
+ let error;
+ try {
+ const options = {transaction: tx};
+
+ await app.models.Worker.createAbsence(ctx, workerId, options);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ error = e;
+ }
+
+ expect(error.message).toEqual(`Cannot add holidays on this day`);
+ });
+
it(`should throw an error when adding a absence if the worker has hours recorded that day and not is a half absence`, async() => {
const ctx = {
req: {accessToken: {userId: 19}},
diff --git a/modules/worker/back/methods/worker/specs/getAvailablePda.spec.js b/modules/worker/back/methods/worker/specs/getAvailablePda.spec.js
new file mode 100644
index 0000000000..c7051f0b4b
--- /dev/null
+++ b/modules/worker/back/methods/worker/specs/getAvailablePda.spec.js
@@ -0,0 +1,13 @@
+const models = require('vn-loopback/server/server').models;
+
+describe('worker getAvailablePda()', () => {
+ it('should return a Pda that has no user assigned', async() => {
+ const [{id}] = await models.Worker.getAvailablePda();
+
+ const deviceProductionUser = await models.DeviceProductionUser.findOne({
+ where: {deviceProductionFk: id}
+ });
+
+ expect(!deviceProductionUser).toBeTruthy();
+ });
+});
diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json
index e1a47b7e96..b7c3555113 100644
--- a/modules/worker/back/model-config.json
+++ b/modules/worker/back/model-config.json
@@ -121,6 +121,9 @@
},
"Operator": {
"dataSource": "vn"
+ },
+ "Locker": {
+ "dataSource": "vn"
}
}
diff --git a/modules/worker/back/models/absence-type.json b/modules/worker/back/models/absence-type.json
index 7fc62f780f..2f61033677 100644
--- a/modules/worker/back/models/absence-type.json
+++ b/modules/worker/back/models/absence-type.json
@@ -22,7 +22,10 @@
},
"holidayEntitlementRate": {
"type": "number"
- }
+ },
+ "isFestiveEligible": {
+ "type": "boolean"
+ }
},
"acls": [
{
@@ -32,4 +35,4 @@
"permission": "ALLOW"
}
]
-}
\ No newline at end of file
+}
diff --git a/modules/worker/back/models/device-production-user.js b/modules/worker/back/models/device-production-user.js
new file mode 100644
index 0000000000..8eead58e07
--- /dev/null
+++ b/modules/worker/back/models/device-production-user.js
@@ -0,0 +1,11 @@
+const UserError = require('vn-loopback/util/user-error');
+module.exports = Self => {
+ Self.rewriteDbError(function(err) {
+ if (err.code === 'ER_DUP_ENTRY')
+ return new UserError(`This PDA is already assigned to another user`);
+
+ if (err.code === 'ER_SIGNAL_EXCEPTION' && err.sqlMessage === 'You can only have one active PDA')
+ return new UserError(err.sqlMessage);
+ return err;
+ });
+};
diff --git a/modules/worker/back/models/device-production-user.json b/modules/worker/back/models/device-production-user.json
index 35a90fb50d..a024cc94c8 100644
--- a/modules/worker/back/models/device-production-user.json
+++ b/modules/worker/back/models/device-production-user.json
@@ -14,6 +14,10 @@
}
},
"properties": {
+ "id": {
+ "type": "number",
+ "id": true
+ },
"deviceProductionFk": {
"type": "number",
"id": true
@@ -21,6 +25,9 @@
"userFk": {
"type": "number"
},
+ "simSerialNumber": {
+ "type": "string"
+ },
"created": {
"type": "date"
}
@@ -28,7 +35,7 @@
"relations": {
"deviceProduction": {
"type": "belongsTo",
- "model": "DeviceProduction",
+ "model": "DeviceProduction",
"foreignKey": "deviceProductionFk"
},
"user": {
@@ -36,5 +43,10 @@
"model": "User",
"foreignKey": "userFk"
}
+ },
+ "scope": {
+ "include":{
+ "relation": "deviceProduction"
+ }
}
}
diff --git a/modules/worker/back/models/locker.js b/modules/worker/back/models/locker.js
new file mode 100644
index 0000000000..4475c2cd1c
--- /dev/null
+++ b/modules/worker/back/models/locker.js
@@ -0,0 +1,21 @@
+module.exports = Self => {
+ Self.observe('before save', async ctx => {
+ const models = Self.app.models;
+ const changes = ctx.data || ctx.instance;
+ const instance = ctx.currentInstance;
+
+ const workerFk = changes?.workerFk || instance?.workerFk;
+ if (workerFk) {
+ const locker = await models.Locker.findOne({
+ where: {workerFk}
+ }, ctx.options);
+
+ if (locker) {
+ await Self.rawSql(
+ 'UPDATE locker SET workerFk = NULL where workerFk = ?',
+ [workerFk],
+ ctx.options);
+ }
+ }
+ });
+};
diff --git a/modules/worker/back/models/locker.json b/modules/worker/back/models/locker.json
new file mode 100644
index 0000000000..335fca5a96
--- /dev/null
+++ b/modules/worker/back/models/locker.json
@@ -0,0 +1,23 @@
+{
+ "name": "Locker",
+ "base": "VnModel",
+ "description": "Worker's locker",
+ "options": {
+ "mysql": {
+ "table": "locker"
+ }
+ },
+ "properties": {
+ "code": {
+ "type": "string"
+ },
+ "gender": {
+ "type": "string"
+ }
+ },
+ "scopes": {
+ "codes": {
+ "fields": ["id","code"]
+ }
+ }
+}
diff --git a/modules/worker/back/models/specs/locker.spec.js b/modules/worker/back/models/specs/locker.spec.js
new file mode 100644
index 0000000000..96fca24059
--- /dev/null
+++ b/modules/worker/back/models/specs/locker.spec.js
@@ -0,0 +1,59 @@
+const {models} = require('vn-loopback/server/server');
+
+describe('locker model ', () => {
+ const productionBossId = 50;
+ const hrBuyerId = 124;
+ const hrId = 37;
+ const jessicaJonesId = 1110;
+ const bruceBannerId = 1109;
+ const lockerMaleId = 3;
+ const lockerFemaleId = 5;
+ const lockerNewFemaleId = 6;
+ let ctx;
+ let options;
+ let tx;
+
+ beforeEach(async() => {
+ ctx = {
+ req: {
+ accessToken: {userId: hrId},
+ headers: {origin: 'http://localhost'}
+ },
+ };
+ options = {transaction: tx};
+ tx = await models.Locker.beginTransaction({});
+ options.transaction = tx;
+ });
+
+ afterEach(async() => {
+ await tx.rollback();
+ });
+
+ it('should allocate a locker', async() => {
+ ctx.req.accessToken.userId = productionBossId;
+
+ const locker = await models.Locker.findById(lockerMaleId, null, options);
+ await locker.updateAttributes({workerFk: bruceBannerId}, options);
+
+ expect(locker.workerFk).toEqual(bruceBannerId);
+ });
+
+ it('should take away a locker', async() => {
+ ctx.req.accessToken.userId = hrBuyerId;
+ const locker = await models.Locker.findById(lockerFemaleId, null, options);
+ await locker.updateAttributes({workerFk: null}, options);
+
+ expect(locker.workerFk).toEqual(null);
+ });
+
+ it('should change a locker', async() => {
+ const oldLocker = await models.Locker.findById(lockerFemaleId, null, options);
+ const locker = await models.Locker.findById(lockerNewFemaleId, null, options);
+ await locker.updateAttributes({workerFk: jessicaJonesId}, options);
+ const oldNowLocker = await models.Locker.findById(lockerFemaleId, null, options);
+
+ expect(oldLocker.workerFk).toEqual(jessicaJonesId);
+ expect(locker.workerFk).toEqual(jessicaJonesId);
+ expect(oldNowLocker.workerFk).toEqual(null);
+ });
+});
diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js
index b475bf26e2..0b0e043f2e 100644
--- a/modules/worker/back/models/worker.js
+++ b/modules/worker/back/models/worker.js
@@ -20,10 +20,7 @@ module.exports = Self => {
require('../methods/worker/search')(Self);
require('../methods/worker/isAuthorized')(Self);
require('../methods/worker/setPassword')(Self);
-
- Self.validatesUniquenessOf('locker', {
- message: 'This locker has already been assigned'
- });
+ require('../methods/worker/getAvailablePda')(Self);
Self.validateAsync('fi', tinIsValid, {
message: 'Invalid TIN'
diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json
index 4c28cf2171..4e7617aabe 100644
--- a/modules/worker/back/models/worker.json
+++ b/modules/worker/back/models/worker.json
@@ -48,9 +48,6 @@
"code": {
"type" : "string"
},
- "locker": {
- "type" : "number"
- },
"fi": {
"type" : "string"
},
@@ -59,7 +56,29 @@
},
"isF11Allowed": {
"type" : "boolean"
+ },
+ "sex": {
+ "type" : "string"
+ },
+ "isFreelance": {
+ "type" : "boolean"
+ },
+ "fiDueDate": {
+ "type": "date"
+ },
+ "hasMachineryAuthorized": {
+ "type": "boolean"
+ },
+ "seniority": {
+ "type": "date"
+ },
+ "isDisable": {
+ "type": "boolean"
+ },
+ "isSsDiscounted": {
+ "type": "boolean"
}
+
},
"relations": {
"user": {
@@ -91,87 +110,20 @@
"type": "hasMany",
"model": "WorkerTeamCollegues",
"foreignKey": "workerFk"
+ },
+ "locker": {
+ "type": "hasMany",
+ "model": "Locker",
+ "foreignKey": "workerFk"
}
},
- "scopes":{
- "summary": {
- "include": [
- {
- "relation": "user",
- "scope": {
- "fields": ["email", "name", "nickname", "roleFk", "emailVerified"],
- "include": [
- {
- "relation": "role",
- "scope": {
- "fields": ["name"]
- }
- },
- {
- "relation": "emailUser",
- "scope": {
- "fields": ["email"]
- }
- }
- ]
- }
- }, {
- "relation": "department",
- "scope": {
- "include": {
- "relation": "department"
- }
- }
- }, {
- "relation": "boss"
- }, {
- "relation": "client",
- "scope": {
- "fields": [
- "id",
- "name",
- "fi",
- "socialName",
- "contact",
- "street",
- "city",
- "postcode",
- "email",
- "mobile",
- "isActive",
- "credit",
- "creditInsurance",
- "iban",
- "dueDay",
- "isEqualizated",
- "isFreezed",
- "hasToInvoiceByAddress",
- "hasToInvoice",
- "isToBeMailed",
- "hasSepaVnl",
- "hasLcr",
- "hasCoreVnl",
- "hasCoreVnh",
- "hasIncoterms",
- "isTaxDataChecked",
- "quality",
- "isVies",
- "isRelevant",
- "accountingAccount",
- "created",
- "sageTaxTypeFk",
- "sageTransactionTypeFk",
- "businessTypeFk",
- "salesPersonFk",
- "hasElectronicInvoice",
- "rating",
- "recommendedCredit"
- ]
- }
- }, {
- "relation": "sip"
- }
- ]
+ "acls":[
+ {
+ "property": "__get__locker",
+ "accessType": "READ",
+ "permission": "ALLOW",
+ "principalType": "ROLE",
+ "principalId": "$owner"
}
- }
+ ]
}
diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html
index 2d85d018de..bece1b6fde 100644
--- a/modules/worker/front/basic-data/index.html
+++ b/modules/worker/front/basic-data/index.html
@@ -54,8 +54,8 @@
@@ -75,11 +75,6 @@
ng-model="$ctrl.worker.SSN"
rule>
-
-
diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js
index 1aa548db9c..9a40e31c2e 100644
--- a/modules/worker/front/card/index.js
+++ b/modules/worker/front/card/index.js
@@ -4,13 +4,37 @@ import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard {
reload() {
const filter = {
- where: {
- id: this.$params.id}
+ include: [
+ {
+ relation: 'user',
+ scope: {
+ fields: ['name', 'emailVerified'],
+ include: {
+ relation: 'emailUser',
+ scope: {
+ fields: ['email']
+ }
+ }
+ }
+ }, {
+ relation: 'sip',
+ scope: {
+ fields: ['extension', 'secret']
+ }
+ }, {
+ relation: 'department',
+ scope: {
+ include: {
+ relation: 'department'
+ }
+ }
+ }
+ ]
};
return Promise.all([
- this.$http.get(`Workers/summary`, {filter})
- .then(res => this.worker = res.data[0]),
+ this.$http.get(`Workers/${this.$params.id}`, {filter})
+ .then(res => this.worker = res.data),
this.$http.get(`Workers/${this.$params.id}/activeContract`)
.then(res => this.hasWorkCenter = res.data?.workCenterFk)
]);
diff --git a/modules/worker/front/create/index.html b/modules/worker/front/create/index.html
index 39b2dbf475..3030ffecd0 100644
--- a/modules/worker/front/create/index.html
+++ b/modules/worker/front/create/index.html
@@ -65,7 +65,7 @@
rule>
{{code}} - {{town.name}} ({{town.province.name}},
- {{town.province.country.country}})
+ {{town.province.country.name}})
- {{name}} ({{country.country}})
+ {{name}} ({{country.name}})
@@ -99,7 +99,7 @@
value-field="name">
{{name}}, {{province.name}}
- ({{province.country.country}})
+ ({{province.country.name}})
this.entity = res.data[0]);
+ return this.getData(`Workers/${this.id}`, {filter})
+ .then(res => this.entity = res.data);
}
getPassRequirements() {
diff --git a/modules/worker/front/descriptor/index.spec.js b/modules/worker/front/descriptor/index.spec.js
index cee8b0def7..4f7fa6a05a 100644
--- a/modules/worker/front/descriptor/index.spec.js
+++ b/modules/worker/front/descriptor/index.spec.js
@@ -14,14 +14,14 @@ describe('vnWorkerDescriptor', () => {
describe('loadData()', () => {
it(`should perform a get query to store the worker data into the controller`, () => {
const id = 1;
- const response = ['foo'];
+ const response = 'foo';
$httpBackend.whenGET('UserConfigs/getUserConfig').respond({});
- $httpBackend.expectRoute('GET', `Workers/summary`).respond(response);
+ $httpBackend.expectRoute('GET', `Workers/${id}`).respond(response);
controller.id = id;
$httpBackend.flush();
- expect([controller.worker]).toEqual(response);
+ expect(controller.worker).toEqual(response);
});
});
diff --git a/modules/worker/front/pda/index.html b/modules/worker/front/pda/index.html
deleted file mode 100644
index c6d31dc858..0000000000
--- a/modules/worker/front/pda/index.html
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
diff --git a/modules/worker/front/pda/index.js b/modules/worker/front/pda/index.js
index 885261e5c4..c3616b41e4 100644
--- a/modules/worker/front/pda/index.js
+++ b/modules/worker/front/pda/index.js
@@ -1,53 +1,18 @@
import ngModule from '../module';
import Section from 'salix/components/section';
-import './style.scss';
class Controller extends Section {
constructor($element, $) {
super($element, $);
- const filter = {
- where: {userFk: this.$params.id},
- include: {relation: 'deviceProduction'}
- };
- this.$http.get('DeviceProductionUsers', {filter}).
- then(res => {
- if (res.data && res.data.length > 0)
- this.setCurrentPDA(res.data[0]);
- });
}
- deallocatePDA() {
- this.$http.post(`Workers/${this.$params.id}/deallocatePDA`, {pda: this.currentPDA.deviceProductionFk})
- .then(() => {
- this.vnApp.showSuccess(this.$t('PDA deallocated'));
- delete this.currentPDA;
- });
- }
-
- allocatePDA() {
- this.$http.post(`Workers/${this.$params.id}/allocatePDA`, {pda: this.newPDA})
- .then(res => {
- if (res.data)
- this.setCurrentPDA(res.data);
-
- this.vnApp.showSuccess(this.$t('PDA allocated'));
- delete this.newPDA;
- });
- }
-
- setCurrentPDA(data) {
- this.currentPDA = data;
- this.currentPDA.description = [];
- this.currentPDA.description.push(`ID: ${this.currentPDA.deviceProductionFk}`);
- this.currentPDA.description.push(`${this.$t('Model')}: ${this.currentPDA.deviceProduction.modelFk}`);
- this.currentPDA.description.push(`${this.$t('Serial Number')}: ${this.currentPDA.deviceProduction.serialNumber}`);
- this.currentPDA.description = this.currentPDA.description.join(' ');
+ async $onInit() {
+ const url = await this.vnApp.getUrl(`worker/${this.$params.id}/pda`);
+ this.$state.go('worker.card.summary', {id: this.$params.id});
+ window.location.href = url;
}
}
-Controller.$inject = ['$element', '$scope'];
-
ngModule.vnComponent('vnWorkerPda', {
- template: require('./index.html'),
- controller: Controller,
+ controller: Controller
});
diff --git a/modules/worker/front/pda/index.spec.js b/modules/worker/front/pda/index.spec.js
deleted file mode 100644
index a0540af45c..0000000000
--- a/modules/worker/front/pda/index.spec.js
+++ /dev/null
@@ -1,72 +0,0 @@
-import './index';
-
-describe('Worker', () => {
- describe('Component vnWorkerPda', () => {
- let $httpBackend;
- let $scope;
- let $element;
- let controller;
-
- beforeEach(ngModule('worker'));
-
- beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
- $httpBackend = _$httpBackend_;
- $scope = $rootScope.$new();
- $element = angular.element('');
- controller = $componentController('vnWorkerPda', {$element, $scope});
- $httpBackend.expectGET(`DeviceProductionUsers`).respond();
- }));
-
- describe('deallocatePDA()', () => {
- it('should make an HTTP Post query to deallocatePDA', () => {
- jest.spyOn(controller.vnApp, 'showSuccess');
- controller.currentPDA = {deviceProductionFk: 1};
- controller.$params.id = 1;
-
- $httpBackend
- .expectPOST(`Workers/${controller.$params.id}/deallocatePDA`,
- {pda: controller.currentPDA.deviceProductionFk})
- .respond();
- controller.deallocatePDA();
- $httpBackend.flush();
-
- expect(controller.vnApp.showSuccess).toHaveBeenCalled();
- expect(controller.currentPDA).toBeUndefined();
- });
- });
-
- describe('allocatePDA()', () => {
- it('should make an HTTP Post query to allocatePDA', () => {
- jest.spyOn(controller.vnApp, 'showSuccess');
- controller.newPDA = 4;
- controller.$params.id = 1;
-
- $httpBackend
- .expectPOST(`Workers/${controller.$params.id}/allocatePDA`,
- {pda: controller.newPDA})
- .respond();
- controller.allocatePDA();
- $httpBackend.flush();
-
- expect(controller.vnApp.showSuccess).toHaveBeenCalled();
- expect(controller.newPDA).toBeUndefined();
- });
- });
-
- describe('setCurrentPDA()', () => {
- it('should set CurrentPDA', () => {
- const data = {
- deviceProductionFk: 1,
- deviceProduction: {
- modelFk: 1,
- serialNumber: 1
- }
- };
- controller.setCurrentPDA(data);
-
- expect(controller.currentPDA).toBeDefined();
- expect(controller.currentPDA.description).toBeDefined();
- });
- });
- });
-});
diff --git a/modules/worker/front/pda/style.scss b/modules/worker/front/pda/style.scss
deleted file mode 100644
index c55c9d2187..0000000000
--- a/modules/worker/front/pda/style.scss
+++ /dev/null
@@ -1,6 +0,0 @@
-@import "./variables";
-
-.text-grey {
- color: $color-font-light;
-}
-
diff --git a/modules/worker/front/summary/index.js b/modules/worker/front/summary/index.js
index d1a27a6d42..212609f582 100644
--- a/modules/worker/front/summary/index.js
+++ b/modules/worker/front/summary/index.js
@@ -10,14 +10,53 @@ class Controller extends Summary {
this.$.worker = null;
if (!value) return;
+ const query = `Workers/${value.id}`;
const filter = {
- where: {
- id: value.id
- }
+ include: [
+ {
+ relation: 'user',
+ scope: {
+ fields: ['name', 'roleFk'],
+ include: [{
+ relation: 'role',
+ scope: {
+ fields: ['name']
+ }
+ },
+ {
+ relation: 'emailUser',
+ scope: {
+ fields: ['email']
+ }
+ }]
+ }
+ },
+ {
+ relation: 'client',
+ scope: {fields: ['fi', 'phone']}
+ },
+ {
+ relation: 'boss',
+ scope: {fields: ['id', 'name']}
+ },
+ {
+ relation: 'sip',
+ scope: {fields: ['extension']}
+ },
+ {
+ relation: 'department',
+ scope: {
+ include: {
+ relation: 'department',
+ scope: {fields: ['id', 'code', 'name']}
+ }
+ }
+ }
+ ]
};
- this.$http.get(`Workers/summary`, {filter}).then(res => {
- this.$.worker = res.data[0];
+ this.$http.get(query, {params: {filter}}).then(res => {
+ this.$.worker = res.data;
});
}
diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js
index 968685fecc..08dafd181c 100644
--- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js
+++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js
@@ -5,6 +5,7 @@ describe('zone deletezone()', () => {
const userId = 9;
const activeCtx = {
accessToken: {userId: userId},
+ __: value => value
};
const ctx = {req: activeCtx};
const zoneId = 9;
@@ -15,19 +16,15 @@ describe('zone deletezone()', () => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
- try {
- const originalTickets = await models.Ticket.find({
- where: {
- zoneFk: zoneId
- }
- });
- ticketIDs = originalTickets.map(ticket => ticket.id);
- originalTicketStates = await models.TicketState.find({where: {
- ticketFk: {inq: ticketIDs},
- code: 'FIXING'}});
- } catch (error) {
- console.error(error);
- }
+ const originalTickets = await models.Ticket.find({
+ where: {
+ zoneFk: zoneId
+ }
+ });
+ ticketIDs = originalTickets.map(ticket => ticket.id);
+ originalTicketStates = await models.TicketState.find({where: {
+ ticketFk: {inq: ticketIDs},
+ code: 'FIXING'}});
});
it('should delete a zone and update their tickets', async() => {
diff --git a/modules/zone/front/delivery-days/index.html b/modules/zone/front/delivery-days/index.html
index a3bed71d02..c47d899828 100644
--- a/modules/zone/front/delivery-days/index.html
+++ b/modules/zone/front/delivery-days/index.html
@@ -37,7 +37,7 @@
{{code}} {{town.name}}
- {{town.province.name}}, {{town.province.country.country}}
+ {{town.province.name}}, {{town.province.country.name}}
diff --git a/myt.config.yml b/myt.config.yml
index 17300aa372..56239ca3c5 100755
--- a/myt.config.yml
+++ b/myt.config.yml
@@ -227,7 +227,7 @@ localFixtures:
- expeditionScan
- expeditionState
- expeditionStateType
- - expeditionTruck
+ - roadmapStop
- expense
- genus
- greuge
diff --git a/package.json b/package.json
index 033eafc40e..fc8b709c9d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "salix-back",
- "version": "24.20.0",
+ "version": "24.24.1",
"author": "Verdnatura Levante SL",
"description": "Salix backend",
"license": "GPL-3.0",
@@ -39,6 +39,7 @@
"loopback-context": "^3.5.2",
"loopback-datasource-juggler": "3.36.1",
"md5": "^2.2.1",
+ "moment": "^2.30.1",
"mysql": "2.18.1",
"node-ssh": "^11.0.0",
"object.pick": "^1.3.0",
@@ -81,6 +82,8 @@
"gulp-print": "^2.0.1",
"gulp-wrap": "^0.15.0",
"gulp-yaml": "^1.0.1",
+ "gulp-rename": "^2.0.0",
+ "gulp-replace": "^1.1.4",
"html-loader": "^0.4.5",
"html-loader-jest": "^0.2.1",
"html-webpack-plugin": "^5.5.1",
@@ -113,7 +116,8 @@
"test:e2e": "node e2e/tests.js",
"test:front": "jest --watch",
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",
- "lint": "eslint ./ --cache --ignore-pattern .gitignore"
+ "lint": "eslint ./ --cache --ignore-pattern .gitignore",
+ "watch:db": "node ./db/dbWatcher.js"
},
"jest": {
"projects": [
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d3959ac03f..22d5b46f1e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -83,6 +83,9 @@ dependencies:
md5:
specifier: ^2.2.1
version: 2.3.0
+ moment:
+ specifier: ^2.30.1
+ version: 2.30.1
mysql:
specifier: 2.18.1
version: 2.18.1
@@ -199,6 +202,12 @@ devDependencies:
gulp-print:
specifier: ^2.0.1
version: 2.0.1
+ gulp-rename:
+ specifier: ^2.0.0
+ version: 2.0.0
+ gulp-replace:
+ specifier: ^1.1.4
+ version: 1.1.4
gulp-wrap:
specifier: ^0.15.0
version: 0.15.0(ejs@2.3.1)
@@ -2629,6 +2638,10 @@ packages:
resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==}
dev: true
+ /@types/expect@1.20.4:
+ resolution: {integrity: sha512-Q5Vn3yjTDyCMV50TB6VRIbQNxSE4OmZR86VSbGaNpfUolm0iePBB4KdEEHmxoY5sT2+2DIvXW0rvMDP2nHZ4Mg==}
+ dev: true
+
/@types/express-serve-static-core@4.17.42:
resolution: {integrity: sha512-ckM3jm2bf/MfB3+spLPWYPUH573plBFwpOhqQ2WottxYV85j1HQFlxmnTq57X1yHY9awZPig06hL/cLMgNWHIQ==}
dependencies:
@@ -2787,6 +2800,13 @@ packages:
resolution: {integrity: sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==}
dev: false
+ /@types/vinyl@2.0.12:
+ resolution: {integrity: sha512-Sr2fYMBUVGYq8kj3UthXFAu5UN6ZW+rYr4NACjZQJvHvj+c8lYv0CahmZ2P/r7iUkN44gGUBwqxZkrKXYPb7cw==}
+ dependencies:
+ '@types/expect': 1.20.4
+ '@types/node': 20.11.16
+ dev: true
+
/@types/yargs-parser@21.0.3:
resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==}
dev: true
@@ -3767,6 +3787,11 @@ packages:
engines: {node: '>=8'}
dev: true
+ /binaryextensions@2.3.0:
+ resolution: {integrity: sha512-nAihlQsYGyc5Bwq6+EsubvANYGExeJKHDO3RjnvwU042fawQTQfM3Kxn7IHUXQOz4bzfwsGYYHGSvXyW4zOGLg==}
+ engines: {node: '>=0.8'}
+ dev: true
+
/bindings@1.5.0:
resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}
requiresBuild: true
@@ -7087,6 +7112,22 @@ packages:
map-stream: 0.0.7
dev: true
+ /gulp-rename@2.0.0:
+ resolution: {integrity: sha512-97Vba4KBzbYmR5VBs9mWmK+HwIf5mj+/zioxfZhOKeXtx5ZjBk57KFlePf5nxq9QsTtFl0ejnHE3zTC9MHXqyQ==}
+ engines: {node: '>=4'}
+ dev: true
+
+ /gulp-replace@1.1.4:
+ resolution: {integrity: sha512-SVSF7ikuWKhpAW4l4wapAqPPSToJoiNKsbDoUnRrSgwZHH7lH8pbPeQj1aOVYQrbZKhfSVBxVW+Py7vtulRktw==}
+ engines: {node: '>=10'}
+ dependencies:
+ '@types/node': 20.11.16
+ '@types/vinyl': 2.0.12
+ istextorbinary: 3.3.0
+ replacestream: 4.0.3
+ yargs-parser: 21.1.1
+ dev: true
+
/gulp-util@3.0.8:
resolution: {integrity: sha512-q5oWPc12lwSFS9h/4VIjG+1NuNDlJ48ywV2JKItY4Ycc/n1fXJeYPVQsfu5ZrhQi7FGSDBalwUCLar/GyHXKGw==}
engines: {node: '>=0.10'}
@@ -8321,6 +8362,14 @@ packages:
istanbul-lib-report: 3.0.1
dev: true
+ /istextorbinary@3.3.0:
+ resolution: {integrity: sha512-Tvq1W6NAcZeJ8op+Hq7tdZ434rqnMx4CCZ7H0ff83uEloDvVbqAwaMTZcafKGJT0VHkYzuXUiCY4hlXQg6WfoQ==}
+ engines: {node: '>=8'}
+ dependencies:
+ binaryextensions: 2.3.0
+ textextensions: 3.3.0
+ dev: true
+
/jackspeak@2.3.6:
resolution: {integrity: sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==}
engines: {node: '>=14'}
@@ -10202,6 +10251,10 @@ packages:
to-iso-string: 0.0.2
dev: false
+ /moment@2.30.1:
+ resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
+ dev: false
+
/ms@0.7.1:
resolution: {integrity: sha512-lRLiIR9fSNpnP6TC4v8+4OU7oStC01esuNowdQ34L+Gk8e5Puoc88IqJ+XAY/B3Mn2ZKis8l8HX90oU8ivzUHg==}
dev: false
@@ -12058,6 +12111,14 @@ packages:
remove-trailing-separator: 1.1.0
dev: true
+ /replacestream@4.0.3:
+ resolution: {integrity: sha512-AC0FiLS352pBBiZhd4VXB1Ab/lh0lEgpP+GGvZqbQh8a5cmXVoTe5EX/YeTFArnp4SRGTHh1qCHu9lGs1qG8sA==}
+ dependencies:
+ escape-string-regexp: 1.0.5
+ object-assign: 4.1.1
+ readable-stream: 2.3.8
+ dev: true
+
/request@2.88.2:
resolution: {integrity: sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==}
engines: {node: '>= 6'}
@@ -13556,6 +13617,11 @@ packages:
resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==}
dev: true
+ /textextensions@3.3.0:
+ resolution: {integrity: sha512-mk82dS8eRABNbeVJrEiN5/UMSCliINAuz8mkUwH4SwslkNP//gbEzlWNS5au0z5Dpx40SQxzqZevZkn+WYJ9Dw==}
+ engines: {node: '>=8'}
+ dev: true
+
/throat@5.0.0:
resolution: {integrity: sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA==}
dev: true
diff --git a/print/templates/reports/campaign-metrics/sql/client.sql b/print/templates/reports/campaign-metrics/sql/client.sql
index 9f392c97eb..38f9fffc64 100644
--- a/print/templates/reports/campaign-metrics/sql/client.sql
+++ b/print/templates/reports/campaign-metrics/sql/client.sql
@@ -6,7 +6,7 @@ SELECT
c.id,
c.name AS clientName,
p.name AS province,
- co.country
+ co.name country
FROM client c
JOIN province p ON c.provinceFk = p.id
JOIN country co ON c.countryFk = co.id
diff --git a/print/templates/reports/claim-pickup-order/sql/client.sql b/print/templates/reports/claim-pickup-order/sql/client.sql
index 640b0c8a73..47e89cf1b5 100644
--- a/print/templates/reports/claim-pickup-order/sql/client.sql
+++ b/print/templates/reports/claim-pickup-order/sql/client.sql
@@ -8,7 +8,7 @@ SELECT
a.street,
a.nickname,
p.name AS province,
- ct.country,
+ ct.name country,
IFNULL(c.phone, cc.phone) AS phone
FROM claim cl
JOIN client c ON c.id = cl.clientFk
diff --git a/print/templates/reports/client-debt-statement/sql/client.sql b/print/templates/reports/client-debt-statement/sql/client.sql
index d675cf168d..acc6161319 100644
--- a/print/templates/reports/client-debt-statement/sql/client.sql
+++ b/print/templates/reports/client-debt-statement/sql/client.sql
@@ -6,7 +6,7 @@ SELECT
c.city,
c.fi,
p.name AS province,
- ct.country
+ ct.name country
FROM client c
JOIN country ct ON ct.id = c.countryFk
LEFT JOIN province p ON p.id = c.provinceFk
diff --git a/print/templates/reports/cmr/sql/data.sql b/print/templates/reports/cmr/sql/data.sql
index e9500cc4b9..42231709a7 100644
--- a/print/templates/reports/cmr/sql/data.sql
+++ b/print/templates/reports/cmr/sql/data.sql
@@ -14,12 +14,12 @@ SELECT c.id cmrFk,
s.street carrierStreet,
s.postCode carrierPostCode,
s.city carrierCity,
- cou.country carrierCountry,
+ cou.name carrierCountry,
s2.name senderName,
s2.street senderStreet,
s2.postCode senderPostCode,
s2.city senderCity,
- cou2.country senderCountry,
+ cou2.name senderCountry,
a.street deliveryStreet,
a.id deliveryAddressFk,
a.postalCode deliveryPostalCode,
@@ -27,12 +27,12 @@ SELECT c.id cmrFk,
a.nickname deliveryName,
a.phone deliveryPhone,
a.mobile deliveryMobile,
- cou3.country deliveryCountry,
+ cou3.name deliveryCountry,
cl.phone clientPhone,
a2.street loadStreet,
a2.postalCode loadPostalCode,
a2.city loadCity,
- cou4.country loadCountry,
+ cou4.name loadCountry,
co.stamp senderStamp,
s.stamp deliveryStamp
FROM cmr c
diff --git a/print/templates/reports/collection-label/assets/css/style.css b/print/templates/reports/collection-label/assets/css/style.css
index eb300f8508..3eb68a2b28 100644
--- a/print/templates/reports/collection-label/assets/css/style.css
+++ b/print/templates/reports/collection-label/assets/css/style.css
@@ -32,9 +32,12 @@ html {
#bold {
font-weight: bold;
}
-#barcode{
+.barcode{
width: 370px;
}
+.qr{
+ max-height: 137px;
+}
#shipped {
font-weight: bold;
width: 50px;
diff --git a/print/templates/reports/collection-label/collection-label.html b/print/templates/reports/collection-label/collection-label.html
index a0bfcad0ee..752a311858 100644
--- a/print/templates/reports/collection-label/collection-label.html
+++ b/print/templates/reports/collection-label/collection-label.html
@@ -8,11 +8,15 @@
{{labelData.clientFk ? `${labelData.ticketFk} « ${labelData.clientFk}` : labelData.ticketFk}}
|
- {{labelData.shipped || '---'}} |
+ {{dashIfEmpty(labelData.shipped)}} |
-
- |
- {{labelData.workerCode || '---'}} |
+
+ ![]() |
+ {{dashIfEmpty(labelData.workerCode)}} |
+
+
+ |
+ {{dashIfEmpty(labelData.workerCode)}} |
{{labelData.labelCount || 0}} |
@@ -21,11 +25,11 @@
{{labelData.code == 'V' ? (labelData.size || 0) + 'cm' : (labelData.volume || 0) + 'm³'}} |
- {{getAgencyDescripton(labelData)}} |
+ {{dashIfEmpty(getAgencyDescription(labelData))}} |
{{labelData.lineCount || 0}} |
- {{labelData.nickName ? labelData.nickName.toUpperCase() : '---'}} |
+ {{dashIfEmpty(labelData?.nickName.toUpperCase()) }} |
{{labelData.shippedHour || labelData.zoneHour}} |
diff --git a/print/templates/reports/collection-label/collection-label.js b/print/templates/reports/collection-label/collection-label.js
index db2adeb34a..f2f697ae64 100644
--- a/print/templates/reports/collection-label/collection-label.js
+++ b/print/templates/reports/collection-label/collection-label.js
@@ -1,6 +1,7 @@
-const jsBarcode = require('jsbarcode');
const {DOMImplementation, XMLSerializer} = require('xmldom');
const vnReport = require('../../../core/mixins/vn-report.js');
+const {toDataURL} = require('qrcode');
+const jsBarcode = require('jsbarcode');
module.exports = {
name: 'collection-label',
@@ -27,10 +28,28 @@ module.exports = {
} else
ticketIds = [this.id];
- this.labelsData = await this.rawSqlFromDef('labelsData', [ticketIds]);
+ const labels = await this.rawSqlFromDef('labelsData', [ticketIds]);
+
+ const [{scannableCodeType}] = await this.rawSqlFromDef('barcodeType');
+ if (scannableCodeType === 'qr') {
+ for (const labelData of labels)
+ labelData.qrData = await this.getQr(labelData?.ticketFk, labelData?.workerFk);
+ }
+
+ this.labelsData = labels;
this.checkMainEntity(this.labelsData);
},
methods: {
+ async getQr(ticketFk, workerFk = null) {
+ const QRdata = JSON.stringify({
+ company: 'vnl',
+ user: workerFk,
+ created: Date.vnNew(),
+ table: 'ticket',
+ id: ticketFk
+ });
+ return toDataURL(QRdata, {margin: 0});
+ },
getBarcode(id) {
const xmlSerializer = new XMLSerializer();
const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null);
@@ -52,18 +71,16 @@ module.exports = {
if (labelData.code == 'V')
value = value + `${labelData.wagon}-${labelData.level}`;
else
- value = value + `${labelData.color.substring(0, 4)}`;
+ value = value + `${labelData.color?.substring(0, 4)}`;
} else
value = '-'.repeat(19);
return value;
},
- getAgencyDescripton(labelData) {
+ getAgencyDescription(labelData) {
let value;
if (labelData.agencyDescription)
value = labelData.agencyDescription.toUpperCase().substring(0, 11);
- else
- value = '---';
if (labelData.routeFk) {
let routeFk = labelData.routeFk.toString();
@@ -72,5 +89,8 @@ module.exports = {
return value;
},
+ dashIfEmpty(value) {
+ return value || '---';
+ }
},
};
diff --git a/print/templates/reports/collection-label/sql/barcodeType.sql b/print/templates/reports/collection-label/sql/barcodeType.sql
new file mode 100644
index 0000000000..0700c95a2f
--- /dev/null
+++ b/print/templates/reports/collection-label/sql/barcodeType.sql
@@ -0,0 +1,3 @@
+SELECT scannableCodeType
+ FROM productionConfig
+ LIMIT 1
\ 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
index 61990812d6..2ffa6d8db7 100644
--- a/print/templates/reports/collection-label/sql/labelsData.sql
+++ b/print/templates/reports/collection-label/sql/labelsData.sql
@@ -3,7 +3,7 @@ SELECT c.itemPackingTypeFk code,
SUBSTRING('ABCDEFGH', tc.wagon, 1) wagon,
tc.`level`,
t.id ticketFk,
- COALESCE(et.description, zo.name, am.name) agencyDescription,
+ COALESCE(rs.description, zo.name, am.name) agencyDescription,
cc.code color,
t.clientFk,
CAST(SUM(sv.volume) AS DECIMAL(5, 2)) volume,
@@ -11,6 +11,7 @@ SELECT c.itemPackingTypeFk code,
IF(sgd.id, IFNULL(pc.itemPreviousDefaultSize, i.`size`), i.`size`)
) `size`,
w.code workerCode,
+ w.id workerFk,
TIME_FORMAT(t.shipped, '%H:%i') shippedHour,
TIME_FORMAT(zo.`hour`, '%H:%i') zoneHour,
DATE_FORMAT(t.shipped, '%d/%m/%y') shipped,
@@ -34,7 +35,7 @@ SELECT c.itemPackingTypeFk code,
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
+ LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
JOIN vn.productionConfig pc
WHERE t.id IN (?)
diff --git a/print/templates/reports/expedition-pallet-label/sql/labelData.sql b/print/templates/reports/expedition-pallet-label/sql/labelData.sql
index b2a805251e..385614305a 100644
--- a/print/templates/reports/expedition-pallet-label/sql/labelData.sql
+++ b/print/templates/reports/expedition-pallet-label/sql/labelData.sql
@@ -1,19 +1,19 @@
SELECT ep.id palletFk,
t.routeFk,
- et2.description truck,
+ rs2.description truck,
r.description `zone`,
COUNT(es.id) labels,
t.warehouseFk warehouseFk,
dayname(r.created) `dayName`,
- et.id <=> rm.expeditionTruckFk isMatch
- FROM vn.expeditionTruck et
- JOIN vn.expeditionPallet ep ON ep.truckFk = et.id
+ rs.id <=> rm.expeditionTruckFk isMatch
+ FROM vn.roadmapStop rs
+ JOIN vn.expeditionPallet ep ON ep.truckFk = rs.id
JOIN vn.expeditionScan es ON es.palletFk = ep.id
JOIN vn.expedition e ON e.id = es.expeditionFk
JOIN vn.ticket t ON t.id = e.ticketFk
JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
- LEFT JOIN vn.expeditionTruck et2 ON et2.id = rm.expeditionTruckFk
+ LEFT JOIN vn.roadmapStop rs2 ON rs2.id = rm.expeditionTruckFk
WHERE ep.id = ?
GROUP BY ep.id, t.routeFk
ORDER BY t.routeFk
diff --git a/print/templates/reports/incoterms-authorization/sql/client.sql b/print/templates/reports/incoterms-authorization/sql/client.sql
index bb17afd1d4..9eff1379c8 100644
--- a/print/templates/reports/incoterms-authorization/sql/client.sql
+++ b/print/templates/reports/incoterms-authorization/sql/client.sql
@@ -4,7 +4,7 @@ SELECT
c.name,
c.fi,
c.street,
- cty.country
+ cty.name country
FROM client c
JOIN country cty ON cty.id = c.countryFk
WHERE c.id = ?
\ No newline at end of file
diff --git a/print/templates/reports/letter-debtor/sql/client.sql b/print/templates/reports/letter-debtor/sql/client.sql
index d675cf168d..87fffb8b7c 100644
--- a/print/templates/reports/letter-debtor/sql/client.sql
+++ b/print/templates/reports/letter-debtor/sql/client.sql
@@ -6,7 +6,7 @@ SELECT
c.city,
c.fi,
p.name AS province,
- ct.country
+ ct.name country
FROM client c
JOIN country ct ON ct.id = c.countryFk
LEFT JOIN province p ON p.id = c.provinceFk
diff --git a/print/templates/reports/sepa-core/sql/client.sql b/print/templates/reports/sepa-core/sql/client.sql
index c22e7f114b..b3ba180b31 100644
--- a/print/templates/reports/sepa-core/sql/client.sql
+++ b/print/templates/reports/sepa-core/sql/client.sql
@@ -7,7 +7,7 @@ SELECT
c.city,
c.fi,
p.name AS province,
- ct.country,
+ ct.name country,
ct.code AS countryCode,
ct.ibanLength AS ibanLength
FROM client c
diff --git a/print/templates/reports/sepa-core/sql/supplier.sql b/print/templates/reports/sepa-core/sql/supplier.sql
index 80635ecf59..156fc71c07 100644
--- a/print/templates/reports/sepa-core/sql/supplier.sql
+++ b/print/templates/reports/sepa-core/sql/supplier.sql
@@ -2,7 +2,7 @@ SELECT
m.code mandateCode,
s.name,
s.street,
- sc.country,
+ sc.name country,
s.postCode,
s.city,
sp.name province,
diff --git a/print/templates/reports/supplier-campaign-metrics/sql/supplier.sql b/print/templates/reports/supplier-campaign-metrics/sql/supplier.sql
index 0c2fa12edb..d446ba6e64 100644
--- a/print/templates/reports/supplier-campaign-metrics/sql/supplier.sql
+++ b/print/templates/reports/supplier-campaign-metrics/sql/supplier.sql
@@ -5,7 +5,7 @@ SELECT
s.id,
s.name AS supplierName,
p.name AS province,
- co.country
+ co.name country
FROM supplier s
JOIN province p ON s.provinceFk = p.id
JOIN country co ON s.countryFk = co.id
diff --git a/webpack.config.js b/webpack.config.js
index 7296a62d19..2c01a10eb3 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -70,6 +70,7 @@ let baseConfig = {
]
},
optimization: {
+ nodeEnv: false,
runtimeChunk: true,
splitChunks: {
chunks: 'all',
@@ -99,9 +100,6 @@ let baseConfig = {
filename: 'index.html',
chunks: ['salix']
}),
- new webpack.DefinePlugin({
- 'process.env.NODE_ENV': JSON.stringify(env)
- })
],
devtool: 'source-map',
stats: {