diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index 6efd6603b..dbbc3a46b 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -12,7 +12,7 @@ { } ], returns: { - type: ['Object'], + type: ['object'], root: true }, http: { @@ -42,6 +42,7 @@ module.exports = Self => { 'stickers', 'packing', 'grouping', + 'groupingMode', 'quantity', 'packageFk', 'weight', diff --git a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js index aa8f23a85..7c813ea89 100644 --- a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js +++ b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('Buy latests buys filter()', () => { +describe('Entry latests buys filter()', () => { it('should return the entry matching "search"', async() => { const tx = await models.Buy.beginTransaction({}); const options = {transaction: tx}; @@ -12,7 +12,7 @@ describe('Buy latests buys filter()', () => { } }; - const results = await models.Buy.latestBuysFilter(ctx); + const results = await models.Buy.latestBuysFilter(ctx, options); const firstBuy = results[0]; expect(results.length).toEqual(1); diff --git a/modules/entry/front/buy/index/index.html b/modules/entry/front/buy/index/index.html index bb33b98b3..eaa37c92e 100644 --- a/modules/entry/front/buy/index/index.html +++ b/modules/entry/front/buy/index/index.html @@ -111,17 +111,45 @@ - + + + + + + - + + + + + + @@ -213,7 +241,6 @@ vn-id="item-descriptor" warehouse-fk="$ctrl.vnConfig.warehouseFk"> - { + buy.groupingMode = newGroupingMode; + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + } } ngModule.vnComponent('vnEntryBuyIndex', { diff --git a/modules/entry/front/buy/index/index.spec.js b/modules/entry/front/buy/index/index.spec.js index ee249c3b6..aff52bc80 100644 --- a/modules/entry/front/buy/index/index.spec.js +++ b/modules/entry/front/buy/index/index.spec.js @@ -1,3 +1,4 @@ +/* eslint max-len: ["error", { "code": 150 }]*/ import './index.js'; describe('Entry buy', () => { @@ -64,4 +65,50 @@ describe('Entry buy', () => { expect(controller.buys.length).toEqual(1); }); }); + + describe('toggleGroupingMode()', () => { + it(`should toggle grouping mode from grouping to packing`, () => { + const grouping = 1; + const packing = 2; + const buy = {id: 999, groupingMode: grouping}; + + const query = `Buys/${buy.id}`; + $httpBackend.expectPATCH(query, {groupingMode: packing}).respond(200); + controller.toggleGroupingMode(buy, 'packing'); + $httpBackend.flush(); + }); + + it(`should toggle grouping mode from packing to grouping`, () => { + const grouping = 1; + const packing = 2; + const buy = {id: 999, groupingMode: packing}; + + const query = `Buys/${buy.id}`; + $httpBackend.expectPATCH(query, {groupingMode: grouping}).respond(200); + controller.toggleGroupingMode(buy, 'grouping'); + $httpBackend.flush(); + }); + + it(`should toggle off the grouping mode if it was packing to packing`, () => { + const noGrouping = 0; + const packing = 2; + const buy = {id: 999, groupingMode: packing}; + + const query = `Buys/${buy.id}`; + $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); + controller.toggleGroupingMode(buy, 'packing'); + $httpBackend.flush(); + }); + + it(`should toggle off the grouping mode if it was grouping to grouping`, () => { + const noGrouping = 0; + const grouping = 1; + const buy = {id: 999, groupingMode: grouping}; + + const query = `Buys/${buy.id}`; + $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); + controller.toggleGroupingMode(buy, 'grouping'); + $httpBackend.flush(); + }); + }); }); diff --git a/modules/invoiceIn/back/methods/invoice-in/summary.js b/modules/invoiceIn/back/methods/invoice-in/summary.js index 265aa06e7..acabe29d9 100644 --- a/modules/invoiceIn/back/methods/invoice-in/summary.js +++ b/modules/invoiceIn/back/methods/invoice-in/summary.js @@ -46,6 +46,24 @@ module.exports = Self => { fields: ['withholding'] } }, + { + relation: 'invoiceInDueDay', + scope: { + fields: [ + 'id', + 'invoiceInFk', + 'dueDated', + 'bankFk', + 'amount', + 'foreignValue'], + include: [{ + relation: 'bank', + scope: { + fields: ['bank'] + } + }] + } + }, { relation: 'invoiceInTax', scope: { diff --git a/modules/invoiceIn/back/models/invoice-in-due-day.json b/modules/invoiceIn/back/models/invoice-in-due-day.json index 5a66ecd8b..d2cffc81b 100644 --- a/modules/invoiceIn/back/models/invoice-in-due-day.json +++ b/modules/invoiceIn/back/models/invoice-in-due-day.json @@ -30,6 +30,13 @@ "created": { "type": "date" } + }, + "relations": { + "bank": { + "type": "belongsTo", + "model": "Bank", + "foreignKey": "bankFk" + } } } diff --git a/modules/invoiceIn/front/dueDay/index.html b/modules/invoiceIn/front/dueDay/index.html new file mode 100644 index 000000000..579ef3609 --- /dev/null +++ b/modules/invoiceIn/front/dueDay/index.html @@ -0,0 +1,68 @@ + + + + +
+ + + + + + {{id}}: {{bank}} + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/invoiceIn/front/dueDay/index.js b/modules/invoiceIn/front/dueDay/index.js new file mode 100644 index 000000000..22b697f7e --- /dev/null +++ b/modules/invoiceIn/front/dueDay/index.js @@ -0,0 +1,31 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +class Controller extends Section { + add() { + this.$.model.insert({ + dueDated: new Date(), + bankFk: this.vnConfig.local.bankFk + }); + } + + onSubmit() { + this.$.watcher.check(); + this.$.model.save().then(() => { + this.$.watcher.notifySaved(); + this.$.watcher.updateOriginalData(); + this.card.reload(); + }); + } +} + +ngModule.vnComponent('vnInvoiceInDueDay', { + template: require('./index.html'), + controller: Controller, + require: { + card: '^vnInvoiceInCard' + }, + bindings: { + invoiceIn: '<' + } +}); diff --git a/modules/invoiceIn/front/dueDay/index.spec.js b/modules/invoiceIn/front/dueDay/index.spec.js new file mode 100644 index 000000000..7dddd3bb0 --- /dev/null +++ b/modules/invoiceIn/front/dueDay/index.spec.js @@ -0,0 +1,44 @@ +import './index.js'; +import watcher from 'core/mocks/watcher'; +import crudModel from 'core/mocks/crud-model'; + +describe('InvoiceIn', () => { + describe('Component due day', () => { + let controller; + let $scope; + let vnApp; + + beforeEach(ngModule('invoiceIn')); + + beforeEach(inject(($componentController, $rootScope, _vnApp_) => { + vnApp = _vnApp_; + jest.spyOn(vnApp, 'showError'); + $scope = $rootScope.$new(); + $scope.model = crudModel; + $scope.watcher = watcher; + + const $element = angular.element(''); + controller = $componentController('vnInvoiceInDueDay', {$element, $scope}); + controller.invoiceIn = {id: 1}; + })); + + describe('onSubmit()', () => { + it('should make HTTP POST request to save due day values', () => { + controller.card = {reload: () => {}}; + jest.spyOn($scope.watcher, 'check'); + jest.spyOn($scope.watcher, 'notifySaved'); + jest.spyOn($scope.watcher, 'updateOriginalData'); + jest.spyOn(controller.card, 'reload'); + jest.spyOn($scope.model, 'save'); + + controller.onSubmit(); + + expect($scope.model.save).toHaveBeenCalledWith(); + expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith(); + expect($scope.watcher.check).toHaveBeenCalledWith(); + expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); + expect(controller.card.reload).toHaveBeenCalledWith(); + }); + }); + }); +}); diff --git a/modules/invoiceIn/front/index.js b/modules/invoiceIn/front/index.js index 033c4ad69..18e9d73c2 100644 --- a/modules/invoiceIn/front/index.js +++ b/modules/invoiceIn/front/index.js @@ -9,5 +9,6 @@ import './descriptor-popover'; import './summary'; import './basic-data'; import './tax'; +import './dueDay'; import './create'; import './log'; diff --git a/modules/invoiceIn/front/locale/es.yml b/modules/invoiceIn/front/locale/es.yml index 46415480d..1ebfa8fe2 100644 --- a/modules/invoiceIn/front/locale/es.yml +++ b/modules/invoiceIn/front/locale/es.yml @@ -1,4 +1,5 @@ Add tax: Añadir iva +Add due day: Añadir vencimiento Amounts do not match: La BI no coincide con el vencimiento ni con el total Due day: Vencimiento Entries list: Listado de entradas @@ -9,6 +10,7 @@ InvoiceIn deleted: Factura eliminada Invoice list: Listado de facturas recibidas InvoiceIn booked: Factura contabilizada Remove tax: Quitar iva +Remove due day: Quitar vencimiento Sage tax: Sage iva Sage transaction: Sage transaccion Search invoices in by reference: Buscar facturas recibidas por referencia diff --git a/modules/invoiceIn/front/routes.json b/modules/invoiceIn/front/routes.json index bae496629..0eb6258d3 100644 --- a/modules/invoiceIn/front/routes.json +++ b/modules/invoiceIn/front/routes.json @@ -21,7 +21,11 @@ }, { "state": "invoiceIn.card.tax", - "icon": "icon-lines" + "icon": "icon-tax" + }, + { + "state": "invoiceIn.card.dueDay", + "icon": "icon-calendar" }, { "state": "invoiceIn.card.log", @@ -95,6 +99,16 @@ }, "acl": ["administrative"] }, + { + "url": "/dueDay", + "state": "invoiceIn.card.dueDay", + "component": "vn-invoice-in-due-day", + "description": "Due day", + "params": { + "invoice-in": "$ctrl.invoiceIn" + }, + "acl": ["administrative"] + }, { "url": "/log", "state": "invoiceIn.card.log", diff --git a/modules/invoiceIn/front/summary/index.html b/modules/invoiceIn/front/summary/index.html index a4b7b06ee..ae6d985f8 100644 --- a/modules/invoiceIn/front/summary/index.html +++ b/modules/invoiceIn/front/summary/index.html @@ -58,7 +58,7 @@
- +

+ + +

+ + Due day + +

+ + + + Date + Bank + Amount + Foreign value + + + + + {{::dueDay.dueDated | date:'dd/MM/yyyy'}} + {{::dueDay.bank.bank}} + {{::dueDay.amount | currency: 'EUR':2}} + {{::dueDay.foreignValue}} + + + + + diff --git a/modules/invoiceIn/front/summary/locale/es.yml b/modules/invoiceIn/front/summary/locale/es.yml index fbfa5f140..9349a1069 100644 --- a/modules/invoiceIn/front/summary/locale/es.yml +++ b/modules/invoiceIn/front/summary/locale/es.yml @@ -8,4 +8,6 @@ Accounted date: Fecha contable Doc number: Numero documento Sage withholding: Retención sage Undeductible VAT: Iva no deducible -Do not match: No coinciden \ No newline at end of file +Do not match: No coinciden +VAT: IVA +Due day: Vencimiento \ No newline at end of file