From 8fa159910206910c2cec602f4f846bcd07877754 Mon Sep 17 00:00:00 2001 From: Vicente Falco Date: Sun, 1 Oct 2017 19:59:35 +0200 Subject: [PATCH] Conflicto rama dev --- services/client/common/models/Address.js | 61 -------- services/client/common/models/Address.json | 80 ---------- services/client/common/models/Client.js | 145 ----------------- services/client/common/models/Client.json | 163 -------------------- services/client/common/models/Country.json | 36 ----- services/client/common/models/Employee.json | 28 ---- services/client/common/models/Province.json | 40 ----- services/production/.DS_Store | Bin 0 -> 6148 bytes 8 files changed, 553 deletions(-) delete mode 100644 services/client/common/models/Address.js delete mode 100644 services/client/common/models/Address.json delete mode 100644 services/client/common/models/Client.js delete mode 100644 services/client/common/models/Client.json delete mode 100644 services/client/common/models/Country.json delete mode 100644 services/client/common/models/Employee.json delete mode 100644 services/client/common/models/Province.json create mode 100644 services/production/.DS_Store diff --git a/services/client/common/models/Address.js b/services/client/common/models/Address.js deleted file mode 100644 index 9d2af67cc..000000000 --- a/services/client/common/models/Address.js +++ /dev/null @@ -1,61 +0,0 @@ -module.exports = function(Address) { - Address.validate('default',isEnabled,{message: 'No se puede poner predeterminado un consignatario desactivado'}); - function isEnabled(err) { - if (!this.enabled && this.default) err(); - } - - Address.beforeRemote('create',function(ctx, modelInstance, next){ - var data = ctx.req.body; - create(data, next); - }); - - function create(data, next){ - if(data.default){ - removeAllDefault(data.client); - } - next(); - } - - Address.beforeRemote('prototype.updateAttributes',function(ctx, modelInstance, next){ - var data = ctx.req.body; - data.id = ctx.req.params.id; - getAddress(ctx, data, next); - }); - - function getAddress(ctx, data, next){ - var address = Address.findOne( {where: { id: data.id}}, function (err, address){ - if(address) - callbackGetAddress(ctx, data, address, next) - }); - } - - function callbackGetAddress(ctx, data, address, next){ - if (data.default){ - removeAllDefault(address.client); - next(); - } - else if (address.default && !data.default) - next(generateErrorDefaultAddress()); - else - next(); - } - - function getData(ctx){ - if (ctx.data) - return ctx.data; - else - return ctx.instance; - } - - function removeAllDefault(cl){ - Address.update({client: cl}, {default: false}); - } - - function generateErrorDefaultAddress(){ - var error = new Error(); - error.message = "No se puede desmarcar el consignatario predeterminado"; - error.status = 500; - return error; - } -}; - diff --git a/services/client/common/models/Address.json b/services/client/common/models/Address.json deleted file mode 100644 index 648487eb0..000000000 --- a/services/client/common/models/Address.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "name": "Address", - "base": "PersistedModel", - "validateUpsert": true, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" - }, - "clientFk": { - "type": "Number" - }, - "consignee": { - "type": "string", - "required": true - }, - "street": { - "type": "string", - "required": true - }, - "city": { - "type": "string", - "required": true - }, - "postcode": { - "type": "string" - }, - "provinceFk": { - "type": "Number" - }, - "phone": { - "type": "string" - }, - "mobile": { - "type": "string" - }, - "enabled": { - "type": "boolean" - }, - "default": { - "type": "boolean" - }, - "defaultAgencyFk": { - "type": "Number" - }, - "longitude": { - "type": "Number" - }, - "latitude": { - "type": "Number" - } - }, - "validations": [], - "relations": { - "countryFk": { - "type": "hasOne", - "model": "Country", - "foreignKey": "id" - }, - "clientFk": { - "type": "hasOne", - "model": "Client", - "foreignKey": "id" - }, - "defaultAgencyFk": { - "type": "hasOne", - "model": "Agency", - "foreignKey": "id" - } - }, - "acls": [ - { - "accessType": "*", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] -} diff --git a/services/client/common/models/Client.js b/services/client/common/models/Client.js deleted file mode 100644 index 13990502b..000000000 --- a/services/client/common/models/Client.js +++ /dev/null @@ -1,145 +0,0 @@ - -module.exports = function(Client) { - // Validations - - Client.validatesUniquenessOf('name', {message: 'El nombre debe ser único'}); - Client.validatesUniquenessOf('fi', {message: 'El NIF/CIF debe ser único'}); - Client.validatesPresenceOf('socialName', {message: 'Debe especificarse la razón social'}); - Client.validatesFormatOf('postcode', {allowNull: true, with: /^\d+$/, message: 'El código postal solo debe contener números'}); - Client.validatesLengthOf('postcode', {allowNull: true, min: 3, max: 10}); - Client.validatesFormatOf('email', {allowNull: true, with: /^[\w|\.|\-]+@\w[\w|\.|\-]*\w$/, message: 'Correo electrónico inválido'}); - - Client.validate('payMethod', hasCC, {message: 'Introduzca el iban del cliente'}); - function hasCC(err) { - if (this.payMethod == 2 && !this.iban) err(); - }; - - Client.validate('payMethod', hasSalesMan, {message: 'No se puede cambiar la forma de pago si no hay comercial asignado'}); - function hasSalesMan(err) { - if(this.payMethod && !this.salesPerson) err(); - }; - - // Hooks - - Client.observe('before save', function(ctx, next) { - if(ctx.instance) { - if (!ctx.instance.dueDay){ - ctx.instance.dueDay = 5; - } - next(); - } - else { - Client.findById(ctx.where.id, - function(err, item) { - if (!err) { - if (item.payMethod != ctx.data.payMethod && item.dueDay == ctx.data.dueDay) { - ctx.data.dueDay = 5; - } - } - next(); - } - ); - } - }); - - // Methods - - Client.remoteMethod('activate', { - description: 'Activate or deactive client', - accepts: { - arg: 'id', - type: 'number', - required: true, - description: 'Model id', - http: {source: 'path'} - }, - returns: { - arg: 'active', - type: 'boolean' - }, - http: { - verb: 'put', - path: '/:id/activate' - } - }); - - Client.activate = function(id, cb) { - console.log(id); - Client.findById(id, function(err, client) { - if(!err) { - Client.update({id: client.id}, {active: !client.active}); - cb(null, !client.active); - } - }); - }; - - // Basic filter - - Client.installMethod('filter', filterClients); - function filterClients(p) { - return { - where: { - id: p.id, - name: {regexp: p.name}, - cif: p.cif, - socialName: {regexp: p.socialName}, - city: {regexp: p.city}, - postcode: p.postcode, - email: {regexp: p.email}, - phone: p.phone - }, - skip: (p.page - 1) * p.size, - limit: p.size - }; - } - - // Client addresses - - 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, p, cb) { - let filter = { - where: { - clientFk: id, - }, - skip: (p.page - 1) * p.size, - limit: p.size - }; - - Client.app.models.Address.find(filter, function(err, instances) { - if(!err) { - cb(null, instances); - } - }) - }; -}; \ No newline at end of file diff --git a/services/client/common/models/Client.json b/services/client/common/models/Client.json deleted file mode 100644 index d961bbe4c..000000000 --- a/services/client/common/models/Client.json +++ /dev/null @@ -1,163 +0,0 @@ -{ - "name": "Client", - "base": "MyModel", - "scopes": { - "test": { - "where": { - "name": "Verdnatura" - } - } - }, - "validateUpsert": true, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" - }, - "name": { - "type": "string", - "required": true - }, - "fi": { - "type": "string", - "description": "Fiscal indetifier" - }, - "socialName": { - "type": "string" - }, - "creationTime": { - "type": "string" - }, - "contact": { - "type": "string" - }, - "street": { - "type": "string" - }, - "city": { - "type": "string" - }, - "postcode": { - "type": "string" - }, - "provinceFk": { - "type": "Number" - }, - "countryFk": { - "type": "Number" - }, - "email": { - "type": "string" - }, - "phone": { - "type": "string" - }, - "mobile": { - "type": "string" - }, - "fax": { - "type": "string" - }, - "active": { - "type": "boolean" - }, - "credit": { - "type": "Number" - }, - "creditInsurance": { - "type": "Number" - }, - "iban": { - "type": "string" - }, - "dueDay": { - "type": "Number" - }, - "equalizationTax": { - "type": "boolean", - "description": "The client has equalization tax" - }, - "hasToInvoice": { - "type": "boolean", - "description": "Global invoicing enabled for the client" - }, - "invoiceByEmail": { - "type": "boolean", - "description": "Send invoices by email" - }, - "payMethodFk": { - "type": "Number" - }, - "salesPersonFk": { - "type": "Number" - }, - "contactChannelFk": { - "type": "Number" - }, - "sepaVnl": { - "type": "boolean" - }, - "coreVnl": { - "type": "boolean" - }, - "coreVnh": { - "type": "boolean" - }, - "eypbc": { - "type": "boolean" - }, - "quality": { - "type": "Number" - }, - "vies": { - "type": "Number" - }, - "isRelevant": { - "type": "boolean" - }, - "typeFk": { - "type": "Number" - }, - "accountingAccount": { - "type": "string" - } - }, - "validations": [], - "relations": { - "accountFk": { - "type": "hasOne", - "model": "Account", - "foreignKey": "id" - }, - "payMethodFk": { - "type": "hasOne", - "model": "PayMethod", - "foreignKey": "id" - }, - "salesPersonFk": { - "type": "hasOne", - "model": "Employee", - "foreignKey": "id" - }, - "addressesFk": { - "type": "hasMany", - "model": "Address", - "foreignKey": "clientFk" - }, - "chanelFK":{ - "type": "hasOne", - "model": "Chanel", - "foreignKey": "chanelFK" - } - }, - "acls": [ - { - "accessType": "*", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ], - "methods": {} -} diff --git a/services/client/common/models/Country.json b/services/client/common/models/Country.json deleted file mode 100644 index 7305d94fd..000000000 --- a/services/client/common/models/Country.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "Country", - "base": "PersistedModel", - "validateUpsert": true, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" - }, - "name": { - "type": "string", - "required": true - }, - "inCee": { - "type": "Number" - }, - "code": { - "type": "string" - }, - "currencyFk": { - "type": "Number" - }, - "realCountryFk": { - "type": "Number" - } - }, - "acls": [ - { - "accessType": "*", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] -} \ No newline at end of file diff --git a/services/client/common/models/Employee.json b/services/client/common/models/Employee.json deleted file mode 100644 index d464e9bfc..000000000 --- a/services/client/common/models/Employee.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "Employee", - "base": "PersistedModel", - "validateUpsert": true, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" - }, - "name": { - "type": "string", - "required": true - }, - "userFk": { - "type": "Number", - "required": true - } - }, - "acls": [ - { - "accessType": "*", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] -} diff --git a/services/client/common/models/Province.json b/services/client/common/models/Province.json deleted file mode 100644 index d8dfab67e..000000000 --- a/services/client/common/models/Province.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "Province", - "base": "PersistedModel", - "validateUpsert": true, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" - }, - "name": { - "type": "string", - "required": true - }, - "countryFk": { - "type": "Number" - }, - "warehouseFk": { - "type": "Number" - }, - "zoneFk": { - "type": "Number" - } - }, - "relations": { - "countryFk": { - "type": "hasOne", - "model": "Country", - "foreignKey": "id" - } - }, - "acls": [ - { - "accessType": "*", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] -} \ No newline at end of file diff --git a/services/production/.DS_Store b/services/production/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..9946d372df15c5a819aa529905bdac5d1af33b53 GIT binary patch literal 6148 zcmeHKF>V4u473A^kZ33=_Y3*K3XvD^0SXXJL?oh6UzK;|X_>Lzz(GeEG?u)x>-Fqv zr#PR@%vayLH?xJA&EQ1);V?Gt(?|AF5eLF?#@LiG1m;NvCe^FO@T4Q&Dz6s~iAguF=ELh|uMWlIcAVcL-MlAilmb%VQh`Y>7p(v9 z@H_qgB}pqOAO)UE0iUin>lL0