From 7704256079ea1ebe23df7409a9ebc3806936de81 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 11 May 2023 08:00:49 +0200 Subject: [PATCH 1/4] master to test --- loopback/locale/en.json | 2 +- .../ticket/back/methods/ticket/componentUpdate.js | 1 + modules/ticket/back/methods/ticket/new.js | 2 +- .../ticket/back/methods/ticket/priceDifference.js | 1 + modules/zone/back/methods/agency/getShipped.js | 12 ++++++++---- .../back/methods/agency/specs/getShipped.spec.js | 10 ++++++---- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index cffedd891..e950b981b 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -172,4 +172,4 @@ "Comment added to client": "Comment added to client", "This ticket is already a refund": "This ticket is already a refund", "A claim with that sale already exists": "A claim with that sale already exists" -} \ No newline at end of file +} diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index 531d13b51..b03301204 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -124,6 +124,7 @@ module.exports = Self => { const isDeliveryBoss = await models.VnUser.hasRole(userId, 'deliveryBoss', myOptions); if (!isDeliveryBoss) { const zoneShipped = await models.Agency.getShipped( + ctx, args.landed, args.addressFk, args.agencyModeFk, diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index a5d04bc4c..5f7cf3cb6 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -100,7 +100,7 @@ module.exports = Self => { } if (!args.shipped && args.landed) { - const shippedResult = await models.Agency.getShipped(args.landed, + const shippedResult = await models.Agency.getShipped(ctx, args.landed, address.id, args.agencyModeId, args.warehouseId, myOptions); args.shipped = (shippedResult && shippedResult.shipped) || args.landed; } diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index a0a10d997..16812dcb0 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -81,6 +81,7 @@ module.exports = Self => { const isDeliveryBoss = await models.VnUser.hasRole(userId, 'deliveryBoss', myOptions); if (!isDeliveryBoss) { const zoneShipped = await models.Agency.getShipped( + ctx, args.landed, args.addressId, args.agencyModeId, diff --git a/modules/zone/back/methods/agency/getShipped.js b/modules/zone/back/methods/agency/getShipped.js index 165dd6731..7ef912abd 100644 --- a/modules/zone/back/methods/agency/getShipped.js +++ b/modules/zone/back/methods/agency/getShipped.js @@ -1,7 +1,7 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; module.exports = Self => { - Self.remoteMethod('getShipped', { + Self.remoteMethodCtx('getShipped', { description: 'Returns the first shipped possible for params', accessType: 'READ', accepts: [{ @@ -34,18 +34,22 @@ module.exports = Self => { } }); - Self.getShipped = async(landed, addressFk, agencyModeFk, warehouseFk, options) => { + Self.getShipped = async(ctx, landed, addressFk, agencyModeFk, warehouseFk, options) => { const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); const stmts = []; + const userId = ctx.req.accessToken.userId; + const models = Self.app.models; + const isProductionAssistant = await models.VnUser.hasRole(userId, 'productionAssi', myOptions); stmts.push(new ParameterizedSQL( - `CALL vn.zone_getShipped(?, ?, ?, TRUE)`, [ + `CALL vn.zone_getShipped(?, ?, ?, ?)`, [ landed, addressFk, - agencyModeFk + agencyModeFk, + isProductionAssistant ] )); diff --git a/modules/zone/back/methods/agency/specs/getShipped.spec.js b/modules/zone/back/methods/agency/specs/getShipped.spec.js index c262357a7..b226557fb 100644 --- a/modules/zone/back/methods/agency/specs/getShipped.spec.js +++ b/modules/zone/back/methods/agency/specs/getShipped.spec.js @@ -1,6 +1,9 @@ -const {models} = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('agency getShipped()', () => { + const employeeId = 1; + const ctx = {req: {accessToken: {userId: employeeId}}}; + it('should return a shipment date', async() => { const landed = Date.vnNew(); landed.setDate(landed.getDate() + 1); @@ -12,8 +15,7 @@ describe('agency getShipped()', () => { try { const options = {transaction: tx}; - - const result = await models.Agency.getShipped(landed, addressFk, agencyModeFk, warehouseFk, options); + const result = await models.Agency.getShipped(ctx, landed, addressFk, agencyModeFk, warehouseFk, options); expect(result).toBeDefined(); @@ -37,7 +39,7 @@ describe('agency getShipped()', () => { try { const options = {transaction: tx}; - const result = await models.Agency.getShipped(landed, addressFk, agencyModeFk, warehouseFk, options); + const result = await models.Agency.getShipped(ctx, landed, addressFk, agencyModeFk, warehouseFk, options); expect(result).toBeUndefined(); From 43ab07d954ca0dab5224c44d81e077fd1a3b045e Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 11 May 2023 11:57:13 +0200 Subject: [PATCH 2/4] refs move reports views --- db/changes/231801/01-viewCompany10L.sql | 12 ++++++++++++ .../components/report-footer/report-footer.js | 15 ++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 db/changes/231801/01-viewCompany10L.sql diff --git a/db/changes/231801/01-viewCompany10L.sql b/db/changes/231801/01-viewCompany10L.sql new file mode 100644 index 000000000..335827b42 --- /dev/null +++ b/db/changes/231801/01-viewCompany10L.sql @@ -0,0 +1,12 @@ +-- vn.companyL10n source + +CREATE OR REPLACE +ALGORITHM = UNDEFINED VIEW `vn`.`companyL10n` AS +select + `c`.`id` AS `id`, + ifnull(`ci`.`footnotes`, `c`.`footnotes`) AS `footnotes` +from + (`vn`.`company` `c` +left join `vn`.`companyI18n` `ci` on + (`ci`.`companyFk` = `c`.`id` + and `ci`.`lang` = `util`.`LANG`())); \ No newline at end of file diff --git a/print/core/components/report-footer/report-footer.js b/print/core/components/report-footer/report-footer.js index 0eaab8ce4..077ef0bde 100755 --- a/print/core/components/report-footer/report-footer.js +++ b/print/core/components/report-footer/report-footer.js @@ -4,13 +4,14 @@ const db = require('../../database'); module.exports = { name: 'report-footer', async serverPrefetch() { - this.company = await db.findOne( - `SELECT - ci.footnotes - FROM companyI18n ci - JOIN company c ON c.id = ci.companyFk - WHERE c.code = ? AND ci.lang = (SELECT lang FROM account.user WHERE id = ?)`, - [this.companyCode, this.recipientId]); + this.company = await db.findOne(` + SELECT IFNULL(ci.footnotes, cl.footnotes) as footnotes + FROM company c + LEFT JOIN companyL10n cl ON c.id = cl.id + LEFT JOIN companyI18n ci ON ci.companyFk = cl.id + AND ci.lang = (SELECT lang FROM account.user where id = ?) + WHERE c.code = ?`, + [this.recipientId, this.companyCode]); }, props: ['leftText', 'companyCode', 'recipientId', 'centerText'] From d0c8be5697afb24982fc56d420de327a9da0f630 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 11 May 2023 12:07:14 +0200 Subject: [PATCH 3/4] refs #5517, #5667 Fix crudModel status, log fixes --- front/core/components/crud-model/crud-model.js | 6 +++--- front/core/components/crud-model/index.spec.js | 2 +- front/core/components/data-viewer/index.js | 5 ++--- front/salix/components/log/index.html | 9 ++++++--- front/salix/components/log/style.scss | 4 ++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/front/core/components/crud-model/crud-model.js b/front/core/components/crud-model/crud-model.js index 495a7d2b0..421a79f9b 100644 --- a/front/core/components/crud-model/crud-model.js +++ b/front/core/components/crud-model/crud-model.js @@ -139,7 +139,7 @@ export default class CrudModel extends ModelProxy { filter.limit = this.page * this.limit; } - return this.sendRequest(filter, append, true); + return this.sendRequest(filter, append); } clear() { @@ -231,12 +231,12 @@ export default class CrudModel extends ModelProxy { return params; } - sendRequest(filter, append, loadMore) { + sendRequest(filter, append) { this.cancelRequest(); this.canceler = this.$q.defer(); this.isPaging = append; - if (!loadMore) + if (!append && this.status != 'ready') this.status = 'loading'; let params = Object.assign( diff --git a/front/core/components/crud-model/index.spec.js b/front/core/components/crud-model/index.spec.js index e42476098..7eab80405 100644 --- a/front/core/components/crud-model/index.spec.js +++ b/front/core/components/crud-model/index.spec.js @@ -150,7 +150,7 @@ describe('Component vnCrudModel', () => { controller.loadMore(true); - expect(controller.sendRequest).toHaveBeenCalledWith({'skip': 2}, true, true); + expect(controller.sendRequest).toHaveBeenCalledWith({'skip': 2}, true); }); }); diff --git a/front/core/components/data-viewer/index.js b/front/core/components/data-viewer/index.js index 8d0d94402..b480997da 100644 --- a/front/core/components/data-viewer/index.js +++ b/front/core/components/data-viewer/index.js @@ -7,11 +7,10 @@ export default class DataViewer { } get status() { - if (this.model) - return this.model.status; - if (this.isLoading) return 'loading'; + if (this.model) + return this.model.status; if (!this.data) return 'clear'; if (this.data.length) diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html index b7697a1fd..c6b1ade2a 100644 --- a/front/salix/components/log/index.html +++ b/front/salix/components/log/index.html @@ -14,9 +14,12 @@ order="changedModel" auto-load="true"> - +
-
+
+ title="{{::log.creationDate | date:'dd/MM/yyyy HH:mm:ss'}}"> {{::$ctrl.relativeDate(log.creationDate)}}
diff --git a/front/salix/components/log/style.scss b/front/salix/components/log/style.scss index b78dc3824..381b99039 100644 --- a/front/salix/components/log/style.scss +++ b/front/salix/components/log/style.scss @@ -4,7 +4,7 @@ vn-log { .change { display: flex; - & > .user-wrapper { + & > .left { position: relative; padding-right: 10px; @@ -34,7 +34,7 @@ vn-log { bottom: -8px; } } - &:last-child > .user-wrapper > .line { + &:last-child > .left > .line { display: none; } .detail { From 36205e75beba2bc4a33c39dd57385c32523d7aa8 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 18 May 2023 07:55:43 +0200 Subject: [PATCH 4/4] feat(232201): new version --- CHANGELOG.md | 17 ++++++++++++++++- db/changes/232001/00-createWorker.sql | 10 +++++----- db/changes/{232001 => 232201}/.gitkeep | 0 package-lock.json | 2 +- package.json | 2 +- 5 files changed, 23 insertions(+), 8 deletions(-) rename db/changes/{232001 => 232201}/.gitkeep (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 083e43199..bfff5e53b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [2320.01] - 2023-05-25 +## [2322.01] - 2023-06-08 ### Added - + ### Changed - @@ -18,6 +19,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +## [2320.01] - 2023-05-25 + +### Added +- (Tickets -> Crear Factura) Al facturar se envia automáticamente el pdf al cliente + + +### Changed +- (Trabajadores -> Nuevo trabajador) Los clientes se crean sin 'TR' pero se añade tipo de negocio 'Trabajador' + +### Fixed +- + + + ## [2318.01] - 2023-05-08 ### Added diff --git a/db/changes/232001/00-createWorker.sql b/db/changes/232001/00-createWorker.sql index df08b9df4..3e5af683f 100644 --- a/db/changes/232001/00-createWorker.sql +++ b/db/changes/232001/00-createWorker.sql @@ -1,14 +1,14 @@ -INSERT INTO vn.businessType (code,description) + INSERT INTO `vn`.`businessType` (`code`, `description`) VALUES ('worker','Trabajador'); -ALTER TABLE `vn`.`workerConfig` ADD businessTypeFk varchar(100) NULL +ALTER TABLE `vn`.`workerConfig` ADD businessTypeFk varchar(100) NULL COMMENT 'Tipo de negocio por defecto al dar de alta un trabajador nuevo'; UPDATE `vn`.`workerConfig` SET businessTypeFk = 'worker' WHERE id = 1; - UPDATE client c - JOIN worker w ON w.id = c.id + UPDATE `vn`.`client` c + JOIN `vn`.`worker` w ON w.id = c.id SET c.name = REPLACE(c.name, 'TR ', ''), - c.businessTypeFk = 'worker'; \ No newline at end of file + c.businessTypeFk = 'worker'; diff --git a/db/changes/232001/.gitkeep b/db/changes/232201/.gitkeep similarity index 100% rename from db/changes/232001/.gitkeep rename to db/changes/232201/.gitkeep diff --git a/package-lock.json b/package-lock.json index d373248fd..05ff6466a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.18.01", + "version": "23.22.01", "lockfileVersion": 1, "requires": true, "packages": { diff --git a/package.json b/package.json index 4b4f552ac..d068d6615 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.20.01", + "version": "23.22.01", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0",