diff --git a/client/client/src/addresses/addresses.html b/client/client/src/addresses/addresses.html index f98012185..d313c188f 100644 --- a/client/client/src/addresses/addresses.html +++ b/client/client/src/addresses/addresses.html @@ -7,7 +7,7 @@ + ng-class="{'bg-dark-item': address.isDefaultAddress,'bg-opacity-item': !address.isActive && !address.isDefaultAddress}"> star diff --git a/gulpfile.js b/gulpfile.js index 603a6c3f5..100db117e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -38,7 +38,9 @@ gulp.task('client', ['clean'], () => { }); gulp.task('services', ['nginx'], () => { - process.env.NODE_ENV = gutil.env.env || 'development'; + if (gutil.env.env && !process.env.NODE_ENV) + process.env.NODE_ENV = gutil.env.env; + const servicesPath = './services/'; const services = fs.readdirSync(servicesPath); services.splice(services.indexOf('loopback'), 1); diff --git a/services/client/common/methods/client/addresses.js b/services/client/common/methods/client/addresses.js deleted file mode 100644 index 5000d04d0..000000000 --- a/services/client/common/methods/client/addresses.js +++ /dev/null @@ -1,72 +0,0 @@ -module.exports = function(Client) { - Client.remoteMethod('addressesList', { - description: 'List items using a filter', - accessType: 'READ', - accepts: [ - { - arg: 'id', - type: 'string', - required: true, - description: 'Model id', - http: {source: 'path'} - }, - { - arg: 'filter', - type: 'object', - required: true, - description: 'Filter defining where', - http: function(ctx) { - return ctx.req.query; - } - } - ], - returns: { - arg: 'data', - type: ['Address'], - root: true - }, - http: { - path: `/:id/addressesList`, - verb: 'get' - } - }); - - Client.addressesList = function(id, params, callback) { - let filter = { - where: { - clientFk: id - }, - skip: (params.page - 1) * params.size, - limit: params.size, - order: ['isDefaultAddress DESC', 'isEnabled DESC'], - include: {observations: 'observationType'} - }; - - let total = null; - let items = null; - - function response(type, value) { - if (type === 'total') { - total = value; - } else { - items = value; - } - - if (total !== null && items !== null) { - callback(null, {total: total, items: items}); - } - } - - Client.app.models.Address.find(filter, function(err, results) { - if (err) - return callback(err, null); - response('find', results); - }); - - Client.app.models.Address.count(filter.where, function(err, result) { - if (err) - return callback(err, null); - response('total', result); - }); - }; -}; diff --git a/services/client/common/methods/client/addressesPropagateRe.js b/services/client/common/methods/client/addressesPropagateRe.js deleted file mode 100644 index 64b159339..000000000 --- a/services/client/common/methods/client/addressesPropagateRe.js +++ /dev/null @@ -1,43 +0,0 @@ -module.exports = function(Client) { - Client.remoteMethod('addressesPropagateRe', { - description: 'Change property isEqualizated in all client addresses', - accessType: 'WRITE', - accepts: [ - { - arg: 'id', - type: 'string', - required: true, - description: 'Client id', - http: {source: 'path'} - }, - { - arg: 'data', - type: 'Object', - required: true, - description: 'data with new value', - http: {source: 'body'} - } - ], - returns: { - arg: 'data', - type: 'boolean', - root: true - }, - http: { - path: `/:id/addressesPropagateRe`, - verb: 'patch' - } - }); - - Client.addressesPropagateRe = (id, data, callback) => { - if (data.hasOwnProperty('isEqualizated')) { - Client.app.models.Address.updateAll({clientFk: id}, data, (err, info) => { - if (err) - return callback(err, null); - callback(null, true); - }); - } else { - callback(null, false); - } - }; -}; diff --git a/services/client/common/methods/client/card.js b/services/client/common/methods/client/card.js deleted file mode 100644 index 08a8f74cb..000000000 --- a/services/client/common/methods/client/card.js +++ /dev/null @@ -1,46 +0,0 @@ -module.exports = function(Client) { - Client.remoteMethod('card', { - description: 'Get client for card call', - accepts: { - arg: 'id', - type: 'number', - required: true, - description: 'Model id', - http: {source: 'path'} - }, - returns: { - arg: 'data', - type: 'Client', - root: true - }, - http: { - verb: 'get', - path: '/:id/card' - } - }); - - Client.card = function(id, callback) { - let filter = { - where: { - id: id - }, - include: require('./card.json') - }; - - Client.find(filter, function(error, instances) { - if (error) throw error; - - callback(null, formatCard(instances[0])); - }); - }; - - function formatCard(card) { - let cardFormated = JSON.parse(JSON.stringify(card)); - if (cardFormated.salesPersonFk) - cardFormated.salesPerson = { - id: card.salesPerson().id, - name: `${card.salesPerson().name} ${card.salesPerson().surname}` - }; - return cardFormated; - } -}; diff --git a/services/client/common/methods/client/create.js b/services/client/common/methods/client/create.js deleted file mode 100644 index 219e30028..000000000 --- a/services/client/common/methods/client/create.js +++ /dev/null @@ -1,58 +0,0 @@ -let app = require('../../../server/server'); -let md5 = require('md5'); - -module.exports = function(Client) { - Client.remoteMethod('createUserProfile', { - description: 'Creates both client and its web account', - accepts: { - arg: 'data', - type: 'object', - http: {source: 'body'} - }, - returns: { - root: true, - type: 'boolean' - }, - http: { - verb: 'post', - path: '/createUserProfile' - } - }); - - Client.createUserProfile = (data, callback) => { - let firstEmail = data.email ? data.email.split(',')[0] : null; - let user = { - name: data.userName, - email: firstEmail, - password: md5(parseInt(Math.random() * 100000000000000)) - }; - - app.models.Account.beginTransaction({}, (error, transaction) => { - app.models.Account.create(user, {transaction}, (error, account) => { - if (error) { - transaction.rollback(); - return callback(error); - } - - let client = { - name: data.name, - fi: data.fi, - socialName: data.socialName, - id: account.id, - email: data.email, - salesPersonFk: data.salesPersonFk - }; - - Client.create(client, {transaction}, (error, newClient) => { - if (error) { - transaction.rollback(); - return callback(error); - } - - transaction.commit(); - callback(null, newClient); - }); - }); - }); - }; -}; diff --git a/services/client/common/methods/client/specs/salesperson.spec.js b/services/client/common/methods/client/specs/salesperson.spec.js deleted file mode 100644 index fa5cc4ea7..000000000 --- a/services/client/common/methods/client/specs/salesperson.spec.js +++ /dev/null @@ -1,33 +0,0 @@ -import app from '../../../../server/server'; -import {catchErrors} from '../../../../../../services/utils/jasmineHelpers'; - -describe('Client activeSalesPerson', () => { - it('should call the activeSalesPerson() method with limit of 1', done => { - let filter = { - limit: 1 - }; - - let callback = (error, result) => { - if (error) return catchErrors(done)(error); - - expect(result.length).toEqual(1); - done(); - }; - - app.models.Client.activeSalesPerson(filter, callback); - }); - - it('should call the activeSalesPerson() method with no limit and receive all 3 salesPersons', done => { - let filter = { - }; - - let callback = (error, result) => { - if (error) return catchErrors(done)(error); - - expect(result.length).toEqual(3); - done(); - }; - - app.models.Client.activeSalesPerson(filter, callback); - }); -}); diff --git a/services/loopback/common/locale/en.json b/services/loopback/common/locale/en.json index d824c1ad8..18e98b233 100644 --- a/services/loopback/common/locale/en.json +++ b/services/loopback/common/locale/en.json @@ -1,7 +1,8 @@ { - "PHONE_INVALID_FORMAT": "The phone format is invalid", - "You are not allowed to change the credit": "You are not allowed to change the credit", - "Unable to mark the equivalence surcharge": "Unable to mark the equivalence surcharge", - "The default consignee can not be unchecked": "The default consignee can not be unchecked", - "Unable to default a disabled consignee": "Unable to default a disabled consignee" + "PHONE_INVALID_FORMAT": "The phone format is invalid", + "You are not allowed to change the credit": "You are not allowed to change the credit", + "Unable to mark the equivalence surcharge": "Unable to mark the equivalence surcharge", + "The default consignee can not be unchecked": "The default consignee can not be unchecked", + "Unable to default a disabled consignee": "Unable to default a disabled consignee", + "El método de pago seleccionado requiere que se especifique el IBAN": "El método de pago seleccionado requiere que se especifique el IBAN" } \ No newline at end of file diff --git a/services/client/common/methods/client/specs/addressesPropagateRe.spec.js b/services/loopback/common/methods/client/specs/addressesPropagateRe.spec.js similarity index 100% rename from services/client/common/methods/client/specs/addressesPropagateRe.spec.js rename to services/loopback/common/methods/client/specs/addressesPropagateRe.spec.js diff --git a/services/client/common/methods/client/specs/card.spec.js b/services/loopback/common/methods/client/specs/card.spec.js similarity index 100% rename from services/client/common/methods/client/specs/card.spec.js rename to services/loopback/common/methods/client/specs/card.spec.js diff --git a/services/client/common/methods/client/specs/create.spec.js b/services/loopback/common/methods/client/specs/createWithUser.spec.js similarity index 98% rename from services/client/common/methods/client/specs/create.spec.js rename to services/loopback/common/methods/client/specs/createWithUser.spec.js index e10fb62c6..8ac31a7de 100644 --- a/services/client/common/methods/client/specs/create.spec.js +++ b/services/loopback/common/methods/client/specs/createWithUser.spec.js @@ -97,7 +97,7 @@ describe('Client Create', () => { socialName: client.socialName }; - app.models.Client.createUserProfile(formerAccountData, (err, client) => { + app.models.Client.createWithUser(formerAccountData, (err, client) => { expect(err.details.codes.name[0]).toEqual('uniqueness'); done(); }); @@ -107,7 +107,7 @@ describe('Client Create', () => { }); it('should create a new account', done => { - app.models.Client.createUserProfile(newAccountData, (error, client) => { + app.models.Client.createWithUser(newAccountData, (error, client) => { if (error) return catchErrors(done)(error); app.models.Account.findOne({where: {name: newAccountData.userName}}) .then(account => { diff --git a/services/client/common/methods/client/specs/roles.spec.js b/services/loopback/common/methods/client/specs/hasCustomerRole.spec.js similarity index 69% rename from services/client/common/methods/client/specs/roles.spec.js rename to services/loopback/common/methods/client/specs/hasCustomerRole.spec.js index 559d272b2..c8b866082 100644 --- a/services/client/common/methods/client/specs/roles.spec.js +++ b/services/loopback/common/methods/client/specs/hasCustomerRole.spec.js @@ -1,8 +1,8 @@ import app from '../../../../server/server'; import {catchErrors} from '../../../../../../services/utils/jasmineHelpers'; -describe('Client getRoleCustomer', () => { - it('should call the getRoleCustomer() method with a customer id', done => { +describe('Client hasCustomerRole', () => { + it('should call the hasCustomerRole() method with a customer id', done => { let id = 1; let params = {}; @@ -13,10 +13,10 @@ describe('Client getRoleCustomer', () => { done(); }; - app.models.Client.getRoleCustomer(id, params, callback); + app.models.Client.hasCustomerRole(id, params, callback); }); - it('should call the getRoleCustomer() method with a non customer id', done => { + it('should call the hasCustomerRole() method with a non customer id', done => { let id = 8; let params = {}; @@ -27,10 +27,10 @@ describe('Client getRoleCustomer', () => { done(); }; - app.models.Client.getRoleCustomer(id, params, callback); + app.models.Client.hasCustomerRole(id, params, callback); }); - it('should call the getRoleCustomer() method with an unreal id', done => { + it('should call the hasCustomerRole() method with an unreal id', done => { let id = 999; let params = {}; @@ -41,10 +41,10 @@ describe('Client getRoleCustomer', () => { done(); }; - app.models.Client.getRoleCustomer(id, params, callback); + app.models.Client.hasCustomerRole(id, params, callback); }); - it('should call the getRoleCustomer() method with an invalid id', done => { + it('should call the hasCustomerRole() method with an invalid id', done => { let id = 'WRONG!'; let params = {}; @@ -55,6 +55,6 @@ describe('Client getRoleCustomer', () => { done(); }; - app.models.Client.getRoleCustomer(id, params, callback); + app.models.Client.hasCustomerRole(id, params, callback); }); }); diff --git a/services/client/common/methods/client/specs/addresses.spec.js b/services/loopback/common/methods/client/specs/listAddresses.spec.js similarity index 79% rename from services/client/common/methods/client/specs/addresses.spec.js rename to services/loopback/common/methods/client/specs/listAddresses.spec.js index a56b9c981..3575d3a5e 100644 --- a/services/client/common/methods/client/specs/addresses.spec.js +++ b/services/loopback/common/methods/client/specs/listAddresses.spec.js @@ -2,7 +2,7 @@ import app from '../../../../server/server'; import {catchErrors} from '../../../../../../services/utils/jasmineHelpers'; describe('Client addresses', () => { - it('should call the addressesList method and receive total results and items', done => { + it('should call the listAddresses method and receive total results and items', done => { let id = 1; let params = { page: 1, @@ -15,6 +15,6 @@ describe('Client addresses', () => { expect(Object.keys(result)).toEqual(['total', 'items']); done(); }; - app.models.Client.addressesList(id, params, callback); + app.models.Client.listAddresses(id, params, callback); }); }); diff --git a/services/client/common/methods/client/specs/employee.spec.js b/services/loopback/common/methods/client/specs/listWorkers.spec.js similarity index 72% rename from services/client/common/methods/client/specs/employee.spec.js rename to services/loopback/common/methods/client/specs/listWorkers.spec.js index 2cbaa4020..00194842e 100644 --- a/services/client/common/methods/client/specs/employee.spec.js +++ b/services/loopback/common/methods/client/specs/listWorkers.spec.js @@ -1,8 +1,8 @@ import app from '../../../../server/server'; import {catchErrors} from '../../../../../../services/utils/jasmineHelpers'; -describe('Client employeeList', () => { - it('should call the employeeList()', done => { +describe('Client listWorkers', () => { + it('should call the listWorkers()', done => { let callback = (error, result) => { if (error) return catchErrors(done)(error); let amountOfEmployees = Object.keys(result).length; @@ -10,6 +10,6 @@ describe('Client employeeList', () => { expect(amountOfEmployees).toEqual(6); done(); }; - app.models.Client.employeeList(callback); + app.models.Client.listWorkers(callback); }); }); diff --git a/services/print/application/config/datasources.json b/services/print/application/config/datasources.json index ec5c19adb..02ed03a35 100644 --- a/services/print/application/config/datasources.json +++ b/services/print/application/config/datasources.json @@ -8,7 +8,7 @@ "host": "localhost", "port": 3306, "database": "vn", - "user": "reports", + "user": "root", "password": "" }, "pdf": {