From fea0db14e2b1d135a84d81ea33a43fa83a4dfc3e Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 30 Aug 2023 13:35:51 +0200 Subject: [PATCH 1/2] fixes #6169 invoiceIn con valores predeterminados --- modules/invoiceIn/front/basic-data/index.js | 27 ++++++++++++-------- modules/invoiceIn/front/create/index.js | 1 + modules/invoiceIn/front/create/index.spec.js | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/modules/invoiceIn/front/basic-data/index.js b/modules/invoiceIn/front/basic-data/index.js index 8747fc4f2..246f1b16f 100644 --- a/modules/invoiceIn/front/basic-data/index.js +++ b/modules/invoiceIn/front/basic-data/index.js @@ -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) { diff --git a/modules/invoiceIn/front/create/index.js b/modules/invoiceIn/front/create/index.js index 186f5d478..885d55359 100644 --- a/modules/invoiceIn/front/create/index.js +++ b/modules/invoiceIn/front/create/index.js @@ -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() { diff --git a/modules/invoiceIn/front/create/index.spec.js b/modules/invoiceIn/front/create/index.spec.js index 93109346c..1b6c903ce 100644 --- a/modules/invoiceIn/front/create/index.spec.js +++ b/modules/invoiceIn/front/create/index.spec.js @@ -26,7 +26,7 @@ describe('InvoiceIn', () => { controller.$onInit(); - expect(controller.invoiceIn).toEqual({}); + expect(controller.invoiceIn).toBeDefined(); }); it(`should define invoiceIn and it's supplierFk when received via params`, () => { From 30c863722cf5d40f28cd7dc6e8fa2c5adde3e4c4 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 30 Aug 2023 14:14:20 +0200 Subject: [PATCH 2/2] fixes #6169 no se necesita tests --- modules/invoiceIn/front/create/index.spec.js | 52 -------------------- 1 file changed, 52 deletions(-) delete mode 100644 modules/invoiceIn/front/create/index.spec.js diff --git a/modules/invoiceIn/front/create/index.spec.js b/modules/invoiceIn/front/create/index.spec.js deleted file mode 100644 index 1b6c903ce..000000000 --- a/modules/invoiceIn/front/create/index.spec.js +++ /dev/null @@ -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(''); - 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).toBeDefined(); - }); - - 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}); - }); - }); - }); -}); -