diff --git a/back/methods/campaign/latest.js b/back/methods/campaign/latest.js index 6c97d3ce2..a418f1267 100644 --- a/back/methods/campaign/latest.js +++ b/back/methods/campaign/latest.js @@ -25,7 +25,7 @@ module.exports = Self => { const minDate = new Date(); minDate.setFullYear(minDate.getFullYear() - 1); - const where = {dated: {gte: minDate.toJSON().split('T')[0]}}; + const where = {dated: {gte: minDate}}; filter = mergeFilters(filter, {where}); const stmt = new ParameterizedSQL( diff --git a/back/methods/campaign/spec/latest.spec.js b/back/methods/campaign/spec/latest.spec.js index 74d384532..a71849b59 100644 --- a/back/methods/campaign/spec/latest.spec.js +++ b/back/methods/campaign/spec/latest.spec.js @@ -1,6 +1,6 @@ const app = require('vn-loopback/server/server'); -fdescribe('campaign latest()', () => { +describe('campaign latest()', () => { it('should return the campaigns from the last year', async() => { const now = new Date(); const result = await app.models.Campaign.latest(); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 45fff9169..1ea4fa114 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2652,7 +2652,7 @@ INSERT INTO `vn`.`mdbVersion` (`app`, `branchFk`, `version`) INSERT INTO `vn`.`accountingConfig` (`id`, `minDate`, `maxDate`) VALUES - (1, '2022-01-01', '2024-01-01'); + (1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-01-01'), CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)), '-01-01')); INSERT INTO `vn`.`saleGroup` (`userFk`, `parkingFk`, `sectorFk`)