rutas reparadas
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Javi Gallego 2021-05-31 08:21:16 +02:00
parent 38ec2415fd
commit 3a5d84b34c
11 changed files with 311 additions and 31 deletions

View File

@ -0,0 +1,104 @@
import './card.js';
describe('Order', () => {
describe('Component vnOrderCreateCard', () => {
let controller;
let $httpBackend;
let $scope;
beforeEach(ngModule('order'));
beforeEach(inject(($componentController, _$httpBackend_, _vnApp_, $rootScope) => {
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
const $element = angular.element('<vn-order-create-card></vn-order-create-card>');
controller = $componentController('vnOrderCreateCard', {$element, $scope});
controller.item = {id: 3};
}));
describe('set order', () => {
it(`should set order if the value given is not null`, () => {
controller.order = 1;
expect(controller.order).toEqual(1);
});
});
describe('set clientFk', () => {
it(`should set addressFk to null and clientFk to a value and set addressFk to a value given`, () => {
let filter = {
include: {
relation: 'defaultAddress',
scope: {
fields: 'id'
}
},
where: {id: 2}
};
filter = encodeURIComponent(JSON.stringify(filter));
let response = [
{
defaultAddress: {id: 1}
}
];
$httpBackend.whenGET(`Clients?filter=${filter}`).respond(response);
$httpBackend.expectGET(`Clients?filter=${filter}`);
controller.clientFk = 2;
$httpBackend.flush();
expect(controller.clientFk).toEqual(2);
expect(controller.order.addressFk).toBe(1);
});
});
describe('set addressFk', () => {
it(`should set agencyModeFk property to null and addressFk to a value`, () => {
controller.addressFk = 101;
expect(controller.addressFk).toEqual(101);
expect(controller.order.agencyModeFk).toBe(null);
});
});
describe('getAvailableAgencies()', () => {
it(`should make a query if landed and addressFk exists`, () => {
controller.order.addressFk = 101;
controller.order.landed = 101;
$httpBackend.whenRoute('GET', 'Agencies/landsThatDay')
.respond({data: 1});
controller.getAvailableAgencies();
$httpBackend.flush();
});
});
describe('onSubmit()', () => {
it(`should call createOrder()`, () => {
jest.spyOn(controller, 'createOrder');
controller.onSubmit();
expect(controller.createOrder).toHaveBeenCalledWith();
});
});
describe('createOrder()', () => {
it(`should make a query, call vnApp.showSuccess and $state.go if the response is defined`, () => {
controller.order.landed = 101;
controller.order.addressFk = 101;
controller.order.agencyModeFk = 101;
jest.spyOn(controller.vnApp, 'showSuccess');
jest.spyOn(controller.$state, 'go');
$httpBackend.expect('POST', 'Orders/new', {landed: 101, addressId: 101, agencyModeId: 101}).respond(200, 1);
controller.createOrder();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.$state.go).toHaveBeenCalledWith('order.card.catalog', {id: 1});
});
});
});
});

View File

@ -0,0 +1,55 @@
<div class="vn-w-md">
<vn-card class="vn-pa-lg">
<vn-autocomplete
vn-focus
vn-id="supplier"
url="Suppliers"
label="Supplier"
search-function="{or: [{id: $search}, {name: {like: '%'+ $search +'%'}}]}"
show-field="name"
value-field="id"
ng-model="$ctrl.supplierFk"
order="id"
vn-focus>
<tpl-item>{{id}}: {{name}}</tpl-item>
</vn-autocomplete>
<vn-textfield
vn-one
label="supplierRef"
ng-model="$ctrl.supplierRef">
</vn-textfield>
<vn-date-picker
label="Issued"
ng-model="$ctrl.issued">
</vn-date-picker>
<vn-autocomplete
vn-one
label="Currency"
ng-model="$ctrl.invoiceIn.currencyFk"
url="Currencies"
show-field="code"
value-field="id">
</vn-autocomplete>
<vn-autocomplete
vn-one
vn-id="company"
ng-model="$ctrl.companyId"
data="companies"
show-field="code"
value-field="id"
label="Company">
</vn-autocomplete>
</vn-card>
<vn-button-bar>
<vn-submit
ng-click="$ctrl.onSubmit()"
label="Create">
</vn-submit>
<vn-button
class="cancel"
label="Cancel"
ui-sref="InvoiceIn.index">
</vn-button>
</vn-button-bar>
</div>

View File

@ -0,0 +1,57 @@
import ngModule from '../../../supplier/front/module';
import Section from 'salix/components/section';
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.invoiceIn = {};
}
$onInit() {
if (this.$params && this.$params.supplierFk)
this.supplierFk = this.$params.supplierFk;
}
set invoiceIn(value) {
if (value)
this._invoiceIn = value;
}
get invoiceIn() {
return this._invoiceIn;
}
set supplierFk(value) {
this.invoiceIn.supplierFk = value;
}
get supplierFk() {
return this.invoiceIn.supplierFk;
}
set issued(value) {
this.invoiceIn.landed = value;
}
get issued() {
return this.invoiceIn.issued;
}
get warehouseFk() {
return this.invoiceIn.warehouseFk;
}
onSubmit() {
this.$http.post(`InvoicesIn/new`, this.invoiceIn).then(res => {
this.vnApp.showSuccess(this.$t('Data saved!'));
this.$state.go('invoiceIn.summary', {id: res.data});
});
}
}
ngModule.vnComponent('vnInvoiceInCreate', {
template: require('./index.html'),
controller: Controller
});

View File

@ -0,0 +1,34 @@
import './index.js';
describe('Order', () => {
describe('Component vnOrderCreate', () => {
let $scope;
let controller;
beforeEach(ngModule('order'));
beforeEach(inject(($componentController, $rootScope) => {
$scope = $rootScope.$new();
$scope.card = {createOrder: () => {}};
const $element = angular.element('<vn-order-create></vn-order-create>');
controller = $componentController('vnOrderCreate', {$element, $scope});
}));
describe('onSubmit()', () => {
it(`should call createOrder()`, () => {
jest.spyOn(controller.$.card, 'createOrder');
controller.onSubmit();
expect(controller.$.card.createOrder).toHaveBeenCalledWith();
});
it(`should call go()`, async() => {
jest.spyOn(controller.$state, 'go');
await controller.onSubmit();
expect(controller.$state.go).toHaveBeenCalledWith('order.card.summary', {id: undefined});
});
});
});
});

View File

@ -0,0 +1 @@
a:a

View File

@ -8,3 +8,4 @@ import './descriptor';
import './descriptor-popover'; import './descriptor-popover';
import './summary'; import './summary';
import './basic-data'; import './basic-data';
import './create';

View File

@ -1,5 +1,5 @@
InvoiceIn: Facturas recibidas InvoiceIn: Facturas recibidas
Search invoices in by reference: Buscar facturas recibidas por referencia Search invoices in by reference: Buscar facturas recibidas por referencia
Entries list: Listado de entradas Entries list: Listado de entradas
Invoice list: Listado de entradas Invoice list: Listado de facturas recibidas
InvoiceIn deleted: Factura eliminada InvoiceIn deleted: Factura eliminada

View File

@ -54,6 +54,12 @@
"params": { "params": {
"invoice-in": "$ctrl.invoiceIn" "invoice-in": "$ctrl.invoiceIn"
} }
},
{
"url" : "/create?supplierFk",
"state": "invoiceIn.create",
"component": "vn-invoice-in-create",
"description": "New InvoiceIn"
} }
] ]
} }

View File

@ -56,6 +56,11 @@
</vn-quick-link> </vn-quick-link>
</div> </div>
<div ng-transclude="btnThree"> <div ng-transclude="btnThree">
<vn-quick-link
tooltip="Create invoiceIn"
state="['invoiceIn.create', {supplierFk: $ctrl.id}]"
icon="icon-invoice-in-create">
</vn-quick-link>
</div> </div>
</div> </div>
</slot-body> </slot-body>

View File

@ -4,3 +4,4 @@ Go to client: Ir al cliente
Verified supplier: Proveedor verificado Verified supplier: Proveedor verificado
Unverified supplier: Proveedor no verificado Unverified supplier: Proveedor no verificado
Inactive supplier: Proveedor inactivo Inactive supplier: Proveedor inactivo
Create invoiceIn: Crear factura recibida

74
package-lock.json generated
View File

@ -3597,16 +3597,16 @@
} }
}, },
"browserslist": { "browserslist": {
"version": "4.16.3", "version": "4.16.6",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.3.tgz", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.6.tgz",
"integrity": "sha512-vIyhWmIkULaq04Gt93txdh+j02yX/JzlyhLYbV3YQCn/zvES3JnY7TifHHvvr1w5hTDluNKMkV05cs4vy8Q7sw==", "integrity": "sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"caniuse-lite": "^1.0.30001181", "caniuse-lite": "^1.0.30001219",
"colorette": "^1.2.1", "colorette": "^1.2.2",
"electron-to-chromium": "^1.3.649", "electron-to-chromium": "^1.3.723",
"escalade": "^3.1.1", "escalade": "^3.1.1",
"node-releases": "^1.1.70" "node-releases": "^1.1.71"
} }
}, },
"bser": { "bser": {
@ -3824,9 +3824,9 @@
"integrity": "sha1-FkpUg+Yw+kMh5a8HAg5TGDGyYJs=" "integrity": "sha1-FkpUg+Yw+kMh5a8HAg5TGDGyYJs="
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30001200", "version": "1.0.30001230",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001200.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001230.tgz",
"integrity": "sha512-ic/jXfa6tgiPBAISWk16jRI2q8YfjxHnSG7ddSL1ptrIP8Uy11SayFrjXRAk3NumHpDb21fdTkbTxb/hOrFrnQ==", "integrity": "sha512-5yBd5nWCBS+jWKTcHOzXwo5xzcj4ePE/yjtkZyUV1BTUmrBaA9MRGC+e7mxnqXSA90CmCA8L3eKLaSUkt099IQ==",
"dev": true "dev": true
}, },
"canonical-json": { "canonical-json": {
@ -5031,9 +5031,9 @@
"dev": true "dev": true
}, },
"dns-packet": { "dns-packet": {
"version": "1.3.1", "version": "1.3.4",
"resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-1.3.1.tgz", "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-1.3.4.tgz",
"integrity": "sha512-0UxfQkMhYAUaZI+xrNZOz/as5KgDU0M/fQ9b6SpkyLbk3GEswDi6PADJVaYJradtRVsRIlF1zLyOodbcTCDzUg==", "integrity": "sha512-BQ6F4vycLXBvdrJZ6S3gZewt6rcrks9KBgM9vrhW+knGRqc8uEdT7fuCwloc7nny5xNoMJ17HGH0R/6fpo8ECA==",
"dev": true, "dev": true,
"requires": { "requires": {
"ip": "^1.1.0", "ip": "^1.1.0",
@ -5282,9 +5282,9 @@
"integrity": "sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==" "integrity": "sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA=="
}, },
"electron-to-chromium": { "electron-to-chromium": {
"version": "1.3.687", "version": "1.3.740",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.687.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.740.tgz",
"integrity": "sha512-IpzksdQNl3wdgkzf7dnA7/v10w0Utf1dF2L+B4+gKrloBrxCut+au+kky3PYvle3RMdSxZP+UiCZtLbcYRxSNQ==", "integrity": "sha512-Mi2m55JrX2BFbNZGKYR+2ItcGnR4O5HhrvgoRRyZQlaMGQULqDhoGkLWHzJoshSzi7k1PUofxcDbNhlFrDZNhg==",
"dev": true "dev": true
}, },
"elliptic": { "elliptic": {
@ -8336,9 +8336,9 @@
} }
}, },
"hosted-git-info": { "hosted-git-info": {
"version": "2.8.8", "version": "2.8.9",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
"integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
"dev": true "dev": true
}, },
"hpack.js": { "hpack.js": {
@ -8709,12 +8709,12 @@
"integrity": "sha512-wcGvY31MpFNHIkUcXHHnvrE4IKYlpvitJw5P/1u892gMBAM46muQ+RH7UN1d+Ntnfx5apnOnVY6vcLmrWHOLwg==" "integrity": "sha512-wcGvY31MpFNHIkUcXHHnvrE4IKYlpvitJw5P/1u892gMBAM46muQ+RH7UN1d+Ntnfx5apnOnVY6vcLmrWHOLwg=="
}, },
"httpntlm": { "httpntlm": {
"version": "1.6.1", "version": "1.7.7",
"resolved": "https://registry.npmjs.org/httpntlm/-/httpntlm-1.6.1.tgz", "resolved": "https://registry.npmjs.org/httpntlm/-/httpntlm-1.7.7.tgz",
"integrity": "sha1-rQFScUOi6Hc8+uapb1hla7UqNLI=", "integrity": "sha512-Pv2Rvrz8H0qv1Dne5mAdZ9JegG1uc6Vu5lwLflIY6s8RKHdZQbW39L4dYswSgqMDT0pkJILUTKjeyU0VPNRZjA==",
"requires": { "requires": {
"httpreq": ">=0.4.22", "httpreq": ">=0.4.22",
"underscore": "~1.7.0" "underscore": "~1.12.1"
} }
}, },
"httpreq": { "httpreq": {
@ -13392,9 +13392,9 @@
} }
}, },
"node-releases": { "node-releases": {
"version": "1.1.71", "version": "1.1.72",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.71.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.72.tgz",
"integrity": "sha512-zR6HoT6LrLCRBwukmrVbHv0EpEQjksO6GmFcZQQuCAy139BEsoVKPYnf3jongYW83fAa1torLGYwxxky/p28sg==", "integrity": "sha512-LLUo+PpH3dU6XizX3iVoubUNheF/owjXCZZ5yACDxNnPtgFuludV1ZL3ayK1kVep42Rmm0+R9/Y60NQbZ2bifw==",
"dev": true "dev": true
}, },
"node-sass": { "node-sass": {
@ -16669,6 +16669,22 @@
"requires": { "requires": {
"httpntlm": "1.6.1", "httpntlm": "1.6.1",
"nodemailer-shared": "1.1.0" "nodemailer-shared": "1.1.0"
},
"dependencies": {
"httpntlm": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/httpntlm/-/httpntlm-1.6.1.tgz",
"integrity": "sha1-rQFScUOi6Hc8+uapb1hla7UqNLI=",
"requires": {
"httpreq": ">=0.4.22",
"underscore": "~1.7.0"
}
},
"underscore": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz",
"integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk="
}
} }
}, },
"snakeize": { "snakeize": {
@ -18603,9 +18619,9 @@
} }
}, },
"underscore": { "underscore": {
"version": "1.7.0", "version": "1.12.1",
"resolved": "http://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz",
"integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=" "integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw=="
}, },
"underscore.string": { "underscore.string": {
"version": "3.3.5", "version": "3.3.5",