From bce66899c54dfeb1631242c356747a67950b7124 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Tue, 1 Feb 2022 12:24:11 +0100 Subject: [PATCH 1/6] corrected a typo --- .../entry/back/methods/entry/specs/latestBuysFilter.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); From f7297801f8069ddc3b3686d7862dc669fd12e8fb Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 7 Feb 2022 12:24:08 +0100 Subject: [PATCH 2/6] add due day section --- .../back/methods/invoice-in/summary.js | 18 +++++ .../back/models/invoice-in-due-day.json | 7 ++ modules/invoiceIn/front/dueDay/index.html | 68 +++++++++++++++++++ modules/invoiceIn/front/dueDay/index.js | 31 +++++++++ modules/invoiceIn/front/dueDay/index.spec.js | 44 ++++++++++++ modules/invoiceIn/front/index.js | 1 + modules/invoiceIn/front/locale/es.yml | 2 + modules/invoiceIn/front/routes.json | 16 ++++- modules/invoiceIn/front/summary/index.html | 31 ++++++++- modules/invoiceIn/front/summary/locale/es.yml | 4 +- 10 files changed, 219 insertions(+), 3 deletions(-) create mode 100644 modules/invoiceIn/front/dueDay/index.html create mode 100644 modules/invoiceIn/front/dueDay/index.js create mode 100644 modules/invoiceIn/front/dueDay/index.spec.js 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 From cb21d4db01ad86d9d3beb7ac81f1996149bc8267 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 7 Feb 2022 17:59:40 +0100 Subject: [PATCH 3/6] removed a typo --- modules/claim/front/search-panel/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ Date: Mon, 7 Feb 2022 18:00:23 +0100 Subject: [PATCH 4/6] added groupingMode to getBuys --- modules/entry/back/methods/entry/getBuys.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js index 6da9ec53e..ebb271df1 100644 --- a/modules/entry/back/methods/entry/getBuys.js +++ b/modules/entry/back/methods/entry/getBuys.js @@ -18,7 +18,7 @@ module.exports = Self => { } ], returns: { - type: ['Object'], + type: ['object'], root: true }, http: { @@ -42,6 +42,7 @@ module.exports = Self => { 'stickers', 'packing', 'grouping', + 'groupingMode', 'quantity', 'packageFk', 'weight', From 00f89466751e362c4f276adeabd761d750b313bf Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 7 Feb 2022 18:01:45 +0100 Subject: [PATCH 5/6] feat(entry.buys): each buy groupingMode can now changed --- modules/entry/front/buy/index/index.html | 33 +++++++++++++-- modules/entry/front/buy/index/index.js | 17 ++++++++ modules/entry/front/buy/index/index.spec.js | 47 +++++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-) 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..b9884acb1 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 groupingFk = 1; + const packingFk = 2; + const buy = {id: 999, groupingMode: groupingFk}; + + const query = `Buys/${buy.id}`; + $httpBackend.expectPATCH(query, {groupingMode: packingFk}).respond(200); + controller.toggleGroupingMode(buy, 'packing'); + $httpBackend.flush(); + }); + + it(`should toggle grouping mode from packing to grouping`, () => { + const groupingFk = 1; + const packingFk = 2; + const buy = {id: 999, groupingMode: packingFk}; + + const query = `Buys/${buy.id}`; + $httpBackend.expectPATCH(query, {groupingMode: groupingFk}).respond(200); + controller.toggleGroupingMode(buy, 'grouping'); + $httpBackend.flush(); + }); + + it(`should toggle off the grouping mode if it was packing to packing`, () => { + const noGroupingFk = 0; + const packingFk = 2; + const buy = {id: 999, groupingMode: packingFk}; + + const query = `Buys/${buy.id}`; + $httpBackend.expectPATCH(query, {groupingMode: noGroupingFk}).respond(200); + controller.toggleGroupingMode(buy, 'packing'); + $httpBackend.flush(); + }); + + it(`should toggle off the grouping mode if it was grouping to grouping`, () => { + const noGroupingFk = 0; + const groupingFk = 1; + const buy = {id: 999, groupingMode: groupingFk}; + + const query = `Buys/${buy.id}`; + $httpBackend.expectPATCH(query, {groupingMode: noGroupingFk}).respond(200); + controller.toggleGroupingMode(buy, 'grouping'); + $httpBackend.flush(); + }); + }); }); From 4f1d34069b1a65ee2ef315dcce2a32003358222c Mon Sep 17 00:00:00 2001 From: carlosjr Date: Tue, 8 Feb 2022 09:27:39 +0100 Subject: [PATCH 6/6] corrected some typos --- modules/entry/front/buy/index/index.js | 8 +++--- modules/entry/front/buy/index/index.spec.js | 32 ++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/entry/front/buy/index/index.js b/modules/entry/front/buy/index/index.js index 2f2588cde..6d9ee5760 100644 --- a/modules/entry/front/buy/index/index.js +++ b/modules/entry/front/buy/index/index.js @@ -58,11 +58,11 @@ export default class Controller extends Section { } toggleGroupingMode(buy, mode) { - const groupingFk = 1; - const packingFk = 2; - const grouingMode = mode === 'grouping' ? groupingFk : packingFk; + const grouping = 1; + const packing = 2; + const groupingMode = mode === 'grouping' ? grouping : packing; - const newGroupingMode = buy.groupingMode === grouingMode ? 0 : grouingMode; + const newGroupingMode = buy.groupingMode === groupingMode ? 0 : groupingMode; const params = { groupingMode: newGroupingMode diff --git a/modules/entry/front/buy/index/index.spec.js b/modules/entry/front/buy/index/index.spec.js index b9884acb1..aff52bc80 100644 --- a/modules/entry/front/buy/index/index.spec.js +++ b/modules/entry/front/buy/index/index.spec.js @@ -68,45 +68,45 @@ describe('Entry buy', () => { describe('toggleGroupingMode()', () => { it(`should toggle grouping mode from grouping to packing`, () => { - const groupingFk = 1; - const packingFk = 2; - const buy = {id: 999, groupingMode: groupingFk}; + const grouping = 1; + const packing = 2; + const buy = {id: 999, groupingMode: grouping}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: packingFk}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: packing}).respond(200); controller.toggleGroupingMode(buy, 'packing'); $httpBackend.flush(); }); it(`should toggle grouping mode from packing to grouping`, () => { - const groupingFk = 1; - const packingFk = 2; - const buy = {id: 999, groupingMode: packingFk}; + const grouping = 1; + const packing = 2; + const buy = {id: 999, groupingMode: packing}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: groupingFk}).respond(200); + $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 noGroupingFk = 0; - const packingFk = 2; - const buy = {id: 999, groupingMode: packingFk}; + const noGrouping = 0; + const packing = 2; + const buy = {id: 999, groupingMode: packing}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: noGroupingFk}).respond(200); + $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 noGroupingFk = 0; - const groupingFk = 1; - const buy = {id: 999, groupingMode: groupingFk}; + const noGrouping = 0; + const grouping = 1; + const buy = {id: 999, groupingMode: grouping}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: noGroupingFk}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); controller.toggleGroupingMode(buy, 'grouping'); $httpBackend.flush(); });