diff --git a/Jenkinsfile b/Jenkinsfile index 03ac84de3f..4a1f9ba546 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,13 +62,13 @@ pipeline { } } } - // stage('Backend') { - // steps { - // nodejs('node-v14') { - // sh 'gulp launchBackTest --ci' - // } - // } - // } + stage('Backend') { + steps { + nodejs('node-v14') { + sh 'npm run test:back:ci' + } + } + } } } stage('Build') { diff --git a/README.md b/README.md index 1e3ad5e9e7..f73a8551be 100644 --- a/README.md +++ b/README.md @@ -54,17 +54,17 @@ $ gulp docker For client-side unit tests run from project's root. ``` -$ jest +$ npm run test:front ``` For server-side unit tests run from project's root. ``` -$ gulp backTest +$ npm run test:back ``` For end-to-end tests run from project's root. ``` -$ gulp e2e +$ npm run test:e2e ``` ## Visual Studio Code extensions diff --git a/back/methods/account/specs/change-password.spec.js b/back/methods/account/specs/change-password.spec.js index 9f1130df52..17fadb3c69 100644 --- a/back/methods/account/specs/change-password.spec.js +++ b/back/methods/account/specs/change-password.spec.js @@ -1,9 +1,12 @@ -const app = require('vn-loopback/server/server'); +const {models} = require('vn-loopback/server/server'); describe('account changePassword()', () => { it('should throw an error when old password is wrong', async() => { - let req = app.models.Account.changePassword(null, 1, 'wrongOldPass', 'newPass'); + let err; + await models.Account.changePassword(1, 'wrongPassword', 'nightmare.9999') + .catch(error => err = error.sqlMessage); - await expectAsync(req).toBeRejected(); + expect(err).toBeDefined(); + expect(err).toEqual('Invalid password'); }); }); diff --git a/back/methods/collection/setSaleQuantity.js b/back/methods/collection/setSaleQuantity.js index 95145e9a02..644c44a609 100644 --- a/back/methods/collection/setSaleQuantity.js +++ b/back/methods/collection/setSaleQuantity.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('setSaleQuantity', { + Self.remoteMethod('setSaleQuantity', { description: 'Update sale quantity', accessType: 'WRITE', accepts: [{ @@ -24,11 +24,13 @@ module.exports = Self => { } }); - Self.setSaleQuantity = async ctx => { - const args = ctx.args; + Self.setSaleQuantity = async(saleId, quantity) => { const models = Self.app.models; - const sale = await models.Sale.findById(args.saleId); - return await sale.updateAttribute('quantity', args.quantity); + const sale = await models.Sale.findById(saleId); + return await sale.updateAttributes({ + originalQuantity: sale.quantity, + quantity: quantity + }); }; }; diff --git a/back/methods/collection/spec/newCollection.spec.js b/back/methods/collection/spec/newCollection.spec.js index 88d105b4b8..6abe73f8ea 100644 --- a/back/methods/collection/spec/newCollection.spec.js +++ b/back/methods/collection/spec/newCollection.spec.js @@ -1,8 +1,8 @@ const app = require('vn-loopback/server/server'); -// #3400 analizar que hacer con rutas de back colletion -xdescribe('newCollection()', () => { - it('return a new collection', async() => { +describe('newCollection()', () => { + it('should return a new collection', async() => { + pending('#3400 analizar que hacer con rutas de back collection'); let ctx = {req: {accessToken: {userId: 1106}}}; let response = await app.models.Collection.newCollection(ctx, 1, 1, 1); diff --git a/back/methods/collection/spec/setSaleQuantity.spec.js b/back/methods/collection/spec/setSaleQuantity.spec.js index 4e3c8c4aad..5d06a43834 100644 --- a/back/methods/collection/spec/setSaleQuantity.spec.js +++ b/back/methods/collection/spec/setSaleQuantity.spec.js @@ -5,19 +5,12 @@ describe('setSaleQuantity()', () => { const saleId = 30; const newQuantity = 10; - const ctx = { - args: { - saleId: saleId, - quantity: newQuantity - } - }; - const originalSale = await models.Sale.findById(saleId); - await models.Collection.setSaleQuantity(ctx); + await models.Collection.setSaleQuantity(saleId, newQuantity); const updateSale = await models.Sale.findById(saleId); - expect(updateSale.quantity).toBeLessThan(originalSale.quantity); + expect(updateSale.originalQuantity).toEqual(originalSale.quantity); expect(updateSale.quantity).toEqual(newQuantity); }); }); diff --git a/back/methods/dms/deleteTrashFiles.js b/back/methods/dms/deleteTrashFiles.js new file mode 100644 index 0000000000..9d16e9d81e --- /dev/null +++ b/back/methods/dms/deleteTrashFiles.js @@ -0,0 +1,57 @@ +const fs = require('fs-extra'); +const path = require('path'); + +module.exports = Self => { + Self.remoteMethod('deleteTrashFiles', { + description: 'Deletes files that have trash type', + accessType: 'WRITE', + returns: { + type: 'object', + root: true + }, + http: { + path: `/deleteTrashFiles`, + verb: 'POST' + } + }); + + Self.deleteTrashFiles = async(options) => { + const tx = await Self.beginTransaction({}); + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) + myOptions.transaction = tx; + + try { + const models = Self.app.models; + const DmsContainer = models.DmsContainer; + + const trashDmsType = await models.DmsType.findOne({ + where: {code: 'trash'} + }, myOptions); + + const dmsToDelete = await models.Dms.find({ + where: { + dmsTypeFk: trashDmsType.id + } + }, myOptions); + + for (let dms of dmsToDelete) { + const pathHash = DmsContainer.getHash(dms.id); + const dmsContainer = await DmsContainer.container(pathHash); + const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file); + await fs.unlink(dstFile); + await dms.destroy(myOptions); + } + if (tx) await tx.commit(); + + } catch (e) { + if (tx) await tx.rollback(); + + throw e; + } + }; +}; diff --git a/back/model-config.json b/back/model-config.json index 4ce11b99df..3432103832 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -68,6 +68,12 @@ "Language": { "dataSource": "vn" }, + "MachineWorker": { + "dataSource": "vn" + }, + "MobileAppVersionControl": { + "dataSource": "vn" + }, "Module": { "dataSource": "vn" }, diff --git a/back/models/account.json b/back/models/account.json index 9150bc1a77..5f0b05f9bd 100644 --- a/back/models/account.json +++ b/back/models/account.json @@ -47,7 +47,7 @@ "type": "date" }, "image": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/back/models/accounting-type.json b/back/models/accounting-type.json index be08ac533d..086be9d133 100644 --- a/back/models/accounting-type.json +++ b/back/models/accounting-type.json @@ -28,6 +28,9 @@ }, "maxAmount": { "type": "number" + }, + "daysInFuture": { + "type": "number" } }, "acls": [{ diff --git a/back/models/app-version-control.json b/back/models/app-version-control.json new file mode 100644 index 0000000000..46c53be3cd --- /dev/null +++ b/back/models/app-version-control.json @@ -0,0 +1,24 @@ +{ + "name": "MobileAppVersionControl", + "base": "VnModel", + "options": { + "mysql": { + "table": "vn.mobileAppVersionControl" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "appName": { + "type": "string" + }, + "version": { + "type": "string" + }, + "isVersionCritical": { + "type": "boolean" + } + } +} diff --git a/back/models/autonomy.json b/back/models/autonomy.json index ce9ac0bc67..8c9d82936d 100644 --- a/back/models/autonomy.json +++ b/back/models/autonomy.json @@ -9,7 +9,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, diff --git a/back/models/bank-entity.json b/back/models/bank-entity.json index c45cd43366..35d1116bd5 100644 --- a/back/models/bank-entity.json +++ b/back/models/bank-entity.json @@ -8,15 +8,15 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "bic": { - "type": "String" + "type": "string" }, "name": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/back/models/bank.json b/back/models/bank.json index 33a2637d69..da73b11411 100644 --- a/back/models/bank.json +++ b/back/models/bank.json @@ -8,35 +8,35 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "bank": { - "type": "String", + "type": "string", "required": true }, "account": { - "type": "String", + "type": "string", "required": true }, "accountingTypeFk": { - "type": "Number", + "type": "number", "required": true, "mysql": { "columnName": "cash" } }, "entityFk": { - "type": "Number", + "type": "number", "required": true }, "isActive": { - "type": "Boolean", + "type": "boolean", "required": true }, "currencyFk": { - "type": "Number", + "type": "number", "required": true } }, diff --git a/back/models/chat-config.json b/back/models/chat-config.json index d4f708b7a0..bdfbeb60da 100644 --- a/back/models/chat-config.json +++ b/back/models/chat-config.json @@ -10,20 +10,20 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "host": { - "type": "String" + "type": "string" }, "api": { - "type": "String" + "type": "string" }, "user": { - "type": "String" + "type": "string" }, "password": { - "type": "String" + "type": "string" } }, "acls": [{ diff --git a/back/models/company.json b/back/models/company.json index eb349477b4..a36b43b692 100644 --- a/back/models/company.json +++ b/back/models/company.json @@ -10,11 +10,11 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "code": { - "type": "String" + "type": "string" }, "expired": { "type": "date" diff --git a/back/models/country.json b/back/models/country.json index 8364636fcb..8fa25b88e3 100644 --- a/back/models/country.json +++ b/back/models/country.json @@ -9,7 +9,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, @@ -21,7 +21,7 @@ "type": "string" }, "isUeeMember": { - "type": "Boolean" + "type": "boolean" } }, "relations": { diff --git a/back/models/delivery.json b/back/models/delivery.json index 7c3c5c6211..65a0eef1bd 100644 --- a/back/models/delivery.json +++ b/back/models/delivery.json @@ -9,17 +9,17 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "date": { - "type": "Date" + "type": "date" }, "m3":{ - "type": "Number" + "type": "number" }, "warehouseFk":{ - "type": "Number" + "type": "number" } } } diff --git a/back/models/dms-type.json b/back/models/dms-type.json index b51c810acd..c7a1815fe9 100644 --- a/back/models/dms-type.json +++ b/back/models/dms-type.json @@ -9,7 +9,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, diff --git a/back/models/dms.js b/back/models/dms.js index 91291a0c2a..24c072f565 100644 --- a/back/models/dms.js +++ b/back/models/dms.js @@ -5,6 +5,7 @@ module.exports = Self => { require('../methods/dms/uploadFile')(Self); require('../methods/dms/removeFile')(Self); require('../methods/dms/updateFile')(Self); + require('../methods/dms/deleteTrashFiles')(Self); Self.checkRole = async function(ctx, id) { const models = Self.app.models; diff --git a/back/models/dms.json b/back/models/dms.json index f517a23ffe..0259e5487e 100644 --- a/back/models/dms.json +++ b/back/models/dms.json @@ -13,7 +13,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, @@ -36,7 +36,7 @@ "type": "boolean" }, "created": { - "type": "Date" + "type": "date" } }, "relations": { diff --git a/back/models/email-user.json b/back/models/email-user.json index e983635ce5..81c01ab0c8 100644 --- a/back/models/email-user.json +++ b/back/models/email-user.json @@ -9,7 +9,7 @@ "properties": { "userFk": { "id": true, - "type": "Number", + "type": "number", "required": true }, "email": { diff --git a/back/models/image-collection-size.json b/back/models/image-collection-size.json index adb92d16bc..9452456ee0 100644 --- a/back/models/image-collection-size.json +++ b/back/models/image-collection-size.json @@ -8,20 +8,20 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "width": { - "type": "Number", + "type": "number", "required": true }, "height": { - "type": "Number", + "type": "number", "required": true }, "crop": { - "type": "Boolean", + "type": "boolean", "required": true } }, diff --git a/back/models/image-collection.json b/back/models/image-collection.json index fd019ecc37..186ab02084 100644 --- a/back/models/image-collection.json +++ b/back/models/image-collection.json @@ -8,32 +8,32 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "name": { - "type": "String", + "type": "string", "required": true }, "desc": { - "type": "String", + "type": "string", "required": true }, "maxWidth": { - "type": "Number", + "type": "number", "required": true }, "maxHeight": { - "type": "Number", + "type": "number", "required": true }, "model": { - "type": "String", + "type": "string", "required": true }, "property": { - "type": "String", + "type": "string", "required": true } }, diff --git a/back/models/machine-worker.json b/back/models/machine-worker.json new file mode 100644 index 0000000000..2244a533fa --- /dev/null +++ b/back/models/machine-worker.json @@ -0,0 +1,33 @@ +{ + "name": "MachineWorker", + "base": "VnModel", + "options": { + "mysql": { + "table": "vn.machineWorker" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "workerFk": { + "type": "number" + }, + "machineFk": { + "type": "number" + }, + "inTime": { + "type": "date", + "mysql": { + "columnName": "inTimed" + } + }, + "outTime": { + "type": "date", + "mysql": { + "columnName": "outTimed" + } + } + } +} diff --git a/back/models/postcode.json b/back/models/postcode.json index e28a77dc4d..eadc2c86c4 100644 --- a/back/models/postcode.json +++ b/back/models/postcode.json @@ -9,7 +9,7 @@ "properties": { "code": { "id": true, - "type": "String" + "type": "string" } }, "relations": { diff --git a/back/models/sage-withholding.json b/back/models/sage-withholding.json index dddbcfd747..87f00a01c5 100644 --- a/back/models/sage-withholding.json +++ b/back/models/sage-withholding.json @@ -11,7 +11,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier", "mysql": { diff --git a/back/models/town.json b/back/models/town.json index 41633fe0af..4ad7297913 100644 --- a/back/models/town.json +++ b/back/models/town.json @@ -9,10 +9,10 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "name": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/back/models/user-config-view.json b/back/models/user-config-view.json index 8ffbc6f485..f9235725c4 100644 --- a/back/models/user-config-view.json +++ b/back/models/user-config-view.json @@ -9,18 +9,18 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "userFk": { - "type": "String", + "type": "string", "required": true }, "tableCode": { - "type": "String", + "type": "string", "required": true }, "configuration": { - "type": "Object" + "type": "object" } }, "relations": { diff --git a/back/models/user-log.json b/back/models/user-log.json index e3e3a67521..43ccbfa438 100644 --- a/back/models/user-log.json +++ b/back/models/user-log.json @@ -9,40 +9,40 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "originFk": { - "type": "Number", + "type": "number", "required": true }, "userFk": { - "type": "Number" + "type": "number" }, "action": { - "type": "String", + "type": "string", "required": true }, "changedModel": { - "type": "String" + "type": "string" }, "oldInstance": { - "type": "Object" + "type": "object" }, "newInstance": { - "type": "Object" + "type": "object" }, "creationDate": { - "type": "Date" + "type": "date" }, "changedModelId": { - "type": "Number" + "type": "number" }, "changedModelValue": { - "type": "String" + "type": "string" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/back/models/user.json b/back/models/user.json index 1d8f8f3a56..921362e0ed 100644 --- a/back/models/user.json +++ b/back/models/user.json @@ -9,7 +9,7 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "username":{ diff --git a/back/models/warehouse.json b/back/models/warehouse.json index 1d8ca44e3f..eb86e21148 100644 --- a/back/models/warehouse.json +++ b/back/models/warehouse.json @@ -10,17 +10,17 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "name": { - "type": "String" + "type": "string" }, "code": { - "type": "String" + "type": "string" }, "isInventory": { - "type": "Number" + "type": "number" }, "isManaged":{ "type": "boolean" diff --git a/back/nodemonConfig.json b/back/nodemonConfig.json new file mode 100644 index 0000000000..a1c9ca84fc --- /dev/null +++ b/back/nodemonConfig.json @@ -0,0 +1,24 @@ +{ + "verbose": true, + "watch": [ + "back/**/*.js", + "modules/**/*.js" + ], + "ignore": [ + "modules/account/front/**/*", + "modules/claim/front/**/*", + "modules/client/front/**/*", + "modules/entry/front/**/*", + "modules/invoiceIn/front/**/*", + "modules/invoiceOut/front/**/*", + "modules/item/front/**/*", + "modules/monitor/front/**/*", + "modules/order/front/**/*", + "modules/route/front/**/*", + "modules/supplier/front/**/*", + "modules/ticket/front/**/*", + "modules/travel/front/**/*", + "modules/worker/front/**/*", + "modules/zone/front/**/*" + ] +} \ No newline at end of file diff --git a/back/tests.js b/back/tests.js index c715c96bf3..8099061771 100644 --- a/back/tests.js +++ b/back/tests.js @@ -1,4 +1,5 @@ -require('require-yaml'); +const Docker = require('../db/docker.js'); +let dataSources = require('../loopback/server/datasources.json'); process.on('warning', warning => { console.log(warning.name); @@ -6,34 +7,64 @@ process.on('warning', warning => { console.log(warning.stack); }); -let verbose = false; +async function test() { + let isCI = false; -if (process.argv[2] === '--v') - verbose = true; + if (process.argv[2] === 'ci') + isCI = true; -let Jasmine = require('jasmine'); -let jasmine = new Jasmine(); -let SpecReporter = require('jasmine-spec-reporter').SpecReporter; + const container = new Docker(); -let serviceSpecs = [ - `${__dirname}/**/*[sS]pec.js`, - `${__dirname}/../loopback/**/*[sS]pec.js`, - `${__dirname}/../modules/*/back/**/*.[sS]pec.js` -]; + await container.run(isCI); + dataSources = JSON.parse(JSON.stringify(dataSources)); -jasmine.loadConfig({ - spec_dir: '.', - spec_files: serviceSpecs, - helpers: [] -}); + Object.assign(dataSources.vn, { + host: container.dbConf.host, + port: container.dbConf.port + }); -jasmine.addReporter(new SpecReporter({ - spec: { - // displayStacktrace: 'summary', - displaySuccessful: verbose, - displayFailedSpec: true, - displaySpecDuration: true + const bootOptions = {dataSources}; + const app = require('vn-loopback/server/server'); + app.boot(bootOptions); + + const Jasmine = require('jasmine'); + const jasmine = new Jasmine(); + + const SpecReporter = require('jasmine-spec-reporter').SpecReporter; + jasmine.addReporter(new SpecReporter({ + spec: { + displaySuccessful: isCI, + displayPending: isCI + }, + summary: { + displayPending: false, + } + })); + + if (isCI) { + const JunitReporter = require('jasmine-reporters'); + jasmine.addReporter(new JunitReporter.JUnitXmlReporter()); + + jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000; } -})); -jasmine.execute(); + const backSpecs = [ + './back/**/*[sS]pec.js', + './loopback/**/*[sS]pec.js', + './modules/*/back/**/*.[sS]pec.js' + ]; + + jasmine.loadConfig({ + spec_dir: '.', + spec_files: backSpecs, + helpers: [], + }); + + jasmine.exitOnCompletion = false; + await jasmine.execute(); + if (app) await app.disconnect(); + if (container) await container.rm(); + console.log('app disconnected & container removed'); +} + +test(); diff --git a/db/changes/10451-april/00-aclExpeditionState.sql b/db/changes/10451-april/00-aclExpeditionState.sql new file mode 100644 index 0000000000..d26117bbff --- /dev/null +++ b/db/changes/10451-april/00-aclExpeditionState.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) +VALUES('ExpeditionState', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10451-april/00-aclExpense.sql b/db/changes/10451-april/00-aclExpense.sql new file mode 100644 index 0000000000..55ca8c3895 --- /dev/null +++ b/db/changes/10451-april/00-aclExpense.sql @@ -0,0 +1,5 @@ +INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES('Expense', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); + +INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES('Expense', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); diff --git a/db/changes/10451-april/00-aclSupplierActivity.sql b/db/changes/10451-april/00-aclSupplierActivity.sql new file mode 100644 index 0000000000..bf73a15068 --- /dev/null +++ b/db/changes/10451-april/00-aclSupplierActivity.sql @@ -0,0 +1,5 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) +VALUES('SupplierActivity', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) +VALUES('SupplierActivity', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); diff --git a/db/changes/10451-april/00-invoiceOut_queue.sql b/db/changes/10451-april/00-invoiceOut_queue.sql deleted file mode 100644 index f60bcab77c..0000000000 --- a/db/changes/10451-april/00-invoiceOut_queue.sql +++ /dev/null @@ -1,14 +0,0 @@ -create table `vn`.`invoiceOut_queue` -( - invoiceFk int(10) unsigned not null, - queued datetime default now() not null, - printed datetime null, - `status` VARCHAR(50) default '' null, - constraint invoiceOut_queue_pk - primary key (invoiceFk), - constraint invoiceOut_queue_invoiceOut_id_fk - foreign key (invoiceFk) references invoiceOut (id) - on update cascade on delete cascade -) - comment 'Queue for PDF invoicing'; - diff --git a/db/changes/10451-april/00-ticket_doRefund.sql b/db/changes/10451-april/00-ticket_doRefund.sql index 5540ff8cfc..5725b4fe52 100644 --- a/db/changes/10451-april/00-ticket_doRefund.sql +++ b/db/changes/10451-april/00-ticket_doRefund.sql @@ -2,49 +2,64 @@ DROP PROCEDURE IF EXISTS vn.ticket_doRefund; DELIMITER $$ $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRefund`(IN vOriginTicket INT, OUT vNewTicket INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRefund`(OUT vNewTicket INT) BEGIN - +/** + * Crea un ticket de abono a partir de tmp.sale y/o tmp.ticketService + * + * @return vNewTicket + */ DECLARE vDone BIT DEFAULT 0; - DECLARE vCustomer MEDIUMINT; + DECLARE vClientFk MEDIUMINT; DECLARE vWarehouse TINYINT; DECLARE vCompany MEDIUMINT; DECLARE vAddress MEDIUMINT; - DECLARE vRefundAgencyMode INT; - DECLARE vItemFk INT; - DECLARE vQuantity DECIMAL (10,2); - DECLARE vConcept VARCHAR(50); - DECLARE vPrice DECIMAL (10,2); - DECLARE vDiscount TINYINT; + DECLARE vRefundAgencyMode INT; + DECLARE vItemFk INT; + DECLARE vQuantity DECIMAL (10,2); + DECLARE vConcept VARCHAR(50); + DECLARE vPrice DECIMAL (10,2); + DECLARE vDiscount TINYINT; DECLARE vSaleNew INT; - DECLARE vSaleMain INT; - DECLARE vZoneFk INT; - DECLARE vDescription VARCHAR(50); - DECLARE vTaxClassFk INT; - DECLARE vTicketServiceTypeFk INT; - - DECLARE cSales CURSOR FOR - SELECT * - FROM tmp.sale; - + DECLARE vSaleMain INT; + DECLARE vZoneFk INT; + DECLARE vDescription VARCHAR(50); + DECLARE vTaxClassFk INT; + DECLARE vTicketServiceTypeFk INT; + DECLARE vOriginTicket INT; + + DECLARE cSales CURSOR FOR + SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount + FROM tmp.sale s; + DECLARE cTicketServices CURSOR FOR - SELECT * - FROM tmp.ticketService; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; - - SELECT id INTO vRefundAgencyMode + SELECT ts.description, - ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk + FROM tmp.ticketService ts; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SELECT sub.ticketFk INTO vOriginTicket + FROM ( + SELECT s.ticketFk + FROM tmp.sale s + UNION ALL + SELECT ts.ticketFk + FROM tmp.ticketService ts + ) sub + LIMIT 1; + + SELECT id INTO vRefundAgencyMode FROM agencyMode WHERE `name` = 'ABONO'; SELECT clientFk, warehouseFk, companyFk, addressFk - INTO vCustomer, vWarehouse, vCompany, vAddress - FROM ticket - WHERE id = vOriginTicket; - - SELECT id INTO vZoneFk + INTO vClientFk, vWarehouse, vCompany, vAddress + FROM ticket + WHERE id = vOriginTicket; + + SELECT id INTO vZoneFk FROM zone WHERE agencyModeFk = vRefundAgencyMode - LIMIT 1; - + LIMIT 1; + INSERT INTO vn.ticket ( clientFk, shipped, @@ -54,10 +69,10 @@ BEGIN warehouseFk, companyFk, landed, - zoneFk + zoneFk ) SELECT - vCustomer, + vClientFk, CURDATE(), vAddress, vRefundAgencyMode, @@ -65,49 +80,48 @@ BEGIN vWarehouse, vCompany, CURDATE(), - vZoneFk + vZoneFk FROM address a WHERE a.id = vAddress; SET vNewTicket = LAST_INSERT_ID(); - SET vDone := 0; + SET vDone := FALSE; OPEN cSales; - FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; + FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; WHILE NOT vDone DO - + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount) VALUES( vNewTicket, vItemFk, vQuantity, vConcept, vPrice, vDiscount ); - - SET vSaleNew = LAST_INSERT_ID(); - - INSERT INTO vn.saleComponent(saleFk,componentFk,`value`) - SELECT vSaleNew,componentFk,`value` - FROM vn.saleComponent - WHERE saleFk = vSaleMain; - + + SET vSaleNew = LAST_INSERT_ID(); + + INSERT INTO vn.saleComponent(saleFk,componentFk,`value`) + SELECT vSaleNew,componentFk,`value` + FROM vn.saleComponent + WHERE saleFk = vSaleMain; + FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; - + END WHILE; CLOSE cSales; - SET vDone := 0; + SET vDone := FALSE; OPEN cTicketServices; - FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk; + FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk; WHILE NOT vDone DO - + INSERT INTO vn.ticketService(description, quantity, price, taxClassFk, ticketFk, ticketServiceTypeFk) VALUES(vDescription, vQuantity, vPrice, vTaxClassFk, vNewTicket, vTicketServiceTypeFk); - + FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk; - + END WHILE; CLOSE cTicketServices; INSERT INTO vn.ticketRefund(refundTicketFk, originalTicketFk) VALUES(vNewTicket, vOriginTicket); - END$$ DELIMITER ; diff --git a/db/changes/10460-mother/00-clientConfig.sql b/db/changes/10460-mother/00-clientConfig.sql new file mode 100644 index 0000000000..cd67a57976 --- /dev/null +++ b/db/changes/10460-mother/00-clientConfig.sql @@ -0,0 +1,5 @@ +ALTER TABLE `vn`.`clientConfig` ADD `maxCreditRows` int(11) NULL COMMENT 'Máximo número de registros a mantener en la tabla clientCredit'; + +UPDATE `vn`.`clientConfig` + SET `maxCreditRows` = 10 + WHERE `id` = 1; \ No newline at end of file diff --git a/db/changes/10460-mother/00-dmsForeignKey.sql b/db/changes/10460-mother/00-dmsForeignKey.sql new file mode 100644 index 0000000000..6a4736fddd --- /dev/null +++ b/db/changes/10460-mother/00-dmsForeignKey.sql @@ -0,0 +1,8 @@ +ALTER TABLE `vn`.`propertyDms` DROP FOREIGN KEY propertyDms_FK; +ALTER TABLE `vn`.`propertyDms` ADD CONSTRAINT propertyDms_FK FOREIGN KEY (dmsFk) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `vn`.`clientDms` DROP FOREIGN KEY clientDms_ibfk_2; +ALTER TABLE `vn`.`clientDms` ADD CONSTRAINT clientDms_ibfk_2 FOREIGN KEY (dmsFk) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `vn`.`workerDocument` DROP FOREIGN KEY workerDocument_ibfk_2; +ALTER TABLE `vn`.`workerDocument` ADD CONSTRAINT workerDocument_ibfk_2 FOREIGN KEY (document) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/changes/10460-mother/01-dmsType.sql b/db/changes/10460-mother/01-dmsType.sql new file mode 100644 index 0000000000..649ffbc712 --- /dev/null +++ b/db/changes/10460-mother/01-dmsType.sql @@ -0,0 +1,5 @@ +ALTER TABLE `vn`.`dmsType` ADD monthToDelete INT UNSIGNED DEFAULT NULL NULL; +ALTER TABLE `vn`.`dmsType` MODIFY COLUMN monthToDelete int(10) unsigned DEFAULT NULL NULL COMMENT 'Meses en el pasado para ir borrando registros, dejar a null para no borrarlos nunca'; +UPDATE `vn`.`dmsType` + SET monthToDelete=6 + WHERE id=20; diff --git a/db/changes/10460-mother/02-dmsTrigger.sql b/db/changes/10460-mother/02-dmsTrigger.sql new file mode 100644 index 0000000000..d4525440b0 --- /dev/null +++ b/db/changes/10460-mother/02-dmsTrigger.sql @@ -0,0 +1,18 @@ + +DELIMITER $$ +$$ +CREATE TRIGGER `vn`.`dms_beforeDelete` +BEFORE DELETE +ON dms FOR EACH ROW +BEGIN + DECLARE vCanNotBeDeleted INT; + SELECT COUNT(*) INTO vCanNotBeDeleted + FROM dmsType dt + WHERE NOT (code <=> 'trash') + AND dt.id = OLD.dmsTypeFk; + + IF vCanNotBeDeleted THEN + CALL util.throw('A dms can not be deleted'); + END IF; +END$$ +DELIMITER ; diff --git a/db/changes/10460-mother/03-clean.sql b/db/changes/10460-mother/03-clean.sql new file mode 100644 index 0000000000..13951394fd --- /dev/null +++ b/db/changes/10460-mother/03-clean.sql @@ -0,0 +1,175 @@ +DROP PROCEDURE IF EXISTS vn.clean; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clean`() +BEGIN + DECLARE vDateShort DATETIME; + DECLARE vOneYearAgo DATE; + DECLARE vFourYearsAgo DATE; + DECLARE v18Month DATE; + DECLARE v26Month DATE; + DECLARE v3Month DATE; + DECLARE vTrashId varchar(15); + + SET vDateShort = TIMESTAMPADD(MONTH, -2, CURDATE()); + SET vOneYearAgo = TIMESTAMPADD(YEAR,-1,CURDATE()); + SET vFourYearsAgo = TIMESTAMPADD(YEAR,-4,CURDATE()); + SET v18Month = TIMESTAMPADD(MONTH, -18,CURDATE()); + SET v26Month = TIMESTAMPADD(MONTH, -26,CURDATE()); + SET v3Month = TIMESTAMPADD(MONTH, -3, CURDATE()); + + DELETE FROM ticketParking WHERE created < vDateShort; + DELETE FROM routesMonitor WHERE dated < vDateShort; + DELETE FROM workerTimeControlLog WHERE created < vDateShort; + DELETE FROM `message` WHERE sendDate < vDateShort; + DELETE FROM messageInbox WHERE sendDate < vDateShort; + DELETE FROM messageInbox WHERE sendDate < vDateShort; + DELETE FROM workerTimeControl WHERE timed < vFourYearsAgo; + DELETE FROM itemShelving WHERE created < CURDATE() AND visible = 0; + DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,CURDATE()); + DELETE FROM entryLog WHERE creationDate < vDateShort; + DELETE IGNORE FROM expedition WHERE created < v26Month; + DELETE FROM sms WHERE created < v18Month; + DELETE FROM saleTracking WHERE created < vOneYearAgo; + DELETE tobs FROM ticketObservation tobs + JOIN ticket t ON tobs.ticketFk = t.id WHERE t.shipped < TIMESTAMPADD(YEAR,-2,CURDATE()); + DELETE sc.* FROM saleCloned sc JOIN sale s ON s.id = sc.saleClonedFk JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped < vOneYearAgo; + DELETE FROM sharingCart where ended < vDateShort; + DELETE FROM sharingClient where ended < vDateShort; + DELETE tw.* FROM ticketWeekly tw + LEFT JOIN sale s ON s.ticketFk = tw.ticketFk WHERE s.itemFk IS NULL; + DELETE FROM claim WHERE ticketCreated < vFourYearsAgo; + DELETE FROM message WHERE sendDate < vDateShort; + -- Robert ubicacion anterior de trevelLog comentario para debug + DELETE sc FROM saleChecked sc + JOIN sale s ON sc.saleFk = s.id WHERE s.created < vDateShort; + DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Month; + DELETE bm + FROM buyMark bm + JOIN buy b ON b.id = bm.id + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed <= vDateShort; + DELETE FROM stowaway WHERE created < v3Month; + DELETE FROM vn.buy WHERE created < vDateShort AND entryFk = 9200; + DELETE FROM vn.itemShelvingLog WHERE created < vDateShort; + DELETE FROM vn.stockBuyed WHERE creationDate < vDateShort; + + + -- Equipos duplicados + DELETE w.* + FROM workerTeam w + JOIN (SELECT id, team, workerFk, COUNT(*) - 1 as duplicated + FROM workerTeam + GROUP BY team,workerFk + HAVING duplicated + ) d ON d.team = w.team AND d.workerFk = w.workerFk AND d.id != w.id; + + DELETE sc + FROM saleComponent sc + JOIN sale s ON s.id= sc.saleFk + JOIN ticket t ON t.id= s.ticketFk + WHERE t.shipped < v18Month; + + DELETE c + FROM vn.claim c + JOIN vn.claimState cs ON cs.id = c.claimStateFk + WHERE cs.description = "Anulado" AND + c.created < vDateShort; + DELETE + FROM vn.expeditionTruck + WHERE ETD < v3Month; + + -- borrar travels sin entradas + DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete; + CREATE TEMPORARY TABLE tmp.thermographToDelete + SELECT th.id,th.dmsFk + FROM vn.travel t + LEFT JOIN vn.entry e ON e.travelFk = t.id + JOIN vn.travelThermograph th ON th.travelFk = t.id + WHERE t.shipped < TIMESTAMPADD(MONTH, -3, CURDATE()) AND e.travelFk IS NULL; + + SELECT dt.id into vTrashId + FROM vn.dmsType dt + WHERE dt.code = 'trash'; + + UPDATE tmp.thermographToDelete th + JOIN vn.dms d ON d.id = th.dmsFk + SET d.dmsTypeFk = vTrashId; + + DELETE th + FROM tmp.thermographToDelete tmp + JOIN vn.travelThermograph th ON th.id = tmp.id; + + DELETE t + FROM vn.travel t + LEFT JOIN vn.entry e ON e.travelFk = t.id + WHERE t.shipped < TIMESTAMPADD(MONTH, -3, CURDATE()) AND e.travelFk IS NULL; + + UPDATE dms d + JOIN dmsType dt ON dt.id = d.dmsTypeFk + SET d.dmsTypeFk = vTrashId + WHERE created < TIMESTAMPADD(MONTH, -dt.monthToDelete, CURDATE()); + + -- borrar entradas sin compras + DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete; + CREATE TEMPORARY TABLE tmp.entryToDelete + SELECT e.* + FROM vn.entry e + LEFT JOIN vn.buy b ON b.entryFk = e.id + JOIN vn.entryConfig ec ON e.id != ec.defaultEntry + WHERE e.dated < TIMESTAMPADD(MONTH, -3, CURDATE()) AND b.entryFK IS NULL; + + DELETE e + FROM vn.entry e + JOIN tmp.entryToDelete tmp ON tmp.id = e.id; + + -- borrar de route registros menores a 4 años + DROP TEMPORARY TABLE IF EXISTS tmp.routeToDelete; + CREATE TEMPORARY TABLE tmp.routeToDelete + SELECT * + FROM vn.route r + WHERE created < TIMESTAMPADD(YEAR,-4,CURDATE()); + + UPDATE tmp.routeToDelete tmp + JOIN vn.dms d ON d.id = tmp.gestdocFk + SET d.dmsTypeFk = vTrashId; + + DELETE r + FROM tmp.routeToDelete tmp + JOIN vn.route r ON r.id = tmp.id; + + -- borrar registros de dua y awb menores a 2 años + DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete; + CREATE TEMPORARY TABLE tmp.duaToDelete + SELECT * + FROM vn.dua + WHERE operated < TIMESTAMPADD(YEAR,-2,CURDATE()); + + UPDATE tmp.duaToDelete tm + JOIN vn.dms d ON d.id = tm.gestdocFk + SET d.dmsTypeFk = vTrashId; + + DELETE d + FROM tmp.duaToDelete tmp + JOIN vn.dua d ON d.id = tmp.id; + + DELETE FROM vn.awb WHERE created < TIMESTAMPADD(YEAR,-2,CURDATE()); + + -- Borra los ficheros gestDoc + INSERT INTO vn.printServerQueue(priorityFk, labelReportFk)VALUES(1,11); + + -- Borra los registros de collection y ticketcollection + DELETE FROM vn.collection WHERE created < vDateShort; + + DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete; + DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete; + DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete; + + DELETE FROM travelLog WHERE creationDate < v3Month; + + CALL shelving_clean; + +END$$ +DELIMITER ; diff --git a/db/changes/10460-mother/04-acl.sql b/db/changes/10460-mother/04-acl.sql new file mode 100644 index 0000000000..c1dc4f6edb --- /dev/null +++ b/db/changes/10460-mother/04-acl.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) + VALUES ('Dms','deleteTrashFiles','WRITE','ALLOW','ROLE','employee') \ No newline at end of file diff --git a/db/changes/10460-motherDay/00-aclItemType.sql b/db/changes/10460-motherDay/00-aclItemType.sql new file mode 100644 index 0000000000..836a69dfd2 --- /dev/null +++ b/db/changes/10460-motherDay/00-aclItemType.sql @@ -0,0 +1,4 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('ItemType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('ItemType', '*', 'WRITE', 'ALLOW', 'ROLE', 'buyer'); \ No newline at end of file diff --git a/db/changes/10460-mothersDay/delete.keep b/db/changes/10460-mothersDay/delete.keep deleted file mode 100644 index 0e7498f402..0000000000 --- a/db/changes/10460-mothersDay/delete.keep +++ /dev/null @@ -1 +0,0 @@ -Delete file \ No newline at end of file diff --git a/db/changes/10451-april/00-ClientUnpaid.sql b/db/changes/10461-mother/00-ClientUnpaid.sql similarity index 87% rename from db/changes/10451-april/00-ClientUnpaid.sql rename to db/changes/10461-mother/00-ClientUnpaid.sql index d84fe494a0..16deedace2 100644 --- a/db/changes/10451-april/00-ClientUnpaid.sql +++ b/db/changes/10461-mother/00-ClientUnpaid.sql @@ -3,8 +3,8 @@ CREATE TABLE `vn`.`clientUnpaid` ( `dated` date NOT NULL, `amount` double DEFAULT 0, PRIMARY KEY (`clientFk`), - CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE + CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE ); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) - VALUES('ClientUnpaid', '*', '*', 'ALLOW', 'ROLE', 'administrative'); \ No newline at end of file + VALUES('ClientUnpaid', '*', '*', 'ALLOW', 'ROLE', 'administrative'); diff --git a/db/changes/10461-mother/00-invoiceOut_queue.sql b/db/changes/10461-mother/00-invoiceOut_queue.sql new file mode 100644 index 0000000000..2b9f45e0fc --- /dev/null +++ b/db/changes/10461-mother/00-invoiceOut_queue.sql @@ -0,0 +1,8 @@ +CREATE TABLE `vn`.`invoiceOut_queue` ( + `invoiceFk` int(10) unsigned not null, + `queued` datetime default now() not null, + `printed` datetime null, + `status` VARCHAR(50) DEFAULT '' NULL, + CONSTRAINT `invoiceOut_queue_pk` PRIMARY KEY (`invoiceFk`), + CONSTRAINT `invoiceOut_queue_invoiceOut_id_fk` FOREIGN KEY (`invoiceFk`) REFERENCES `vn`.`invoiceOut` (`id`) ON UPDATE CASCADE ON DELETE CASCADE +) comment 'Queue for PDF invoicing'; diff --git a/db/changes/10470-family/00-accountingType.sql b/db/changes/10470-family/00-accountingType.sql new file mode 100644 index 0000000000..f3c092a34a --- /dev/null +++ b/db/changes/10470-family/00-accountingType.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn`.`accountingType` ADD daysInFuture INT NULL; +ALTER TABLE `vn`.`accountingType` MODIFY COLUMN daysInFuture int(11) DEFAULT 0 NULL; \ No newline at end of file diff --git a/db/changes/10470-family/delete.keep b/db/changes/10470-family/delete.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/db/docker.js b/db/docker.js index ea9fe8ed16..34026f85fe 100644 --- a/db/docker.js +++ b/db/docker.js @@ -24,7 +24,10 @@ module.exports = class Docker { let d = new Date(); let pad = v => v < 10 ? '0' + v : v; let stamp = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; + + log('Building container image...'); await this.execP(`docker build --build-arg STAMP=${stamp} -t salix-db ./db`); + log('Image built.'); let dockerArgs; @@ -39,6 +42,7 @@ module.exports = class Docker { let runChown = process.platform != 'linux'; + log('Starting container...'); const container = await this.execP(`docker run --env RUN_CHOWN=${runChown} -d ${dockerArgs} salix-db`); this.id = container.stdout.trim(); @@ -158,6 +162,7 @@ module.exports = class Docker { return reject(new Error('Docker exited, please see the docker logs for more info')); let conn = mysql.createConnection(myConf); + conn.on('error', () => {}); conn.connect(err => { conn.destroy(); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 2a8921926a..c69012f414 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -99,13 +99,19 @@ INSERT INTO `account`.`mailForward`(`account`, `forwardTo`) VALUES (1, 'employee@domain.local'); -INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`) +INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`) VALUES - (1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106), - (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107), - (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108), - (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109), - (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110); + (1, 'printer1', 'path1', 0), + (2, 'printer2', 'path2', 1); + + +INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`, `sectorFk`, `labelerFk`) + VALUES + (1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106, NULL, NULL), + (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107, NULL, 1), + (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108, 1, NULL), + (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109, 1, 2), + (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1); INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) VALUES @@ -113,7 +119,7 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) (2, 'USD', 'Dollar USA', 1.4), (3, 'GBP', 'Libra', 1), (4, 'JPY', 'Yen Japones', 1); - + INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`) VALUES (1, 'España', 1, 'ES', 1, 24, 4, 0, 1), @@ -156,22 +162,23 @@ INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `park ('HEJ', 2, 0, 1, 0, 1106), ('UXN', 1, 0, 1, 0, 1106); -INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`) +INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`) VALUES - (1, 'CC y Polizas de crédito', NULL, NULL, NULL), - (2, 'Cash', 'Cash', 'cash', 1000), - (3, 'Credit card', 'Credit Card', 'creditCard', NULL), - (4, 'Finalcial lines', NULL, NULL, NULL), - (5, 'Other products', NULL, NULL, NULL), - (6, 'Loans', NULL, NULL, NULL), - (7, 'Leasing', NULL, NULL, NULL), - (8, 'Compensations', 'Compensations', 'compensation', NULL); + (1, 'CC and credit policies', 'Transfers', 'wireTransfer', NULL, 1), + (2, 'Cash', 'Cash', 'cash', 1000, 0), + (3, 'Credit card', 'Credit Card', 'creditCard', NULL, 0), + (4, 'Finalcial lines', NULL, NULL, NULL, 0), + (5, 'Other products', NULL, NULL, NULL, 0), + (6, 'Loans', NULL, NULL, NULL, 0), + (7, 'Leasing', NULL, NULL, NULL, 0), + (8, 'Compensations', 'Compensations', 'compensation', NULL, 0); INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) VALUES (1, 'Pay on receipt', '5720000001', 3, 0, 1, 1), (2, 'Cash', '5700000001', 2, 0, 1, 1), (3, 'Compensation', '4000000000', 8, 0, 1, 1), + (4, 'Transfers', '4000000001', 1, 0, 1, 1), (3117, 'Caixa Rural d''Algemesi', '5720000000', 8, 3117, 1, 1); @@ -313,9 +320,9 @@ INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`) (1103, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), (1104, -30, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)); -INSERT INTO `vn`.`clientConfig`(`riskTolerance`) +INSERT INTO `vn`.`clientConfig`(`riskTolerance`, `maxCreditRows`) VALUES - (200); + (200, 10); INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`) VALUES @@ -393,17 +400,17 @@ DROP TEMPORARY TABLE tmp.address; INSERT INTO `vn`.`clientCredit`(`id`, `clientFk`, `workerFk`, `amount`, `created`) VALUES - (1 , 1101, 5, 300, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (2 , 1101, 5, 900, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (3 , 1101, 5, 800, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)), - (4 , 1101, 5, 700, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)), - (5 , 1101, 5, 600, DATE_ADD(CURDATE(), INTERVAL -5 MONTH)), + (1 , 1101, 5, 300, DATE_ADD(CURDATE(), INTERVAL -11 MONTH)), + (2 , 1101, 5, 900, DATE_ADD(CURDATE(), INTERVAL -10 MONTH)), + (3 , 1101, 5, 800, DATE_ADD(CURDATE(), INTERVAL -9 MONTH)), + (4 , 1101, 5, 700, DATE_ADD(CURDATE(), INTERVAL -8 MONTH)), + (5 , 1101, 5, 600, DATE_ADD(CURDATE(), INTERVAL -7 MONTH)), (6 , 1101, 5, 500, DATE_ADD(CURDATE(), INTERVAL -6 MONTH)), - (7 , 1101, 5, 400, DATE_ADD(CURDATE(), INTERVAL -7 MONTH)), - (8 , 1101, 9, 300, DATE_ADD(CURDATE(), INTERVAL -8 MONTH)), - (9 , 1101, 9, 200, DATE_ADD(CURDATE(), INTERVAL -9 MONTH)), - (10, 1101, 9, 100, DATE_ADD(CURDATE(), INTERVAL -10 MONTH)), - (11, 1101, 9, 50 , DATE_ADD(CURDATE(), INTERVAL -11 MONTH)), + (7 , 1101, 5, 400, DATE_ADD(CURDATE(), INTERVAL -5 MONTH)), + (8 , 1101, 9, 300, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)), + (9 , 1101, 9, 200, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)), + (10, 1101, 9, 100, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), + (11, 1101, 9, 50 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), (12, 1102, 9, 800, CURDATE()), (14, 1104, 9, 90 , CURDATE()), (15, 1105, 9, 90 , CURDATE()); @@ -744,14 +751,19 @@ INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code` (7, 'Accessories', 1, NULL, 'icon-accessory', 'accessory'), (8, 'Fruit', 1, NULL, 'icon-fruit', 'fruit'); -INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`) +INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) VALUES - (1, 'CRI', 'Crisantemo', 2, 1, 31, 35, 0), - (2, 'ITG', 'Anthurium', 1, 1, 31, 35, 0), - (3, 'WPN', 'Paniculata', 2, 1, 31, 35, 0), - (4, 'PRT', 'Delivery ports', 3, 1, NULL, 35, 1), - (5, 'CON', 'Container', 3, 1, NULL, 35, 1), - (6, 'ALS', 'Alstroemeria', 1, 1, 31, 16, 0); + ('warm', 'Warm', 'Warm'), + ('cool', 'Cool', 'Cool'); + +INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`, `temperatureFk`) + VALUES + (1, 'CRI', 'Crisantemo', 2, 1, 31, 35, 0, 'cool'), + (2, 'ITG', 'Anthurium', 1, 1, 31, 35, 0, 'cool'), + (3, 'WPN', 'Paniculata', 2, 1, 31, 35, 0, 'cool'), + (4, 'PRT', 'Delivery ports', 3, 1, NULL, 35, 1, 'warm'), + (5, 'CON', 'Container', 3, 1, NULL, 35, 1, 'warm'), + (6, 'ALS', 'Alstroemeria', 1, 1, 31, 16, 0, 'warm'); INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`) VALUES @@ -809,25 +821,25 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) ('VT', 'Sales'); INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, - `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`) + `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`) VALUES - (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0), - (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0), - (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0), - (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0), - (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0), - (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0), - (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0), - (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0), - (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0), - (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0), - (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0), - (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0), - (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1), - (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0), - (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0), - (16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0), - (71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0); + (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0, 15), + (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0, 10), + (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, 5), + (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL), + (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL), + (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL), + (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL), + (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, NULL), + (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL), + (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL), + (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL), + (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL), + (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1, NULL), + (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL), + (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL), + (16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL), + (71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0, NULL); -- Update the taxClass after insert of the items UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2 @@ -854,18 +866,35 @@ INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPack ('cc', 1640038.00, 56.00, 220.00, 128.00, 1, CURDATE(), 15, 90.00), ('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, CURDATE(), 16, 0.00); -INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `checked`, `workerFk`, `externalId`, `packagingFk`) +INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`) VALUES - (1, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 15, 1, 1, 18, 'UR9000006041', 94), - (2, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 16, 2, 1, 18, 'UR9000006041', 94), - (3, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 3, 1, 18, 'UR9000006041', 94), - (4, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 4, 1, 18, 'UR9000006041', 94), - (5, 1, 2, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94), - (6, 7, 3, 71, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), NULL, 1, 1, 18, NULL, 94), - (7, 2, 4, 71, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL, 1, 1, 18, NULL, 94), - (8, 3, 5, 71, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), NULL, 1, 1, 18, NULL, 94), - (9, 3, 6, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94), - (10, 7, 7, 71, NOW(), NULL, 1, 1, 18, NULL, 94); + (1, 'En reparto', 'ON DELIVERY'), + (2, 'Entregada', 'DELIVERED'), + (3, 'Perdida', 'LOST'); + + +INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `checked`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`) + VALUES + (1, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 15, 1, 1, 18, 'UR9000006041', 94, 1), + (2, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 16, 2, 1, 18, 'UR9000006041', 94, 1), + (3, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 3, 1, 18, 'UR9000006041', 94, 2), + (4, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 4, 1, 18, 'UR9000006041', 94, 2), + (5, 1, 2, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94, 3), + (6, 7, 3, 71, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), NULL, 1, 1, 18, NULL, 94, 3), + (7, 2, 4, 71, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL, 1, 1, 18, NULL, 94, NULL), + (8, 3, 5, 71, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), NULL, 1, 1, 18, NULL, 94, 1), + (9, 3, 6, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94, 2), + (10, 7, 7, 71, NOW(), NULL, 1, 1, 18, NULL, 94, 3); + + +INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`) + VALUES + (1, CURDATE(), 1, 1, 1), + (2, CURDATE(), 2, 1, 1), + (3, CURDATE(), 3, 1, 1), + (4, CURDATE(), 3, 2, 1106), + (5, CURDATE(), 5, 1, 1106), + (6, CURDATE(), 5, 3, 1106); INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp`) VALUES @@ -1296,11 +1325,11 @@ INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `pr (5, 442, 'GCR building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'), (6, 442, 'The Gotham Tonight building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'); -INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`) +INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`) VALUES - (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1), - (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1), - (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'flowerPlants', 1); + (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), + (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), + (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'); INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`) VALUES @@ -1604,51 +1633,59 @@ INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`) INSERT INTO `hedera`.`visit`(`id`, `firstAgentFk`) VALUES - (1, NULL), - (2, NULL), - (3, NULL), - (4, NULL), - (5, NULL), - (6, NULL), - (7, NULL), - (8, NULL), - (9, NULL); + (1, NULL), + (2, NULL), + (3, NULL), + (4, NULL), + (5, NULL), + (6, NULL), + (7, NULL), + (8, NULL), + (9, NULL), + (10, NULL), + (11, NULL); INSERT INTO `hedera`.`visitAgent`(`id`, `visitFk`) VALUES - (1, 1), - (2, 2), - (3, 3), - (4, 4), - (5, 5), - (6, 6), - (7, 7), - (8, 8), - (9, 9); + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5), + (6, 6), + (7, 7), + (8, 8), + (9, 9), + (10, 10), + (11, 11); INSERT INTO `hedera`.`visitAccess`(`id`, `agentFk`, `stamp`) VALUES - (1, 1, CURDATE()), - (2, 2, CURDATE()), - (3, 3, CURDATE()), - (4, 4, CURDATE()), - (5, 5, CURDATE()), - (6, 6, CURDATE()), - (7, 7, CURDATE()), - (8, 8, CURDATE()), - (9, 9, CURDATE()); + (1, 1, CURDATE()), + (2, 2, CURDATE()), + (3, 3, CURDATE()), + (4, 4, CURDATE()), + (5, 5, CURDATE()), + (6, 6, CURDATE()), + (7, 7, CURDATE()), + (8, 8, CURDATE()), + (9, 9, CURDATE()), + (10, 10, CURDATE()), + (11, 11, CURDATE()); INSERT INTO `hedera`.`visitUser`(`id`, `accessFk`, `userFk`, `stamp`) VALUES - (1, 1, 1101, CURDATE()), - (2, 2, 1101, CURDATE()), - (3, 3, 1101, CURDATE()), - (4, 4, 1102, CURDATE()), - (5, 5, 1102, CURDATE()), - (6, 6, 1102, CURDATE()), - (7, 7, 1103, CURDATE()), - (8, 8, 1103, CURDATE()), - (9, 9, 1103, CURDATE()); + (1, 1, 1101, CURDATE()), + (2, 2, 1101, CURDATE()), + (3, 3, 1101, CURDATE()), + (4, 4, 1102, CURDATE()), + (5, 5, 1102, CURDATE()), + (6, 6, 1102, CURDATE()), + (7, 7, 1103, CURDATE()), + (8, 8, 1103, CURDATE()), + (9, 9, 1103, CURDATE()), + (10, 10, 1102, DATE_SUB(CURDATE(), INTERVAL 1 DAY)), + (11, 11, 1103, DATE_SUB(CURDATE(), INTERVAL 1 DAY)); INSERT INTO `hedera`.`userSession`(`created`, `lastUpdate`, `ssid`, `data`, `userVisitFk`) VALUES @@ -2273,11 +2310,6 @@ INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `week (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000); INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11'); - -INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) - VALUES - ('warm', 'Warm', 'Warm'), - ('cool', 'Cool', 'Cool'); INSERT INTO `vn`.`thermograph`(`id`, `model`) VALUES @@ -2527,3 +2559,21 @@ INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackage (3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0), (4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0), (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0); + +INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`) + VALUES + ('delivery', '9.2', 0), + ('warehouse', '8.1', 0); + +INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmentFk`, `type`, `use`, `productionYear`, `workerFk`, `companyFk`) + VALUES + ('RE-001', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442), + ('RE-002', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442); + +INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`) + VALUES + (1106, 1, CURDATE(), CURDATE()), + (1106, 1, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (1106, 2, CURDATE(), NULL), + (1106, 2, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)); + diff --git a/db/dump/structure.sql b/db/dump/structure.sql index fdd7e1151b..21ef7758c5 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -37460,6 +37460,31 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `printer` +-- + +DROP TABLE IF EXISTS `printer`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `printer` ( + `id` tinyint(3) unsigned NOT NULL, + `name` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `path` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `modelFk` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `macWifi` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `ipAddress` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `reference` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isLabeler` tinyint(1) DEFAULT 0 COMMENT 'Indica si es impresora de etiquetas', + PRIMARY KEY (`id`), + UNIQUE KEY `printer_UN` (`reference`), + UNIQUE KEY `printer_UN1` (`macWifi`), + UNIQUE KEY `printer_UN2` (`name`), + KEY `printer_FK` (`modelFk`), + CONSTRAINT `printer_FK` FOREIGN KEY (`modelFk`) REFERENCES `printerModel` (`code`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `printingQueueCheck` -- diff --git a/db/export-structure.sh b/db/export-structure.sh index 3882313064..9b23f43ac7 100755 --- a/db/export-structure.sh +++ b/db/export-structure.sh @@ -60,7 +60,6 @@ IGNORETABLES=( --ignore-table=vn.plantpassportAuthority__ --ignore-table=vn.preparationException --ignore-table=vn.priceFixed__ - --ignore-table=vn.printer --ignore-table=vn.printingQueue --ignore-table=vn.printServerQueue__ --ignore-table=vn.promissoryNote diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 2ecb739609..29176489ce 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -982,8 +982,8 @@ export default { save: 'vn-invoice-in-basic-data button[type=submit]' }, invoiceInTax: { - addTaxButton: 'vn-invoice-in-tax vn-icon-button[icon="add_circle"]', - thirdExpence: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="invoiceInTax.expenseFk"]', + addTaxButton: 'vn-invoice-in-tax vn-icon-button[vn-tooltip="Add tax"]', + thirdExpense: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="invoiceInTax.expenseFk"]', thirdTaxableBase: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-input-number[ng-model="invoiceInTax.taxableBase"]', thirdTaxType: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="invoiceInTax.taxTypeSageFk"]', thirdTransactionType: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="invoiceInTax.transactionTypeSageFk"]', diff --git a/e2e/helpers/tests.js b/e2e/helpers/tests.js new file mode 100644 index 0000000000..aac9963dd5 --- /dev/null +++ b/e2e/helpers/tests.js @@ -0,0 +1,87 @@ +require('@babel/register')({presets: ['@babel/env']}); +require('core-js/stable'); +require('regenerator-runtime/runtime'); + +const axios = require('axios'); +const Docker = require('../../db/docker.js'); +const e2eConfig = require('./config.js'); +const log = require('fancy-log'); + +process.on('warning', warning => { + console.log(warning.name); + console.log(warning.message); + console.log(warning.stack); +}); + +async function test() { + if (process.argv[2] === 'show') + process.env.E2E_SHOW = true; + + const container = new Docker('salix-db'); + + await container.run(); + + const Jasmine = require('jasmine'); + const jasmine = new Jasmine(); + + const specFiles = [ + `./e2e/paths/01*/*[sS]pec.js`, + `./e2e/paths/02*/*[sS]pec.js`, + `./e2e/paths/03*/*[sS]pec.js`, + `./e2e/paths/04*/*[sS]pec.js`, + `./e2e/paths/05*/*[sS]pec.js`, + `./e2e/paths/06*/*[sS]pec.js`, + `./e2e/paths/07*/*[sS]pec.js`, + `./e2e/paths/08*/*[sS]pec.js`, + `./e2e/paths/09*/*[sS]pec.js`, + `./e2e/paths/10*/*[sS]pec.js`, + `./e2e/paths/11*/*[sS]pec.js`, + `./e2e/paths/12*/*[sS]pec.js`, + `./e2e/paths/13*/*[sS]pec.js`, + `./e2e/paths/**/*[sS]pec.js` + ]; + + jasmine.loadConfig({ + spec_dir: '.', + spec_files: specFiles, + helpers: [], + random: false, + }); + + await backendStatus(); + + jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000; + await jasmine.execute(); +} + +async function backendStatus() { + log('Awaiting backend connection...'); + + const milliseconds = 1000; + const maxAttempts = 10; + + return new Promise(resolve => { + let timer; + let attempts = 1; + timer = setInterval(async() => { + try { + attempts++; + const url = `${e2eConfig.url}/api/Applications/status`; + const {data} = await axios.get(url); + + if (data == true) { + clearInterval(timer); + log('Backend connection stablished!'); + resolve(attempts); + } + } catch (error) { + if (error && attempts >= maxAttempts) { + log('Could not connect to backend'); + process.exit(); + } + } + }, milliseconds); + }); +} + +test(); diff --git a/e2e/paths/09-invoice-in/04_tax.spec.js b/e2e/paths/09-invoice-in/04_tax.spec.js index 364a25d7e4..b1dbe20088 100644 --- a/e2e/paths/09-invoice-in/04_tax.spec.js +++ b/e2e/paths/09-invoice-in/04_tax.spec.js @@ -19,7 +19,7 @@ describe('InvoiceIn tax path', () => { it('should add a new tax', async() => { await page.waitToClick(selectors.invoiceInTax.addTaxButton); - await page.autocompleteSearch(selectors.invoiceInTax.thirdExpence, '6210000567'); + await page.autocompleteSearch(selectors.invoiceInTax.thirdExpense, '6210000567'); await page.write(selectors.invoiceInTax.thirdTaxableBase, '100'); await page.autocompleteSearch(selectors.invoiceInTax.thirdTaxType, '6'); await page.autocompleteSearch(selectors.invoiceInTax.thirdTransactionType, 'Operaciones exentas'); @@ -37,9 +37,9 @@ describe('InvoiceIn tax path', () => { expect(result).toEqual('Taxable base €1,323.16'); }); - it('should navigate back to the tax section and check the reciently added line contains the expected expense', async() => { + it('should navigate back to tax section, check the reciently added line contains the expected expense', async() => { await page.accessToSection('invoiceIn.card.tax'); - const result = await page.waitToGetProperty(selectors.invoiceInTax.thirdExpence, 'value'); + const result = await page.waitToGetProperty(selectors.invoiceInTax.thirdExpense, 'value'); expect(result).toEqual('6210000567: Alquiler VNH'); }); diff --git a/front/core/components/multi-check/multi-check.html b/front/core/components/multi-check/multi-check.html index eaa4577f06..fe485e19b6 100644 --- a/front/core/components/multi-check/multi-check.html +++ b/front/core/components/multi-check/multi-check.html @@ -5,12 +5,14 @@ - + All diff --git a/front/core/components/multi-check/multi-check.js b/front/core/components/multi-check/multi-check.js index e60d16519d..041603f13a 100644 --- a/front/core/components/multi-check/multi-check.js +++ b/front/core/components/multi-check/multi-check.js @@ -146,16 +146,17 @@ export default class MultiCheck extends FormInput { if (!this.model || !this.model.data) return; const data = this.model.data; - const modelParams = this.model.userParams; const params = { filter: { - modelParams: modelParams, limit: null } }; + if (this.model.userFilter) + Object.assign(params.filter, this.model.userFilter); + if (this.model.userParams) + Object.assign(params, this.model.userParams); this.rows = data.length; - this.$http.get(this.model.url, {params}) .then(res => { this.allRowsCount = res.data.length; @@ -172,6 +173,10 @@ export default class MultiCheck extends FormInput { this.checkedDummyCount = this.allRowsCount; } + isCheckedDummy() { + return this.checked && this.checkDummyEnabled; + } + /** * Toggles checked property on * all instances diff --git a/front/core/components/multi-check/multi-check.spec.js b/front/core/components/multi-check/multi-check.spec.js index 1c0adb9d8b..5cb8cbbef2 100644 --- a/front/core/components/multi-check/multi-check.spec.js +++ b/front/core/components/multi-check/multi-check.spec.js @@ -190,4 +190,30 @@ describe('Component vnMultiCheck', () => { expect(controller.checkedDummyCount).toBeNull(); }); }); + + describe('isCheckedDummy()', () => { + it(`should return true only if is checked and checked dummy is enabled`, () => { + controller.checked = true; + controller.checkDummyEnabled = true; + const isCheckedDummy = controller.isCheckedDummy(); + + expect(isCheckedDummy).toEqual(true); + }); + + it(`should return false if not checked`, () => { + controller.checked = false; + controller.checkDummyEnabled = true; + const isCheckedDummy = controller.isCheckedDummy(); + + expect(isCheckedDummy).toEqual(false); + }); + + it(`should return false if checked dummy is disabled`, () => { + controller.checked = true; + controller.checkDummyEnabled = false; + const isCheckedDummy = controller.isCheckedDummy(); + + expect(isCheckedDummy).toEqual(false); + }); + }); }); diff --git a/front/core/components/multi-check/style.scss b/front/core/components/multi-check/style.scss index 7a4d10675e..15f462e8ff 100644 --- a/front/core/components/multi-check/style.scss +++ b/front/core/components/multi-check/style.scss @@ -3,15 +3,8 @@ vn-multi-check { .vn-check { margin-bottom: 12px } - - vn-list{ - padding: 50px; - } - vn-menu{ - padding: 50px; - } - } + .bold{ font-weight: bold; } \ No newline at end of file diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index c2af9b41e7..a3295c47e7 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -46,11 +46,13 @@
- - +
+ + +
{ - const jasmine = require('gulp-jasmine'); - - const options = { - verbose: false, - includeStackTrace: false, - errorOnFail: false, - timeout: 5000, - config: {} - }; - - if (argv.ci) { - const reporters = require('jasmine-reporters'); - options.reporter = new reporters.JUnitXmlReporter(); - } - - let backSpecFiles = [ - 'back/**/*.spec.js', - 'loopback/**/*.spec.js', - 'modules/*/back/**/*.spec.js' - ]; - - gulp.src(backSpecFiles) - .pipe(jasmine(options)) - .on('end', resolve) - .on('error', reject) - .resume(); - }); - } catch (e) { - err = e; - } - await app.disconnect(); - await container.rm(); - done(); - if (err) - throw err; -} -launchBackTest.description = ` - Runs the backend tests once using a random container, can receive --ci arg to save reports on a xml file`; - -// Backend tests - -function backTest(done) { - const nodemon = require('gulp-nodemon'); - - nodemon({ - exec: ['node --tls-min-v1.0 ./node_modules/gulp/bin/gulp.js'], - args: ['launchBackTest'], - watch: backSources, - done: done - }); -} -backTest.description = `Watches for changes in modules to execute backTest task`; - -// End to end tests -function e2eSingleRun() { - require('@babel/register')({presets: ['@babel/env']}); - require('core-js/stable'); - require('regenerator-runtime/runtime'); - - const jasmine = require('gulp-jasmine'); - const SpecReporter = require('jasmine-spec-reporter').SpecReporter; - - if (argv.show || argv.s) - process.env.E2E_SHOW = true; - - const specFiles = [ - `${__dirname}/e2e/paths/01*/*[sS]pec.js`, - `${__dirname}/e2e/paths/02*/*[sS]pec.js`, - `${__dirname}/e2e/paths/03*/*[sS]pec.js`, - `${__dirname}/e2e/paths/04*/*[sS]pec.js`, - `${__dirname}/e2e/paths/05*/*[sS]pec.js`, - `${__dirname}/e2e/paths/06*/*[sS]pec.js`, - `${__dirname}/e2e/paths/07*/*[sS]pec.js`, - `${__dirname}/e2e/paths/08*/*[sS]pec.js`, - `${__dirname}/e2e/paths/09*/*[sS]pec.js`, - `${__dirname}/e2e/paths/10*/*[sS]pec.js`, - `${__dirname}/e2e/paths/11*/*[sS]pec.js`, - `${__dirname}/e2e/paths/12*/*[sS]pec.js`, - `${__dirname}/e2e/paths/13*/*[sS]pec.js`, - `${__dirname}/e2e/paths/**/*[sS]pec.js` - ]; - - return gulp.src(specFiles).pipe(jasmine({ - errorOnFail: false, - timeout: 30000, - config: { - random: false, - // TODO: Waiting for this option to be implemented - // https://github.com/jasmine/jasmine/issues/1533 - stopSpecOnExpectationFailure: false - }, - reporter: [ - new SpecReporter({ - spec: { - displayStacktrace: 'none', - displaySuccessful: true, - displayFailedSpec: true, - displaySpecDuration: true, - }, - summary: { - displayStacktrace: 'raw', - displayPending: false - }, - colors: { - enabled: true, - successful: 'brightGreen', - failed: 'brightRed' - }, - // stacktrace: { - // filter: stacktrace => { - // const lines = stacktrace.split('\n'); - // const filtered = []; - // for (let i = 1; i < lines.length; i++) { - // if (/e2e\/paths/.test(lines[i])) - // filtered.push(lines[i]); - // } - // return filtered.join('\n'); - // } - // } - }) - ] - })); -} - -e2e = gulp.series(docker, async function isBackendReady() { - const attempts = await backendStatus(); - log(`Backend ready after ${attempts} attempt(s)`); - - return attempts; -}, e2eSingleRun); -e2e.description = `Restarts database and runs the e2e tests`; - -async function backendStatus() { - const milliseconds = 250; - return new Promise(resolve => { - let timer; - let attempts = 1; - timer = setInterval(async() => { - try { - const url = `${e2eConfig.url}/api/Applications/status`; - const {body} = await got.get(url); - - if (body == 'true') { - clearInterval(timer); - resolve(attempts); - } else - attempts++; - } catch (error) { - if (error || attempts > 100) // 250ms * 100 => 25s timeout - throw new Error('Could not connect to backend'); - } - }, milliseconds); - }); -} -backendStatus.description = `Performs a simple requests to check the backend status`; - function install() { const install = require('gulp-install'); const print = require('gulp-print'); @@ -431,9 +248,6 @@ module.exports = { back, backOnly, backWatch, - backTest, - launchBackTest, - e2e, i, install, build, @@ -444,6 +258,5 @@ module.exports = { locales, localesRoutes, watch, - docker, - backendStatus, + docker }; diff --git a/jest.front.config.js b/jest.front.config.js index dbea13950e..a03c61d114 100644 --- a/jest.front.config.js +++ b/jest.front.config.js @@ -47,5 +47,6 @@ module.exports = { '^.+\\.js?$': 'babel-jest', '^.+\\.html$': 'html-loader-jest' }, + reporters: ['default', 'jest-junit'] }; diff --git a/loopback/common/models/field-acl.json b/loopback/common/models/field-acl.json index 25ed949b97..a3f74aca27 100644 --- a/loopback/common/models/field-acl.json +++ b/loopback/common/models/field-acl.json @@ -9,19 +9,19 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "model": { - "type": "String" + "type": "string" }, "property":{ - "type": "String" + "type": "string" }, "actionType":{ - "type": "String" + "type": "string" }, "role":{ - "type": "String" + "type": "string" } } } diff --git a/modules/account/back/models/samba-config.json b/modules/account/back/models/samba-config.json index 1bde4cdb6e..732c9b071c 100644 --- a/modules/account/back/models/samba-config.json +++ b/modules/account/back/models/samba-config.json @@ -29,7 +29,7 @@ "type": "string" }, "verifyCert": { - "type": "Boolean" + "type": "boolean" } } } diff --git a/modules/account/back/models/sip-config.json b/modules/account/back/models/sip-config.json index 088f182246..6c5ba3db38 100644 --- a/modules/account/back/models/sip-config.json +++ b/modules/account/back/models/sip-config.json @@ -11,7 +11,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true } } diff --git a/modules/account/back/models/sip.json b/modules/account/back/models/sip.json index 7a7cb8605d..21671f4bfc 100644 --- a/modules/account/back/models/sip.json +++ b/modules/account/back/models/sip.json @@ -8,7 +8,7 @@ }, "properties": { "userFk": { - "type": "Number", + "type": "number", "id": true, "description": "The user id", "mysql": { @@ -16,7 +16,7 @@ } }, "extension": { - "type": "String", + "type": "string", "required": true } }, diff --git a/modules/account/front/role/summary/index.js b/modules/account/front/role/summary/index.js index 0a08fe8b24..4f321fa98f 100644 --- a/modules/account/front/role/summary/index.js +++ b/modules/account/front/role/summary/index.js @@ -6,7 +6,6 @@ class Controller extends Component { this._role = value; this.$.summary = null; if (!value) return; - this.$http.get(`Roles/${value.id}`) .then(res => this.$.summary = res.data); } diff --git a/modules/claim/back/models/claim-beginning.json b/modules/claim/back/models/claim-beginning.json index abdae440a7..afa21f817b 100644 --- a/modules/claim/back/models/claim-beginning.json +++ b/modules/claim/back/models/claim-beginning.json @@ -13,12 +13,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "quantity": { - "type": "Number", + "type": "number", "required": true } }, diff --git a/modules/claim/back/models/claim-destination.json b/modules/claim/back/models/claim-destination.json index 8782fb815c..60f9488991 100644 --- a/modules/claim/back/models/claim-destination.json +++ b/modules/claim/back/models/claim-destination.json @@ -8,12 +8,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "description": { - "type": "String", + "type": "string", "required": true } }, diff --git a/modules/claim/back/models/claim-development.json b/modules/claim/back/models/claim-development.json index 2e8eb2f019..02061fab7b 100644 --- a/modules/claim/back/models/claim-development.json +++ b/modules/claim/back/models/claim-development.json @@ -12,7 +12,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, diff --git a/modules/claim/back/models/claim-dms.json b/modules/claim/back/models/claim-dms.json index 9ef9648864..a215b6bb75 100644 --- a/modules/claim/back/models/claim-dms.json +++ b/modules/claim/back/models/claim-dms.json @@ -17,7 +17,7 @@ ], "properties": { "dmsFk": { - "type": "Number", + "type": "number", "id": true, "required": true } diff --git a/modules/claim/back/models/claim-end.json b/modules/claim/back/models/claim-end.json index d908c252b2..12d79f71b2 100644 --- a/modules/claim/back/models/claim-end.json +++ b/modules/claim/back/models/claim-end.json @@ -12,7 +12,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" } diff --git a/modules/claim/back/models/claim-log.json b/modules/claim/back/models/claim-log.json index 28b3f88ecd..519cfe1ea8 100644 --- a/modules/claim/back/models/claim-log.json +++ b/modules/claim/back/models/claim-log.json @@ -9,40 +9,40 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "originFk": { - "type": "Number", + "type": "number", "required": true }, "userFk": { - "type": "Number" + "type": "number" }, "action": { - "type": "String", + "type": "string", "required": true }, "changedModel": { - "type": "String" + "type": "string" }, "oldInstance": { - "type": "Object" + "type": "object" }, "newInstance": { - "type": "Object" + "type": "object" }, "creationDate": { - "type": "Date" + "type": "date" }, "changedModelId": { - "type": "Number" + "type": "number" }, "changedModelValue": { - "type": "String" + "type": "string" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/claim/back/models/claim-ratio.json b/modules/claim/back/models/claim-ratio.json index 196db72f6c..605da98c66 100644 --- a/modules/claim/back/models/claim-ratio.json +++ b/modules/claim/back/models/claim-ratio.json @@ -9,23 +9,23 @@ "validateUpsert": true, "properties": { "clientFk": { - "type": "Number", + "type": "number", "id": true }, "yearSale": { - "type": "Number" + "type": "number" }, "claimAmount": { - "type": "Number" + "type": "number" }, "claimingRate": { - "type": "Number" + "type": "number" }, "priceIncreasing": { - "type": "Number" + "type": "number" }, "packingRate": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/claim/back/models/claim-reason.json b/modules/claim/back/models/claim-reason.json index 562acc14ef..8d51b8079a 100644 --- a/modules/claim/back/models/claim-reason.json +++ b/modules/claim/back/models/claim-reason.json @@ -8,12 +8,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "description": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/claim/back/models/claim-redelivery.json b/modules/claim/back/models/claim-redelivery.json index 8611a3a44f..d153c7a8ee 100644 --- a/modules/claim/back/models/claim-redelivery.json +++ b/modules/claim/back/models/claim-redelivery.json @@ -8,12 +8,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "description": { - "type": "String", + "type": "string", "required": true } }, diff --git a/modules/claim/back/models/claim-responsible.json b/modules/claim/back/models/claim-responsible.json index 6bd06605b9..bdc5df0eca 100644 --- a/modules/claim/back/models/claim-responsible.json +++ b/modules/claim/back/models/claim-responsible.json @@ -8,16 +8,16 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "description": { - "type": "String", + "type": "string", "required": true }, "responsability": { - "type": "Number", + "type": "number", "required": true } }, diff --git a/modules/claim/back/models/claim-result.json b/modules/claim/back/models/claim-result.json index 468f271de8..2c96306962 100644 --- a/modules/claim/back/models/claim-result.json +++ b/modules/claim/back/models/claim-result.json @@ -8,12 +8,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "description": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/claim/back/models/claim.json b/modules/claim/back/models/claim.json index 431290812a..a3490ccf47 100644 --- a/modules/claim/back/models/claim.json +++ b/modules/claim/back/models/claim.json @@ -12,7 +12,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, diff --git a/modules/client/back/methods/client/sendSms.js b/modules/client/back/methods/client/sendSms.js index cc11d17be8..9d6a12416e 100644 --- a/modules/client/back/methods/client/sendSms.js +++ b/modules/client/back/methods/client/sendSms.js @@ -39,7 +39,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; - const sms = await models.Sms.send(ctx, id, destination, message); + const sms = await models.Sms.send(ctx, destination, message); const logRecord = { originFk: id, userFk: userId, diff --git a/modules/client/back/methods/client/specs/updatePortfolio.spec.js b/modules/client/back/methods/client/specs/updatePortfolio.spec.js index 4830156fc4..f56555c08c 100644 --- a/modules/client/back/methods/client/specs/updatePortfolio.spec.js +++ b/modules/client/back/methods/client/specs/updatePortfolio.spec.js @@ -12,11 +12,13 @@ describe('Client updatePortfolio', () => { const expectedResult = 841.63; - await models.Client.rawSql(`UPDATE vn.client SET salesPersonFk = ${salesPersonId} WHERE id = ${clientId}; `); + const clientQuery = `UPDATE vn.client SET salesPersonFk = ${salesPersonId} WHERE id = ${clientId}; `; + await models.Client.rawSql(clientQuery); await models.Client.updatePortfolio(); - let [salesPerson] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `, null, options); + const portfolioQuery = `SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `; + const [salesPerson] = await models.Client.rawSql(portfolioQuery, null, options); expect(salesPerson.portfolioWeight).toEqual(expectedResult); @@ -26,8 +28,9 @@ describe('Client updatePortfolio', () => { throw e; } }); - // task 3817 - xit('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => { + + it('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => { + pending('task 3817'); const salesPersonId = 19; const tx = await models.Client.beginTransaction({}); @@ -40,7 +43,8 @@ describe('Client updatePortfolio', () => { await models.Client.updatePortfolio(); - let [salesPerson] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `, null, options); + const portfolioQuery = `SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `; + const [salesPerson] = await models.Client.rawSql(portfolioQuery, null, options); expect(salesPerson.portfolioWeight).toEqual(expectedResult); diff --git a/modules/client/back/methods/sms/send.js b/modules/client/back/methods/sms/send.js index 08daf83a1f..94b2b6c276 100644 --- a/modules/client/back/methods/sms/send.js +++ b/modules/client/back/methods/sms/send.js @@ -6,10 +6,6 @@ module.exports = Self => { description: 'Sends SMS to a destination phone', accessType: 'WRITE', accepts: [ - { - arg: 'destinationFk', - type: 'integer' - }, { arg: 'destination', type: 'string', @@ -31,7 +27,7 @@ module.exports = Self => { } }); - Self.send = async(ctx, destinationFk, destination, message) => { + Self.send = async(ctx, destination, message) => { const userId = ctx.req.accessToken.userId; const smsConfig = await Self.app.models.SmsConfig.findOne(); @@ -68,7 +64,6 @@ module.exports = Self => { const newSms = { senderFk: userId, - destinationFk: destinationFk || null, destination: destination, message: message, status: error diff --git a/modules/client/back/methods/sms/send.spec.js b/modules/client/back/methods/sms/send.spec.js index 7ca78b2149..8eee85bd62 100644 --- a/modules/client/back/methods/sms/send.spec.js +++ b/modules/client/back/methods/sms/send.spec.js @@ -3,7 +3,7 @@ const app = require('vn-loopback/server/server'); describe('sms send()', () => { it('should not return status error', async() => { const ctx = {req: {accessToken: {userId: 1}}}; - const result = await app.models.Sms.send(ctx, 1105, '123456789', 'My SMS Body'); + const result = await app.models.Sms.send(ctx, '123456789', 'My SMS Body'); expect(result.status).toBeUndefined(); }); diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index b6bf715b1b..4feb3b1688 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -14,6 +14,9 @@ "Client": { "dataSource": "vn" }, + "ClientConfig": { + "dataSource": "vn" + }, "ClientContact": { "dataSource": "vn" }, diff --git a/modules/client/back/models/address-observation.json b/modules/client/back/models/address-observation.json index 3096c8e5d6..2fdb8bc0f7 100644 --- a/modules/client/back/models/address-observation.json +++ b/modules/client/back/models/address-observation.json @@ -8,7 +8,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, diff --git a/modules/client/back/models/address.json b/modules/client/back/models/address.json index dd533cb32f..0dcbbf7fe1 100644 --- a/modules/client/back/models/address.json +++ b/modules/client/back/models/address.json @@ -14,7 +14,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, @@ -43,10 +43,10 @@ "type": "boolean" }, "longitude": { - "type": "Number" + "type": "number" }, "latitude": { - "type": "Number" + "type": "number" }, "isEqualizated": { "type": "boolean" diff --git a/modules/client/back/models/client-config.json b/modules/client/back/models/client-config.json new file mode 100644 index 0000000000..90d47333dd --- /dev/null +++ b/modules/client/back/models/client-config.json @@ -0,0 +1,22 @@ +{ + "name": "ClientConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "clientConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "riskTolerance": { + "type": "number" + }, + "maxCreditRows": { + "type": "number" + } + } +} \ No newline at end of file diff --git a/modules/client/back/models/client-contact.json b/modules/client/back/models/client-contact.json index ea916c0726..514ebbf5e8 100644 --- a/modules/client/back/models/client-contact.json +++ b/modules/client/back/models/client-contact.json @@ -3,34 +3,34 @@ "description": "Client phone contacts", "base": "Loggable", "log": { - "model": "ClientLog", - "relation": "client", - "showField": "name" + "model": "ClientLog", + "relation": "client", + "showField": "name" }, "options": { - "mysql": { - "table": "clientContact" - } + "mysql": { + "table": "clientContact" + } }, "validateUpsert": true, "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" - }, - "name": { - "type": "string" - }, - "phone": { - "type": "string" - } + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string" + }, + "phone": { + "type": "string" + } }, "relations": { - "client": { - "type": "belongsTo", - "model": "Client", - "foreignKey": "clientFk" - } + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "clientFk" + } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/modules/client/back/models/client-credit-limit.json b/modules/client/back/models/client-credit-limit.json index 5263fb94bd..740f0cf534 100644 --- a/modules/client/back/models/client-credit-limit.json +++ b/modules/client/back/models/client-credit-limit.json @@ -1,26 +1,26 @@ { - "name": "ClientCreditLimit", - "base": "VnModel", - "options": { - "mysql": { - "table": "clientCreditLimit" - } - }, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" + "name": "ClientCreditLimit", + "base": "VnModel", + "options": { + "mysql": { + "table": "clientCreditLimit" + } }, - "maxAmount": { - "type": "Number" + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "maxAmount": { + "type": "number" + } + }, + "relations": { + "role": { + "type": "belongsTo", + "model": "Role", + "foreignKey": "roleFk" + } } - }, - "relations": { - "role": { - "type": "belongsTo", - "model": "Role", - "foreignKey": "roleFk" - } - } } \ No newline at end of file diff --git a/modules/client/back/models/client-credit.js b/modules/client/back/models/client-credit.js new file mode 100644 index 0000000000..01fe8214aa --- /dev/null +++ b/modules/client/back/models/client-credit.js @@ -0,0 +1,23 @@ +module.exports = Self => { + Self.observe('after save', async ctx => { + const instance = ctx.instance; + const models = Self.app.models; + + const clientConfig = await models.ClientConfig.findOne(); + const maxCreditRows = clientConfig.maxCreditRows; + + const clientCredit = await models.ClientCredit.find({ + where: {clientFk: instance.clientFk}, + order: 'created DESC', + limit: maxCreditRows + }, ctx.options); + + const lastCredit = clientCredit[maxCreditRows - 1]; + if (lastCredit) { + await models.ClientCredit.destroyAll({ + clientFk: instance.clientFk, + created: {lt: lastCredit.created} + }, ctx.options); + } + }); +}; diff --git a/modules/client/back/models/client-credit.json b/modules/client/back/models/client-credit.json index 2b71fbe2d6..b92639b80c 100644 --- a/modules/client/back/models/client-credit.json +++ b/modules/client/back/models/client-credit.json @@ -1,36 +1,36 @@ { - "name": "ClientCredit", - "description": "Log of credit changes", - "base": "VnModel", - "options": { - "mysql": { - "table": "clientCredit" - } - }, - "validateUpsert": true, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" + "name": "ClientCredit", + "description": "Log of credit changes", + "base": "VnModel", + "options": { + "mysql": { + "table": "clientCredit" + } }, - "amount": { - "type": "Number" + "validateUpsert": true, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "amount": { + "type": "number" + }, + "created": { + "type": "date" + } }, - "created": { - "type": "date" + "relations": { + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "clientFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + } } - }, - "relations": { - "client": { - "type": "belongsTo", - "model": "Client", - "foreignKey": "clientFk" - }, - "worker": { - "type": "belongsTo", - "model": "Worker", - "foreignKey": "workerFk" - } - } } \ No newline at end of file diff --git a/modules/client/back/models/client-dms.json b/modules/client/back/models/client-dms.json index 28ad219175..88b4349dfa 100644 --- a/modules/client/back/models/client-dms.json +++ b/modules/client/back/models/client-dms.json @@ -13,12 +13,12 @@ }, "properties": { "dmsFk": { - "type": "Number", + "type": "number", "id": true, "required": true }, "clientFk": { - "type": "Number", + "type": "number", "required": true } }, diff --git a/modules/client/back/models/client-log.json b/modules/client/back/models/client-log.json index 50c892e853..9c0933c0c1 100644 --- a/modules/client/back/models/client-log.json +++ b/modules/client/back/models/client-log.json @@ -9,40 +9,40 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "originFk": { - "type": "Number", + "type": "number", "required": true }, "userFk": { - "type": "Number" + "type": "number" }, "action": { - "type": "String", + "type": "string", "required": true }, "changedModel": { - "type": "String" + "type": "string" }, "oldInstance": { - "type": "Object" + "type": "object" }, "newInstance": { - "type": "Object" + "type": "object" }, "creationDate": { - "type": "Date" + "type": "date" }, "changedModelId": { - "type": "Number" + "type": "number" }, "changedModelValue": { - "type": "String" + "type": "string" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/client/back/models/client-observation.json b/modules/client/back/models/client-observation.json index a9c7b483a5..d3059377db 100644 --- a/modules/client/back/models/client-observation.json +++ b/modules/client/back/models/client-observation.json @@ -13,12 +13,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "clientFk": { - "type": "Number" + "type": "number" }, "text": { "type": "string", diff --git a/modules/client/back/models/client-risk.json b/modules/client/back/models/client-risk.json index f76483fca4..eac36affbb 100644 --- a/modules/client/back/models/client-risk.json +++ b/modules/client/back/models/client-risk.json @@ -2,22 +2,22 @@ "name": "ClientRisk", "base": "VnModel", "options": { - "mysql": { - "table": "clientRisk" - } + "mysql": { + "table": "clientRisk" + } }, "properties": { - "clientFk": { - "type": "Number", - "id": true - }, - "companyFk": { - "type": "Number", - "id": true - }, - "amount": { - "type": "Number" - } + "clientFk": { + "type": "number", + "id": true + }, + "companyFk": { + "type": "number", + "id": true + }, + "amount": { + "type": "number" + } }, "relations": { "client": { @@ -31,4 +31,4 @@ "foreignKey": "companyFk" } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/modules/client/back/models/client-sample.json b/modules/client/back/models/client-sample.json index 812da8be8e..920758217c 100644 --- a/modules/client/back/models/client-sample.json +++ b/modules/client/back/models/client-sample.json @@ -14,7 +14,7 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "created": { diff --git a/modules/client/back/models/client-type.json b/modules/client/back/models/client-type.json index a91cc38b6c..eeae845eb8 100644 --- a/modules/client/back/models/client-type.json +++ b/modules/client/back/models/client-type.json @@ -8,17 +8,17 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true }, "code": { - "type": "String" + "type": "string" }, "type": { - "type": "String" + "type": "string" }, "isCreatedAsServed": { - "type": "Number" + "type": "number" } } } \ No newline at end of file diff --git a/modules/client/back/models/client-unpaid.json b/modules/client/back/models/client-unpaid.json index a3d1a684c2..0fc3a91950 100644 --- a/modules/client/back/models/client-unpaid.json +++ b/modules/client/back/models/client-unpaid.json @@ -2,21 +2,21 @@ "name": "ClientUnpaid", "base": "VnModel", "options": { - "mysql": { - "table": "clientUnpaid" - } + "mysql": { + "table": "clientUnpaid" + } }, "properties": { - "clientFk": { - "type": "number", - "id": true - }, - "dated": { - "type": "date" - }, - "amount": { - "type": "Number" - } + "clientFk": { + "type": "number", + "id": true + }, + "dated": { + "type": "date" + }, + "amount": { + "type": "number" + } }, "relations": { "client": { diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index 6404cfba0b..b9951e8bbc 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -12,7 +12,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, @@ -55,16 +55,16 @@ "type": "boolean" }, "credit": { - "type": "Number" + "type": "number" }, "creditInsurance": { - "type": "Number" + "type": "number" }, "iban": { "type": "string" }, "dueDay": { - "type": "Number" + "type": "number" }, "isEqualizated": { "type": "boolean", @@ -105,7 +105,7 @@ "type": "boolean" }, "quality": { - "type": "Number" + "type": "number" }, "isVies": { "type": "boolean" @@ -117,7 +117,7 @@ "type": "string" }, "created": { - "type": "Date" + "type": "date" }, "sageTaxTypeFk": { "type": "number", diff --git a/modules/client/back/models/contact-channel.json b/modules/client/back/models/contact-channel.json index 3a5de2140a..75151b9f92 100644 --- a/modules/client/back/models/contact-channel.json +++ b/modules/client/back/models/contact-channel.json @@ -1,20 +1,20 @@ { - "name": "ContactChannel", - "base": "VnModel", - "options": { - "mysql": { - "table": "contactChannel" - } - }, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" + "name": "ContactChannel", + "base": "VnModel", + "options": { + "mysql": { + "table": "contactChannel" + } }, - "name": { - "type": "string", - "required": true + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string", + "required": true + } } - } } \ No newline at end of file diff --git a/modules/client/back/models/credit-classification.json b/modules/client/back/models/credit-classification.json index 2e636af63c..543f8359e1 100644 --- a/modules/client/back/models/credit-classification.json +++ b/modules/client/back/models/credit-classification.json @@ -1,42 +1,42 @@ { - "name": "CreditClassification", - "description": "Clasified clients", - "base": "VnModel", - "options": { - "mysql": { - "table": "creditClassification" - } - }, - "properties": { - "id": { - "id": true, - "type": "Number", - "description": "Identifier" + "name": "CreditClassification", + "description": "Clasified clients", + "base": "VnModel", + "options": { + "mysql": { + "table": "creditClassification" + } }, - "started": { - "type": "date", - "required": true, - "mysql": { - "columnName": "dateStart" - } + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "started": { + "type": "date", + "required": true, + "mysql": { + "columnName": "dateStart" + } + }, + "finished": { + "type": "date", + "mysql": { + "columnName": "dateEnd" + } + } }, - "finished": { - "type": "date", - "mysql": { - "columnName": "dateEnd" - } + "relations": { + "customer": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "client" + }, + "insurances": { + "type": "hasMany", + "model": "CreditInsurance", + "foreignKey": "creditClassification" + } } - }, - "relations": { - "customer": { - "type": "belongsTo", - "model": "Client", - "foreignKey": "client" - }, - "insurances": { - "type": "hasMany", - "model": "CreditInsurance", - "foreignKey": "creditClassification" - } - } -} +} \ No newline at end of file diff --git a/modules/client/back/models/credit-insurance.json b/modules/client/back/models/credit-insurance.json index 6a9d04677a..db4154978f 100644 --- a/modules/client/back/models/credit-insurance.json +++ b/modules/client/back/models/credit-insurance.json @@ -10,11 +10,11 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "credit": { - "type": "Number" + "type": "number" }, "created": { "type": "date", @@ -23,7 +23,7 @@ } }, "grade": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/client/back/models/customs-agent.json b/modules/client/back/models/customs-agent.json index f72d7bf28b..3a2e0258fa 100644 --- a/modules/client/back/models/customs-agent.json +++ b/modules/client/back/models/customs-agent.json @@ -8,26 +8,26 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "description": "Identifier", "id": true }, "fiscalName": { - "type": "String", + "type": "string", "required": true }, "street": { - "type": "String" + "type": "string" }, "nif": { - "type": "String", + "type": "string", "required": true }, "phone": { - "type": "String" + "type": "string" }, "email": { - "type": "String" + "type": "string" } } } \ No newline at end of file diff --git a/modules/client/back/models/defaulter.json b/modules/client/back/models/defaulter.json index 8293264359..ddff1d2143 100644 --- a/modules/client/back/models/defaulter.json +++ b/modules/client/back/models/defaulter.json @@ -9,19 +9,19 @@ }, "properties": { "id": { - "type": "Number" + "type": "number" }, "created": { - "type": "Date" + "type": "date" }, "amount": { - "type": "Number" + "type": "number" }, "defaulterSinced": { - "type": "Number" + "type": "number" }, "hasChanged": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/client/back/models/greuge-config.json b/modules/client/back/models/greuge-config.json index b72348023f..1ba66668d8 100644 --- a/modules/client/back/models/greuge-config.json +++ b/modules/client/back/models/greuge-config.json @@ -8,7 +8,7 @@ }, "properties": { "freightPickUpPrice": { - "type": "Number" + "type": "number" } }, "acls": [{ diff --git a/modules/client/back/models/greuge-type.json b/modules/client/back/models/greuge-type.json index 5c5b1870de..36b14e147c 100644 --- a/modules/client/back/models/greuge-type.json +++ b/modules/client/back/models/greuge-type.json @@ -9,14 +9,14 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "name": { - "type": "String" + "type": "string" }, "code": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/client/back/models/greuge.json b/modules/client/back/models/greuge.json index 2abc33f7ce..918ff0ca56 100644 --- a/modules/client/back/models/greuge.json +++ b/modules/client/back/models/greuge.json @@ -14,15 +14,15 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "description": { - "type": "String", + "type": "string", "required": true }, "amount": { - "type": "Number", + "type": "number", "required": true }, "shipped": { @@ -32,7 +32,7 @@ "type": "date" }, "greugeTypeFk": { - "type": "Number", + "type": "number", "required": true } diff --git a/modules/client/back/models/incoterms.json b/modules/client/back/models/incoterms.json index 915a5b59a0..fdf743c14c 100644 --- a/modules/client/back/models/incoterms.json +++ b/modules/client/back/models/incoterms.json @@ -8,12 +8,12 @@ }, "properties": { "code": { - "type": "String", + "type": "string", "description": "Identifier", "id": true }, "name": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/client/back/models/mandate-type.json b/modules/client/back/models/mandate-type.json index 8bd46ce194..ec189f089b 100644 --- a/modules/client/back/models/mandate-type.json +++ b/modules/client/back/models/mandate-type.json @@ -9,11 +9,11 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "name": { - "type": "String" + "type": "string" } } } \ No newline at end of file diff --git a/modules/client/back/models/mandate.json b/modules/client/back/models/mandate.json index a671c45f1f..914b23ce27 100644 --- a/modules/client/back/models/mandate.json +++ b/modules/client/back/models/mandate.json @@ -9,11 +9,11 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "code": { - "type": "String" + "type": "string" }, "created": { "type": "date" diff --git a/modules/client/back/models/observation-type.json b/modules/client/back/models/observation-type.json index 5a7bdcfdd1..474c5faac4 100644 --- a/modules/client/back/models/observation-type.json +++ b/modules/client/back/models/observation-type.json @@ -9,15 +9,15 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "description": { - "type": "String", + "type": "string", "required": true }, "code": { - "type": "String", + "type": "string", "required": true } }, diff --git a/modules/client/back/models/pay-method.json b/modules/client/back/models/pay-method.json index 4080a09538..c83c21e2f7 100644 --- a/modules/client/back/models/pay-method.json +++ b/modules/client/back/models/pay-method.json @@ -8,7 +8,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, @@ -23,7 +23,7 @@ "type": "string" }, "outstandingDebt": { - "type": "Number" + "type": "number" }, "isIbanRequiredForClients": { "type": "boolean" diff --git a/modules/client/back/models/recovery.json b/modules/client/back/models/recovery.json index 5a26cd8422..de4183924d 100644 --- a/modules/client/back/models/recovery.json +++ b/modules/client/back/models/recovery.json @@ -2,40 +2,40 @@ "name": "Recovery", "base": "Loggable", "log": { - "model": "ClientLog", - "relation": "client" + "model": "ClientLog", + "relation": "client" }, "options": { - "mysql": { - "table": "recovery" - } + "mysql": { + "table": "recovery" + } }, "properties": { - "id": { - "id": true, - "type": "Number", - "description": "Identifier" - }, - "started": { - "type": "date", - "required": true - }, - "finished": { - "type": "date" - }, - "amount": { - "type": "Number", - "required": true - }, - "period": { - "type": "Number" - } + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "started": { + "type": "date", + "required": true + }, + "finished": { + "type": "date" + }, + "amount": { + "type": "number", + "required": true + }, + "period": { + "type": "number" + } }, "relations": { - "client": { - "type": "belongsTo", - "model": "Client", - "foreignKey": "clientFk" - } + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "clientFk" + } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/modules/client/back/models/sage-tax-type.json b/modules/client/back/models/sage-tax-type.json index b60ef20cd5..97af7353c5 100644 --- a/modules/client/back/models/sage-tax-type.json +++ b/modules/client/back/models/sage-tax-type.json @@ -8,7 +8,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier", "mysql": { diff --git a/modules/client/back/models/sage-transaction-type.json b/modules/client/back/models/sage-transaction-type.json index dbe8f3b39a..1903c650c0 100644 --- a/modules/client/back/models/sage-transaction-type.json +++ b/modules/client/back/models/sage-transaction-type.json @@ -8,7 +8,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier", "mysql": { diff --git a/modules/client/back/models/sms-config.json b/modules/client/back/models/sms-config.json index f48c6198d6..ba78e4a8db 100644 --- a/modules/client/back/models/sms-config.json +++ b/modules/client/back/models/sms-config.json @@ -9,18 +9,18 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "uri": { - "type": "String" + "type": "string" }, "apiKey": { - "type": "String" + "type": "string" }, "title": { - "type": "String" + "type": "string" } } } diff --git a/modules/client/back/models/sms.json b/modules/client/back/models/sms.json index e6e6ff64c4..29438fc67c 100644 --- a/modules/client/back/models/sms.json +++ b/modules/client/back/models/sms.json @@ -9,30 +9,30 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "sender": { - "type": "String", + "type": "string", "required": true }, "destination": { - "type": "String", + "type": "string", "required": true }, "message": { - "type": "String", + "type": "string", "required": true }, "statusCode": { - "type": "Number" + "type": "number" }, "status": { - "type": "String" + "type": "string" }, "created": { - "type": "Date" + "type": "date" } }, "relations": { diff --git a/modules/client/back/models/specs/address.spec.js b/modules/client/back/models/specs/address.spec.js index 81af6ee283..f0b421d351 100644 --- a/modules/client/back/models/specs/address.spec.js +++ b/modules/client/back/models/specs/address.spec.js @@ -14,7 +14,7 @@ describe('loopback model address', () => { } }; - beforeEach(() => { + beforeAll(() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ active: activeCtx }); diff --git a/modules/client/back/models/specs/clientCredit.spec.js b/modules/client/back/models/specs/clientCredit.spec.js new file mode 100644 index 0000000000..fcd86c979f --- /dev/null +++ b/modules/client/back/models/specs/clientCredit.spec.js @@ -0,0 +1,53 @@ +const models = require('vn-loopback/server/server').models; + +describe('Client Credit', () => { + const instance = {id: 1101, name: 'Bruce Banner'}; + + describe('after save', () => { + it('should delete old rows of clientCredit', async() => { + const tx = await models.ClientCredit.beginTransaction({}); + const clientConfig = await models.ClientConfig.findOne({ + where: {id: 1} + }); + + let rowsBefore; + let rowsAfter; + + try { + const options = {transaction: tx}; + const salesAssistant = await models.Account.findOne({ + where: {name: 'salesAssistant'} + }, options); + + rowsBefore = await models.ClientCredit.find({ + where: {clientFk: instance.id}, + order: 'created DESC', + }, options); + + await models.ClientCredit.create({ + amount: 355, + clientFk: instance.id, + workerFk: salesAssistant.id + }, options); + + rowsAfter = await models.ClientCredit.find({ + where: {clientFk: instance.id}, + order: 'created DESC', + }, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + + const FirstRowsBefore = rowsBefore[0]; + const FirstRowsAfter = rowsAfter[0]; + + expect(FirstRowsAfter.id).toBeGreaterThan(FirstRowsBefore.id); + + expect(rowsBefore.length).toBeGreaterThanOrEqual(clientConfig.maxCreditRows); + expect(rowsAfter.length).toEqual(clientConfig.maxCreditRows); + }); + }); +}); diff --git a/modules/client/back/models/tpv-error.json b/modules/client/back/models/tpv-error.json index 61e2a71563..d62203f40a 100644 --- a/modules/client/back/models/tpv-error.json +++ b/modules/client/back/models/tpv-error.json @@ -8,7 +8,7 @@ }, "properties": { "code": { - "type": "String", + "type": "string", "id": true, "description": "Identifier" }, diff --git a/modules/client/back/models/tpv-merchant.json b/modules/client/back/models/tpv-merchant.json index db5c937d86..d4dba6cb11 100644 --- a/modules/client/back/models/tpv-merchant.json +++ b/modules/client/back/models/tpv-merchant.json @@ -8,7 +8,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, diff --git a/modules/client/back/models/tpv-response.json b/modules/client/back/models/tpv-response.json index d3a382b5f0..674ba434c3 100644 --- a/modules/client/back/models/tpv-response.json +++ b/modules/client/back/models/tpv-response.json @@ -8,7 +8,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, diff --git a/modules/client/back/models/tpv-transaction.json b/modules/client/back/models/tpv-transaction.json index 011616d98a..2d926cc407 100644 --- a/modules/client/back/models/tpv-transaction.json +++ b/modules/client/back/models/tpv-transaction.json @@ -8,33 +8,33 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "merchantFk": { - "type": "Number" + "type": "number" }, "clientFk": { - "type": "Number" + "type": "number" }, "receiptFk": { - "type": "Number" + "type": "number" }, "amount": { - "type": "Number" + "type": "number" }, "response": { - "type": "Number" + "type": "number" }, "errorCode": { - "type": "String" + "type": "string" }, "status": { - "type": "String" + "type": "string" }, "created": { - "type": "Date" + "type": "date" } }, "relations": { diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index 454e5e44d9..c6a6e7ff97 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -6,12 +6,7 @@ class Controller extends Dialog { super($element, $, $transclude); this.vnReport = vnReport; - - const tomorrow = new Date(); - tomorrow.setDate(tomorrow.getDate() + 1); - this.receipt = { - payed: tomorrow - }; + this.receipt = {}; } set payed(value) { @@ -72,6 +67,10 @@ class Controller extends Dialog { `${accountingType && accountingType.receiptDescription}`; } this.maxAmount = accountingType && accountingType.maxAmount; + + this.receipt.payed = new Date(); + if (accountingType.daysInFuture) + this.receipt.payed.setDate(this.receipt.payed.getDate() + accountingType.daysInFuture); } } diff --git a/modules/entry/back/methods/entry/latestBuysFilter.js b/modules/entry/back/methods/entry/latestBuysFilter.js index 9693670c8f..6399faa522 100644 --- a/modules/entry/back/methods/entry/latestBuysFilter.js +++ b/modules/entry/back/methods/entry/latestBuysFilter.js @@ -98,9 +98,6 @@ module.exports = Self => { Self.latestBuysFilter = async(ctx, filter, options) => { const myOptions = {}; - if (filter && filter.modelParams) - ctx.args = filter.modelParams; - if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js b/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js index edfdac9884..41971a64c0 100644 --- a/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js +++ b/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js @@ -1,5 +1,6 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); +const activeCtx = {accessToken: {userId: 9}}; describe('entry importBuysPreview()', () => { const entryId = 1; diff --git a/modules/entry/back/models/entry-log.json b/modules/entry/back/models/entry-log.json index c63a55d9e0..6f8edaf25b 100644 --- a/modules/entry/back/models/entry-log.json +++ b/modules/entry/back/models/entry-log.json @@ -9,40 +9,40 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "originFk": { - "type": "Number", + "type": "number", "required": true }, "userFk": { - "type": "Number" + "type": "number" }, "action": { - "type": "String", + "type": "string", "required": true }, "changedModel": { - "type": "String" + "type": "string" }, "oldInstance": { - "type": "Object" + "type": "object" }, "newInstance": { - "type": "Object" + "type": "object" }, "creationDate": { - "type": "Date" + "type": "date" }, "changedModelId": { - "type": "String" + "type": "string" }, "changedModelValue": { - "type": "String" + "type": "string" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/entry/back/models/entry-observation.json b/modules/entry/back/models/entry-observation.json index 535735d839..0c63dd6632 100644 --- a/modules/entry/back/models/entry-observation.json +++ b/modules/entry/back/models/entry-observation.json @@ -13,11 +13,11 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "description": { - "type": "String", + "type": "string", "required": true } }, diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index a4d6f7e837..adeda5e56c 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -148,12 +148,12 @@ - {{::buy.packing | dashIfEmpty}} + {{::buy.packing | dashIfEmpty}} - {{::buy.grouping | dashIfEmpty}} + {{::buy.grouping | dashIfEmpty}} {{::buy.quantity}} diff --git a/modules/entry/front/latest-buys/index.js b/modules/entry/front/latest-buys/index.js index 44c29cb11b..ec1109b818 100644 --- a/modules/entry/front/latest-buys/index.js +++ b/modules/entry/front/latest-buys/index.js @@ -159,8 +159,22 @@ export default class Controller extends Section { lines: rowsToEdit }; - if (this.checkedDummyCount && this.checkedDummyCount > 0) - data.filter = this.$.model.userParams; + if (this.checkedDummyCount && this.checkedDummyCount > 0) { + const params = {}; + if (this.$.model.userParams) { + const userParams = this.$.model.userParams; + for (let param in userParams) { + let newParam = this.exprBuilder(param, userParams[param]); + if (!newParam) + newParam = {[param]: userParams[param]}; + Object.assign(params, newParam); + } + } + if (this.$.model.userFilter) + Object.assign(params, this.$.model.userFilter.where); + + data.filter = params; + } return this.$http.post('Buys/editLatestBuys', data) .then(() => { diff --git a/modules/invoiceIn/front/dueDay/index.html b/modules/invoiceIn/front/dueDay/index.html index 579ef36098..1a1935e728 100644 --- a/modules/invoiceIn/front/dueDay/index.html +++ b/modules/invoiceIn/front/dueDay/index.html @@ -25,6 +25,9 @@ ng-model="invoiceInDueDay.bankFk" url="Banks" show-field="bank" + select-fields="['id','bank']" + order="id" + search-function="$ctrl.bankSearchFunc($search)" rule> {{id}}: {{bank}} diff --git a/modules/invoiceIn/front/dueDay/index.js b/modules/invoiceIn/front/dueDay/index.js index 22b697f7e2..3cc1c81e8a 100644 --- a/modules/invoiceIn/front/dueDay/index.js +++ b/modules/invoiceIn/front/dueDay/index.js @@ -17,6 +17,12 @@ class Controller extends Section { this.card.reload(); }); } + + bankSearchFunc($search) { + return /^\d+$/.test($search) + ? {id: $search} + : {bank: {like: '%' + $search + '%'}}; + } } ngModule.vnComponent('vnInvoiceInDueDay', { diff --git a/modules/invoiceIn/front/tax/index.html b/modules/invoiceIn/front/tax/index.html index c495d44d2f..acc9cf4924 100644 --- a/modules/invoiceIn/front/tax/index.html +++ b/modules/invoiceIn/front/tax/index.html @@ -33,6 +33,13 @@ show-field="id" rule> {{id}}: {{name}} + + + + - \ No newline at end of file + + + + + +
+
{{$ctrl.$t('New expense')}}
+ + + + + + + + + + +
+
+ + + + +
\ No newline at end of file diff --git a/modules/invoiceIn/front/tax/index.js b/modules/invoiceIn/front/tax/index.js index 53cfc55980..d05a77f29f 100644 --- a/modules/invoiceIn/front/tax/index.js +++ b/modules/invoiceIn/front/tax/index.js @@ -1,7 +1,12 @@ import ngModule from '../module'; import Section from 'salix/components/section'; +import UserError from 'core/lib/user-error'; class Controller extends Section { + constructor($element, $, vnWeekDays) { + super($element, $); + this.expense = {}; + } taxRate(invoiceInTax, taxRateSelection) { const taxTypeSage = taxRateSelection && taxRateSelection.rate; const taxableBase = invoiceInTax && invoiceInTax.taxableBase; @@ -26,6 +31,27 @@ class Controller extends Section { this.card.reload(); }); } + + onResponse() { + try { + if (!this.expense.code) + throw new Error(`The code can't be empty`); + if (!this.expense.description) + throw new UserError(`The description can't be empty`); + + const data = [{ + id: this.expense.code, + isWithheld: this.expense.isWithheld, + name: this.expense.description + }]; + + this.$http.post(`Expenses`, data) .then(() => { + this.vnApp.showSuccess(this.$t('Expense saved!')); + }); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + } + } } ngModule.vnComponent('vnInvoiceInTax', { diff --git a/modules/invoiceIn/front/tax/index.spec.js b/modules/invoiceIn/front/tax/index.spec.js index 20d5d40d86..c62ada9ca8 100644 --- a/modules/invoiceIn/front/tax/index.spec.js +++ b/modules/invoiceIn/front/tax/index.spec.js @@ -1,16 +1,19 @@ import './index.js'; import watcher from 'core/mocks/watcher'; import crudModel from 'core/mocks/crud-model'; +const UserError = require('vn-loopback/util/user-error'); describe('InvoiceIn', () => { describe('Component tax', () => { let controller; let $scope; let vnApp; + let $httpBackend; beforeEach(ngModule('invoiceIn')); - beforeEach(inject(($componentController, $rootScope, _vnApp_) => { + beforeEach(inject(($componentController, $rootScope, _vnApp_, _$httpBackend_) => { + $httpBackend = _$httpBackend_; vnApp = _vnApp_; jest.spyOn(vnApp, 'showError'); $scope = $rootScope.$new(); @@ -19,6 +22,7 @@ describe('InvoiceIn', () => { const $element = angular.element(''); controller = $componentController('vnInvoiceInTax', {$element, $scope}); + controller.$.model = crudModel; controller.invoiceIn = {id: 1}; })); @@ -55,5 +59,56 @@ describe('InvoiceIn', () => { expect(controller.card.reload).toHaveBeenCalledWith(); }); }); + + describe('onResponse()', () => { + it('should return success message', () => { + controller.expense = { + code: 7050000005, + isWithheld: 0, + description: 'Test' + }; + + const data = [{ + id: controller.expense.code, + isWithheld: controller.expense.isWithheld, + name: controller.expense.description + }]; + + jest.spyOn(controller.vnApp, 'showSuccess'); + $httpBackend.expect('POST', `Expenses`, data).respond(); + + controller.onResponse(); + $httpBackend.flush(); + + expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Expense saved!'); + }); + + it('should return an error if code is empty', () => { + controller.expense = { + code: null, + isWithheld: 0, + description: 'Test' + }; + + jest.spyOn(controller.vnApp, 'showError'); + controller.onResponse(); + + expect(controller.vnApp.showError).toHaveBeenCalledWith(`The code can't be empty`); + }); + + it('should return an error if description is empty', () => { + controller.expense = { + code: 7050000005, + isWithheld: 0, + description: null + }; + + jest.spyOn(controller.vnApp, 'showError'); + controller.onResponse(); + + expect(controller.vnApp.showError).toHaveBeenCalledWith(`The description can't be empty`); + }); + }); }); }); + diff --git a/modules/invoiceIn/front/tax/locale/es.yml b/modules/invoiceIn/front/tax/locale/es.yml new file mode 100644 index 0000000000..3ff68ea402 --- /dev/null +++ b/modules/invoiceIn/front/tax/locale/es.yml @@ -0,0 +1,7 @@ +Create expense: Crear gasto +New expense: Nuevo gasto +It's a withholding: Es una retención +The fields can't be empty: Los campos no pueden estar vacíos +The code can't be empty: El código no puede estar vacío +The description can't be empty: La descripción no puede estar vacía +Expense saved!: Gasto guardado! \ No newline at end of file diff --git a/modules/invoiceOut/back/models/invoice-out.json b/modules/invoiceOut/back/models/invoice-out.json index 45c4c27747..2bf5182e83 100644 --- a/modules/invoiceOut/back/models/invoice-out.json +++ b/modules/invoiceOut/back/models/invoice-out.json @@ -9,21 +9,21 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "ref": { - "type": "String", + "type": "string", "required": true }, "serial": { - "type": "String" + "type": "string" }, "issued": { "type": "date" }, "amount": { - "type": "Number" + "type": "number" }, "created": { "type": "date" @@ -35,7 +35,7 @@ "type": "date" }, "hasPdf": { - "type": "Boolean" + "type": "boolean" } }, "relations": { diff --git a/modules/invoiceOut/back/models/tax-class.json b/modules/invoiceOut/back/models/tax-class.json index fa56764667..a259b874a4 100644 --- a/modules/invoiceOut/back/models/tax-class.json +++ b/modules/invoiceOut/back/models/tax-class.json @@ -8,16 +8,16 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "description": "Identifier", "id": true }, "description": { - "type": "String", + "type": "string", "required": true }, "code": { - "type": "String", + "type": "string", "required": true } }, diff --git a/modules/invoiceOut/back/models/tax-code.json b/modules/invoiceOut/back/models/tax-code.json index dfd69139e0..b515ca3349 100644 --- a/modules/invoiceOut/back/models/tax-code.json +++ b/modules/invoiceOut/back/models/tax-code.json @@ -8,7 +8,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, @@ -16,7 +16,7 @@ "type": "date" }, "code": { - "type": "String" + "type": "string" }, "rate": { "type": "number" @@ -25,10 +25,10 @@ "type": "number" }, "type": { - "type": "String" + "type": "string" }, "isActive": { - "type": "Boolean" + "type": "boolean" } }, "relations": { diff --git a/modules/invoiceOut/back/models/tax-type.json b/modules/invoiceOut/back/models/tax-type.json index 4e30446b07..46a73835d4 100644 --- a/modules/invoiceOut/back/models/tax-type.json +++ b/modules/invoiceOut/back/models/tax-type.json @@ -8,21 +8,21 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "nickname": { - "type": "String" + "type": "string" }, "serial": { - "type": "String" + "type": "string" }, "TIPOOPE": { - "type": "String" + "type": "string" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index 859486ab17..ef4c9a62ed 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -76,6 +76,13 @@ translate> Show CITES letter + + Refund +
+ + diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js index 7738845f97..b884e50cba 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.js +++ b/modules/invoiceOut/front/descriptor-menu/index.js @@ -116,6 +116,35 @@ class Controller extends Section { invoiceId: this.id }); } + + async refundInvoiceOut() { + let filter = { + where: {refFk: this.invoiceOut.ref} + }; + const tickets = await this.$http.get('Tickets', {filter}); + this.tickets = tickets.data; + this.ticketsIds = []; + for (let ticket of this.tickets) + this.ticketsIds.push(ticket.id); + + filter = { + where: {ticketFk: {inq: this.ticketsIds}} + }; + const sales = await this.$http.get('Sales', {filter}); + this.sales = sales.data; + + const ticketServices = await this.$http.get('TicketServices', {filter}); + this.services = ticketServices.data; + + const params = { + sales: this.sales, + services: this.services + }; + const query = `Sales/refund`; + return this.$http.post(query, params).then(res => { + this.$state.go('ticket.card.sale', {id: res.data}); + }); + } } Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; diff --git a/modules/invoiceOut/front/descriptor-menu/index.spec.js b/modules/invoiceOut/front/descriptor-menu/index.spec.js index fced12e0d5..c84c97a571 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.spec.js +++ b/modules/invoiceOut/front/descriptor-menu/index.spec.js @@ -122,4 +122,34 @@ describe('vnInvoiceOutDescriptorMenu', () => { expect(controller.vnApp.showMessage).toHaveBeenCalled(); }); }); + + // #4084 review with Juan + xdescribe('refundInvoiceOut()', () => { + it('should make a query and go to ticket.card.sale', () => { + controller.$state.go = jest.fn(); + + const invoiceOut = { + id: 1, + ref: 'T1111111' + }; + controller.invoiceOut = invoiceOut; + const tickets = [{id: 1}]; + const sales = [{id: 1}]; + const services = [{id: 2}]; + + $httpBackend.expectGET(`Tickets`).respond(tickets); + $httpBackend.expectGET(`Sales`).respond(sales); + $httpBackend.expectGET(`TicketServices`).respond(services); + + const expectedParams = { + sales: sales, + services: services + }; + $httpBackend.expectPOST(`Sales/refund`, expectedParams).respond(); + controller.refundInvoiceOut(); + $httpBackend.flush(); + + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: undefined}); + }); + }); }); diff --git a/modules/invoiceOut/front/descriptor-menu/locale/es.yml b/modules/invoiceOut/front/descriptor-menu/locale/es.yml index a76f6aad30..8949f1f91b 100644 --- a/modules/invoiceOut/front/descriptor-menu/locale/es.yml +++ b/modules/invoiceOut/front/descriptor-menu/locale/es.yml @@ -12,6 +12,8 @@ Are you sure you want to delete this invoice?: Estas seguro de eliminar esta fac Are you sure you want to clone this invoice?: Estas seguro de clonar esta factura? InvoiceOut booked: Factura asentada Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? +Are you sure you want to refund this invoice?: Estas seguro de querer abonar esta factura? +Create a single ticket with all the content of the current invoice: Crear un ticket unico con todo el contenido de la factura actual Regenerate PDF invoice: Regenerar PDF factura The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado The email can't be empty: El correo no puede estar vacío diff --git a/modules/item/back/models/expense.json b/modules/item/back/models/expense.json index 65af020139..368876fbed 100644 --- a/modules/item/back/models/expense.json +++ b/modules/item/back/models/expense.json @@ -13,13 +13,10 @@ "description": "Identifier" }, "name": { - "type": "String" + "type": "string" }, "isWithheld": { "type": "number" - }, - "taxTypeFk": { - "type": "number" } }, "relations": { @@ -28,13 +25,5 @@ "model": "TaxType", "foreignKey": "taxTypeFk" } - }, - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] + } } \ No newline at end of file diff --git a/modules/item/back/models/genus.json b/modules/item/back/models/genus.json index f18d8e4ae5..007454130d 100644 --- a/modules/item/back/models/genus.json +++ b/modules/item/back/models/genus.json @@ -8,12 +8,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "name": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/item/back/models/ink.json b/modules/item/back/models/ink.json index a3cd857bfe..6a39daafe3 100644 --- a/modules/item/back/models/ink.json +++ b/modules/item/back/models/ink.json @@ -8,12 +8,12 @@ }, "properties": { "id": { - "type": "String", + "type": "string", "id": true, "description": "Identifier" }, "name": { - "type": "String" + "type": "string" }, "showOrder": { "type": "number" diff --git a/modules/item/back/models/item-barcode.json b/modules/item/back/models/item-barcode.json index b9de53dd11..e2ce347cb8 100644 --- a/modules/item/back/models/item-barcode.json +++ b/modules/item/back/models/item-barcode.json @@ -13,12 +13,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "code": { - "type": "String", + "type": "string", "required": true } }, diff --git a/modules/item/back/models/item-botanical.json b/modules/item/back/models/item-botanical.json index 6c465f0eee..8d8fd389f7 100644 --- a/modules/item/back/models/item-botanical.json +++ b/modules/item/back/models/item-botanical.json @@ -12,7 +12,7 @@ }, "properties": { "itemFk": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" } diff --git a/modules/item/back/models/item-log.json b/modules/item/back/models/item-log.json index c52931193d..633a8f86b7 100644 --- a/modules/item/back/models/item-log.json +++ b/modules/item/back/models/item-log.json @@ -9,40 +9,40 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "originFk": { - "type": "Number", + "type": "number", "required": true }, "userFk": { - "type": "Number" + "type": "number" }, "action": { - "type": "String", + "type": "string", "required": true }, "changedModel": { - "type": "String" + "type": "string" }, "oldInstance": { - "type": "Object" + "type": "object" }, "newInstance": { - "type": "Object" + "type": "object" }, "creationDate": { - "type": "Date" + "type": "date" }, "changedModelId": { - "type": "Number" + "type": "number" }, "changedModelValue": { - "type": "String" + "type": "string" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/item/back/models/item-placement.json b/modules/item/back/models/item-placement.json index 7bbb2dc912..0c036ef14f 100644 --- a/modules/item/back/models/item-placement.json +++ b/modules/item/back/models/item-placement.json @@ -8,17 +8,17 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true }, "code": { - "type": "String" + "type": "string" }, "itemFk": { - "type": "Number" + "type": "number" }, "warehouseFk": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/item/back/models/item-shelving-sale.json b/modules/item/back/models/item-shelving-sale.json index 04f505ddd6..8b89a75976 100644 --- a/modules/item/back/models/item-shelving-sale.json +++ b/modules/item/back/models/item-shelving-sale.json @@ -8,15 +8,15 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "quantity": { - "type": "Number" + "type": "number" }, "created": { - "type": "Date" + "type": "date" } }, "relations": { diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index f0391c5651..951a4553ab 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -8,27 +8,27 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "shelve": { - "type": "String" + "type": "string" }, "shelvingFk": { - "type": "String" + "type": "string" }, "itemFk": { - "type": "Number" + "type": "number" }, "deep": { - "type": "Number" + "type": "number" }, "quantity": { - "type": "Number" + "type": "number" }, "created": { - "type": "Date" + "type": "date" } }, "relations": { diff --git a/modules/item/back/models/item-tag.json b/modules/item/back/models/item-tag.json index 6beeb29d39..5660b36288 100644 --- a/modules/item/back/models/item-tag.json +++ b/modules/item/back/models/item-tag.json @@ -13,23 +13,23 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "value": { - "type": "String" + "type": "string" }, "itemFk": { - "type": "Number", + "type": "number", "required": true }, "tagFk": { - "type": "Number", + "type": "number", "required": true }, "priority": { - "type": "Number", + "type": "number", "required": true } }, diff --git a/modules/item/back/models/item-tax-country.json b/modules/item/back/models/item-tax-country.json index 24c6215185..f10a9eb727 100644 --- a/modules/item/back/models/item-tax-country.json +++ b/modules/item/back/models/item-tax-country.json @@ -13,21 +13,21 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "effectived": { - "type": "Boolean" + "type": "boolean" }, "itemFk": { - "type": "Number" + "type": "number" }, "countryFk": { - "type": "Number" + "type": "number" }, "taxClassFk": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/item/back/models/item-type-tag.json b/modules/item/back/models/item-type-tag.json index ca374e00e8..8c4d50a079 100644 --- a/modules/item/back/models/item-type-tag.json +++ b/modules/item/back/models/item-type-tag.json @@ -8,12 +8,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "priority": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json index cb9d5ace80..843d9877f8 100644 --- a/modules/item/back/models/item-type.json +++ b/modules/item/back/models/item-type.json @@ -21,8 +21,11 @@ "life": { "type": "number" }, - "isPackaging": { - "type": "boolean" + "promo": { + "type": "number" + }, + "isUnconventionalSize": { + "type": "number" } }, "relations": { @@ -40,6 +43,16 @@ "type": "belongsTo", "model": "ItemCategory", "foreignKey": "categoryFk" + }, + "itemPackingType": { + "type": "belongsTo", + "model": "ItemPackingType", + "foreignKey": "itemPackingTypeFk" + }, + "temperature": { + "type": "belongsTo", + "model": "Temperature", + "foreignKey": "temperatureFk" } }, "acls": [ diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index efde2690f2..01b6ba093f 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -140,6 +140,9 @@ }, "isFloramondo": { "type": "boolean" + }, + "packingShelve": { + "type": "number" } }, "relations": { diff --git a/modules/item/back/models/producer.json b/modules/item/back/models/producer.json index 81a36f8d1b..593a172b52 100644 --- a/modules/item/back/models/producer.json +++ b/modules/item/back/models/producer.json @@ -8,12 +8,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "name": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/item/back/models/specie.json b/modules/item/back/models/specie.json index c5a1f455e6..f244744169 100644 --- a/modules/item/back/models/specie.json +++ b/modules/item/back/models/specie.json @@ -8,12 +8,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "name": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/item/back/models/tag.json b/modules/item/back/models/tag.json index 4cd1ad74ef..6c5f5c0ba1 100644 --- a/modules/item/back/models/tag.json +++ b/modules/item/back/models/tag.json @@ -8,25 +8,25 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "name": { - "type": "String", + "type": "string", "required": true }, "isFree": { - "type": "Boolean" + "type": "boolean" }, "sourceTable": { - "type": "String" + "type": "string" }, "unit": { - "type": "String" + "type": "string" }, "isQuantitative": { - "type": "Boolean", + "type": "boolean", "mysql": { "columnName": "isQuantitatif" } diff --git a/modules/item/front/index.js b/modules/item/front/index.js index c328b1c8d8..6a8d1b3b78 100644 --- a/modules/item/front/index.js +++ b/modules/item/front/index.js @@ -23,4 +23,4 @@ import './waste/index/'; import './waste/detail'; import './fixed-price'; import './fixed-price-search-panel'; - +import './item-type'; diff --git a/modules/item/front/item-type/basic-data/index.html b/modules/item/front/item-type/basic-data/index.html new file mode 100644 index 0000000000..1417a05ab0 --- /dev/null +++ b/modules/item/front/item-type/basic-data/index.html @@ -0,0 +1,62 @@ + + +
+ + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/item/front/item-type/basic-data/index.js b/modules/item/front/item-type/basic-data/index.js new file mode 100644 index 0000000000..ec280fdf81 --- /dev/null +++ b/modules/item/front/item-type/basic-data/index.js @@ -0,0 +1,12 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section {} + +ngModule.component('vnItemTypeBasicData', { + template: require('./index.html'), + controller: Controller, + bindings: { + itemType: '<' + } +}); diff --git a/modules/item/front/item-type/card/index.html b/modules/item/front/item-type/card/index.html new file mode 100644 index 0000000000..80af6088e0 --- /dev/null +++ b/modules/item/front/item-type/card/index.html @@ -0,0 +1,5 @@ + + + + + diff --git a/modules/item/front/item-type/card/index.js b/modules/item/front/item-type/card/index.js new file mode 100644 index 0000000000..fa6b37340e --- /dev/null +++ b/modules/item/front/item-type/card/index.js @@ -0,0 +1,23 @@ +import ngModule from '../../module'; +import ModuleCard from 'salix/components/module-card'; + +class Controller extends ModuleCard { + reload() { + const filter = { + include: [ + {relation: 'worker'}, + {relation: 'category'}, + {relation: 'itemPackingType'}, + {relation: 'temperature'} + ] + }; + + this.$http.get(`ItemTypes/${this.$params.id}`, {filter}) + .then(res => this.itemType = res.data); + } +} + +ngModule.vnComponent('vnItemTypeCard', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/item/front/item-type/card/index.spec.js b/modules/item/front/item-type/card/index.spec.js new file mode 100644 index 0000000000..ab2314bb91 --- /dev/null +++ b/modules/item/front/item-type/card/index.spec.js @@ -0,0 +1,27 @@ +import './index'; + +describe('component vnItemTypeCard', () => { + let controller; + let $httpBackend; + + beforeEach(ngModule('item')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnItemTypeCard', {$element: null}); + })); + + describe('reload()', () => { + it('should reload the controller data', () => { + controller.$params.id = 1; + + const itemType = {id: 1}; + + $httpBackend.expectGET('ItemTypes/1').respond(itemType); + controller.reload(); + $httpBackend.flush(); + + expect(controller.itemType).toEqual(itemType); + }); + }); +}); diff --git a/modules/item/front/item-type/create/index.html b/modules/item/front/item-type/create/index.html new file mode 100644 index 0000000000..44cb5183de --- /dev/null +++ b/modules/item/front/item-type/create/index.html @@ -0,0 +1,62 @@ + + +
+ + + + + + + + + + + + + + + + + + + + +
diff --git a/modules/item/front/item-type/create/index.js b/modules/item/front/item-type/create/index.js new file mode 100644 index 0000000000..ccf7744be8 --- /dev/null +++ b/modules/item/front/item-type/create/index.js @@ -0,0 +1,15 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + onSubmit() { + return this.$.watcher.submit().then(res => + this.$state.go('item.itemType.card.basicData', {id: res.data.id}) + ); + } +} + +ngModule.component('vnItemTypeCreate', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/item/front/item-type/create/index.spec.js b/modules/item/front/item-type/create/index.spec.js new file mode 100644 index 0000000000..4b000df9a4 --- /dev/null +++ b/modules/item/front/item-type/create/index.spec.js @@ -0,0 +1,34 @@ +import './index'; + +describe('component vnItemTypeCreate', () => { + let $scope; + let $state; + let controller; + + beforeEach(ngModule('item')); + + beforeEach(inject(($componentController, $rootScope, _$state_) => { + $scope = $rootScope.$new(); + $state = _$state_; + $scope.watcher = { + submit: () => { + return { + then: callback => { + callback({data: {id: '1234'}}); + } + }; + } + }; + const $element = angular.element(''); + controller = $componentController('vnItemTypeCreate', {$element, $scope}); + })); + + describe('onSubmit()', () => { + it(`should call submit() on the watcher then expect a callback`, () => { + jest.spyOn($state, 'go'); + controller.onSubmit(); + + expect(controller.$state.go).toHaveBeenCalledWith('item.itemType.card.basicData', {id: '1234'}); + }); + }); +}); diff --git a/modules/item/front/item-type/descriptor/index.html b/modules/item/front/item-type/descriptor/index.html new file mode 100644 index 0000000000..5a0e8ed490 --- /dev/null +++ b/modules/item/front/item-type/descriptor/index.html @@ -0,0 +1,25 @@ + + +
+ + + + + + + + +
+
+
\ No newline at end of file diff --git a/modules/item/front/item-type/descriptor/index.js b/modules/item/front/item-type/descriptor/index.js new file mode 100644 index 0000000000..9322c599ac --- /dev/null +++ b/modules/item/front/item-type/descriptor/index.js @@ -0,0 +1,20 @@ +import ngModule from '../../module'; +import Descriptor from 'salix/components/descriptor'; + +class Controller extends Descriptor { + get itemType() { + return this.entity; + } + + set itemType(value) { + this.entity = value; + } +} + +ngModule.component('vnItemTypeDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + itemType: '<' + } +}); diff --git a/modules/item/front/item-type/index.js b/modules/item/front/item-type/index.js new file mode 100644 index 0000000000..5dcbe40978 --- /dev/null +++ b/modules/item/front/item-type/index.js @@ -0,0 +1,8 @@ +import './main'; +import './index/'; +import './summary'; +import './card'; +import './descriptor'; +import './create'; +import './basic-data'; +import './search-panel'; diff --git a/modules/item/front/item-type/index/index.html b/modules/item/front/item-type/index/index.html new file mode 100644 index 0000000000..50b9eb1722 --- /dev/null +++ b/modules/item/front/item-type/index/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/item/front/item-type/index/index.js b/modules/item/front/item-type/index/index.js new file mode 100644 index 0000000000..54ecba9976 --- /dev/null +++ b/modules/item/front/item-type/index/index.js @@ -0,0 +1,14 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + preview(itemType) { + this.selectedItemType = itemType; + this.$.summary.show(); + } +} + +ngModule.component('vnItemTypeIndex', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/item/front/item-type/index/index.spec.js b/modules/item/front/item-type/index/index.spec.js new file mode 100644 index 0000000000..887c03f7fa --- /dev/null +++ b/modules/item/front/item-type/index/index.spec.js @@ -0,0 +1,34 @@ +import './index'; + +describe('Item', () => { + describe('Component vnItemTypeIndex', () => { + let controller; + let $window; + + beforeEach(ngModule('item')); + + beforeEach(inject(($componentController, _$window_) => { + $window = _$window_; + const $element = angular.element(''); + controller = $componentController('vnItemTypeIndex', {$element}); + })); + + describe('preview()', () => { + it('should show the dialog summary', () => { + controller.$.summary = {show: () => {}}; + jest.spyOn(controller.$.summary, 'show'); + + const itemType = {id: 1}; + + const event = new MouseEvent('click', { + view: $window, + bubbles: true, + cancelable: true + }); + controller.preview(event, itemType); + + expect(controller.$.summary.show).toHaveBeenCalledWith(); + }); + }); + }); +}); diff --git a/modules/item/front/item-type/index/locale/es.yml b/modules/item/front/item-type/index/locale/es.yml new file mode 100644 index 0000000000..1a71ff2122 --- /dev/null +++ b/modules/item/front/item-type/index/locale/es.yml @@ -0,0 +1,2 @@ +Item Type: Familia +New itemType: Nueva familia \ No newline at end of file diff --git a/modules/item/front/item-type/main/index.html b/modules/item/front/item-type/main/index.html new file mode 100644 index 0000000000..faba696c00 --- /dev/null +++ b/modules/item/front/item-type/main/index.html @@ -0,0 +1,18 @@ + + + + + + + + + \ No newline at end of file diff --git a/modules/item/front/item-type/main/index.js b/modules/item/front/item-type/main/index.js new file mode 100644 index 0000000000..0dea00abb3 --- /dev/null +++ b/modules/item/front/item-type/main/index.js @@ -0,0 +1,24 @@ +import ngModule from '../../module'; +import ModuleMain from 'salix/components/module-main'; + +export default class ItemType extends ModuleMain { + exprBuilder(param, value) { + switch (param) { + case 'search': + return /^\d+$/.test(value) + ? {id: value} + : {or: [ + {name: {like: `%${value}%`}}, + {code: {like: `%${value}%`}} + ]}; + case 'name': + case 'code': + return {[param]: {like: `%${value}%`}}; + } + } +} + +ngModule.vnComponent('vnItemType', { + controller: ItemType, + template: require('./index.html') +}); diff --git a/modules/item/front/item-type/main/index.spec.js b/modules/item/front/item-type/main/index.spec.js new file mode 100644 index 0000000000..dcb14ec0ea --- /dev/null +++ b/modules/item/front/item-type/main/index.spec.js @@ -0,0 +1,31 @@ +import './index'; + +describe('Item', () => { + describe('Component vnItemType', () => { + let controller; + + beforeEach(ngModule('item')); + + beforeEach(inject($componentController => { + const $element = angular.element(''); + controller = $componentController('vnItemType', {$element}); + })); + + describe('exprBuilder()', () => { + it('should return a filter based on a search by id', () => { + const filter = controller.exprBuilder('search', '123'); + + expect(filter).toEqual({id: '123'}); + }); + + it('should return a filter based on a search by name or code', () => { + const filter = controller.exprBuilder('search', 'Alstroemeria'); + + expect(filter).toEqual({or: [ + {name: {like: '%Alstroemeria%'}}, + {code: {like: '%Alstroemeria%'}}, + ]}); + }); + }); + }); +}); diff --git a/modules/item/front/item-type/main/locale/es.yml b/modules/item/front/item-type/main/locale/es.yml new file mode 100644 index 0000000000..7aceac46f6 --- /dev/null +++ b/modules/item/front/item-type/main/locale/es.yml @@ -0,0 +1 @@ +Search itemType by id, name or code: Buscar familia por id, nombre o código \ No newline at end of file diff --git a/modules/item/front/item-type/search-panel/index.html b/modules/item/front/item-type/search-panel/index.html new file mode 100644 index 0000000000..4aa7629006 --- /dev/null +++ b/modules/item/front/item-type/search-panel/index.html @@ -0,0 +1,22 @@ +
+
+ + + + + + + + + + + +
+
\ No newline at end of file diff --git a/modules/item/front/item-type/search-panel/index.js b/modules/item/front/item-type/search-panel/index.js new file mode 100644 index 0000000000..17a439c39b --- /dev/null +++ b/modules/item/front/item-type/search-panel/index.js @@ -0,0 +1,7 @@ +import ngModule from '../../module'; +import SearchPanel from 'core/components/searchbar/search-panel'; + +ngModule.component('vnItemTypeSearchPanel', { + template: require('./index.html'), + controller: SearchPanel +}); diff --git a/modules/item/front/item-type/summary/index.html b/modules/item/front/item-type/summary/index.html new file mode 100644 index 0000000000..d003c8f385 --- /dev/null +++ b/modules/item/front/item-type/summary/index.html @@ -0,0 +1,50 @@ + +
+ {{summary.id}} - {{summary.name}} - {{summary.worker.firstName}} {{summary.worker.lastName}} +
+ + +

Basic data

+ + + + + + + + + + + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/modules/item/front/item-type/summary/index.js b/modules/item/front/item-type/summary/index.js new file mode 100644 index 0000000000..7645de8b14 --- /dev/null +++ b/modules/item/front/item-type/summary/index.js @@ -0,0 +1,33 @@ +import ngModule from '../../module'; +import Component from 'core/lib/component'; + +class Controller extends Component { + set itemType(value) { + this._itemType = value; + this.$.summary = null; + if (!value) return; + + const filter = { + include: [ + {relation: 'worker'}, + {relation: 'category'}, + {relation: 'itemPackingType'}, + {relation: 'temperature'} + ] + }; + this.$http.get(`ItemTypes/${value.id}`, {filter}) + .then(res => this.$.summary = res.data); + } + + get itemType() { + return this._itemType; + } +} + +ngModule.component('vnItemTypeSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + itemType: '<' + } +}); diff --git a/modules/item/front/item-type/summary/locale/es.yml b/modules/item/front/item-type/summary/locale/es.yml new file mode 100644 index 0000000000..8f4cef70ff --- /dev/null +++ b/modules/item/front/item-type/summary/locale/es.yml @@ -0,0 +1,4 @@ +Life: Vida +Promo: Promoción +Item packing type: Tipo de embalaje +Is unconventional size: Es de tamaño poco convencional \ No newline at end of file diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 9e21e16975..5743d0ce7f 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -9,7 +9,8 @@ {"state": "item.index", "icon": "icon-item"}, {"state": "item.request", "icon": "icon-buyrequest"}, {"state": "item.waste.index", "icon": "icon-claims"}, - {"state": "item.fixedPrice", "icon": "icon-fixedPrice"} + {"state": "item.fixedPrice", "icon": "icon-fixedPrice"}, + {"state": "item.itemType", "icon": "contact_support"} ], "card": [ {"state": "item.card.basicData", "icon": "settings"}, @@ -20,6 +21,9 @@ {"state": "item.card.diary", "icon": "icon-transaction"}, {"state": "item.card.last-entries", "icon": "icon-regentry"}, {"state": "item.card.log", "icon": "history"} + ], + "itemType": [ + {"state": "item.itemType.card.basicData", "icon": "settings"} ] }, "keybindings": [ @@ -169,6 +173,47 @@ "component": "vn-fixed-price", "description": "Fixed prices", "acl": ["buyer"] + }, + { + "url" : "/item-type?q", + "state": "item.itemType", + "component": "vn-item-type", + "description": "Item Type", + "acl": ["buyer"] + }, + { + "url": "/create", + "state": "item.itemType.create", + "component": "vn-item-type-create", + "description": "New itemType", + "acl": ["buyer"] + }, + { + "url": "/:id", + "state": "item.itemType.card", + "component": "vn-item-type-card", + "abstract": true, + "description": "Detail" + }, + { + "url": "/summary", + "state": "item.itemType.card.summary", + "component": "vn-item-type-summary", + "description": "Summary", + "params": { + "item-type": "$ctrl.itemType" + }, + "acl": ["buyer"] + }, + { + "url": "/basic-data", + "state": "item.itemType.card.basicData", + "component": "vn-item-type-basic-data", + "description": "Basic data", + "params": { + "item-type": "$ctrl.itemType" + }, + "acl": ["buyer"] } ] } \ No newline at end of file diff --git a/modules/monitor/back/methods/sales-monitor/clientsFilter.js b/modules/monitor/back/methods/sales-monitor/clientsFilter.js index 3d8edf6080..a081255512 100644 --- a/modules/monitor/back/methods/sales-monitor/clientsFilter.js +++ b/modules/monitor/back/methods/sales-monitor/clientsFilter.js @@ -43,11 +43,9 @@ module.exports = Self => { TIME(v.stamp) AS hour, DATE(v.stamp) AS dated, wtc.workerFk - FROM hedera.userSession s - JOIN hedera.visitUser v ON v.id = s.userVisitFk + FROM hedera.visitUser v JOIN client c ON c.id = v.userFk - LEFT JOIN account.user u ON c.salesPersonFk = u.id - LEFT JOIN worker w ON c.salesPersonFk = w.id + JOIN account.user u ON c.salesPersonFk = u.id LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk AND CURDATE() BETWEEN sc.started AND sc.ended LEFT JOIN workerTeamCollegues wtc @@ -58,7 +56,9 @@ module.exports = Self => { const where = filter.where; where['wtc.workerFk'] = userId; - stmt.merge(conn.makeSuffix(filter)); + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge(`GROUP BY clientFk, v.stamp`); + stmt.merge(conn.makePagination(filter)); return conn.executeStmt(stmt, myOptions); }; diff --git a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js index 3fcc6c91aa..bcb37830c9 100644 --- a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js +++ b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js @@ -6,12 +6,49 @@ describe('SalesMonitor clientsFilter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 18}}, args: {}}; - const filter = {order: 'dated DESC'}; + + const from = new Date(); + const to = new Date(); + from.setHours(0, 0, 0, 0); + to.setHours(23, 59, 59, 59); + + const filter = { + where: { + 'v.stamp': {between: [from, to]} + } + }; const result = await models.SalesMonitor.clientsFilter(ctx, filter, options); - expect(result.length).toEqual(9); + expect(result.length).toEqual(3); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return the clients web activity filtered', async() => { + const tx = await models.SalesMonitor.beginTransaction({}); + + try { + const options = {transaction: tx}; + const ctx = {req: {accessToken: {userId: 18}}, args: {}}; + const yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + const today = new Date(); + yesterday.setHours(0, 0, 0, 0); + today.setHours(23, 59, 59, 59); + + const filter = { + where: { + 'v.stamp': {between: [yesterday, today]} + } + }; + const result = await models.SalesMonitor.clientsFilter(ctx, filter, options); + + expect(result.length).toEqual(5); await tx.rollback(); } catch (e) { diff --git a/modules/monitor/front/index/clients/index.html b/modules/monitor/front/index/clients/index.html index 35b52fa099..eafc2256ee 100644 --- a/modules/monitor/front/index/clients/index.html +++ b/modules/monitor/front/index/clients/index.html @@ -88,8 +88,16 @@ - - +
+ + + + + { +describe('AgencyTerm createInvoiceIn()', () => { const rows = [ { routeFk: 2, @@ -17,6 +16,7 @@ xdescribe('AgencyTerm createInvoiceIn()', () => { ]; it('should make an invoiceIn', async() => { + pending('Include after #3638 export database'); const tx = await models.AgencyTerm.beginTransaction({}); const options = {transaction: tx}; @@ -32,8 +32,12 @@ xdescribe('AgencyTerm createInvoiceIn()', () => { await models.AgencyTerm.createInvoiceIn(rows, dms, options); const [newInvoiceIn] = await models.InvoiceIn.rawSql('SELECT MAX(id) id FROM invoiceIn', null, options); - const [newInvoiceInDueDay] = await models.InvoiceInDueDay.rawSql('SELECT MAX(id) id FROM invoiceInDueDay', null, options); - const [newInvoiceInTax] = await models.InvoiceInTax.rawSql('SELECT MAX(id) id FROM invoiceInTax', null, options); + + const dueDayQuery = 'SELECT MAX(id) id FROM invoiceInDueDay'; + const [newInvoiceInDueDay] = await models.InvoiceInDueDay.rawSql(dueDayQuery, null, options); + + const taxQuery = 'SELECT MAX(id) id FROM invoiceInTax'; + const [newInvoiceInTax] = await models.InvoiceInTax.rawSql(taxQuery, null, options); expect(newInvoiceIn.id).toBeGreaterThan(oldInvoiceIn.id); expect(newInvoiceInDueDay.id).toBeGreaterThan(oldInvoiceInDueDay.id); diff --git a/modules/route/back/methods/route/specs/guessPriority.spec.js b/modules/route/back/methods/route/specs/guessPriority.spec.js index 892324acfb..902647ba1f 100644 --- a/modules/route/back/methods/route/specs/guessPriority.spec.js +++ b/modules/route/back/methods/route/specs/guessPriority.spec.js @@ -1,9 +1,21 @@ const app = require('vn-loopback/server/server'); +const LoopBackContext = require('loopback-context'); describe('route guessPriority()', () => { const targetRouteId = 7; let routeTicketsToRestore; + const activeCtx = { + accessToken: {userId: 9}, + __: () => {} + }; + + beforeAll(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + afterAll(async() => { let restoreFixtures = []; routeTicketsToRestore.forEach(ticket => { @@ -12,12 +24,9 @@ describe('route guessPriority()', () => { await Promise.all(restoreFixtures); }); - it('should call guessPriority() and then check the tickets in the target route now have their priorities defined', async() => { + it('should call guessPriority() then check all tickets in that route have their priorities defined', async() => { const ctx = { - req: { - accessToken: {userId: 9}, - __: () => {} - }, + req: activeCtx }; routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}}); diff --git a/modules/route/back/models/deliveryPoint.json b/modules/route/back/models/deliveryPoint.json index c6c0a2116f..639f21e353 100644 --- a/modules/route/back/models/deliveryPoint.json +++ b/modules/route/back/models/deliveryPoint.json @@ -8,15 +8,15 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "name": { - "type": "String" + "type": "string" }, "ubication": { - "type": "String" + "type": "string" } } } diff --git a/modules/route/back/models/route-log.json b/modules/route/back/models/route-log.json index abaeeb7225..37f898267f 100644 --- a/modules/route/back/models/route-log.json +++ b/modules/route/back/models/route-log.json @@ -9,40 +9,40 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "originFk": { - "type": "Number", + "type": "number", "required": true }, "userFk": { - "type": "Number" + "type": "number" }, "action": { - "type": "String", + "type": "string", "required": true }, "changedModel": { - "type": "String" + "type": "string" }, "oldInstance": { - "type": "Object" + "type": "object" }, "newInstance": { - "type": "Object" + "type": "object" }, "creationDate": { - "type": "Date" + "type": "date" }, "changedModelId": { - "type": "Number" + "type": "number" }, "changedModelValue": { - "type": "String" + "type": "string" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/route/back/models/route.json b/modules/route/back/models/route.json index bdb641096d..46fb6b76f7 100644 --- a/modules/route/back/models/route.json +++ b/modules/route/back/models/route.json @@ -11,7 +11,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, @@ -22,10 +22,10 @@ "type": "date" }, "kmStart": { - "type": "Number" + "type": "number" }, "kmEnd": { - "type": "Number" + "type": "number" }, "started": { "type": "date" @@ -40,13 +40,13 @@ } }, "cost": { - "type": "Number" + "type": "number" }, "m3": { - "type": "Number" + "type": "number" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/route/back/models/vehicle.json b/modules/route/back/models/vehicle.json index 399480c98f..a35926befd 100644 --- a/modules/route/back/models/vehicle.json +++ b/modules/route/back/models/vehicle.json @@ -8,27 +8,27 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "numberPlate": { - "type": "String" + "type": "string" }, "tradeMark": { - "type": "String" + "type": "string" }, "model": { - "type": "String" + "type": "string" }, "m3": { - "type": "Number" + "type": "number" }, "description": { - "type": "String" + "type": "string" }, "isActive": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/supplier/back/methods/supplier/getSummary.js b/modules/supplier/back/methods/supplier/getSummary.js index c29a2a058e..bf3fa56f58 100644 --- a/modules/supplier/back/methods/supplier/getSummary.js +++ b/modules/supplier/back/methods/supplier/getSummary.js @@ -41,7 +41,9 @@ module.exports = Self => { 'sageTaxTypeFk', 'sageTransactionTypeFk', 'sageWithholdingFk', - 'workerFk' + 'workerFk', + 'supplierActivityFk', + 'healthRegister' ], include: [ { @@ -98,6 +100,12 @@ module.exports = Self => { } } }, + { + relation: 'supplierActivity', + scope: { + fields: ['code', 'name'] + } + } ] }; diff --git a/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js b/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js index 0eec549263..a47e547d19 100644 --- a/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js +++ b/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js @@ -66,6 +66,8 @@ describe('Supplier updateFiscalData', () => { city: 'VALENCIA', provinceFk: 2, countryFk: 1, + supplierActivityFk: 'animals', + healthRegister: '400664487H' }; const result = await app.models.Supplier.updateFiscalData(ctx, supplierId); @@ -80,6 +82,8 @@ describe('Supplier updateFiscalData', () => { expect(result.city).toEqual('VALENCIA'); expect(result.provinceFk).toEqual(2); expect(result.countryFk).toEqual(1); + expect(result.supplierActivityFk).toEqual('animals'); + expect(result.healthRegister).toEqual('400664487H'); // Restores ctx.args = defaultData; diff --git a/modules/supplier/back/methods/supplier/updateFiscalData.js b/modules/supplier/back/methods/supplier/updateFiscalData.js index daa602af05..4604b3f910 100644 --- a/modules/supplier/back/methods/supplier/updateFiscalData.js +++ b/modules/supplier/back/methods/supplier/updateFiscalData.js @@ -56,6 +56,14 @@ module.exports = Self => { { arg: 'countryFk', type: 'any' + }, + { + arg: 'supplierActivityFk', + type: 'string' + }, + { + arg: 'healthRegister', + type: 'string' }], returns: { arg: 'res', diff --git a/modules/supplier/back/model-config.json b/modules/supplier/back/model-config.json index 7c1bba1ec6..dbc387ed20 100644 --- a/modules/supplier/back/model-config.json +++ b/modules/supplier/back/model-config.json @@ -11,6 +11,9 @@ "SupplierAccount": { "dataSource": "vn" }, + "SupplierActivity": { + "dataSource": "vn" + }, "SupplierAgencyTerm": { "dataSource": "vn" }, diff --git a/modules/supplier/back/models/pay-dem.json b/modules/supplier/back/models/pay-dem.json index f214f3e3af..1253c751ce 100644 --- a/modules/supplier/back/models/pay-dem.json +++ b/modules/supplier/back/models/pay-dem.json @@ -8,12 +8,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "payDem": { - "type": "Number" + "type": "number" } } } diff --git a/modules/supplier/back/models/supplier-account.json b/modules/supplier/back/models/supplier-account.json index 8e2838fe59..2ee83338b3 100644 --- a/modules/supplier/back/models/supplier-account.json +++ b/modules/supplier/back/models/supplier-account.json @@ -12,15 +12,15 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "iban": { - "type": "String" + "type": "string" }, "beneficiary": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/supplier/back/models/supplier-activity.json b/modules/supplier/back/models/supplier-activity.json new file mode 100644 index 0000000000..7a0b9a5379 --- /dev/null +++ b/modules/supplier/back/models/supplier-activity.json @@ -0,0 +1,18 @@ +{ + "name": "SupplierActivity", + "base": "VnModel", + "options": { + "mysql": { + "table": "supplierActivity" + } + }, + "properties": { + "code": { + "type": "string", + "id": true + }, + "name": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/modules/supplier/back/models/supplier-contact.json b/modules/supplier/back/models/supplier-contact.json index 104a3a4047..9e13c33a83 100644 --- a/modules/supplier/back/models/supplier-contact.json +++ b/modules/supplier/back/models/supplier-contact.json @@ -12,27 +12,27 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "supplierFk": { - "type": "String" + "type": "string" }, "phone": { - "type": "String" + "type": "string" }, "mobile": { - "type": "String" + "type": "string" }, "email": { - "type": "String" + "type": "string" }, "observation": { - "type": "String" + "type": "string" }, "name": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json index 8b4b8f26f0..b27073ca5c 100644 --- a/modules/supplier/back/models/supplier.json +++ b/modules/supplier/back/models/supplier.json @@ -101,6 +101,12 @@ }, "isPayMethodChecked": { "type": "boolean" + }, + "supplierActivityFk": { + "type": "string" + }, + "healthRegister": { + "type": "string" } }, "relations": { @@ -159,6 +165,11 @@ "type": "hasMany", "model": "SupplierAddress", "foreignKey": "supplierFk" + }, + "supplierActivity": { + "type": "belongsTo", + "model": "SupplierActivity", + "foreignKey": "supplierActivityFk" } } } \ No newline at end of file diff --git a/modules/supplier/front/fiscal-data/index.html b/modules/supplier/front/fiscal-data/index.html index 4f34528f2d..77a5cce4ea 100644 --- a/modules/supplier/front/fiscal-data/index.html +++ b/modules/supplier/front/fiscal-data/index.html @@ -30,6 +30,11 @@ data="sageWithholdings" order="withholding"> + +
@@ -87,6 +92,22 @@ {{id}}: {{transaction}} + + + + + + + + + diff --git a/modules/supplier/front/summary/locale/es.yml b/modules/supplier/front/summary/locale/es.yml index 512b75f9d4..35291e579d 100644 --- a/modules/supplier/front/summary/locale/es.yml +++ b/modules/supplier/front/summary/locale/es.yml @@ -7,4 +7,6 @@ Sage tax type: Tipo de impuesto Sage Sage transaction type: Tipo de transacción Sage Sage withholding: Retencion Sage Go to the supplier: Ir al proveedor -Responsible: Responsable \ No newline at end of file +Responsible: Responsable +Supplier activity: Actividad proveedor +Healt register: Pasaporte sanitario \ No newline at end of file diff --git a/modules/ticket/back/methods/expedition-state/filter.js b/modules/ticket/back/methods/expedition-state/filter.js new file mode 100644 index 0000000000..1483780f70 --- /dev/null +++ b/modules/ticket/back/methods/expedition-state/filter.js @@ -0,0 +1,41 @@ +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +module.exports = Self => { + Self.remoteMethod('filter', { + description: 'Find all instances of the model matched by filter from the data source.', + accessType: 'READ', + accepts: [ + { + arg: 'filter', + type: 'object', + description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', + http: {source: 'query'}, + }, + ], + returns: { + type: ['object'], + root: true, + }, + http: { + path: `/filter`, + verb: 'GET', + }, + }); + + Self.filter = async(filter, options) => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const stmt = new ParameterizedSQL( + `SELECT es.created, u.name, u.id workerFk, est.description state + FROM vn.expeditionState es + JOIN vn.expeditionStateType est ON est.id = es.typeFk + JOIN account.user u ON u.id = es.userFk + `); + stmt.merge(Self.buildSuffix(filter, 'es')); + + return Self.rawStmt(stmt, myOptions); + }; +}; diff --git a/modules/ticket/back/methods/expedition-state/specs/filter.spec.js b/modules/ticket/back/methods/expedition-state/specs/filter.spec.js new file mode 100644 index 0000000000..f144606ebd --- /dev/null +++ b/modules/ticket/back/methods/expedition-state/specs/filter.spec.js @@ -0,0 +1,21 @@ +const models = require('vn-loopback/server/server').models; + +describe('expeditionState filter()', () => { + it('should return the expedition states matching the filter', async() => { + const tx = await models.ExpeditionState.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const filter = {where: {expeditionFk: 5}}; + const response = await models.ExpeditionState.filter(filter, options); + + expect(response.length).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/ticket/back/methods/expedition/filter.js b/modules/ticket/back/methods/expedition/filter.js index 5eb7510b73..538e199388 100644 --- a/modules/ticket/back/methods/expedition/filter.js +++ b/modules/ticket/back/methods/expedition/filter.js @@ -47,9 +47,10 @@ module.exports = Self => { e.packagingFk, es.workerFk expeditionScanWorkerFk, su.name scannerUserName, - es.scanned - FROM - vn.expedition e + es.scanned, + est.description state + FROM vn.expedition e + LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk LEFT JOIN vn.item i2 ON i2.id = e.itemFk INNER JOIN vn.item i1 ON i1.id = e.isBox LEFT JOIN vn.packaging p ON p.id = e.packagingFk diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index 9c87f23d38..83a420a8e9 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -2,19 +2,19 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('refund', { - description: 'Create ticket with the selected lines changing the sign to the quantites', + description: 'Create ticket refund with lines and services changing the sign to the quantites', accessType: 'WRITE', accepts: [{ arg: 'sales', description: 'The sales', type: ['object'], - required: true + required: false }, { - arg: 'ticketId', - type: 'number', - required: true, - description: 'The ticket id' + arg: 'services', + type: ['object'], + required: false, + description: 'The services' }], returns: { type: 'number', @@ -26,7 +26,7 @@ module.exports = Self => { } }); - Self.refund = async(ctx, sales, ticketId, options) => { + Self.refund = async(ctx, sales, services, options) => { const myOptions = {}; let tx; @@ -39,7 +39,6 @@ module.exports = Self => { } try { - const salesIds = []; const userId = ctx.req.accessToken.userId; const isClaimManager = await Self.app.models.Account.hasRole(userId, 'claimManager'); @@ -49,39 +48,47 @@ module.exports = Self => { if (!hasValidRole) throw new UserError(`You don't have privileges to create refund`); - for (let sale of sales) - salesIds.push(sale.id); + const salesIds = []; + if (sales) { + for (let sale of sales) + salesIds.push(sale.id); + } else + salesIds.push(null); + + const servicesIds = []; + if (services) { + for (let service of services) + servicesIds.push(service.id); + } else + servicesIds.push(null); const query = ` DROP TEMPORARY TABLE IF EXISTS tmp.sale; DROP TEMPORARY TABLE IF EXISTS tmp.ticketService; CREATE TEMPORARY TABLE tmp.sale - SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount + SELECT s.id, s.itemFk, s.quantity, s.concept, s.price, s.discount, s.ticketFk FROM sale s WHERE s.id IN (?); - CREATE TEMPORARY TABLE tmp.ticketService( - description VARCHAR(50), - quantity DECIMAL (10,2), - price DECIMAL (10,2), - taxClassFk INT, - ticketServiceTypeFk INT - ); - - CALL vn.ticket_doRefund(?, @newTicket); + CREATE TEMPORARY TABLE tmp.ticketService + SELECT ts.description, ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk, ts.ticketFk + FROM ticketService ts + WHERE ts.id IN (?); + + CALL vn.ticket_doRefund(@newTicket); DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE tmp.ticketService;`; - await Self.rawSql(query, [salesIds, ticketId], myOptions); + await Self.rawSql(query, [salesIds, servicesIds], myOptions); const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions); - ticketId = newTicket.id; + const newTicketId = newTicket.id; if (tx) await tx.commit(); - return ticketId; + return newTicketId; } catch (e) { if (tx) await tx.rollback(); throw e; diff --git a/modules/ticket/back/methods/sale/refundAll.js b/modules/ticket/back/methods/sale/refundAll.js deleted file mode 100644 index 6fcd27f0a6..0000000000 --- a/modules/ticket/back/methods/sale/refundAll.js +++ /dev/null @@ -1,78 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.remoteMethodCtx('refundAll', { - description: 'Create ticket with all lines and services changing the sign to the quantites', - accessType: 'WRITE', - accepts: [{ - arg: 'ticketId', - type: 'number', - required: true, - description: 'The ticket id' - }], - returns: { - type: 'number', - root: true - }, - http: { - path: `/refundAll`, - verb: 'post' - } - }); - - Self.refundAll = async(ctx, ticketId, options) => { - const myOptions = {}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const userId = ctx.req.accessToken.userId; - - const isClaimManager = await Self.app.models.Account.hasRole(userId, 'claimManager'); - const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant'); - const hasValidRole = isClaimManager || isSalesAssistant; - - if (!hasValidRole) - throw new UserError(`You don't have privileges to create refund`); - - const query = ` - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketService; - - CREATE TEMPORARY TABLE tmp.sale - SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - WHERE t.id IN (?); - - CREATE TEMPORARY TABLE tmp.ticketService - SELECT ts.description, - ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk - FROM ticketService ts - WHERE ts.ticketFk IN (?); - - CALL vn.ticket_doRefund(?, @newTicket); - - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE tmp.ticketService;`; - - await Self.rawSql(query, [ticketId, ticketId, ticketId], myOptions); - - const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions); - ticketId = newTicket.id; - - if (tx) await tx.commit(); - - return ticketId; - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js index 40fd6c17ea..5cb353055a 100644 --- a/modules/ticket/back/methods/sale/specs/refund.spec.js +++ b/modules/ticket/back/methods/sale/specs/refund.spec.js @@ -1,20 +1,20 @@ const models = require('vn-loopback/server/server').models; describe('sale refund()', () => { + const sales = [ + {id: 7, ticketFk: 11}, + {id: 8, ticketFk: 11} + ]; + const services = [{id: 1}]; + it('should create ticket with the selected lines changing the sign to the quantites', async() => { const tx = await models.Sale.beginTransaction({}); const ctx = {req: {accessToken: {userId: 9}}}; - const ticketId = 11; - const sales = [ - {id: 7, ticketFk: 11}, - {id: 8, ticketFk: 11} - ]; - try { const options = {transaction: tx}; - const response = await models.Sale.refund(ctx, sales, ticketId, options); + const response = await models.Sale.refund(ctx, sales, services, options); const [newTicketId] = await models.Sale.rawSql('SELECT MAX(t.id) id FROM vn.ticket t;', null, options); expect(response).toEqual(newTicketId.id); @@ -30,17 +30,12 @@ describe('sale refund()', () => { const tx = await models.Sale.beginTransaction({}); const ctx = {req: {accessToken: {userId: 1}}}; - const ticketId = 11; - const sales = [ - {id: 7, ticketFk: 11} - ]; - let error; try { const options = {transaction: tx}; - await models.Sale.refund(ctx, sales, ticketId, options); + await models.Sale.refund(ctx, sales, services, options); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/methods/ticket/sendSms.js b/modules/ticket/back/methods/ticket/sendSms.js index efe8ff206b..a0adcae076 100644 --- a/modules/ticket/back/methods/ticket/sendSms.js +++ b/modules/ticket/back/methods/ticket/sendSms.js @@ -45,7 +45,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; try { - const sms = await Self.app.models.Sms.send(ctx, id, destination, message); + const sms = await Self.app.models.Sms.send(ctx, destination, message); const logRecord = { originFk: id, userFk: userId, diff --git a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js index 04e1c140a6..9b629e6346 100644 --- a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js @@ -28,8 +28,9 @@ describe('ticket setDeleted()', () => { expect(error.message).toEqual('You must delete the claim id %d first'); }); - // test excluded by task #3693 - xit('should delete the ticket, remove the stowaway link and change the stowaway ticket state to "FIXING" and get rid of the itemshelving', async() => { + + it('should delete ticket, remove stowaway and itemshelving then change stowaway state to "FIXING" ', async() => { + pending('test excluded by task #3693'); const tx = await models.Ticket.beginTransaction({}); try { diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json index 5d5f086946..41885ee33f 100644 --- a/modules/ticket/back/model-config.json +++ b/modules/ticket/back/model-config.json @@ -14,6 +14,9 @@ "Expedition": { "dataSource": "vn" }, + "ExpeditionState": { + "dataSource": "vn" + }, "Packaging": { "dataSource": "vn" }, diff --git a/modules/ticket/back/models/annual-average-invoiced.json b/modules/ticket/back/models/annual-average-invoiced.json index d1f5820119..02f097d41c 100644 --- a/modules/ticket/back/models/annual-average-invoiced.json +++ b/modules/ticket/back/models/annual-average-invoiced.json @@ -8,7 +8,7 @@ }, "properties": { "invoiced": { - "type": "Number" + "type": "number" }, "clientFk": { "id": true diff --git a/modules/ticket/back/models/component-type.json b/modules/ticket/back/models/component-type.json index d72217a24c..26daf52164 100644 --- a/modules/ticket/back/models/component-type.json +++ b/modules/ticket/back/models/component-type.json @@ -9,11 +9,11 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "type": { - "type": "String" + "type": "string" }, "isBase":{ "type":"Boolean" diff --git a/modules/ticket/back/models/component.json b/modules/ticket/back/models/component.json index 002b4804fd..46ac492c52 100644 --- a/modules/ticket/back/models/component.json +++ b/modules/ticket/back/models/component.json @@ -9,26 +9,26 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "name": { - "type": "String" + "type": "string" }, "classRate": { - "type": "Number" + "type": "number" }, "tax": { - "type": "Number" + "type": "number" }, "isRenewable": { - "type": "Number" + "type": "number" }, "typeFk": { - "type": "Number" + "type": "number" }, "code": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/ticket/back/models/expedition-state.js b/modules/ticket/back/models/expedition-state.js new file mode 100644 index 0000000000..af76af718a --- /dev/null +++ b/modules/ticket/back/models/expedition-state.js @@ -0,0 +1,3 @@ +module.exports = function(Self) { + require('../methods/expedition-state/filter')(Self); +}; diff --git a/modules/ticket/back/models/expedition-state.json b/modules/ticket/back/models/expedition-state.json new file mode 100644 index 0000000000..262eb2e385 --- /dev/null +++ b/modules/ticket/back/models/expedition-state.json @@ -0,0 +1,28 @@ +{ + "name": "ExpeditionState", + "base": "VnModel", + "options": { + "mysql": { + "table": "expeditionState" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "created": { + "type": "date" + }, + "expeditionFk": { + "type": "number" + }, + "typeFk": { + "type": "number" + }, + "userFk": { + "type": "number" + } + } +} diff --git a/modules/ticket/back/models/expedition.json b/modules/ticket/back/models/expedition.json index c0b8d65085..fc94f185df 100644 --- a/modules/ticket/back/models/expedition.json +++ b/modules/ticket/back/models/expedition.json @@ -13,17 +13,17 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "isBox": { - "type": "Number" + "type": "number" }, "created": { - "type": "Date" + "type": "date" }, "counter": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/ticket/back/models/sale-checked.json b/modules/ticket/back/models/sale-checked.json index 8ac52d598f..96d7905055 100644 --- a/modules/ticket/back/models/sale-checked.json +++ b/modules/ticket/back/models/sale-checked.json @@ -8,7 +8,7 @@ }, "properties": { "isChecked": { - "type": "Number" + "type": "number" }, "saleFk": { "id": true diff --git a/modules/ticket/back/models/sale-component.json b/modules/ticket/back/models/sale-component.json index 3b7991fbb9..bf0f73e290 100644 --- a/modules/ticket/back/models/sale-component.json +++ b/modules/ticket/back/models/sale-component.json @@ -8,14 +8,14 @@ }, "properties": { "value": { - "type": "Number" + "type": "number" }, "saleFk": { - "type": "Number", + "type": "number", "id": 2 }, "componentFk": { - "type": "Number", + "type": "number", "id": 1 } }, diff --git a/modules/ticket/back/models/sale-tracking.json b/modules/ticket/back/models/sale-tracking.json index 43b0df160e..4a103ea15c 100644 --- a/modules/ticket/back/models/sale-tracking.json +++ b/modules/ticket/back/models/sale-tracking.json @@ -9,23 +9,23 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "saleFk": { - "type": "Number" + "type": "number" }, "stateFk": { - "type": "Number" + "type": "number" }, "isChecked": { "type": "boolean" }, "created": { - "type": "Date" + "type": "date" }, "originalQuantity": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index 2652aded2a..2a4457263d 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -7,7 +7,6 @@ module.exports = Self => { require('../methods/sale/updateConcept')(Self); require('../methods/sale/recalculatePrice')(Self); require('../methods/sale/refund')(Self); - require('../methods/sale/refundAll')(Self); require('../methods/sale/canEdit')(Self); Self.validatesPresenceOf('concept', { diff --git a/modules/ticket/back/models/sale.json b/modules/ticket/back/models/sale.json index 767a3e59e1..e18f0291f5 100644 --- a/modules/ticket/back/models/sale.json +++ b/modules/ticket/back/models/sale.json @@ -14,30 +14,33 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "concept": { - "type": "String", + "type": "string", "required": true }, "quantity": { - "type": "Number" + "type": "number" }, "price": { - "type": "Number" + "type": "number" }, "discount": { - "type": "Number" + "type": "number" }, "reserved": { "type": "boolean" }, "isPicked": { - "type": "Number" + "type": "number" }, "created": { "type": "date" + }, + "originalQuantity":{ + "type": "number" } }, "relations": { diff --git a/modules/ticket/back/models/stowaway.json b/modules/ticket/back/models/stowaway.json index 5a925cd203..ef3aeb40da 100644 --- a/modules/ticket/back/models/stowaway.json +++ b/modules/ticket/back/models/stowaway.json @@ -9,15 +9,15 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "shipFk": { - "type": "Number", + "type": "number", "required": false }, "created":{ - "type": "Date", + "type": "date", "required": false } }, diff --git a/modules/ticket/back/models/ticket-config.json b/modules/ticket/back/models/ticket-config.json index ff6818bb5d..a1c96e7f6a 100644 --- a/modules/ticket/back/models/ticket-config.json +++ b/modules/ticket/back/models/ticket-config.json @@ -9,11 +9,11 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "scopeDays": { - "type": "Number" + "type": "number" } } } diff --git a/modules/ticket/back/models/ticket-last-state.json b/modules/ticket/back/models/ticket-last-state.json index 6c8bc66d5f..e871a8ee68 100644 --- a/modules/ticket/back/models/ticket-last-state.json +++ b/modules/ticket/back/models/ticket-last-state.json @@ -12,10 +12,10 @@ }, "ticketFk": { "id": true, - "type": "Number" + "type": "number" }, "ticketTrackingFk": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/ticket/back/models/ticket-log.json b/modules/ticket/back/models/ticket-log.json index 950742e986..169bdeaa04 100644 --- a/modules/ticket/back/models/ticket-log.json +++ b/modules/ticket/back/models/ticket-log.json @@ -9,40 +9,40 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "originFk": { - "type": "Number", + "type": "number", "required": true }, "userFk": { - "type": "Number" + "type": "number" }, "action": { - "type": "String", + "type": "string", "required": true }, "changedModel": { - "type": "String" + "type": "string" }, "oldInstance": { - "type": "Object" + "type": "object" }, "newInstance": { - "type": "Object" + "type": "object" }, "creationDate": { - "type": "Date" + "type": "date" }, "changedModelId": { - "type": "Number" + "type": "number" }, "changedModelValue": { - "type": "String" + "type": "string" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/ticket/back/models/ticket-observation.json b/modules/ticket/back/models/ticket-observation.json index ba4f85ce8b..9035e44405 100644 --- a/modules/ticket/back/models/ticket-observation.json +++ b/modules/ticket/back/models/ticket-observation.json @@ -13,11 +13,11 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "description": { - "type": "String", + "type": "string", "required": true } }, diff --git a/modules/ticket/back/models/ticket-packaging.json b/modules/ticket/back/models/ticket-packaging.json index feea541faa..533f4064cd 100644 --- a/modules/ticket/back/models/ticket-packaging.json +++ b/modules/ticket/back/models/ticket-packaging.json @@ -13,17 +13,17 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "quantity": { - "type": "Number" + "type": "number" }, "created": { - "type": "Date" + "type": "date" }, "pvp": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/ticket/back/models/ticket-request.json b/modules/ticket/back/models/ticket-request.json index f216cd5319..01601c7f6c 100644 --- a/modules/ticket/back/models/ticket-request.json +++ b/modules/ticket/back/models/ticket-request.json @@ -12,29 +12,29 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "description": { - "type": "String", + "type": "string", "required": true }, "created": { - "type": "Date" + "type": "date" }, "quantity": { - "type": "Number", + "type": "number", "required": true }, "price": { - "type": "Number" + "type": "number" }, "isOk": { - "type": "Boolean" + "type": "boolean" }, "response": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/ticket/back/models/ticket-service-type.json b/modules/ticket/back/models/ticket-service-type.json index 623d0f3988..ec2c9232a5 100644 --- a/modules/ticket/back/models/ticket-service-type.json +++ b/modules/ticket/back/models/ticket-service-type.json @@ -7,16 +7,16 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "name": { - "type": "String", + "type": "string", "required": true }, "expenseFk": { - "type": "Number", + "type": "number", "mysql": { "columnName": "expenceFk" } diff --git a/modules/ticket/back/models/ticket-service.json b/modules/ticket/back/models/ticket-service.json index 8b0c490a8c..347b6b976e 100644 --- a/modules/ticket/back/models/ticket-service.json +++ b/modules/ticket/back/models/ticket-service.json @@ -13,32 +13,32 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "ticketFk": { - "type": "Number", + "type": "number", "required": true }, "description": { - "type": "String", + "type": "string", "required": true }, "quantity": { - "type": "Number", + "type": "number", "required": true }, "price": { - "type": "Number", + "type": "number", "required": true }, "taxClassFk": { - "type": "Number", + "type": "number", "required": true }, "ticketServiceTypeFk": { - "type": "Number", + "type": "number", "required": true } }, diff --git a/modules/ticket/back/models/ticket-tracking.json b/modules/ticket/back/models/ticket-tracking.json index c2c365013e..e80e2f8f4a 100644 --- a/modules/ticket/back/models/ticket-tracking.json +++ b/modules/ticket/back/models/ticket-tracking.json @@ -14,20 +14,20 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "created": { - "type": "Date" + "type": "date" }, "ticketFk": { - "type": "Number" + "type": "number" }, "stateFk": { - "type": "Number" + "type": "number" }, "workerFk": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/ticket/back/models/ticket-update-action.json b/modules/ticket/back/models/ticket-update-action.json index 3072c21727..e69f7e1ab4 100644 --- a/modules/ticket/back/models/ticket-update-action.json +++ b/modules/ticket/back/models/ticket-update-action.json @@ -9,15 +9,15 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "description": { - "type": "String", + "type": "string", "required": true }, "code": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/ticket/back/models/ticket-weekly.json b/modules/ticket/back/models/ticket-weekly.json index 6d432831f2..d81baf4adb 100644 --- a/modules/ticket/back/models/ticket-weekly.json +++ b/modules/ticket/back/models/ticket-weekly.json @@ -14,10 +14,10 @@ "properties": { "ticketFk": { "id": true, - "type": "Number" + "type": "number" }, "weekDay": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index c99575d423..1dcfd669ff 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -302,7 +302,7 @@ \ No newline at end of file diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 1c80a6f9db..c6388654ef 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -273,9 +273,21 @@ class Controller extends Section { .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); } - refundAll() { - const params = {ticketId: this.id}; - const query = `Sales/refundAll`; + async refund() { + const filter = { + where: {ticketFk: this.id} + }; + const sales = await this.$http.get('Sales', {filter}); + this.sales = sales.data; + + const ticketServices = await this.$http.get('TicketServices', {filter}); + this.services = ticketServices.data; + + const params = { + sales: this.sales, + services: this.services + }; + const query = `Sales/refund`; return this.$http.post(query, params).then(res => { this.$state.go('ticket.card.sale', {id: res.data}); }); diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 75f3522aed..af377d8ea7 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -262,16 +262,27 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { }); }); - describe('refundAll()', () => { + // #4084 review with Juan + xdescribe('refund()', () => { it('should make a query and go to ticket.card.sale', () => { - jest.spyOn(controller.$state, 'go').mockReturnValue(); - const expectedParams = {ticketId: ticket.id}; + controller.$state.go = jest.fn(); - $httpBackend.expect('POST', `Sales/refundAll`, expectedParams).respond({ticketId: 16}); - controller.refundAll(); + controller._id = ticket.id; + const sales = [{id: 1}]; + const services = [{id: 2}]; + + $httpBackend.expectGET(`Sales`).respond(sales); + $httpBackend.expectGET(`TicketServices`).respond(services); + + const expectedParams = { + sales: sales, + services: services + }; + $httpBackend.expectPOST(`Sales/refund`, expectedParams).respond(); + controller.refund(); $httpBackend.flush(); - expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: {ticketId: ticket.id}}); + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: undefined}); }); }); diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index bdbb2c3e8d..a41d368f6b 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -19,10 +19,9 @@ Package type Counter externalId - Packager Created - Palletizer - Scanned + State + @@ -33,7 +32,7 @@ vn-tooltip="Delete expedition"> - {{expedition.id | zeroFill:6}} + {{expedition.id | zeroFill:6}} {{::expedition.freightItemName}} {{::expedition.counter}} {{::expedition.externalId}} - - - {{::expedition.userName | dashIfEmpty}} - - {{::expedition.created | date:'dd/MM/yyyy HH:mm'}} + {{::expedition.state}} - - {{::expedition.scannerUserName | dashIfEmpty}} - + + - {{::expedition.scanned | date:'dd/MM/yyyy HH:mm'}} @@ -77,4 +71,44 @@ on-accept="$ctrl.onDialogAccept($data)" question="Delete expedition" message="Are you sure you want to delete this expedition?"> - \ No newline at end of file + + + + + + + + + + + State + Worker + Created + + + + + {{::expeditionState.state}} + + + {{::expeditionState.name || 'System' | translate}} + + + {{::expeditionState.created | date:'dd/MM/yyyy HH:mm'}} + + + + + + + + \ No newline at end of file diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 0c395e6ce1..120d89bb29 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -6,6 +6,11 @@ class Controller extends Section { return this.$http.delete(`Expeditions/${id}`) .then(() => this.$.model.refresh()); } + + showLog(expedition) { + this.expedition = expedition; + this.$.statusLog.show(); + } } ngModule.vnComponent('vnTicketExpedition', { diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js index 425539aef0..586ef21096 100644 --- a/modules/ticket/front/expedition/index.spec.js +++ b/modules/ticket/front/expedition/index.spec.js @@ -5,10 +5,12 @@ describe('Ticket', () => { let controller; let $scope; let $httpBackend; + let $window; beforeEach(ngModule('ticket')); - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$window_) => { + $window = _$window_; $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.model = { @@ -30,5 +32,23 @@ describe('Ticket', () => { expect($scope.model.refresh).toHaveBeenCalledWith(); }); }); + + describe('showLog()', () => { + it('should show the popover status log', () => { + controller.$.statusLog = {show: () => {}}; + jest.spyOn(controller.$.statusLog, 'show'); + + const expedition = {id: 1}; + + const event = new MouseEvent('click', { + view: $window, + bubbles: true, + cancelable: true + }); + controller.showLog(event, expedition); + + expect(controller.$.statusLog.show).toHaveBeenCalledWith(); + }); + }); }); }); diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml new file mode 100644 index 0000000000..d23cf25af3 --- /dev/null +++ b/modules/ticket/front/expedition/locale/es.yml @@ -0,0 +1 @@ +Status log: Hitorial de estados \ No newline at end of file diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index bb8a81bc4c..987333e289 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -483,7 +483,7 @@ class Controller extends Section { const sales = this.selectedValidSales(); if (!sales) return; - const params = {sales: sales, ticketId: this.ticket.id}; + const params = {sales: sales}; const query = `Sales/refund`; this.resetChanges(); this.$http.post(query, params).then(res => { diff --git a/modules/ticket/front/services/index.html b/modules/ticket/front/services/index.html index 13fd84b003..bb5505ce6d 100644 --- a/modules/ticket/front/services/index.html +++ b/modules/ticket/front/services/index.html @@ -42,7 +42,7 @@ { +describe('Travel cloneWithEntries()', () => { const models = app.models; const travelId = 5; const currentUserId = 1102; @@ -9,44 +8,45 @@ xdescribe('Travel cloneWithEntries()', () => { let travelBefore; let newTravelId; - afterAll(async() => { - try { - const entries = await models.Entry.find({ - where: { - travelFk: newTravelId - } - }); - const entriesId = entries.map(entry => entry.id); + // afterAll(async() => { + // try { + // const entries = await models.Entry.find({ + // where: { + // travelFk: newTravelId + // } + // }); + // const entriesId = entries.map(entry => entry.id); - // Destroy all entries buys - await models.Buy.destroyAll({ - where: { - entryFk: {inq: entriesId} - } - }); + // // Destroy all entries buys + // await models.Buy.destroyAll({ + // where: { + // entryFk: {inq: entriesId} + // } + // }); - // Destroy travel entries - await models.Entry.destroyAll({ - where: { - travelFk: newTravelId - } - }); + // // Destroy travel entries + // await models.Entry.destroyAll({ + // where: { + // travelFk: newTravelId + // } + // }); - // Destroy new travel - await models.Travel.destroyById(newTravelId); + // // Destroy new travel + // await models.Travel.destroyById(newTravelId); - // Restore original travel shipped & landed - const travel = await models.Travel.findById(travelId); - await travel.updateAttributes({ - shipped: travelBefore.shipped, - landed: travelBefore.landed - }); - } catch (error) { - console.error(error); - } - }); + // // Restore original travel shipped & landed + // const travel = await models.Travel.findById(travelId); + // await travel.updateAttributes({ + // shipped: travelBefore.shipped, + // landed: travelBefore.landed + // }); + // } catch (error) { + // console.error(error); + // } + // }); it(`should clone the travel and the containing entries`, async() => { + pending('#2687 - Cannot make a data rollback because of the triggers'); const warehouseThree = 3; const agencyModeOne = 1; const yesterday = new Date(); diff --git a/modules/travel/back/models/thermograph.json b/modules/travel/back/models/thermograph.json index 2519fffc40..bd9ad3119f 100644 --- a/modules/travel/back/models/thermograph.json +++ b/modules/travel/back/models/thermograph.json @@ -8,13 +8,13 @@ }, "properties": { "id": { - "type": "String", + "type": "string", "id": true, "description": "Identifier", "required": true }, "model": { - "type": "String", + "type": "string", "required": true } } diff --git a/modules/travel/back/models/travel-log.json b/modules/travel/back/models/travel-log.json index d53be88f1c..d07f83e50d 100644 --- a/modules/travel/back/models/travel-log.json +++ b/modules/travel/back/models/travel-log.json @@ -9,40 +9,40 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "originFk": { - "type": "Number", + "type": "number", "required": true }, "userFk": { - "type": "Number" + "type": "number" }, "action": { - "type": "String", + "type": "string", "required": true }, "changedModel": { - "type": "String" + "type": "string" }, "oldInstance": { - "type": "Object" + "type": "object" }, "newInstance": { - "type": "Object" + "type": "object" }, "creationDate": { - "type": "Date" + "type": "date" }, "changedModelId": { - "type": "String" + "type": "string" }, "changedModelValue": { - "type": "String" + "type": "string" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json index cd2f1d6535..95330e2636 100644 --- a/modules/travel/back/models/travel.json +++ b/modules/travel/back/models/travel.json @@ -12,7 +12,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, @@ -23,28 +23,28 @@ "type": "date" }, "isDelivered": { - "type": "Boolean" + "type": "boolean" }, "isReceived": { - "type": "Boolean" + "type": "boolean" }, "ref": { - "type": "String" + "type": "string" }, "totalEntries": { - "type": "Number" + "type": "number" }, "m3": { - "type": "Number" + "type": "number" }, "kg": { - "type": "Number" + "type": "number" }, "cargoSupplierFk": { - "type": "Number" + "type": "number" }, "agencyModeFk": { - "type": "Number", + "type": "number", "mysql": { "columnName": "agencyFk" } diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 44bda5627c..82cb5038e2 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -135,7 +135,8 @@ module.exports = Self => { function formatDate(date) { let day = date.getDate(); if (day < 10) day = `0${day}`; - let month = date.getMonth(); + + let month = date.getMonth() + 1; if (month < 10) month = `0${month}`; let year = date.getFullYear(); diff --git a/modules/worker/back/methods/worker/deleteAbsence.js b/modules/worker/back/methods/worker/deleteAbsence.js index 72e9243d9f..45dc04b2de 100644 --- a/modules/worker/back/methods/worker/deleteAbsence.js +++ b/modules/worker/back/methods/worker/deleteAbsence.js @@ -87,7 +87,7 @@ module.exports = Self => { function formatDate(date) { let day = date.getDate(); if (day < 10) day = `0${day}`; - let month = date.getMonth(); + let month = date.getMonth() + 1; if (month < 10) month = `0${month}`; let year = date.getFullYear(); diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index c155e331de..c6b984bd21 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -20,6 +20,9 @@ "EducationLevel": { "dataSource": "vn" }, + "Sector": { + "dataSource": "vn" + }, "WorkCenter": { "dataSource": "vn" }, diff --git a/modules/worker/back/models/absence-type.json b/modules/worker/back/models/absence-type.json index f4e9aed182..7fc62f780f 100644 --- a/modules/worker/back/models/absence-type.json +++ b/modules/worker/back/models/absence-type.json @@ -9,19 +9,19 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "name": { - "type": "String" + "type": "string" }, "rgb": { - "type": "String" + "type": "string" }, "code": { - "type": "String" + "type": "string" }, "holidayEntitlementRate": { - "type": "Number" + "type": "number" } }, "acls": [ diff --git a/modules/worker/back/models/calendar-holiday.json b/modules/worker/back/models/calendar-holiday.json index 5444525530..f7777c2b7f 100644 --- a/modules/worker/back/models/calendar-holiday.json +++ b/modules/worker/back/models/calendar-holiday.json @@ -9,14 +9,14 @@ "properties": { "calendarHolidaysNameFk": { "id": true, - "type": "Number" + "type": "number" }, "calendarHolidaysTypeFk": { "id": true, - "type": "Number" + "type": "number" }, "dated": { - "type": "Date" + "type": "date" } }, "relations": { diff --git a/modules/worker/back/models/calendar-holidays-name.json b/modules/worker/back/models/calendar-holidays-name.json index d04ef9c74a..d2798f106c 100644 --- a/modules/worker/back/models/calendar-holidays-name.json +++ b/modules/worker/back/models/calendar-holidays-name.json @@ -9,10 +9,10 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "name": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/worker/back/models/calendar-holidays-type.json b/modules/worker/back/models/calendar-holidays-type.json index 178331b877..cf738d3536 100644 --- a/modules/worker/back/models/calendar-holidays-type.json +++ b/modules/worker/back/models/calendar-holidays-type.json @@ -9,13 +9,13 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "name": { - "type": "String" + "type": "string" }, "hexColour": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/worker/back/models/calendar.json b/modules/worker/back/models/calendar.json index 1da7179c4e..40d29c5192 100644 --- a/modules/worker/back/models/calendar.json +++ b/modules/worker/back/models/calendar.json @@ -13,13 +13,13 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "businessFk": { - "type": "Number" + "type": "number" }, "dated": { - "type": "Date" + "type": "date" } }, "relations": { diff --git a/modules/worker/back/models/device.json b/modules/worker/back/models/device.json index 5367faedfe..566f7da7df 100644 --- a/modules/worker/back/models/device.json +++ b/modules/worker/back/models/device.json @@ -9,13 +9,13 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "sn": { - "type": "String" + "type": "string" }, "model": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/worker/back/models/sector.json b/modules/worker/back/models/sector.json new file mode 100644 index 0000000000..8bd5e773f3 --- /dev/null +++ b/modules/worker/back/models/sector.json @@ -0,0 +1,20 @@ +{ + "name": "Sector", + "base": "VnModel", + "options": { + "mysql": { + "table": "sector" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "string", + "required": true + } + } +} \ No newline at end of file diff --git a/modules/worker/back/models/work-center-holiday.json b/modules/worker/back/models/work-center-holiday.json index eddfd7af1c..e5f201d9d1 100644 --- a/modules/worker/back/models/work-center-holiday.json +++ b/modules/worker/back/models/work-center-holiday.json @@ -9,13 +9,13 @@ "properties": { "workCenterFk": { "id": true, - "type": "Number" + "type": "number" }, "days": { - "type": "Number" + "type": "number" }, "year": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/worker/back/models/work-center.json b/modules/worker/back/models/work-center.json index a0e651bba5..2d7bab24e3 100644 --- a/modules/worker/back/models/work-center.json +++ b/modules/worker/back/models/work-center.json @@ -9,10 +9,10 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "name": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/worker/back/models/worker-department.json b/modules/worker/back/models/worker-department.json index 0eeca50e71..b169cbf5e0 100644 --- a/modules/worker/back/models/worker-department.json +++ b/modules/worker/back/models/worker-department.json @@ -9,10 +9,10 @@ "properties": { "workerFk": { "id": true, - "type": "Number" + "type": "number" }, "departmentFk": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/worker/back/models/worker-dms.json b/modules/worker/back/models/worker-dms.json index 80634cfcc2..575cfbc243 100644 --- a/modules/worker/back/models/worker-dms.json +++ b/modules/worker/back/models/worker-dms.json @@ -13,25 +13,25 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true }, "dmsFk": { - "type": "Number", + "type": "number", "required": true, "mysql": { "columnName": "document" } }, "workerFk": { - "type": "Number", + "type": "number", "required": true, "mysql": { "columnName": "worker" } }, "isReadableByWorker": { - "type": "Boolean" + "type": "boolean" } }, "relations": { diff --git a/modules/worker/back/models/worker-log.json b/modules/worker/back/models/worker-log.json index f100f34868..d2fa0487d4 100644 --- a/modules/worker/back/models/worker-log.json +++ b/modules/worker/back/models/worker-log.json @@ -9,40 +9,40 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "originFk": { - "type": "Number", + "type": "number", "required": true }, "userFk": { - "type": "Number" + "type": "number" }, "action": { - "type": "String", + "type": "string", "required": true }, "changedModel": { - "type": "String" + "type": "string" }, "oldInstance": { - "type": "Object" + "type": "object" }, "newInstance": { - "type": "Object" + "type": "object" }, "creationDate": { - "type": "Date" + "type": "date" }, "changedModelId": { - "type": "String" + "type": "string" }, "changedModelValue": { - "type": "String" + "type": "string" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/worker/back/models/worker-mana.json b/modules/worker/back/models/worker-mana.json index b98b2a325b..0e50b8f639 100644 --- a/modules/worker/back/models/worker-mana.json +++ b/modules/worker/back/models/worker-mana.json @@ -8,11 +8,11 @@ }, "properties": { "amount": { - "type": "Number" + "type": "number" }, "workerFk": { "id": true, - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/worker/back/models/worker-media.json b/modules/worker/back/models/worker-media.json index 805ff383b5..8a28fb4225 100644 --- a/modules/worker/back/models/worker-media.json +++ b/modules/worker/back/models/worker-media.json @@ -9,10 +9,10 @@ "properties": { "workerFk": { "id": true, - "type": "Number" + "type": "number" }, "mediaValue": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/worker/back/models/worker-team-collegues.json b/modules/worker/back/models/worker-team-collegues.json index 2e4a0a4f8e..18b7d90bde 100644 --- a/modules/worker/back/models/worker-team-collegues.json +++ b/modules/worker/back/models/worker-team-collegues.json @@ -9,11 +9,11 @@ "properties": { "workerFk": { "id": true, - "type": "Number" + "type": "number" }, "collegueFk": { "id": true, - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/worker/back/models/worker-team.json b/modules/worker/back/models/worker-team.json index 4cd4b12445..0b490ba6e2 100644 --- a/modules/worker/back/models/worker-team.json +++ b/modules/worker/back/models/worker-team.json @@ -8,12 +8,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "team": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/worker/back/models/worker-time-control-mail.json b/modules/worker/back/models/worker-time-control-mail.json index 7f8522757c..daf3d5155e 100644 --- a/modules/worker/back/models/worker-time-control-mail.json +++ b/modules/worker/back/models/worker-time-control-mail.json @@ -9,26 +9,26 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "required": true }, "workerFk": { - "type": "Number" + "type": "number" }, "year": { - "type": "Number" + "type": "number" }, "week": { - "type": "Number" + "type": "number" }, "state": { - "type": "String" + "type": "string" }, "updated": { - "type": "Date" + "type": "date" }, "emailResponse": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/worker/back/models/worker-time-control-params.json b/modules/worker/back/models/worker-time-control-params.json index cc904cf405..14cabbfb06 100644 --- a/modules/worker/back/models/worker-time-control-params.json +++ b/modules/worker/back/models/worker-time-control-params.json @@ -9,19 +9,19 @@ }, "properties": { "mailHost": { - "type": "String" + "type": "string" }, "mailUser": { - "type": "String" + "type": "string" }, "mailPass": { - "type": "String" + "type": "string" }, "mailSuccessFolder": { - "type": "String" + "type": "string" }, "mailErrorFolder": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index c8054caff4..f7a3443585 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -46,6 +46,9 @@ }, "SSN": { "type" : "string" + }, + "labelerFk": { + "type" : "number" } }, "relations": { @@ -78,6 +81,11 @@ "type": "hasMany", "model": "WorkerTeamCollegues", "foreignKey": "workerFk" + }, + "sector": { + "type": "belongsTo", + "model": "Sector", + "foreignKey": "sectorFk" } } } \ No newline at end of file diff --git a/modules/zone/back/models/agency-mode.json b/modules/zone/back/models/agency-mode.json index ded58e8192..027cec190f 100644 --- a/modules/zone/back/models/agency-mode.json +++ b/modules/zone/back/models/agency-mode.json @@ -9,7 +9,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, @@ -24,10 +24,10 @@ "type": "number" }, "m3": { - "type": "Number" + "type": "number" }, "inflation": { - "type": "Number" + "type": "number" }, "reportMail": { "type": "string" @@ -36,7 +36,7 @@ "type": "boolean" }, "code": { - "type": "String", + "type": "string", "required": false } }, diff --git a/modules/zone/back/models/delivery-method.json b/modules/zone/back/models/delivery-method.json index 8106c1d4f6..31454f2f8f 100644 --- a/modules/zone/back/models/delivery-method.json +++ b/modules/zone/back/models/delivery-method.json @@ -9,7 +9,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, diff --git a/modules/zone/back/models/zone-closure.json b/modules/zone/back/models/zone-closure.json index 8953748389..0483a0c832 100644 --- a/modules/zone/back/models/zone-closure.json +++ b/modules/zone/back/models/zone-closure.json @@ -9,10 +9,10 @@ "properties": { "zoneFk": { "id": true, - "type": "Number" + "type": "number" }, "dated": { - "type": "Date", + "type": "date", "required": true }, "hour": { diff --git a/modules/zone/back/models/zone-estimated-delivery.json b/modules/zone/back/models/zone-estimated-delivery.json index d65cee3b55..399de8f58a 100644 --- a/modules/zone/back/models/zone-estimated-delivery.json +++ b/modules/zone/back/models/zone-estimated-delivery.json @@ -9,28 +9,28 @@ "properties": { "zoneFk": { "id": true, - "type": "Number" + "type": "number" }, "hourTheoretical": { "type": "date" }, "totalVolume": { - "type": "Number" + "type": "number" }, "remainingVolume": { - "type": "Number" + "type": "number" }, "speed": { - "type": "Number" + "type": "number" }, "hourEffective": { - "type": "Date" + "type": "date" }, "minutesLess": { - "type": "Date" + "type": "date" }, "etc": { - "type": "Date" + "type": "date" } }, diff --git a/modules/zone/back/models/zone-event.json b/modules/zone/back/models/zone-event.json index 54c9c4a7d3..7cf4b83011 100644 --- a/modules/zone/back/models/zone-event.json +++ b/modules/zone/back/models/zone-event.json @@ -13,41 +13,41 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "zoneFk": { "id": true, - "type": "Number" + "type": "number" }, "type": { - "type": "String" + "type": "string" }, "dated": { - "type": "Date" + "type": "date" }, "started": { - "type": "Date" + "type": "date" }, "ended": { - "type": "Date" + "type": "date" }, "weekDays": { - "type": "String" + "type": "string" }, "hour": { - "type": "Date" + "type": "date" }, "travelingDays": { - "type": "Number" + "type": "number" }, "price": { - "type": "Number" + "type": "number" }, "bonus": { - "type": "Number" + "type": "number" }, "m3Max": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/zone/back/models/zone-exclusion.json b/modules/zone/back/models/zone-exclusion.json index f1c80debdb..415bce40c5 100644 --- a/modules/zone/back/models/zone-exclusion.json +++ b/modules/zone/back/models/zone-exclusion.json @@ -9,10 +9,10 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "dated": { - "type": "Date", + "type": "date", "required": true } }, diff --git a/modules/zone/back/models/zone-geo.json b/modules/zone/back/models/zone-geo.json index 0a001235fa..e9d9aa3ebd 100644 --- a/modules/zone/back/models/zone-geo.json +++ b/modules/zone/back/models/zone-geo.json @@ -9,22 +9,22 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "name": { - "type": "String" + "type": "string" }, "lft": { - "type": "Number" + "type": "number" }, "rgt": { - "type": "Number" + "type": "number" }, "depth": { - "type": "Number" + "type": "number" }, "sons": { - "type": "Number" + "type": "number" } } } \ No newline at end of file diff --git a/modules/zone/back/models/zone-included.json b/modules/zone/back/models/zone-included.json index e462b7a65a..595f47a784 100644 --- a/modules/zone/back/models/zone-included.json +++ b/modules/zone/back/models/zone-included.json @@ -14,10 +14,10 @@ "properties": { "zoneFk": { "id": true, - "type": "Number" + "type": "number" }, "isIncluded": { - "type": "Boolean" + "type": "boolean" } }, "relations": { diff --git a/modules/zone/back/models/zone-log.json b/modules/zone/back/models/zone-log.json index ddca9261b1..c2c66c155f 100644 --- a/modules/zone/back/models/zone-log.json +++ b/modules/zone/back/models/zone-log.json @@ -9,40 +9,40 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "forceId": false }, "originFk": { - "type": "Number", + "type": "number", "required": true }, "userFk": { - "type": "Number" + "type": "number" }, "action": { - "type": "String", + "type": "string", "required": true }, "changedModel": { - "type": "String" + "type": "string" }, "oldInstance": { - "type": "Object" + "type": "object" }, "newInstance": { - "type": "Object" + "type": "object" }, "creationDate": { - "type": "Date" + "type": "date" }, "changedModelId": { - "type": "String" + "type": "string" }, "changedModelValue": { - "type": "String" + "type": "string" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/zone/back/models/zone-warehouse.json b/modules/zone/back/models/zone-warehouse.json index 0f0e43f4ab..003e4e3c29 100644 --- a/modules/zone/back/models/zone-warehouse.json +++ b/modules/zone/back/models/zone-warehouse.json @@ -13,10 +13,10 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "warehouseFk": { - "type": "Number", + "type": "number", "required": true } }, diff --git a/modules/zone/front/basic-data/index.html b/modules/zone/front/basic-data/index.html index eb701a8037..1836216a27 100644 --- a/modules/zone/front/basic-data/index.html +++ b/modules/zone/front/basic-data/index.html @@ -67,7 +67,6 @@ diff --git a/package.json b/package.json index 35c27fc0c4..52741641ab 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,6 @@ "gulp-env": "^0.4.0", "gulp-file": "^0.4.0", "gulp-install": "^1.1.0", - "gulp-jasmine": "^4.0.0", "gulp-merge-json": "^1.3.1", "gulp-nodemon": "^2.5.0", "gulp-print": "^2.0.1", @@ -78,7 +77,7 @@ "html-loader-jest": "^0.2.1", "html-webpack-plugin": "^4.0.0-beta.11", "identity-obj-proxy": "^3.0.0", - "jasmine": "^3.10.0", + "jasmine": "^4.1.0", "jasmine-reporters": "^2.4.0", "jasmine-spec-reporter": "^7.0.0", "jest": "^26.0.1", @@ -88,7 +87,7 @@ "minimist": "^1.2.5", "mysql2": "^1.7.0", "node-sass": "^4.14.1", - "nodemon": "^1.19.4", + "nodemon": "^2.0.16", "plugin-error": "^1.0.1", "raw-loader": "^1.0.0", "regenerator-runtime": "^0.13.7", @@ -102,7 +101,10 @@ }, "scripts": { "dbtest": "nodemon -q db/tests.js -w db/tests", - "test": "jest --watch", + "test:back": "nodemon -q back/tests.js --config back/nodemonConfig.json", + "test:back:ci": "node back/tests.js ci", + "test:e2e": "node e2e/helpers/tests.js", + "test:front": "jest --watch", "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", "lint": "eslint ./ --cache --ignore-pattern .gitignore", "docker": "docker build --progress=plain -t salix-db ./db" diff --git a/print/templates/email/osticket-report/osticket-report.html b/print/templates/email/osticket-report/osticket-report.html index 76973c8e17..a9cf9a24aa 100644 --- a/print/templates/email/osticket-report/osticket-report.html +++ b/print/templates/email/osticket-report/osticket-report.html @@ -35,8 +35,8 @@

diff --git a/print/templates/reports/driver-route/sql/routes.sql b/print/templates/reports/driver-route/sql/routes.sql index 3fbe59b0d0..4b6f6a318d 100644 --- a/print/templates/reports/driver-route/sql/routes.sql +++ b/print/templates/reports/driver-route/sql/routes.sql @@ -14,5 +14,6 @@ FROM route r LEFT JOIN account.user u ON u.id = w.userFk LEFT JOIN agencyMode am ON am.id = r.agencyModeFk LEFT JOIN agency a ON a.id = am.agencyFk - LEFT JOIN supplier s ON s.id = a.supplierFk + LEFT JOIN supplierAgencyTerm sa ON sa.agencyFk = a.id + LEFT JOIN supplier s ON s.id = sa.supplierFk WHERE r.id IN(?) \ No newline at end of file