Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into 232001_test_to_dev
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-05-18 07:17:31 +02:00
commit ba763abc26
13 changed files with 52 additions and 29 deletions

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

@ -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(

View File

@ -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);
});
});

View File

@ -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)

View File

@ -14,9 +14,12 @@
order="changedModel"
auto-load="true">
</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="user-wrapper">
<div class="left">
<vn-avatar class="vn-mt-xs"
ng-class="::{system: !log.user}"
val="{{::log.user ? log.user.nickname : 'System'}}"
@ -33,7 +36,7 @@
<div class="header vn-mb-sm">
<div
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)}}
</div>
<span class="chip" ng-class="::$ctrl.actionsClass[log.action]" translate>

View File

@ -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 {

View File

@ -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"
}
}

View File

@ -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,

View File

@ -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;
}

View File

@ -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,

View File

@ -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
]
));

View File

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

View File

@ -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']