diff --git a/modules/invoiceIn/back/locale/invoiceIn/en.yml b/modules/invoiceIn/back/locale/invoiceIn/en.yml
index ec9a824b6..9e94eba0d 100644
--- a/modules/invoiceIn/back/locale/invoiceIn/en.yml
+++ b/modules/invoiceIn/back/locale/invoiceIn/en.yml
@@ -16,5 +16,5 @@ columns:
bookEntried: book entried
isVatDeductible: is VAT deductible
withholdingSageFk: withholding
- expenceFkDeductible: expence deductible
+ expenseFkDeductible: expense deductible
editorFk: editor
\ No newline at end of file
diff --git a/modules/invoiceIn/back/locale/invoiceIn/es.yml b/modules/invoiceIn/back/locale/invoiceIn/es.yml
index 64e96b379..bd64c4327 100644
--- a/modules/invoiceIn/back/locale/invoiceIn/es.yml
+++ b/modules/invoiceIn/back/locale/invoiceIn/es.yml
@@ -16,5 +16,5 @@ columns:
bookEntried: fecha asiento
isVatDeductible: impuesto deducible
withholdingSageFk: código de retención
- expenceFkDeductible: gasto deducible
+ expenseFkDeductible: gasto deducible
editorFk: editor
\ No newline at end of file
diff --git a/modules/invoiceIn/back/locale/invoiceInTax/en.yml b/modules/invoiceIn/back/locale/invoiceInTax/en.yml
index c0d12c37d..6af547d3f 100644
--- a/modules/invoiceIn/back/locale/invoiceInTax/en.yml
+++ b/modules/invoiceIn/back/locale/invoiceInTax/en.yml
@@ -4,7 +4,7 @@ columns:
invoiceInFk: invoice in
taxCodeFk: tax
taxableBase: taxable base
- expenceFk: expence
+ expenseFk: expense
foreignValue: foreign amount
taxTypeSageFk: tax type
transactionTypeSageFk: transaction type
diff --git a/modules/invoiceIn/back/locale/invoiceInTax/es.yml b/modules/invoiceIn/back/locale/invoiceInTax/es.yml
index 7cb847ed8..92f3855e4 100644
--- a/modules/invoiceIn/back/locale/invoiceInTax/es.yml
+++ b/modules/invoiceIn/back/locale/invoiceInTax/es.yml
@@ -4,7 +4,7 @@ columns:
invoiceInFk: factura recibida
taxCodeFk: código IVA
taxableBase: base imponible
- expenceFk: código gasto
+ expenseFk: código gasto
foreignValue: importe divisa
taxTypeSageFk: código impuesto
transactionTypeSageFk: código transacción
diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js
index f5eab9099..dd193af85 100644
--- a/modules/invoiceIn/back/methods/invoice-in/filter.js
+++ b/modules/invoiceIn/back/methods/invoice-in/filter.js
@@ -146,7 +146,7 @@ module.exports = Self => {
ii.docFk AS dmsFk,
dm.file,
ii.supplierFk,
- ii.expenceFkDeductible deductibleExpenseFk,
+ ii.expenseFkDeductible deductibleExpenseFk,
s.name AS supplierName,
s.account,
SUM(iid.amount) AS amount,
diff --git a/modules/invoiceIn/back/models/invoice-in-tax.json b/modules/invoiceIn/back/models/invoice-in-tax.json
index 1f68476c3..5bfbbe2a8 100644
--- a/modules/invoiceIn/back/models/invoice-in-tax.json
+++ b/modules/invoiceIn/back/models/invoice-in-tax.json
@@ -19,10 +19,7 @@
"type": "number"
},
"expenseFk": {
- "type": "number",
- "mysql": {
- "columnName": "expenceFk"
- }
+ "type": "number"
},
"created": {
"type": "date"
diff --git a/modules/invoiceIn/back/models/invoice-in.json b/modules/invoiceIn/back/models/invoice-in.json
index 754899866..5be55c851 100644
--- a/modules/invoiceIn/back/models/invoice-in.json
+++ b/modules/invoiceIn/back/models/invoice-in.json
@@ -51,7 +51,7 @@
"deductibleExpenseFk": {
"type": "number",
"mysql": {
- "columnName": "expenceFkDeductible"
+ "columnName": "expenseFkDeductible"
}
}
},
diff --git a/modules/item/back/models/expense.json b/modules/item/back/models/expense.json
index 03147c08b..468063602 100644
--- a/modules/item/back/models/expense.json
+++ b/modules/item/back/models/expense.json
@@ -3,7 +3,7 @@
"base": "VnModel",
"options": {
"mysql": {
- "table": "expence"
+ "table": "expense"
}
},
"properties": {
diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json
index 6db1f5efc..097fe7708 100644
--- a/modules/item/back/models/item.json
+++ b/modules/item/back/models/item.json
@@ -117,10 +117,7 @@
"description": "The item family"
},
"expenseFk": {
- "type": "number",
- "mysql": {
- "columnName": "expenceFk"
- }
+ "type": "number"
},
"minPrice": {
"type": "number"
@@ -131,9 +128,6 @@
"nonRecycledPlastic": {
"type": "number"
},
- "minQuantity": {
- "type": "number"
- },
"packingOut": {
"type": "number"
},
diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html
index 426c17800..3e47faa5f 100644
--- a/modules/item/front/basic-data/index.html
+++ b/modules/item/front/basic-data/index.html
@@ -105,7 +105,7 @@
url="Expenses"
label="Expense"
ng-model="$ctrl.item.expenseFk"
- vn-name="expence"
+ vn-name="expense"
initial-data="$ctrl.item.expense">
diff --git a/modules/route/back/methods/agency-term/createInvoiceIn.js b/modules/route/back/methods/agency-term/createInvoiceIn.js
index 5a8430e49..f00ab95c6 100644
--- a/modules/route/back/methods/agency-term/createInvoiceIn.js
+++ b/modules/route/back/methods/agency-term/createInvoiceIn.js
@@ -54,7 +54,7 @@ module.exports = Self => {
dmsFk: firstDms.id,
}, myOptions);
- const expence = await models.AgencyTermConfig.findOne(null, myOptions);
+ const expense = await models.AgencyTermConfig.findOne(null, myOptions);
const [taxTypeSage] = await Self.rawSql(`
SELECT IFNULL(s.taxTypeSageFk, CodigoIva) value
@@ -78,7 +78,7 @@ module.exports = Self => {
await models.InvoiceInTax.create({
invoiceInFk: newInvoiceIn.id,
taxableBase: firstRow.totalPrice,
- expenseFk: expence.expenceFk,
+ expenseFk: expense.expenseFk,
taxTypeSageFk: taxTypeSage.value,
transactionTypeSageFk: transactionTypeSage.value
}, myOptions);
diff --git a/modules/route/back/models/agency-term-config.json b/modules/route/back/models/agency-term-config.json
index c94fc266b..81a608acf 100644
--- a/modules/route/back/models/agency-term-config.json
+++ b/modules/route/back/models/agency-term-config.json
@@ -7,7 +7,7 @@
}
},
"properties": {
- "expenceFk": {
+ "expenseFk": {
"type": "string",
"id": true
},
diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js
index 2419d3a5e..55ca474d7 100644
--- a/modules/ticket/back/methods/expedition/deleteExpeditions.js
+++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js
@@ -1,6 +1,7 @@
+const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
- Self.remoteMethod('deleteExpeditions', {
+ Self.remoteMethodCtx('deleteExpeditions', {
description: 'Delete the selected expeditions',
accessType: 'WRITE',
accepts: [{
@@ -9,44 +10,59 @@ module.exports = Self => {
required: true,
description: 'The expeditions ids to delete'
}],
- returns: {
- type: ['object'],
- root: true
- },
http: {
path: `/deleteExpeditions`,
verb: 'POST'
+ },
+ returns: {
+ type: ['object'],
+ root: true
}
});
- Self.deleteExpeditions = async(expeditionIds, options) => {
+ Self.deleteExpeditions = async(ctx, expeditionIds) => {
const models = Self.app.models;
- const myOptions = {};
- let tx;
+ const $t = ctx.req.__;
+ const notDeletedExpeditions = [];
+ const deletedExpeditions = [];
- if (typeof options == 'object')
- Object.assign(myOptions, options);
+ for (let expeditionId of expeditionIds) {
+ const filter = {
+ fields: [],
+ where: {
+ id: expeditionId
+ },
+ include: [
+ {
+ relation: 'agencyMode',
+ scope: {
+ fields: ['code'],
+ }
+ }
+ ]
+ };
- if (!myOptions.transaction) {
- tx = await Self.beginTransaction({});
- myOptions.transaction = tx;
- }
+ const expedition = await models.Expedition.findOne(filter);
+ const {code} = expedition.agencyMode();
- try {
- const promises = [];
- for (let expeditionId of expeditionIds) {
- const deletedExpedition = models.Expedition.destroyById(expeditionId, myOptions);
- promises.push(deletedExpedition);
+ if (code && code.toLowerCase().substring(0, 10) == 'viaexpress') {
+ const isDeleted = await models.ViaexpressConfig.deleteExpedition(expeditionId);
+
+ if (isDeleted === 'true') {
+ const deletedExpedition = await models.Expedition.destroyById(expeditionId);
+ deletedExpeditions.push(deletedExpedition);
+ } else notDeletedExpeditions.push(expeditionId);
+ } else {
+ const deletedExpedition = await models.Expedition.destroyById(expeditionId);
+ deletedExpeditions.push(deletedExpedition);
}
-
- const deletedExpeditions = await Promise.all(promises);
-
- if (tx) await tx.commit();
-
- return deletedExpeditions;
- } catch (e) {
- if (tx) await tx.rollback();
- throw e;
}
+
+ if (notDeletedExpeditions.length) {
+ throw new UserError(
+ $t(`It was not able to remove the next expeditions:`, {expeditions: notDeletedExpeditions.join()})
+ );
+ }
+ return deletedExpeditions;
};
};
diff --git a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js
index 61937989e..bf8bafe34 100644
--- a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js
+++ b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js
@@ -2,17 +2,16 @@ const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('ticket deleteExpeditions()', () => {
+ let ctx;
beforeAll(async() => {
- const activeCtx = {
+ ctx = {
accessToken: {userId: 9},
- http: {
- req: {
- headers: {origin: 'http://localhost'}
- }
+ req: {
+ headers: {origin: 'http://localhost'}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
- active: activeCtx
+ active: ctx
});
});
@@ -23,7 +22,7 @@ describe('ticket deleteExpeditions()', () => {
const options = {transaction: tx};
const expeditionIds = [12, 13];
- const result = await models.Expedition.deleteExpeditions(expeditionIds, options);
+ const result = await models.Expedition.deleteExpeditions(ctx, expeditionIds, options);
expect(result.length).toEqual(2);
diff --git a/modules/ticket/back/models/expedition.json b/modules/ticket/back/models/expedition.json
index e32a3b23d..069c6e281 100644
--- a/modules/ticket/back/models/expedition.json
+++ b/modules/ticket/back/models/expedition.json
@@ -20,6 +20,9 @@
},
"counter": {
"type": "number"
+ },
+ "externalId": {
+ "type": "string"
}
},
"relations": {
@@ -30,7 +33,7 @@
},
"agencyMode": {
"type": "belongsTo",
- "model": "agency-mode",
+ "model": "AgencyMode",
"foreignKey": "agencyModeFk"
},
"worker": {
diff --git a/modules/ticket/back/models/ticket-service-type.json b/modules/ticket/back/models/ticket-service-type.json
index ec2c9232a..9340d6023 100644
--- a/modules/ticket/back/models/ticket-service-type.json
+++ b/modules/ticket/back/models/ticket-service-type.json
@@ -18,7 +18,7 @@
"expenseFk": {
"type": "number",
"mysql": {
- "columnName": "expenceFk"
+ "columnName": "expenseFk"
}
}
},
diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html
index d64c22408..1b0608633 100644
--- a/modules/worker/front/calendar/index.html
+++ b/modules/worker/front/calendar/index.html
@@ -70,17 +70,18 @@
fields="['started', 'ended']"
ng-model="$ctrl.businessId"
search-function="{businessFk: $search}"
+ show-field="businessFk"
value-field="businessFk"
order="businessFk DESC"
limit="5">
-
- #{{businessFk}}
-
- {{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}}
-
-
-
-
+
+ #{{businessFk}}
+
+ {{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}}
+
+
+
+
@@ -110,3 +111,4 @@
message="This item will be deleted"
question="Are you sure you want to continue?">
+
diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js
index 0a955c586..f8a94be52 100644
--- a/modules/worker/front/time-control/index.js
+++ b/modules/worker/front/time-control/index.js
@@ -111,10 +111,8 @@ class Controller extends Section {
dayIndex.setDate(dayIndex.getDate() + 1);
}
- if (this.worker) {
- this.fetchHours();
- this.getWeekData();
- }
+ this.fetchHours();
+ this.getWeekData();
}
set weekTotalHours(totalHours) {
diff --git a/modules/zone/back/models/zone-closure.js b/modules/zone/back/models/zone-closure.js
index d25d6f707..61350ef56 100644
--- a/modules/zone/back/models/zone-closure.js
+++ b/modules/zone/back/models/zone-closure.js
@@ -14,7 +14,7 @@ module.exports = Self => {
async function doCalc(ctx) {
try {
await Self.rawSql(`
- CREATE EVENT zoneClosure_doRecalc
+ CREATE DEFINER = CURRENT_ROLE EVENT zoneClosure_doRecalc
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 15 SECOND
DO CALL zoneClosure_recalc;
`);