diff --git a/db/changes/10161-postValentineDay/00-zoneEvent.sql b/db/changes/10161-postValentineDay/00-zoneEvent.sql new file mode 100644 index 000000000..1554afbec --- /dev/null +++ b/db/changes/10161-postValentineDay/00-zoneEvent.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn`.`zoneEvent` +ADD COLUMN m3Max DECIMAL(10,2) UNSIGNED NULL DEFAULT NULL AFTER bonus; \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 498a9dc7c..2f3a9378d 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -35,7 +35,7 @@ INSERT INTO `vn`.`packagingConfig`(`upperGap`) UPDATE `account`.`role` SET id = 100 WHERE id = 0; INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`, `lang`) - SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'EN' + SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'en' FROM `account`.`role` WHERE id <> 20 ORDER BY id; @@ -55,18 +55,18 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`) VALUES - (101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'ES'), - (102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'EN'), - (103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'FR'), - (104, 'TonyStark', 'Tony Stark', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'TonyStark@mydomain.com', 'ES'), - (105, 'MaxEisenhardt', 'Max Eisenhardt', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'MaxEisenhardt@mydomain.com', 'PT'), - (106, 'DavidCharlesHaller', 'David Charles Haller', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'DavidCharlesHaller@mydomain.com', 'EN'), - (107, 'HankPym', 'Hank Pym', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'HankPym@mydomain.com', 'EN'), - (108, 'CharlesXavier', 'Charles Xavier', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'CharlesXavier@mydomain.com', 'EN'), - (109, 'BruceBanner', 'Bruce Banner', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'BruceBanner@mydomain.com', 'EN'), - (110, 'JessicaJones', 'Jessica Jones', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'JessicaJones@mydomain.com', 'EN'), - (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'EN'), - (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'EN'); + (101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'es'), + (102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'en'), + (103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'fr'), + (104, 'TonyStark', 'Tony Stark', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'TonyStark@mydomain.com', 'es'), + (105, 'MaxEisenhardt', 'Max Eisenhardt', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt'), + (106, 'DavidCharlesHaller', 'David Charles Haller', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en'), + (107, 'HankPym', 'Hank Pym', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'HankPym@mydomain.com', 'en'), + (108, 'CharlesXavier', 'Charles Xavier', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'CharlesXavier@mydomain.com', 'en'), + (109, 'BruceBanner', 'Bruce Banner', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'BruceBanner@mydomain.com', 'en'), + (110, 'JessicaJones', 'Jessica Jones', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'JessicaJones@mydomain.com', 'en'), + (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en'), + (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en'); INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`) VALUES @@ -1103,11 +1103,11 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`) (104, 500), (105, 5000); -INSERT INTO `vn`.`supplier`(`id`, `name`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`) +INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`) VALUES - (1, 'Plants SL', 4000000001, 1, 'A11111111', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1), - (2, 'Flower King', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2), - (442, 'Verdnatura Levante SL', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2); + (1, 'Plants SL', 'Plants nick', 4000000001, 1, 'A11111111', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1), + (2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2), + (442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2); INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`) VALUES diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 873e7c0b5..563b8d89a 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -788,7 +788,7 @@ export default { createdThermograph: 'vn-travel-thermograph-index vn-tbody > vn-tr', upload: 'vn-travel-thermograph-create button[type=submit]' }, - agencyBasicData: { + zoneBasicData: { name: 'vn-zone-basic-data vn-textfield[ng-model="$ctrl.zone.name"]', agency: 'vn-zone-basic-data vn-autocomplete[ng-model="$ctrl.zone.agencyModeFk"]', maxVolume: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.m3Max"]', @@ -799,5 +799,10 @@ export default { inflation: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.inflation"]', volumetric: 'vn-zone-basic-data vn-check[ng-model="$ctrl.zone.isVolumetric"]', saveButton: 'vn-zone-basic-data vn-submit > button', + }, + entrySummary: { + header: 'vn-entry-summary > vn-card > h5', + reference: 'vn-entry-summary vn-label-value[label="Reference"]', + confirmed: 'vn-entry-summary vn-check[label="Confirmed"]', } }; diff --git a/e2e/paths/11-agency/01_basic-data.spec.js b/e2e/paths/11-agency/01_basic-data.spec.js deleted file mode 100644 index 43369aeab..000000000 --- a/e2e/paths/11-agency/01_basic-data.spec.js +++ /dev/null @@ -1,103 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Agency basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('deliveryBoss', 'zone'); // turns up the agency module name and route aint the same lol - await page.accessToSearchResult('10'); - await page.accessToSection('zone.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the basic data section', async() => { - let url = await page.expectURL('#!/zone/10/basic-data'); - - expect(url).toBe(true); - }); - - it('should edit de form and then save', async() => { - await page.clearInput(selectors.agencyBasicData.name); - await page.write(selectors.agencyBasicData.name, 'Brimstone teleportation'); - await page.autocompleteSearch(selectors.agencyBasicData.agency, 'Quantum break device'); - await page.write(selectors.agencyBasicData.maxVolume, '10'); - await page.clearInput(selectors.agencyBasicData.travelingDays); - await page.write(selectors.agencyBasicData.travelingDays, '1'); - await page.clearInput(selectors.agencyBasicData.closing); - await page.type(selectors.agencyBasicData.closing, '2100'); - await page.clearInput(selectors.agencyBasicData.price); - await page.write(selectors.agencyBasicData.price, '999'); - await page.clearInput(selectors.agencyBasicData.bonus); - await page.write(selectors.agencyBasicData.bonus, '100'); - await page.clearInput(selectors.agencyBasicData.inflation); - await page.write(selectors.agencyBasicData.inflation, '200'); - await page.waitToClick(selectors.agencyBasicData.volumetric); - await page.waitToClick(selectors.agencyBasicData.saveButton); - }); - - it('should reload the section', async() => { - await page.reloadSection('zone.card.basicData'); - let url = await page.expectURL('#!/zone/10/basic-data'); - - expect(url).toBe(true); - }); - - it('should confirm the name was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.name, 'value'); - - expect(result).toEqual('Brimstone teleportation'); - }); - - it('should confirm the agency was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.agency, 'value'); - - expect(result).toEqual('Quantum break device'); - }); - - it('should confirm the max volume was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.maxVolume, 'value'); - - expect(result).toEqual('10'); - }); - - it('should confirm the traveling days were updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.travelingDays, 'value'); - - expect(result).toEqual('1'); - }); - - it('should confirm the closing hour was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.closing, 'value'); - - expect(result).toEqual('21:00'); - }); - - it('should confirm the price was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.price, 'value'); - - expect(result).toEqual('999'); - }); - - it('should confirm the bonus was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.bonus, 'value'); - - expect(result).toEqual('100'); - }); - - it('should confirm the inflation was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.inflation, 'value'); - - expect(result).toEqual('200'); - }); - - it('should confirm the volumetric checkbox was checked', async() => { - await page.waitForClassPresent(selectors.agencyBasicData.volumetric, 'checked'); - }); -}); diff --git a/e2e/paths/11-zone/01_basic-data.spec.js b/e2e/paths/11-zone/01_basic-data.spec.js new file mode 100644 index 000000000..211c0beb5 --- /dev/null +++ b/e2e/paths/11-zone/01_basic-data.spec.js @@ -0,0 +1,103 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Zone basic data path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('deliveryBoss', 'zone'); // turns up the zone module name and route aint the same lol + await page.accessToSearchResult('10'); + await page.accessToSection('zone.card.basicData'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the basic data section', async() => { + let url = await page.expectURL('#!/zone/10/basic-data'); + + expect(url).toBe(true); + }); + + it('should edit de form and then save', async() => { + await page.clearInput(selectors.zoneBasicData.name); + await page.write(selectors.zoneBasicData.name, 'Brimstone teleportation'); + await page.autocompleteSearch(selectors.zoneBasicData.agency, 'Quantum break device'); + await page.write(selectors.zoneBasicData.maxVolume, '10'); + await page.clearInput(selectors.zoneBasicData.travelingDays); + await page.write(selectors.zoneBasicData.travelingDays, '1'); + await page.clearInput(selectors.zoneBasicData.closing); + await page.type(selectors.zoneBasicData.closing, '2100'); + await page.clearInput(selectors.zoneBasicData.price); + await page.write(selectors.zoneBasicData.price, '999'); + await page.clearInput(selectors.zoneBasicData.bonus); + await page.write(selectors.zoneBasicData.bonus, '100'); + await page.clearInput(selectors.zoneBasicData.inflation); + await page.write(selectors.zoneBasicData.inflation, '200'); + await page.waitToClick(selectors.zoneBasicData.volumetric); + await page.waitToClick(selectors.zoneBasicData.saveButton); + }); + + it('should reload the section', async() => { + await page.reloadSection('zone.card.basicData'); + let url = await page.expectURL('#!/zone/10/basic-data'); + + expect(url).toBe(true); + }); + + it('should confirm the name was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.name, 'value'); + + expect(result).toEqual('Brimstone teleportation'); + }); + + it('should confirm the agency was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.agency, 'value'); + + expect(result).toEqual('Quantum break device'); + }); + + it('should confirm the max volume was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.maxVolume, 'value'); + + expect(result).toEqual('10'); + }); + + it('should confirm the traveling days were updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.travelingDays, 'value'); + + expect(result).toEqual('1'); + }); + + it('should confirm the closing hour was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.closing, 'value'); + + expect(result).toEqual('21:00'); + }); + + it('should confirm the price was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.price, 'value'); + + expect(result).toEqual('999'); + }); + + it('should confirm the bonus was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.bonus, 'value'); + + expect(result).toEqual('100'); + }); + + it('should confirm the inflation was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.inflation, 'value'); + + expect(result).toEqual('200'); + }); + + it('should confirm the volumetric checkbox was checked', async() => { + await page.waitForClassPresent(selectors.zoneBasicData.volumetric, 'checked'); + }); +}); diff --git a/e2e/paths/12-entry/01_summary.spec.js b/e2e/paths/12-entry/01_summary.spec.js new file mode 100644 index 000000000..39b12b840 --- /dev/null +++ b/e2e/paths/12-entry/01_summary.spec.js @@ -0,0 +1,43 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Entry summary path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('buyer', 'entry'); + await page.waitToClick('vn-entry-index vn-tbody > a:nth-child(2)'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the second entry summary section', async() => { + let url = await page.expectURL('#!/entry/2/summary'); + + expect(url).toBe(true); + }); + + it(`should display details from the entry on the header`, async() => { + await page.waitForTextInElement(selectors.entrySummary.header, 'The king'); + const result = await page.waitToGetProperty(selectors.entrySummary.header, 'innerText'); + + expect(result).toContain('The king'); + }); + + it('should display some entry details like the reference', async() => { + const result = await page.waitToGetProperty(selectors.entrySummary.reference, 'innerText'); + + expect(result).toContain('Movement 2'); + }); + + it('should display other entry details like the confirmed', async() => { + const result = await page.checkboxState(selectors.entrySummary.confirmed, 'innerText'); + + expect(result).toContain('unchecked'); + }); +}); diff --git a/front/core/styles/icons/salixfont.css b/front/core/styles/icons/salixfont.css index 64f2776ea..505fb8520 100644 --- a/front/core/styles/icons/salixfont.css +++ b/front/core/styles/icons/salixfont.css @@ -23,6 +23,12 @@ -moz-osx-font-smoothing: grayscale; } +.icon-net:before { + content: "\e95b"; +} +.icon-anonymous:before { + content: "\e95c"; +} .icon-buyrequest:before { content: "\e914"; } diff --git a/front/core/styles/icons/salixfont.svg b/front/core/styles/icons/salixfont.svg index 2c13f601b..7cd1af528 100644 --- a/front/core/styles/icons/salixfont.svg +++ b/front/core/styles/icons/salixfont.svg @@ -98,4 +98,6 @@ + + \ No newline at end of file diff --git a/front/core/styles/icons/salixfont.ttf b/front/core/styles/icons/salixfont.ttf index 7a6ad2721..08a36a48b 100644 Binary files a/front/core/styles/icons/salixfont.ttf and b/front/core/styles/icons/salixfont.ttf differ diff --git a/front/core/styles/icons/salixfont.woff b/front/core/styles/icons/salixfont.woff index 0e6d9a21a..325a1bc2d 100644 Binary files a/front/core/styles/icons/salixfont.woff and b/front/core/styles/icons/salixfont.woff differ diff --git a/front/module-import.js b/front/module-import.js index 0bfe7f8ca..dd1692c18 100755 --- a/front/module-import.js +++ b/front/module-import.js @@ -12,7 +12,7 @@ export default function moduleImport(moduleName) { case 'ticket' : return import('ticket/front'); case 'order' : return import('order/front'); case 'claim' : return import('claim/front'); - case 'agency' : return import('agency/front'); + case 'zone' : return import('zone/front'); case 'travel' : return import('travel/front'); case 'worker' : return import('worker/front'); case 'invoiceOut' : return import('invoiceOut/front'); diff --git a/front/salix/locale/es.yml b/front/salix/locale/es.yml index 34e1a2487..3ce39af8d 100644 --- a/front/salix/locale/es.yml +++ b/front/salix/locale/es.yml @@ -32,7 +32,7 @@ Remove: Quitar # Modules -Agencies: Agencias +Zones: Zonas Claims: Reclamaciones Clients: Clientes Items: Artículos diff --git a/jest-front.js b/jest-front.js index 40c0e52fc..5d6c342c0 100644 --- a/jest-front.js +++ b/jest-front.js @@ -2,7 +2,7 @@ import 'angular'; import 'angular-mocks'; import core from './front/core/module.js'; import './front/salix/components/app/app.js'; -import './modules/agency/front/module.js'; +import './modules/zone/front/module.js'; import './modules/claim/front/module.js'; import './modules/client/front/module.js'; import './modules/invoiceOut/front/module.js'; diff --git a/modules/agency/front/module.js b/modules/agency/front/module.js deleted file mode 100644 index cf38d7fe9..000000000 --- a/modules/agency/front/module.js +++ /dev/null @@ -1,3 +0,0 @@ -import {ng} from 'core/vendor'; - -export default ng.module('agency', ['vnCore']); diff --git a/modules/client/front/balance/index/index.spec.js b/modules/client/front/balance/index/index.spec.js index e10f903d0..e044b7979 100644 --- a/modules/client/front/balance/index/index.spec.js +++ b/modules/client/front/balance/index/index.spec.js @@ -44,12 +44,6 @@ describe('Client', () => { }); describe('company setter/getter', () => { - it('should return the company', () => { - controller.companyId = null; - - expect(controller._companyId).toEqual(jasmine.any(Object)); - }); - it('should return the company and then call getData()', () => { spyOn(controller, 'getData'); controller.companyId = 442; diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index 30777bcda..d8e035942 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -77,18 +77,15 @@
- From date + Send consumer report
-
- To date -
{ type: 'Number', description: 'The currency id to filter', http: {source: 'query'} + }, { + arg: 'from', + type: 'Date', + description: `The from date filter` + }, { + arg: 'to', + type: 'Date', + description: `The to date filter` } ], returns: { @@ -91,6 +99,10 @@ module.exports = Self => { return {[param]: {like: `%${value}%`}}; case 'created': return {'e.created': {gte: value}}; + case 'from': + return {'t.landed': {gte: value}}; + case 'to': + return {'t.landed': {lte: value}}; case 'id': case 'isBooked': case 'isConfirmed': diff --git a/modules/entry/back/methods/entry/getEntry.js b/modules/entry/back/methods/entry/getEntry.js new file mode 100644 index 000000000..008ee8148 --- /dev/null +++ b/modules/entry/back/methods/entry/getEntry.js @@ -0,0 +1,76 @@ +module.exports = Self => { + Self.remoteMethod('getEntry', { + description: 'Returns an entry', + accessType: 'READ', + accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: `/:id/getEntry`, + verb: 'GET' + } + }); + + Self.getEntry = async id => { + let filter = { + where: {id: id}, + include: [ + { + relation: 'supplier', + scope: { + fields: ['id', 'nickname'] + } + }, + { + relation: 'travel', + scope: { + fields: ['id', 'name', 'shipped', 'landed', 'agencyFk', 'warehouseOutFk', 'warehouseInFk'], + include: [ + { + relation: 'agency', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseOut', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseIn', + scope: { + fields: ['name'] + } + } + ] + } + }, + { + relation: 'currency', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'company', + scope: { + fields: ['id', 'code'] + } + } + ], + }; + + let entry = await Self.app.models.Entry.findOne(filter); + return entry; + }; +}; diff --git a/modules/entry/back/methods/entry/specs/getEntry.spec.js b/modules/entry/back/methods/entry/specs/getEntry.spec.js new file mode 100644 index 000000000..3791a3703 --- /dev/null +++ b/modules/entry/back/methods/entry/specs/getEntry.spec.js @@ -0,0 +1,31 @@ +const app = require('vn-loopback/server/server'); + +describe('travel getEntry()', () => { + const entryId = 1; + it('should check the entry contains the id', async() => { + const entry = await app.models.Entry.getEntry(entryId); + + expect(entry.id).toEqual(entryId); + }); + + it('should check the entry contains the supplier name', async() => { + const entry = await app.models.Entry.getEntry(entryId); + const supplierName = entry.supplier().nickname; + + expect(supplierName).toEqual('Plants nick'); + }); + + it('should check the entry contains the receiver warehouse name', async() => { + const entry = await app.models.Entry.getEntry(entryId); + const receiverWarehouseName = entry.travel().warehouseIn().name; + + expect(receiverWarehouseName).toEqual('Warehouse One'); + }); + + it('should check the entry contains the company code', async() => { + const entry = await app.models.Entry.getEntry(entryId); + const companyCode = entry.company().code; + + expect(companyCode).toEqual('VNL'); + }); +}); diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 4034b7e0a..b1f71b4bd 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -1,4 +1,5 @@ module.exports = Self => { require('../methods/entry/filter')(Self); + require('../methods/entry/getEntry')(Self); }; diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index a2eef4cd2..c2a7d7c42 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -39,6 +39,9 @@ "commission": { "type": "Number" }, + "isOrdered": { + "type": "Boolean" + }, "created": { "type": "date" }, diff --git a/modules/entry/front/card/index.js b/modules/entry/front/card/index.js index 62fed7db0..83f47c83d 100644 --- a/modules/entry/front/card/index.js +++ b/modules/entry/front/card/index.js @@ -11,11 +11,34 @@ class Controller extends ModuleCard { fields: ['id', 'code'] } }, { - relation: 'travel' + relation: 'travel', + scope: { + fields: ['id', 'landed', 'agencyFk', 'warehouseOutFk'], + include: [ + { + relation: 'agency', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseOut', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseIn', + scope: { + fields: ['name'] + } + } + ] + } }, { relation: 'supplier', scope: { - fields: ['id', 'name'] + fields: ['id', 'nickname'] } }, { relation: 'currency' @@ -27,7 +50,7 @@ class Controller extends ModuleCard { } } -ngModule.component('vnEntry Card', { +ngModule.component('vnEntryCard', { template: require('./index.html'), controller: Controller }); diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html index 372479c79..cd4057c43 100644 --- a/modules/entry/front/descriptor/index.html +++ b/modules/entry/front/descriptor/index.html @@ -6,16 +6,37 @@ - + +
- + + + + + + +
+ +
diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js index a9f5cd679..8f51308f2 100644 --- a/modules/entry/front/descriptor/index.js +++ b/modules/entry/front/descriptor/index.js @@ -1,17 +1,80 @@ import ngModule from '../module'; +import Component from 'core/lib/component'; -class Controller { - constructor($scope) { - this.$ = $scope; +class Controller extends Component { + constructor($element, $, $httpParamSerializer, vnConfig) { + super($element, $); + this.vnConfig = vnConfig; + this.$httpParamSerializer = $httpParamSerializer; + this.moreOptions = [ + {name: 'Show entry report', callback: this.showEntryReport} + ]; + } + + onMoreChange(callback) { + callback.call(this); + } + + get entry() { + return this._entry; + } + + set entry(value) { + this._entry = value; + if (!value) return; + + const date = value.travel.landed; + let to = new Date(date); + let from = new Date(date); + to.setDate(to.getDate() + 10); + + to.setHours(0, 0, 0, 0); + + from.setDate(from.getDate() - 10); + from.setHours(0, 0, 0, 0); + + let links = { + btnOne: { + icon: 'local_airport', + state: `travel.index({q: '{"agencyFk": ${value.travel.agencyFk}}'})`, + tooltip: 'All travels with current agency' + }}; + + links.btnTwo = { + icon: 'icon-entry', + state: `entry.index({q: '{"supplierFk": ${value.supplierFk}, "to": "${to}", "from": "${from}"}'})`, + tooltip: 'All entries with current supplier' + }; + + this._quicklinks = links; + } + + get quicklinks() { + return this._quicklinks; + } + + set quicklinks(value = {}) { + this._quicklinks = Object.assign(value, this._quicklinks); + } + + showEntryReport() { + const params = { + clientId: this.vnConfig.storage.currentUserWorkerId, + entryId: this.entry.id + }; + const serializedParams = this.$httpParamSerializer(params); + let url = `api/report/entry-order?${serializedParams}`; + window.open(url); } } -Controller.$inject = ['$scope']; +Controller.$inject = ['$element', '$scope', '$httpParamSerializer', 'vnConfig']; ngModule.component('vnEntryDescriptor', { template: require('./index.html'), bindings: { - entry: '<' + entry: '<', + quicklinks: '<' }, require: { card: '^?vnEntryCard' diff --git a/modules/entry/front/descriptor/index.spec.js b/modules/entry/front/descriptor/index.spec.js new file mode 100644 index 000000000..a63abc0f1 --- /dev/null +++ b/modules/entry/front/descriptor/index.spec.js @@ -0,0 +1,35 @@ +import './index.js'; + +describe('Entry Component vnEntryDescriptor', () => { + let $httpParamSerializer; + let controller; + let $element; + + beforeEach(ngModule('entry')); + + beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope, _$httpParamSerializer_) => { + $httpParamSerializer = _$httpParamSerializer_; + $element = angular.element(``); + controller = $componentController('vnEntryDescriptor', {$element}); + controller._entry = {id: 2}; + controller.vnConfig.storage = {currentUserWorkerId: 9}; + controller.cardReload = ()=> { + return true; + }; + })); + + describe('showEntryReport()', () => { + it('should open a new window showing a delivery note PDF document', () => { + const params = { + clientId: controller.vnConfig.storage.currentUserWorkerId, + entryId: controller.entry.id + }; + const serializedParams = $httpParamSerializer(params); + let expectedPath = `api/report/entry-order?${serializedParams}`; + spyOn(window, 'open'); + controller.showEntryReport(); + + expect(window.open).toHaveBeenCalledWith(expectedPath); + }); + }); +}); diff --git a/modules/entry/front/descriptor/locale/es.yml b/modules/entry/front/descriptor/locale/es.yml index e5b926f1d..5e1eb25c2 100644 --- a/modules/entry/front/descriptor/locale/es.yml +++ b/modules/entry/front/descriptor/locale/es.yml @@ -1 +1,4 @@ Reference: Referencia +All travels with current agency: Todos los envios con la agencia actual +All entries with current supplier: Todas las entradas con el proveedor actual +Show entry report: Ver informe del pedido \ No newline at end of file diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index a0272fccf..25e054a71 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -5,7 +5,4 @@ import './index/'; import './search-panel'; import './descriptor'; import './card'; -// import './summary'; -// import './basic-data'; -// import './log'; -// import './create'; +import './summary'; diff --git a/modules/entry/front/index/index.html b/modules/entry/front/index/index.html index f0f540489..60bbe46d5 100644 --- a/modules/entry/front/index/index.html +++ b/modules/entry/front/index/index.html @@ -16,7 +16,7 @@ - + Id Landed Reference @@ -33,18 +33,18 @@ - + + icon="icon-anonymous"> + icon="icon-net"> {{::entry.id}} diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index bd1ace3f2..612edc157 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -28,6 +28,14 @@ "state": "entry.card", "abstract": true, "component": "vn-entry-card" + }, { + "url": "/summary", + "state": "entry.card.summary", + "component": "vn-entry-summary", + "description": "Summary", + "params": { + "entry": "$ctrl.entry" + } } ] } \ No newline at end of file diff --git a/modules/entry/front/search-panel/index.html b/modules/entry/front/search-panel/index.html index d648edcdd..a3daa8f0f 100644 --- a/modules/entry/front/search-panel/index.html +++ b/modules/entry/front/search-panel/index.html @@ -54,6 +54,18 @@ ng-model="filter.created"> + + + + + + +
Entry #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js new file mode 100644 index 000000000..3b26907d7 --- /dev/null +++ b/modules/entry/front/summary/index.js @@ -0,0 +1,37 @@ +import ngModule from '../module'; +import './style.scss'; +import Component from 'core/lib/component'; + +class Controller extends Component { + constructor($element, $, $httpParamSerializer) { + super($element, $); + this.$httpParamSerializer = $httpParamSerializer; + } + + get entry() { + return this._entry; + } + + set entry(value) { + this._entry = value; + + if (value && value.id) + this.getEntryData(); + } + + getEntryData() { + return this.$http.get(`/api/Entries/${this.entry.id}/getEntry`).then(response => { + this.entryData = response.data; + }); + } +} + +Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; + +ngModule.component('vnEntrySummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + entry: '<' + } +}); diff --git a/modules/entry/front/summary/index.spec.js b/modules/entry/front/summary/index.spec.js new file mode 100644 index 000000000..ea4a5a7c1 --- /dev/null +++ b/modules/entry/front/summary/index.spec.js @@ -0,0 +1,50 @@ +import './index'; + +describe('component vnEntrySummary', () => { + let controller; + let $httpBackend; + let $scope; + let $element; + + beforeEach(angular.mock.module('entry', $translateProvider => { + $translateProvider.translations('en', {}); + })); + + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + $httpBackend = _$httpBackend_; + $scope = $rootScope.$new(); + $element = angular.element(``); + controller = $componentController('vnEntrySummary', {$element, $scope}); + })); + + describe('entry setter/getter', () => { + it('should check if value.id is defined', () => { + spyOn(controller, 'getEntryData'); + + controller.entry = {id: 1}; + + expect(controller.getEntryData).toHaveBeenCalledWith(); + }); + + it('should return the entry and then call getEntryData()', () => { + spyOn(controller, 'getEntryData'); + controller.entry = {id: 99}; + + expect(controller._entry.id).toEqual(99); + expect(controller.getEntryData).toHaveBeenCalledWith(); + }); + }); + + describe('getEntryData()', () => { + it('should perform a get and then store data on the controller', () => { + controller._entry = {id: 999}; + + const query = `/api/Entries/${controller._entry.id}/getEntry`; + $httpBackend.expectGET(query).respond('I am the entryData'); + controller.getEntryData(); + $httpBackend.flush(); + + expect(controller.entryData).toEqual('I am the entryData'); + }); + }); +}); diff --git a/modules/entry/front/summary/locale/es.yml b/modules/entry/front/summary/locale/es.yml new file mode 100644 index 000000000..1673d6a17 --- /dev/null +++ b/modules/entry/front/summary/locale/es.yml @@ -0,0 +1,3 @@ +Inventory: Inventario +Virtual: Redada +Entry: Entrada \ No newline at end of file diff --git a/modules/entry/front/summary/style.scss b/modules/entry/front/summary/style.scss new file mode 100644 index 000000000..8887e15b9 --- /dev/null +++ b/modules/entry/front/summary/style.scss @@ -0,0 +1,10 @@ +@import "variables"; + + +vn-entry-summary .summary { + max-width: $width-lg; + + vn-icon[icon=insert_drive_file]{ + color: $color-font-secondary; + } +} \ No newline at end of file diff --git a/modules/item/front/request/index.html b/modules/item/front/request/index.html index 3216e05e1..20da8946d 100644 --- a/modules/item/front/request/index.html +++ b/modules/item/front/request/index.html @@ -1,4 +1,4 @@ - { case 'search': return {or: [ {'t.id': value}, - {'c.id': value} + {'c.id': value}, + {'c.name': {like: `%${value}%`}} ]}; } }); diff --git a/modules/ticket/back/methods/ticket-weekly/specs/filter.spec.js b/modules/ticket/back/methods/ticket-weekly/specs/filter.spec.js new file mode 100644 index 000000000..14729b094 --- /dev/null +++ b/modules/ticket/back/methods/ticket-weekly/specs/filter.spec.js @@ -0,0 +1,41 @@ +const app = require('vn-loopback/server/server'); + +describe('ticket-weekly filter()', () => { + const authUserId = 9; + it('should return the tickets matching the filter', async() => { + const ctx = {req: {accessToken: {userId: authUserId}}, args: {}}; + const filter = {order: 'id DESC'}; + const result = await app.models.TicketWeekly.filter(ctx, filter); + const firstRow = result[0]; + + expect(firstRow.ticketFk).toEqual(1); + }); + + it('should return the ticket with id one', async() => { + const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 2}}; + const filter = {}; + const result = await app.models.TicketWeekly.filter(ctx, filter); + const firstRow = result[0]; + + expect(firstRow.ticketFk).toEqual(2); + }); + + it('should return the ticket matching the client name', async() => { + const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'bruce'}}; + const filter = {}; + const result = await app.models.TicketWeekly.filter(ctx, filter); + const firstRow = result[0]; + + expect(firstRow.clientName).toEqual('Bruce Wayne'); + }); + + it('should return the ticket matching the client id', async() => { + const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 101}}; + const filter = {}; + const result = await app.models.TicketWeekly.filter(ctx, filter); + const firstRow = result[0]; + + expect(firstRow.clientFk).toEqual(101); + expect(firstRow.clientName).toEqual('Bruce Wayne'); + }); +}); diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 5fea43fbd..fa3067c17 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -96,7 +96,8 @@ module.exports = Self => { }); Self.filter = async(ctx, filter) => { - let conn = Self.dataSource.connector; + const conn = Self.dataSource.connector; + const args = ctx.args; let worker = await Self.app.models.Worker.findOne({ where: {userFk: ctx.req.accessToken.userId}, @@ -107,13 +108,13 @@ module.exports = Self => { let teamIds = []; - if (worker.collegues().length && ctx.args.myTeam) { + if (worker.collegues().length && args.myTeam) { worker.collegues().forEach(collegue => { teamIds.push(collegue.collegueFk); }); } - if (ctx.args.mine || (worker.collegues().length === 0 && ctx.args.myTeam)) { + if (args.mine || (worker.collegues().length === 0 && args.myTeam)) { worker = await Self.app.models.Worker.findOne({ fields: ['id'], where: {userFk: ctx.req.accessToken.userId} @@ -121,23 +122,14 @@ module.exports = Self => { teamIds = [worker && worker.id]; } - if (ctx.args && (ctx.args.mine || ctx.args.myTeam)) - ctx.args.teamIds = teamIds; + if (ctx.args && (args.mine || args.myTeam)) + args.teamIds = teamIds; - if (ctx.args && ctx.args.to) { - const dateTo = ctx.args.to; + if (ctx.args && args.to) { + const dateTo = args.to; dateTo.setHours(23, 59, 0, 0); } - let orderTickets = []; - if (ctx.args && ctx.args.orderFk) { - let ticketsToSearch = await Self.app.models.OrderTicket.find({where: {orderFk: ctx.args.orderFk}}); - ticketsToSearch.forEach(ticket => { - orderTickets.push(ticket.ticketFk); - }); - ctx.args.search = orderTickets; - } - let where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': @@ -215,6 +207,14 @@ module.exports = Self => { LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN account.user u ON u.id = wk.userFk`); + + if (args.orderFk) { + stmt.merge({ + sql: `JOIN orderTicket ot ON ot.ticketFk = t.id AND ot.orderFk = ?`, + params: [args.orderFk] + }); + } + stmt.merge(conn.makeSuffix(filter)); stmts.push(stmt); @@ -249,7 +249,7 @@ module.exports = Self => { let hasProblem; let range; let hasWhere; - switch (ctx.args.problems) { + switch (args.problems) { case true: condition = `or`; hasProblem = true; diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 7e5e1c126..656f99d65 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -2,39 +2,45 @@ const app = require('vn-loopback/server/server'); describe('ticket filter()', () => { it('should return the tickets matching the filter', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {}}; - - let filter = {order: 'id DESC'}; - let result = await app.models.Ticket.filter(ctx, filter); - let ticketId = result[0].id; + const ctx = {req: {accessToken: {userId: 9}}, args: {}}; + const filter = {order: 'id DESC'}; + const result = await app.models.Ticket.filter(ctx, filter); + const ticketId = result[0].id; expect(ticketId).toEqual(24); }); it('should return the tickets matching the problems on true', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {problems: true}}; - - let filter = {}; - let result = await app.models.Ticket.filter(ctx, filter); + const ctx = {req: {accessToken: {userId: 9}}, args: {problems: true}}; + const filter = {}; + const result = await app.models.Ticket.filter(ctx, filter); expect(result.length).toEqual(4); }); it('should return the tickets matching the problems on false', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {problems: false}}; - - let filter = {}; - let result = await app.models.Ticket.filter(ctx, filter); + const ctx = {req: {accessToken: {userId: 9}}, args: {problems: false}}; + const filter = {}; + const result = await app.models.Ticket.filter(ctx, filter); expect(result.length).toEqual(20); }); it('should return the tickets matching the problems on null', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {problems: null}}; - - let filter = {}; - let result = await app.models.Ticket.filter(ctx, filter); + const ctx = {req: {accessToken: {userId: 9}}, args: {problems: null}}; + const filter = {}; + const result = await app.models.Ticket.filter(ctx, filter); expect(result.length).toEqual(24); }); + + it('should return the tickets matching the orderId 11', async() => { + const ctx = {req: {accessToken: {userId: 9}}, args: {orderFk: 11}}; + const filter = {}; + const result = await app.models.Ticket.filter(ctx, filter); + const firstRow = result[0]; + + expect(result.length).toEqual(1); + expect(firstRow.ticketFk).toEqual(11); + }); }); diff --git a/modules/travel/front/summary/index.spec.js b/modules/travel/front/summary/index.spec.js index 5411d8a0d..593d2cfcc 100644 --- a/modules/travel/front/summary/index.spec.js +++ b/modules/travel/front/summary/index.spec.js @@ -20,12 +20,6 @@ describe('component vnTravelSummary', () => { })); describe('travel setter/getter', () => { - it('should return the travel', () => { - controller.travel = {id: null}; - - expect(controller.travel).toEqual(jasmine.any(Object)); - }); - it('should return the travel and then call both getTravel() and getEntries()', () => { spyOn(controller, 'getTravel'); spyOn(controller, 'getEntries'); diff --git a/modules/worker/front/dms/index/index.html b/modules/worker/front/dms/index/index.html index 7859a50a4..2deffecf6 100644 --- a/modules/worker/front/dms/index/index.html +++ b/modules/worker/front/dms/index/index.html @@ -16,13 +16,10 @@ Id - Type - Order Reference Description Original File - Employee Created @@ -32,17 +29,6 @@ {{::document.dmsFk}} - - - {{::document.dms.dmsType.name}} - - - - - {{::document.dms.hardCopyNumber}} - - {{::document.dms.reference}} @@ -64,12 +50,6 @@ href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}">{{::document.dms.file}}
- - - {{::document.dms.worker.user.nickname | dashIfEmpty}} - - {{::document.dms.created | date:'dd/MM/yyyy HH:mm'}} diff --git a/modules/agency/back/methods/agency/getAgenciesWithWarehouse.js b/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js similarity index 100% rename from modules/agency/back/methods/agency/getAgenciesWithWarehouse.js rename to modules/zone/back/methods/agency/getAgenciesWithWarehouse.js diff --git a/modules/agency/back/methods/agency/getLanded.js b/modules/zone/back/methods/agency/getLanded.js similarity index 100% rename from modules/agency/back/methods/agency/getLanded.js rename to modules/zone/back/methods/agency/getLanded.js diff --git a/modules/agency/back/methods/agency/getShipped.js b/modules/zone/back/methods/agency/getShipped.js similarity index 100% rename from modules/agency/back/methods/agency/getShipped.js rename to modules/zone/back/methods/agency/getShipped.js diff --git a/modules/agency/back/methods/agency/landsThatDay.js b/modules/zone/back/methods/agency/landsThatDay.js similarity index 100% rename from modules/agency/back/methods/agency/landsThatDay.js rename to modules/zone/back/methods/agency/landsThatDay.js diff --git a/modules/agency/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js b/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js similarity index 100% rename from modules/agency/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js rename to modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js diff --git a/modules/agency/back/methods/agency/specs/getLanded.spec.js b/modules/zone/back/methods/agency/specs/getLanded.spec.js similarity index 100% rename from modules/agency/back/methods/agency/specs/getLanded.spec.js rename to modules/zone/back/methods/agency/specs/getLanded.spec.js diff --git a/modules/agency/back/methods/agency/specs/getShipped.spec.js b/modules/zone/back/methods/agency/specs/getShipped.spec.js similarity index 100% rename from modules/agency/back/methods/agency/specs/getShipped.spec.js rename to modules/zone/back/methods/agency/specs/getShipped.spec.js diff --git a/modules/agency/back/methods/agency/specs/landsThatDay.spec.js b/modules/zone/back/methods/agency/specs/landsThatDay.spec.js similarity index 100% rename from modules/agency/back/methods/agency/specs/landsThatDay.spec.js rename to modules/zone/back/methods/agency/specs/landsThatDay.spec.js diff --git a/modules/agency/back/methods/zone/clone.js b/modules/zone/back/methods/zone/clone.js similarity index 100% rename from modules/agency/back/methods/zone/clone.js rename to modules/zone/back/methods/zone/clone.js diff --git a/modules/agency/back/methods/zone/getEvents.js b/modules/zone/back/methods/zone/getEvents.js similarity index 100% rename from modules/agency/back/methods/zone/getEvents.js rename to modules/zone/back/methods/zone/getEvents.js diff --git a/modules/agency/back/methods/zone/getLeaves.js b/modules/zone/back/methods/zone/getLeaves.js similarity index 100% rename from modules/agency/back/methods/zone/getLeaves.js rename to modules/zone/back/methods/zone/getLeaves.js diff --git a/modules/agency/back/methods/zone/specs/clone.spec.js b/modules/zone/back/methods/zone/specs/clone.spec.js similarity index 100% rename from modules/agency/back/methods/zone/specs/clone.spec.js rename to modules/zone/back/methods/zone/specs/clone.spec.js diff --git a/modules/agency/back/methods/zone/toggleIsIncluded.js b/modules/zone/back/methods/zone/toggleIsIncluded.js similarity index 100% rename from modules/agency/back/methods/zone/toggleIsIncluded.js rename to modules/zone/back/methods/zone/toggleIsIncluded.js diff --git a/modules/agency/back/model-config.json b/modules/zone/back/model-config.json similarity index 100% rename from modules/agency/back/model-config.json rename to modules/zone/back/model-config.json diff --git a/modules/agency/back/models/agency-mode.json b/modules/zone/back/models/agency-mode.json similarity index 100% rename from modules/agency/back/models/agency-mode.json rename to modules/zone/back/models/agency-mode.json diff --git a/modules/agency/back/models/agency.js b/modules/zone/back/models/agency.js similarity index 100% rename from modules/agency/back/models/agency.js rename to modules/zone/back/models/agency.js diff --git a/modules/agency/back/models/agency.json b/modules/zone/back/models/agency.json similarity index 100% rename from modules/agency/back/models/agency.json rename to modules/zone/back/models/agency.json diff --git a/modules/agency/back/models/delivery-method.json b/modules/zone/back/models/delivery-method.json similarity index 100% rename from modules/agency/back/models/delivery-method.json rename to modules/zone/back/models/delivery-method.json diff --git a/modules/agency/back/models/zone-closure.js b/modules/zone/back/models/zone-closure.js similarity index 100% rename from modules/agency/back/models/zone-closure.js rename to modules/zone/back/models/zone-closure.js diff --git a/modules/agency/back/models/zone-closure.json b/modules/zone/back/models/zone-closure.json similarity index 100% rename from modules/agency/back/models/zone-closure.json rename to modules/zone/back/models/zone-closure.json diff --git a/modules/agency/back/models/zone-event.js b/modules/zone/back/models/zone-event.js similarity index 100% rename from modules/agency/back/models/zone-event.js rename to modules/zone/back/models/zone-event.js diff --git a/modules/agency/back/models/zone-event.json b/modules/zone/back/models/zone-event.json similarity index 94% rename from modules/agency/back/models/zone-event.json rename to modules/zone/back/models/zone-event.json index 0d46b1fe2..9ac1007b5 100644 --- a/modules/agency/back/models/zone-event.json +++ b/modules/zone/back/models/zone-event.json @@ -41,6 +41,9 @@ }, "bonus": { "type": "Number" + }, + "m3Max": { + "type": "Number" } }, "relations": { diff --git a/modules/agency/back/models/zone-exclusion.json b/modules/zone/back/models/zone-exclusion.json similarity index 100% rename from modules/agency/back/models/zone-exclusion.json rename to modules/zone/back/models/zone-exclusion.json diff --git a/modules/agency/back/models/zone-geo.json b/modules/zone/back/models/zone-geo.json similarity index 100% rename from modules/agency/back/models/zone-geo.json rename to modules/zone/back/models/zone-geo.json diff --git a/modules/agency/back/models/zone-included.json b/modules/zone/back/models/zone-included.json similarity index 100% rename from modules/agency/back/models/zone-included.json rename to modules/zone/back/models/zone-included.json diff --git a/modules/agency/back/models/zone-warehouse.json b/modules/zone/back/models/zone-warehouse.json similarity index 100% rename from modules/agency/back/models/zone-warehouse.json rename to modules/zone/back/models/zone-warehouse.json diff --git a/modules/agency/back/models/zone.js b/modules/zone/back/models/zone.js similarity index 100% rename from modules/agency/back/models/zone.js rename to modules/zone/back/models/zone.js diff --git a/modules/agency/back/models/zone.json b/modules/zone/back/models/zone.json similarity index 100% rename from modules/agency/back/models/zone.json rename to modules/zone/back/models/zone.json diff --git a/modules/agency/front/basic-data/index.html b/modules/zone/front/basic-data/index.html similarity index 100% rename from modules/agency/front/basic-data/index.html rename to modules/zone/front/basic-data/index.html diff --git a/modules/agency/front/basic-data/index.js b/modules/zone/front/basic-data/index.js similarity index 100% rename from modules/agency/front/basic-data/index.js rename to modules/zone/front/basic-data/index.js diff --git a/modules/agency/front/calendar/index.html b/modules/zone/front/calendar/index.html similarity index 100% rename from modules/agency/front/calendar/index.html rename to modules/zone/front/calendar/index.html diff --git a/modules/agency/front/calendar/index.js b/modules/zone/front/calendar/index.js similarity index 100% rename from modules/agency/front/calendar/index.js rename to modules/zone/front/calendar/index.js diff --git a/modules/agency/front/calendar/style.scss b/modules/zone/front/calendar/style.scss similarity index 100% rename from modules/agency/front/calendar/style.scss rename to modules/zone/front/calendar/style.scss diff --git a/modules/agency/front/card/index.html b/modules/zone/front/card/index.html similarity index 100% rename from modules/agency/front/card/index.html rename to modules/zone/front/card/index.html diff --git a/modules/agency/front/card/index.js b/modules/zone/front/card/index.js similarity index 100% rename from modules/agency/front/card/index.js rename to modules/zone/front/card/index.js diff --git a/modules/agency/front/card/index.spec.js b/modules/zone/front/card/index.spec.js similarity index 95% rename from modules/agency/front/card/index.spec.js rename to modules/zone/front/card/index.spec.js index cc53fe946..48970ce6b 100644 --- a/modules/agency/front/card/index.spec.js +++ b/modules/zone/front/card/index.spec.js @@ -5,7 +5,7 @@ describe('Agency Component vnZoneCard', () => { let $httpBackend; let data = {id: 1, name: 'fooName'}; - beforeEach(ngModule('agency')); + beforeEach(ngModule('zone')); beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $stateParams) => { $httpBackend = _$httpBackend_; diff --git a/modules/agency/front/create/index.html b/modules/zone/front/create/index.html similarity index 100% rename from modules/agency/front/create/index.html rename to modules/zone/front/create/index.html diff --git a/modules/agency/front/create/index.js b/modules/zone/front/create/index.js similarity index 100% rename from modules/agency/front/create/index.js rename to modules/zone/front/create/index.js diff --git a/modules/agency/front/create/index.spec.js b/modules/zone/front/create/index.spec.js similarity index 96% rename from modules/agency/front/create/index.spec.js rename to modules/zone/front/create/index.spec.js index 5b2a022f8..5041e5095 100644 --- a/modules/agency/front/create/index.spec.js +++ b/modules/zone/front/create/index.spec.js @@ -6,7 +6,7 @@ describe('Agency Component vnZoneCreate', () => { let $state; let controller; - beforeEach(ngModule('agency')); + beforeEach(ngModule('zone')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_) => { $scope = $rootScope.$new(); diff --git a/modules/agency/front/create/locale/es.yml b/modules/zone/front/create/locale/es.yml similarity index 100% rename from modules/agency/front/create/locale/es.yml rename to modules/zone/front/create/locale/es.yml diff --git a/modules/agency/front/delivery-days/index.html b/modules/zone/front/delivery-days/index.html similarity index 100% rename from modules/agency/front/delivery-days/index.html rename to modules/zone/front/delivery-days/index.html diff --git a/modules/agency/front/delivery-days/index.js b/modules/zone/front/delivery-days/index.js similarity index 100% rename from modules/agency/front/delivery-days/index.js rename to modules/zone/front/delivery-days/index.js diff --git a/modules/agency/front/delivery-days/style.scss b/modules/zone/front/delivery-days/style.scss similarity index 100% rename from modules/agency/front/delivery-days/style.scss rename to modules/zone/front/delivery-days/style.scss diff --git a/modules/agency/front/descriptor/index.html b/modules/zone/front/descriptor/index.html similarity index 100% rename from modules/agency/front/descriptor/index.html rename to modules/zone/front/descriptor/index.html diff --git a/modules/agency/front/descriptor/index.js b/modules/zone/front/descriptor/index.js similarity index 100% rename from modules/agency/front/descriptor/index.js rename to modules/zone/front/descriptor/index.js diff --git a/modules/agency/front/events/index.html b/modules/zone/front/events/index.html similarity index 82% rename from modules/agency/front/events/index.html rename to modules/zone/front/events/index.html index 693b24a85..0df58287f 100644 --- a/modules/agency/front/events/index.html +++ b/modules/zone/front/events/index.html @@ -75,6 +75,10 @@ label="Bonus" value="{{::row.bonus | currency:'EUR':2}}"> + + - - + + + + + + + + + + + + - - - - diff --git a/modules/agency/front/events/index.js b/modules/zone/front/events/index.js similarity index 100% rename from modules/agency/front/events/index.js rename to modules/zone/front/events/index.js diff --git a/modules/agency/front/events/locale/es.yml b/modules/zone/front/events/locale/es.yml similarity index 100% rename from modules/agency/front/events/locale/es.yml rename to modules/zone/front/events/locale/es.yml diff --git a/modules/agency/front/index.js b/modules/zone/front/index.js similarity index 100% rename from modules/agency/front/index.js rename to modules/zone/front/index.js diff --git a/modules/agency/front/index/index.html b/modules/zone/front/index/index.html similarity index 100% rename from modules/agency/front/index/index.html rename to modules/zone/front/index/index.html diff --git a/modules/agency/front/index/index.js b/modules/zone/front/index/index.js similarity index 100% rename from modules/agency/front/index/index.js rename to modules/zone/front/index/index.js diff --git a/modules/agency/front/index/index.spec.js b/modules/zone/front/index/index.spec.js similarity index 96% rename from modules/agency/front/index/index.spec.js rename to modules/zone/front/index/index.spec.js index cf2fdfab5..04fc599b7 100644 --- a/modules/agency/front/index/index.spec.js +++ b/modules/zone/front/index/index.spec.js @@ -4,7 +4,7 @@ describe('Agency Component vnZoneIndex', () => { let $componentController; let controller; - beforeEach(ngModule('agency')); + beforeEach(ngModule('zone')); beforeEach(angular.mock.inject(_$componentController_ => { $componentController = _$componentController_; diff --git a/modules/agency/front/index/locale/es.yml b/modules/zone/front/index/locale/es.yml similarity index 100% rename from modules/agency/front/index/locale/es.yml rename to modules/zone/front/index/locale/es.yml diff --git a/modules/agency/front/locale/es.yml b/modules/zone/front/locale/es.yml similarity index 100% rename from modules/agency/front/locale/es.yml rename to modules/zone/front/locale/es.yml diff --git a/modules/agency/front/location/index.html b/modules/zone/front/location/index.html similarity index 100% rename from modules/agency/front/location/index.html rename to modules/zone/front/location/index.html diff --git a/modules/agency/front/location/index.js b/modules/zone/front/location/index.js similarity index 100% rename from modules/agency/front/location/index.js rename to modules/zone/front/location/index.js diff --git a/modules/agency/front/location/style.scss b/modules/zone/front/location/style.scss similarity index 100% rename from modules/agency/front/location/style.scss rename to modules/zone/front/location/style.scss diff --git a/modules/agency/front/main/index.html b/modules/zone/front/main/index.html similarity index 100% rename from modules/agency/front/main/index.html rename to modules/zone/front/main/index.html diff --git a/modules/agency/front/main/index.js b/modules/zone/front/main/index.js similarity index 100% rename from modules/agency/front/main/index.js rename to modules/zone/front/main/index.js diff --git a/modules/zone/front/module.js b/modules/zone/front/module.js new file mode 100644 index 000000000..08a427e04 --- /dev/null +++ b/modules/zone/front/module.js @@ -0,0 +1,3 @@ +import {ng} from 'core/vendor'; + +export default ng.module('zone', ['vnCore']); diff --git a/modules/agency/front/routes.json b/modules/zone/front/routes.json similarity index 94% rename from modules/agency/front/routes.json rename to modules/zone/front/routes.json index 7c5b1338d..857b4b0a4 100644 --- a/modules/agency/front/routes.json +++ b/modules/zone/front/routes.json @@ -1,12 +1,12 @@ { - "module": "agency", - "name": "Agencies", - "icon" : "icon-delivery", + "module": "zone", + "name": "Zones", + "icon" : "location_on", "validations" : true, "dependencies": ["worker"], "menus": { "main": [ - {"state": "zone.index", "icon": "icon-delivery"}, + {"state": "zone.index", "icon": "location_on"}, {"state": "zone.deliveryDays", "icon": "today"} ], "card": [ diff --git a/modules/agency/front/search-panel/index.html b/modules/zone/front/search-panel/index.html similarity index 100% rename from modules/agency/front/search-panel/index.html rename to modules/zone/front/search-panel/index.html diff --git a/modules/agency/front/search-panel/index.js b/modules/zone/front/search-panel/index.js similarity index 100% rename from modules/agency/front/search-panel/index.js rename to modules/zone/front/search-panel/index.js diff --git a/modules/agency/front/summary/index.html b/modules/zone/front/summary/index.html similarity index 100% rename from modules/agency/front/summary/index.html rename to modules/zone/front/summary/index.html diff --git a/modules/agency/front/summary/index.js b/modules/zone/front/summary/index.js similarity index 100% rename from modules/agency/front/summary/index.js rename to modules/zone/front/summary/index.js diff --git a/modules/agency/front/summary/index.spec.js b/modules/zone/front/summary/index.spec.js similarity index 98% rename from modules/agency/front/summary/index.spec.js rename to modules/zone/front/summary/index.spec.js index d0f99dbb2..03faf4cfd 100644 --- a/modules/agency/front/summary/index.spec.js +++ b/modules/zone/front/summary/index.spec.js @@ -7,7 +7,7 @@ describe('component vnZoneSummary', () => { let $httpBackend; let $httpParamSerializer; - beforeEach(ngModule('agency')); + beforeEach(ngModule('zone')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; diff --git a/modules/agency/front/warehouses/index.html b/modules/zone/front/warehouses/index.html similarity index 100% rename from modules/agency/front/warehouses/index.html rename to modules/zone/front/warehouses/index.html diff --git a/modules/agency/front/warehouses/index.js b/modules/zone/front/warehouses/index.js similarity index 100% rename from modules/agency/front/warehouses/index.js rename to modules/zone/front/warehouses/index.js diff --git a/print/templates/reports/entry-order/assets/css/import.js b/print/templates/reports/entry-order/assets/css/import.js new file mode 100644 index 000000000..fd8796c2b --- /dev/null +++ b/print/templates/reports/entry-order/assets/css/import.js @@ -0,0 +1,9 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/spacing.css`, + `${appPath}/common/css/misc.css`, + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css new file mode 100644 index 000000000..4215e7181 --- /dev/null +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -0,0 +1,6 @@ + + +h3 { + font-weight: 100; + color: #555 +} \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html new file mode 100644 index 000000000..cbb0de0d5 --- /dev/null +++ b/print/templates/reports/entry-order/entry-order.html @@ -0,0 +1,146 @@ + + + + + + + + + +
+ +
+
+ + +
+
+ +
+
+
+
+
+
+

{{$t('title')}}

+ + + + + + + + + + + + + + + +
{{$t('entryId')}}{{entry.id}}
{{$t('date')}}{{entry.landed | date('%d-%m-%Y')}}
{{$t('ref')}}{{entry.ref}}
+
+
+
+
+
+
{{$t('supplierData')}}
+
+

{{supplier.name}}

+
+ {{supplier.street}} +
+
+ {{supplier.postCode}}, {{supplier.city}}, ({{supplier.province}}) +
+
+ {{supplier.nif}} +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
{{$t('boxes')}}{{$t('packing')}}{{$t('concept')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}
+ {{$t('total')}} + {{getTotal() | currency('EUR', locale)}}
+ +
+
+
+
+

{{$t('notes')}}

+
+ {{entry.notes}} +
+
+
+
+
+
+
+ +
+
+ + +
+
+
+ + \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.js b/print/templates/reports/entry-order/entry-order.js new file mode 100755 index 000000000..55492fbaf --- /dev/null +++ b/print/templates/reports/entry-order/entry-order.js @@ -0,0 +1,85 @@ +const db = require(`${appPath}/core/database`); +const Component = require(`${appPath}/core/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); + +module.exports = { + name: 'entry-order', + async serverPrefetch() { + this.supplier = await this.fetchSupplier(this.entryId); + this.entry = await this.fetchEntry(this.entryId); + this.buys = await this.fetchBuys(this.entryId); + + if (!this.entry) + throw new Error('Something went wrong'); + }, + data() { + return {totalBalance: 0.00}; + }, + methods: { + fetchSupplier(entryId) { + return db.findOne( + `SELECT + s.name, + s.street, + s.nif, + s.postCode, + s.city, + p.name province + FROM supplier s + JOIN entry e ON e.supplierFk = s.id + LEFT JOIN province p ON p.id = s.provinceFk + WHERE e.id = ?`, [entryId]); + }, + fetchEntry(entryId) { + return db.findOne( + `SELECT + e.id, + e.ref, + e.notes, + c.code companyCode, + t.landed + FROM entry e + JOIN travel t ON t.id = e.travelFk + JOIN company c ON c.id = e.companyFk + WHERE e.id = ?`, [entryId]); + }, + fetchBuys(entryId) { + return db.rawSql( + `SELECT + b.itemFk, + b.quantity, + b.buyingValue, + b.stickers box, + b.packing, + i.name itemName, + i.tag5, + i.value5, + i.tag6, + i.value6, + i.tag7, + i.value7 + FROM buy b + JOIN item i ON i.id = b.itemFk + WHERE b.entryFk = ?`, [entryId]); + }, + getTotal() { + let total = 0.00; + this.buys.forEach(buy => { + total += buy.quantity * buy.buyingValue; + }); + + return total; + } + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() + }, + props: { + entryId: { + type: String, + required: true + } + } +}; diff --git a/print/templates/reports/entry-order/locale/en.yml b/print/templates/reports/entry-order/locale/en.yml new file mode 100644 index 000000000..e69de29bb diff --git a/print/templates/reports/entry-order/locale/es.yml b/print/templates/reports/entry-order/locale/es.yml new file mode 100644 index 000000000..3c29d6401 --- /dev/null +++ b/print/templates/reports/entry-order/locale/es.yml @@ -0,0 +1,16 @@ +title: Pedido +supplierName: Proveedor +supplierStreet: Dirección +entryId: Referencia interna +date: Fecha +ref: Nº Factura +boxes: Cajas +packing: U/C +quantity: Cantidad +price: Precio +amount: Importe +concept: Descripción +total: Total +entry: Entrada {0} +supplierData: Datos del proveedor +notes: Notas \ No newline at end of file