Merge branch 'dev' into 5633-accountShortToStandard
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alexandre Riera 2023-05-18 12:27:15 +00:00
commit 6ccb308b6d
18 changed files with 75 additions and 37 deletions

View File

@ -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/), 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). 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 ### Added
- -
### Changed ### 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 ## [2318.01] - 2023-05-08
### Added ### Added

View File

@ -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`()));

View File

@ -1,14 +1,14 @@
INSERT INTO vn.businessType (code,description) INSERT INTO `vn`.`businessType` (`code`, `description`)
VALUES ('worker','Trabajador'); 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'; COMMENT 'Tipo de negocio por defecto al dar de alta un trabajador nuevo';
UPDATE `vn`.`workerConfig` UPDATE `vn`.`workerConfig`
SET businessTypeFk = 'worker' SET businessTypeFk = 'worker'
WHERE id = 1; WHERE id = 1;
UPDATE client c UPDATE `vn`.`client` c
JOIN worker w ON w.id = c.id JOIN `vn`.`worker` w ON w.id = c.id
SET c.name = REPLACE(c.name, 'TR ', ''), SET c.name = REPLACE(c.name, 'TR ', ''),
c.businessTypeFk = 'worker'; c.businessTypeFk = 'worker';

View File

@ -139,7 +139,7 @@ export default class CrudModel extends ModelProxy {
filter.limit = this.page * this.limit; filter.limit = this.page * this.limit;
} }
return this.sendRequest(filter, append, true); return this.sendRequest(filter, append);
} }
clear() { clear() {
@ -231,12 +231,12 @@ export default class CrudModel extends ModelProxy {
return params; return params;
} }
sendRequest(filter, append, loadMore) { sendRequest(filter, append) {
this.cancelRequest(); this.cancelRequest();
this.canceler = this.$q.defer(); this.canceler = this.$q.defer();
this.isPaging = append; this.isPaging = append;
if (!loadMore) if (!append && this.status != 'ready')
this.status = 'loading'; this.status = 'loading';
let params = Object.assign( let params = Object.assign(

View File

@ -150,7 +150,7 @@ describe('Component vnCrudModel', () => {
controller.loadMore(true); controller.loadMore(true);
expect(controller.sendRequest).toHaveBeenCalledWith({'skip': 2}, true, true); expect(controller.sendRequest).toHaveBeenCalledWith({'skip': 2}, true);
}); });
}); });

View File

@ -7,11 +7,10 @@ export default class DataViewer {
} }
get status() { get status() {
if (this.model)
return this.model.status;
if (this.isLoading) if (this.isLoading)
return 'loading'; return 'loading';
if (this.model)
return this.model.status;
if (!this.data) if (!this.data)
return 'clear'; return 'clear';
if (this.data.length) if (this.data.length)

View File

@ -14,9 +14,12 @@
order="changedModel" order="changedModel"
auto-load="true"> auto-load="true">
</vn-crud-model> </vn-crud-model>
<vn-data-viewer model="model" class="vn-w-md vn-px-sm"> <vn-data-viewer
model="model"
is-loading="model.isLoading"
class="vn-w-md vn-px-sm">
<div class="change vn-mb-sm" ng-repeat="log in $ctrl.logs"> <div class="change vn-mb-sm" ng-repeat="log in $ctrl.logs">
<div class="user-wrapper"> <div class="left">
<vn-avatar class="vn-mt-xs" <vn-avatar class="vn-mt-xs"
ng-class="::{system: !log.user}" ng-class="::{system: !log.user}"
val="{{::log.user ? log.user.nickname : 'System'}}" val="{{::log.user ? log.user.nickname : 'System'}}"
@ -33,7 +36,7 @@
<div class="header vn-mb-sm"> <div class="header vn-mb-sm">
<div <div
class="date text-secondary text-caption" class="date text-secondary text-caption"
title="{{::log.creationDate | date:'dd/MM/yyyy HH:mm'}}"> title="{{::log.creationDate | date:'dd/MM/yyyy HH:mm:ss'}}">
{{::$ctrl.relativeDate(log.creationDate)}} {{::$ctrl.relativeDate(log.creationDate)}}
</div> </div>
<span class="chip" ng-class="::$ctrl.actionsClass[log.action]" translate> <span class="chip" ng-class="::$ctrl.actionsClass[log.action]" translate>

View File

@ -4,7 +4,7 @@ vn-log {
.change { .change {
display: flex; display: flex;
& > .user-wrapper { & > .left {
position: relative; position: relative;
padding-right: 10px; padding-right: 10px;
@ -34,7 +34,7 @@ vn-log {
bottom: -8px; bottom: -8px;
} }
} }
&:last-child > .user-wrapper > .line { &:last-child > .left > .line {
display: none; display: none;
} }
.detail { .detail {

View File

@ -172,4 +172,4 @@
"Comment added to client": "Comment added to client", "Comment added to client": "Comment added to client",
"This ticket is already a refund": "This ticket is already a refund", "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" "A claim with that sale already exists": "A claim with that sale already exists"
} }

View File

@ -124,6 +124,7 @@ module.exports = Self => {
const isDeliveryBoss = await models.VnUser.hasRole(userId, 'deliveryBoss', myOptions); const isDeliveryBoss = await models.VnUser.hasRole(userId, 'deliveryBoss', myOptions);
if (!isDeliveryBoss) { if (!isDeliveryBoss) {
const zoneShipped = await models.Agency.getShipped( const zoneShipped = await models.Agency.getShipped(
ctx,
args.landed, args.landed,
args.addressFk, args.addressFk,
args.agencyModeFk, args.agencyModeFk,

View File

@ -100,7 +100,7 @@ module.exports = Self => {
} }
if (!args.shipped && args.landed) { 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); address.id, args.agencyModeId, args.warehouseId, myOptions);
args.shipped = (shippedResult && shippedResult.shipped) || args.landed; args.shipped = (shippedResult && shippedResult.shipped) || args.landed;
} }

View File

@ -81,6 +81,7 @@ module.exports = Self => {
const isDeliveryBoss = await models.VnUser.hasRole(userId, 'deliveryBoss', myOptions); const isDeliveryBoss = await models.VnUser.hasRole(userId, 'deliveryBoss', myOptions);
if (!isDeliveryBoss) { if (!isDeliveryBoss) {
const zoneShipped = await models.Agency.getShipped( const zoneShipped = await models.Agency.getShipped(
ctx,
args.landed, args.landed,
args.addressId, args.addressId,
args.agencyModeId, args.agencyModeId,

View File

@ -1,7 +1,7 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => { module.exports = Self => {
Self.remoteMethod('getShipped', { Self.remoteMethodCtx('getShipped', {
description: 'Returns the first shipped possible for params', description: 'Returns the first shipped possible for params',
accessType: 'READ', accessType: 'READ',
accepts: [{ 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 = {}; const myOptions = {};
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
const stmts = []; 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( stmts.push(new ParameterizedSQL(
`CALL vn.zone_getShipped(?, ?, ?, TRUE)`, [ `CALL vn.zone_getShipped(?, ?, ?, ?)`, [
landed, landed,
addressFk, addressFk,
agencyModeFk agencyModeFk,
isProductionAssistant
] ]
)); ));

View File

@ -1,6 +1,9 @@
const {models} = require('vn-loopback/server/server'); const models = require('vn-loopback/server/server').models;
describe('agency getShipped()', () => { describe('agency getShipped()', () => {
const employeeId = 1;
const ctx = {req: {accessToken: {userId: employeeId}}};
it('should return a shipment date', async() => { it('should return a shipment date', async() => {
const landed = Date.vnNew(); const landed = Date.vnNew();
landed.setDate(landed.getDate() + 1); landed.setDate(landed.getDate() + 1);
@ -12,8 +15,7 @@ describe('agency getShipped()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const result = await models.Agency.getShipped(ctx, landed, addressFk, agencyModeFk, warehouseFk, options);
const result = await models.Agency.getShipped(landed, addressFk, agencyModeFk, warehouseFk, options);
expect(result).toBeDefined(); expect(result).toBeDefined();
@ -37,7 +39,7 @@ describe('agency getShipped()', () => {
try { try {
const options = {transaction: tx}; 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(); expect(result).toBeUndefined();

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "salix-back", "name": "salix-back",
"version": "23.18.01", "version": "23.22.01",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"packages": { "packages": {

View File

@ -1,6 +1,6 @@
{ {
"name": "salix-back", "name": "salix-back",
"version": "23.20.01", "version": "23.22.01",
"author": "Verdnatura Levante SL", "author": "Verdnatura Levante SL",
"description": "Salix backend", "description": "Salix backend",
"license": "GPL-3.0", "license": "GPL-3.0",

View File

@ -4,13 +4,14 @@ const db = require('../../database');
module.exports = { module.exports = {
name: 'report-footer', name: 'report-footer',
async serverPrefetch() { async serverPrefetch() {
this.company = await db.findOne( this.company = await db.findOne(`
`SELECT SELECT IFNULL(ci.footnotes, cl.footnotes) as footnotes
ci.footnotes FROM company c
FROM companyI18n ci LEFT JOIN companyL10n cl ON c.id = cl.id
JOIN company c ON c.id = ci.companyFk LEFT JOIN companyI18n ci ON ci.companyFk = cl.id
WHERE c.code = ? AND ci.lang = (SELECT lang FROM account.user WHERE id = ?)`, AND ci.lang = (SELECT lang FROM account.user where id = ?)
[this.companyCode, this.recipientId]); WHERE c.code = ?`,
[this.recipientId, this.companyCode]);
}, },
props: ['leftText', 'companyCode', 'recipientId', 'centerText'] props: ['leftText', 'companyCode', 'recipientId', 'centerText']