Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2502-supplier_summary

This commit is contained in:
Carlos Jimenez Ruiz 2020-10-28 09:54:26 +01:00
commit 8dba3fbb93
32 changed files with 118 additions and 60 deletions

View File

@ -1,3 +1,8 @@
UPDATE `salix`.`ACL` SET `principalId` = 'deliveryBoss' WHERE (`id` = '194'); UPDATE `salix`.`ACL` SET `principalId` = 'deliveryBoss' WHERE (`id` = '194');
UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '97');
UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '100');
UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '103');
UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '202');
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Town', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Town', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss');
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Province', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Province', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss');

View File

@ -0,0 +1,3 @@
UPDATE `vn`.`claimState` SET `roleFk` = '72' WHERE (`id` = '3');
UPDATE `vn`.`claimState` SET `roleFk` = '72' WHERE (`id` = '4');
UPDATE `vn`.`claimState` SET `roleFk` = '72' WHERE (`id` = '5');

File diff suppressed because one or more lines are too long

View File

@ -1534,9 +1534,9 @@ INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`)
VALUES VALUES
( 1, 'pending', 'Pendiente', 1, 1), ( 1, 'pending', 'Pendiente', 1, 1),
( 2, 'managed', 'Gestionado', 1, 5), ( 2, 'managed', 'Gestionado', 1, 5),
( 3, 'resolved', 'Resuelto', 21, 7), ( 3, 'resolved', 'Resuelto', 72, 7),
( 4, 'canceled', 'Anulado', 1, 6), ( 4, 'canceled', 'Anulado', 72, 6),
( 5, 'disputed', 'Cuestionado', 21, 3), ( 5, 'disputed', 'Cuestionado', 72, 3),
( 6, 'mana', 'Mana', 1, 4), ( 6, 'mana', 'Mana', 1, 4),
( 7, 'inProgress', 'En Curso', 1, 2); ( 7, 'inProgress', 'En Curso', 1, 2);

View File

@ -14,8 +14,8 @@ describe('Claim edit basic data path', () => {
await browser.close(); await browser.close();
}); });
it(`should log in as salesAssistant then reach basic data of the target claim`, async() => { it(`should log in as claimManager then reach basic data of the target claim`, async() => {
await page.loginAndModule('salesAssistant', 'claim'); await page.loginAndModule('claimManager', 'claim');
await page.accessToSearchResult('1'); await page.accessToSearchResult('1');
await page.accessToSection('claim.card.basicData'); await page.accessToSection('claim.card.basicData');
}); });
@ -30,7 +30,7 @@ describe('Claim edit basic data path', () => {
expect(message.type).toBe('success'); expect(message.type).toBe('success');
}); });
it(`should have been redirected to the next section of claims as the role is salesAssistant`, async() => { it(`should have been redirected to the next section of claims as the role is claimManager`, async() => {
await page.waitForState('claim.card.detail'); await page.waitForState('claim.card.detail');
}); });

View File

@ -8,7 +8,7 @@ describe('Claim development', () => {
beforeAll(async() => { beforeAll(async() => {
browser = await getBrowser(); browser = await getBrowser();
page = browser.page; page = browser.page;
await page.loginAndModule('salesAssistant', 'claim'); await page.loginAndModule('claimManager', 'claim');
await page.accessToSearchResult('1'); await page.accessToSearchResult('1');
await page.accessToSection('claim.card.development'); await page.accessToSection('claim.card.development');
}); });
@ -31,7 +31,7 @@ describe('Claim development', () => {
expect(message.type).toBe('success'); expect(message.type).toBe('success');
}); });
it(`should redirect to the next section of claims as the role is salesAssistant`, async() => { it(`should redirect to the next section of claims as the role is claimManager`, async() => {
await page.waitForState('claim.card.action'); await page.waitForState('claim.card.action');
}); });

View File

@ -8,7 +8,7 @@ describe('Claim action path', () => {
beforeAll(async() => { beforeAll(async() => {
browser = await getBrowser(); browser = await getBrowser();
page = browser.page; page = browser.page;
await page.loginAndModule('administrative', 'claim'); await page.loginAndModule('claimManager', 'claim');
await page.accessToSearchResult('2'); await page.accessToSearchResult('2');
await page.accessToSection('claim.card.action'); await page.accessToSection('claim.card.action');
}); });

View File

@ -26,8 +26,8 @@ describe('claim Descriptor path', () => {
await page.waitForSelector(selectors.claimDescriptor.moreMenuDeleteClaim, {hidden: true}); await page.waitForSelector(selectors.claimDescriptor.moreMenuDeleteClaim, {hidden: true});
}); });
it(`should log in as salesAssistant and navigate to the target claim`, async() => { it(`should log in as claimManager and navigate to the target claim`, async() => {
await page.loginAndModule('salesAssistant', 'claim'); await page.loginAndModule('claimManager', 'claim');
await page.accessToSearchResult(claimId); await page.accessToSearchResult(claimId);
await page.waitForState('claim.card.summary'); await page.waitForState('claim.card.summary');
}); });

View File

@ -73,6 +73,7 @@
"I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})", "I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})",
"I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})", "I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})",
"Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
"The grade must be similar to the last one": "The grade must be similar to the last one",
"agencyModeFk": "Agency", "agencyModeFk": "Agency",
"clientFk": "Client", "clientFk": "Client",
"zoneFk": "Zone", "zoneFk": "Zone",

View File

@ -2,13 +2,13 @@ const app = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context'); const LoopBackContext = require('loopback-context');
describe('claimBeginning', () => { describe('claimBeginning', () => {
const salesAssistantId = 21; const claimManagerId = 72;
let ticket; let ticket;
let refundTicketSales; let refundTicketSales;
let salesInsertedInClaimEnd; let salesInsertedInClaimEnd;
const activeCtx = { const activeCtx = {
accessToken: {userId: salesAssistantId}, accessToken: {userId: claimManagerId},
}; };
const ctx = {req: activeCtx}; const ctx = {req: activeCtx};

View File

@ -21,10 +21,8 @@ module.exports = Self => {
Self.isEditable = async(ctx, id) => { Self.isEditable = async(ctx, id) => {
const userId = ctx.req.accessToken.userId; const userId = ctx.req.accessToken.userId;
const isClaimManager = await Self.app.models.Account.hasRole(userId, 'claimManager');
const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant'); const claim = await Self.app.models.Claim.findById(id, {
let claim = await Self.app.models.Claim.findById(id, {
fields: ['claimStateFk'], fields: ['claimStateFk'],
include: [{ include: [{
relation: 'claimState' relation: 'claimState'
@ -33,7 +31,7 @@ module.exports = Self => {
const isClaimResolved = claim && claim.claimState().code == 'resolved'; const isClaimResolved = claim && claim.claimState().code == 'resolved';
if (!claim || (isClaimResolved && !isSalesAssistant)) if (!claim || (isClaimResolved && !isClaimManager))
return false; return false;
return true; return true;

View File

@ -2,9 +2,9 @@ const app = require('vn-loopback/server/server');
describe('claim isEditable()', () => { describe('claim isEditable()', () => {
const salesPerdonId = 18; const salesPerdonId = 18;
const salesAssistantId = 21; const claimManagerId = 72;
it('should return false if the given claim does not exist', async() => { it('should return false if the given claim does not exist', async() => {
let ctx = {req: {accessToken: {userId: salesAssistantId}}}; let ctx = {req: {accessToken: {userId: claimManagerId}}};
let result = await app.models.Claim.isEditable(ctx, 99999); let result = await app.models.Claim.isEditable(ctx, 99999);
expect(result).toEqual(false); expect(result).toEqual(false);
@ -17,14 +17,14 @@ describe('claim isEditable()', () => {
expect(result).toEqual(false); expect(result).toEqual(false);
}); });
it('should be able to edit a resolved claim for a salesAssistant', async() => { it('should be able to edit a resolved claim for a claimManager', async() => {
let ctx = {req: {accessToken: {userId: salesAssistantId}}}; let ctx = {req: {accessToken: {userId: claimManagerId}}};
let result = await app.models.Claim.isEditable(ctx, 4); let result = await app.models.Claim.isEditable(ctx, 4);
expect(result).toEqual(true); expect(result).toEqual(true);
}); });
it('should be able to edit a claim for a salesAssistant', async() => { it('should be able to edit a claim for a claimManager', async() => {
let ctx = {req: {accessToken: {userId: salesPerdonId}}}; let ctx = {req: {accessToken: {userId: salesPerdonId}}};
let result = await app.models.Claim.isEditable(ctx, 1); let result = await app.models.Claim.isEditable(ctx, 1);

View File

@ -42,17 +42,17 @@ describe('Update Claim', () => {
it(`should success to update the claim within privileges `, async() => { it(`should success to update the claim within privileges `, async() => {
let newClaim = await app.models.Claim.create(originalData); let newClaim = await app.models.Claim.create(originalData);
const correctState = 4; const canceledState = 4;
const salesPersonId = 18; const claimManagerId = 72;
const ctx = { const ctx = {
req: { req: {
accessToken: { accessToken: {
userId: salesPersonId userId: claimManagerId
} }
}, },
args: { args: {
observation: 'valid observation', observation: 'valid observation',
claimStateFk: correctState, claimStateFk: canceledState,
hasToPickUp: false hasToPickUp: false
} }
}; };
@ -66,15 +66,15 @@ describe('Update Claim', () => {
await app.models.Claim.destroyById(newClaim.id); await app.models.Claim.destroyById(newClaim.id);
}); });
it('should change some sensible fields as salesAssistant', async() => { it('should change some sensible fields as claimManager', async() => {
let newClaim = await app.models.Claim.create(originalData); let newClaim = await app.models.Claim.create(originalData);
const chatModel = app.models.Chat; const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough(); spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const salesAssistantId = 21; const claimManagerId = 72;
const ctx = { const ctx = {
req: { req: {
accessToken: {userId: salesAssistantId}, accessToken: {userId: claimManagerId},
headers: {origin: 'http://localhost'} headers: {origin: 'http://localhost'}
}, },
args: { args: {

View File

@ -60,9 +60,9 @@ module.exports = Self => {
if (args.claimStateFk) { if (args.claimStateFk) {
const canUpdate = await canChangeState(ctx, claim.claimStateFk); const canUpdate = await canChangeState(ctx, claim.claimStateFk);
const hasRights = await canChangeState(ctx, args.claimStateFk); const hasRights = await canChangeState(ctx, args.claimStateFk);
const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant'); const isClaimManager = await models.Account.hasRole(userId, 'claimManager');
if (!canUpdate || !hasRights || changedHasToPickUp && !isSalesAssistant) if (!canUpdate || !hasRights || changedHasToPickUp && !isClaimManager)
throw new UserError(`You don't have enough privileges to change that field`); throw new UserError(`You don't have enough privileges to change that field`);
} }
delete args.ctx; delete args.ctx;

View File

@ -56,7 +56,8 @@
class="vn-mr-md" class="vn-mr-md"
label="Pick up" label="Pick up"
ng-model="$ctrl.claim.hasToPickUp" ng-model="$ctrl.claim.hasToPickUp"
vn-acl="salesAssistant"> vn-acl="claimManager"
info="When checked will notify to the salesPerson">
</vn-check> </vn-check>
</vn-horizontal> </vn-horizontal>
</vn-card> </vn-card>

View File

@ -5,7 +5,7 @@ import './style.scss';
class Controller extends Section { class Controller extends Section {
onSubmit() { onSubmit() {
this.$.watcher.submit().then(() => { this.$.watcher.submit().then(() => {
if (this.aclService.hasAny(['salesAssistant'])) if (this.aclService.hasAny(['claimManager']))
this.$state.go('claim.card.detail'); this.$state.go('claim.card.detail');
}); });
} }

View File

@ -5,3 +5,4 @@ Responsability: Responsabilidad
Company: Empresa Company: Empresa
Sales/Client: Comercial/Cliente Sales/Client: Comercial/Cliente
Pick up: Recoger Pick up: Recoger
When checked will notify a pickup to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial

View File

@ -13,7 +13,7 @@
Send Pickup order Send Pickup order
</vn-item> </vn-item>
<vn-item <vn-item
vn-acl="salesAssistant" vn-acl="claimManager"
vn-acl-action="remove" vn-acl-action="remove"
ng-click="confirmDeleteClaim.show()" ng-click="confirmDeleteClaim.show()"
name="deleteClaim" name="deleteClaim"

View File

@ -77,7 +77,7 @@ class Controller extends Section {
this.$.model.refresh(); this.$.model.refresh();
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
if (this.aclService.hasAny(['salesAssistant'])) if (this.aclService.hasAny(['claimManager']))
this.$state.go('claim.card.development'); this.$state.go('claim.card.development');
}); });
} }
@ -133,7 +133,7 @@ class Controller extends Section {
showEditPopover(event, saleClaimed) { showEditPopover(event, saleClaimed) {
if (this.isEditable) { if (this.isEditable) {
if (!this.aclService.hasAny(['salesAssistant'])) if (!this.aclService.hasAny(['claimManager']))
return this.vnApp.showError(this.$t('Insuficient permisos')); return this.vnApp.showError(this.$t('Insuficient permisos'));
this.saleClaimed = saleClaimed; this.saleClaimed = saleClaimed;

View File

@ -9,7 +9,7 @@ class Controller extends Section {
this.$.watcher.notifySaved(); this.$.watcher.notifySaved();
this.$.watcher.updateOriginalData(); this.$.watcher.updateOriginalData();
if (this.aclService.hasAny(['salesAssistant'])) if (this.aclService.hasAny(['claimManager']))
this.$state.go('claim.card.action'); this.$state.go('claim.card.action');
}); });
} }

View File

@ -70,7 +70,7 @@
"params": { "params": {
"claim": "$ctrl.claim" "claim": "$ctrl.claim"
}, },
"acl": ["salesAssistant"] "acl": ["claimManager"]
}, { }, {
"url": "/action", "url": "/action",
"state": "claim.card.action", "state": "claim.card.action",
@ -79,7 +79,7 @@
"params": { "params": {
"claim": "$ctrl.claim" "claim": "$ctrl.claim"
}, },
"acl": ["salesAssistant"] "acl": ["claimManager"]
}, { }, {
"url": "/photos", "url": "/photos",
"state": "claim.card.photos", "state": "claim.card.photos",

View File

@ -42,7 +42,7 @@
max="5" max="5"
min="1" min="1"
step="1" step="1"
vn-acl="salesAssistant"> vn-acl="claimManager">
</vn-range> </vn-range>
</vn-one> </vn-one>
<vn-auto> <vn-auto>

View File

@ -7,7 +7,7 @@ export default class Client extends ModuleMain {
case 'search': case 'search':
return /^\d+$/.test(value) return /^\d+$/.test(value)
? {id: value} ? {id: value}
: {name: {like: `%${value}%`}}; : {or: [{name: {like: `%${value}%`}}, {socialName: {like: `%${value}%`}}]};
case 'phone': case 'phone':
return { return {
or: [ or: [

View File

@ -55,8 +55,8 @@
</span> </span>
</vn-td> </vn-td>
<vn-td number> <vn-td number>
<span ng-class="::{link: sale.isTicket}" <span class="link"
ng-click="$ctrl.showTicketDescriptor($event, sale)" ng-click="$ctrl.showDescriptor($event, sale)"
name="origin"> name="origin">
{{::sale.origin | dashIfEmpty}} {{::sale.origin | dashIfEmpty}}
</span> </span>
@ -94,3 +94,7 @@
<vn-client-descriptor-popover <vn-client-descriptor-popover
vn-id="clientDescriptor"> vn-id="clientDescriptor">
</vn-client-descriptor-popover> </vn-client-descriptor-popover>
<vn-entry-descriptor-popover
vn-id="entryDescriptor">
</vn-entry-descriptor-popover>

View File

@ -58,10 +58,12 @@ class Controller extends Section {
this.$anchorScroll(); this.$anchorScroll();
} }
showTicketDescriptor(event, sale) { showDescriptor(event, sale) {
if (!sale.isTicket) return; let descriptor = 'entryDescriptor';
if (sale.isTicket)
descriptor = 'ticketDescriptor';
this.$.ticketDescriptor.show(event.target, sale.origin); this.$[descriptor].show(event.target, sale.origin);
} }
} }

View File

@ -60,6 +60,34 @@ describe('Item', () => {
expect(controller.$anchorScroll).toHaveBeenCalledWith(); expect(controller.$anchorScroll).toHaveBeenCalledWith();
}); });
}); });
describe('showDescriptor ()', () => {
it('should call to the entryDescriptor show() method', () => {
controller.$.entryDescriptor = {};
controller.$.entryDescriptor.show = jest.fn();
const $event = new Event('click');
const target = document.createElement('div');
target.dispatchEvent($event);
const data = {id: 1, origin: 1};
controller.showDescriptor($event, data);
expect(controller.$.entryDescriptor.show).toHaveBeenCalledWith($event.target, data.origin);
});
it('should call to the ticketDescriptor show() method', () => {
controller.$.ticketDescriptor = {};
controller.$.ticketDescriptor.show = jest.fn();
const $event = new Event('click');
const target = document.createElement('div');
target.dispatchEvent($event);
const data = {id: 1, origin: 1, isTicket: true};
controller.showDescriptor($event, data);
expect(controller.$.ticketDescriptor.show).toHaveBeenCalledWith($event.target, data.origin);
});
});
}); });
}); });

View File

@ -3,7 +3,7 @@
"name": "Items", "name": "Items",
"icon": "icon-item", "icon": "icon-item",
"validations" : true, "validations" : true,
"dependencies": ["worker", "client", "ticket"], "dependencies": ["worker", "client", "ticket", "entry"],
"menus": { "menus": {
"main": [ "main": [
{"state": "item.index", "icon": "icon-item"}, {"state": "item.index", "icon": "icon-item"},

View File

@ -28,8 +28,12 @@
<vn-label-value label="Agency" <vn-label-value label="Agency"
value="{{$ctrl.summary.agencyMode.name}}"> value="{{$ctrl.summary.agencyMode.name}}">
</vn-label-value> </vn-label-value>
<vn-label-value label="Zone" <vn-label-value label="Zone">
value="{{$ctrl.summary.zone.name}}"> <span
ng-click="zoneDescriptor.show($event, $ctrl.summary.zoneFk)"
class="link">
{{$ctrl.summary.zone.name}}
</span>
</vn-label-value> </vn-label-value>
<vn-label-value label="Warehouse" <vn-label-value label="Warehouse"
value="{{$ctrl.summary.warehouse.name}}"> value="{{$ctrl.summary.warehouse.name}}">
@ -247,3 +251,6 @@
<vn-worker-descriptor-popover <vn-worker-descriptor-popover
vn-id="workerDescriptor"> vn-id="workerDescriptor">
</vn-worker-descriptor-popover> </vn-worker-descriptor-popover>
<vn-zone-descriptor-popover
vn-id="zoneDescriptor">
</vn-zone-descriptor-popover>

View File

@ -3,7 +3,7 @@
"name": "Travels", "name": "Travels",
"icon": "local_airport", "icon": "local_airport",
"validations": true, "validations": true,
"dependencies": ["worker"], "dependencies": ["worker", "entry"],
"menus": { "menus": {
"main": [ "main": [
{"state": "travel.index", "icon": "local_airport"} {"state": "travel.index", "icon": "local_airport"}

View File

@ -41,7 +41,7 @@
value="{{$ctrl.travelData.ref}}"> value="{{$ctrl.travelData.ref}}">
</vn-label-value> </vn-label-value>
<vn-label-value <vn-label-value
label="m3" label="m³"
value="{{$ctrl.travelData.m3}}"> value="{{$ctrl.travelData.m3}}">
</vn-label-value> </vn-label-value>
<vn-label-value <vn-label-value
@ -63,7 +63,7 @@
<vn-th shrink>Package</vn-th> <vn-th shrink>Package</vn-th>
<vn-th shrink>CC</vn-th> <vn-th shrink>CC</vn-th>
<vn-th shrink>Pallet</vn-th> <vn-th shrink>Pallet</vn-th>
<vn-th shrink>m3</vn-th> <vn-th shrink>m³</vn-th>
<vn-th shrink></vn-th> <vn-th shrink></vn-th>
</vn-tr> </vn-tr>
</vn-thead> </vn-thead>
@ -75,7 +75,12 @@
disabled="true"> disabled="true">
</vn-check> </vn-check>
</vn-td> </vn-td>
<vn-td shrink>{{entry.id}} </vn-td> <vn-td shrink>
<span class="link"
vn-click-stop="entryDescriptor.show($event, entry.id)">
{{entry.id}}
</span>
</vn-td>
<vn-td expand>{{entry.supplierName}}</vn-td> <vn-td expand>{{entry.supplierName}}</vn-td>
<vn-td shrink>{{entry.ref}}</vn-td> <vn-td shrink>{{entry.ref}}</vn-td>
<vn-td shrink>{{entry.hb}}</vn-td> <vn-td shrink>{{entry.hb}}</vn-td>
@ -142,3 +147,6 @@
</vn-auto> </vn-auto>
</vn-horizontal> </vn-horizontal>
</vn-card> </vn-card>
<vn-entry-descriptor-popover
vn-id="entryDescriptor">
</vn-entry-descriptor-popover>

View File

@ -9,7 +9,7 @@ Received: Recibida
Agency: Agencia Agency: Agencia
Entries: Entradas Entries: Entradas
Confirmed: Confirmada Confirmed: Confirmada
Entry Id: Entrada Id Entry Id: Id entrada
Supplier: Proveedor Supplier: Proveedor
Pallet: Pallet Pallet: Pallet
Freight: Porte Freight: Porte

View File

@ -73,7 +73,7 @@
value="{{::row.bonus | currency:'EUR':2}}"> value="{{::row.bonus | currency:'EUR':2}}">
</vn-label-value> </vn-label-value>
<vn-label-value <vn-label-value
label="Max m3" label="Max m³"
value="{{::row.m3Max}}"> value="{{::row.m3Max}}">
</vn-label-value> </vn-label-value>
</vn-item-section> </vn-item-section>
@ -166,7 +166,7 @@
</vn-input-number> </vn-input-number>
</vn-horizontal> </vn-horizontal>
<vn-input-number <vn-input-number
label="Max m3" label="Max m³"
ng-model="$ctrl.selected.m3Max" ng-model="$ctrl.selected.m3Max"
min="0" min="0"
step="0.01"> step="0.01">