diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 6560240c6..2217aaee2 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -46,7 +46,7 @@ module.exports = Self => { const {data} = await Self.getUserStatus(recipient.name); if (data) { - if (data.status === 'offline' || data.status === 'busy') { + if (data.status === 'offline' || data.status === 'busy') { // Send message to department room const workerDepartment = await models.WorkerDepartment.findById(recipientId, { include: { diff --git a/back/methods/collection/setSaleQuantity.js b/back/methods/collection/setSaleQuantity.js index 95145e9a0..644c44a60 100644 --- a/back/methods/collection/setSaleQuantity.js +++ b/back/methods/collection/setSaleQuantity.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('setSaleQuantity', { + Self.remoteMethod('setSaleQuantity', { description: 'Update sale quantity', accessType: 'WRITE', accepts: [{ @@ -24,11 +24,13 @@ module.exports = Self => { } }); - Self.setSaleQuantity = async ctx => { - const args = ctx.args; + Self.setSaleQuantity = async(saleId, quantity) => { const models = Self.app.models; - const sale = await models.Sale.findById(args.saleId); - return await sale.updateAttribute('quantity', args.quantity); + const sale = await models.Sale.findById(saleId); + return await sale.updateAttributes({ + originalQuantity: sale.quantity, + quantity: quantity + }); }; }; diff --git a/back/methods/collection/spec/setSaleQuantity.spec.js b/back/methods/collection/spec/setSaleQuantity.spec.js index 4e3c8c4aa..5d06a4383 100644 --- a/back/methods/collection/spec/setSaleQuantity.spec.js +++ b/back/methods/collection/spec/setSaleQuantity.spec.js @@ -5,19 +5,12 @@ describe('setSaleQuantity()', () => { const saleId = 30; const newQuantity = 10; - const ctx = { - args: { - saleId: saleId, - quantity: newQuantity - } - }; - const originalSale = await models.Sale.findById(saleId); - await models.Collection.setSaleQuantity(ctx); + await models.Collection.setSaleQuantity(saleId, newQuantity); const updateSale = await models.Sale.findById(saleId); - expect(updateSale.quantity).toBeLessThan(originalSale.quantity); + expect(updateSale.originalQuantity).toEqual(originalSale.quantity); expect(updateSale.quantity).toEqual(newQuantity); }); }); diff --git a/db/changes/10451-april/00-invoiceOut_queue.sql b/db/changes/10451-april/00-invoiceOut_queue.sql deleted file mode 100644 index f60bcab77..000000000 --- a/db/changes/10451-april/00-invoiceOut_queue.sql +++ /dev/null @@ -1,14 +0,0 @@ -create table `vn`.`invoiceOut_queue` -( - invoiceFk int(10) unsigned not null, - queued datetime default now() not null, - printed datetime null, - `status` VARCHAR(50) default '' null, - constraint invoiceOut_queue_pk - primary key (invoiceFk), - constraint invoiceOut_queue_invoiceOut_id_fk - foreign key (invoiceFk) references invoiceOut (id) - on update cascade on delete cascade -) - comment 'Queue for PDF invoicing'; - diff --git a/db/changes/10451-april/00-ClientUnpaid.sql b/db/changes/10461-mother/00-ClientUnpaid.sql similarity index 87% rename from db/changes/10451-april/00-ClientUnpaid.sql rename to db/changes/10461-mother/00-ClientUnpaid.sql index d84fe494a..16deedace 100644 --- a/db/changes/10451-april/00-ClientUnpaid.sql +++ b/db/changes/10461-mother/00-ClientUnpaid.sql @@ -3,8 +3,8 @@ CREATE TABLE `vn`.`clientUnpaid` ( `dated` date NOT NULL, `amount` double DEFAULT 0, PRIMARY KEY (`clientFk`), - CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE + CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE ); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) - VALUES('ClientUnpaid', '*', '*', 'ALLOW', 'ROLE', 'administrative'); \ No newline at end of file + VALUES('ClientUnpaid', '*', '*', 'ALLOW', 'ROLE', 'administrative'); diff --git a/db/changes/10461-mother/00-invoiceOut_queue.sql b/db/changes/10461-mother/00-invoiceOut_queue.sql new file mode 100644 index 000000000..2b9f45e0f --- /dev/null +++ b/db/changes/10461-mother/00-invoiceOut_queue.sql @@ -0,0 +1,8 @@ +CREATE TABLE `vn`.`invoiceOut_queue` ( + `invoiceFk` int(10) unsigned not null, + `queued` datetime default now() not null, + `printed` datetime null, + `status` VARCHAR(50) DEFAULT '' NULL, + CONSTRAINT `invoiceOut_queue_pk` PRIMARY KEY (`invoiceFk`), + CONSTRAINT `invoiceOut_queue_invoiceOut_id_fk` FOREIGN KEY (`invoiceFk`) REFERENCES `vn`.`invoiceOut` (`id`) ON UPDATE CASCADE ON DELETE CASCADE +) comment 'Queue for PDF invoicing'; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 4114f0e73..c69012f41 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1633,51 +1633,59 @@ INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`) INSERT INTO `hedera`.`visit`(`id`, `firstAgentFk`) VALUES - (1, NULL), - (2, NULL), - (3, NULL), - (4, NULL), - (5, NULL), - (6, NULL), - (7, NULL), - (8, NULL), - (9, NULL); + (1, NULL), + (2, NULL), + (3, NULL), + (4, NULL), + (5, NULL), + (6, NULL), + (7, NULL), + (8, NULL), + (9, NULL), + (10, NULL), + (11, NULL); INSERT INTO `hedera`.`visitAgent`(`id`, `visitFk`) VALUES - (1, 1), - (2, 2), - (3, 3), - (4, 4), - (5, 5), - (6, 6), - (7, 7), - (8, 8), - (9, 9); + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5), + (6, 6), + (7, 7), + (8, 8), + (9, 9), + (10, 10), + (11, 11); INSERT INTO `hedera`.`visitAccess`(`id`, `agentFk`, `stamp`) VALUES - (1, 1, CURDATE()), - (2, 2, CURDATE()), - (3, 3, CURDATE()), - (4, 4, CURDATE()), - (5, 5, CURDATE()), - (6, 6, CURDATE()), - (7, 7, CURDATE()), - (8, 8, CURDATE()), - (9, 9, CURDATE()); + (1, 1, CURDATE()), + (2, 2, CURDATE()), + (3, 3, CURDATE()), + (4, 4, CURDATE()), + (5, 5, CURDATE()), + (6, 6, CURDATE()), + (7, 7, CURDATE()), + (8, 8, CURDATE()), + (9, 9, CURDATE()), + (10, 10, CURDATE()), + (11, 11, CURDATE()); INSERT INTO `hedera`.`visitUser`(`id`, `accessFk`, `userFk`, `stamp`) VALUES - (1, 1, 1101, CURDATE()), - (2, 2, 1101, CURDATE()), - (3, 3, 1101, CURDATE()), - (4, 4, 1102, CURDATE()), - (5, 5, 1102, CURDATE()), - (6, 6, 1102, CURDATE()), - (7, 7, 1103, CURDATE()), - (8, 8, 1103, CURDATE()), - (9, 9, 1103, CURDATE()); + (1, 1, 1101, CURDATE()), + (2, 2, 1101, CURDATE()), + (3, 3, 1101, CURDATE()), + (4, 4, 1102, CURDATE()), + (5, 5, 1102, CURDATE()), + (6, 6, 1102, CURDATE()), + (7, 7, 1103, CURDATE()), + (8, 8, 1103, CURDATE()), + (9, 9, 1103, CURDATE()), + (10, 10, 1102, DATE_SUB(CURDATE(), INTERVAL 1 DAY)), + (11, 11, 1103, DATE_SUB(CURDATE(), INTERVAL 1 DAY)); INSERT INTO `hedera`.`userSession`(`created`, `lastUpdate`, `ssid`, `data`, `userVisitFk`) VALUES diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 29176489c..770911d0e 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -101,6 +101,47 @@ export default { email: 'vn-user-mail-forwarding vn-textfield[ng-model="data.forwardTo"]', save: 'vn-user-mail-forwarding vn-submit' }, + accountAcl: { + addAcl: 'vn-acl-index button vn-icon[icon="add"]', + thirdAcl: 'vn-acl-index vn-list> a:nth-child(3)', + deleteThirdAcl: 'vn-acl-index vn-list > a:nth-child(3) > vn-item-section > vn-icon-button[icon="delete"]', + role: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.principalId"]', + model: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.model"]', + property: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.property"]', + accessType: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.accessType"]', + permission: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.permission"]', + save: 'vn-acl-create vn-submit' + }, + accountConnections: { + firstConnection: 'vn-connections vn-list > a:nth-child(1)', + deleteFirstConnection: 'vn-connections vn-list > a:nth-child(1) > vn-item-section > vn-icon-button[icon="exit_to_app"]' + }, + accountAccounts: { + syncRoles: 'vn-account-accounts vn-button[label="Synchronize roles"]', + syncUser: 'vn-account-accounts vn-button[label="Synchronize user"]', + syncAll: 'vn-account-accounts vn-button[label="Synchronize all"]', + syncUserName: 'vn-textfield[ng-model="$ctrl.syncUser"]', + syncUserPassword: 'vn-textfield[ng-model="$ctrl.syncPassword"]', + buttonAccept: 'button[response="accept"]' + }, + accountLdap: { + checkEnable: 'vn-account-ldap vn-check[ng-model="watcher.hasData"]', + server: 'vn-account-ldap vn-textfield[ng-model="$ctrl.config.server"]', + rdn: 'vn-account-ldap vn-textfield[ng-model="$ctrl.config.rdn"]', + password: 'vn-account-ldap vn-textfield[ng-model="$ctrl.config.password"]', + userDn: 'vn-account-ldap vn-textfield[ng-model="$ctrl.config.userDn"]', + groupDn: 'vn-account-ldap vn-textfield[ng-model="$ctrl.config.groupDn"]', + save: 'vn-account-ldap vn-submit' + }, + accountSamba: { + checkEnable: 'vn-account-samba vn-check[ng-model="watcher.hasData"]', + adDomain: 'vn-account-samba vn-textfield[ng-model="$ctrl.config.adDomain"]', + adController: 'vn-account-samba vn-textfield[ng-model="$ctrl.config.adController"]', + adUser: 'vn-account-samba vn-textfield[ng-model="$ctrl.config.adUser"]', + adPassword: 'vn-account-samba vn-textfield[ng-model="$ctrl.config.adPassword"]', + verifyCert: 'vn-account-samba vn-check[ng-model="$ctrl.config.verifyCert"]', + save: 'vn-account-samba vn-submit' + }, clientsIndex: { createClientButton: `vn-float-button` }, diff --git a/e2e/paths/14-account/04_acl.spec.js b/e2e/paths/14-account/04_acl.spec.js new file mode 100644 index 000000000..c400dbfb2 --- /dev/null +++ b/e2e/paths/14-account/04_acl.spec.js @@ -0,0 +1,60 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Account ACL path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('developer', 'account'); + await page.accessToSection('account.acl'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should go to create new acl', async() => { + await page.waitToClick(selectors.accountAcl.addAcl); + await page.waitForState('account.acl.create'); + }); + + it('should create new acl', async() => { + await page.autocompleteSearch(selectors.accountAcl.role, 'sysadmin'); + await page.autocompleteSearch(selectors.accountAcl.model, 'UserAccount'); + await page.autocompleteSearch(selectors.accountAcl.accessType, '*'); + await page.autocompleteSearch(selectors.accountAcl.permission, 'ALLOW'); + await page.waitToClick(selectors.accountAcl.save); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should navigate to edit', async() => { + await page.doSearch(); + await page.waitToClick(selectors.accountAcl.thirdAcl); + await page.waitForState('account.acl.edit'); + }); + + it('should edit the third acl', async() => { + await page.autocompleteSearch(selectors.accountAcl.model, 'Supplier'); + await page.autocompleteSearch(selectors.accountAcl.accessType, 'READ'); + await page.waitToClick(selectors.accountAcl.save); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should delete the third result', async() => { + const result = await page.waitToGetProperty(selectors.accountAcl.thirdAcl, 'innerText'); + await page.waitToClick(selectors.accountAcl.deleteThirdAcl); + await page.waitToClick(selectors.globalItems.acceptButton); + const message = await page.waitForSnackbar(); + const newResult = await page.waitToGetProperty(selectors.accountAcl.thirdAcl, 'innerText'); + + expect(message.text).toContain('ACL removed'); + expect(result).not.toEqual(newResult); + }); +}); diff --git a/e2e/paths/14-account/05_connections.spec.js b/e2e/paths/14-account/05_connections.spec.js new file mode 100644 index 000000000..89b286101 --- /dev/null +++ b/e2e/paths/14-account/05_connections.spec.js @@ -0,0 +1,33 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Account Connections path', () => { + let browser; + let page; + const account = 'sysadmin'; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule(account, 'account'); + await page.accessToSection('account.connections'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should check this is the last connection', async() => { + const firstResult = await page.waitToGetProperty(selectors.accountConnections.firstConnection, 'innerText'); + + expect(firstResult).toContain(account); + }); + + it('should kill this connection and then get redirected to the login page', async() => { + await page.waitToClick(selectors.accountConnections.deleteFirstConnection); + await page.waitToClick(selectors.globalItems.acceptButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Your session has expired, please login again'); + }); +}); diff --git a/e2e/paths/14-account/06_accounts.spec.js b/e2e/paths/14-account/06_accounts.spec.js new file mode 100644 index 000000000..83893e0cf --- /dev/null +++ b/e2e/paths/14-account/06_accounts.spec.js @@ -0,0 +1,49 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Account Accounts path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('sysadmin', 'account'); + await page.accessToSection('account.accounts'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should sync roles', async() => { + await page.waitToClick(selectors.accountAccounts.syncRoles); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Roles synchronized!'); + }); + + it('should sync user', async() => { + await page.waitToClick(selectors.accountAccounts.syncUser); + await page.write(selectors.accountAccounts.syncUserName, 'sysadmin'); + await page.write(selectors.accountAccounts.syncUserPassword, 'nightmare'); + + await page.waitToClick(selectors.accountAccounts.buttonAccept); + + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('User synchronized!'); + }); + + it('should relogin', async() => { + await page.loginAndModule('sysadmin', 'account'); + await page.accessToSection('account.accounts'); + }); + + it('should sync all', async() => { + await page.waitToClick(selectors.accountAccounts.syncAll); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Synchronizing in the background'); + }); +}); diff --git a/e2e/paths/14-account/07_ldap.spec.js b/e2e/paths/14-account/07_ldap.spec.js new file mode 100644 index 000000000..a3b8137d3 --- /dev/null +++ b/e2e/paths/14-account/07_ldap.spec.js @@ -0,0 +1,32 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Account LDAP path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('sysadmin', 'account'); + await page.accessToSection('account.ldap'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should set data and save', async() => { + await page.waitToClick(selectors.accountLdap.checkEnable); + await page.write(selectors.accountLdap.server, '1234'); + await page.write(selectors.accountLdap.rdn, '1234'); + await page.write(selectors.accountLdap.password, 'nightmare'); + await page.write(selectors.accountLdap.userDn, 'sysadmin'); + await page.write(selectors.accountLdap.groupDn, '1234'); + await page.waitToClick(selectors.accountLdap.save); + + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); +}); diff --git a/e2e/paths/14-account/08_samba.spec.js b/e2e/paths/14-account/08_samba.spec.js new file mode 100644 index 000000000..c3db026dc --- /dev/null +++ b/e2e/paths/14-account/08_samba.spec.js @@ -0,0 +1,32 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Account Samba path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('sysadmin', 'account'); + await page.accessToSection('account.samba'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should set data and save', async() => { + await page.waitToClick(selectors.accountSamba.checkEnable); + await page.write(selectors.accountSamba.adDomain, '1234'); + await page.write(selectors.accountSamba.adController, '1234'); + await page.write(selectors.accountSamba.adUser, 'nightmare'); + await page.write(selectors.accountSamba.adPassword, 'sysadmin'); + await page.waitToClick(selectors.accountSamba.verifyCert); + await page.waitToClick(selectors.accountSamba.save); + + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); +}); diff --git a/front/core/components/multi-check/multi-check.js b/front/core/components/multi-check/multi-check.js index 077c93360..041603f13 100644 --- a/front/core/components/multi-check/multi-check.js +++ b/front/core/components/multi-check/multi-check.js @@ -146,16 +146,17 @@ export default class MultiCheck extends FormInput { if (!this.model || !this.model.data) return; const data = this.model.data; - const modelParams = this.model.userParams; const params = { filter: { - modelParams: modelParams, limit: null } }; + if (this.model.userFilter) + Object.assign(params.filter, this.model.userFilter); + if (this.model.userParams) + Object.assign(params, this.model.userParams); this.rows = data.length; - this.$http.get(this.model.url, {params}) .then(res => { this.allRowsCount = res.data.length; diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index c2af9b41e..a3295c47e 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -46,11 +46,13 @@
- - +
+ + +
{ Self.latestBuysFilter = async(ctx, filter, options) => { const myOptions = {}; - if (filter && filter.modelParams) - ctx.args = filter.modelParams; - if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index a4d6f7e83..adeda5e56 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -148,12 +148,12 @@ - {{::buy.packing | dashIfEmpty}} + {{::buy.packing | dashIfEmpty}} - {{::buy.grouping | dashIfEmpty}} + {{::buy.grouping | dashIfEmpty}} {{::buy.quantity}} diff --git a/modules/entry/front/latest-buys/index.js b/modules/entry/front/latest-buys/index.js index 44c29cb11..ec1109b81 100644 --- a/modules/entry/front/latest-buys/index.js +++ b/modules/entry/front/latest-buys/index.js @@ -159,8 +159,22 @@ export default class Controller extends Section { lines: rowsToEdit }; - if (this.checkedDummyCount && this.checkedDummyCount > 0) - data.filter = this.$.model.userParams; + if (this.checkedDummyCount && this.checkedDummyCount > 0) { + const params = {}; + if (this.$.model.userParams) { + const userParams = this.$.model.userParams; + for (let param in userParams) { + let newParam = this.exprBuilder(param, userParams[param]); + if (!newParam) + newParam = {[param]: userParams[param]}; + Object.assign(params, newParam); + } + } + if (this.$.model.userFilter) + Object.assign(params, this.$.model.userFilter.where); + + data.filter = params; + } return this.$http.post('Buys/editLatestBuys', data) .then(() => { diff --git a/modules/monitor/back/methods/sales-monitor/clientsFilter.js b/modules/monitor/back/methods/sales-monitor/clientsFilter.js index 3d8edf608..a08125551 100644 --- a/modules/monitor/back/methods/sales-monitor/clientsFilter.js +++ b/modules/monitor/back/methods/sales-monitor/clientsFilter.js @@ -43,11 +43,9 @@ module.exports = Self => { TIME(v.stamp) AS hour, DATE(v.stamp) AS dated, wtc.workerFk - FROM hedera.userSession s - JOIN hedera.visitUser v ON v.id = s.userVisitFk + FROM hedera.visitUser v JOIN client c ON c.id = v.userFk - LEFT JOIN account.user u ON c.salesPersonFk = u.id - LEFT JOIN worker w ON c.salesPersonFk = w.id + JOIN account.user u ON c.salesPersonFk = u.id LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk AND CURDATE() BETWEEN sc.started AND sc.ended LEFT JOIN workerTeamCollegues wtc @@ -58,7 +56,9 @@ module.exports = Self => { const where = filter.where; where['wtc.workerFk'] = userId; - stmt.merge(conn.makeSuffix(filter)); + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge(`GROUP BY clientFk, v.stamp`); + stmt.merge(conn.makePagination(filter)); return conn.executeStmt(stmt, myOptions); }; diff --git a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js index 3fcc6c91a..bcb37830c 100644 --- a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js +++ b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js @@ -6,12 +6,49 @@ describe('SalesMonitor clientsFilter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 18}}, args: {}}; - const filter = {order: 'dated DESC'}; + + const from = new Date(); + const to = new Date(); + from.setHours(0, 0, 0, 0); + to.setHours(23, 59, 59, 59); + + const filter = { + where: { + 'v.stamp': {between: [from, to]} + } + }; const result = await models.SalesMonitor.clientsFilter(ctx, filter, options); - expect(result.length).toEqual(9); + expect(result.length).toEqual(3); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return the clients web activity filtered', async() => { + const tx = await models.SalesMonitor.beginTransaction({}); + + try { + const options = {transaction: tx}; + const ctx = {req: {accessToken: {userId: 18}}, args: {}}; + const yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + const today = new Date(); + yesterday.setHours(0, 0, 0, 0); + today.setHours(23, 59, 59, 59); + + const filter = { + where: { + 'v.stamp': {between: [yesterday, today]} + } + }; + const result = await models.SalesMonitor.clientsFilter(ctx, filter, options); + + expect(result.length).toEqual(5); await tx.rollback(); } catch (e) { diff --git a/modules/monitor/front/index/clients/index.html b/modules/monitor/front/index/clients/index.html index 35b52fa09..eafc2256e 100644 --- a/modules/monitor/front/index/clients/index.html +++ b/modules/monitor/front/index/clients/index.html @@ -88,8 +88,16 @@ - - +
+ + + + + { function formatDate(date) { let day = date.getDate(); if (day < 10) day = `0${day}`; - let month = date.getMonth(); + + let month = date.getMonth() + 1; if (month < 10) month = `0${month}`; let year = date.getFullYear(); diff --git a/modules/worker/back/methods/worker/deleteAbsence.js b/modules/worker/back/methods/worker/deleteAbsence.js index 72e9243d9..45dc04b2d 100644 --- a/modules/worker/back/methods/worker/deleteAbsence.js +++ b/modules/worker/back/methods/worker/deleteAbsence.js @@ -87,7 +87,7 @@ module.exports = Self => { function formatDate(date) { let day = date.getDate(); if (day < 10) day = `0${day}`; - let month = date.getMonth(); + let month = date.getMonth() + 1; if (month < 10) month = `0${month}`; let year = date.getFullYear(); diff --git a/print/templates/reports/driver-route/sql/routes.sql b/print/templates/reports/driver-route/sql/routes.sql index 3fbe59b0d..4b6f6a318 100644 --- a/print/templates/reports/driver-route/sql/routes.sql +++ b/print/templates/reports/driver-route/sql/routes.sql @@ -14,5 +14,6 @@ FROM route r LEFT JOIN account.user u ON u.id = w.userFk LEFT JOIN agencyMode am ON am.id = r.agencyModeFk LEFT JOIN agency a ON a.id = am.agencyFk - LEFT JOIN supplier s ON s.id = a.supplierFk + LEFT JOIN supplierAgencyTerm sa ON sa.agencyFk = a.id + LEFT JOIN supplier s ON s.id = sa.supplierFk WHERE r.id IN(?) \ No newline at end of file