diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index c570c6385..ae7612b46 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -564,13 +564,13 @@ INSERT INTO `vn`.`supplierActivity`(`code`, `name`) 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, util.VN_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, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), - (69, 'Packaging', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE(), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), - (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'), - (567, 'Holland', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE(), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), - (791, 'Bros SL', 'Bros nick', 5115000791, 1, '37718083S', 0, util.VN_CURDATE(), 1, 'supplier address 7', 'ASGARD', 3, 46600, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'), - (1381, 'Ornamentales', 'Ornamentales', 7185001381, 1, '07972486L', 0, util.VN_CURDATE(), 1, 'supplier address 4', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'); + (1, 'PLANTS SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_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, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), + (69, 'PACKAGING', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE(), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), + (442, 'VERDNATURA LEVANTE SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'), + (567, 'HOLLAND', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE(), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), + (791, 'BROS SL', 'Bros nick', 5115000791, 1, '37718083S', 0, util.VN_CURDATE(), 1, 'supplier address 7', 'ASGARD', 3, 46600, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'), + (1381, 'ORNAMENTALES', 'Ornamentales', 7185001381, 1, '07972486L', 0, util.VN_CURDATE(), 1, 'supplier address 4', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'); INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `provinceFk`, `postalCode`, `city`, `phone`, `mobile`) VALUES diff --git a/db/versions/10863-brownIvy/00-firstScript.sql b/db/versions/10863-brownIvy/00-firstScript.sql new file mode 100644 index 000000000..d3b79ae66 --- /dev/null +++ b/db/versions/10863-brownIvy/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +UPDATE vn.supplier + SET name = UPPER(name), + nickname = UPPER(nickname); diff --git a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js index 591a6116a..e82f851ea 100644 --- a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js +++ b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js @@ -24,7 +24,7 @@ describe('Supplier summary & descriptor path', () => { it(`should confirm there's data on the summary header`, async() => { const result = await page.waitToGetProperty(selectors.supplierSummary.header, 'innerText'); - expect(result).toContain('Plants SL - 1'); + expect(result).toContain('PLANTS SL - 1'); }); it(`should confirm there's data on the summary basic data`, async() => { diff --git a/e2e/paths/13-supplier/03_fiscal_data.spec.js b/e2e/paths/13-supplier/03_fiscal_data.spec.js index 96977e708..ccd9d7809 100644 --- a/e2e/paths/13-supplier/03_fiscal_data.spec.js +++ b/e2e/paths/13-supplier/03_fiscal_data.spec.js @@ -24,7 +24,7 @@ describe('Supplier fiscal data path', () => { country: null, postcode: null, city: 'Valencia', - socialName: 'Farmer King SL', + socialName: 'FARMER KING SL', taxNumber: '12345678Z', account: '0123456789', sageWithholding: 'retencion estimacion objetiva', @@ -46,7 +46,7 @@ describe('Supplier fiscal data path', () => { country: 'España', postcode: '46000', city: 'Valencia', - socialName: 'Farmer King SL', + socialName: 'FARMER KING SL', taxNumber: '12345678Z', account: '0123456789', sageWithholding: 'RETENCION ESTIMACION OBJETIVA', diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 059da6356..10ab08d57 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -204,6 +204,7 @@ "It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}", "Incorrect pin": "Incorrect pin.", "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified", + "Name should be uppercase": "Name should be uppercase", "Fecha fuera de rango": "Fecha fuera de rango", "There is no zone for these parameters 34": "There is no zone for these parameters 34" -} \ No newline at end of file +} diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 67f9082ec..5c7dc41b6 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -337,5 +337,6 @@ "You already have the mailAlias": "Ya tienes este alias de correo", "The alias cant be modified": "Este alias de correo no puede ser modificado", "No tickets to invoice": "No hay tickets para facturar", + "Name should be uppercase": "El nombre debe ir en mayúscula", "An email is necessary": "Es necesario un email" } diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js index 76f17720f..9834989fc 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js @@ -8,14 +8,14 @@ describe('InvoiceIn filter()', () => { try { const ctx = { args: { - search: 'Plants SL', + search: 'PLANTS SL', } }; const result = await models.InvoiceIn.filter(ctx, {}, options); expect(result.length).toEqual(5); - expect(result[0].supplierName).toEqual('Plants SL'); + expect(result[0].supplierName).toEqual('PLANTS SL'); await tx.rollback(); } catch (e) { diff --git a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js index 30713f517..347851561 100644 --- a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js +++ b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js @@ -5,7 +5,7 @@ describe('Supplier getSummary()', () => { const supplier = await app.models.Supplier.getSummary(1); expect(supplier.id).toEqual(1); - expect(supplier.name).toEqual('Plants SL'); + expect(supplier.name).toEqual('PLANTS SL'); expect(supplier.nif).toEqual('06089160W'); expect(supplier.account).toEqual('4100000001'); expect(supplier.payDay).toEqual(15); diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js index 5fc2ea752..0e7fa0e34 100644 --- a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -25,13 +25,13 @@ describe('Supplier newSupplier()', () => { try { const options = {transaction: tx}; ctx.args = { - name: 'newSupplier', + name: 'NEWSUPPLIER', nif: '12345678Z' }; const result = await models.Supplier.newSupplier(ctx, options); - expect(result.name).toEqual('newSupplier'); + expect(result.name).toEqual('NEWSUPPLIER'); await tx.rollback(); } catch (e) { await tx.rollback(); diff --git a/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js b/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js index a47e547d1..56030a894 100644 --- a/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js +++ b/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js @@ -6,7 +6,7 @@ describe('Supplier updateFiscalData', () => { const administrativeId = 5; const employeeId = 1; const defaultData = { - name: 'Plants SL', + name: 'PLANTS SL', nif: '06089160W', account: '4100000001', sageTaxTypeFk: 4, @@ -56,7 +56,7 @@ describe('Supplier updateFiscalData', () => { }); ctx.args = { - name: 'Weapon Dealer', + name: 'WEAPON DEALER', nif: 'A68446004', account: '4000000005', sageTaxTypeFk: 5, @@ -72,7 +72,7 @@ describe('Supplier updateFiscalData', () => { const result = await app.models.Supplier.updateFiscalData(ctx, supplierId); - expect(result.name).toEqual('Weapon Dealer'); + expect(result.name).toEqual('WEAPON DEALER'); expect(result.nif).toEqual('A68446004'); expect(result.account).toEqual('4000000005'); expect(result.sageTaxTypeFk).toEqual(5); diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index fbd3a00db..3f40ce58b 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -129,7 +129,7 @@ describe('loopback model Supplier', () => { const options = {transaction: tx}; try { - const newSupplier = await models.Supplier.create({name: 'Alfred Pennyworth'}, options); + const newSupplier = await models.Supplier.create({name: 'ALFRED PENNYWORTH'}, options); const fetchedSupplier = await models.Supplier.findById(newSupplier.id, null, options); expect(Number(fetchedSupplier.account)).toEqual(4100000000 + newSupplier.id); diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 5cf357c13..0ac389074 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -46,6 +46,12 @@ module.exports = Self => { Self.validateAsync('postCode', hasValidPostcode, { message: `The postcode doesn't exist. Please enter a correct one` }); + Self.validatesFormatOf('name', { + message: 'Name should be uppercase', + allowNull: false, + allowBlank: false, + with: /^[^a-z]*$/ + }); async function hasValidPostcode(err, done) { if (!this.postcode) diff --git a/modules/supplier/front/create/index.html b/modules/supplier/front/create/index.html index eb6e7261e..1e051f3a8 100644 --- a/modules/supplier/front/create/index.html +++ b/modules/supplier/front/create/index.html @@ -12,7 +12,8 @@ + vn-focus + ng-keyup="$ctrl.supplier.name = $ctrl.supplier.name.toUpperCase()">