Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2824-ticket_totalWith_and_without_VAT

This commit is contained in:
Carlos Jimenez Ruiz 2021-03-10 19:25:43 +01:00
commit 4c0d583556
10 changed files with 56 additions and 44 deletions

View File

@ -0,0 +1,4 @@
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES
('Genus', '*', 'WRITE', 'ALLOW', 'ROLE', 'logisticBoss'),
('Specie', '*', 'WRITE', 'ALLOW', 'ROLE', 'logisticBoss');

View File

@ -22,12 +22,6 @@
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "logisticBoss",
"permission": "ALLOW"
}
]
}

View File

@ -22,12 +22,6 @@
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "logisticBoss",
"permission": "ALLOW"
}
]
}

View File

@ -17,7 +17,8 @@
icon="add_circle"
vn-tooltip="New genus"
ng-click="$ctrl.showGenus($event)"
vn-acl="logisticBoss">
vn-acl="logisticBoss"
vn-acl-action="remove">
</vn-icon-button>
</append>
</vn-autocomplete>
@ -38,7 +39,8 @@
icon="add_circle"
vn-tooltip="New species"
ng-click="$ctrl.showSpecies($event)"
vn-acl="logisticBoss">
vn-acl="logisticBoss"
vn-acl-action="remove">
</vn-icon-button>
</append>
</vn-autocomplete>
@ -61,6 +63,7 @@
<!-- Create new genus dialog -->
<vn-dialog class="edit"
vn-id="genus"
on-response="$ctrl.onGenusResponse($response)"
on-accept="$ctrl.onGenusAccept()"
message="New genus">
<tpl-body>
@ -80,6 +83,7 @@
<!-- Create new species dialog -->
<vn-dialog class="edit"
vn-id="species"
on-response="$ctrl.onSpeciesResponse($response)"
on-accept="$ctrl.onSpeciesAccept()"
message="New species">
<tpl-body>

View File

@ -33,6 +33,7 @@ class Controller extends Section {
this.$http.post(`genera`, this.data).then(res => {
this.vnApp.showMessage(this.$t('The genus has been created'));
this.emit('response', {$response: res.data});
this.onGenusResponse(res.data);
});
} catch (e) {
this.vnApp.showError(this.$t(e.message));
@ -44,11 +45,12 @@ class Controller extends Section {
onSpeciesAccept() {
try {
if (!this.data.name)
throw new Error(`The name of the specie can't be empty`);
throw new Error(`The name of the species can't be empty`);
this.$http.post(`species`, this.data).then(res => {
this.vnApp.showMessage(this.$t('The specie has been created'));
this.vnApp.showMessage(this.$t('The species has been created'));
this.emit('response', {$response: res.data});
this.onSpeciesResponse(res.data);
});
} catch (e) {
this.vnApp.showError(this.$t(e.message));
@ -78,6 +80,14 @@ class Controller extends Section {
this.$.watcher.updateOriginalData();
});
}
onGenusResponse(response) {
this.botanical.genusFk = response.id;
}
onSpeciesResponse(response) {
this.botanical.specieFk = response.id;
}
}
ngModule.vnComponent('vnItemBotanical', {

View File

@ -30,6 +30,11 @@ describe('vnItemBotanical', () => {
}};
}));
beforeEach(() => {
const response = {data: 'MyResult'};
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response);
});
describe('showGenus()', () => {
it('should do nothing in genus field if it default is prevented', () => {
const event = {
@ -45,7 +50,7 @@ describe('vnItemBotanical', () => {
expect(controller.$.genus.show).not.toHaveBeenCalledWith();
});
it('should call preventDefault() and show() in genus field when the default is not prevented', () => {
it('should call show function in genus field when the default is not prevented', () => {
const event = {
defaultPrevented: false,
preventDefault: () => {}
@ -76,7 +81,7 @@ describe('vnItemBotanical', () => {
expect(controller.$.species.show).not.toHaveBeenCalledWith();
});
it('should call preventDefault() and show() in species field when the default is not prevented', () => {
it('should call show function in species field when the default is not prevented', () => {
const event = {
defaultPrevented: false,
preventDefault: () => {}
@ -93,7 +98,7 @@ describe('vnItemBotanical', () => {
});
describe('onGenusAccept()', () => {
it('should throw an error if there is no name in the genus name field', () => {
it('should throw an error if the item botanical has no genus name', () => {
jest.spyOn(controller.vnApp, 'showMessage');
controller.data = {};
@ -103,11 +108,9 @@ describe('vnItemBotanical', () => {
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the genus can't be empty`);
});
it('should do add the new genus', () => {
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond({});
$httpBackend.resetExpectations();
it('should add the new genus', () => {
controller.data = {
id: 4,
name: 'Anilius'
};
@ -115,25 +118,27 @@ describe('vnItemBotanical', () => {
controller.onGenusAccept();
$httpBackend.flush();
controller.onGenusResponse(controller.data);
expect(controller.botanical.genusFk).toEqual(controller.data.id);
});
});
describe('onSpeciesAccept()', () => {
it('should throw an error if there is no name in the specie name field', () => {
it('should throw an error if the item botanical has no species name', () => {
jest.spyOn(controller.vnApp, 'showMessage');
controller.data = {};
controller.onSpeciesAccept();
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the specie can't be empty`);
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the species can't be empty`);
});
it('should do add the new specie', () => {
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond({});
$httpBackend.resetExpectations();
it('should add the new species', () => {
controller.data = {
id: 2,
name: 'Spasiva'
};
@ -141,20 +146,17 @@ describe('vnItemBotanical', () => {
controller.onSpeciesAccept();
$httpBackend.flush();
controller.onSpeciesResponse(controller.data);
});
});
describe('onSubmit()', () => {
it('should make an HTTP POST request to save the genus and species data', () => {
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond({});
$httpBackend.resetExpectations();
it('should make HTTP POST request to save the genus and species data', () => {
jest.spyOn(controller.$.watcher, 'updateOriginalData');
jest.spyOn(controller.$.watcher, 'check');
jest.spyOn(controller.$.watcher, 'notifySaved');
controller.botanical = [{itemFk: 5, genusFk: 3, specieFk: 2}];
$httpBackend.expectPATCH('ItemBotanicals', controller.botanical).respond({});
$httpBackend.expectPATCH('ItemBotanicals').respond();
controller.onSubmit();
$httpBackend.flush();
@ -165,13 +167,11 @@ describe('vnItemBotanical', () => {
});
describe('getBotanicalData()', () => {
it('should get the item data from itemBotanical', () => {
const response = ['MyResult'];
$httpBackend.whenRoute('GET', `ItemBotanicals`).respond(response);
it('should get the species and genus data references of the item', () => {
controller.getBotanicalData();
$httpBackend.flush();
expect(controller.botanical).toEqual(response[0]);
expect(controller.botanical).toEqual(controller.$params);
});
});
});

View File

@ -1,5 +1,5 @@
The genus has been created: El genus ha sido creado
The specie has been created: La especie ha sido creada
The species has been created: La especie ha sido creada
Latin species name: Nombre de la especie en latín
Latin genus name: Nombre del genus en latín
Species: Especie

View File

@ -111,7 +111,7 @@
</h4>
<h4
translate
ng-show="!$ctrl.isBuyer || !$ctrl.isReplenisher">
ng-show="!$ctrl.isBuyer && !$ctrl.isReplenisher">
Tags
</h4>
<vn-label-value
@ -130,7 +130,7 @@
</h4>
<h4
translate
ng-show="!$ctrl.isBuyer || !$ctrl.isAdministrative">
ng-show="!$ctrl.isBuyer && !$ctrl.isAdministrative">
Tax
</h4>
<vn-label-value label="{{tax.country.country}}"
@ -148,7 +148,7 @@
</h4>
<h4
translate
ng-show="!$ctrl.isBuyer || !$ctrl.isReplenisher">
ng-show="!$ctrl.isBuyer && !$ctrl.isReplenisher">
Niche
</h4>
<vn-label-value label="{{niche.warehouse.name}}"
@ -186,7 +186,7 @@
</h4>
<h4
translate
ng-show="!$ctrl.isBuyer || !$ctrl.isReplenisher">
ng-show="!$ctrl.isBuyer && !$ctrl.isReplenisher">
Barcode
</h4>
<p ng-repeat="barcode in $ctrl.summary.item.itemBarcode track by $index">

View File

@ -33,6 +33,11 @@
icon="verified_user"
ng-if="$ctrl.supplier.isSerious == true">
</vn-icon>
<vn-icon
vn-tooltip="Unverified supplier"
icon="icon-supplierfalse"
ng-if="$ctrl.supplier.isSerious == false">
</vn-icon>
</div>
<div class="quicklinks">
<div ng-transclude="btnOne">

View File

@ -2,4 +2,5 @@ Tax number: NIF / CIF
All entries with current supplier: Todas las entradas con el proveedor actual
Go to client: Ir al cliente
Verified supplier: Proveedor verificado
Unverified supplier: Proveedor no verificado
Inactive supplier: Proveedor inactivo