Merge pull request 'fixes #6169 invoiceIn con valores predeterminados' (!1728) from 6169---invoice-in-basic-data--dms-refactor into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1728 Reviewed-by: Juan Ferrer <juan@verdnatura.es>
This commit is contained in:
commit
08e97b6a19
|
@ -67,17 +67,22 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
openCreateDialog() {
|
||||
this.dms = {
|
||||
reference: null,
|
||||
warehouseId: null,
|
||||
companyId: null,
|
||||
dmsTypeId: null,
|
||||
description: null,
|
||||
hasFile: true,
|
||||
hasFileAttached: true,
|
||||
files: null
|
||||
};
|
||||
this.$.dmsCreateDialog.show();
|
||||
const params = {filter: {
|
||||
where: {code: 'invoiceIn'}
|
||||
}};
|
||||
this.$http.get('DmsTypes/findOne', {params}).then(res => {
|
||||
this.dms = {
|
||||
reference: this.invoiceIn.supplierRef,
|
||||
warehouseId: this.vnConfig.warehouseFk,
|
||||
companyId: this.vnConfig.companyFk,
|
||||
dmsTypeId: res.data.id,
|
||||
description: this.invoiceIn.supplier.name,
|
||||
hasFile: true,
|
||||
hasFileAttached: true,
|
||||
files: null
|
||||
};
|
||||
this.$.dmsCreateDialog.show();
|
||||
});
|
||||
}
|
||||
|
||||
downloadFile(dmsId) {
|
||||
|
|
|
@ -6,6 +6,7 @@ class Controller extends Section {
|
|||
this.invoiceIn = {};
|
||||
if (this.$params && this.$params.supplierFk)
|
||||
this.invoiceIn.supplierFk = this.$params.supplierFk;
|
||||
this.invoiceIn.issued = Date.vnNew();
|
||||
}
|
||||
|
||||
get companyFk() {
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
import './index.js';
|
||||
import watcher from 'core/mocks/watcher';
|
||||
|
||||
describe('InvoiceIn', () => {
|
||||
describe('Component vnInvoiceInCreate', () => {
|
||||
let controller;
|
||||
let $element;
|
||||
|
||||
beforeEach(ngModule('invoiceIn'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope) => {
|
||||
const $scope = $rootScope.$new();
|
||||
$scope.watcher = watcher;
|
||||
$element = angular.element('<vn-invoice-in-create></vn-invoice-in-create>');
|
||||
controller = $componentController('vnInvoiceInCreate', {$element, $scope});
|
||||
controller.$params = {};
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
$element.remove();
|
||||
});
|
||||
|
||||
describe('onInit()', () => {
|
||||
it(`should defined the controller's invoiceIn property`, () => {
|
||||
expect(controller.invoiceIn).toBeUndefined();
|
||||
|
||||
controller.$onInit();
|
||||
|
||||
expect(controller.invoiceIn).toEqual({});
|
||||
});
|
||||
|
||||
it(`should define invoiceIn and it's supplierFk when received via params`, () => {
|
||||
controller.$params.supplierFk = 'supplierId';
|
||||
|
||||
controller.$onInit();
|
||||
|
||||
expect(controller.invoiceIn.supplierFk).toEqual('supplierId');
|
||||
});
|
||||
});
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it(`should redirect to basic data by calling the $state.go function`, () => {
|
||||
jest.spyOn(controller.$state, 'go');
|
||||
|
||||
controller.onSubmit();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('invoiceIn.card.basicData', {id: 1234});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue