Fixed errors detected
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
eb3ac6de72
commit
433a0094c4
|
@ -1 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('SupplierAccount', '*', '*', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -1,59 +0,0 @@
|
|||
{
|
||||
"name": "SupplierAccount",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model":"SupplierLog",
|
||||
"relation": "supplier"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "supplierAccount"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"supplierFk": {
|
||||
"type": "Number"
|
||||
},
|
||||
"iban": {
|
||||
"type": "String"
|
||||
},
|
||||
"office": {
|
||||
"type": "String"
|
||||
},
|
||||
"DC": {
|
||||
"type": "String"
|
||||
},
|
||||
"number": {
|
||||
"type": "String"
|
||||
},
|
||||
"description": {
|
||||
"type": "String"
|
||||
},
|
||||
"bicSufix": {
|
||||
"type": "String"
|
||||
},
|
||||
"bankEntityFk": {
|
||||
"type": "Number"
|
||||
},
|
||||
"bankFk": {
|
||||
"type": "Number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"supplier": {
|
||||
"type": "belongsTo",
|
||||
"model": "Supplier",
|
||||
"foreignKey": "supplierFk"
|
||||
},
|
||||
"bankEntity": {
|
||||
"type": "belongsTo",
|
||||
"model": "BankEntity",
|
||||
"foreignKey": "bankEntityFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="SupplierAccounts"
|
||||
fields="['id', 'supplierFk', 'iban', 'bankEntityFk']"
|
||||
link="{supplierFk: $ctrl.$params.id}"
|
||||
include="$ctrl.include"
|
||||
data="$ctrl.supplierAccounts"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.supplierAccounts"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal ng-repeat="supplierAccount in $ctrl.supplierAccounts">
|
||||
<vn-textfield vn-three
|
||||
ng-show="supplierAccount.iban || supplierAccount.iban == undefined"
|
||||
label="Iban"
|
||||
ng-model="supplierAccount.iban"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-autocomplete vn-two vn-focus
|
||||
label="Bank entity"
|
||||
initial-data="$ctrl.getName(bankEntity)"
|
||||
ng-model="supplierAccount.bankEntityFk"
|
||||
url="BankEntities"
|
||||
on-change="$ctrl.getName(bankEntity)"
|
||||
show-field="name"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
<append>
|
||||
<vn-icon-button
|
||||
icon="add_circle"
|
||||
vn-tooltip="New bank entity"
|
||||
ng-click="bankentity.open()">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
<vn-none>
|
||||
<vn-icon-button
|
||||
vn-tooltip="Remove account"
|
||||
icon="delete"
|
||||
ng-click="model.remove($index)"
|
||||
tabindex="-1">
|
||||
</vn-icon-button>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-icon-button
|
||||
vn-bind="+"
|
||||
vn-tooltip="Add account"
|
||||
icon="add_circle"
|
||||
ng-click="$ctrl.add()">
|
||||
</vn-icon-button>
|
||||
</vn-one>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Save">
|
||||
</vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
<!-- New bankentity dialog -->
|
||||
<vn-new-bank-entity
|
||||
vn-id="bankentity"
|
||||
on-response="$ctrl.onResponse($response)">
|
||||
</vn-new-bank-entity>
|
|
@ -1,49 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.include = {
|
||||
relation: 'bankEntity',
|
||||
scope: {
|
||||
fields: ['countryFk', 'id', 'name', 'bic']
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
add() {
|
||||
this.$.model.insert({
|
||||
supplierFk: this.$params.id
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.check();
|
||||
this.$.model.save().then(() => {
|
||||
this.$.watcher.notifySaved();
|
||||
this.$.watcher.updateOriginalData();
|
||||
this.card.reload();
|
||||
});
|
||||
}
|
||||
|
||||
showBankEntity(event) {
|
||||
if (event.defaultPrevented) return;
|
||||
event.preventDefault();
|
||||
this.$.bankEntity.show();
|
||||
}
|
||||
|
||||
onBankEntityAccept() {
|
||||
const query = `SupplierAccounts/${this.$params.id}/createBankEntity`;
|
||||
return this.$http.patch(query, this.newBankEntity)
|
||||
.then(res => this.supplierAccount.bankEntityFk = res.data.id);
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierAccount', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
require: {
|
||||
card: '^vnSupplierCard'
|
||||
}
|
||||
});
|
|
@ -1,68 +0,0 @@
|
|||
import './index.js';
|
||||
|
||||
describe('Supplier Component vnSupplierAccount', () => {
|
||||
let $scope;
|
||||
let $element;
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
beforeEach(ngModule('supplier'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
$scope = $rootScope.$new();
|
||||
$scope.bankEntity = {
|
||||
show: () => {}
|
||||
};
|
||||
$element = angular.element('<vn-supplier-accounts></supplier-accounts>');
|
||||
controller = $componentController('vnSupplierAccount', {$element, $scope});
|
||||
controller.supplierAccount = {
|
||||
supplierFk: 442,
|
||||
name: 'Verdnatura'
|
||||
};
|
||||
}));
|
||||
|
||||
describe('showBankEntity()', () => {
|
||||
it('should do nothing if it default is prevented', () => {
|
||||
const event = {
|
||||
defaultPrevented: true,
|
||||
preventDefault: () => {}
|
||||
};
|
||||
jest.spyOn(event, 'preventDefault');
|
||||
jest.spyOn(controller.$.bankEntity, 'show');
|
||||
|
||||
controller.showBankEntity(event);
|
||||
|
||||
expect(event.preventDefault).not.toHaveBeenCalledWith();
|
||||
expect(controller.$.bankEntity.show).not.toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('should call preventDefault() and show() when the default is not prevented', () => {
|
||||
const event = {
|
||||
defaultPrevented: false,
|
||||
preventDefault: () => {}
|
||||
};
|
||||
jest.spyOn(event, 'preventDefault');
|
||||
jest.spyOn(controller.$.bankEntity, 'show');
|
||||
|
||||
controller.showBankEntity(event);
|
||||
|
||||
expect(event.preventDefault).toHaveBeenCalledWith();
|
||||
expect(controller.$.bankEntity.show).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('should request to create a new bank entity', () => {
|
||||
controller.bankEntity = {
|
||||
name: 'My new bank entity',
|
||||
bic: 'ES1234',
|
||||
countryFk: 1,
|
||||
id: 2200
|
||||
};
|
||||
$httpBackend.expectPATCH(`SupplierAccounts/${controller.$.bankEntity.id}/createBankEntity`).respond({id: 2200});
|
||||
controller.onBankEntityAccept();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.supplierAccount.bankEntityFk).toEqual(controller.bankEntity.id);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
Bank entity: Entidad bancaria
|
||||
swift: Swift BIC
|
|
@ -1,40 +0,0 @@
|
|||
<vn-dialog class="edit"
|
||||
vn-id="bankEntityDialog"
|
||||
on-open="$ctrl.resetLocation()"
|
||||
on-accept="$ctrl.onAccept()"
|
||||
message="New bank entity">
|
||||
<tpl-body>
|
||||
<p translate>Please, ensure you put the correct data!</p>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
vn-focus
|
||||
vn-id="entityName"
|
||||
label="Name"
|
||||
ng-model="$ctrl.location.name"
|
||||
required="true">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
vn-focus
|
||||
vn-id="bic"
|
||||
label="Swift"
|
||||
ng-model="$ctrl.location.bic"
|
||||
required="true">
|
||||
</vn-textfield>
|
||||
<vn-autocomplete vn-one
|
||||
ng-model="$ctrl.location.countryFk"
|
||||
url="Countries"
|
||||
show-field="country"
|
||||
value-field="id"
|
||||
label="Country">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button id= "saveBankEntity" response="accept" translate>Save</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
|
@ -1,40 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import Component from 'core/lib/component';
|
||||
import './style.scss';
|
||||
|
||||
class Controller extends Component {
|
||||
open() {
|
||||
this.$.bankEntityDialog.show();
|
||||
}
|
||||
resetLocation() {
|
||||
this.location = {};
|
||||
}
|
||||
|
||||
onCountryResponse(response) {
|
||||
this.location.countryFk = response.id;
|
||||
}
|
||||
|
||||
onAccept() {
|
||||
try {
|
||||
if (!this.location.countryFk)
|
||||
throw new Error(`The country can't be empty`);
|
||||
|
||||
this.$http.post(`Bankentities`, this.location).then(() => {
|
||||
this.vnApp.showMessage(this.$t('The bank entity has been created. You can save the data now'));
|
||||
this.emit('response', {$response: this.location});
|
||||
});
|
||||
} catch (e) {
|
||||
this.vnApp.showError(this.$t(e.message));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnNewBankEntity', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
data: '<',
|
||||
}
|
||||
});
|
|
@ -1,53 +0,0 @@
|
|||
import './index';
|
||||
|
||||
describe('Supplier Component vnNewBankEntity', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
let $scope;
|
||||
let $element;
|
||||
let vnApp;
|
||||
|
||||
beforeEach(ngModule('supplier'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
vnApp = _vnApp_;
|
||||
jest.spyOn(vnApp, 'showError');
|
||||
$scope = $rootScope.$new();
|
||||
$element = angular.element('<vn-dialog></dialog>');
|
||||
controller = $componentController('vnNewBankEntity', {$element, $scope});
|
||||
}));
|
||||
|
||||
describe('resetLocation()', () => {
|
||||
it('should reset the location in the controller', () => {
|
||||
expect(controller.location).toBeUndefined();
|
||||
|
||||
controller.resetLocation();
|
||||
|
||||
expect(controller.location).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe('onAccept()', () => {
|
||||
it('should throw an error if there is no country id in the location', () => {
|
||||
jest.spyOn(controller.vnApp, 'showMessage');
|
||||
|
||||
controller.location = {};
|
||||
|
||||
controller.onAccept();
|
||||
|
||||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The country can't be empty`);
|
||||
});
|
||||
|
||||
it('should do add the new bank entity', () => {
|
||||
controller.location = {
|
||||
countryFk: 1
|
||||
};
|
||||
|
||||
$httpBackend.expectPOST('Bankentities', controller.location).respond(200, controller.location);
|
||||
|
||||
controller.onAccept();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,11 +0,0 @@
|
|||
New postcode: Nuevo código postal
|
||||
New city: Nueva ciudad
|
||||
New province: Nueva provincia
|
||||
Please, ensure you put the correct data!: ¡Por favor, asegúrate de poner los datos correctos!
|
||||
The postcode can't be empty: El código postal no puede quedar vacío
|
||||
The town can't be empty: La población no puede quedar vacía
|
||||
The province can't be empty: La provincia no puede quedar vacía
|
||||
The country can't be empty: El país no puede quedar vacío
|
||||
The postcode has been created. You can save the data now: Se ha creado el código postal. Ahora puedes guardar los datos
|
||||
The city has been created: Se ha creado la ciudad
|
||||
The province has been created: Se ha creado la provincia
|
|
@ -1,9 +0,0 @@
|
|||
@import "variables";
|
||||
|
||||
vn-new-bank-entity {
|
||||
vn-dialog {
|
||||
p {
|
||||
color: $color-alert
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,8 +8,6 @@ import './search-panel';
|
|||
import './summary';
|
||||
import './basic-data';
|
||||
import './fiscal-data';
|
||||
import './bankentity';
|
||||
import './account';
|
||||
import './contact';
|
||||
import './log';
|
||||
import './consumption';
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
{"state": "supplier.index", "icon": "icon-supplier"}
|
||||
],
|
||||
"card": [
|
||||
{"state": "supplier.card.account", "icon": "face"},
|
||||
{"state": "supplier.card.basicData", "icon": "settings"},
|
||||
{"state": "supplier.card.fiscalData", "icon": "account_balance"},
|
||||
{"state": "supplier.card.billingData", "icon": "icon-payment"},
|
||||
|
@ -100,15 +99,6 @@
|
|||
"supplier": "$ctrl.supplier"
|
||||
},
|
||||
"acl": ["administrative"]
|
||||
},{
|
||||
"url": "/account",
|
||||
"state": "supplier.card.account",
|
||||
"component": "vn-supplier-account",
|
||||
"description": "Account",
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
},
|
||||
"acl": ["administrative"]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue