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

Reviewed-on: #1728
Reviewed-by: Juan Ferrer <juan@verdnatura.es>
This commit is contained in:
Javi Gallego 2023-09-11 07:00:20 +00:00
commit 08e97b6a19
3 changed files with 17 additions and 63 deletions

View File

@ -67,17 +67,22 @@ class Controller extends Section {
} }
openCreateDialog() { openCreateDialog() {
const params = {filter: {
where: {code: 'invoiceIn'}
}};
this.$http.get('DmsTypes/findOne', {params}).then(res => {
this.dms = { this.dms = {
reference: null, reference: this.invoiceIn.supplierRef,
warehouseId: null, warehouseId: this.vnConfig.warehouseFk,
companyId: null, companyId: this.vnConfig.companyFk,
dmsTypeId: null, dmsTypeId: res.data.id,
description: null, description: this.invoiceIn.supplier.name,
hasFile: true, hasFile: true,
hasFileAttached: true, hasFileAttached: true,
files: null files: null
}; };
this.$.dmsCreateDialog.show(); this.$.dmsCreateDialog.show();
});
} }
downloadFile(dmsId) { downloadFile(dmsId) {

View File

@ -6,6 +6,7 @@ class Controller extends Section {
this.invoiceIn = {}; this.invoiceIn = {};
if (this.$params && this.$params.supplierFk) if (this.$params && this.$params.supplierFk)
this.invoiceIn.supplierFk = this.$params.supplierFk; this.invoiceIn.supplierFk = this.$params.supplierFk;
this.invoiceIn.issued = Date.vnNew();
} }
get companyFk() { get companyFk() {

View File

@ -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});
});
});
});
});